<eg-string #updateFailedString i18n-text text="Provider Contact Update Failed"></eg-string>
<eg-string #deleteFailedString i18n-text text="Delete of Provider Contact failed or was not allowed"></eg-string>
<eg-string #deleteSuccessString i18n-text text="Delete of Provider Contact succeeded"></eg-string>
-
+<eg-string #setAsPrimarySuccessString i18n-text text="Successfully set primary contact"></eg-string>
+<eg-string #setAsPrimaryFailedtring i18n-text text="Failed to set primary contact"></eg-string>
<ng-template #emailTmpl let-contact="row">
<a href="mailto:{{contact.email()}}">{{contact.email()}}</a>
<a href="tel:{{contact.phone()}}">{{contact.phone()}}</a>
</ng-template>
+<eg-confirm-dialog #confirmSetAsPrimary
+ i18n-dialogTitle i18n-dialogBody
+ dialogTitle="Confirm Setting Primary Contact"
+ dialogBody="Set {{selected ? selected.name() : ''}} as the primary contact for {{provider ? provider.name() : ''}}?">
+</eg-confirm-dialog>
+
<eg-grid #acqProviderContactsGrid
persistKey="acq.provider.contacts"
idlClass="acqpc" [dataSource]="gridSource"
<eg-grid-toolbar-button label="New Provider Contact" i18n-label (onClick)="createNew()"></eg-grid-toolbar-button>
<eg-grid-toolbar-action label="Edit Selected" i18n-label (onClick)="editSelected($event)"></eg-grid-toolbar-action>
<eg-grid-toolbar-action label="Delete Selected" i18n-label (onClick)="deleteSelected($event)"></eg-grid-toolbar-action>
+ <eg-grid-toolbar-action label="Set as Primary Contact" i18n-label (onClick)="setAsPrimary($event)" [disableOnRows]="notOneSelectedRow">
+ </eg-grid-toolbar-action>
+
<eg-grid-column path="email" [cellTemplate]="emailTmpl" [disableTooltip]="true"></eg-grid-column>
<eg-grid-column path="phone" [cellTemplate]="phoneTmpl" [disableTooltip]="true"></eg-grid-column>
+ <eg-grid-column [filterable]="false" [sortable]="false" i18n-label label="Is Primary?" path="_is_primary" datatype="bool"></eg-grid-column>
</eg-grid>
<ng-container *ngIf="selectedContact">
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';
@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<number> = new EventEmitter<number>();
canCreate: boolean;
canDelete: boolean;
deleteSelected: (rows: IdlObject[]) => void;
+ notOneSelectedRow: (rows: IdlObject[]) => boolean;
permissions: {[name: string]: boolean};
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(
}
);
}
+
+ 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());
+ }
+ );
+ }
+ );
+ });
+ });
+ }
}
[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"
>