mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[TLC-254] Make the item type field configurable (default dc.type)
This commit is contained in:
@@ -77,6 +77,11 @@ submission:
|
||||
# NOTE: after how many time (milliseconds) submission is saved automatically
|
||||
# eg. timer: 5 * (1000 * 60); // 5 minutes
|
||||
timer: 0
|
||||
typeBind:
|
||||
# NOTE: which field to use when matching to type-bind configuration,
|
||||
# eg. dc.type, local.publicationType
|
||||
# default: dc.type
|
||||
field: dc.type
|
||||
icons:
|
||||
metadata:
|
||||
# NOTE: example of configuration
|
||||
|
@@ -33,6 +33,7 @@ import { dateToString, isNgbDateStruct } from '../../date.util';
|
||||
import { DYNAMIC_FORM_CONTROL_TYPE_RELATION_GROUP } from './ds-dynamic-form-ui/ds-dynamic-form-constants';
|
||||
import { CONCAT_GROUP_SUFFIX, DynamicConcatModel } from './ds-dynamic-form-ui/models/ds-dynamic-concat.model';
|
||||
import { VIRTUAL_METADATA_PREFIX } from '../../../core/shared/metadata.models';
|
||||
import { environment } from '../../../../environments/environment';
|
||||
|
||||
@Injectable()
|
||||
export class FormBuilderService extends DynamicFormService {
|
||||
@@ -49,6 +50,11 @@ export class FormBuilderService extends DynamicFormService {
|
||||
*/
|
||||
private formGroups: Map<string, FormGroup>;
|
||||
|
||||
/**
|
||||
* This is the field to use for type binding
|
||||
*/
|
||||
private typeField: string;
|
||||
|
||||
constructor(
|
||||
componentService: DynamicFormComponentService,
|
||||
validationService: DynamicFormValidationService,
|
||||
@@ -57,6 +63,8 @@ export class FormBuilderService extends DynamicFormService {
|
||||
super(componentService, validationService);
|
||||
this.formModels = new Map();
|
||||
this.formGroups = new Map();
|
||||
// Replace . with _ in configured type field here, to make configuration more simple and user-friendly
|
||||
this.typeField = environment.submission.typeBind.field.replace('\.', '_');
|
||||
}
|
||||
|
||||
createDynamicFormControlEvent(control: FormControl, group: FormGroup, model: DynamicFormControlModel, type: string): DynamicFormControlEvent {
|
||||
@@ -274,7 +282,7 @@ export class FormBuilderService extends DynamicFormService {
|
||||
}
|
||||
|
||||
if (isNull(typeBindModel)) {
|
||||
typeBindModel = this.findById('dc_type', rows);
|
||||
typeBindModel = this.findById(this.typeField, rows);
|
||||
}
|
||||
|
||||
if (typeBindModel !== null) {
|
||||
|
@@ -17,6 +17,7 @@ import { RelationshipOptions } from '../models/relationship-options.model';
|
||||
import { VocabularyOptions } from '../../../../core/submission/vocabularies/models/vocabulary-options.model';
|
||||
import { ParserType } from './parser-type';
|
||||
import { isNgbDateStruct } from '../../../date.util';
|
||||
import { environment } from '../../../../../environments/environment';
|
||||
|
||||
export const SUBMISSION_ID: InjectionToken<string> = new InjectionToken<string>('submissionId');
|
||||
export const CONFIG_DATA: InjectionToken<FormFieldModel> = new InjectionToken<FormFieldModel>('configData');
|
||||
@@ -26,6 +27,11 @@ export const PARSER_OPTIONS: InjectionToken<ParserOptions> = new InjectionToken<
|
||||
export abstract class FieldParser {
|
||||
|
||||
protected fieldId: string;
|
||||
/**
|
||||
* This is the field to use for type binding
|
||||
* @protected
|
||||
*/
|
||||
protected typeField: string;
|
||||
|
||||
constructor(
|
||||
@Inject(SUBMISSION_ID) protected submissionId: string,
|
||||
@@ -33,6 +39,8 @@ export abstract class FieldParser {
|
||||
@Inject(INIT_FORM_VALUES) protected initFormValues: any,
|
||||
@Inject(PARSER_OPTIONS) protected parserOptions: ParserOptions
|
||||
) {
|
||||
// Replace . with _ in configured type field here, to make configuration more simple and user-friendly
|
||||
this.typeField = environment.submission.typeBind.field.replace('\.', '_');
|
||||
}
|
||||
|
||||
public abstract modelFactory(fieldValue?: FormFieldMetadataValueObject, label?: boolean): any;
|
||||
@@ -315,14 +323,14 @@ export abstract class FieldParser {
|
||||
const bindValues = [];
|
||||
configuredTypeBindValues.forEach((value) => {
|
||||
bindValues.push({
|
||||
id: 'dc_type',
|
||||
id: this.typeField,
|
||||
value: value
|
||||
});
|
||||
});
|
||||
// match: MATCH_VISIBLE means that if true, the field / component will be visible
|
||||
// operator: OR means that all the values in the 'when' condition will be compared with OR, not AND
|
||||
// when: the list of values to match against, in this case the list of strings from <type-bind>...</type-bind>
|
||||
// Example: Field [x] will be VISIBLE if dc_type = book OR dc_type = book_part
|
||||
// Example: Field [x] will be VISIBLE if item type = book OR item type = book_part
|
||||
//
|
||||
// The opposing match value will be the dc.type for the workspace item
|
||||
return [{
|
||||
|
@@ -110,6 +110,9 @@ export class DefaultAppConfig implements AppConfig {
|
||||
*/
|
||||
timer: 0
|
||||
},
|
||||
typeBind: {
|
||||
field: 'dc.type'
|
||||
},
|
||||
icons: {
|
||||
metadata: [
|
||||
/**
|
||||
|
@@ -5,6 +5,10 @@ interface AutosaveConfig extends Config {
|
||||
timer: number;
|
||||
}
|
||||
|
||||
interface TypeBindConfig extends Config {
|
||||
field: string;
|
||||
}
|
||||
|
||||
interface IconsConfig extends Config {
|
||||
metadata: MetadataIconConfig[];
|
||||
authority: {
|
||||
@@ -24,5 +28,6 @@ export interface ConfidenceIconConfig extends Config {
|
||||
|
||||
export interface SubmissionConfig extends Config {
|
||||
autosave: AutosaveConfig;
|
||||
typeBind: TypeBindConfig;
|
||||
icons: IconsConfig;
|
||||
}
|
||||
|
@@ -100,6 +100,9 @@ export const environment: BuildConfig = {
|
||||
// NOTE: every how many minutes submission is saved automatically
|
||||
timer: 5
|
||||
},
|
||||
typeBind: {
|
||||
field: 'dc.type'
|
||||
},
|
||||
icons: {
|
||||
metadata: [
|
||||
{
|
||||
|
Reference in New Issue
Block a user