mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
metadata updates are now sent to the server, but the format is still wrong
This commit is contained in:
@@ -68,9 +68,11 @@ export class ReorderableFormFieldMetadataValue extends Reorderable {
|
||||
}
|
||||
|
||||
update(): Observable<FormFieldMetadataValueObject> {
|
||||
this.metadataValue.place = this.newIndex;
|
||||
this.model.valueUpdates.next(this.metadataValue as any);
|
||||
console.log('this.control.value', this.control.value);
|
||||
// this.metadataValue.place = this.newIndex;
|
||||
// this.model.valueUpdates.next(this.metadataValue.value);
|
||||
// console.log('this.model', this.model);
|
||||
// this.control.markAsDirty();
|
||||
// console.log('this.control.value', this.control.value);
|
||||
this.oldIndex = this.newIndex;
|
||||
return observableOf(this.metadataValue);
|
||||
}
|
||||
|
@@ -70,6 +70,7 @@ export class DsDynamicFormArrayComponent extends DynamicFormArrayComponent imple
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
console.log('this.model', this.model);
|
||||
this.submissionObjectService
|
||||
.findById(this.model.submissionId).pipe(
|
||||
getSucceededRemoteData(),
|
||||
@@ -89,7 +90,7 @@ export class DsDynamicFormArrayComponent extends DynamicFormArrayComponent imple
|
||||
this.zone.runOutsideAngular(() => {
|
||||
const reorderable$arr: Array<Observable<Reorderable>> = this.model.groups
|
||||
.map((group, index) => [group, (this.control as any).controls[index]])
|
||||
.slice(1) // disregard the first group, it is always empty to ensure the first field remains empty
|
||||
//.slice(1) // disregard the first group, it is always empty to ensure the first field remains empty
|
||||
.map(([group, control]: [DynamicFormArrayGroupModel, AbstractControl], index: number) => {
|
||||
const model = group.group[0] as DynamicConcatModel;
|
||||
let formFieldMetadataValue: FormFieldMetadataValueObject = model.value as FormFieldMetadataValueObject;
|
||||
@@ -158,6 +159,7 @@ export class DsDynamicFormArrayComponent extends DynamicFormArrayComponent imple
|
||||
if (reorderable.hasMoved) {
|
||||
console.log('reorderable moved', reorderable, reorderable.getPlace());
|
||||
reorderable.update().pipe(take(1)).subscribe((v) => {
|
||||
this.change.emit(undefined);
|
||||
console.log('reorderable updated', reorderable, reorderable.getPlace());
|
||||
});
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@ export interface DsDynamicInputModelConfig extends DynamicInputModelConfig {
|
||||
authorityOptions?: AuthorityOptions;
|
||||
languageCodes?: LanguageCode[];
|
||||
language?: string;
|
||||
place?: number;
|
||||
value?: any;
|
||||
relationship?: RelationshipOptions;
|
||||
repeatable: boolean;
|
||||
|
@@ -5,6 +5,7 @@ export interface DynamicRowArrayModelConfig extends DynamicFormArrayModelConfig
|
||||
required: boolean;
|
||||
submissionId: string;
|
||||
hasRelationship: boolean;
|
||||
metadataKey: string;
|
||||
}
|
||||
|
||||
export class DynamicRowArrayModel extends DynamicFormArrayModel {
|
||||
@@ -12,6 +13,7 @@ export class DynamicRowArrayModel extends DynamicFormArrayModel {
|
||||
@serializable() required = false;
|
||||
@serializable() submissionId: string;
|
||||
@serializable() hasRelationship: boolean;
|
||||
@serializable() metadataKey: string;
|
||||
isRowArray = true;
|
||||
|
||||
constructor(config: DynamicRowArrayModelConfig, layout?: DynamicFormControlLayout) {
|
||||
@@ -20,5 +22,6 @@ export class DynamicRowArrayModel extends DynamicFormArrayModel {
|
||||
this.required = config.required;
|
||||
this.submissionId = config.submissionId;
|
||||
this.hasRelationship = config.hasRelationship;
|
||||
this.metadataKey = config.metadataKey;
|
||||
}
|
||||
}
|
||||
|
@@ -228,7 +228,7 @@ export class FormBuilderService extends DynamicFormService {
|
||||
}
|
||||
|
||||
hasArrayGroupValue(model: DynamicFormControlModel): boolean {
|
||||
return model && (this.isListGroup(model) || model.type === DYNAMIC_FORM_CONTROL_TYPE_TAG);
|
||||
return model && (this.isListGroup(model) || model.type === DYNAMIC_FORM_CONTROL_TYPE_TAG || model.type === DYNAMIC_FORM_CONTROL_TYPE_ARRAY);
|
||||
}
|
||||
|
||||
hasMappedGroupValue(model: DynamicFormControlModel): boolean {
|
||||
@@ -285,11 +285,16 @@ export class FormBuilderService extends DynamicFormService {
|
||||
return isNotEmpty(fieldModel) ? formGroup.get(this.getPath(fieldModel)) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Note (discovered while debugging) this is not the ID as used in the form,
|
||||
* but the first part of the path needed in a patch operation:
|
||||
* e.g. add foo/0 -> the id is 'foo'
|
||||
*/
|
||||
getId(model: DynamicPathable): string {
|
||||
let tempModel: DynamicFormControlModel;
|
||||
|
||||
if (this.isArrayGroup(model as DynamicFormControlModel)) {
|
||||
return model.index.toString();
|
||||
return hasValue((model as any).metadataKey) ? (model as any).metadataKey : model.index.toString();
|
||||
} else if (this.isModelInCustomGroup(model as DynamicFormControlModel)) {
|
||||
tempModel = (model as any).parent;
|
||||
} else {
|
||||
|
@@ -44,6 +44,12 @@ export abstract class FieldParser {
|
||||
let arrayCounter = 0;
|
||||
let fieldArrayCounter = 0;
|
||||
|
||||
let metadataKey;
|
||||
|
||||
if (Array.isArray(this.configData.selectableMetadata) && this.configData.selectableMetadata.length === 1) {
|
||||
metadataKey = this.configData.selectableMetadata[0].metadata;
|
||||
};
|
||||
|
||||
const config = {
|
||||
id: uniqueId() + '_array',
|
||||
label: this.configData.label,
|
||||
@@ -52,6 +58,7 @@ export abstract class FieldParser {
|
||||
hasRelationship: isNotEmpty(this.configData.selectableRelationship),
|
||||
required: isNotEmpty(this.configData.mandatory),
|
||||
submissionId: this.submissionId,
|
||||
metadataKey,
|
||||
groupFactory: () => {
|
||||
let model;
|
||||
let isFirstModelInArray = true;
|
||||
@@ -314,6 +321,7 @@ export abstract class FieldParser {
|
||||
|
||||
if (typeof fieldValue === 'object') {
|
||||
modelConfig.language = fieldValue.language;
|
||||
modelConfig.place = fieldValue.place;
|
||||
if (forceValueAsObj) {
|
||||
modelConfig.value = fieldValue;
|
||||
} else {
|
||||
|
@@ -81,7 +81,8 @@ const rowArrayQualdropConfig = {
|
||||
return [MockQualdropModel];
|
||||
},
|
||||
required: false,
|
||||
submissionId: '1234'
|
||||
submissionId: '1234',
|
||||
metadataKey: 'dc.some.key'
|
||||
} as DynamicRowArrayModelConfig;
|
||||
|
||||
export const MockRowArrayQualdropModel: DynamicRowArrayModel = new DynamicRowArrayModel(rowArrayQualdropConfig);
|
||||
|
Reference in New Issue
Block a user