From ebf2a9521299ca82cca4dc25515a531521a074ef Mon Sep 17 00:00:00 2001
From: crisnicandrei <62384997+crisnicandrei@users.noreply.github.com>
Date: Thu, 3 Oct 2024 15:33:49 +0300
Subject: [PATCH] PER-9863: Create archive for me - 2 archives
Disable the buttons after submitting the new archive
---
.../create-new-archive.component.html | 10 ++++++++--
.../create-new-archive.component.spec.ts | 14 ++++++++++++++
.../create-new-archive.component.ts | 2 ++
...finalize-archive-creation-screen.component.html | 1 +
...alize-archive-creation-screen.component.spec.ts | 10 ++++++++++
.../finalize-archive-creation-screen.component.ts | 2 ++
6 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/src/app/onboarding/components/create-new-archive/create-new-archive.component.html b/src/app/onboarding/components/create-new-archive/create-new-archive.component.html
index e10947982..d5fdbc79e 100644
--- a/src/app/onboarding/components/create-new-archive/create-new-archive.component.html
+++ b/src/app/onboarding/components/create-new-archive/create-new-archive.component.html
@@ -190,12 +190,18 @@
Lastly, we’re curious -- what brought you to Permanent.org?
-
+
diff --git a/src/app/onboarding/components/create-new-archive/create-new-archive.component.spec.ts b/src/app/onboarding/components/create-new-archive/create-new-archive.component.spec.ts
index 9e0ec168c..390a8bc61 100644
--- a/src/app/onboarding/components/create-new-archive/create-new-archive.component.spec.ts
+++ b/src/app/onboarding/components/create-new-archive/create-new-archive.component.spec.ts
@@ -111,4 +111,18 @@ describe('CreateNewArchiveComponent #onboarding', () => {
expect(button.disabled).toBe(true);
});
+
+ it('should disable the Skip This Step and submit buttons when the archive has been submitted', async () => {
+ const { find, instance, fixture } = await shallow.render();
+ instance.screen = 'reasons';
+ instance.isArchiveSubmitted = true;
+
+ fixture.detectChanges();
+ const submitButton = find('.create-archive').nativeElement;
+
+ const skipStepButton = find('.skip-step').nativeElement;
+
+ expect(submitButton.disabled).toBe(true);
+ expect(skipStepButton.disabled).toBe(true);
+ });
});
diff --git a/src/app/onboarding/components/create-new-archive/create-new-archive.component.ts b/src/app/onboarding/components/create-new-archive/create-new-archive.component.ts
index e7ac85f52..77df0ca3d 100644
--- a/src/app/onboarding/components/create-new-archive/create-new-archive.component.ts
+++ b/src/app/onboarding/components/create-new-archive/create-new-archive.component.ts
@@ -64,6 +64,7 @@ export class CreateNewArchiveComponent implements OnInit {
public archiveName: string = '';
public screen: NewArchiveScreen = 'start';
public loading: boolean = false;
+ public isArchiveSubmitted: boolean = false;
public selectedGoals: string[] = [];
public selectedReasons: string[] = [];
public selectedValue: string = '';
@@ -153,6 +154,7 @@ export class CreateNewArchiveComponent implements OnInit {
public async onSubmit(): Promise {
try {
this.loading = true;
+ this.isArchiveSubmitted = true;
const fullName = this.name;
const archive = new ArchiveVO({
fullName,
diff --git a/src/app/onboarding/components/glam/finalize-archive-creation-screen/finalize-archive-creation-screen.component.html b/src/app/onboarding/components/glam/finalize-archive-creation-screen/finalize-archive-creation-screen.component.html
index bed3f3c79..770f382ba 100644
--- a/src/app/onboarding/components/glam/finalize-archive-creation-screen/finalize-archive-creation-screen.component.html
+++ b/src/app/onboarding/components/glam/finalize-archive-creation-screen/finalize-archive-creation-screen.component.html
@@ -32,6 +32,7 @@
[variant]="'secondary'"
[icon]="'/accept'"
[size]="'fill'"
+ [disabled]="isArchiveSubmitted"
(buttonClick)="finalizeArchive()"
>Done
diff --git a/src/app/onboarding/components/glam/finalize-archive-creation-screen/finalize-archive-creation-screen.component.spec.ts b/src/app/onboarding/components/glam/finalize-archive-creation-screen/finalize-archive-creation-screen.component.spec.ts
index b91c63459..32573331d 100644
--- a/src/app/onboarding/components/glam/finalize-archive-creation-screen/finalize-archive-creation-screen.component.spec.ts
+++ b/src/app/onboarding/components/glam/finalize-archive-creation-screen/finalize-archive-creation-screen.component.spec.ts
@@ -44,4 +44,14 @@ describe('FinalizeArchiveCreationScreenComponent', () => {
expect(instance.finalizeArchive).toHaveBeenCalled();
});
+
+ it('should disable the done button when it is clicked', async () => {
+ const { instance, fixture, find } = await shallow.render();
+ const doneButton = find('pr-button');
+ doneButton.triggerEventHandler('buttonClick', null);
+
+ fixture.detectChanges();
+
+ expect(instance.isArchiveSubmitted).toBe(true);
+ });
});
diff --git a/src/app/onboarding/components/glam/finalize-archive-creation-screen/finalize-archive-creation-screen.component.ts b/src/app/onboarding/components/glam/finalize-archive-creation-screen/finalize-archive-creation-screen.component.ts
index 5c1b09be8..a24dbe794 100644
--- a/src/app/onboarding/components/glam/finalize-archive-creation-screen/finalize-archive-creation-screen.component.ts
+++ b/src/app/onboarding/components/glam/finalize-archive-creation-screen/finalize-archive-creation-screen.component.ts
@@ -9,8 +9,10 @@ import { Component, Input, Output, EventEmitter } from '@angular/core';
export class FinalizeArchiveCreationScreenComponent {
@Input() name: string = '';
@Output() finalizeArchiveOutput = new EventEmitter();
+ public isArchiveSubmitted: boolean = false;
finalizeArchive() {
+ this.isArchiveSubmitted = true;
this.finalizeArchiveOutput.emit();
}
}