Skip to content

Commit

Permalink
add message when no entity data ready to import
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquesfize committed Jan 22, 2025
1 parent 90d2c5b commit 9241432
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 4 additions & 2 deletions backend/geonature/core/imports/routes/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,9 @@ def preview_valid_data(scope, imprt):
)
columns = [{"prop": field.dest_column, "name": field.name_field} for field in fields]

id_field = entity.unique_column.dest_field
id_field = (
entity.unique_column.dest_field if entity.unique_column.dest_field in fields else None
)
data_fields_query = [transient_table.c[field.dest_field] for field in fields]

query = select(*data_fields_query).where(
Expand All @@ -507,7 +509,7 @@ def count_select(query_cte):
count_ = "*"
# if multiple entities and the entity has a unique column we base the count on the unique column

if entity.unique_column and len(entities) > 1:
if entity.unique_column and len(entities) > 1 and id_field:
count_ = func.distinct(query_cte.c[id_field])
return count_

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ <h5 class="card-title mb-0">
label="{{ entityPreview.entity.label }}"
>
<ngx-datatable
*ngIf="tableReady"
*ngIf="tableReady && entityPreview.valid_data.length > 0"
#table
class="material striped"
[rows]="entityPreview.valid_data"
Expand All @@ -124,6 +124,15 @@ <h5 class="card-title mb-0">
[limit]="15"
[selectionType]="single"
></ngx-datatable>
<ng-container *ngIf="entityPreview.valid_data.length === 0">
<div
class="alert alert-info mt-3"
role="alert"
>
Aucun(e) {{ entityPreview.entity.label.toLowerCase() }}
valide n'a été trouvée
</div>
</ng-container>
</mat-tab>
</mat-tab-group>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ export class FieldMappingService {

this.currentFieldMappingSubscription = this.currentFieldMapping.subscribe((fieldMapping) => {
this.fieldMappingStatus.unmapped = new Set(this.sourceFields);
this.fieldMappingStatus.mapped = new Set();

if (fieldMapping === null) {
this.mappingFormGroup.reset();
Expand Down

0 comments on commit 9241432

Please sign in to comment.