2018-06-11 15:16:25 +05:30
|
|
|
<template>
|
2019-11-19 23:20:33 +05:30
|
|
|
<div class="py-10 flex-1 bg-white window-drag">
|
2019-10-13 17:33:01 +05:30
|
|
|
<div class="px-12">
|
|
|
|
<h1 class="text-2xl font-semibold">{{ _('Setup your organization') }}</h1>
|
2019-12-12 23:10:34 +05:30
|
|
|
<p class="text-gray-600">
|
|
|
|
{{ _('These settings can be changed later') }}
|
|
|
|
</p>
|
2019-10-13 17:33:01 +05:30
|
|
|
</div>
|
2019-12-27 15:54:50 +05:30
|
|
|
<div class="px-8 mt-5 window-no-drag" v-if="doc">
|
2019-12-16 19:22:14 +05:30
|
|
|
<div class="flex items-center border bg-brand rounded-xl px-6 py-5 mb-4">
|
|
|
|
<FormControl
|
|
|
|
:df="meta.getField('companyLogo')"
|
|
|
|
:value="doc.companyLogo"
|
2019-12-27 15:54:50 +05:30
|
|
|
@change="value => setValue('companyLogo', value)"
|
2019-12-16 19:22:14 +05:30
|
|
|
/>
|
|
|
|
<div class="ml-2">
|
|
|
|
<FormControl
|
|
|
|
ref="companyField"
|
|
|
|
:df="meta.getField('companyName')"
|
|
|
|
:value="doc.companyName"
|
2019-12-27 15:54:50 +05:30
|
|
|
@change="value => setValue('companyName', value)"
|
2019-12-16 19:22:14 +05:30
|
|
|
:input-class="
|
|
|
|
classes => [
|
|
|
|
'bg-transparent font-semibold text-xl text-white placeholder-blue-200 focus:outline-none focus:bg-blue-600 px-3 rounded py-1'
|
|
|
|
]
|
|
|
|
"
|
|
|
|
:autofocus="true"
|
|
|
|
/>
|
|
|
|
<FormControl
|
|
|
|
:df="meta.getField('email')"
|
|
|
|
:value="doc.email"
|
2019-12-27 15:54:50 +05:30
|
|
|
@change="value => setValue('email', value)"
|
2019-12-16 19:22:14 +05:30
|
|
|
:input-class="
|
|
|
|
classes => [
|
|
|
|
'text-base bg-transparent text-white placeholder-blue-200 focus:bg-blue-600 focus:outline-none rounded px-3 py-1'
|
|
|
|
]
|
|
|
|
"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-11-19 23:20:33 +05:30
|
|
|
<TwoColumnForm :fields="fields" :doc="doc" />
|
2018-06-11 15:16:25 +05:30
|
|
|
</div>
|
2019-12-16 17:04:22 +05:30
|
|
|
<div class="px-8 flex justify-end mt-5 window-no-drag">
|
2019-12-16 19:22:14 +05:30
|
|
|
<Button
|
|
|
|
@click="submit"
|
|
|
|
type="primary"
|
|
|
|
class="text-white text-sm"
|
2019-12-27 15:54:50 +05:30
|
|
|
:disabled="!valuesFilled || loading"
|
2019-12-16 19:22:14 +05:30
|
|
|
>
|
|
|
|
{{ buttonText }}
|
2019-12-12 23:10:34 +05:30
|
|
|
</Button>
|
2019-10-13 17:33:01 +05:30
|
|
|
</div>
|
2018-07-14 18:45:21 +05:30
|
|
|
</div>
|
2018-06-11 15:16:25 +05:30
|
|
|
</template>
|
|
|
|
<script>
|
2018-07-05 15:44:49 +05:30
|
|
|
import frappe from 'frappejs';
|
2019-11-19 23:20:33 +05:30
|
|
|
import TwoColumnForm from '@/components/TwoColumnForm';
|
2019-12-16 19:22:14 +05:30
|
|
|
import FormControl from '@/components/Controls/FormControl';
|
2019-10-13 17:33:01 +05:30
|
|
|
import Button from '@/components/Button';
|
2019-12-27 15:54:50 +05:30
|
|
|
import { handleErrorWithDialog, showMessageDialog } from '@/utils';
|
2018-06-11 15:16:25 +05:30
|
|
|
|
|
|
|
export default {
|
2018-07-14 18:45:21 +05:30
|
|
|
name: 'SetupWizard',
|
|
|
|
data() {
|
|
|
|
return {
|
2019-12-27 15:54:50 +05:30
|
|
|
doc: null,
|
2019-12-16 19:22:14 +05:30
|
|
|
loading: false,
|
2019-12-27 15:54:50 +05:30
|
|
|
valuesFilled: false
|
2019-10-13 17:33:01 +05:30
|
|
|
};
|
|
|
|
},
|
|
|
|
provide() {
|
|
|
|
return {
|
|
|
|
doctype: 'SetupWizard',
|
|
|
|
name: 'SetupWizard'
|
2018-07-14 18:45:21 +05:30
|
|
|
};
|
|
|
|
},
|
|
|
|
components: {
|
2019-11-19 23:20:33 +05:30
|
|
|
TwoColumnForm,
|
2019-12-16 19:22:14 +05:30
|
|
|
FormControl,
|
2019-10-13 17:33:01 +05:30
|
|
|
Button
|
2018-07-14 18:45:21 +05:30
|
|
|
},
|
2019-12-27 15:54:50 +05:30
|
|
|
async mounted() {
|
2019-07-24 16:24:34 +05:30
|
|
|
this.doc = await frappe.newDoc({ doctype: 'SetupWizard' });
|
2019-12-27 15:54:50 +05:30
|
|
|
this.doc.on('change', () => {
|
|
|
|
this.valuesFilled = this.allValuesFilled();
|
|
|
|
});
|
2018-07-14 18:45:21 +05:30
|
|
|
},
|
|
|
|
methods: {
|
2019-12-27 15:54:50 +05:30
|
|
|
setValue(fieldname, value) {
|
|
|
|
this.doc
|
|
|
|
.set(fieldname, value)
|
|
|
|
.catch(e => handleErrorWithDialog(e, this.doc));
|
|
|
|
},
|
|
|
|
allValuesFilled() {
|
|
|
|
let values = this.meta.quickEditFields.map(
|
|
|
|
fieldname => this.doc[fieldname]
|
|
|
|
);
|
|
|
|
return values.every(Boolean);
|
|
|
|
},
|
2018-07-14 18:45:21 +05:30
|
|
|
async submit() {
|
2019-12-27 15:54:50 +05:30
|
|
|
if (!this.allValuesFilled()) {
|
|
|
|
showMessageDialog({ message: this._('Please fill all values') });
|
|
|
|
return;
|
|
|
|
}
|
2018-10-05 11:05:20 +05:30
|
|
|
try {
|
2019-12-16 19:22:14 +05:30
|
|
|
this.loading = true;
|
2018-10-23 18:12:36 +05:30
|
|
|
frappe.events.trigger('SetupWizard:setup-complete', this.doc);
|
2018-10-05 11:05:20 +05:30
|
|
|
} catch (e) {
|
2019-12-16 19:22:14 +05:30
|
|
|
this.loading = false;
|
2018-10-05 11:05:20 +05:30
|
|
|
console.error(e);
|
|
|
|
}
|
2018-07-14 18:45:21 +05:30
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2019-12-27 15:54:50 +05:30
|
|
|
meta() {
|
|
|
|
return frappe.getMeta('SetupWizard');
|
|
|
|
},
|
2018-07-14 18:45:21 +05:30
|
|
|
fields() {
|
2019-10-13 17:33:01 +05:30
|
|
|
return this.meta.getQuickEditFields();
|
2019-12-16 19:22:14 +05:30
|
|
|
},
|
|
|
|
buttonText() {
|
|
|
|
return this.loading ? this._('Setting Up...') : this._('Next');
|
2018-06-11 15:16:25 +05:30
|
|
|
}
|
2018-07-14 18:45:21 +05:30
|
|
|
}
|
|
|
|
};
|
2018-06-11 15:16:25 +05:30
|
|
|
</script>
|