mirror of
https://github.com/frappe/books.git
synced 2025-01-23 15:18:24 +00:00
feat: handle change in main settings component
- show toast if display precision has changed
This commit is contained in:
parent
975e083084
commit
526eaf9e2c
@ -40,7 +40,7 @@
|
|||||||
</Row>
|
</Row>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-1 p-6 overflow-y-auto">
|
<div class="flex-1 p-6 overflow-y-auto">
|
||||||
<component :is="activeTabComponent" />
|
<component :is="activeTabComponent" @change="handleChange" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -48,6 +48,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { _ } from 'frappejs/utils';
|
import { _ } from 'frappejs/utils';
|
||||||
|
import frappe from 'frappejs';
|
||||||
import WindowControls from '@/components/WindowControls';
|
import WindowControls from '@/components/WindowControls';
|
||||||
import TabGeneral from './TabGeneral.vue';
|
import TabGeneral from './TabGeneral.vue';
|
||||||
import TabSystem from './TabSystem.vue';
|
import TabSystem from './TabSystem.vue';
|
||||||
@ -57,6 +58,8 @@ import Row from '@/components/Row';
|
|||||||
import Icon from '@/components/Icon';
|
import Icon from '@/components/Icon';
|
||||||
import PageHeader from '@/components/PageHeader';
|
import PageHeader from '@/components/PageHeader';
|
||||||
import StatusBadge from '@/components/StatusBadge';
|
import StatusBadge from '@/components/StatusBadge';
|
||||||
|
import { callInitializeMoneyMaker } from '../../utils';
|
||||||
|
import { showToast } from '../../utils';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Settings',
|
name: 'Settings',
|
||||||
@ -71,6 +74,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
activeTab: 0,
|
activeTab: 0,
|
||||||
updated: false,
|
updated: false,
|
||||||
|
fieldsChanged: [],
|
||||||
tabs: [
|
tabs: [
|
||||||
{
|
{
|
||||||
label: _('Invoice'),
|
label: _('Invoice'),
|
||||||
@ -93,7 +97,34 @@ export default {
|
|||||||
activated() {
|
activated() {
|
||||||
this.setActiveTab();
|
this.setActiveTab();
|
||||||
},
|
},
|
||||||
|
deactivated() {
|
||||||
|
if (this.fieldsChanged.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const fieldnames = this.fieldsChanged.map(({ fieldname }) => fieldname);
|
||||||
|
|
||||||
|
if (fieldnames.includes('displayPrecision')) {
|
||||||
|
callInitializeMoneyMaker(undefined, true);
|
||||||
|
const { label } =
|
||||||
|
this.fieldsChanged[fieldnames.indexOf('displayPrecision')];
|
||||||
|
|
||||||
|
showToast({
|
||||||
|
message: _(`${label} change will be visible on reload.`),
|
||||||
|
actionText: frappe._('Reload'),
|
||||||
|
action: async () => {
|
||||||
|
frappe.events.trigger('reload-main-window');
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handleChange(df, newValue, oldValue) {
|
||||||
|
if (!df) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.fieldsChanged.push(df);
|
||||||
|
},
|
||||||
setActiveTab() {
|
setActiveTab() {
|
||||||
const { tab } = this.$route.query;
|
const { tab } = this.$route.query;
|
||||||
const index = this.tabs.findIndex((t) => t.label === _(tab));
|
const index = this.tabs.findIndex((t) => t.label === _(tab));
|
||||||
|
@ -380,13 +380,13 @@ export async function getCurrency() {
|
|||||||
return currency;
|
return currency;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function callInitializeMoneyMaker(currency) {
|
export async function callInitializeMoneyMaker(currency, force = false) {
|
||||||
currency ??= await getCurrency();
|
currency ??= await getCurrency();
|
||||||
if (!currency && frappe.pesa) {
|
if (!force && !currency && frappe.pesa) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currency && frappe.pesa().options.currency === currency) {
|
if (!force && currency && frappe.pesa().options.currency === currency) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await frappe.initializeMoneyMaker(currency);
|
await frappe.initializeMoneyMaker(currency);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user