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> {
|
update(): Observable<FormFieldMetadataValueObject> {
|
||||||
this.metadataValue.place = this.newIndex;
|
// this.metadataValue.place = this.newIndex;
|
||||||
this.model.valueUpdates.next(this.metadataValue as any);
|
// this.model.valueUpdates.next(this.metadataValue.value);
|
||||||
console.log('this.control.value', this.control.value);
|
// console.log('this.model', this.model);
|
||||||
|
// this.control.markAsDirty();
|
||||||
|
// console.log('this.control.value', this.control.value);
|
||||||
this.oldIndex = this.newIndex;
|
this.oldIndex = this.newIndex;
|
||||||
return observableOf(this.metadataValue);
|
return observableOf(this.metadataValue);
|
||||||
}
|
}
|
||||||
|
@@ -70,6 +70,7 @@ export class DsDynamicFormArrayComponent extends DynamicFormArrayComponent imple
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
console.log('this.model', this.model);
|
||||||
this.submissionObjectService
|
this.submissionObjectService
|
||||||
.findById(this.model.submissionId).pipe(
|
.findById(this.model.submissionId).pipe(
|
||||||
getSucceededRemoteData(),
|
getSucceededRemoteData(),
|
||||||
@@ -89,7 +90,7 @@ export class DsDynamicFormArrayComponent extends DynamicFormArrayComponent imple
|
|||||||
this.zone.runOutsideAngular(() => {
|
this.zone.runOutsideAngular(() => {
|
||||||
const reorderable$arr: Array<Observable<Reorderable>> = this.model.groups
|
const reorderable$arr: Array<Observable<Reorderable>> = this.model.groups
|
||||||
.map((group, index) => [group, (this.control as any).controls[index]])
|
.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) => {
|
.map(([group, control]: [DynamicFormArrayGroupModel, AbstractControl], index: number) => {
|
||||||
const model = group.group[0] as DynamicConcatModel;
|
const model = group.group[0] as DynamicConcatModel;
|
||||||
let formFieldMetadataValue: FormFieldMetadataValueObject = model.value as FormFieldMetadataValueObject;
|
let formFieldMetadataValue: FormFieldMetadataValueObject = model.value as FormFieldMetadataValueObject;
|
||||||
@@ -158,6 +159,7 @@ export class DsDynamicFormArrayComponent extends DynamicFormArrayComponent imple
|
|||||||
if (reorderable.hasMoved) {
|
if (reorderable.hasMoved) {
|
||||||
console.log('reorderable moved', reorderable, reorderable.getPlace());
|
console.log('reorderable moved', reorderable, reorderable.getPlace());
|
||||||
reorderable.update().pipe(take(1)).subscribe((v) => {
|
reorderable.update().pipe(take(1)).subscribe((v) => {
|
||||||
|
this.change.emit(undefined);
|
||||||
console.log('reorderable updated', reorderable, reorderable.getPlace());
|
console.log('reorderable updated', reorderable, reorderable.getPlace());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,7 @@ export interface DsDynamicInputModelConfig extends DynamicInputModelConfig {
|
|||||||
authorityOptions?: AuthorityOptions;
|
authorityOptions?: AuthorityOptions;
|
||||||
languageCodes?: LanguageCode[];
|
languageCodes?: LanguageCode[];
|
||||||
language?: string;
|
language?: string;
|
||||||
|
place?: number;
|
||||||
value?: any;
|
value?: any;
|
||||||
relationship?: RelationshipOptions;
|
relationship?: RelationshipOptions;
|
||||||
repeatable: boolean;
|
repeatable: boolean;
|
||||||
|
@@ -5,6 +5,7 @@ export interface DynamicRowArrayModelConfig extends DynamicFormArrayModelConfig
|
|||||||
required: boolean;
|
required: boolean;
|
||||||
submissionId: string;
|
submissionId: string;
|
||||||
hasRelationship: boolean;
|
hasRelationship: boolean;
|
||||||
|
metadataKey: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DynamicRowArrayModel extends DynamicFormArrayModel {
|
export class DynamicRowArrayModel extends DynamicFormArrayModel {
|
||||||
@@ -12,6 +13,7 @@ export class DynamicRowArrayModel extends DynamicFormArrayModel {
|
|||||||
@serializable() required = false;
|
@serializable() required = false;
|
||||||
@serializable() submissionId: string;
|
@serializable() submissionId: string;
|
||||||
@serializable() hasRelationship: boolean;
|
@serializable() hasRelationship: boolean;
|
||||||
|
@serializable() metadataKey: string;
|
||||||
isRowArray = true;
|
isRowArray = true;
|
||||||
|
|
||||||
constructor(config: DynamicRowArrayModelConfig, layout?: DynamicFormControlLayout) {
|
constructor(config: DynamicRowArrayModelConfig, layout?: DynamicFormControlLayout) {
|
||||||
@@ -20,5 +22,6 @@ export class DynamicRowArrayModel extends DynamicFormArrayModel {
|
|||||||
this.required = config.required;
|
this.required = config.required;
|
||||||
this.submissionId = config.submissionId;
|
this.submissionId = config.submissionId;
|
||||||
this.hasRelationship = config.hasRelationship;
|
this.hasRelationship = config.hasRelationship;
|
||||||
|
this.metadataKey = config.metadataKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -228,7 +228,7 @@ export class FormBuilderService extends DynamicFormService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hasArrayGroupValue(model: DynamicFormControlModel): boolean {
|
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 {
|
hasMappedGroupValue(model: DynamicFormControlModel): boolean {
|
||||||
@@ -285,11 +285,16 @@ export class FormBuilderService extends DynamicFormService {
|
|||||||
return isNotEmpty(fieldModel) ? formGroup.get(this.getPath(fieldModel)) : null;
|
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 {
|
getId(model: DynamicPathable): string {
|
||||||
let tempModel: DynamicFormControlModel;
|
let tempModel: DynamicFormControlModel;
|
||||||
|
|
||||||
if (this.isArrayGroup(model as 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)) {
|
} else if (this.isModelInCustomGroup(model as DynamicFormControlModel)) {
|
||||||
tempModel = (model as any).parent;
|
tempModel = (model as any).parent;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -44,6 +44,12 @@ export abstract class FieldParser {
|
|||||||
let arrayCounter = 0;
|
let arrayCounter = 0;
|
||||||
let fieldArrayCounter = 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 = {
|
const config = {
|
||||||
id: uniqueId() + '_array',
|
id: uniqueId() + '_array',
|
||||||
label: this.configData.label,
|
label: this.configData.label,
|
||||||
@@ -52,6 +58,7 @@ export abstract class FieldParser {
|
|||||||
hasRelationship: isNotEmpty(this.configData.selectableRelationship),
|
hasRelationship: isNotEmpty(this.configData.selectableRelationship),
|
||||||
required: isNotEmpty(this.configData.mandatory),
|
required: isNotEmpty(this.configData.mandatory),
|
||||||
submissionId: this.submissionId,
|
submissionId: this.submissionId,
|
||||||
|
metadataKey,
|
||||||
groupFactory: () => {
|
groupFactory: () => {
|
||||||
let model;
|
let model;
|
||||||
let isFirstModelInArray = true;
|
let isFirstModelInArray = true;
|
||||||
@@ -314,6 +321,7 @@ export abstract class FieldParser {
|
|||||||
|
|
||||||
if (typeof fieldValue === 'object') {
|
if (typeof fieldValue === 'object') {
|
||||||
modelConfig.language = fieldValue.language;
|
modelConfig.language = fieldValue.language;
|
||||||
|
modelConfig.place = fieldValue.place;
|
||||||
if (forceValueAsObj) {
|
if (forceValueAsObj) {
|
||||||
modelConfig.value = fieldValue;
|
modelConfig.value = fieldValue;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -81,7 +81,8 @@ const rowArrayQualdropConfig = {
|
|||||||
return [MockQualdropModel];
|
return [MockQualdropModel];
|
||||||
},
|
},
|
||||||
required: false,
|
required: false,
|
||||||
submissionId: '1234'
|
submissionId: '1234',
|
||||||
|
metadataKey: 'dc.some.key'
|
||||||
} as DynamicRowArrayModelConfig;
|
} as DynamicRowArrayModelConfig;
|
||||||
|
|
||||||
export const MockRowArrayQualdropModel: DynamicRowArrayModel = new DynamicRowArrayModel(rowArrayQualdropConfig);
|
export const MockRowArrayQualdropModel: DynamicRowArrayModel = new DynamicRowArrayModel(rowArrayQualdropConfig);
|
||||||
|
Reference in New Issue
Block a user