From 80591b66e5923689ddb07e381c6540d3806bd938 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 17 Aug 2020 15:44:56 -0400 Subject: [PATCH] wire up functionality for primary contact Signed-off-by: Galen Charlton --- .../acq/provider/provider-contacts.component.html | 13 +++++++- .../acq/provider/provider-contacts.component.ts | 35 ++++++++++++++++++++++ .../acq/provider/provider-details.component.html | 2 +- .../staff/acq/provider/provider-record.service.ts | 8 +++++ .../staff/acq/provider/summary-pane.component.css | 1 + .../staff/acq/provider/summary-pane.component.html | 1 + 6 files changed, 58 insertions(+), 2 deletions(-) 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 113b3bfe03..ec7bdab2dd 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 @@ -4,7 +4,8 @@ - + + {{contact.email()}} @@ -14,6 +15,12 @@ {{contact.phone()}} + + + + + + + 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 70ddbc59b6..28b997a275 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 @@ -15,6 +15,7 @@ import {ProviderContactAddressesComponent} from './provider-contact-addresses.co import {AcqProviderSearchFormComponent} from './acq-provider-search-form.component'; import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component'; import {StringComponent} from '@eg/share/string/string.component'; +import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component'; import {ToastService} from '@eg/share/toast/toast.service'; @@ -31,12 +32,15 @@ export class ProviderContactsComponent implements OnInit, AfterViewInit { @ViewChild('editDialog', { static: true }) editDialog: FmRecordEditorComponent; @ViewChild('providerContactAddresses', { static: false }) providerContactAddresses: ProviderContactAddressesComponent; @ViewChild('acqProviderContactsGrid', { static: true }) providerContactsGrid: GridComponent; + @ViewChild('confirmSetAsPrimary', { static: true }) confirmSetAsPrimary: ConfirmDialogComponent; @ViewChild('successString', { static: true }) successString: StringComponent; @ViewChild('createString', { static: false }) createString: StringComponent; @ViewChild('createErrString', { static: false }) createErrString: StringComponent; @ViewChild('updateFailedString', { static: false }) updateFailedString: StringComponent; @ViewChild('deleteFailedString', { static: true }) deleteFailedString: StringComponent; @ViewChild('deleteSuccessString', { static: true }) deleteSuccessString: StringComponent; + @ViewChild('setAsPrimarySuccessString', { static: true }) setAsPrimarySuccessString: StringComponent; + @ViewChild('setAsPrimaryFailedString', { static: true }) setAsPrimaryFailedString: StringComponent; @Output('desireSummarize') summarize: EventEmitter = new EventEmitter(); @@ -47,6 +51,7 @@ export class ProviderContactsComponent implements OnInit, AfterViewInit { canCreate: boolean; canDelete: boolean; deleteSelected: (rows: IdlObject[]) => void; + notOneSelectedRow: (rows: IdlObject[]) => boolean; permissions: {[name: string]: boolean}; @@ -71,6 +76,7 @@ export class ProviderContactsComponent implements OnInit, AfterViewInit { ngOnInit() { this.gridSource = this.getDataSource() this.cellTextGenerator = {}; + this.notOneSelectedRow = (rows: IdlObject[]) => (rows.length !== 1); this.deleteSelected = (idlThings: IdlObject[]) => { idlThings.forEach(idlThing => idlThing.isdeleted(true)); this.providerRecord.batchUpdate(idlThings).subscribe( @@ -253,4 +259,33 @@ export class ProviderContactsComponent implements OnInit, AfterViewInit { } ); } + + setAsPrimary(providerContacts: IdlObject[]) { + this.selectedContact = providerContacts[0]; + this.confirmSetAsPrimary.open().subscribe(confirmed => { + if (!confirmed) { return; } + this.providerRecord.refreshCurrent().then(() => { + this.provider.primary_contact(providerContacts[0].id()); + this.provider.ischanged(true); + this.providerRecord.batchUpdate(this.provider).subscribe( + val => { + this.setAsPrimarySuccessString.current() + .then(str => this.toast.success(str)); + }, + err => { + this.setAsPrimaryFailedString.current() + .then(str => this.toast.danger(str)); + }, + () => { + this.providerRecord.refreshCurrent().then( + () => { + this.providerContactsGrid.reload(); + this.summarize.emit(this.provider.id()); + } + ); + } + ); + }); + }); + } } diff --git a/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-details.component.html b/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-details.component.html index 08e3b93abb..f548c5e143 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-details.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-details.component.html @@ -10,7 +10,7 @@ [record]="provider" (recordSaved)="updateProvider($event)" readonlyFields="id" - hiddenFields="holding_tag" + hiddenFields="holding_tag,primary_contact" [fieldOptions]="{currency_type:{preloadLinkedValues:true},edi_default:{preloadLinkedValues:true},default_claim_policy:{preloadLinkedValues:true}}" fieldOrder="active,name,code,id,currency_type,default_claim_policy,default_copy_count,edi_default,owner,phone,fax_phone,email,url,san,prepayment_required" > diff --git a/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-record.service.ts b/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-record.service.ts index fdb398e0b5..edac9cee74 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-record.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/acq/provider/provider-record.service.ts @@ -67,6 +67,14 @@ export class ProviderRecordService { } } }); + acqpro.contacts().forEach(acct => { + acct['_is_primary'] = false; + if (acqpro.primary_contact()) { + if (acct.id() === acqpro.primary_contact()) { + acct['_is_primary'] = true; + } + } + }); this.currentProvider = provider; this.checkIfCanDelete(provider); return provider; diff --git a/Open-ILS/src/eg2/src/app/staff/acq/provider/summary-pane.component.css b/Open-ILS/src/eg2/src/app/staff/acq/provider/summary-pane.component.css index 48c855085d..de3c24bf50 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/provider/summary-pane.component.css +++ b/Open-ILS/src/eg2/src/app/staff/acq/provider/summary-pane.component.css @@ -23,4 +23,5 @@ .row.provider_default_copy_count { display: none; } .row.provider_contacts { } .provider_contact_role { font-style: italic; } +.provider_primary_contact { color: red; } .row.provider_provider_notes { display: none; } diff --git a/Open-ILS/src/eg2/src/app/staff/acq/provider/summary-pane.component.html b/Open-ILS/src/eg2/src/app/staff/acq/provider/summary-pane.component.html index 7fe963fc4d..1adc157ac1 100644 --- a/Open-ILS/src/eg2/src/app/staff/acq/provider/summary-pane.component.html +++ b/Open-ILS/src/eg2/src/app/staff/acq/provider/summary-pane.component.html @@ -43,6 +43,7 @@
{{contact.role()}} : {{contact.name()}} {{contact.name()}} + (primary)
-- 2.11.0