fix: added forecasting & currency setting in general settings

This commit is contained in:
Shariq Ansari 2025-07-10 16:15:27 +05:30
parent 33e4072430
commit 5dcd416007

View File

@ -10,16 +10,70 @@
</div>
<div class="flex-1 flex flex-col overflow-y-auto">
<template v-for="(setting, i) in settings" :key="setting.name">
<div
class="flex items-center justify-between p-3 cursor-pointer hover:bg-surface-menu-bar rounded"
@click="toggleForecasting()"
>
<div class="flex flex-col gap-0.5">
<div class="text-base font-medium text-ink-gray-7 truncate">
{{ __('Enable forecasting') }}
</div>
<div class="text-base text-ink-gray-5 truncate">
{{
__(
"It will make deal's `Close Date` & `Deal Value` mandatory to get accurate forecasting insights",
)
}}
</div>
</div>
<div>
<Switch
size="sm"
v-model="settings.doc.enable_forecasting"
@click.stop="toggleForecasting(settings.doc.enable_forecasting)"
/>
</div>
</div>
<div class="h-px border-t mx-2 border-outline-gray-modals" />
<div
class="flex items-center justify-between gap-8 p-3 cursor-pointer hover:bg-surface-menu-bar rounded"
>
<div class="flex flex-col gap-0.5">
<div class="text-base font-medium text-ink-gray-7 truncate">
{{ __('Currency') }}
</div>
<div class="text-base text-ink-gray-5">
{{
__(
'Set your CRMs main currency. All monetary values will use this. This cant be changed later.',
)
}}
</div>
</div>
<div>
<Link
class="form-control flex-1 truncate"
:class="settings.doc.currency ? '' : 'w-40'"
:value="settings.doc.currency || ''"
doctype="Currency"
@change="(v) => setCurrency(v)"
:placeholder="__('Select currency')"
:disabled="settings.doc.currency ? true : false"
placement="bottom-end"
/>
</div>
</div>
<div class="h-px border-t mx-2 border-outline-gray-modals" />
<template v-for="(setting, i) in settingsList" :key="setting.name">
<li
class="flex items-center justify-between p-3 cursor-pointer hover:bg-surface-menu-bar rounded"
@click="() => emit('updateStep', setting.name)"
>
<div class="flex flex-col">
<div class="flex flex-col gap-0.5">
<div class="text-base font-medium text-ink-gray-7 truncate">
{{ __(setting.label) }}
</div>
<div class="text-p-base text-ink-gray-5 truncate">
<div class="text-base text-ink-gray-5 truncate">
{{ __(setting.description) }}
</div>
</div>
@ -28,7 +82,7 @@
</div>
</li>
<div
v-if="settings !== i + 1"
v-if="settingsList !== i + 1"
class="h-px border-t mx-2 border-outline-gray-modals"
/>
</template>
@ -37,9 +91,17 @@
</template>
<script setup>
import Link from '@/components/Controls/Link.vue'
import { getSettings } from '@/stores/settings'
import { globalStore } from '@/stores/global'
import { Switch, toast } from 'frappe-ui'
const emit = defineEmits(['updateStep'])
const settings = [
const { _settings: settings } = getSettings()
const { $dialog } = globalStore()
const settingsList = [
{
name: 'brand-settings',
label: 'Brand settings',
@ -51,4 +113,46 @@ const settings = [
description: 'Configure actions that appear on the home dropdown',
},
]
function toggleForecasting(value) {
settings.doc.enable_forecasting =
value !== undefined ? value : !settings.doc.enable_forecasting
settings.save.submit(null, {
onSuccess: () => {
toast.success(
settings.doc.enable_forecasting
? __('Forecasting enabled successfully')
: __('Forecasting disabled successfully'),
)
},
})
}
function setCurrency(value) {
$dialog({
title: __('Set currency'),
message: __(
'Are you sure you want to set the currency as {0}? This cannot be changed later.',
[value],
),
variant: 'solid',
theme: 'blue',
actions: [
{
label: __('Save'),
variant: 'solid',
onClick: (close) => {
settings.doc.currency = value
settings.save.submit(null, {
onSuccess: () => {
toast.success(__('Currency set as {0} successfully', [value]))
close()
},
})
},
},
],
})
}
</script>