Skip to content

Commit 89d0517

Browse files
committed
Merge branch 'refs/heads/dspace-cris-2023_02_x' into ux-plus-2023_02_x
# Conflicts: # src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts
2 parents 8632373 + 1b19d0f commit 89d0517

18 files changed

Lines changed: 136 additions & 78 deletions

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

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,23 @@ export class CollectionFormComponent extends ComColFormComponent<Collection> imp
136136

137137
// retrieve all entity types and submission definitions to populate the dropdowns selection
138138
combineLatest([entities$, definitions$])
139-
.subscribe(([entityTypes, definitions]: [ItemType[], SubmissionDefinitionModel[]]) => {
140-
141-
entityTypes = entityTypes.filter((type: ItemType) => type.label !== NONE_ENTITY_TYPE);
142-
entityTypes.forEach((type: ItemType, index: number) => {
143-
this.entityTypeSelection.add({
144-
disabled: false,
145-
label: type.label,
146-
value: type.label
147-
} as DynamicFormOptionConfig<string>);
148-
if (currentRelationshipValue && currentRelationshipValue.length > 0 && currentRelationshipValue[0].value === type.label) {
149-
this.entityTypeSelection.select(index);
150-
this.entityTypeSelection.disabled = true;
151-
}
152-
});
139+
.subscribe(([entityTypes, definitions]: [ItemType[], SubmissionDefinitionModel[]]) => {
140+
141+
const sortedEntityTypes = entityTypes
142+
.filter((type: ItemType) => type.label !== NONE_ENTITY_TYPE)
143+
.sort((a, b) => a.label.localeCompare(b.label));
144+
145+
sortedEntityTypes.forEach((type: ItemType, index: number) => {
146+
this.entityTypeSelection.add({
147+
disabled: false,
148+
label: type.label,
149+
value: type.label
150+
} as DynamicFormOptionConfig<string>);
151+
if (currentRelationshipValue && currentRelationshipValue.length > 0 && currentRelationshipValue[0].value === type.label) {
152+
this.entityTypeSelection.select(index);
153+
this.entityTypeSelection.disabled = true;
154+
}
155+
});
153156

154157
definitions.forEach((definition: SubmissionDefinitionModel, index: number) => {
155158
this.submissionDefinitionSelection.add({

src/app/item-page/edit-item-page/edit-item-page.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="bern-component-container mt-4">
1+
<div class="container">
22
<div class="row">
33
<div class="col-12">
44
<h2 class="border-bottom">{{'item.edit.head' | translate}}</h2>

src/app/search-navbar/search-navbar.component.scss

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,9 @@ input[type="text"] {
2121
}
2222

2323
@media screen and (max-width: map-get($grid-breakpoints, md)) {
24-
.query:focus {
24+
.search-input {
2525
max-width: 250px !important;
2626
width: 40vw !important;
2727
}
2828

2929
}
30-
31-
@media screen and (max-width: map-get($grid-breakpoints, sm)) {
32-
.search-input {
33-
width: 55vw !important;
34-
}
35-
}

src/app/search-page/configuration-search-page.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { RouteService } from '../core/services/route.service';
99
import { SearchService } from '../core/shared/search/search.service';
1010
import { Router } from '@angular/router';
1111
import { SearchManager } from '../core/browse/search-manager';
12+
import { APP_CONFIG, AppConfig } from '../../config/app-config.interface';
1213

1314
/**
1415
* This component renders a search page using a configuration as input.
@@ -35,7 +36,8 @@ export class ConfigurationSearchPageComponent extends SearchComponent {
3536
@Inject(PLATFORM_ID) public platformId: any,
3637
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService,
3738
protected routeService: RouteService,
38-
protected router: Router) {
39-
super(service, searchManager, sidebarService, windowService, searchConfigService, platformId, routeService, router);
39+
protected router: Router,
40+
@Inject(APP_CONFIG) protected appConfig: AppConfig,) {
41+
super(service, searchManager, sidebarService, windowService, searchConfigService, platformId, routeService, router, appConfig);
4042
}
4143
}

src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import {
33
Component,
44
ComponentFactoryResolver,
55
ContentChildren,
6-
EventEmitter,
7-
Inject,
6+
EventEmitter, Inject,
87
Input,
98
NgZone,
109
OnChanges,
@@ -59,9 +58,7 @@ import { TranslateService } from '@ngx-translate/core';
5958
import { ReorderableRelationship } from './existing-metadata-list-element/existing-metadata-list-element.component';
6059

6160
import { DYNAMIC_FORM_CONTROL_TYPE_ONEBOX } from './models/onebox/dynamic-onebox.model';
62-
import {
63-
DYNAMIC_FORM_CONTROL_TYPE_SCROLLABLE_DROPDOWN
64-
} from './models/scrollable-dropdown/dynamic-scrollable-dropdown.model';
61+
import { DYNAMIC_FORM_CONTROL_TYPE_SCROLLABLE_DROPDOWN } from './models/scrollable-dropdown/dynamic-scrollable-dropdown.model';
6562
import { DYNAMIC_FORM_CONTROL_TYPE_TAG } from './models/tag/dynamic-tag.model';
6663
import { DYNAMIC_FORM_CONTROL_TYPE_DSDATEPICKER } from './models/date-picker/date-picker.model';
6764
import { DYNAMIC_FORM_CONTROL_TYPE_LOOKUP } from './models/lookup/dynamic-lookup.model';
@@ -73,9 +70,7 @@ import { DsDynamicTagComponent } from './models/tag/dynamic-tag.component';
7370
import { DsDatePickerComponent } from './models/date-picker/date-picker.component';
7471
import { DsDynamicListComponent } from './models/list/dynamic-list.component';
7572
import { DsDynamicOneboxComponent } from './models/onebox/dynamic-onebox.component';
76-
import {
77-
DsDynamicScrollableDropdownComponent
78-
} from './models/scrollable-dropdown/dynamic-scrollable-dropdown.component';
73+
import { DsDynamicScrollableDropdownComponent } from './models/scrollable-dropdown/dynamic-scrollable-dropdown.component';
7974
import { DsDynamicLookupComponent } from './models/lookup/dynamic-lookup.component';
8075
import { DsDynamicFormGroupComponent } from './models/form-group/dynamic-form-group.component';
8176
import { DsDynamicFormArrayComponent } from './models/array-group/dynamic-form-array.component';
@@ -87,9 +82,7 @@ import { CustomSwitchComponent } from './models/custom-switch/custom-switch.comp
8782
import { find, map, startWith, switchMap, take } from 'rxjs/operators';
8883
import { combineLatest as observableCombineLatest, Observable, Subscription } from 'rxjs';
8984
import { DsDynamicTypeBindRelationService } from './ds-dynamic-type-bind-relation.service';
90-
import {
91-
DsDynamicRelationInlineGroupComponent
92-
} from './models/relation-inline-group/dynamic-relation-inline-group.components';
85+
import { DsDynamicRelationInlineGroupComponent } from './models/relation-inline-group/dynamic-relation-inline-group.components';
9386
import { SearchResult } from '../../../search/models/search-result.model';
9487
import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
9588
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
@@ -130,6 +123,7 @@ import { APP_CONFIG, AppConfig } from '../../../../../config/app-config.interfac
130123
import { itemLinksToFollow } from '../../../utils/relation-query.utils';
131124
import { DynamicConcatModel } from './models/ds-dynamic-concat.model';
132125
import { Metadata } from '../../../../core/shared/metadata.utils';
126+
import { DynamicLinkModel } from './models/ds-dynamic-link.model';
133127
import { DsDynamicMarkdownComponent } from './models/markdown/dynamic-markdown.component';
134128
import { DYNAMIC_FORM_CONTROL_TYPE_MARKDOWN } from './models/markdown/dynamic-markdown.model';
135129

@@ -560,13 +554,13 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo
560554
addSecurityLevelToMetadata($event) {
561555
this.model.securityLevel = $event;
562556
this.securityLevel = $event;
563-
if (this.model.parent && this.model.parent instanceof DynamicConcatModel) {
557+
if (this.model.parent && (this.model.parent instanceof DynamicConcatModel || this.model.parent instanceof DynamicLinkModel)) {
564558
this.model.parent.securityLevel = $event;
565559
}
566560
if (this.model.value) {
567561
this.model.securityLevel = $event;
568562
this.securityLevel = $event;
569-
if (this.model.parent && this.model.parent instanceof DynamicConcatModel) {
563+
if (this.model.parent && (this.model.parent instanceof DynamicConcatModel || this.model.parent instanceof DynamicLinkModel)) {
570564
this.model.parent.securityLevel = $event;
571565
}
572566
this.change.emit(

src/app/shared/form/builder/ds-dynamic-form-ui/models/link/dynamic-link.model.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/app/shared/form/form.component.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import { DynamicRowGroupModel } from './builder/ds-dynamic-form-ui/models/ds-dyn
2828
import {
2929
DynamicRelationGroupModel
3030
} from './builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.model';
31+
import { DynamicLinkModel } from './builder/ds-dynamic-form-ui/models/ds-dynamic-link.model';
32+
import { DynamicConcatModel } from './builder/ds-dynamic-form-ui/models/ds-dynamic-concat.model';
3133

3234
export interface MetadataFields {
3335
[key: string]: FormFieldMetadataValueObject[]
@@ -78,7 +80,7 @@ export class FormComponent implements OnDestroy, OnInit {
7880
@Input() submitLabel = 'form.submit';
7981

8082
/**
81-
* i18n key for the reset button
83+
* i18n key for the cancel button
8284
*/
8385
@Input() resetLabel = 'form.reset';
8486

@@ -355,7 +357,12 @@ export class FormComponent implements OnDestroy, OnInit {
355357
if (index === 0 && formArrayControl.value?.length === 1) {
356358
event.model = cloneDeep(event.model);
357359
const fieldId = event.model.id;
358-
formArrayControl.at(0).get(fieldId).setValue(null);
360+
361+
if (event.model instanceof DynamicLinkModel || event.model instanceof DynamicConcatModel) {
362+
formArrayControl.at(0).get(fieldId).reset();
363+
} else {
364+
formArrayControl.at(0).get(fieldId).setValue(null);
365+
}
359366
} else {
360367
this.formBuilderService.removeFormArrayGroup(index, formArrayControl, arrayContext);
361368
}
@@ -424,18 +431,18 @@ export class FormComponent implements OnDestroy, OnInit {
424431

425432
private updateMetadataValue(metadataFields: MetadataFields): void {
426433
const metadataKeys = hasValue(metadataFields) ? Object.keys(metadataFields) : [];
427-
const formKeys = hasValue(this.formGroup.value) ? Object.keys(this.formGroup.value) : [];
434+
const formKeys = hasValue(this.formGroup.value) ? Object.keys(this.formGroup.value).map(key => key.replace('_array', '')) : [];
428435

429436
formKeys
430437
.filter((key) => isNotEmpty(this.formGroup.value[key]))
431438
.forEach((key) => {
432-
const innerObjectKeys = (Object.keys(this.formGroup.value[key]) as any[]).map((oldKey) => oldKey.replaceAll('_', '.'));
439+
const innerObjectKeys = (Object.keys(this.formGroup.value[key] ?? {} ) as any[]).map((oldKey) => oldKey.replaceAll('_', '.'));
433440
const filteredKeys = innerObjectKeys.filter(innerKey => metadataKeys.includes(innerKey));
434441
const oldValue = this.formGroup.value[key];
435442

436443
if (filteredKeys.length > 0) {
437444
filteredKeys.forEach((oldValueKey) => {
438-
const newValue = { ...oldValue };
445+
const newValue = {...oldValue};
439446
const formattedKey = (oldValueKey as any).replaceAll('.', '_');
440447
const patchValue = {};
441448

@@ -447,6 +454,6 @@ export class FormComponent implements OnDestroy, OnInit {
447454
}
448455
});
449456
}
450-
});
457+
});
451458
}
452459
}

src/app/shared/form/form.service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
} from './form.actions';
2222
import { FormEntry, FormError, FormTouchedState } from './form.reducer';
2323
import { environment } from '../../../environments/environment';
24+
import { DynamicLinkModel } from './builder/ds-dynamic-form-ui/models/ds-dynamic-link.model';
2425

2526
@Injectable()
2627
export class FormService {
@@ -137,6 +138,7 @@ export class FormService {
137138
}
138139

139140
public addErrorToField(field: AbstractControl, model: DynamicFormControlModel, message: string) {
141+
140142
const error = {}; // create the error object
141143
const errorKey = this.getValidatorNameFromMap(message);
142144
let errorMsg = message;
@@ -163,9 +165,9 @@ export class FormService {
163165
}
164166

165167
// if the field in question is a concat group, pass down the error to its fields
166-
if (field instanceof UntypedFormGroup && model instanceof DynamicFormGroupModel && this.formBuilderService.isConcatGroup(model)) {
168+
if ((field instanceof UntypedFormGroup && model instanceof DynamicFormGroupModel && this.formBuilderService.isConcatGroup(model)) || model instanceof DynamicLinkModel) {
167169
model.group.forEach((subModel) => {
168-
const subField = field.controls[subModel.id];
170+
const subField = (field as UntypedFormGroup).controls[subModel.id];
169171

170172
this.addErrorToField(subField, subModel, message);
171173
});

src/app/shared/loading/loading.component.spec.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-transla
77
import { TranslateLoaderMock } from '../mocks/translate-loader.mock';
88

99
import { LoadingComponent } from './loading.component';
10+
import { Router } from '@angular/router';
11+
import { RouterMock } from '../mocks/router.mock';
1012

1113
describe('LoadingComponent (inline template)', () => {
1214

@@ -26,8 +28,12 @@ describe('LoadingComponent (inline template)', () => {
2628
}),
2729
],
2830
declarations: [LoadingComponent], // declare the test component
29-
providers: [TranslateService]
31+
providers: [
32+
TranslateService,
33+
{provide: Router, useValue: new RouterMock()},
34+
]
3035
}).compileComponents(); // compile template and css
36+
3137
}));
3238

3339
beforeEach(() => {
@@ -75,4 +81,14 @@ describe('LoadingComponent (inline template)', () => {
7581
expect(de).toBeTruthy();
7682
});
7783

84+
it('should add time if the page has been automatically reloaded', () => {
85+
comp.pageReloadCount = 1;
86+
comp.errorMessageDelay = 1000;
87+
comp.warningMessageDelay = 500;
88+
comp.numberOfAutomaticPageReloads = 2;
89+
comp.ngOnInit();
90+
91+
expect(comp.errorTimeoutWithRetriesDelay).toBe(1500);
92+
});
93+
7894
});

0 commit comments

Comments
 (0)