mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-12 12:33:07 +00:00
fixed bug with double selection
This commit is contained in:
@@ -86,11 +86,11 @@ export class RelationshipService extends DataService<Relationship> {
|
||||
return this.getRelationshipEndpoint(id).pipe(
|
||||
isNotEmptyOperator(),
|
||||
take(1),
|
||||
tap(() => this.removeRelationshipItemsFromCacheByRelationship(id)),
|
||||
map((endpointURL: string) => new DeleteRequest(this.requestService.generateRequestId(), endpointURL)),
|
||||
configureRequest(this.requestService),
|
||||
switchMap((restRequest: RestRequest) => this.requestService.getByUUID(restRequest.uuid)),
|
||||
getResponseFromEntry(),
|
||||
tap(() => this.removeRelationshipItemsFromCacheByRelationship(id))
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -5,7 +5,6 @@
|
||||
[for]="model.id"
|
||||
[innerHTML]="(model.required && model.label) ? (model.label | translate) + ' *' : (model.label | translate)"
|
||||
[ngClass]="[getClass('element', 'label'), getClass('grid', 'label')]"></label>
|
||||
|
||||
<ng-container *ngTemplateOutlet="startTemplate?.templateRef; context: model"></ng-container>
|
||||
<!-- Should be *ngIf instead of class d-none, but that breaks the #componentViewContainer reference-->
|
||||
<div [ngClass]="{'form-row': model.hasLanguages || isRelationship, 'd-none': relationshipValue$ | async}">
|
||||
|
@@ -60,7 +60,7 @@ import { DYNAMIC_FORM_CONTROL_TYPE_DSDATEPICKER } from './models/date-picker/dat
|
||||
import { DYNAMIC_FORM_CONTROL_TYPE_LOOKUP } from './models/lookup/dynamic-lookup.model';
|
||||
import { DynamicListCheckboxGroupModel } from './models/list/dynamic-list-checkbox-group.model';
|
||||
import { DynamicListRadioGroupModel } from './models/list/dynamic-list-radio-group.model';
|
||||
import { hasValue, isNotEmpty, isNotUndefined } from '../../../empty.util';
|
||||
import { hasNoValue, hasValue, isNotEmpty, isNotUndefined } from '../../../empty.util';
|
||||
import { DYNAMIC_FORM_CONTROL_TYPE_LOOKUP_NAME } from './models/lookup/dynamic-lookup-name.model';
|
||||
import { DsDynamicTagComponent } from './models/tag/dynamic-tag.component';
|
||||
import { DsDatePickerComponent } from './models/date-picker/date-picker.component';
|
||||
@@ -73,7 +73,7 @@ import { DsDynamicFormArrayComponent } from './models/array-group/dynamic-form-a
|
||||
import { DsDynamicRelationGroupComponent } from './models/relation-group/dynamic-relation-group.components';
|
||||
import { DYNAMIC_FORM_CONTROL_TYPE_RELATION_GROUP } from './models/relation-group/dynamic-relation-group.model';
|
||||
import { DsDatePickerInlineComponent } from './models/date-picker-inline/dynamic-date-picker-inline.component';
|
||||
import { map, startWith, switchMap, find, take, tap } from 'rxjs/operators';
|
||||
import { map, startWith, switchMap, find, take, tap, filter } from 'rxjs/operators';
|
||||
import { combineLatest as observableCombineLatest, Observable, of as observableOf, Subscription } from 'rxjs';
|
||||
import { SearchResult } from '../../../search/search-result.model';
|
||||
import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
|
||||
@@ -97,6 +97,7 @@ import { Relationship } from '../../../../core/shared/item-relationships/relatio
|
||||
import { MetadataValue } from '../../../../core/shared/metadata.models';
|
||||
import { FormService } from '../../form.service';
|
||||
import { deepClone } from 'fast-json-patch';
|
||||
import { SelectableListState } from '../../../object-list/selectable-list/selectable-list.reducer';
|
||||
|
||||
export function dsDynamicFormControlMapFn(model: DynamicFormControlModel): Type<DynamicFormControl> | null {
|
||||
switch (model.type) {
|
||||
@@ -243,6 +244,7 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
||||
this.relationshipValue$ = relationship$.pipe(
|
||||
switchMap((relationship: Relationship) =>
|
||||
relationship.leftItem.pipe(
|
||||
tap((t) => console.log(t)),
|
||||
getSucceededRemoteData(),
|
||||
getRemoteDataPayload(),
|
||||
map((leftItem: Item) => {
|
||||
@@ -256,11 +258,16 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
|
||||
if (this.model.relationshipConfig) {
|
||||
this.listId = 'list-' + this.model.relationshipConfig.relationshipType;
|
||||
this.setItem();
|
||||
this.relationService.getRelatedItemsByLabel(this.item, this.model.relationshipConfig.relationshipType).pipe(
|
||||
tap((t: any) => console.log(deepClone(t))),
|
||||
const subscription = this.selectableListService.getSelectableList(this.listId).pipe(
|
||||
find((list: SelectableListState) => hasNoValue(list)),
|
||||
switchMap(() => {
|
||||
return this.relationService.getRelatedItemsByLabel(this.item, this.model.relationshipConfig.relationshipType).pipe(
|
||||
getSucceededRemoteData(),
|
||||
map((items: RemoteData<PaginatedList<Item>>) => items.payload.page.map((item) => Object.assign(new ItemSearchResult(), { indexableObject: item }))),
|
||||
)
|
||||
})
|
||||
).subscribe((relatedItems: Array<SearchResult<Item>>) => this.selectableListService.select(this.listId, relatedItems));
|
||||
this.subs.push(subscription);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,7 @@ import { SearchService } from '../../../../../../core/shared/search/search.servi
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { SelectableListService } from '../../../../../object-list/selectable-list/selectable-list.service';
|
||||
import { hasValue } from '../../../../../empty.util';
|
||||
import { map, switchMap, take, tap } from 'rxjs/operators';
|
||||
import { map, startWith, switchMap, take, tap } from 'rxjs/operators';
|
||||
import { getSucceededRemoteData } from '../../../../../../core/shared/operators';
|
||||
import { RouteService } from '../../../../../../core/services/route.service';
|
||||
import { CollectionElementLinkType } from '../../../../../object-collection/collection-element-link.type';
|
||||
@@ -129,7 +129,7 @@ export class DsDynamicLookupRelationSearchTabComponent implements OnInit, OnDest
|
||||
this.routeService.setParameter('fixedFilterQuery', this.relationship.filter);
|
||||
this.routeService.setParameter('configuration', this.relationship.searchConfiguration);
|
||||
this.resultsRD$ = this.searchConfigService.paginatedSearchOptions.pipe(
|
||||
switchMap((options) => this.lookupRelationService.getLocalResults(this.relationship, options))
|
||||
switchMap((options) => this.lookupRelationService.getLocalResults(this.relationship, options).pipe(startWith(undefined)))
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -305,6 +305,7 @@ export class FormComponent implements OnDestroy, OnInit {
|
||||
this.formBuilderService.addFormArrayGroup(formArrayControl, arrayContext);
|
||||
const value = formArrayControl.controls[index].value;
|
||||
formArrayControl.controls[formArrayControl.length - 1].setValue(value);
|
||||
formArrayControl.controls[index].setValue(undefined);
|
||||
formArrayControl.controls[index].reset();
|
||||
this.addArrayItem.emit(this.getEvent($event, arrayContext, index, 'add'));
|
||||
this.formService.changeForm(this.formId, this.formModel);
|
||||
|
Reference in New Issue
Block a user