Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/controllers/pendencias-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,10 @@
updateTombo.nomes_populares = alteracao.nomes_populares;
}

if (alteracao.unicata !== undefined) {
updateTombo.unicata = alteracao.unicata;
}

if (alteracao.numero_coleta !== undefined) {
updateTombo.numero_coleta = alteracao.numero_coleta;
}
Expand Down Expand Up @@ -1370,7 +1374,7 @@

if (nomesCientificosPartes.length > 0) {
updateTombo.nome_cientifico = nomesCientificosPartes.join(' ');
} else if (Object.keys(updateTombo).some(key => key.includes('familia_id') || key.includes('genero_id') || key.includes('especie_id') || key.includes('sub_especie_id') || key.includes('variedade_id'))) {

Check warning on line 1377 in src/controllers/pendencias-controller.js

View workflow job for this annotation

GitHub Actions / lint

This line has a length of 207. Maximum allowed is 150
updateTombo.nome_cientifico = null;
}

Expand Down Expand Up @@ -1755,21 +1759,21 @@
if (objetoAlterado.genero_nome) parametros.genero = objetoAlterado.genero_nome;
if (objetoAlterado.especie_nome) parametros.especie = objetoAlterado.especie_nome;

if (objetoAlterado.familia_id) parametros.familia = await Familia.findOne({ where: { id: objetoAlterado.familia_id }, raw: true, nest: true });

Check warning on line 1762 in src/controllers/pendencias-controller.js

View workflow job for this annotation

GitHub Actions / lint

This line has a length of 151. Maximum allowed is 150
if (objetoAlterado.subfamilia_id) parametros.subfamilia = await Subfamilia.findOne({ where: { id: objetoAlterado.subfamilia_id }, raw: true, nest: true });

Check warning on line 1763 in src/controllers/pendencias-controller.js

View workflow job for this annotation

GitHub Actions / lint

This line has a length of 163. Maximum allowed is 150
if (objetoAlterado.genero_id) parametros.genero = await Genero.findOne({ where: { id: objetoAlterado.genero_id }, raw: true, nest: true });
if (objetoAlterado.especie_id) parametros.especie = await Especie.findOne({ where: { id: objetoAlterado.especie_id }, raw: true, nest: true });

Check warning on line 1765 in src/controllers/pendencias-controller.js

View workflow job for this annotation

GitHub Actions / lint

This line has a length of 151. Maximum allowed is 150

if (objetoAlterado.identificadores) parametros.identificador = await Usuario.findOne({ where: { id: objetoAlterado.identificadores }, raw: true, nest: true });

Check warning on line 1767 in src/controllers/pendencias-controller.js

View workflow job for this annotation

GitHub Actions / lint

This line has a length of 167. Maximum allowed is 150
if (objetoAlterado.fase_sucessional_id) parametros.faseSucessional = await FaseSucessional.findOne({ where: { numero: objetoAlterado.fase_sucessional_id }, raw: true, nest: true });

Check warning on line 1768 in src/controllers/pendencias-controller.js

View workflow job for this annotation

GitHub Actions / lint

This line has a length of 189. Maximum allowed is 150
if (objetoAlterado.vegetacao_id) parametros.vegetacao = await Vegetacao.findOne({ where: { id: objetoAlterado.vegetacao_id }, raw: true, nest: true });

Check warning on line 1769 in src/controllers/pendencias-controller.js

View workflow job for this annotation

GitHub Actions / lint

This line has a length of 159. Maximum allowed is 150
if (objetoAlterado.relevo_id) parametros.relevo = await Relevo.findOne({ where: { id: objetoAlterado.relevo_id }, raw: true, nest: true });
if (objetoAlterado.solo_id) parametros.solo = await Solo.findOne({ where: { id: objetoAlterado.solo_id }, raw: true, nest: true });
if (objetoAlterado.cidade_id) parametros.cidade = await Cidade.findOne({ where: { id: objetoAlterado.cidade_id }, raw: true, nest: true });
if (objetoAlterado.tipo_id) parametros.tipo = await Tipo.findOne({ where: { id: objetoAlterado.tipo_id }, raw: true, nest: true });
if (objetoAlterado.entidade_id) parametros.entidade = await Herbario.findOne({ where: { id: objetoAlterado.entidade_id }, raw: true, nest: true });

Check warning on line 1774 in src/controllers/pendencias-controller.js

View workflow job for this annotation

GitHub Actions / lint

This line has a length of 155. Maximum allowed is 150
if (objetoAlterado.variedade_id) parametros.variedade = await Variedade.findOne({ where: { id: objetoAlterado.variedade_id }, raw: true, nest: true });

Check warning on line 1775 in src/controllers/pendencias-controller.js

View workflow job for this annotation

GitHub Actions / lint

This line has a length of 159. Maximum allowed is 150
if (objetoAlterado.sub_especie_id) parametros.subespecie = await Subespecie.findOne({ where: { id: objetoAlterado.sub_especie_id }, raw: true, nest: true });

Check warning on line 1776 in src/controllers/pendencias-controller.js

View workflow job for this annotation

GitHub Actions / lint

This line has a length of 165. Maximum allowed is 150

const tombo = await Tombo.findOne({
where: { hcf: alteracao.dataValues.tombo_hcf, ativo: true },
Expand Down
9 changes: 9 additions & 0 deletions src/controllers/tombos-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const cadastro = (request, response, next) => {
coletor_complementar,
colecoes_anexas: colecoesAnexas,
observacoes,
unicata,
} = request.body.json;
let tomboCriado = null;

Expand Down Expand Up @@ -283,6 +284,9 @@ export const cadastro = (request, response, next) => {
if (observacoes) {
jsonTombo.observacao = observacoes;
}
if (unicata !== undefined) {
jsonTombo.unicata = unicata;
}
if (principal.nome_popular) {
jsonTombo.nomes_populares = principal.nome_popular;
}
Expand Down Expand Up @@ -518,6 +522,9 @@ function alteracaoCuradorouOperador(request, response, transaction) {
const descricao = body?.paisagem?.descricao;
if (descricao !== undefined) update.descricao = descricao;

const unicata = body?.unicata;
if (unicata !== undefined) update.unicata = unicata;

const faseSucessionalId = body?.paisagem?.fase_sucessional_id;
if (faseSucessionalId !== undefined) update.fase_sucessional_id = faseSucessionalId;

Expand Down Expand Up @@ -988,6 +995,7 @@ export const obterTombo = async (request, response, next) => {
'data_identificacao_mes',
'data_identificacao_ano',
'descricao',
'unicata',
],
include: [
{
Expand Down Expand Up @@ -1193,6 +1201,7 @@ export const obterTombo = async (request, response, next) => {
tipo: tombo.colecoes_anexa !== null ? tombo.colecoes_anexa?.tipo : '',
observacao: tombo.colecoes_anexa !== null ? tombo.colecoes_anexa?.observacoes : '',
},
unicata: tombo.unicata ?? null,
};
let dataCol = '';
let dataIdent = '';
Expand Down
4 changes: 4 additions & 0 deletions src/models/Tombo.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ export default (Sequelize, DataTypes) => {
type: DataTypes.TEXT,
allowNull: true,
},
unicata: {
type: DataTypes.BOOLEAN,
allowNull: true,
},
};

const options = {
Expand Down
7 changes: 7 additions & 0 deletions src/validators/tombo-alteracao.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,11 @@ export default {
options: [{ min: 3 }],
},
},
'json.unicata': {
in: 'body',
optional: {
options: { nullable: true },
},
isBoolean: true,
},
};
5 changes: 5 additions & 0 deletions src/validators/tombo-cadastro.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,9 @@ export default {
options: [{ min: 3 }],
},
},
'json.unicata': {
in: 'body',
optional: true,
isBoolean: true,
},
};