Merge pull request #490 from shariquerik/branding

This commit is contained in:
Shariq Ansari 2024-12-27 22:08:42 +05:30 committed by GitHub
commit d9c1d5b77a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 153 additions and 38 deletions

View File

@ -5,7 +5,13 @@
"doctype": "DocType", "doctype": "DocType",
"engine": "InnoDB", "engine": "InnoDB",
"field_order": [ "field_order": [
"defaults_tab",
"restore_defaults", "restore_defaults",
"branding_tab",
"brand_name",
"brand_logo",
"favicon",
"dropdown_items_tab",
"dropdown_items" "dropdown_items"
], ],
"fields": [ "fields": [
@ -17,14 +23,45 @@
{ {
"fieldname": "dropdown_items", "fieldname": "dropdown_items",
"fieldtype": "Table", "fieldtype": "Table",
"label": "Dropdown Items",
"options": "CRM Dropdown Item" "options": "CRM Dropdown Item"
},
{
"fieldname": "defaults_tab",
"fieldtype": "Tab Break",
"label": "Defaults"
},
{
"fieldname": "branding_tab",
"fieldtype": "Tab Break",
"label": "Branding"
},
{
"description": "An image with 1:1 ratio is preferred",
"fieldname": "brand_logo",
"fieldtype": "Attach",
"label": "Logo"
},
{
"fieldname": "dropdown_items_tab",
"fieldtype": "Tab Break",
"label": "Dropdown Items"
},
{
"fieldname": "brand_name",
"fieldtype": "Data",
"label": "Name"
},
{
"description": "An icon file with .ico extension. Should be 16 x 16 px. Generated using a favicon generator. [favicon-generator.org]",
"fieldname": "favicon",
"fieldtype": "Attach",
"label": "Favicon"
} }
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"issingle": 1, "issingle": 1,
"links": [], "links": [],
"modified": "2024-12-27 17:47:29.196692", "modified": "2024-12-27 21:16:47.251706",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "FCRM", "module": "FCRM",
"name": "FCRM Settings", "name": "FCRM Settings",

View File

@ -0,0 +1,12 @@
<template>
<div v-if="brand?.logo">
<img :src="brand.logo" class="h-full w-full object-cover" />
</div>
<CRMLogo v-else class="size-8 shrink-0 rounded" />
</template>
<script setup>
import CRMLogo from '@/components/Icons/CRMLogo.vue'
const brand = defineModel()
</script>

View File

@ -1,5 +1,5 @@
<template> <template>
<Dropdown :options="dropdownItems.doc || []" v-bind="$attrs"> <Dropdown :options="dropdownItems" v-bind="$attrs">
<template v-slot="{ open }"> <template v-slot="{ open }">
<button <button
class="flex h-12 items-center rounded-md py-2 duration-300 ease-in-out" class="flex h-12 items-center rounded-md py-2 duration-300 ease-in-out"
@ -11,7 +11,7 @@
: 'w-52 px-2 hover:bg-surface-gray-3' : 'w-52 px-2 hover:bg-surface-gray-3'
" "
> >
<CRMLogo class="size-8 flex-shrink-0 rounded" /> <BrandLogo v-model="brand" class="size-8 flex-shrink-0" />
<div <div
class="flex flex-1 flex-col text-left duration-300 ease-in-out" class="flex flex-1 flex-col text-left duration-300 ease-in-out"
:class=" :class="
@ -21,7 +21,7 @@
" "
> >
<div class="text-base font-medium leading-none text-ink-gray-9"> <div class="text-base font-medium leading-none text-ink-gray-9">
{{ __('CRM') }} {{ __(brand.name || 'CRM') }}
</div> </div>
<div class="mt-1 text-sm leading-none text-ink-gray-7"> <div class="mt-1 text-sm leading-none text-ink-gray-7">
{{ user.full_name }} {{ user.full_name }}
@ -47,12 +47,13 @@
</template> </template>
<script setup> <script setup>
import CRMLogo from '@/components/Icons/CRMLogo.vue' import BrandLogo from '@/components/BrandLogo.vue'
import Apps from '@/components/Apps.vue' import Apps from '@/components/Apps.vue'
import { sessionStore } from '@/stores/session' import { sessionStore } from '@/stores/session'
import { usersStore } from '@/stores/users' import { usersStore } from '@/stores/users'
import { getSettings } from '@/stores/settings'
import { showSettings } from '@/composables/settings' import { showSettings } from '@/composables/settings'
import { createDocumentResource, Dropdown } from 'frappe-ui' import { Dropdown } from 'frappe-ui'
import { useStorage } from '@vueuse/core' import { useStorage } from '@vueuse/core'
import { computed, markRaw, onMounted } from 'vue' import { computed, markRaw, onMounted } from 'vue'
@ -63,6 +64,7 @@ const props = defineProps({
}, },
}) })
const { settings, brand } = getSettings()
const { logout } = sessionStore() const { logout } = sessionStore()
const { getUser } = usersStore() const { getUser } = usersStore()
@ -70,46 +72,45 @@ const user = computed(() => getUser() || {})
const theme = useStorage('theme', 'light') const theme = useStorage('theme', 'light')
const dropdownItems = createDocumentResource({ const dropdownItems = computed(() => {
doctype: 'FCRM Settings', if (!settings.value?.dropdown_items) return []
name: 'FCRM Settings',
fields: ['dropdown_items'],
auto: true,
transform: (data) => {
let items = data.dropdown_items
let _dropdownItems = [ let items = settings.value.dropdown_items
{
group: 'Dropdown Items', let _dropdownItems = [
{
group: 'Dropdown Items',
hideLabel: true,
items: [],
},
]
items.forEach((item) => {
if (item.hidden) return
if (item.type !== 'Separator') {
_dropdownItems[_dropdownItems.length - 1].items.push(
dropdownItemObj(item),
)
} else {
_dropdownItems.push({
group: '',
hideLabel: true, hideLabel: true,
items: [], items: [],
}, })
] }
})
items.forEach((item) => { return _dropdownItems
if (item.hidden) return
if (item.type !== 'Separator') {
_dropdownItems[_dropdownItems.length - 1].items.push(
dropdownItemObj(item),
)
} else {
_dropdownItems.push({
group: '',
hideLabel: true,
items: [],
})
}
})
return _dropdownItems
},
}) })
function dropdownItemObj(item) { function dropdownItemObj(item) {
let openInNewWindow = item.open_in_new_window let openInNewWindow = item.open_in_new_window
let icon = item.icon || 'external-link' let icon = item.icon || 'external-link'
item.icon = icon.startsWith('<svg') ? markRaw({ template: icon }) : icon if (typeof icon === 'string' && icon.startsWith('<svg')) {
icon = markRaw({ template: icon })
}
item.icon = icon
if (item.is_standard) { if (item.is_standard) {
return getStandardItem(item) return getStandardItem(item)
@ -142,7 +143,7 @@ function getStandardItem(item) {
} }
case 'toggle_theme': case 'toggle_theme':
return { return {
icon: computed(() => (theme.value === 'dark' ? 'sun' : item.icon)), icon: theme.value === 'dark' ? 'sun' : item.icon,
label: __(item.label), label: __(item.label),
onClick: toggleTheme, onClick: toggleTheme,
} }

View File

@ -224,6 +224,7 @@ import GroupBy from '@/components/GroupBy.vue'
import FadedScrollableDiv from '@/components/FadedScrollableDiv.vue' import FadedScrollableDiv from '@/components/FadedScrollableDiv.vue'
import ColumnSettings from '@/components/ColumnSettings.vue' import ColumnSettings from '@/components/ColumnSettings.vue'
import KanbanSettings from '@/components/Kanban/KanbanSettings.vue' import KanbanSettings from '@/components/Kanban/KanbanSettings.vue'
import { getSettings } from '@/stores/settings'
import { globalStore } from '@/stores/global' import { globalStore } from '@/stores/global'
import { viewsStore } from '@/stores/views' import { viewsStore } from '@/stores/views'
import { usersStore } from '@/stores/users' import { usersStore } from '@/stores/users'
@ -260,6 +261,7 @@ const props = defineProps({
}, },
}) })
const { brand } = getSettings()
const { $dialog } = globalStore() const { $dialog } = globalStore()
const { reload: reloadView, getView } = viewsStore() const { reload: reloadView, getView } = viewsStore()
const { isManager } = usersStore() const { isManager } = usersStore()
@ -320,6 +322,7 @@ usePageMeta(() => {
return { return {
title: label, title: label,
emoji: isEmoji(currentView.value.icon) ? currentView.value.icon : '', emoji: isEmoji(currentView.value.icon) ? currentView.value.icon : '',
icon: brand.favicon,
} }
}) })

View File

@ -214,6 +214,7 @@ import SidePanelModal from '@/components/Modals/SidePanelModal.vue'
import AddressModal from '@/components/Modals/AddressModal.vue' import AddressModal from '@/components/Modals/AddressModal.vue'
import { formatDate, timeAgo, createToast } from '@/utils' import { formatDate, timeAgo, createToast } from '@/utils'
import { getView } from '@/utils/view' import { getView } from '@/utils/view'
import { getSettings } from '@/stores/settings'
import { getMeta } from '@/stores/meta' import { getMeta } from '@/stores/meta'
import { globalStore } from '@/stores/global.js' import { globalStore } from '@/stores/global.js'
import { usersStore } from '@/stores/users.js' import { usersStore } from '@/stores/users.js'
@ -233,6 +234,7 @@ import {
import { ref, computed, h } from 'vue' import { ref, computed, h } from 'vue'
import { useRoute, useRouter } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
const { brand } = getSettings()
const { $dialog, makeCall } = globalStore() const { $dialog, makeCall } = globalStore()
const { getUser, isManager } = usersStore() const { getUser, isManager } = usersStore()
@ -298,6 +300,7 @@ const breadcrumbs = computed(() => {
usePageMeta(() => { usePageMeta(() => {
return { return {
title: contact.data?.full_name || contact.data?.name, title: contact.data?.full_name || contact.data?.name,
icon: brand.favicon,
} }
}) })

View File

@ -363,6 +363,7 @@ import {
copyToClipboard, copyToClipboard,
} from '@/utils' } from '@/utils'
import { getView } from '@/utils/view' import { getView } from '@/utils/view'
import { getSettings } from '@/stores/settings'
import { globalStore } from '@/stores/global' import { globalStore } from '@/stores/global'
import { statusesStore } from '@/stores/statuses' import { statusesStore } from '@/stores/statuses'
import { usersStore } from '@/stores/users' import { usersStore } from '@/stores/users'
@ -381,6 +382,7 @@ import { ref, computed, h, onMounted, onBeforeUnmount } from 'vue'
import { useRoute, useRouter } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
import { useActiveTabManager } from '@/composables/useActiveTabManager' import { useActiveTabManager } from '@/composables/useActiveTabManager'
const { brand } = getSettings()
const { $dialog, $socket, makeCall } = globalStore() const { $dialog, $socket, makeCall } = globalStore()
const { statusOptions, getDealStatus } = statusesStore() const { statusOptions, getDealStatus } = statusesStore()
const { isManager } = usersStore() const { isManager } = usersStore()
@ -540,6 +542,7 @@ const breadcrumbs = computed(() => {
usePageMeta(() => { usePageMeta(() => {
return { return {
title: organization.data?.name || deal.data?.name, title: organization.data?.name || deal.data?.name,
icon: brand.favicon,
} }
}) })

View File

@ -333,6 +333,7 @@ import {
copyToClipboard, copyToClipboard,
} from '@/utils' } from '@/utils'
import { getView } from '@/utils/view' import { getView } from '@/utils/view'
import { getSettings } from '@/stores/settings'
import { globalStore } from '@/stores/global' import { globalStore } from '@/stores/global'
import { contactsStore } from '@/stores/contacts' import { contactsStore } from '@/stores/contacts'
import { statusesStore } from '@/stores/statuses' import { statusesStore } from '@/stores/statuses'
@ -355,6 +356,7 @@ import { ref, computed, onMounted, watch } from 'vue'
import { useRouter, useRoute } from 'vue-router' import { useRouter, useRoute } from 'vue-router'
import { useActiveTabManager } from '@/composables/useActiveTabManager' import { useActiveTabManager } from '@/composables/useActiveTabManager'
const { brand } = getSettings()
const { $dialog, $socket, makeCall } = globalStore() const { $dialog, $socket, makeCall } = globalStore()
const { getContactByName, contacts } = contactsStore() const { getContactByName, contacts } = contactsStore()
const { statusOptions, getLeadStatus } = statusesStore() const { statusOptions, getLeadStatus } = statusesStore()
@ -485,6 +487,7 @@ const breadcrumbs = computed(() => {
usePageMeta(() => { usePageMeta(() => {
return { return {
title: lead.data?.lead_name || lead.data?.name, title: lead.data?.lead_name || lead.data?.name,
icon: brand.favicon,
} }
}) })

View File

@ -189,6 +189,7 @@ import DealsListView from '@/components/ListViews/DealsListView.vue'
import AddressModal from '@/components/Modals/AddressModal.vue' import AddressModal from '@/components/Modals/AddressModal.vue'
import { formatDate, timeAgo, createToast } from '@/utils' import { formatDate, timeAgo, createToast } from '@/utils'
import { getView } from '@/utils/view' import { getView } from '@/utils/view'
import { getSettings } from '@/stores/settings'
import { getMeta } from '@/stores/meta' import { getMeta } from '@/stores/meta'
import { globalStore } from '@/stores/global.js' import { globalStore } from '@/stores/global.js'
import { usersStore } from '@/stores/users.js' import { usersStore } from '@/stores/users.js'
@ -208,6 +209,7 @@ import {
import { ref, computed, h } from 'vue' import { ref, computed, h } from 'vue'
import { useRoute, useRouter } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
const { brand } = getSettings()
const { $dialog, makeCall } = globalStore() const { $dialog, makeCall } = globalStore()
const { getUser } = usersStore() const { getUser } = usersStore()
@ -272,6 +274,7 @@ const breadcrumbs = computed(() => {
usePageMeta(() => { usePageMeta(() => {
return { return {
title: contact.data?.full_name || contact.data?.name, title: contact.data?.full_name || contact.data?.name,
icon: brand.favicon,
} }
}) })

View File

@ -273,6 +273,7 @@ import SLASection from '@/components/SLASection.vue'
import CustomActions from '@/components/CustomActions.vue' import CustomActions from '@/components/CustomActions.vue'
import { createToast, setupAssignees, setupCustomizations } from '@/utils' import { createToast, setupAssignees, setupCustomizations } from '@/utils'
import { getView } from '@/utils/view' import { getView } from '@/utils/view'
import { getSettings } from '@/stores/settings'
import { globalStore } from '@/stores/global' import { globalStore } from '@/stores/global'
import { statusesStore } from '@/stores/statuses' import { statusesStore } from '@/stores/statuses'
import { import {
@ -288,10 +289,12 @@ import {
Tabs, Tabs,
Breadcrumbs, Breadcrumbs,
call, call,
usePageMeta
} from 'frappe-ui' } from 'frappe-ui'
import { ref, computed, h, onMounted } from 'vue' import { ref, computed, h, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
const { brand } = getSettings()
const { $dialog, $socket } = globalStore() const { $dialog, $socket } = globalStore()
const { statusOptions, getDealStatus } = statusesStore() const { statusOptions, getDealStatus } = statusesStore()
const route = useRoute() const route = useRoute()
@ -430,6 +433,13 @@ const breadcrumbs = computed(() => {
return items return items
}) })
usePageMeta(() => {
return {
title: organization.data?.name || deal.data?.name,
icon: brand.favicon,
}
})
const tabs = computed(() => { const tabs = computed(() => {
let tabOptions = [ let tabOptions = [
{ {

View File

@ -195,6 +195,7 @@ import SLASection from '@/components/SLASection.vue'
import CustomActions from '@/components/CustomActions.vue' import CustomActions from '@/components/CustomActions.vue'
import { createToast, setupAssignees, setupCustomizations } from '@/utils' import { createToast, setupAssignees, setupCustomizations } from '@/utils'
import { getView } from '@/utils/view' import { getView } from '@/utils/view'
import { getSettings } from '@/stores/settings'
import { globalStore } from '@/stores/global' import { globalStore } from '@/stores/global'
import { contactsStore } from '@/stores/contacts' import { contactsStore } from '@/stores/contacts'
import { statusesStore } from '@/stores/statuses' import { statusesStore } from '@/stores/statuses'
@ -211,10 +212,12 @@ import {
Switch, Switch,
Breadcrumbs, Breadcrumbs,
call, call,
usePageMeta,
} from 'frappe-ui' } from 'frappe-ui'
import { ref, computed, onMounted, watch } from 'vue' import { ref, computed, onMounted, watch } from 'vue'
import { useRouter, useRoute } from 'vue-router' import { useRouter, useRoute } from 'vue-router'
const { brand } = getSettings()
const { $dialog, $socket } = globalStore() const { $dialog, $socket } = globalStore()
const { getContactByName, contacts } = contactsStore() const { getContactByName, contacts } = contactsStore()
const { statusOptions, getLeadStatus } = statusesStore() const { statusOptions, getLeadStatus } = statusesStore()
@ -339,6 +342,13 @@ const breadcrumbs = computed(() => {
return items return items
}) })
usePageMeta(() => {
return {
title: lead.data?.lead_name || lead.data?.name,
icon: brand.favicon,
}
})
const tabs = computed(() => { const tabs = computed(() => {
let tabOptions = [ let tabOptions = [
{ {

View File

@ -177,6 +177,7 @@ import DetailsIcon from '@/components/Icons/DetailsIcon.vue'
import CameraIcon from '@/components/Icons/CameraIcon.vue' import CameraIcon from '@/components/Icons/CameraIcon.vue'
import DealsIcon from '@/components/Icons/DealsIcon.vue' import DealsIcon from '@/components/Icons/DealsIcon.vue'
import ContactsIcon from '@/components/Icons/ContactsIcon.vue' import ContactsIcon from '@/components/Icons/ContactsIcon.vue'
import { getSettings } from '@/stores/settings'
import { getMeta } from '@/stores/meta' import { getMeta } from '@/stores/meta'
import { globalStore } from '@/stores/global' import { globalStore } from '@/stores/global'
import { usersStore } from '@/stores/users' import { usersStore } from '@/stores/users'
@ -205,6 +206,7 @@ const props = defineProps({
}, },
}) })
const { brand } = getSettings()
const { getUser } = usersStore() const { getUser } = usersStore()
const { $dialog } = globalStore() const { $dialog } = globalStore()
const { getDealStatus } = statusesStore() const { getDealStatus } = statusesStore()
@ -266,6 +268,7 @@ const breadcrumbs = computed(() => {
usePageMeta(() => { usePageMeta(() => {
return { return {
title: props.organizationId, title: props.organizationId,
icon: brand.favicon,
} }
}) })

View File

@ -212,6 +212,7 @@ import EditIcon from '@/components/Icons/EditIcon.vue'
import CameraIcon from '@/components/Icons/CameraIcon.vue' import CameraIcon from '@/components/Icons/CameraIcon.vue'
import DealsIcon from '@/components/Icons/DealsIcon.vue' import DealsIcon from '@/components/Icons/DealsIcon.vue'
import ContactsIcon from '@/components/Icons/ContactsIcon.vue' import ContactsIcon from '@/components/Icons/ContactsIcon.vue'
import { getSettings } from '@/stores/settings'
import { getMeta } from '@/stores/meta' import { getMeta } from '@/stores/meta'
import { globalStore } from '@/stores/global' import { globalStore } from '@/stores/global'
import { usersStore } from '@/stores/users' import { usersStore } from '@/stores/users'
@ -241,6 +242,7 @@ const props = defineProps({
}, },
}) })
const { brand } = getSettings()
const { getUser, isManager } = usersStore() const { getUser, isManager } = usersStore()
const { $dialog } = globalStore() const { $dialog } = globalStore()
const { getDealStatus } = statusesStore() const { getDealStatus } = statusesStore()
@ -304,6 +306,7 @@ const breadcrumbs = computed(() => {
usePageMeta(() => { usePageMeta(() => {
return { return {
title: props.organizationId, title: props.organizationId,
icon: brand.favicon,
} }
}) })

View File

@ -0,0 +1,24 @@
import { createDocumentResource } from 'frappe-ui'
import { reactive, ref } from 'vue'
const settings = ref({})
const brand = reactive({})
export function getSettings() {
createDocumentResource({
doctype: 'FCRM Settings',
name: 'FCRM Settings',
onSuccess: (data) => {
settings.value = data
brand.name = settings.value?.brand_name
brand.logo = settings.value?.brand_logo
brand.favicon = settings.value?.favicon
return data
},
})
return {
settings,
brand,
}
}