@ducna01120/fleetops-engine
Version:
Fleet & Transport Management Extension for Fleetbase
58 lines (49 loc) • 1.61 kB
JavaScript
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
export default class VendorFormPanelEditFormComponent extends Component {
store;
intl;
contextPanel;
isIntegratedVendor;
isEditingCredentials = false;
showAdvancedOptions = false;
constructor() {
super(...arguments);
this.vendor = this.args.vendor;
this.isIntegratedVendor = this.vendor && this.vendor.type === 'integrated-vendor';
}
toggleCredentialsReset() {
if (this.isEditingCredentials) {
this.isEditingCredentials = false;
} else {
this.isEditingCredentials = true;
}
}
toggleAdvancedOptions() {
if (this.showAdvancedOptions) {
this.showAdvancedOptions = false;
} else {
this.showAdvancedOptions = true;
}
}
selectVendorAddress(place) {
this.vendor.place = place;
this.vendor.place_uuid = place.id;
}
async editAddress() {
let place;
if (this.vendor.has_place) {
place = await this.vendor.place;
} else {
place = this.store.createRecord('place');
}
return this.contextPanel.focus(place, 'editing', {
onAfterSave: (place) => {
this.selectVendorAddress(place);
this.contextPanel.clear();
},
});
}
}