mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
62849: existing selected objects are already selected and disabled
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
},
|
},
|
||||||
"label": "Journal Issue",
|
"label": "Journal Issue",
|
||||||
"mandatory": true,
|
"mandatory": true,
|
||||||
"repeatable": false,
|
"repeatable": true,
|
||||||
"mandatoryMessage": "Required field!",
|
"mandatoryMessage": "Required field!",
|
||||||
"hints": "Select a journal issue for this publication.",
|
"hints": "Select a journal issue for this publication.",
|
||||||
"selectableMetadata": [
|
"selectableMetadata": [
|
||||||
|
@@ -6,8 +6,9 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body" *ngVar="(resultsRD$ | async) as resultsRD">
|
<div class="modal-body" *ngVar="(resultsRD$ | async) as resultsRD">
|
||||||
<form class="input-group mb-3" #queryForm="ngForm" (ngSubmit)="search(queryForm.value.query)" >
|
<form class="input-group mb-3" #queryForm="ngForm" (ngSubmit)="search(queryForm.value.query)">
|
||||||
<input type="text" class="form-control" name="query" placeholder="Search query" [ngModel]="searchQuery">
|
<input type="text" class="form-control" name="query" placeholder="Search query"
|
||||||
|
[ngModel]="searchQuery">
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<button class="btn btn-outline-secondary" type="submit">Go</button>
|
<button class="btn btn-outline-secondary" type="submit">Go</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -25,16 +26,13 @@
|
|||||||
-->
|
-->
|
||||||
<input *ngIf="!isAllSelected() && !isSomeSelected()" type="checkbox"
|
<input *ngIf="!isAllSelected() && !isSomeSelected()" type="checkbox"
|
||||||
[indeterminate]="false"
|
[indeterminate]="false"
|
||||||
(change)="selectAll()"
|
(change)="selectAll()">
|
||||||
>
|
|
||||||
<input *ngIf="!isAllSelected() && isSomeSelected()" type="checkbox"
|
<input *ngIf="!isAllSelected() && isSomeSelected()" type="checkbox"
|
||||||
[indeterminate]="true"
|
[indeterminate]="true"
|
||||||
(change)="deselectAll()"
|
(change)="deselectAll()">
|
||||||
>
|
|
||||||
<input *ngIf="isAllSelected()" type="checkbox"
|
<input *ngIf="isAllSelected()" type="checkbox"
|
||||||
[checked]="true"
|
[checked]="true"
|
||||||
(change)="deselectAll()"
|
(change)="deselectAll()">
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div ngbDropdown class="input-group-append">
|
<div ngbDropdown class="input-group-append">
|
||||||
@@ -69,6 +67,7 @@
|
|||||||
[name]="'checkbox' + i"
|
[name]="'checkbox' + i"
|
||||||
[id]="'object'+i"
|
[id]="'object'+i"
|
||||||
[checked]="isSelected(result.indexableObject)"
|
[checked]="isSelected(result.indexableObject)"
|
||||||
|
[disabled]="isDisabled(result.indexableObject)"
|
||||||
(change)="selectCheckbox($event.currentTarget.checked, result.indexableObject)">
|
(change)="selectCheckbox($event.currentTarget.checked, result.indexableObject)">
|
||||||
<input *ngIf="!repeatable" class="form-check-input" type="radio"
|
<input *ngIf="!repeatable" class="form-check-input" type="radio"
|
||||||
[name]="'radio' + i"
|
[name]="'radio' + i"
|
||||||
|
@@ -29,6 +29,7 @@ export class DsDynamicLookupRelationModalComponent implements OnInit {
|
|||||||
searchConfig: PaginatedSearchOptions;
|
searchConfig: PaginatedSearchOptions;
|
||||||
repeatable: boolean;
|
repeatable: boolean;
|
||||||
selection: DSpaceObject[] = [];
|
selection: DSpaceObject[] = [];
|
||||||
|
previousSelection: DSpaceObject[] = [];
|
||||||
allSelected = false;
|
allSelected = false;
|
||||||
searchQuery;
|
searchQuery;
|
||||||
initialPagination = Object.assign(new PaginationComponentOptions(), {
|
initialPagination = Object.assign(new PaginationComponentOptions(), {
|
||||||
@@ -75,7 +76,12 @@ export class DsDynamicLookupRelationModalComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isSelected(dso: DSpaceObject): boolean {
|
isSelected(dso: DSpaceObject): boolean {
|
||||||
return hasValue(this.selection.find((selected) => selected.uuid === dso.uuid));
|
const completeSelection = [...this.selection, ...this.previousSelection];
|
||||||
|
return hasValue(completeSelection.find((selected) => selected.uuid === dso.uuid));
|
||||||
|
}
|
||||||
|
|
||||||
|
isDisabled(dso: DSpaceObject): boolean {
|
||||||
|
return hasValue(this.previousSelection.find((selected) => selected.uuid === dso.uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
selectCheckbox(value: boolean, dso: DSpaceObject) {
|
selectCheckbox(value: boolean, dso: DSpaceObject) {
|
||||||
@@ -98,7 +104,8 @@ export class DsDynamicLookupRelationModalComponent implements OnInit {
|
|||||||
selectPage(page: SearchResult<DSpaceObject>[]) {
|
selectPage(page: SearchResult<DSpaceObject>[]) {
|
||||||
const newObjects: DSpaceObject[] = page
|
const newObjects: DSpaceObject[] = page
|
||||||
.map((searchResult) => searchResult.indexableObject)
|
.map((searchResult) => searchResult.indexableObject)
|
||||||
.filter((dso) => hasNoValue(this.selection.find((selected) => selected.uuid === dso.uuid)));
|
.filter((dso) => hasNoValue(this.selection.find((selected) => selected.uuid === dso.uuid)))
|
||||||
|
.filter((dso) => hasNoValue(this.previousSelection.find((object) => object.uuid === dso.uuid)));
|
||||||
this.selection = [...this.selection, ...newObjects]
|
this.selection = [...this.selection, ...newObjects]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,11 +126,13 @@ export class DsDynamicLookupRelationModalComponent implements OnInit {
|
|||||||
const fullSearchConfig = Object.assign(this.searchConfig, { pagination: fullPagination });
|
const fullSearchConfig = Object.assign(this.searchConfig, { pagination: fullPagination });
|
||||||
const results = this.searchService.search(fullSearchConfig);
|
const results = this.searchService.search(fullSearchConfig);
|
||||||
results.pipe(
|
results.pipe(
|
||||||
getSucceededRemoteData(),
|
getSucceededRemoteData(),
|
||||||
map((resultsRD) => resultsRD.payload.page)
|
map((resultsRD) => resultsRD.payload.page)
|
||||||
)
|
)
|
||||||
.subscribe((results) =>
|
.subscribe((results) =>
|
||||||
this.selection = [...this.selection, ...results.map((searchResult) => searchResult.indexableObject)]
|
this.selection = results
|
||||||
|
.map((searchResult) => searchResult.indexableObject)
|
||||||
|
.filter((dso) => hasNoValue(this.previousSelection.find((object) => object.uuid === dso.uuid)))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -47,6 +47,8 @@ export class DsDynamicLookupRelationComponent extends DynamicFormControlComponen
|
|||||||
openLookup() {
|
openLookup() {
|
||||||
this.modalRef = this.modalService.open(DsDynamicLookupRelationModalComponent);
|
this.modalRef = this.modalService.open(DsDynamicLookupRelationModalComponent);
|
||||||
this.modalRef.componentInstance.repeatable = this.model.repeatable;
|
this.modalRef.componentInstance.repeatable = this.model.repeatable;
|
||||||
|
this.modalRef.componentInstance.selection = this.selectedResults || [];
|
||||||
|
this.modalRef.componentInstance.previousSelection = this.model.value || [];
|
||||||
this.modalRef.componentInstance.relationKey = this.model.name;
|
this.modalRef.componentInstance.relationKey = this.model.name;
|
||||||
this.modalRef.result.then((resultList) => {
|
this.modalRef.result.then((resultList) => {
|
||||||
this.selectedResults = resultList;
|
this.selectedResults = resultList;
|
||||||
|
Reference in New Issue
Block a user