Skip to content

Commit 054043a

Browse files
authored
Merge pull request DSpace#2980 from atmire/w2p-114599_ClickingSaveOnCreateComColProvidesUserFeedback
Clicking save on create community and collection pages provides user feedback
2 parents 0e61cfd + 20146bd commit 054043a

7 files changed

Lines changed: 66 additions & 12 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
beforeEach(() => {
2+
cy.visit('/collections/create?parent='.concat(Cypress.env('DSPACE_TEST_COMMUNITY')));
3+
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
4+
});
5+
6+
it('should show loading component while saving', () => {
7+
const title = 'Test Collection Title';
8+
cy.get('#title').type(title);
9+
10+
cy.get('button[type="submit"]').click();
11+
12+
cy.get('ds-loading').should('be.visible');
13+
});

cypress/e2e/community-create.cy.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
beforeEach(() => {
2+
cy.visit('/communities/create');
3+
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
4+
});
5+
6+
it('should show loading component while saving', () => {
7+
const title = 'Test Community Title';
8+
cy.get('#title').type(title);
9+
10+
cy.get('button[type="submit"]').click();
11+
12+
cy.get('ds-loading').should('be.visible');
13+
});
Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
<div class="container">
2-
<div class="row">
3-
<div class="col-12 pb-4">
4-
<h2 id="sub-header" class="border-bottom pb-2">{{'collection.create.sub-head' | translate:{ parent: dsoNameService.getName((parentRD$| async)?.payload) } }}</h2>
5-
</div>
1+
<div class="container" *ngIf="(isLoading$ | async) === false">
2+
<div class="row">
3+
<div class="col-12 pb-4">
4+
<h2 id="sub-header"
5+
class="border-bottom pb-2">{{ 'collection.create.sub-head' | translate:{ parent: dsoNameService.getName((parentRD$| async)?.payload) } }}</h2>
66
</div>
7-
<ds-collection-form (submitForm)="onSubmit($event)"
8-
(back)="navigateToHome()"
9-
(finish)="navigateToNewPage()"></ds-collection-form>
7+
</div>
8+
<ds-collection-form (submitForm)="onSubmit($event)"
9+
(back)="navigateToHome()"
10+
(finish)="navigateToNewPage()"></ds-collection-form>
11+
</div>
12+
13+
<div class="container">
14+
<ds-loading *ngIf="isLoading$ | async"></ds-loading>
1015
</div>

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { AsyncPipe } from '@angular/common';
1+
import {
2+
AsyncPipe,
3+
NgIf,
4+
} from '@angular/common';
25
import { Component } from '@angular/core';
36
import { Router } from '@angular/router';
47
import {
@@ -13,6 +16,7 @@ import { RequestService } from '../../core/data/request.service';
1316
import { RouteService } from '../../core/services/route.service';
1417
import { Collection } from '../../core/shared/collection.model';
1518
import { CreateComColPageComponent } from '../../shared/comcol/comcol-forms/create-comcol-page/create-comcol-page.component';
19+
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
1620
import { NotificationsService } from '../../shared/notifications/notifications.service';
1721
import { CollectionFormComponent } from '../collection-form/collection-form.component';
1822

@@ -27,6 +31,8 @@ import { CollectionFormComponent } from '../collection-form/collection-form.comp
2731
CollectionFormComponent,
2832
TranslateModule,
2933
AsyncPipe,
34+
ThemedLoadingComponent,
35+
NgIf,
3036
],
3137
standalone: true,
3238
})
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
<div class="container">
1+
<div class="container" *ngIf="(isLoading$ | async) === false">
22
<div class="row">
33
<div class="col-12 pb-4">
44
<ng-container *ngVar="(parentRD$ | async)?.payload as parent">
55
<h2 *ngIf="!parent" id="header" class="border-bottom pb-2">{{ 'community.create.head' | translate }}</h2>
6-
<h2 *ngIf="parent" id="sub-header" class="border-bottom pb-2">{{ 'community.create.sub-head' | translate:{ parent: dsoNameService.getName(parent) } }}</h2>
6+
<h2 *ngIf="parent" id="sub-header"
7+
class="border-bottom pb-2">{{ 'community.create.sub-head' | translate:{ parent: dsoNameService.getName(parent) } }}</h2>
78
</ng-container>
89
</div>
910
</div>
1011
<ds-community-form (submitForm)="onSubmit($event)"
1112
(back)="navigateToHome()"
1213
(finish)="navigateToNewPage()"></ds-community-form>
1314
</div>
15+
16+
<div class="container">
17+
<ds-loading *ngIf="isLoading$ | async"></ds-loading>
18+
</div>

src/app/community-page/create-community-page/create-community-page.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { RequestService } from '../../core/data/request.service';
1515
import { RouteService } from '../../core/services/route.service';
1616
import { Community } from '../../core/shared/community.model';
1717
import { CreateComColPageComponent } from '../../shared/comcol/comcol-forms/create-comcol-page/create-comcol-page.component';
18+
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
1819
import { NotificationsService } from '../../shared/notifications/notifications.service';
1920
import { VarDirective } from '../../shared/utils/var.directive';
2021
import { CommunityFormComponent } from '../community-form/community-form.component';
@@ -32,6 +33,7 @@ import { CommunityFormComponent } from '../community-form/community-form.compone
3233
VarDirective,
3334
NgIf,
3435
AsyncPipe,
36+
ThemedLoadingComponent,
3537
],
3638
standalone: true,
3739
})

src/app/shared/comcol/comcol-forms/create-comcol-page/create-comcol-page.component.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import {
44
} from '@angular/core';
55
import { Router } from '@angular/router';
66
import { TranslateService } from '@ngx-translate/core';
7-
import { Observable } from 'rxjs';
7+
import {
8+
BehaviorSubject,
9+
Observable,
10+
} from 'rxjs';
811
import {
912
mergeMap,
1013
take,
@@ -62,6 +65,11 @@ export class CreateComColPageComponent<TDomain extends Collection | Community> i
6265
*/
6366
protected type: ResourceType;
6467

68+
/**
69+
* The
70+
*/
71+
isLoading$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
72+
6573
public constructor(
6674
protected dsoDataService: ComColDataService<TDomain>,
6775
public dsoNameService: DSONameService,
@@ -89,6 +97,7 @@ export class CreateComColPageComponent<TDomain extends Collection | Community> i
8997
* @param event The event returned by the community/collection form. Contains the new dso and logo uploader
9098
*/
9199
onSubmit(event) {
100+
this.isLoading$.next(true);
92101
const dso = event.dso;
93102
const uploader = event.uploader;
94103

@@ -101,6 +110,7 @@ export class CreateComColPageComponent<TDomain extends Collection | Community> i
101110
);
102111
}))
103112
.subscribe((dsoRD: TDomain) => {
113+
this.isLoading$.next(false);
104114
if (isNotUndefined(dsoRD)) {
105115
this.newUUID = dsoRD.uuid;
106116
if (uploader.queue.length > 0) {

0 commit comments

Comments
 (0)