| @@ -5,11 +5,11 @@ | |||||
| </div> | </div> | ||||
| <div class="search-toggle" [class.search-box-open]="searchBoxOpen"> | <div class="search-toggle" [class.search-box-open]="searchBoxOpen"> | ||||
| <app-list #listComponent | <app-list #listComponent | ||||
| [getDataFunction]="getDataFunction" | |||||
| [onRowSelectedFunction]="onRowSelected" | |||||
| [listColDefinitions]="listColDefinitions" | |||||
| [showDetailButton]="false" | |||||
| [showPosition]="false" | |||||
| [getDataFunction]="getDataFunction" | |||||
| [onRowSelectedFunction]="onRowSelected" | |||||
| [listColDefinitions]="listColDefinitions" | |||||
| [showDetailButton]="false" | |||||
| [showPosition]="false" | |||||
| > | > | ||||
| </app-list> | </app-list> | ||||
| </div> | </div> | ||||
| @@ -74,7 +74,7 @@ export class SearchSelectComponent implements OnInit, AfterViewInit { | |||||
| clearSearch() { | clearSearch() { | ||||
| this.paragraphRef.nativeElement.textContent = ''; | this.paragraphRef.nativeElement.textContent = ''; | ||||
| this.searchBoxFilled = false; | this.searchBoxFilled = false; | ||||
| this.documentForm.get(this.formId)?.setValue(undefined); | |||||
| this.documentForm.get(this.formId)?.setValue(null); | |||||
| } | } | ||||
| public getPageIndex() { | public getPageIndex() { | ||||
| @@ -1,13 +1,13 @@ | |||||
| <div class="spt-container"> | <div class="spt-container"> | ||||
| <div class="top-btn"> | <div class="top-btn"> | ||||
| <button class="btn btn-primary" (click)="openModalNewDocument()">+ {{ 'basic.new-document' | translate }} | |||||
| <button class="btn btn-primary" (click)="openModalNewEditDocument()">+ {{ 'basic.new-document' | translate }} | |||||
| </button> | </button> | ||||
| </div> | </div> | ||||
| <app-list #listComponent | <app-list #listComponent | ||||
| [getDataFunction]="getDataFunction" | [getDataFunction]="getDataFunction" | ||||
| [onSortFunction]="onSortChange" | [onSortFunction]="onSortChange" | ||||
| [onDownloadFunction]="navigateToDocumentFile" | [onDownloadFunction]="navigateToDocumentFile" | ||||
| [onEditFunction]="openModalEditDocument" | |||||
| [onEditFunction]="openModalNewEditDocument" | |||||
| [listColDefinitions]="listColDefinitions" | [listColDefinitions]="listColDefinitions" | ||||
| [searchable]="true" | [searchable]="true" | ||||
| [showDetailButton]="false" | [showDetailButton]="false" | ||||
| @@ -123,23 +123,15 @@ export class DocumentListComponent implements OnInit, AfterViewInit { | |||||
| window.open(element.documentUrl?.toString(), '_blank'); | window.open(element.documentUrl?.toString(), '_blank'); | ||||
| } | } | ||||
| openModalNewDocument() { | |||||
| let postInputs: any = {}; | |||||
| let document: DocumentJsonld = {} as DocumentJsonld; | |||||
| if (this.partner !== undefined) { | |||||
| document.partnerIri = this.partner?.id; | |||||
| postInputs['partner'] = this.partner; | |||||
| } | |||||
| if (this.product !== undefined) { | |||||
| document.productIri = this.product?.id; | |||||
| postInputs['product'] = this.product; | |||||
| } | |||||
| postInputs['document'] = document; | |||||
| this.appHelperService.openModal(NewDocumentComponent, postInputs, this.listComponent.getData); | |||||
| openModalNewEditDocument = (element?: DocumentJsonld) => { | |||||
| const documentInputs: any = { | |||||
| partner: this.partner, | |||||
| product: this.product, | |||||
| document: element || { | |||||
| partnerIri: this.partner?.id, | |||||
| productIri: this.product?.id | |||||
| } as DocumentJsonld | |||||
| }; | |||||
| this.appHelperService.openModal(NewDocumentComponent, documentInputs, this.listComponent.getData); | |||||
| } | } | ||||
| openModalEditDocument = (element: DocumentJsonld) => { | |||||
| this.appHelperService.openModal(NewDocumentComponent, { 'document': element }, this.listComponent.getData); | |||||
| } | |||||
| } | } | ||||
| @@ -14,8 +14,8 @@ | |||||
| <div class="mb-3"> | <div class="mb-3"> | ||||
| <label for="partner" class="form-label">{{ 'form.partner' | translate }}:</label> | <label for="partner" class="form-label">{{ 'form.partner' | translate }}:</label> | ||||
| <ng-container *ngIf="document.partnerIri === null || document.partnerIri === undefined"> | |||||
| <app-search-select #partnerSearchSelect *ngIf="document.id === null || document.id === undefined" | |||||
| <ng-container *ngIf="partner === undefined"> | |||||
| <app-search-select #partnerSearchSelect | |||||
| [formId]="'partnerIri'" | [formId]="'partnerIri'" | ||||
| [formLabelLangKey]="'form.partner'" | [formLabelLangKey]="'form.partner'" | ||||
| [documentForm]="documentForm" | [documentForm]="documentForm" | ||||
| @@ -26,19 +26,16 @@ | |||||
| > | > | ||||
| </app-search-select> | </app-search-select> | ||||
| <input type="hidden" id="partner" formControlName="partner" | <input type="hidden" id="partner" formControlName="partner" | ||||
| *ngIf="document.id === null || document.id === undefined"/> | |||||
| /> | |||||
| </ng-container> | </ng-container> | ||||
| <input type="text" | |||||
| *ngIf="document.partnerIri !== null && document.partnerIri !== undefined && (document.id === null || document.id === undefined)" | |||||
| class="form-control" disabled value="{{partner.name}}"/> | |||||
| <input type="text" *ngIf="document.id !== null && document.id !== undefined" class="form-control" | |||||
| <input type="text" class="form-control" *ngIf="partner !== undefined" | |||||
| disabled value="{{partner?.name}}"/> | disabled value="{{partner?.name}}"/> | ||||
| </div> | </div> | ||||
| <div class="mb-3"> | <div class="mb-3"> | ||||
| <label for="product" class="form-label">{{ 'form.product' | translate }}:</label> | <label for="product" class="form-label">{{ 'form.product' | translate }}:</label> | ||||
| <ng-container *ngIf="document.productIri === null || document.productIri === undefined"> | |||||
| <app-search-select #productSearchSelect *ngIf="document.id === null || document.id === undefined" | |||||
| <ng-container *ngIf="product === undefined"> | |||||
| <app-search-select #productSearchSelect | |||||
| [formId]="'productIri'" | [formId]="'productIri'" | ||||
| [formLabelLangKey]="'form.product'" | [formLabelLangKey]="'form.product'" | ||||
| [documentForm]="documentForm" | [documentForm]="documentForm" | ||||
| @@ -48,13 +45,9 @@ | |||||
| [listColDefinitions]="SearchSelectComponent.getDefaultColDefProducts()" | [listColDefinitions]="SearchSelectComponent.getDefaultColDefProducts()" | ||||
| > | > | ||||
| </app-search-select> | </app-search-select> | ||||
| <input type="hidden" id="product" formControlName="product" | |||||
| *ngIf="document.id === null || document.id === undefined"/> | |||||
| <input type="hidden" id="product" formControlName="product"/> | |||||
| </ng-container> | </ng-container> | ||||
| <input type="text" | |||||
| *ngIf="document.productIri !== null && document.productIri !== undefined && (document.id === null || document.id === undefined)" | |||||
| class="form-control" disabled value="{{product.name}}"/> | |||||
| <input type="text" *ngIf="document.id !== null && document.id !== undefined" class="form-control" | |||||
| <input type="text" class="form-control" *ngIf="product !== undefined" | |||||
| disabled value="{{product?.name}}"/> | disabled value="{{product?.name}}"/> | ||||
| </div> | </div> | ||||
| @@ -44,7 +44,6 @@ export class NewDocumentComponent implements OnInit, AfterViewInit { | |||||
| ngOnInit(): void { | ngOnInit(): void { | ||||
| this.documentForm = FormGroupInitializer.initFormGroup(this.documentForm, this.document); | this.documentForm = FormGroupInitializer.initFormGroup(this.documentForm, this.document); | ||||
| console.log(this.document); | |||||
| } | } | ||||
| ngAfterViewInit(): void { | ngAfterViewInit(): void { | ||||