mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 13:33:03 +00:00
[TLC-254] Remove some unwanted (ported) methods from form builder
This commit is contained in:
@@ -389,15 +389,6 @@ export class FormBuilderService extends DynamicFormService {
|
||||
return (tempModel.id !== tempModel.name) ? tempModel.name : tempModel.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new form model to formModels map
|
||||
* @param id id of model
|
||||
* @param model model
|
||||
*/
|
||||
addFormModel(id: string, model: DynamicFormControlModel[]): void {
|
||||
this.formModels.set(id, model);
|
||||
}
|
||||
|
||||
/**
|
||||
* If present, remove form model from formModels map
|
||||
* @param id id of model
|
||||
@@ -427,44 +418,6 @@ export class FormBuilderService extends DynamicFormService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method searches a field in all forms instantiated
|
||||
* by form.component and, if found, it updates its value
|
||||
*
|
||||
* @param fieldId id of field to update
|
||||
* @param value new value to set
|
||||
* @return the model updated if found
|
||||
*/
|
||||
updateModelValue(fieldId: string, value: FormFieldMetadataValueObject): DynamicFormControlModel {
|
||||
let returnModel = null;
|
||||
this.formModels.forEach((models, formId) => {
|
||||
const fieldModel: any = this.findById(fieldId, models);
|
||||
if (hasValue(fieldModel)) {
|
||||
if (isNotEmpty(value)) {
|
||||
if (fieldModel.repeatable && isNotEmpty(fieldModel.value)) {
|
||||
// if model is repeatable and has already a value add a new field instead of replacing it
|
||||
const formGroup = this.formGroups.get(formId);
|
||||
const arrayContext = fieldModel.parent?.context;
|
||||
if (isNotEmpty(formGroup) && isNotEmpty(arrayContext)) {
|
||||
const formArrayControl = this.getFormControlByModel(formGroup, arrayContext) as FormArray;
|
||||
const index = arrayContext?.groups?.length;
|
||||
this.insertFormArrayGroup(index, formArrayControl, arrayContext);
|
||||
const newAddedModel: any = this.findById(fieldId, models, index);
|
||||
this.detectChanges();
|
||||
newAddedModel.value = value;
|
||||
returnModel = newAddedModel;
|
||||
}
|
||||
} else {
|
||||
fieldModel.value = value;
|
||||
returnModel = fieldModel;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
return returnModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the metadata list related to the event.
|
||||
* @param event
|
||||
@@ -537,29 +490,4 @@ export class FormBuilderService extends DynamicFormService {
|
||||
return Object.keys(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new formbuilder in forma array by copying current formBuilder index
|
||||
* @param index index of formBuilder selected to be copied
|
||||
* @param formArray formArray of the inline group forms
|
||||
* @param formArrayModel formArrayModel model of forms that will be created
|
||||
*/
|
||||
copyFormArrayGroup(index: number, formArray: FormArray, formArrayModel: DynamicFormArrayModel) {
|
||||
|
||||
const groupModel = formArrayModel.insertGroup(index);
|
||||
const previousGroup = formArray.controls[index] as FormGroup;
|
||||
const newGroup = this.createFormGroup(groupModel.group, null, groupModel);
|
||||
const previousKey = Object.keys(previousGroup.getRawValue())[0];
|
||||
const newKey = Object.keys(newGroup.getRawValue())[0];
|
||||
|
||||
if (!isObjectEmpty(previousGroup.getRawValue()[previousKey])) {
|
||||
newGroup.get(newKey).setValue(previousGroup.getRawValue()[previousKey]);
|
||||
}
|
||||
|
||||
formArray.insert(index, newGroup);
|
||||
|
||||
return newGroup;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user