Skip to content

Commit 8982db7

Browse files
[DURACOM-453] add back button to footer, add breadcrumb in edit page, fix issue with dso edit loader, minor restyle in submission footer
1 parent 386078e commit 8982db7

8 files changed

Lines changed: 83 additions & 48 deletions

File tree

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

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import {
3939
} from '@ngx-translate/core';
4040
import {
4141
catchError,
42-
combineLatest,
42+
forkJoin,
4343
Observable,
4444
of,
4545
} from 'rxjs';
@@ -155,46 +155,47 @@ export class CollectionFormComponent extends ComColFormComponent<Collection> imp
155155
);
156156

157157
// retrieve all entity types and submission definitions to populate the dropdowns selection
158-
combineLatest([entities$, definitions$])
159-
.subscribe(([entityTypes, definitions]: [ItemType[], SubmissionDefinitionModel[]]) => {
160-
161-
const sortedEntityTypes = entityTypes
162-
.sort((a, b) => a.label.localeCompare(b.label));
163-
164-
sortedEntityTypes.forEach((type: ItemType, index: number) => {
165-
this.entityTypeSelection.add({
166-
disabled: false,
167-
label: type.label,
168-
value: type.label,
169-
} as DynamicFormOptionConfig<string>);
170-
if (currentRelationshipValue && currentRelationshipValue.length > 0 && currentRelationshipValue[0].value === type.label) {
171-
this.entityTypeSelection.select(index);
172-
this.entityTypeSelection.disabled = true;
173-
}
174-
});
175-
176-
definitions.filter(def => !def.id.includes('-edit')).forEach((definition: SubmissionDefinitionModel, index: number) => {
177-
this.submissionDefinitionSelection.add({
178-
disabled: false,
179-
label: definition.name,
180-
value: definition.name,
181-
} as DynamicFormOptionConfig<string>);
182-
if (currentDefinitionValue && currentDefinitionValue.length > 0 && currentDefinitionValue[0].value === definition.name) {
183-
this.submissionDefinitionSelection.select(index);
184-
}
185-
});
186-
187-
this.formModel = entityTypes.length === 0 ?
188-
[...collectionFormModels, this.submissionDefinitionSelection, this.sharedWorkspaceChekbox] :
189-
[...collectionFormModels, this.entityTypeSelection, this.submissionDefinitionSelection, this.sharedWorkspaceChekbox];
190-
191-
super.ngOnInit();
192-
193-
if (currentSharedWorkspaceValue && currentSharedWorkspaceValue.length > 0) {
194-
this.sharedWorkspaceChekbox.value = currentSharedWorkspaceValue[0].value === 'true';
158+
forkJoin({
159+
entityTypes: entities$,
160+
definitions: definitions$,
161+
}).subscribe(({ entityTypes, definitions }: {entityTypes: ItemType[]; definitions: ConfigObject[]}) => {
162+
const sortedEntityTypes = entityTypes
163+
.sort((a, b) => a.label.localeCompare(b.label));
164+
165+
sortedEntityTypes.forEach((type: ItemType, index: number) => {
166+
this.entityTypeSelection.add({
167+
disabled: false,
168+
label: type.label,
169+
value: type.label,
170+
} as DynamicFormOptionConfig<string>);
171+
if (currentRelationshipValue && currentRelationshipValue.length > 0 && currentRelationshipValue[0].value === type.label) {
172+
this.entityTypeSelection.select(index);
173+
this.entityTypeSelection.disabled = true;
195174
}
196-
this.chd.detectChanges();
197175
});
198176

177+
definitions.filter(def => !def.id.includes('-edit')).forEach((definition: SubmissionDefinitionModel, index: number) => {
178+
this.submissionDefinitionSelection.add({
179+
disabled: false,
180+
label: definition.name,
181+
value: definition.name,
182+
} as DynamicFormOptionConfig<string>);
183+
if (currentDefinitionValue && currentDefinitionValue.length > 0 && currentDefinitionValue[0].value === definition.name) {
184+
this.submissionDefinitionSelection.select(index);
185+
}
186+
});
187+
188+
this.formModel = entityTypes.length === 0 ?
189+
[...collectionFormModels, this.submissionDefinitionSelection, this.sharedWorkspaceChekbox] :
190+
[...collectionFormModels, this.entityTypeSelection, this.submissionDefinitionSelection, this.sharedWorkspaceChekbox];
191+
192+
super.ngOnInit();
193+
194+
if (currentSharedWorkspaceValue && currentSharedWorkspaceValue.length > 0) {
195+
this.sharedWorkspaceChekbox.value = currentSharedWorkspaceValue[0].value === 'true';
196+
}
197+
this.chd.detectChanges();
198+
});
199+
199200
}
200201
}

src/app/dso-shared/dso-edit-metadata/dso-edit-metadata-value/dso-edit-metadata-value.component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ export class DsoEditMetadataValueComponent implements OnInit, OnChanges, OnDestr
363363
* @param {SimpleChanges} changes
364364
*/
365365
ngOnChanges(changes: SimpleChanges): void {
366+
if (changes.mdField) {
367+
this.fieldType$ = this.getFieldType();
368+
}
369+
366370
if (isNotEmpty(changes.mdField) && !changes.mdField.firstChange) {
367371
if (isNotEmpty(changes.mdField.currentValue) ) {
368372
if (isNotEmpty(changes.mdField.previousValue) &&

src/app/edit-item/edit-item-routes.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Route } from '@angular/router';
2+
import { i18nBreadcrumbResolver } from '@dspace/core/breadcrumbs/i18n-breadcrumb.resolver';
23

34
import { authenticatedGuard } from '../core/auth/authenticated.guard';
45
import { pendingChangesGuard } from '../submission/edit/pending-changes/pending-changes.guard';
@@ -14,7 +15,13 @@ export const ROUTES: Route[] = [
1415
canActivate: [authenticatedGuard],
1516
canDeactivate: [pendingChangesGuard],
1617
component: ThemedSubmissionEditComponent,
17-
data: { title: 'submission.edit.title' },
18+
resolve: {
19+
breadcrumb: i18nBreadcrumbResolver,
20+
},
21+
data: {
22+
title: 'submission.edit.title',
23+
breadcrumbKey: 'submission.edit.item',
24+
},
1825
},
1926
],
2027
},

src/app/shared/form/builder/parsers/concat-field-parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class ConcatFieldParser extends FieldParser {
4141
protected separator: string,
4242
protected firstPlaceholder: string = null,
4343
protected secondPlaceholder: string = null) {
44-
super(submissionId, configData, initFormValues, parserOptions, translate, securityConfig);
44+
super(submissionId, configData, initFormValues, parserOptions, securityConfig, translate);
4545

4646
this.separator = separator;
4747
this.firstPlaceholder = firstPlaceholder;

src/app/shared/form/builder/parsers/field-parser.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { FormFieldMetadataValueObject } from '@dspace/core/shared/form/models/fo
77
import { MetadataValue } from '@dspace/core/shared/metadata.models';
88
import { Metadata } from '@dspace/core/shared/metadata.utils';
99
import { RelationshipOptions } from '@dspace/core/shared/relationship-options.model';
10+
import { MetadataSecurityConfiguration } from '@dspace/core/submission/models/metadata-security-configuration';
1011
import { SectionVisibility } from '@dspace/core/submission/models/section-visibility.model';
1112
import { SubmissionScopeType } from '@dspace/core/submission/submission-scope-type';
1213
import { VisibilityType } from '@dspace/core/submission/visibility-type';
@@ -46,7 +47,7 @@ export const PARSER_OPTIONS: InjectionToken<ParserOptions> = new InjectionToken<
4647
* The regex itself is encapsulated inside a `RegExp` object, that will validate the pattern syntax.
4748
*/
4849
export const REGEX_FIELD_VALIDATOR = new RegExp('(\\/?)(.+)\\1([gimsuy]*)', 'i');
49-
export const SECURITY_CONFIG: InjectionToken<any> = new InjectionToken<any>('securityConfig');
50+
export const SECURITY_CONFIG: InjectionToken<MetadataSecurityConfiguration> = new InjectionToken<MetadataSecurityConfiguration>('securityConfig');
5051

5152
export abstract class FieldParser {
5253

@@ -62,7 +63,7 @@ export abstract class FieldParser {
6263
@Inject(CONFIG_DATA) protected configData: FormFieldModel,
6364
@Inject(INIT_FORM_VALUES) protected initFormValues: any,
6465
@Inject(PARSER_OPTIONS) protected parserOptions: ParserOptions,
65-
@Inject(SECURITY_CONFIG) protected securityConfig: any = null,
66+
@Inject(SECURITY_CONFIG) protected securityConfig: MetadataSecurityConfiguration = null,
6667
protected translate: TranslateService,
6768
) {
6869
}
@@ -456,7 +457,7 @@ export abstract class FieldParser {
456457
// look to find security for metadata
457458
if (this.securityConfig && metadata) {
458459
if (this.securityConfig.metadataCustomSecurity) {
459-
const metadataConfig = (this.securityConfig.metadataCustomSecurity as any)[metadata];
460+
const metadataConfig = this.securityConfig.metadataCustomSecurity[metadata];
460461
if (metadataConfig) {
461462
return metadataConfig;
462463
} else {

src/app/submission/form/footer/submission-form-footer.component.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,19 @@
1111
(click)="$event.preventDefault();confirmDiscard(content)">
1212
<i class="fas fa-trash"></i> {{'submission.general.discard.submit' | translate}}
1313
</button>
14+
} @else {
15+
<button
16+
type="button"
17+
id="cancel"
18+
[attr.data-test]="'cancel' | dsBrowserOnly"
19+
class="btn btn-outline-primary"
20+
[dsBtnDisabled]="(processingSaveStatus | async) || (processingDepositStatus | async)"
21+
(click)="navigateBack()">
22+
<i class="fas fa-arrow-left"></i> {{'submission.general.back.submit' | translate}}
23+
</button>
1424
}
1525
</div>
16-
<div class="text-end d-flex justify-content-end align-items-center flex-sm-row flex-column">
26+
<div class="text-end d-flex justify-content-end align-items-center flex-sm-row flex-column gap-1">
1727
@if ((hasUnsavedModification | async) !== true && (processingSaveStatus | async) !== true && (processingDepositStatus | async) !== true && (submissionIsInvalid | async)) {
1828
<span>
1929
<i class="fas fa-warning"></i> {{'submission.general.info.invalid' | translate}}

src/app/submission/form/footer/submission-form-footer.component.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { AsyncPipe } from '@angular/common';
1+
import {
2+
AsyncPipe,
3+
Location,
4+
} from '@angular/common';
25
import {
36
Component,
47
Input,
@@ -79,8 +82,8 @@ export class SubmissionFormFooterComponent implements OnChanges {
7982
* @param {SubmissionService} submissionService
8083
*/
8184
constructor(private modalService: NgbModal,
82-
private restService: SubmissionRestService,
83-
private submissionService: SubmissionService) {
85+
private submissionService: SubmissionService,
86+
private location: Location) {
8487
}
8588

8689
/**
@@ -143,4 +146,11 @@ export class SubmissionFormFooterComponent implements OnChanges {
143146
return 'submission.general.save-later';
144147
}
145148

149+
/**
150+
* When back button is pressed go to previous location
151+
*/
152+
navigateBack(): void {
153+
this.location.back();
154+
}
155+
146156
}

src/assets/i18n/en.json5

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5237,6 +5237,8 @@
52375237

52385238
"submission.edit.title": "Edit Submission",
52395239

5240+
"submission.edit.item.breadcrumbs": "Edit item",
5241+
52405242
"submission.general.cancel": "Cancel",
52415243

52425244
"submission.general.cannot_submit": "You don't have permission to make a new submission.",

0 commit comments

Comments
 (0)