Skip to content

Commit 014e8f7

Browse files
committed
fix(preprint-stepper): added delete logic
1 parent aacfd54 commit 014e8f7

23 files changed

Lines changed: 342 additions & 19 deletions

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/features/preprints/components/stepper/author-assertion-step/author-assertions-step.component.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,4 +238,11 @@ <h2>{{ 'preprints.preprintStepper.authorAssertions.publicPreregistration.title'
238238
[loading]="isUpdatingPreprint()"
239239
(onClick)="nextButtonClicked()"
240240
/>
241+
<p-button
242+
class="w-6 md:w-6rem"
243+
styleClass="w-full"
244+
[label]="'common.buttons.delete' | translate"
245+
severity="danger"
246+
(onClick)="deletePreprint()"
247+
/>
241248
</section>

src/app/features/preprints/components/stepper/author-assertion-step/author-assertions-step.component.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,15 @@ describe('AuthorAssertionsStepComponent', () => {
284284
expect(emitSpy).toHaveBeenCalled();
285285
});
286286

287+
it('should emit deleteClicked when deletePreprint is called', () => {
288+
setup({ detectChanges: false });
289+
const emitSpy = jest.spyOn(component.deleteClicked, 'emit');
290+
291+
component.deletePreprint();
292+
293+
expect(emitSpy).toHaveBeenCalled();
294+
});
295+
287296
it('should handle discard confirmation callbacks when there are unsaved changes', () => {
288297
setup();
289298
const emitSpy = jest.spyOn(component.backClicked, 'emit');

src/app/features/preprints/components/stepper/author-assertion-step/author-assertions-step.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export class AuthorAssertionsStepComponent {
126126

127127
nextClicked = output<void>();
128128
backClicked = output<void>();
129+
deleteClicked = output<void>();
129130

130131
constructor() {
131132
effect(() => {
@@ -259,6 +260,10 @@ export class AuthorAssertionsStepComponent {
259260
});
260261
}
261262

263+
deletePreprint() {
264+
this.deleteClicked.emit();
265+
}
266+
262267
private disableAndClearValidators(control: AbstractControl): void {
263268
if (control instanceof FormArray) {
264269
while (control.length !== 0) {

src/app/features/preprints/components/stepper/file-step/file-step.component.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,11 @@ <h2>{{ 'preprints.preprintStepper.file.title' | translate }}</h2>
163163
tooltipPosition="top"
164164
(onClick)="nextButtonClicked()"
165165
/>
166+
<p-button
167+
class="w-6 md:w-6rem"
168+
styleClass="w-full"
169+
[label]="'common.buttons.delete' | translate"
170+
severity="danger"
171+
(onClick)="deletePreprint()"
172+
/>
166173
</section>

src/app/features/preprints/components/stepper/file-step/file-step.component.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,15 @@ describe('FileStepComponent', () => {
199199
expect(emitSpy).toHaveBeenCalled();
200200
});
201201

202+
it('should emit deleteClicked when deletePreprint is called', () => {
203+
setup({ detectChanges: false });
204+
const emitSpy = jest.spyOn(component.deleteClicked, 'emit');
205+
206+
component.deletePreprint();
207+
208+
expect(emitSpy).toHaveBeenCalled();
209+
});
210+
202211
it('should handle nextButtonClicked for allowed and blocked states', () => {
203212
setup({ detectChanges: false });
204213
const emitSpy = jest.spyOn(component.nextClicked, 'emit');

src/app/features/preprints/components/stepper/file-step/file-step.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export class FileStepComponent implements OnInit {
120120

121121
nextClicked = output<void>();
122122
backClicked = output<void>();
123+
deleteClicked = output<void>();
123124

124125
isFileSourceSelected = computed(() => this.selectedFileSource() !== PreprintFileSource.None);
125126
canProceedToNext = computed(() => !!this.preprintFile() && !this.versionFileMode());
@@ -163,6 +164,10 @@ export class FileStepComponent implements OnInit {
163164
this.nextClicked.emit();
164165
}
165166

167+
deletePreprint() {
168+
this.deleteClicked.emit();
169+
}
170+
166171
onFileSelected(event: Event): void {
167172
const input = event.target as HTMLInputElement;
168173
const file = input.files?.[0];

src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-metadata-step.component.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,11 @@ <h2 class="mb-4">{{ 'preprints.preprintStepper.metadata.publicationCitationTitle
118118
[loading]="isUpdatingPreprint()"
119119
(onClick)="nextButtonClicked()"
120120
/>
121+
<p-button
122+
class="w-6 md:w-6rem"
123+
styleClass="w-full"
124+
[label]="'common.buttons.delete' | translate"
125+
severity="danger"
126+
(onClick)="deletePreprint()"
127+
/>
121128
</section>

src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-metadata-step.component.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,15 @@ describe('PreprintsMetadataStepComponent', () => {
236236
expect(customConfirmationServiceMock.confirmContinue).not.toHaveBeenCalled();
237237
});
238238

239+
it('should emit deleteClicked when deletePreprint is called', () => {
240+
setup({ detectChanges: false });
241+
const emitSpy = jest.spyOn(component.deleteClicked, 'emit');
242+
243+
component.deletePreprint();
244+
245+
expect(emitSpy).toHaveBeenCalled();
246+
});
247+
239248
it('should request confirmation and emit on confirm when there are changes in backButtonClicked', () => {
240249
setup();
241250
const backClickedSpy = jest.spyOn(component.backClicked, 'emit');

src/app/features/preprints/components/stepper/preprints-metadata-step/preprints-metadata-step.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export class PreprintsMetadataStepComponent implements OnInit {
6565
provider = input.required<PreprintProviderDetails>();
6666
nextClicked = output<void>();
6767
backClicked = output<void>();
68+
deleteClicked = output<void>();
6869

6970
private actions = createDispatchMap({
7071
updatePreprint: UpdatePreprint,
@@ -154,6 +155,10 @@ export class PreprintsMetadataStepComponent implements OnInit {
154155
});
155156
}
156157

158+
deletePreprint() {
159+
this.deleteClicked.emit();
160+
}
161+
157162
createLicense(licenseDetails: { id: string; licenseOptions: LicenseOptions }) {
158163
this.actions.saveLicense(licenseDetails.id, licenseDetails.licenseOptions);
159164
}

0 commit comments

Comments
 (0)