[DURACOM-208] add showAdd flag in vocabulary-treeview-modal.component

This commit is contained in:
Giuseppe Digilio
2024-01-11 13:34:26 +01:00
parent 1fd0d35d9b
commit 585c49caef
4 changed files with 16 additions and 13 deletions

View File

@@ -11,6 +11,7 @@
[preloadLevel]="preloadLevel" [preloadLevel]="preloadLevel"
[selectedItems]="selectedItems" [selectedItems]="selectedItems"
[multiSelect]="multiSelect" [multiSelect]="multiSelect"
[showAdd]="showAdd"
(select)="onSelect($event)"> (select)="onSelect($event)">
</ds-vocabulary-treeview> </ds-vocabulary-treeview>
</div> </div>

View File

@@ -36,6 +36,11 @@ export class VocabularyTreeviewModalComponent implements OnInit {
*/ */
@Input() multiSelect = false; @Input() multiSelect = false;
/**
* A boolean representing if to show the add button or not
*/
@Input() showAdd = true;
/** /**
* Contain a descriptive message for this vocabulary retrieved from i18n files * Contain a descriptive message for this vocabulary retrieved from i18n files
*/ */

View File

@@ -2,7 +2,6 @@ import { FlatTreeControl } from '@angular/cdk/tree';
import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges } from '@angular/core'; import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges } from '@angular/core';
import { Observable, Subscription } from 'rxjs'; import { Observable, Subscription } from 'rxjs';
import { TranslateService } from '@ngx-translate/core';
import { VocabularyEntryDetail } from '../../../core/submission/vocabularies/models/vocabulary-entry-detail.model'; import { VocabularyEntryDetail } from '../../../core/submission/vocabularies/models/vocabulary-entry-detail.model';
import { hasValue, isEmpty, isNotEmpty } from '../../empty.util'; import { hasValue, isEmpty, isNotEmpty } from '../../empty.util';
@@ -13,7 +12,6 @@ import { PageInfo } from '../../../core/shared/page-info.model';
import { VocabularyEntry } from '../../../core/submission/vocabularies/models/vocabulary-entry.model'; import { VocabularyEntry } from '../../../core/submission/vocabularies/models/vocabulary-entry.model';
import { VocabularyTreeFlattener } from './vocabulary-tree-flattener'; import { VocabularyTreeFlattener } from './vocabulary-tree-flattener';
import { VocabularyTreeFlatDataSource } from './vocabulary-tree-flat-data-source'; import { VocabularyTreeFlatDataSource } from './vocabulary-tree-flat-data-source';
import { VocabularyService } from '../../../core/submission/vocabularies/vocabulary.service';
import { AlertType } from '../../alert/alert-type'; import { AlertType } from '../../alert/alert-type';
import { FormFieldMetadataValueObject } from '../builder/models/form-field-metadata-value.model'; import { FormFieldMetadataValueObject } from '../builder/models/form-field-metadata-value.model';
@@ -50,7 +48,7 @@ export class VocabularyTreeviewComponent implements OnDestroy, OnInit, OnChanges
@Input() multiSelect = false; @Input() multiSelect = false;
/** /**
* The vocabulary entries already selected, if any * A boolean representing if to show the add button or not
*/ */
@Input() showAdd = true; @Input() showAdd = true;
@@ -117,13 +115,9 @@ export class VocabularyTreeviewComponent implements OnDestroy, OnInit, OnChanges
* Initialize instance variables * Initialize instance variables
* *
* @param {VocabularyTreeviewService} vocabularyTreeviewService * @param {VocabularyTreeviewService} vocabularyTreeviewService
* @param {vocabularyService} vocabularyService
* @param {TranslateService} translate
*/ */
constructor( constructor(
private vocabularyTreeviewService: VocabularyTreeviewService, private vocabularyTreeviewService: VocabularyTreeviewService
private vocabularyService: VocabularyService,
private translate: TranslateService
) { ) {
this.treeFlattener = new VocabularyTreeFlattener(this.transformer, this.getLevel, this.treeFlattener = new VocabularyTreeFlattener(this.transformer, this.getLevel,
this.isExpandable, this.getChildren); this.isExpandable, this.getChildren);

View File

@@ -10,7 +10,8 @@ import { SearchService } from '../../../../../core/shared/search/search.service'
import { import {
FILTER_CONFIG, FILTER_CONFIG,
IN_PLACE_SEARCH, IN_PLACE_SEARCH,
SearchFilterService, REFRESH_FILTER REFRESH_FILTER,
SearchFilterService
} from '../../../../../core/shared/search/search-filter.service'; } from '../../../../../core/shared/search/search-filter.service';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { RemoteDataBuildService } from '../../../../../core/cache/builders/remote-data-build.service'; import { RemoteDataBuildService } from '../../../../../core/cache/builders/remote-data-build.service';
@@ -18,14 +19,15 @@ import { SEARCH_CONFIG_SERVICE } from '../../../../../my-dspace-page/my-dspace-p
import { SearchConfigurationService } from '../../../../../core/shared/search/search-configuration.service'; import { SearchConfigurationService } from '../../../../../core/shared/search/search-configuration.service';
import { SearchFilterConfig } from '../../../models/search-filter-config.model'; import { SearchFilterConfig } from '../../../models/search-filter-config.model';
import { FacetValue } from '../../../models/facet-value.model'; import { FacetValue } from '../../../models/facet-value.model';
import { getFacetValueForType } from '../../../search.utils'; import { addOperatorToFilterValue, getFacetValueForType } from '../../../search.utils';
import { filter, map, take } from 'rxjs/operators'; import { filter, map, take } from 'rxjs/operators';
import { VocabularyService } from '../../../../../core/submission/vocabularies/vocabulary.service'; import { VocabularyService } from '../../../../../core/submission/vocabularies/vocabulary.service';
import { Observable, BehaviorSubject } from 'rxjs'; import { BehaviorSubject, Observable } from 'rxjs';
import { PageInfo } from '../../../../../core/shared/page-info.model'; import { PageInfo } from '../../../../../core/shared/page-info.model';
import { environment } from '../../../../../../environments/environment'; import { environment } from '../../../../../../environments/environment';
import { addOperatorToFilterValue } from '../../../search.utils'; import {
import { VocabularyTreeviewModalComponent } from '../../../../form/vocabulary-treeview-modal/vocabulary-treeview-modal.component'; VocabularyTreeviewModalComponent
} from '../../../../form/vocabulary-treeview-modal/vocabulary-treeview-modal.component';
@Component({ @Component({
selector: 'ds-search-hierarchy-filter', selector: 'ds-search-hierarchy-filter',
@@ -91,6 +93,7 @@ export class SearchHierarchyFilterComponent extends SearchFacetFilterComponent i
name: this.getVocabularyEntry(), name: this.getVocabularyEntry(),
closed: true closed: true
}; };
modalRef.componentInstance.showAdd = false;
modalRef.result.then((detail: VocabularyEntryDetail) => { modalRef.result.then((detail: VocabularyEntryDetail) => {
this.selectedValues$ this.selectedValues$
.pipe(take(1)) .pipe(take(1))