fix: reload after updating settings

This commit is contained in:
Shariq Ansari 2024-12-30 15:55:17 +05:30
parent 03ec2db6dd
commit 22dc47d1bf
3 changed files with 85 additions and 71 deletions

View File

@ -10,7 +10,7 @@
/> />
</h2> </h2>
<div v-if="settings.doc" class="flex-1 flex flex-col gap-6 overflow-y-auto"> <div v-if="settings.doc" class="flex-1 flex flex-col gap-8 overflow-y-auto">
<div class="flex w-full"> <div class="flex w-full">
<FormControl <FormControl
type="text" type="text"
@ -21,10 +21,9 @@
</div> </div>
<!-- logo --> <!-- logo -->
<hr class="w-full border-outline-gray-2" />
<div class="flex flex-col justify-between gap-5"> <div class="flex flex-col justify-between gap-4">
<span class="text-lg font-semibold text-ink-gray-9"> <span class="text-base font-semibold text-ink-gray-9">
{{ __('Logo') }} {{ __('Logo') }}
</span> </span>
<div class="flex flex-1 gap-5"> <div class="flex flex-1 gap-5">
@ -57,10 +56,9 @@
</div> </div>
<!-- favicon --> <!-- favicon -->
<hr class="w-full border-outline-gray-2" />
<div class="flex flex-col justify-between gap-5"> <div class="flex flex-col justify-between gap-4">
<span class="text-lg font-semibold text-ink-gray-9"> <span class="text-base font-semibold text-ink-gray-9">
{{ __('Favicon') }} {{ __('Favicon') }}
</span> </span>
<div class="flex flex-1 gap-5"> <div class="flex flex-1 gap-5">
@ -93,10 +91,9 @@
</div> </div>
<!-- dropdown settings --> <!-- dropdown settings -->
<hr class="w-full border-outline-gray-2" />
<div class="flex flex-col justify-between gap-5"> <div class="flex flex-col justify-between gap-4">
<span class="text-lg font-semibold text-ink-gray-9"> <span class="text-base font-semibold text-ink-gray-9">
{{ __('Dropdown settings') }} {{ __('Dropdown settings') }}
</span> </span>
<div class="flex flex-1"> <div class="flex flex-1">
@ -107,10 +104,15 @@
/> />
</div> </div>
</div> </div>
</div>
<div class="flex flex-row-reverse"> <div class="flex flex-row-reverse">
<Button :label="__('Save')" variant="solid" @click="updateSettings" /> <Button
</div> variant="solid"
:label="__('Update')"
:disabled="!settings.isDirty"
@click="updateSettings"
/>
</div> </div>
</div> </div>
</template> </template>
@ -121,10 +123,11 @@ import { FormControl, Badge } from 'frappe-ui'
import { getSettings } from '@/stores/settings' import { getSettings } from '@/stores/settings'
import { showSettings } from '@/composables/settings' import { showSettings } from '@/composables/settings'
const { _settings: settings } = getSettings() const { _settings: settings, setupBrand } = getSettings()
function updateSettings() { function updateSettings() {
settings.save.submit() settings.save.submit()
showSettings.value = false showSettings.value = false
setupBrand()
} }
</script> </script>

View File

@ -3,7 +3,8 @@
<h2 class="flex gap-2 text-xl font-semibold leading-none h-5"> <h2 class="flex gap-2 text-xl font-semibold leading-none h-5">
{{ __('Send Invites To') }} {{ __('Send Invites To') }}
</h2> </h2>
<div class="flex-1 overflow-y-auto"> <div class="flex-1 flex flex-col gap-8 overflow-y-auto">
<div>
<label class="block text-xs text-ink-gray-5 mb-1.5"> <label class="block text-xs text-ink-gray-5 mb-1.5">
{{ __('Invite by email') }} {{ __('Invite by email') }}
</label> </label>
@ -26,9 +27,11 @@
:description="description" :description="description"
/> />
<ErrorMessage class="mt-2" v-if="error" :message="error" /> <ErrorMessage class="mt-2" v-if="error" :message="error" />
</div>
<template v-if="pendingInvitations.data?.length && !invitees.length"> <template v-if="pendingInvitations.data?.length && !invitees.length">
<div class="flex flex-col gap-4">
<div <div
class="mt-6 flex items-center justify-between py-4 text-base font-semibold" class="flex items-center justify-between text-base font-semibold"
> >
<div>{{ __('Pending Invites') }}</div> <div>{{ __('Pending Invites') }}</div>
</div> </div>
@ -42,7 +45,9 @@
<span class="text-ink-gray-9"> <span class="text-ink-gray-9">
{{ user.email }} {{ user.email }}
</span> </span>
<span class="text-ink-gray-5"> ({{ roleMap[user.role] }}) </span> <span class="text-ink-gray-5">
({{ roleMap[user.role] }})
</span>
</div> </div>
<div> <div>
<Tooltip text="Delete Invitation"> <Tooltip text="Delete Invitation">
@ -59,6 +64,7 @@
</div> </div>
</li> </li>
</ul> </ul>
</div>
</template> </template>
</div> </div>
<div class="flex flex-row-reverse"> <div class="flex flex-row-reverse">

View File

@ -10,16 +10,21 @@ export function getSettings() {
name: 'FCRM Settings', name: 'FCRM Settings',
onSuccess: (data) => { onSuccess: (data) => {
settings.value = data settings.value = data
brand.name = settings.value?.brand_name setupBrand()
brand.logo = settings.value?.brand_logo
brand.favicon = settings.value?.favicon
return data return data
}, },
}) })
function setupBrand() {
brand.name = settings.value?.brand_name
brand.logo = settings.value?.brand_logo
brand.favicon = settings.value?.favicon
}
return { return {
_settings, _settings,
settings, settings,
brand, brand,
setupBrand,
} }
} }