Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPORT] feat: create and set import buttons #387

Open
wants to merge 7 commits into
base: feat/import-monitoring
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ button:disabled {
cursor: not-allowed;
text-decoration: none;
}

#import-btn {
margin: 0 0.5rem;
}
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]="[importRoute]"
[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,7 @@ 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 { Utils } from '../../utils/utils';
import { TOOLTIPMESSAGEALERT } from '../../constants/guard';
Expand Down Expand Up @@ -41,20 +42,39 @@ export class MonitoringListComponent implements OnInit {
childrenColumns;

queyParamsNewObject = {};
importQueryParams = {};

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

public canImport: boolean = false;

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

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

// get user cruved
const userCruved =
this._cruvedStore.cruved[this.obj.moduleCode].module_objects.MONITORINGS_SITES.cruved;

let cruvedImport: any = {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let cruvedImport: any = {};
let cruvedImport: any = {C:0};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

traité.

if (this._cruvedStore.cruved.IMPORT) {
cruvedImport = this._cruvedStore.cruved.IMPORT.module_objects.IMPORT.cruved;
}
this.canImport = cruvedImport.C > 0 && userCruved.C > 0;
}

get importRoute(): string {
return `/import/${this.obj.moduleCode}/process/upload`;
}

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

getImportQueryParams() {
if ('observation' in this.obj.children) {
return {
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_base_site: this.obj.properties['id_base_site'],
};
}
if ('site' in this.obj.children) {
return {};
}
return {};
}

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