<eg-staff-banner bannerText="Providers" i18n-bannerText>
</eg-staff-banner>
+<eg-string #createString i18n-text text="New Provider Added"></eg-string>
+<eg-string #createErrString i18n-text text="Failed to Create New Provider"></eg-string>
<div><div class="row">
<div class="col-10">
<div class="row mb-2">
<div class="col-lg-2 offset-lg-10">
- <button class="btn btn-primary" [hidden]="showSearchForm" (click)="showSearchForm = !showSearchForm" i18n>Show Search Form</button>
- <button class="btn btn-primary" [hidden]="!showSearchForm" (click)="showSearchForm = !showSearchForm" i18n>Hide Search Form</button>
+ <div class="btn-toolbar" role="toolbar">
+ <div class="button-grp mr-2">
+ <button class="btn btn-primary" [hidden]="showSearchForm" (click)="showSearchForm = !showSearchForm" i18n>Show Search Form</button>
+ <button class="btn btn-primary" [hidden]="!showSearchForm" (click)="showSearchForm = !showSearchForm" i18n>Hide Search Form</button>
+ </div>
+ <div class="button-grp mr-2">
+ <button class="btn btn-primary" (click)="createNew()" i18n>New Provider</button>
+ </div>
+ </div>
</div>
</div>
<div class="row mb-5" [hidden]="!showSearchForm">
</div>
</div></div>
+
+<eg-fm-record-editor #createDialog
+ idlClass="acqpro"
+ fieldOrder="active,name,code,currency_type,default_claim_policy,default_copy_count,edi_default,owner,url,san,prepayment_required"
+ hiddenFields="id,email,phone,fax_phone,holding_tag">
+</eg-fm-record-editor>
import {PcrudService} from '@eg/core/pcrud.service';
import {AcqProviderSummaryPaneComponent} from './summary-pane.component';
import {ProviderRecordService} from './provider-record.service';
+import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component';
+import {StringComponent} from '@eg/share/string/string.component';
+import {ToastService} from '@eg/share/toast/toast.service';
+import {AuthService} from '@eg/core/auth.service';
@Component({
templateUrl: './acq-provider.component.html'
validTabTypes = ['details', 'addresses', 'contacts', 'attributes', 'holdings', 'edi_accounts', 'purchase_orders', 'invoices'];
defaultTabType = 'details';
@ViewChild('acqSearchProviderSummary', { static: true }) providerSummaryPane: AcqProviderSummaryPaneComponent;
+ @ViewChild('createDialog', { static: true }) createDialog: FmRecordEditorComponent;
+ @ViewChild('createString', { static: false }) createString: StringComponent;
+ @ViewChild('createErrString', { static: false }) createErrString: StringComponent;
onTabChange: ($event: NgbTabChangeEvent) => void;
constructor(
private router: Router,
private route: ActivatedRoute,
+ private auth: AuthService,
private pcrud: PcrudService,
private idl: IdlService,
private providerRecord: ProviderRecordService,
+ private toast: ToastService,
) {
}
ngAfterViewInit() {}
+ createNew() {
+ this.createDialog.mode = 'create';
+ const provider = this.idl.create('acqpro');
+ provider.active(true);
+ provider.owner(this.auth.user().ws_ou());
+ provider.default_copy_count(1);
+ this.createDialog.record = provider;
+ this.createDialog.recordId = null;
+ this.createDialog.open({size: 'lg'}).subscribe(
+ ok => {
+ this.createString.current()
+ .then(str => this.toast.success(str));
+ this.onDesireSummarize(ok.id());
+ },
+ rejection => {
+ if (!rejection.dismissed) {
+ this.createErrString.current()
+ .then(str => this.toast.danger(str));
+ }
+ }
+ );
+ }
}