mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
Fixed issue with adding lookup repeatable fields
This commit is contained in:
@@ -2,16 +2,20 @@ import { distinctUntilChanged, filter, map } from 'rxjs/operators';
|
|||||||
import { ChangeDetectorRef, Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
|
import { ChangeDetectorRef, Component, EventEmitter, Input, OnDestroy, OnInit, Output } from '@angular/core';
|
||||||
import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
|
import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
|
||||||
|
|
||||||
import { DynamicFormArrayModel, DynamicFormControlEvent, DynamicFormControlModel, DynamicFormGroupModel, DynamicFormLayout, } from '@ng-dynamic-forms/core';
|
import {
|
||||||
|
DynamicFormArrayModel,
|
||||||
|
DynamicFormControlEvent,
|
||||||
|
DynamicFormControlModel,
|
||||||
|
DynamicFormGroupModel,
|
||||||
|
DynamicFormLayout,
|
||||||
|
} from '@ng-dynamic-forms/core';
|
||||||
import { findIndex } from 'lodash';
|
import { findIndex } from 'lodash';
|
||||||
import { FormBuilderService } from './builder/form-builder.service';
|
import { FormBuilderService } from './builder/form-builder.service';
|
||||||
import { Observable, Subscription } from 'rxjs';
|
import { Observable, Subscription } from 'rxjs';
|
||||||
import { hasValue, isNotEmpty, isNotNull, isNull } from '../empty.util';
|
import { hasValue, isNotEmpty, isNotNull, isNull } from '../empty.util';
|
||||||
import { FormService } from './form.service';
|
import { FormService } from './form.service';
|
||||||
import { FormEntry, FormError } from './form.reducer';
|
import { FormEntry, FormError } from './form.reducer';
|
||||||
import { DYNAMIC_FORM_CONTROL_TYPE_SCROLLABLE_DROPDOWN } from './builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.model';
|
|
||||||
import { QUALDROP_GROUP_SUFFIX } from './builder/ds-dynamic-form-ui/models/ds-dynamic-qualdrop.model';
|
import { QUALDROP_GROUP_SUFFIX } from './builder/ds-dynamic-form-ui/models/ds-dynamic-qualdrop.model';
|
||||||
import { DYNAMIC_FORM_CONTROL_TYPE_ONEBOX } from './builder/ds-dynamic-form-ui/models/onebox/dynamic-onebox.model';
|
|
||||||
|
|
||||||
const QUALDROP_GROUP_REGEX = new RegExp(`${QUALDROP_GROUP_SUFFIX}_\\d+$`);
|
const QUALDROP_GROUP_REGEX = new RegExp(`${QUALDROP_GROUP_SUFFIX}_\\d+$`);
|
||||||
|
|
||||||
@@ -151,8 +155,8 @@ export class FormComponent implements OnDestroy, OnInit {
|
|||||||
this.formValid = this.getFormGroupValidStatus();
|
this.formValid = this.getFormGroupValidStatus();
|
||||||
|
|
||||||
this.subs.push(this.formGroup.statusChanges.pipe(
|
this.subs.push(this.formGroup.statusChanges.pipe(
|
||||||
filter((currentStatus) => this.formValid !== this.getFormGroupValidStatus()))
|
filter(() => this.formValid !== this.getFormGroupValidStatus()))
|
||||||
.subscribe((currentStatus) => {
|
.subscribe(() => {
|
||||||
this.formService.setStatusChanged(this.formId, this.getFormGroupValidStatus());
|
this.formService.setStatusChanged(this.formId, this.getFormGroupValidStatus());
|
||||||
this.formValid = this.getFormGroupValidStatus();
|
this.formValid = this.getFormGroupValidStatus();
|
||||||
}));
|
}));
|
||||||
@@ -317,7 +321,7 @@ export class FormComponent implements OnDestroy, OnInit {
|
|||||||
|
|
||||||
// set that field to the new value
|
// set that field to the new value
|
||||||
const model = arrayContext.groups[arrayContext.groups.length - 1].group[0] as any;
|
const model = arrayContext.groups[arrayContext.groups.length - 1].group[0] as any;
|
||||||
if (model.type === DYNAMIC_FORM_CONTROL_TYPE_SCROLLABLE_DROPDOWN || model.type === DYNAMIC_FORM_CONTROL_TYPE_ONEBOX) {
|
if (model.hasAuthority) {
|
||||||
model.value = Object.values(value)[0];
|
model.value = Object.values(value)[0];
|
||||||
const ctrl = formArrayControl.controls[formArrayControl.length - 1];
|
const ctrl = formArrayControl.controls[formArrayControl.length - 1];
|
||||||
const ctrlValue = ctrl.value;
|
const ctrlValue = ctrl.value;
|
||||||
|
Reference in New Issue
Block a user