Skip to content

Commit 6369166

Browse files
[DURACOM-453] remove collection form required from fields, fix metadata, allow none in selection
1 parent 8c656fe commit 6369166

2 files changed

Lines changed: 5 additions & 37 deletions

File tree

src/app/collection-page/collection-form/collection-form.component.ts

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { RequestService } from '@dspace/core/data/request.service';
1919
import { NotificationsService } from '@dspace/core/notification-system/notifications.service';
2020
import { Collection } from '@dspace/core/shared/collection.model';
2121
import { ItemType } from '@dspace/core/shared/item-relationships/item-type.model';
22-
import { NONE_ENTITY_TYPE } from '@dspace/core/shared/item-relationships/item-type.resource-type';
2322
import { MetadataValue } from '@dspace/core/shared/metadata.models';
2423
import { getFirstSucceededRemoteListPayload } from '@dspace/core/shared/operators';
2524
import {
@@ -51,7 +50,6 @@ import { FormComponent } from '../../shared/form/form.component';
5150
import { UploaderComponent } from '../../shared/upload/uploader/uploader.component';
5251
import { VarDirective } from '../../shared/utils/var.directive';
5352
import {
54-
collectionFormCorrectionSubmissionDefinitionSelectionConfig,
5553
collectionFormEntityTypeSelectionConfig,
5654
collectionFormModels,
5755
collectionFormSharedWorkspaceCheckboxConfig,
@@ -97,12 +95,6 @@ export class CollectionFormComponent extends ComColFormComponent<Collection> imp
9795
*/
9896
submissionDefinitionSelection: DynamicSelectModel<string> = new DynamicSelectModel(collectionFormSubmissionDefinitionSelectionConfig);
9997

100-
/**
101-
* The dynamic form field used for correction submission definition selection
102-
* @type {DynamicSelectModel<string>}
103-
*/
104-
correctionSubmissionDefinitionSelection: DynamicSelectModel<string> = new DynamicSelectModel(collectionFormCorrectionSubmissionDefinitionSelectionConfig);
105-
10698
sharedWorkspaceChekbox: DynamicCheckboxModel = new DynamicCheckboxModel(collectionFormSharedWorkspaceCheckboxConfig);
10799

108100
/**
@@ -145,13 +137,11 @@ export class CollectionFormComponent extends ComColFormComponent<Collection> imp
145137
initializeForm() {
146138
let currentRelationshipValue: MetadataValue[];
147139
let currentDefinitionValue: MetadataValue[];
148-
let currentCorrectionDefinitionValue: MetadataValue[];
149140
let currentSharedWorkspaceValue: MetadataValue[];
150141
if (this.dso && this.dso.metadata) {
151142
currentRelationshipValue = this.dso.metadata['dspace.entity.type'];
152-
currentDefinitionValue = this.dso.metadata['cris.submission.definition'];
153-
currentCorrectionDefinitionValue = this.dso.metadata['cris.submission.definition-correction'];
154-
currentSharedWorkspaceValue = this.dso.metadata['cris.workspace.shared'];
143+
currentDefinitionValue = this.dso.metadata['dspace.submission.definition'];
144+
currentSharedWorkspaceValue = this.dso.metadata['dspace.workspace.shared'];
155145
}
156146

157147
const entities$: Observable<ItemType[]> = this.entityTypeService.findAll({ elementsPerPage: 100, currentPage: 1 }).pipe(
@@ -169,7 +159,6 @@ export class CollectionFormComponent extends ComColFormComponent<Collection> imp
169159
.subscribe(([entityTypes, definitions]: [ItemType[], SubmissionDefinitionModel[]]) => {
170160

171161
const sortedEntityTypes = entityTypes
172-
.filter((type: ItemType) => type.label !== NONE_ENTITY_TYPE)
173162
.sort((a, b) => a.label.localeCompare(b.label));
174163

175164
sortedEntityTypes.forEach((type: ItemType, index: number) => {
@@ -190,22 +179,14 @@ export class CollectionFormComponent extends ComColFormComponent<Collection> imp
190179
label: definition.name,
191180
value: definition.name,
192181
} as DynamicFormOptionConfig<string>);
193-
this.correctionSubmissionDefinitionSelection.add({
194-
disabled: false,
195-
label: definition.name,
196-
value: definition.name,
197-
} as DynamicFormOptionConfig<string>);
198182
if (currentDefinitionValue && currentDefinitionValue.length > 0 && currentDefinitionValue[0].value === definition.name) {
199183
this.submissionDefinitionSelection.select(index);
200184
}
201-
if (currentCorrectionDefinitionValue && currentCorrectionDefinitionValue.length > 0 && currentCorrectionDefinitionValue[0].value === definition.name) {
202-
this.correctionSubmissionDefinitionSelection.select(index);
203-
}
204185
});
205186

206187
this.formModel = entityTypes.length === 0 ?
207-
[...collectionFormModels, this.submissionDefinitionSelection, this.correctionSubmissionDefinitionSelection, this.sharedWorkspaceChekbox] :
208-
[...collectionFormModels, this.entityTypeSelection, this.submissionDefinitionSelection, this.correctionSubmissionDefinitionSelection, this.sharedWorkspaceChekbox];
188+
[...collectionFormModels, this.submissionDefinitionSelection, this.sharedWorkspaceChekbox] :
189+
[...collectionFormModels, this.entityTypeSelection, this.submissionDefinitionSelection, this.sharedWorkspaceChekbox];
209190

210191
super.ngOnInit();
211192

src/app/collection-page/collection-form/collection-form.models.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ import { environment } from '../../../environments/environment';
1111
export const collectionFormEntityTypeSelectionConfig: DynamicSelectModelConfig<string> = {
1212
id: 'entityType',
1313
name: 'dspace.entity.type',
14-
required: true,
1514
disabled: false,
16-
validators: {
17-
required: null,
18-
},
1915
errorMessages: {
2016
required: 'collection.form.errors.entityType.required',
2117
},
@@ -24,21 +20,12 @@ export const collectionFormEntityTypeSelectionConfig: DynamicSelectModelConfig<s
2420
export const collectionFormSubmissionDefinitionSelectionConfig: DynamicSelectModelConfig<string> = {
2521
id: 'submissionDefinition',
2622
name: 'cris.submission.definition',
27-
required: true,
2823
disabled: false,
29-
validators: {
30-
required: null,
31-
},
3224
errorMessages: {
3325
required: 'collection.form.errors.submissionDefinition.required',
3426
},
3527
};
36-
export const collectionFormCorrectionSubmissionDefinitionSelectionConfig: DynamicSelectModelConfig<string> = {
37-
id: 'correctionSubmissionDefinition',
38-
name: 'cris.submission.definition-correction',
39-
required: false,
40-
disabled: false,
41-
};
28+
4229

4330
export const collectionFormSharedWorkspaceCheckboxConfig: DynamicCheckboxModelConfig = {
4431
id: 'sharedWorkspace',

0 commit comments

Comments
 (0)