mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
111768: move original code back to init only for performance
This commit is contained in:
@@ -68,10 +68,14 @@ export class DsDynamicScrollableDropdownComponent extends DsDynamicVocabularyCom
|
||||
*/
|
||||
ngOnInit() {
|
||||
this.updatePageInfo(this.model.maxOptions, 1);
|
||||
this.loadOptions();
|
||||
this.loadOptions(true);
|
||||
this.group.get(this.model.id).valueChanges.pipe(distinctUntilChanged())
|
||||
.subscribe((value) => {
|
||||
this.setCurrentValue(value);
|
||||
});
|
||||
}
|
||||
|
||||
loadOptions() {
|
||||
loadOptions(fromInit: boolean) {
|
||||
this.loading = true;
|
||||
this.vocabularyService.getVocabularyEntriesByValue(this.inputText, false, this.model.vocabularyOptions, this.pageInfo).pipe(
|
||||
getFirstSucceededRemoteDataPayload(),
|
||||
@@ -79,7 +83,7 @@ export class DsDynamicScrollableDropdownComponent extends DsDynamicVocabularyCom
|
||||
tap(() => this.loading = false)
|
||||
).subscribe((list: PaginatedList<VocabularyEntry>) => {
|
||||
this.optionsList = list.page;
|
||||
if (this.model.value) {
|
||||
if (fromInit && this.model.value) {
|
||||
this.setCurrentValue(this.model.value, true);
|
||||
}
|
||||
|
||||
@@ -92,11 +96,6 @@ export class DsDynamicScrollableDropdownComponent extends DsDynamicVocabularyCom
|
||||
this.selectedIndex = 0;
|
||||
this.cdr.detectChanges();
|
||||
});
|
||||
|
||||
this.group.get(this.model.id).valueChanges.pipe(distinctUntilChanged())
|
||||
.subscribe((value) => {
|
||||
this.setCurrentValue(value);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +112,7 @@ export class DsDynamicScrollableDropdownComponent extends DsDynamicVocabularyCom
|
||||
this.group.markAsUntouched();
|
||||
this.inputText = null;
|
||||
this.updatePageInfo(this.model.maxOptions, 1);
|
||||
this.loadOptions();
|
||||
this.loadOptions(false);
|
||||
sdRef.open();
|
||||
}
|
||||
}
|
||||
@@ -170,7 +169,7 @@ export class DsDynamicScrollableDropdownComponent extends DsDynamicVocabularyCom
|
||||
this.inputText += keyName;
|
||||
// When a new key is added, we need to reset the page info
|
||||
this.updatePageInfo(this.model.maxOptions, 1);
|
||||
this.loadOptions();
|
||||
this.loadOptions(false);
|
||||
}
|
||||
|
||||
removeKeyFromInput() {
|
||||
@@ -179,7 +178,7 @@ export class DsDynamicScrollableDropdownComponent extends DsDynamicVocabularyCom
|
||||
if (this.inputText === '') {
|
||||
this.inputText = null;
|
||||
}
|
||||
this.loadOptions();
|
||||
this.loadOptions(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user