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
18 changes: 17 additions & 1 deletion src/controllers/fichas-tombos-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ export default function fichaTomboController(request, response, next) {
{
model: Vegetacao,
},
{
model: FaseSucessional,
},
{
as: 'local_coleta',
model: LocalColeta,
Expand All @@ -158,6 +161,18 @@ export default function fichaTomboController(request, response, next) {
model: ColetorComplementar,
as: 'coletor_complementar',
},
{
required: false,
model: Cidade,
include: {
model: Estado,
attributes: ['id', 'nome', 'sigla', 'pais_id'],
include: {
as: 'pais',
model: Pais,
},
},
},
];

const where = {
Expand Down Expand Up @@ -239,7 +254,7 @@ export default function fichaTomboController(request, response, next) {
const coletores = `${!!tombo?.coletore?.nome !== false ? tombo?.coletore?.nome?.concat(' ') : ''}${tombo?.coletor_complementar ? tombo.coletor_complementar?.complementares : ''}`;

const localColeta = tombo?.local_coleta;
const cidade = localColeta?.cidade || '';
const cidade = localColeta?.cidade || tombo?.cidade || '';
const estado = cidade?.estado || '';
const pais = estado?.pais || '';

Expand Down Expand Up @@ -295,6 +310,7 @@ export default function fichaTomboController(request, response, next) {

relevo: tombo?.relevo?.nome || '',
vegetacao: tombo?.vegetaco?.nome || '',
fase_sucessional: tombo?.fase_sucessional?.nome || '',

familia: tombo.familia,
imprimir: request.params.imprimir_cod,
Expand Down
4 changes: 2 additions & 2 deletions src/database/migration/20260408200000_cria_view_splinker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function run(knex: Knex): Promise<void> {
COALESCE(t.data_coleta_dia::text, '') AS "DayCollected",
COALESCE(t.data_coleta_mes::text, '') AS "MonthCollected",
COALESCE(t.data_coleta_ano::text, '') AS "YearCollected",
(COALESCE(col.nome, '') || COALESCE(cc.complementares, '')) AS "Collector"
(COALESCE(col.nome, '') ||' ' || COALESCE(cc.complementares, '')) AS "Collector",
COALESCE(t.numero_coleta::text, '') AS "CollectorNumber",
'' AS "Continent",
COALESCE(p.nome, '') AS "Country",
Expand Down Expand Up @@ -76,7 +76,7 @@ export async function run(knex: Knex): Promise<void> {
) AS "Notes"
FROM tombos t
LEFT JOIN locais_coleta lc ON t.local_coleta_id = lc.id
LEFT JOIN cidades c ON lc.cidade_id = c.id
LEFT JOIN cidades c ON t.cidade_id = c.id
LEFT JOIN estados est ON c.estado_id = est.id
LEFT JOIN paises p ON est.pais_id = p.id
LEFT JOIN familias f ON t.familia_id = f.id
Expand Down
10 changes: 6 additions & 4 deletions src/views/ficha-tombo.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,12 @@
<div>
<b class="fs-14">Local de Coleta:</b>

<% if (localColeta && localColeta.descricao) { %>
<% const temDescricaoLocal = localColeta && localColeta.descricao; %>
<% if (temDescricaoLocal) { %>
<%- localColeta.descricao %>
<% } %>
<% if (cidade && cidade.nome) { %>
- <%- cidade.nome %>
<%- temDescricaoLocal ? ' - ' : '' %><%- cidade.nome %>
<% } %>
<% if (cidade && cidade.estado) { %>
- <%- cidade.estado.nome %>
Expand Down Expand Up @@ -355,8 +356,9 @@
<% if (tombo && tombo.altitude) { %>
- Altitude: <%- tombo.altitude %>m
<% } %>
<% if (localColeta && localColeta.fase_sucessional) { %>
- Fase sucessional: <%- localColeta.fase_sucessional.nome %>
<% const faseSucessionalNome = (localColeta && localColeta.fase_sucessional && localColeta.fase_sucessional.nome) || fase_sucessional; %>
<% if (faseSucessionalNome) { %>
- Fase sucessional: <%- faseSucessionalNome %>
<% } %>
</div>

Expand Down
Loading