Skip to content

Commit 72f1d76

Browse files
authored
Merge pull request #2818 from ORCID/lmendoza/PD-3931
PD-3931
2 parents e7dfa65 + eaacc5c commit 72f1d76

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/app/cdk/side-bar/modals/modal-websites/modal-websites.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
mat-raised-button
1010
color="primary"
1111
(click)="saveEvent()"
12+
[disabled]="loadingWebsites || isSavingWebsites || websitesForm?.invalid"
1213
i18n="@@shared.saveChanges"
1314
id="save-websites-button"
1415
[attr.aria-label]="ariaLabelSave"

src/app/cdk/side-bar/modals/modal-websites/modal-websites.component.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { MatDialogRef } from '@angular/material/dialog'
2121
import { cloneDeep } from 'lodash'
2222
import * as _ from 'lodash'
2323
import { Subject } from 'rxjs'
24-
import { first, takeUntil } from 'rxjs/operators'
24+
import { finalize, first, takeUntil } from 'rxjs/operators'
2525
import { SnackbarService } from 'src/app/cdk/snackbar/snackbar.service'
2626

2727
import { URL_REGEXP } from '../../../../constants'
@@ -65,6 +65,7 @@ export class ModalWebsitesComponent implements OnInit, OnDestroy {
6565
screenDirection = 'ltr'
6666
addedWebsiteCount = 0
6767
loadingWebsites = true
68+
isSavingWebsites = false
6869
urlMaxLength = 1999
6970
urlTitleMaxLength = 354
7071

@@ -177,18 +178,27 @@ export class ModalWebsitesComponent implements OnInit, OnDestroy {
177178
}
178179

179180
saveEvent() {
181+
if (this.isSavingWebsites) {
182+
return
183+
}
184+
180185
this.websitesForm.markAllAsTouched()
181186
this.websitesForm.updateValueAndValidity()
182187

183188
if (this.websitesForm.valid) {
184-
this.loadingWebsites = true
189+
this.isSavingWebsites = true
185190
this._recordWebsitesService
186191
.postWebsites(this.formToBackend(this.websitesForm))
192+
.pipe(
193+
finalize(() => {
194+
this.isSavingWebsites = false
195+
})
196+
)
187197
.subscribe(
188198
() => {
189199
this.closeEvent()
190200
},
191-
(error) => {}
201+
() => {}
192202
)
193203
} else {
194204
this._snackBar.showValidationError()

0 commit comments

Comments
 (0)