Skip to content

Commit d71964d

Browse files
authored
Merge pull request DSpace#3113 from 4Science/task/main/DURACOM-271_coar-fixes-fixed
COAR Notify impossible to send/receive message from another DSpace
2 parents f7a14a1 + fe09cb6 commit d71964d

49 files changed

Lines changed: 699 additions & 475 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.html

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ <h1 class="flex-grow-1">{{ isNewService ? ('ldn-create-service.title' | translat
212212
<span> {{'ldn-service.control-constaint-select-none' | translate}} </span>
213213
</button>
214214
<button (click)="selectInboundItemFilter(constraint.id, i); $event.stopPropagation()"
215-
*ngFor="let constraint of (itemfiltersRD$ | async)?.payload?.page; let internalIndex = index"
215+
*ngFor="let constraint of (itemFiltersRD$ | async)?.payload?.page; let internalIndex = index"
216216
class="dropdown-item collection-item text-truncate w-100"
217217
ngbDropdownItem
218218
type="button">
@@ -263,14 +263,18 @@ <h1 class="flex-grow-1">{{ isNewService ? ('ldn-create-service.title' | translat
263263

264264
<span (click)="addInboundPattern()"
265265
class="add-pattern-link mb-2">{{ 'ldn-new-service.form.label.addPattern' | translate }}</span>
266+
<hr>
267+
<div class="form-group row">
268+
<div class="col text-right space-children-mr">
269+
<ng-content select="[before]"></ng-content>
270+
<button (click)="resetFormAndLeave()" class="btn btn-outline-secondary" type="button">
271+
<span>&nbsp;{{ 'submission.general.back.submit' | translate }}</span>
272+
</button>
273+
<button class="btn btn-primary" type="submit">
274+
<span><i class="fas fa-save"></i>&nbsp;{{ 'ldn-new-service.form.label.submit' | translate }}</span>
275+
</button>
266276

267-
<div class="submission-form-footer my-1 position-sticky d-flex justify-content-between" role="group">
268-
<button (click)="resetFormAndLeave()" class="btn btn-primary" type="button">
269-
<span>&nbsp;{{ 'submission.general.back.submit' | translate }}</span>
270-
</button>
271-
<button class="btn btn-primary" type="submit">
272-
<span><i class="fas fa-save"></i>&nbsp;{{ 'ldn-new-service.form.label.submit' | translate }}</span>
273-
</button>
277+
</div>
274278
</div>
275279
</form>
276280
</div>
@@ -294,15 +298,15 @@ <h4 *ngIf="isNewService">{{'service.overview.create.modal' | translate }}</h4>
294298
</div>
295299
<div class="modal-footer">
296300
<div *ngIf="!isNewService">
297-
<button (click)="closeModal()" class="btn btn-danger mr-2"
301+
<button (click)="closeModal()" class="btn btn-outline-secondary mr-2"
298302
id="delete-confirm-edit">{{ 'service.detail.return' | translate }}
299303
</button>
300304
<button *ngIf="!isNewService" (click)="patchService()"
301305
class="btn btn-primary">{{ 'service.detail.update' | translate }}
302306
</button>
303307
</div>
304308
<div *ngIf="isNewService">
305-
<button (click)="closeModal()" class="btn btn-danger mr-2 "
309+
<button (click)="closeModal()" class="btn btn-outline-secondary mr-2 "
306310
id="delete-confirm-new">{{ 'service.refuse.create' | translate }}
307311
</button>
308312
<button (click)="createService()"

src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,15 @@ describe('LdnServiceFormEditComponent', () => {
145145

146146
it('should init properties correctly', fakeAsync(() => {
147147
spyOn(component, 'fetchServiceData');
148-
spyOn(component, 'setItemfilters');
148+
spyOn(component, 'setItemFilters');
149149
component.ngOnInit();
150150
tick(100);
151151
expect((component as any).serviceId).toEqual(testId);
152152
expect(component.isNewService).toBeFalsy();
153153
expect(component.areControlsInitialized).toBeTruthy();
154154
expect(component.formModel.controls.notifyServiceInboundPatterns).toBeDefined();
155155
expect(component.fetchServiceData).toHaveBeenCalledWith(testId);
156-
expect(component.setItemfilters).toHaveBeenCalled();
156+
expect(component.setItemFilters).toHaveBeenCalled();
157157
}));
158158

159159
it('should unsubscribe on destroy', () => {

src/app/admin/admin-ldn-services/ldn-service-form/ldn-service-form.component.ts

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
9292
public inboundPatterns: string[] = notifyPatterns;
9393
public isNewService: boolean;
9494
public areControlsInitialized: boolean;
95-
public itemfiltersRD$: Observable<RemoteData<PaginatedList<Itemfilter>>>;
95+
public itemFiltersRD$: Observable<RemoteData<PaginatedList<Itemfilter>>>;
9696
public config: FindListOptions = Object.assign(new FindListOptions(), {
9797
elementsPerPage: 20,
9898
});
@@ -104,12 +104,12 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
104104
private deletedInboundPatterns: number[] = [];
105105
private modalRef: any;
106106
private ldnService: LdnService;
107-
private selectPatternDefaultLabeli18Key = 'ldn-service.form.label.placeholder.default-select';
107+
private selectPatternDefaultLabelI18Key = 'ldn-service.form.label.placeholder.default-select';
108108
private routeSubscription: Subscription;
109109

110110
constructor(
111111
protected ldnServicesService: LdnServicesService,
112-
private ldnItemfiltersService: LdnItemfiltersService,
112+
private ldnItemFiltersService: LdnItemfiltersService,
113113
private formBuilder: FormBuilder,
114114
private router: Router,
115115
private route: ActivatedRoute,
@@ -147,7 +147,7 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
147147
this.fetchServiceData(this.serviceId);
148148
}
149149
});
150-
this.setItemfilters();
150+
this.setItemFilters();
151151
}
152152

153153
ngOnDestroy(): void {
@@ -157,8 +157,8 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
157157
/**
158158
* Sets item filters using LDN item filters service
159159
*/
160-
setItemfilters() {
161-
this.itemfiltersRD$ = this.ldnItemfiltersService.findAll().pipe(
160+
setItemFilters() {
161+
this.itemFiltersRD$ = this.ldnItemFiltersService.findAll().pipe(
162162
getFirstCompletedRemoteData());
163163
}
164164

@@ -168,21 +168,12 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
168168
*/
169169
createService() {
170170
this.formModel.markAllAsTouched();
171-
const notifyServiceInboundPatterns = this.formModel.get('notifyServiceInboundPatterns') as FormArray;
172-
const hasInboundPattern = notifyServiceInboundPatterns?.length > 0 ? this.checkPatterns(notifyServiceInboundPatterns) : false;
173171

174172
if (this.formModel.invalid) {
175173
this.closeModal();
176174
return;
177175
}
178176

179-
if (!hasInboundPattern) {
180-
this.notificationService.warning(this.translateService.get('ldn-service-notification.created.warning.title'));
181-
this.closeModal();
182-
return;
183-
}
184-
185-
186177
this.formModel.value.notifyServiceInboundPatterns = this.formModel.value.notifyServiceInboundPatterns.map((pattern: {
187178
pattern: string;
188179
patternLabel: string,
@@ -272,20 +263,24 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
272263
}
273264

274265
/**
275-
* Filters pattern objects, initializes form groups, assigns labels, and adds them to the specified form array so the correct string is shown in the dropdown..
266+
* Filters pattern objects, initializes form groups, assigns labels, and adds them to the specified form array so the correct string is shown in the dropdown.
276267
* @param formArrayName - The name of the form array to be populated
277268
*/
278269
filterPatternObjectsAndAssignLabel(formArrayName: string) {
279270
const PatternsArray = this.formModel.get(formArrayName) as FormArray;
280271
PatternsArray.clear();
281272

282-
const servicesToUse = this.ldnService.notifyServiceInboundPatterns;
273+
const servicesToUse = [...this.ldnService.notifyServiceInboundPatterns];
274+
if (servicesToUse.length === 0) {
275+
servicesToUse.push({ pattern: '', constraint: '', automatic: 'false' });
276+
}
283277

284278
servicesToUse.forEach((patternObj: NotifyServicePattern) => {
285279
const patternFormGroup = this.initializeInboundPatternFormGroup();
280+
const patternLabel = patternObj?.pattern ? 'ldn-service.form.pattern.' + patternObj?.pattern + '.label' : 'ldn-service.form.label.placeholder.default-select';
286281
const newPatternObjWithLabel = Object.assign(new NotifyServicePattern(), {
287282
...patternObj,
288-
patternLabel: this.translateService.instant('ldn-service.form.pattern.' + patternObj?.pattern + '.label'),
283+
patternLabel: this.translateService.instant(patternLabel),
289284
});
290285
patternFormGroup.patchValue(newPatternObjWithLabel);
291286

@@ -412,7 +407,7 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
412407
}
413408

414409
/**
415-
* Patches the LDN service by retrieving and sending patch operations geenrated in generatePatchOperations()
410+
* Patches the LDN service by retrieving and sending patch operations generated in generatePatchOperations()
416411
*/
417412
patchService() {
418413
this.deleteMarkedInboundPatterns();
@@ -425,17 +420,6 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
425420
return;
426421
}
427422

428-
const notifyServiceInboundPatterns = this.formModel.get('notifyServiceInboundPatterns') as FormArray;
429-
const deletedInboundPatternsLength = this.deletedInboundPatterns.length;
430-
// If no inbound patterns are specified, close the modal and return
431-
// notify the user that no patterns are specified
432-
if (notifyServiceInboundPatterns.length === deletedInboundPatternsLength) {
433-
this.notificationService.warning(this.translateService.get('ldn-service-notification.created.warning.title'));
434-
this.deletedInboundPatterns = [];
435-
this.closeModal();
436-
return;
437-
}
438-
439423
this.ldnServicesService.patch(this.ldnService, patchOperations).pipe(
440424
getFirstCompletedRemoteData(),
441425
).subscribe(
@@ -571,7 +555,7 @@ export class LdnServiceFormComponent implements OnInit, OnDestroy {
571555
private createInboundPatternFormGroup(): FormGroup {
572556
const inBoundFormGroup = {
573557
pattern: '',
574-
patternLabel: this.translateService.instant(this.selectPatternDefaultLabeli18Key),
558+
patternLabel: this.translateService.instant(this.selectPatternDefaultLabelI18Key),
575559
constraint: '',
576560
constraintFormatted: '',
577561
automatic: false,

src/app/admin/admin-ldn-services/ldn-services-directory/ldn-services-directory.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ <h4>{{'service.overview.delete.header' | translate }}</h4>
8282
<div>
8383
{{ 'service.overview.delete.body' | translate }}
8484
</div>
85-
<div class="mt-4">
85+
<div class="mt-4 text-right">
8686
<button (click)="closeModal()"
8787
[attr.aria-label]="'ldn-service-overview-close-modal' | translate"
88-
class="btn btn-primary mr-2">{{ 'service.detail.delete.cancel' | translate }}</button>
88+
class="btn btn-outline-secondary mr-2">{{ 'service.detail.delete.cancel' | translate }}</button>
8989
<button (click)="deleteSelected(this.selectedServiceId.toString(), ldnServicesService)"
9090
class="btn btn-danger"
9191
[attr.aria-label]="'ldn-service-overview-select-delete' | translate"

src/app/admin/admin-ldn-services/ldn-services-patterns/ldn-service-coar-patterns.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export const notifyPatterns = [
1111

1212
'request-review',
1313

14+
'announce-relationship',
15+
1416
];
1517

1618

src/app/admin/admin-notify-dashboard/admin-notify-dashboard.component.spec.ts

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { ActivatedRoute } from '@angular/router';
77
import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap';
88
import { TranslateModule } from '@ngx-translate/core';
99

10+
import { APP_CONFIG } from '../../../config/app-config.interface';
11+
import { environment } from '../../../environments/environment.test';
1012
import { buildPaginatedList } from '../../core/data/paginated-list.model';
1113
import { SearchService } from '../../core/shared/search/search.service';
1214
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
@@ -28,9 +30,89 @@ describe('AdminNotifyDashboardComponent', () => {
2830
let searchResult3;
2931
let results;
3032

31-
const mockBoxes = [
32-
{ title: 'admin-notify-dashboard.received-ldn', boxes: [ undefined, undefined, undefined, undefined, undefined ] },
33-
{ title: 'admin-notify-dashboard.generated-ldn', boxes: [ undefined, undefined, undefined, undefined, undefined ] },
33+
const mockBoxes = [
34+
{
35+
title: 'admin-notify-dashboard.received-ldn',
36+
boxes: [
37+
{
38+
color: '#B8DAFF',
39+
title: 'admin-notify-dashboard.NOTIFY.incoming.accepted',
40+
config: 'NOTIFY.incoming.accepted',
41+
description: 'admin-notify-dashboard.NOTIFY.incoming.accepted.description',
42+
count: undefined,
43+
},
44+
{
45+
color: '#D4EDDA',
46+
title: 'admin-notify-dashboard.NOTIFY.incoming.processed',
47+
config: 'NOTIFY.incoming.processed',
48+
description: 'admin-notify-dashboard.NOTIFY.incoming.processed.description',
49+
count: undefined,
50+
},
51+
{
52+
color: '#FDBBC7',
53+
title: 'admin-notify-dashboard.NOTIFY.incoming.failure',
54+
config: 'NOTIFY.incoming.failure',
55+
description: 'admin-notify-dashboard.NOTIFY.incoming.failure.description',
56+
count: undefined,
57+
},
58+
{
59+
color: '#FDBBC7',
60+
title: 'admin-notify-dashboard.NOTIFY.incoming.untrusted',
61+
config: 'NOTIFY.incoming.untrusted',
62+
description: 'admin-notify-dashboard.NOTIFY.incoming.untrusted.description',
63+
count: undefined,
64+
},
65+
{
66+
color: '#43515F',
67+
title: 'admin-notify-dashboard.NOTIFY.incoming.involvedItems',
68+
textColor: '#fff',
69+
config: 'NOTIFY.incoming.involvedItems',
70+
description: 'admin-notify-dashboard.NOTIFY.incoming.involvedItems.description',
71+
count: undefined,
72+
},
73+
],
74+
},
75+
{
76+
title: 'admin-notify-dashboard.generated-ldn',
77+
boxes: [
78+
{
79+
color: '#D4EDDA',
80+
title: 'admin-notify-dashboard.NOTIFY.outgoing.delivered',
81+
config: 'NOTIFY.outgoing.delivered',
82+
description: 'admin-notify-dashboard.NOTIFY.outgoing.delivered.description',
83+
count: undefined,
84+
},
85+
{
86+
color: '#B8DAFF',
87+
title: 'admin-notify-dashboard.NOTIFY.outgoing.queued',
88+
config: 'NOTIFY.outgoing.queued',
89+
description: 'admin-notify-dashboard.NOTIFY.outgoing.queued.description',
90+
count: undefined,
91+
},
92+
{
93+
color: '#FDEEBB',
94+
title: 'admin-notify-dashboard.NOTIFY.outgoing.queued_for_retry',
95+
config: 'NOTIFY.outgoing.queued_for_retry',
96+
description: 'admin-notify-dashboard.NOTIFY.outgoing.queued_for_retry.description',
97+
count: undefined,
98+
},
99+
{
100+
color: '#FDBBC7',
101+
title: 'admin-notify-dashboard.NOTIFY.outgoing.failure',
102+
config: 'NOTIFY.outgoing.failure',
103+
description: 'admin-notify-dashboard.NOTIFY.outgoing.failure.description',
104+
count: undefined,
105+
},
106+
{
107+
color: '#43515F',
108+
title: 'admin-notify-dashboard.NOTIFY.outgoing.involvedItems',
109+
textColor: '#fff',
110+
config: 'NOTIFY.outgoing.involvedItems',
111+
description: 'admin-notify-dashboard.NOTIFY.outgoing.involvedItems.description',
112+
count: undefined,
113+
},
114+
],
115+
},
34116
];
35117

36118
beforeEach(async () => {
@@ -45,6 +127,7 @@ describe('AdminNotifyDashboardComponent', () => {
45127
await TestBed.configureTestingModule({
46128
imports: [TranslateModule.forRoot(), NgbNavModule, AdminNotifyDashboardComponent],
47129
providers: [
130+
{ provide: APP_CONFIG, useValue: environment },
48131
{ provide: SearchService, useValue: { search: () => createSuccessfulRemoteDataObject$(results) } },
49132
{ provide: ActivatedRoute, useValue: new ActivatedRouteStub() },
50133
],

0 commit comments

Comments
 (0)