Skip to content

Commit

Permalink
feat: create and set import buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Corny committed Dec 10, 2024
1 parent a4df16e commit aab97e9
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,28 @@
<i class="fa fa-plus" aria-hidden="true"></i> Ajouter
{{ child0.template['label_art_undef_new'] || '' }}
</button>

<button
mat-raised-button
id="import-btn"
*ngIf="this.canImport"
color="primary"
class="btn-action uppercase float-right"
[routerLink]="['/import']"
[queryParams]="this.getImportQueryParams()"
>
Importer
<mat-icon>file_upload</mat-icon>
</button>
</div>
</div>
<div class="mt-2">
<pnx-monitoring-datatable
*ngIf="childrenDataTable && childrenDataTable[child0.objectType]"
(bEditChanged)="onbEditChanged($event)"
(bEditChanged)="onbEditChanged($event)"
[rows]="childrenDataTable[child0.objectType]['rows']"
[columns]="childrenDataTable[child0.objectType]['columns']"
[frontendModuleMonitoringUrl]="frontendModuleMonitoringUrl"
[columns]="childrenDataTable[child0.objectType]['columns']"
[frontendModuleMonitoringUrl]="frontendModuleMonitoringUrl"
(rowStatusChange)="onSelectedChildren(child0.objectType, $event)"
(onFilter)="onFilterChange(child0.objectType, $event)"
(onDeleteRow)="onDeleteRowChange($event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Component, OnInit, Input, Output, EventEmitter, SimpleChanges } from '@
import { ConfigService } from '../../services/config.service';

import { MonitoringObject } from '../../class/monitoring-object';
import { CruvedStoreService } from '@geonature_common/service/cruved-store.service';
import { ModuleService } from '@geonature/services/module.service';

import { Utils } from '../../utils/utils';
import { TOOLTIPMESSAGEALERT } from '../../constants/guard';
Expand Down Expand Up @@ -41,20 +43,39 @@ export class MonitoringListComponent implements OnInit {
childrenColumns;

queyParamsNewObject = {};
importQueryParams = {}

// medias;
canCreateChild: { [key: string]: boolean } = {};
toolTipNotAllowed: string = TOOLTIPMESSAGEALERT;

public userCruved: any;
public canImport: boolean = false;

constructor(
private _configService: ConfigService,
private _listService: ListService
) {}
private _listService: ListService,
public _cruvedStore: CruvedStoreService,
private _moduleService: ModuleService,
) { }

ngOnInit() {
// Permet d'éviter une double initialisation du composant
// this._configService.init(this.obj.moduleCode).subscribe(() => {
// this.initDataTable();
// });

// get user cruved
const currentModule = this._moduleService.currentModule;
this.userCruved = currentModule.module_objects.MONITORINGS_SITES.cruved;
let cruvedImport: any = {};
if (this._cruvedStore.cruved.IMPORT) {
cruvedImport = this._cruvedStore.cruved.IMPORT.module_objects.IMPORT.cruved;
}
const canCreateImport = cruvedImport.C > 0;
const canCreateMonitoring = this.userCruved.C > 0;

this.canImport = canCreateImport && canCreateMonitoring;
}

initDataTable() {
Expand Down Expand Up @@ -126,6 +147,29 @@ export class MonitoringListComponent implements OnInit {
return nb == nbSelected ? `(${nb})` : `(${nbSelected}/${nb})`;
}

getImportQueryParams() {
if ("observation" in this.obj.children) {
return {
id_module: this.obj.properties['id_module'],
id_base_site: this.obj.properties['id_base_site'], // todo: is it useful ?
id_dataset: this.obj.properties['id_dataset'], // todo: is it useful ?
id_base_visit: this.obj.properties['id_base_visit']
}
}
if ("visit" in this.obj.children) {
return {
id_module: this.obj.parents['module'].properties['id_module'],
id_base_site: this.obj.properties['id_base_site']
}
}
if ("site" in this.obj.children) {
return {
id_module: this.obj.properties['id_module'],
}
}
return {}
}

ngOnChanges(changes: SimpleChanges) {
for (const propName of Object.keys(changes)) {
const chng = changes[propName];
Expand Down

0 comments on commit aab97e9

Please sign in to comment.