From: Galen Charlton Date: Mon, 31 Aug 2020 21:43:47 +0000 (-0400) Subject: LH#15: tweaks to primary contact functionality X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b1f7e8b96034cdcd38cc816db0031dd5ecb1183d;p=working%2FEvergreen.git LH#15: tweaks to primary contact functionality - added unset as primary action - fixed confirmation modals - more selectively enable and disable the set and unset actions Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-contacts.component.html b/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-contacts.component.html index ec7bdab2dd..694ca44413 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-contacts.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-contacts.component.html @@ -6,6 +6,8 @@ + + {{contact.email()}} @@ -18,7 +20,13 @@ + dialogBody="Set {{selectedContact ? selectedContact.name() : ''}} as the primary contact for {{provider ? provider.name() : ''}}?"> + + + - + + + diff --git a/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-contacts.component.ts b/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-contacts.component.ts index 28b997a275..5e1b0c4b4b 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-contacts.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-contacts.component.ts @@ -33,6 +33,7 @@ export class ProviderContactsComponent implements OnInit, AfterViewInit { @ViewChild('providerContactAddresses', { static: false }) providerContactAddresses: ProviderContactAddressesComponent; @ViewChild('acqProviderContactsGrid', { static: true }) providerContactsGrid: GridComponent; @ViewChild('confirmSetAsPrimary', { static: true }) confirmSetAsPrimary: ConfirmDialogComponent; + @ViewChild('confirmUnsetAsPrimary', { static: true }) confirmUnsetAsPrimary: ConfirmDialogComponent; @ViewChild('successString', { static: true }) successString: StringComponent; @ViewChild('createString', { static: false }) createString: StringComponent; @ViewChild('createErrString', { static: false }) createErrString: StringComponent; @@ -41,6 +42,8 @@ export class ProviderContactsComponent implements OnInit, AfterViewInit { @ViewChild('deleteSuccessString', { static: true }) deleteSuccessString: StringComponent; @ViewChild('setAsPrimarySuccessString', { static: true }) setAsPrimarySuccessString: StringComponent; @ViewChild('setAsPrimaryFailedString', { static: true }) setAsPrimaryFailedString: StringComponent; + @ViewChild('unsetAsPrimarySuccessString', { static: true }) unsetAsPrimarySuccessString: StringComponent; + @ViewChild('unsetAsPrimaryFailedString', { static: true }) unsetAsPrimaryFailedString: StringComponent; @Output('desireSummarize') summarize: EventEmitter = new EventEmitter(); @@ -51,7 +54,8 @@ export class ProviderContactsComponent implements OnInit, AfterViewInit { canCreate: boolean; canDelete: boolean; deleteSelected: (rows: IdlObject[]) => void; - notOneSelectedRow: (rows: IdlObject[]) => boolean; + cannotSetPrimaryContact: (rows: IdlObject[]) => boolean; + cannotUnsetPrimaryContact: (rows: IdlObject[]) => boolean; permissions: {[name: string]: boolean}; @@ -76,7 +80,8 @@ export class ProviderContactsComponent implements OnInit, AfterViewInit { ngOnInit() { this.gridSource = this.getDataSource() this.cellTextGenerator = {}; - this.notOneSelectedRow = (rows: IdlObject[]) => (rows.length !== 1); + this.cannotSetPrimaryContact = (rows: IdlObject[]) => (rows.length !== 1 || (rows.length == 1 && rows[0]._is_primary)); + this.cannotUnsetPrimaryContact = (rows: IdlObject[]) => (rows.length !== 1 || (rows.length == 1 && !rows[0]._is_primary)); this.deleteSelected = (idlThings: IdlObject[]) => { idlThings.forEach(idlThing => idlThing.isdeleted(true)); this.providerRecord.batchUpdate(idlThings).subscribe( @@ -288,4 +293,33 @@ export class ProviderContactsComponent implements OnInit, AfterViewInit { }); }); } + + unsetAsPrimary(providerContacts: IdlObject[]) { + this.selectedContact = providerContacts[0]; + this.confirmUnsetAsPrimary.open().subscribe(confirmed => { + if (!confirmed) { return; } + this.providerRecord.refreshCurrent().then(() => { + this.provider.primary_contact(null); + this.provider.ischanged(true); + this.providerRecord.batchUpdate(this.provider).subscribe( + val => { + this.unsetAsPrimarySuccessString.current() + .then(str => this.toast.success(str)); + }, + err => { + this.unsetAsPrimaryFailedString.current() + .then(str => this.toast.danger(str)); + }, + () => { + this.providerRecord.refreshCurrent().then( + () => { + this.providerContactsGrid.reload(); + this.summarize.emit(this.provider.id()); + } + ); + } + ); + }); + }); + } }