Merge pull request #356 from frappe/develop

chore: Merge develop to main
This commit is contained in:
Shariq Ansari 2024-09-18 18:34:32 +05:30 committed by GitHub
commit 7898f2b5b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
30 changed files with 740 additions and 199 deletions

View File

@ -80,8 +80,7 @@
"fetch_from": ".website",
"fieldname": "website",
"fieldtype": "Data",
"label": "Website",
"options": "URL"
"label": "Website"
},
{
"fieldname": "close_date",
@ -339,7 +338,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-06-20 12:55:41.602364",
"modified": "2024-09-17 18:34:15.873610",
"modified_by": "Administrator",
"module": "FCRM",
"name": "CRM Deal",
@ -371,8 +370,10 @@
"write": 1
}
],
"show_title_field_in_link": 1,
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"title_field": "organization",
"track_changes": 1
}

View File

@ -18,6 +18,10 @@ frappe.ui.form.on("CRM Form Script", {
);
}
if (!frappe.boot.developer_mode) {
frm.toggle_enable("is_standard", 0);
}
frm.trigger("add_enable_button");
},

View File

@ -35,6 +35,7 @@
"default": "0",
"fieldname": "enabled",
"fieldtype": "Check",
"hidden": 1,
"label": "Enabled"
},
{
@ -64,7 +65,7 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-09-11 12:56:09.288849",
"modified": "2024-09-16 19:40:19.340948",
"modified_by": "Administrator",
"module": "FCRM",
"name": "CRM Form Script",

View File

@ -14,7 +14,7 @@ class CRMFormScript(Document):
or frappe.flags.in_test
or frappe.flags.in_fixtures
)
if in_user_env and self.is_standard and not frappe.conf.developer_mode:
if in_user_env and not self.is_new() and self.is_standard and not frappe.conf.developer_mode:
# only enabled can be changed for standard form scripts
if self.has_value_changed("enabled"):
enabled_value = self.enabled

View File

@ -107,8 +107,7 @@
{
"fieldname": "website",
"fieldtype": "Data",
"label": "Website",
"options": "URL"
"label": "Website"
},
{
"fieldname": "mobile_no",
@ -291,7 +290,7 @@
"image_field": "image",
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-02-05 00:58:07.321058",
"modified": "2024-09-17 18:36:57.289897",
"modified_by": "Administrator",
"module": "FCRM",
"name": "CRM Lead",
@ -325,6 +324,7 @@
],
"sender_field": "email",
"sender_name_field": "first_name",
"show_title_field_in_link": 1,
"sort_field": "modified",
"sort_order": "DESC",
"states": [],

View File

@ -28,8 +28,7 @@
{
"fieldname": "website",
"fieldtype": "Data",
"label": "Website",
"options": "URL"
"label": "Website"
},
{
"fieldname": "organization_logo",
@ -80,7 +79,7 @@
"image_field": "organization_logo",
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-09-13 15:52:05.106389",
"modified": "2024-09-17 18:37:10.341062",
"modified_by": "Administrator",
"module": "FCRM",
"name": "CRM Organization",

View File

@ -0,0 +1,21 @@
// Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.ui.form.on("ERPNext CRM Settings", {
refresh(frm) {
if (!frm.doc.enabled) return;
frm.add_custom_button(__("Reset ERPNext Form Script"), () => {
frappe.confirm(
__(
"Are you sure you want to reset 'Create Quotation from CRM Deal' Form Script?"
),
() => frm.trigger("reset_erpnext_form_script")
);
});
},
async reset_erpnext_form_script(frm) {
let script = await frm.call("reset_erpnext_form_script");
script.message &&
frappe.msgprint(__("Form Script updated successfully"));
},
});

View File

@ -0,0 +1,124 @@
{
"actions": [],
"allow_rename": 1,
"creation": "2024-07-02 15:23:17.022214",
"doctype": "DocType",
"engine": "InnoDB",
"field_order": [
"enabled",
"is_erpnext_in_different_site",
"column_break_vfru",
"erpnext_company",
"section_break_oubd",
"erpnext_site_url",
"column_break_fllx",
"api_key",
"api_secret",
"section_break_jnbn",
"create_customer_on_status_change",
"column_break_kbhw",
"deal_status"
],
"fields": [
{
"depends_on": "eval:doc.enabled && doc.is_erpnext_in_different_site",
"fieldname": "api_key",
"fieldtype": "Data",
"label": "API Key",
"mandatory_depends_on": "is_erpnext_in_different_site"
},
{
"depends_on": "eval:doc.enabled && doc.is_erpnext_in_different_site",
"fieldname": "api_secret",
"fieldtype": "Password",
"label": "API Secret",
"mandatory_depends_on": "is_erpnext_in_different_site"
},
{
"depends_on": "enabled",
"fieldname": "section_break_oubd",
"fieldtype": "Section Break"
},
{
"fieldname": "column_break_fllx",
"fieldtype": "Column Break"
},
{
"depends_on": "eval:doc.enabled && doc.is_erpnext_in_different_site",
"fieldname": "erpnext_site_url",
"fieldtype": "Data",
"label": "ERPNext Site URL",
"mandatory_depends_on": "is_erpnext_in_different_site"
},
{
"depends_on": "enabled",
"fieldname": "erpnext_company",
"fieldtype": "Data",
"label": "Company in ERPNext Site",
"mandatory_depends_on": "enabled"
},
{
"fieldname": "column_break_vfru",
"fieldtype": "Column Break"
},
{
"default": "0",
"fieldname": "enabled",
"fieldtype": "Check",
"label": "Enabled"
},
{
"default": "0",
"depends_on": "enabled",
"fieldname": "is_erpnext_in_different_site",
"fieldtype": "Check",
"label": "Is ERPNext installed on a different site?"
},
{
"fieldname": "section_break_jnbn",
"fieldtype": "Section Break"
},
{
"default": "0",
"depends_on": "enabled",
"fieldname": "create_customer_on_status_change",
"fieldtype": "Check",
"label": "Create customer on status change"
},
{
"fieldname": "column_break_kbhw",
"fieldtype": "Column Break"
},
{
"depends_on": "eval:doc.enabled && doc.create_customer_on_status_change",
"fieldname": "deal_status",
"fieldtype": "Link",
"label": "Deal Status",
"mandatory_depends_on": "create_customer_on_status_change",
"options": "CRM Deal Status"
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2024-09-17 19:21:11.060901",
"modified_by": "Administrator",
"module": "FCRM",
"name": "ERPNext CRM Settings",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"print": 1,
"read": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "creation",
"sort_order": "DESC",
"states": []
}

View File

@ -0,0 +1,262 @@
# Copyright (c) 2024, Frappe and contributors
# For license information, please see license.txt
import frappe
from frappe import _
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
from frappe.model.document import Document
from frappe.frappeclient import FrappeClient
from frappe.utils import get_url_to_form
import json
class ERPNextCRMSettings(Document):
def validate(self):
if self.enabled:
self.validate_if_erpnext_installed()
self.add_quotation_to_option()
self.create_custom_fields()
self.create_crm_form_script()
def validate_if_erpnext_installed(self):
if not self.is_erpnext_in_different_site:
if "erpnext" not in frappe.get_installed_apps():
frappe.throw(_("ERPNext is not installed in the current site"))
def add_quotation_to_option(self):
if not self.is_erpnext_in_different_site:
if not frappe.db.exists("Property Setter", {"name": "Quotation-quotation_to-link_filters"}):
make_property_setter(
doctype="Quotation",
fieldname="quotation_to",
property="link_filters",
value='[["DocType","name","in", ["Customer", "Lead", "Prospect", "Frappe CRM Deal"]]]',
property_type="JSON",
validate_fields_for_doctype=False,
)
def create_custom_fields(self):
if not self.is_erpnext_in_different_site:
from erpnext.crm.frappe_crm_api import create_custom_fields_for_frappe_crm
create_custom_fields_for_frappe_crm()
else:
self.create_custom_fields_in_remote_site()
def create_custom_fields_in_remote_site(self):
client = get_erpnext_site_client(self)
try:
client.post_api("erpnext.crm.frappe_crm_api.create_custom_fields_for_frappe_crm")
except Exception:
frappe.log_error(
frappe.get_traceback(),
f"Error while creating custom field in the remote erpnext site: {self.erpnext_site_url}"
)
frappe.throw("Error while creating custom field in ERPNext, check error log for more details")
def create_crm_form_script(self):
if not frappe.db.exists("CRM Form Script", "Create Quotation from CRM Deal"):
script = get_crm_form_script()
frappe.get_doc({
"doctype": "CRM Form Script",
"name": "Create Quotation from CRM Deal",
"dt": "CRM Deal",
"view": "Form",
"script": script,
"enabled": 1,
"is_standard": 1
}).insert()
@frappe.whitelist()
def reset_erpnext_form_script(self):
try:
if frappe.db.exists("CRM Form Script", "Create Quotation from CRM Deal"):
script = get_crm_form_script()
frappe.db.set_value("CRM Form Script", "Create Quotation from CRM Deal", "script", script)
return True
return False
except Exception:
frappe.log_error(frappe.get_traceback(), "Error while resetting form script")
return False
def get_erpnext_site_client(erpnext_crm_settings):
site_url = erpnext_crm_settings.erpnext_site_url
api_key = erpnext_crm_settings.api_key
api_secret = erpnext_crm_settings.get_password("api_secret", raise_exception=False)
return FrappeClient(
site_url, api_key=api_key, api_secret=api_secret
)
@frappe.whitelist()
def get_customer_link(crm_deal):
erpnext_crm_settings = frappe.get_single("ERPNext CRM Settings")
if not erpnext_crm_settings.enabled:
frappe.throw(_("ERPNext is not integrated with the CRM"))
if not erpnext_crm_settings.is_erpnext_in_different_site:
customer_url = get_url_to_form("Customer")
customer = frappe.db.exists("Customer", {"crm_deal": crm_deal})
if customer:
return f"{customer_url}/{customer}"
else:
return ""
else:
client = get_erpnext_site_client(erpnext_crm_settings)
try:
customer = client.get_list("Customer", {"crm_deal": crm_deal})[0]["name"]
if customer:
return f"{erpnext_crm_settings.erpnext_site_url}/app/customer/{customer}"
else:
return ""
except Exception:
frappe.log_error(
frappe.get_traceback(),
f"Error while fetching customer in remote site: {erpnext_crm_settings.erpnext_site_url}"
)
frappe.throw(_("Error while fetching customer in ERPNext, check error log for more details"))
@frappe.whitelist()
def get_quotation_url(crm_deal, organization):
erpnext_crm_settings = frappe.get_single("ERPNext CRM Settings")
if not erpnext_crm_settings.enabled:
frappe.throw(_("ERPNext is not integrated with the CRM"))
if not erpnext_crm_settings.is_erpnext_in_different_site:
quotation_url = get_url_to_form("Quotation")
return f"{quotation_url}/new?quotation_to=CRM Deal&crm_deal={crm_deal}&party_name={crm_deal}&company={erpnext_crm_settings.erpnext_company}"
else:
site_url = erpnext_crm_settings.get("erpnext_site_url")
quotation_url = f"{site_url}/app/quotation"
prospect = create_prospect_in_remote_site(crm_deal, erpnext_crm_settings)
return f"{quotation_url}/new?quotation_to=Prospect&crm_deal={crm_deal}&party_name={prospect}&company={erpnext_crm_settings.erpnext_company}"
def create_prospect_in_remote_site(crm_deal, erpnext_crm_settings):
try:
client = get_erpnext_site_client(erpnext_crm_settings)
doc = frappe.get_doc("CRM Deal", crm_deal)
contacts = get_contacts(doc)
address = get_organization_address(doc.organization)
return client.post_api("erpnext.crm.frappe_crm_api.create_prospect_against_crm_deal",
{
"organization": doc.organization,
"lead_name": doc.lead_name,
"no_of_employees": doc.no_of_employees,
"deal_owner": doc.deal_owner,
"crm_deal": doc.name,
"territory": doc.territory,
"industry": doc.industry,
"website": doc.website,
"annual_revenue": doc.annual_revenue,
"contacts": json.dumps(contacts),
"erpnext_company": erpnext_crm_settings.erpnext_company,
"address": address.as_dict() if address else None
},
)
except Exception:
frappe.log_error(
frappe.get_traceback(),
f"Error while creating prospect in remote site: {erpnext_crm_settings.erpnext_site_url}"
)
frappe.throw(_("Error while creating prospect in ERPNext, check error log for more details"))
def get_contacts(doc):
contacts = []
for c in doc.contacts:
contacts.append({
"contact": c.contact,
"full_name": c.full_name,
"email": c.email,
"mobile_no": c.mobile_no,
"gender": c.gender,
"is_primary": c.is_primary,
})
return contacts
def get_organization_address(organization):
address = frappe.get_value("CRM Organization", organization, "address")
address = frappe.get_doc("Address", address) if address else None
return address
def create_customer_in_erpnext(doc, method):
erpnext_crm_settings = frappe.get_single("ERPNext CRM Settings")
if (
not erpnext_crm_settings.enabled
or not erpnext_crm_settings.create_customer_on_status_change
or doc.status != erpnext_crm_settings.deal_status
):
return
contacts = get_contacts(doc)
address = get_organization_address(doc.organization)
customer = {
"customer_name": doc.organization,
"customer_group": "All Customer Groups",
"customer_type": "Company",
"territory": doc.territory,
"default_currency": doc.currency,
"industry": doc.industry,
"website": doc.website,
"crm_deal": doc.name,
"contacts": json.dumps(contacts),
"address": address.as_dict() if address else None,
}
if not erpnext_crm_settings.is_erpnext_in_different_site:
from erpnext.crm.frappe_crm_api import create_customer
create_customer(customer)
else:
create_customer_in_remote_site(customer, erpnext_crm_settings)
frappe.publish_realtime("crm_customer_created")
def create_customer_in_remote_site(customer, erpnext_crm_settings):
client = get_erpnext_site_client(erpnext_crm_settings)
try:
client.post_api("erpnext.crm.frappe_crm_api.create_customer", customer)
except Exception:
frappe.log_error(
frappe.get_traceback(),
"Error while creating customer in remote site"
)
frappe.throw(_("Error while creating customer in ERPNext, check error log for more details"))
@frappe.whitelist()
def get_crm_form_script():
return """
async function setupForm({ doc, call, $dialog, updateField, createToast }) {
let actions = [];
let is_erpnext_integration_enabled = await call("frappe.client.get_single_value", {doctype: "ERPNext CRM Settings", field: "enabled"});
if (!["Lost", "Won"].includes(doc?.status) && is_erpnext_integration_enabled) {
actions.push({
label: __("Create Quotation"),
onClick: async () => {
let quotation_url = await call(
"crm.fcrm.doctype.erpnext_crm_settings.erpnext_crm_settings.get_quotation_url",
{
crm_deal: doc.name,
organization: doc.organization
}
);
if (quotation_url) {
window.open(quotation_url, '_blank');
}
}
})
}
if (is_erpnext_integration_enabled) {
let customer_url = await call("crm.fcrm.doctype.erpnext_crm_settings.erpnext_crm_settings.get_customer_link", {
crm_deal: doc.name
});
if (customer_url) {
actions.push({
label: __("View Customer"),
onClick: () => window.open(customer_url, '_blank')
});
}
}
return {
actions: actions,
};
}
"""

View File

@ -0,0 +1,9 @@
# Copyright (c) 2024, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
# import frappe
from frappe.tests.utils import FrappeTestCase
class TestERPNextCRMSettings(FrappeTestCase):
pass

View File

@ -152,6 +152,9 @@ doc_events = {
"validate": ["crm.api.whatsapp.validate"],
"on_update": ["crm.api.whatsapp.on_update"],
},
"CRM Deal": {
"on_update": ["crm.fcrm.doctype.erpnext_crm_settings.erpnext_crm_settings.create_customer_in_erpnext"],
},
}
# Scheduled Tasks

View File

@ -8,7 +8,7 @@
/>
<title>Frappe CRM</title>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-title" content="Frappe CRM" />
<meta name="apple-mobile-web-app-status-bar-style" content="white" />

View File

@ -3,7 +3,7 @@
<div
v-for="section in sections"
:key="section.label"
class="first:border-t-0 first:pt-0"
class="section first:border-t-0 first:pt-0"
:class="section.hideBorder ? '' : 'border-t pt-4'"
>
<div
@ -22,12 +22,13 @@
>
<div v-for="field in section.fields" :key="field.name">
<div
class="settings-field"
v-if="
(field.type == 'Check' ||
(field.read_only && data[field.name]) ||
!field.read_only ||
!field.hidden) &&
(!field.depends_on || field.display_depends_on)
(!field.depends_on || field.display_via_depends_on)
"
>
<div
@ -35,7 +36,14 @@
class="mb-2 text-sm text-gray-600"
>
{{ __(field.label) }}
<span class="text-red-500" v-if="field.mandatory">*</span>
<span
class="text-red-500"
v-if="
field.mandatory ||
(field.mandatory_depends_on && field.mandatory_via_depends_on)
"
>*</span
>
</div>
<FormControl
v-if="field.read_only && field.type !== 'Check'"
@ -231,4 +239,12 @@ const props = defineProps({
:deep(.form-control.prefix select) {
padding-left: 2rem;
}
.section {
display: none;
}
.section:has(.settings-field) {
display: block;
}
</style>

View File

@ -0,0 +1,20 @@
<template>
<svg
width="18"
height="18"
viewBox="0 0 18 18"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M1 5C1 2.79086 2.79086 1 5 1H13C15.2091 1 17 2.79086 17 5V13C17 15.2091 15.2091 17 13 17H5C2.79086 17 1 15.2091 1 13V5Z"
stroke="currentColor"
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M11.7819 6.27142H11.5136H8.02453H6.28001V4.84002H11.7819V6.27142ZM8.02451 9.62623V11.5944H11.8267V13.0258H6.27999V8.19484H8.02451H11.5135V9.62623H8.02451Z"
fill="currentColor"
/>
</svg>
</template>

View File

@ -19,7 +19,7 @@
<script setup>
import EditValueModal from '@/components/Modals/EditValueModal.vue'
import AssignmentModal from '@/components/Modals/AssignmentModal.vue'
import { setupListActions, createToast } from '@/utils'
import { setupListCustomizations, createToast } from '@/utils'
import { globalStore } from '@/stores/global'
import { capture } from '@/telemetry'
import { call } from 'frappe-ui'
@ -45,7 +45,7 @@ const list = defineModel()
const router = useRouter()
const { $dialog } = globalStore()
const { $dialog, $socket } = globalStore()
const showEditModal = ref(false)
const selectedValues = ref([])
@ -230,17 +230,20 @@ function reload(unselectAll) {
list.value?.reload()
}
onMounted(() => {
onMounted(async () => {
if (!list.value?.data) return
setupListActions(list.value.data, {
let customization = await setupListCustomizations(list.value.data, {
list: list.value,
call,
createToast,
$dialog,
$socket,
router,
})
customBulkActions.value = list.value?.data?.bulkActions || []
customListActions.value = list.value?.data?.listActions || []
customBulkActions.value =
customization?.bulkActions || list.value?.data?.bulkActions || []
customListActions.value =
customization?.actions || list.value?.data?.listActions || []
})
defineExpose({

View File

@ -69,10 +69,10 @@
</div>
<div v-else-if="column.key === 'organization'">
<Avatar
v-if="item.label"
v-if="item"
class="flex items-center"
:image="item.logo"
:label="item.label"
:image="item"
:label="item"
size="sm"
/>
</div>

View File

@ -1,12 +1,13 @@
<template>
<FadedScrollableDiv
class="flex max-h-[300px] flex-col gap-1.5 overflow-y-auto"
class="flex flex-col gap-1.5 overflow-y-auto"
:class="[isLastSection ? '' : 'max-h-[300px]']"
>
<div
v-for="field in _fields"
:key="field.label"
:class="[field.hidden && 'hidden']"
class="flex items-center gap-2 px-3 leading-5 first:mt-3"
class="section-field flex items-center gap-2 px-3 leading-5 first:mt-3"
>
<Tooltip :text="__(field.label)" :hoverDelay="1">
<div class="sm:w-[106px] w-36 shrink-0 truncate text-sm text-gray-600">
@ -124,6 +125,10 @@ const props = defineProps({
type: Object,
required: true,
},
isLastSection: {
type: Boolean,
default: false,
},
})
const { getUser } = usersStore()

View File

@ -0,0 +1,11 @@
<template>
<SettingsPage
doctype="ERPNext CRM Settings"
:title="__('ERPNext Settings')"
:successMessage="__('ERPNext Settings updated')"
class="p-8"
/>
</template>
<script setup>
import SettingsPage from '@/components/Settings/SettingsPage.vue'
</script>

View File

@ -39,10 +39,12 @@
<script setup>
import ContactsIcon from '@/components/Icons/ContactsIcon.vue'
import WhatsAppIcon from '@/components/Icons/WhatsAppIcon.vue'
import ERPNextIcon from '@/components/Icons/ERPNextIcon.vue'
import PhoneIcon from '@/components/Icons/PhoneIcon.vue'
import InviteMemberPage from '@/components/Settings/InviteMemberPage.vue'
import ProfileSettings from '@/components/Settings/ProfileSettings.vue'
import WhatsAppSettings from '@/components/Settings/WhatsAppSettings.vue'
import ERPNextSettings from '@/components/Settings/ERPNextSettings.vue'
import TwilioSettings from '@/components/Settings/TwilioSettings.vue'
import SidebarLink from '@/components/SidebarLink.vue'
import { isWhatsappInstalled } from '@/composables/settings'
@ -83,6 +85,11 @@ const tabs = computed(() => {
component: markRaw(WhatsAppSettings),
condition: () => isWhatsappInstalled.value,
},
{
label: __('ERPNext'),
icon: ERPNextIcon,
component: markRaw(ERPNextSettings),
},
],
},
]

View File

@ -1,7 +1,7 @@
<template>
<div class="flex h-full flex-col gap-8">
<h2 class="flex gap-2 text-xl font-semibold leading-none h-5">
<div>{{ __(doctype) }}</div>
<div>{{ title || __(doctype) }}</div>
<Badge
v-if="data.isDirty"
:label="__('Not Saved')"
@ -15,6 +15,7 @@
:sections="sections"
:data="data.doc"
/>
<ErrorMessage class="mt-2" :message="error" />
</div>
<div v-else class="flex flex-1 items-center justify-center">
<Spinner class="size-8" />
@ -36,15 +37,20 @@ import {
createResource,
Spinner,
Badge,
ErrorMessage,
} from 'frappe-ui'
import { evaluate_depends_on_value, createToast } from '@/utils'
import { computed } from 'vue'
import { ref, computed } from 'vue'
const props = defineProps({
doctype: {
type: String,
required: true,
},
title: {
type: String,
default: '',
},
successMessage: {
type: String,
default: 'Updated Successfully',
@ -61,6 +67,8 @@ const fields = createResource({
auto: true,
})
const error = ref(null)
const data = createDocumentResource({
doctype: props.doctype,
name: props.doctype,
@ -69,6 +77,7 @@ const data = createDocumentResource({
auto: true,
setValue: {
onSuccess: () => {
error.value = null
createToast({
title: __('Success'),
text: __(props.successMessage),
@ -113,10 +122,14 @@ const sections = computed(() => {
} else {
_sections[_sections.length - 1].fields.push({
...field,
display_depends_on: evaluate_depends_on_value(
display_via_depends_on: evaluate_depends_on_value(
field.depends_on,
data.doc,
),
mandatory_via_depends_on: evaluate_depends_on_value(
field.mandatory_depends_on,
data.doc,
),
name: field.value,
})
}
@ -126,6 +139,24 @@ const sections = computed(() => {
})
function update() {
error.value = null
if (validateMandatoryFields()) return
data.save.submit()
}
function validateMandatoryFields() {
for (let section of sections.value) {
for (let field of section.fields) {
if (
(field.mandatory ||
(field.mandatory_depends_on && field.mandatory_via_depends_on)) &&
!data.doc[field.name]
) {
error.value = __('{0} is mandatory', [__(field.label)])
return true
}
}
}
return false
}
</script>

View File

@ -43,7 +43,11 @@
:class="{ 'border-b': i !== sections.data.length - 1 }"
>
<Section :is-opened="section.opened" :label="section.label">
<SectionFields :fields="section.fields" v-model="data" />
<SectionFields
:fields="section.fields"
:isLastSection="i == section.data.length - 1"
v-model="data"
/>
</Section>
</div>
</div>

View File

@ -8,19 +8,14 @@
</Breadcrumbs>
</template>
<template #right-header>
<CustomActions
v-if="deal.data._customActions"
:actions="deal.data._customActions"
/>
<CustomActions v-if="customActions" :actions="customActions" />
<component :is="deal.data._assignedTo?.length == 1 ? 'Button' : 'div'">
<MultipleAvatar
:avatars="deal.data._assignedTo"
@click="showAssignmentModal = true"
/>
</component>
<Dropdown
:options="statusOptions('deal', updateField, deal.data._customStatuses)"
>
<Dropdown :options="statusOptions('deal', updateField, customStatuses)">
<template #default="{ open }">
<Button
:label="deal.data.status"
@ -64,15 +59,15 @@
<Avatar
size="3xl"
class="size-12"
:label="organization?.name || __('Untitled')"
:image="organization?.organization_logo"
:label="organization.data?.name || __('Untitled')"
:image="organization.data?.organization_logo"
/>
</div>
</Tooltip>
<div class="flex flex-col gap-2.5 truncate">
<Tooltip :text="organization?.name || __('Set an organization')">
<Tooltip :text="organization.data?.name || __('Set an organization')">
<div class="truncate text-2xl font-medium">
{{ organization?.name || __('Untitled') }}
{{ organization.data?.name || __('Untitled') }}
</div>
</Tooltip>
<div class="flex gap-1.5">
@ -121,7 +116,7 @@
<div
v-for="(section, i) in fieldsLayout.data"
:key="section.label"
class="flex flex-col p-3"
class="section flex flex-col p-3"
:class="{ 'border-b': i !== fieldsLayout.data.length - 1 }"
>
<Section :is-opened="section.opened" :label="section.label">
@ -166,13 +161,14 @@
<SectionFields
v-if="section.fields"
:fields="section.fields"
:isLastSection="i == fieldsLayout.data.length - 1"
v-model="deal.data"
@update="updateField"
/>
<div v-else>
<div
v-if="
deal_contacts?.loading && deal_contacts?.data?.length == 0
dealContacts?.loading && dealContacts?.data?.length == 0
"
class="flex min-h-20 flex-1 items-center justify-center gap-3 text-base text-gray-500"
>
@ -180,8 +176,8 @@
<span>{{ __('Loading...') }}</span>
</div>
<div
v-else-if="deal_contacts?.data?.length"
v-for="(contact, i) in deal_contacts.data"
v-else-if="dealContacts?.data?.length"
v-for="(contact, i) in dealContacts.data"
:key="contact.name"
>
<div
@ -257,7 +253,7 @@
</Section>
</div>
<div
v-if="i != deal_contacts.data.length - 1"
v-if="i != dealContacts.data.length - 1"
class="mx-2 h-px border-t border-gray-200"
/>
</div>
@ -279,10 +275,7 @@
v-model:organization="_organization"
:options="{
redirect: false,
afterInsert: (doc) =>
updateField('organization', doc.name, () => {
organizations.reload()
}),
afterInsert: (doc) => updateField('organization', doc.name),
}"
/>
<ContactModal
@ -340,14 +333,12 @@ import {
openWebsite,
createToast,
setupAssignees,
setupCustomActions,
setupCustomStatuses,
setupCustomizations,
errorMessage,
copyToClipboard,
} from '@/utils'
import { getView } from '@/utils/view'
import { globalStore } from '@/stores/global'
import { organizationsStore } from '@/stores/organizations'
import { statusesStore } from '@/stores/statuses'
import { usersStore } from '@/stores/users'
import { whatsappEnabled, callEnabled } from '@/composables/settings'
@ -361,11 +352,10 @@ import {
call,
usePageMeta,
} from 'frappe-ui'
import { ref, computed, h, onMounted } from 'vue'
import { ref, computed, h, onMounted, onBeforeUnmount } from 'vue'
import { useRoute, useRouter } from 'vue-router'
const { $dialog, makeCall } = globalStore()
const { organizations, getOrganization } = organizationsStore()
const { $dialog, $socket, makeCall } = globalStore()
const { statusOptions, getDealStatus } = statusesStore()
const { isManager } = usersStore()
const route = useRoute()
@ -378,41 +368,71 @@ const props = defineProps({
},
})
const customActions = ref([])
const customStatuses = ref([])
const deal = createResource({
url: 'crm.fcrm.doctype.crm_deal.api.get_deal',
params: { name: props.dealId },
cache: ['deal', props.dealId],
onSuccess: (data) => {
onSuccess: async (data) => {
organization.update({
params: { doctype: 'CRM Organization', name: data.organization },
})
organization.fetch()
let obj = {
doc: data,
$dialog,
$socket,
router,
updateField,
createToast,
deleteDoc: deleteDeal,
resource: {
deal,
dealContacts,
fieldsLayout,
},
call,
}
setupAssignees(data)
setupCustomStatuses(data, obj)
setupCustomActions(data, obj)
let customization = await setupCustomizations(data, obj)
customActions.value = customization.actions || []
customStatuses.value = customization.statuses || []
},
})
const organization = createResource({
url: 'frappe.client.get',
onSuccess: (data) => (deal.data._organizationObj = data),
})
onMounted(() => {
if (deal.data) return
$socket.on('crm_customer_created', () => {
createToast({
title: __('Customer created successfully'),
icon: 'check',
iconClasses: 'text-green-600',
})
})
if (deal.data) {
organization.data = deal.data._organizationObj
return
}
deal.fetch()
})
onBeforeUnmount(() => {
$socket.off('crm_customer_created')
})
const reload = ref(false)
const showOrganizationModal = ref(false)
const showAssignmentModal = ref(false)
const showSidePanelModal = ref(false)
const _organization = ref({})
const organization = computed(() => {
return deal.data?.organization && getOrganization(deal.data.organization)
})
function updateDeal(fieldname, value, callback) {
value = Array.isArray(fieldname) ? '' : value
@ -481,7 +501,7 @@ const breadcrumbs = computed(() => {
}
items.push({
label: organization.value?.name || __('Untitled'),
label: organization.data?.name || __('Untitled'),
route: { name: 'Deal', params: { dealId: deal.data.name } },
})
return items
@ -489,7 +509,7 @@ const breadcrumbs = computed(() => {
usePageMeta(() => {
return {
title: organization.value?.name || deal.data?.name,
title: organization.data?.name || deal.data?.name,
}
})
@ -595,7 +615,7 @@ async function addContact(contact) {
contact,
})
if (d) {
deal_contacts.reload()
dealContacts.reload()
createToast({
title: __('Contact added'),
icon: 'check',
@ -610,7 +630,7 @@ async function removeContact(contact) {
contact,
})
if (d) {
deal_contacts.reload()
dealContacts.reload()
createToast({
title: __('Contact removed'),
icon: 'check',
@ -625,7 +645,7 @@ async function setPrimaryContact(contact) {
contact,
})
if (d) {
deal_contacts.reload()
dealContacts.reload()
createToast({
title: __('Primary contact set'),
icon: 'check',
@ -634,7 +654,7 @@ async function setPrimaryContact(contact) {
}
}
const deal_contacts = createResource({
const dealContacts = createResource({
url: 'crm.fcrm.doctype.crm_deal.api.get_deal_contacts',
params: { name: props.dealId },
cache: ['deal_contacts', props.dealId],
@ -648,7 +668,7 @@ const deal_contacts = createResource({
})
function triggerCall() {
let primaryContact = deal_contacts.data?.find((c) => c.is_primary)
let primaryContact = dealContacts.data?.find((c) => c.is_primary)
let mobile_no = primaryContact.mobile_no || null
if (!primaryContact) {
@ -685,3 +705,12 @@ function openEmailBox() {
activities.value.emailBox.show = true
}
</script>
<style scoped>
:deep(.section:has(.section-field.hidden)) {
display: none;
}
:deep(.section:has(.section-field:not(.hidden))) {
display: flex;
}
</style>

View File

@ -290,6 +290,7 @@ import {
dateFormat,
dateTooltipFormat,
timeAgo,
website,
formatNumberIntoCurrency,
formatTime,
} from '@/utils'
@ -394,6 +395,8 @@ function parseRows(rows) {
label: deal.organization,
logo: getOrganization(deal.organization)?.organization_logo,
}
} else if (row === 'website') {
_rows[row] = website(deal.website)
} else if (row == 'annual_revenue') {
_rows[row] = formatNumberIntoCurrency(
deal.annual_revenue,

View File

@ -8,17 +8,14 @@
</Breadcrumbs>
</template>
<template #right-header>
<CustomActions
v-if="lead.data._customActions"
:actions="lead.data._customActions"
/>
<CustomActions v-if="customActions" :actions="customActions" />
<component :is="lead.data._assignedTo?.length == 1 ? 'Button' : 'div'">
<MultipleAvatar
:avatars="lead.data._assignedTo"
@click="showAssignmentModal = true"
/>
</component>
<Dropdown :options="statusOptions('lead', updateField, lead.data._customStatuses)">
<Dropdown :options="statusOptions('lead', updateField, customStatuses)">
<template #default="{ open }">
<Button
:label="lead.data.status"
@ -179,6 +176,7 @@
<Section :is-opened="section.opened" :label="section.label">
<SectionFields
:fields="section.fields"
:isLastSection="i == fieldsLayout.data.length - 1"
v-model="lead.data"
@update="updateField"
/>
@ -307,15 +305,13 @@ import {
openWebsite,
createToast,
setupAssignees,
setupCustomActions,
setupCustomStatuses,
setupCustomizations,
errorMessage,
copyToClipboard,
} from '@/utils'
import { getView } from '@/utils/view'
import { globalStore } from '@/stores/global'
import { contactsStore } from '@/stores/contacts'
import { organizationsStore } from '@/stores/organizations'
import { statusesStore } from '@/stores/statuses'
import { usersStore } from '@/stores/users'
import { whatsappEnabled, callEnabled } from '@/composables/settings'
@ -335,9 +331,8 @@ import {
import { ref, computed, onMounted, watch } from 'vue'
import { useRouter, useRoute } from 'vue-router'
const { $dialog, makeCall } = globalStore()
const { $dialog, $socket, makeCall } = globalStore()
const { getContactByName, contacts } = contactsStore()
const { organizations } = organizationsStore()
const { statusOptions, getLeadStatus } = statusesStore()
const { isManager } = usersStore()
const route = useRoute()
@ -350,23 +345,32 @@ const props = defineProps({
},
})
const customActions = ref([])
const customStatuses = ref([])
const lead = createResource({
url: 'crm.fcrm.doctype.crm_lead.api.get_lead',
params: { name: props.leadId },
cache: ['lead', props.leadId],
onSuccess: (data) => {
onSuccess: async (data) => {
let obj = {
doc: data,
$dialog,
$socket,
router,
updateField,
createToast,
deleteDoc: deleteLead,
resource: {
lead,
fieldsLayout,
},
call,
}
setupAssignees(data)
setupCustomStatuses(data, obj)
setupCustomActions(data, obj)
let customization = await setupCustomizations(data, obj)
customActions.value = customization.actions || []
customStatuses.value = customization.statuses || []
},
})
@ -615,7 +619,6 @@ async function convertToDeal(updated) {
if (deal) {
capture('convert_lead_to_deal')
if (updated) {
await organizations.reload()
await contacts.reload()
}
router.push({ name: 'Deal', params: { dealId: deal } })

View File

@ -305,17 +305,21 @@ import QuickEntryModal from '@/components/Modals/QuickEntryModal.vue'
import ViewControls from '@/components/ViewControls.vue'
import { globalStore } from '@/stores/global'
import { usersStore } from '@/stores/users'
import { organizationsStore } from '@/stores/organizations'
import { statusesStore } from '@/stores/statuses'
import { callEnabled } from '@/composables/settings'
import { dateFormat, dateTooltipFormat, timeAgo, formatTime } from '@/utils'
import {
dateFormat,
dateTooltipFormat,
timeAgo,
website,
formatTime,
} from '@/utils'
import { Avatar, Tooltip, Dropdown } from 'frappe-ui'
import { useRoute } from 'vue-router'
import { ref, computed, reactive, h } from 'vue'
const { makeCall } = globalStore()
const { getUser } = usersStore()
const { getOrganization } = organizationsStore()
const { getLeadStatus } = statusesStore()
const route = useRoute()
@ -412,10 +416,9 @@ function parseRows(rows) {
image_label: lead.first_name,
}
} else if (row == 'organization') {
_rows[row] = {
label: lead.organization,
logo: getOrganization(lead.organization)?.organization_logo,
}
_rows[row] = lead.organization
} else if (row === 'website') {
_rows[row] = website(lead.website)
} else if (row == 'status') {
_rows[row] = {
label: lead.status,

View File

@ -9,11 +9,7 @@
</template>
</Breadcrumbs>
<div class="absolute right-0">
<Dropdown
:options="
statusOptions('deal', updateField, deal.data._customStatuses)
"
>
<Dropdown :options="statusOptions('deal', updateField, customStatuses)">
<template #default="{ open }">
<Button
:label="deal.data.status"
@ -45,10 +41,7 @@
/>
</component>
<div class="flex items-center gap-2">
<CustomActions
v-if="deal.data._customActions"
:actions="deal.data._customActions"
/>
<CustomActions v-if="customActions" :actions="customActions" />
</div>
</div>
<div v-if="deal.data" class="flex h-full overflow-hidden">
@ -108,13 +101,14 @@
<SectionFields
v-if="section.fields"
:fields="section.fields"
:isLastSection="i == fieldsLayout.data.length - 1"
v-model="deal.data"
@update="updateField"
/>
<div v-else>
<div
v-if="
deal_contacts?.loading && deal_contacts?.data?.length == 0
dealContacts?.loading && dealContacts?.data?.length == 0
"
class="flex min-h-20 flex-1 items-center justify-center gap-3 text-base text-gray-500"
>
@ -230,10 +224,7 @@
v-model:organization="_organization"
:options="{
redirect: false,
afterInsert: (doc) =>
updateField('organization', doc.name, () => {
organizations.reload()
}),
afterInsert: (doc) => updateField('organization', doc.name),
}"
/>
<ContactModal
@ -278,15 +269,9 @@ import Section from '@/components/Section.vue'
import SectionFields from '@/components/SectionFields.vue'
import SLASection from '@/components/SLASection.vue'
import CustomActions from '@/components/CustomActions.vue'
import {
createToast,
setupAssignees,
setupCustomActions,
setupCustomStatuses,
} from '@/utils'
import { createToast, setupAssignees, setupCustomizations } from '@/utils'
import { getView } from '@/utils/view'
import { globalStore } from '@/stores/global'
import { organizationsStore } from '@/stores/organizations'
import { statusesStore } from '@/stores/statuses'
import {
whatsappEnabled,
@ -304,8 +289,7 @@ import {
import { ref, computed, h, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router'
const { $dialog } = globalStore()
const { organizations, getOrganization } = organizationsStore()
const { $dialog, $socket } = globalStore()
const { statusOptions, getDealStatus } = statusesStore()
const route = useRoute()
const router = useRouter()
@ -317,26 +301,45 @@ const props = defineProps({
},
})
const customActions = ref([])
const customStatuses = ref([])
const deal = createResource({
url: 'crm.fcrm.doctype.crm_deal.api.get_deal',
params: { name: props.dealId },
cache: ['deal', props.dealId],
onSuccess: (data) => {
onSuccess: async (data) => {
organization.update({
params: { doctype: 'CRM Organization', name: data.organization },
})
organization.fetch()
let obj = {
doc: data,
$dialog,
$socket,
router,
updateField,
createToast,
deleteDoc: deleteDeal,
resource: {
deal,
dealContacts,
fieldsLayout,
},
call,
}
setupAssignees(data)
setupCustomStatuses(data, obj)
setupCustomActions(data, obj)
let customization = await setupCustomizations(data, obj)
customActions.value = customization.actions || []
customStatuses.value = customization.statuses || []
},
})
const organization = createResource({
url: 'frappe.client.get',
onSuccess: (data) => (deal.data._organizationObj = data),
})
onMounted(() => {
if (deal.data) return
deal.fetch()
@ -347,10 +350,6 @@ const showOrganizationModal = ref(false)
const showAssignmentModal = ref(false)
const _organization = ref({})
const organization = computed(() => {
return deal.data?.organization && getOrganization(deal.data.organization)
})
function updateDeal(fieldname, value, callback) {
value = Array.isArray(fieldname) ? '' : value
@ -419,7 +418,7 @@ const breadcrumbs = computed(() => {
}
items.push({
label: organization.value?.name || __('Untitled'),
label: organization.data?.name || __('Untitled'),
route: { name: 'Deal', params: { dealId: deal.data.name } },
})
return items
@ -533,7 +532,7 @@ async function addContact(contact) {
contact,
})
if (d) {
deal_contacts.reload()
dealContacts.reload()
createToast({
title: __('Contact added'),
icon: 'check',
@ -548,7 +547,7 @@ async function removeContact(contact) {
contact,
})
if (d) {
deal_contacts.reload()
dealContacts.reload()
createToast({
title: __('Contact removed'),
icon: 'check',
@ -563,7 +562,7 @@ async function setPrimaryContact(contact) {
contact,
})
if (d) {
deal_contacts.reload()
dealContacts.reload()
createToast({
title: __('Primary contact set'),
icon: 'check',
@ -572,7 +571,7 @@ async function setPrimaryContact(contact) {
}
}
const deal_contacts = createResource({
const dealContacts = createResource({
url: 'crm.fcrm.doctype.crm_deal.api.get_deal_contacts',
params: { name: props.dealId },
cache: ['deal_contacts', props.dealId],

View File

@ -9,11 +9,7 @@
</template>
</Breadcrumbs>
<div class="absolute right-0">
<Dropdown
:options="
statusOptions('lead', updateField, lead.data._customStatuses)
"
>
<Dropdown :options="statusOptions('lead', updateField, customStatuses)">
<template #default="{ open }">
<Button
:label="lead.data.status"
@ -45,10 +41,7 @@
/>
</component>
<div class="flex items-center gap-2">
<CustomActions
v-if="lead.data._customActions"
:actions="lead.data._customActions"
/>
<CustomActions v-if="customActions" :actions="customActions" />
<Button
:label="__('Convert')"
variant="solid"
@ -84,6 +77,7 @@
<Section :is-opened="section.opened" :label="section.label">
<SectionFields
:fields="section.fields"
:isLastSection="i == fieldsLayout.data.length - 1"
v-model="lead.data"
@update="updateField"
/>
@ -199,16 +193,10 @@ import Section from '@/components/Section.vue'
import SectionFields from '@/components/SectionFields.vue'
import SLASection from '@/components/SLASection.vue'
import CustomActions from '@/components/CustomActions.vue'
import {
createToast,
setupAssignees,
setupCustomActions,
setupCustomStatuses,
} from '@/utils'
import { createToast, setupAssignees, setupCustomizations } from '@/utils'
import { getView } from '@/utils/view'
import { globalStore } from '@/stores/global'
import { contactsStore } from '@/stores/contacts'
import { organizationsStore } from '@/stores/organizations'
import { statusesStore } from '@/stores/statuses'
import {
whatsappEnabled,
@ -226,9 +214,8 @@ import {
import { ref, computed, onMounted, watch } from 'vue'
import { useRouter, useRoute } from 'vue-router'
const { $dialog } = globalStore()
const { $dialog, $socket } = globalStore()
const { getContactByName, contacts } = contactsStore()
const { organizations } = organizationsStore()
const { statusOptions, getLeadStatus } = statusesStore()
const route = useRoute()
const router = useRouter()
@ -240,23 +227,32 @@ const props = defineProps({
},
})
const customActions = ref([])
const customStatuses = ref([])
const lead = createResource({
url: 'crm.fcrm.doctype.crm_lead.api.get_lead',
params: { name: props.leadId },
cache: ['lead', props.leadId],
onSuccess: (data) => {
onSuccess: async (data) => {
let obj = {
doc: data,
$dialog,
$socket,
router,
updateField,
createToast,
deleteDoc: deleteLead,
resource: {
lead,
fieldsLayout,
},
call,
}
setupAssignees(data)
setupCustomStatuses(data, obj)
setupCustomActions(data, obj)
let customization = await setupCustomizations(data, obj)
customActions.value = customization.actions || []
customStatuses.value = customization.statuses || []
},
})
@ -496,7 +492,6 @@ async function convertToDeal(updated) {
)
if (deal) {
if (updated) {
await organizations.reload()
await contacts.reload()
}
router.push({ name: 'Deal', params: { dealId: deal } })

View File

@ -82,6 +82,7 @@ import {
dateFormat,
dateTooltipFormat,
timeAgo,
website,
formatNumberIntoCurrency,
} from '@/utils'
import { ref, computed } from 'vue'
@ -130,8 +131,4 @@ const rows = computed(() => {
return _rows
})
})
function website(url) {
return url && url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, '')
}
</script>

View File

@ -57,7 +57,7 @@ export function taskStatusOptions(action, data) {
label: status,
onClick: () => action && action(status, data),
}
}
},
)
}
@ -72,9 +72,16 @@ export function taskPriorityOptions(action, data) {
}
export function openWebsite(url) {
if (!url.startsWith('http://') && !url.startsWith('https://')) {
url = 'https://' + url
}
window.open(url, '_blank')
}
export function website(url) {
return url && url.replace(/^(?:https?:\/\/)?(?:www\.)?/i, '')
}
export function htmlToText(html) {
const div = document.createElement('div')
div.innerHTML = html
@ -125,77 +132,61 @@ export function setupAssignees(data) {
}))
}
function getActionsFromScript(script, obj) {
async function getFromScript(script, obj) {
let scriptFn = new Function(script + '\nreturn setupForm')()
let formScript = scriptFn(obj)
return formScript?.actions || []
let formScript = await scriptFn(obj)
return formScript || {}
}
function getStatusFromScript(script, obj) {
let scriptFn = new Function(script + '\nreturn setupForm')()
let formScript = scriptFn(obj)
return formScript?.statuses || []
}
export function setupCustomStatuses(data, obj) {
export async function setupCustomizations(data, obj) {
if (!data._form_script) return []
let statuses = []
let actions = []
if (Array.isArray(data._form_script)) {
data._form_script.forEach((script) => {
statuses = statuses.concat(getStatusFromScript(script, obj))
})
for (let script of data._form_script) {
let _script = await getFromScript(script, obj)
actions = actions.concat(_script?.actions || [])
statuses = statuses.concat(_script?.statuses || [])
}
} else {
statuses = getStatusFromScript(data._form_script, data)
let _script = await getFromScript(data._form_script, obj)
actions = _script?.actions || []
statuses = _script?.statuses || []
}
data._customStatuses = statuses
}
export function setupCustomActions(data, obj) {
if (!data._form_script) return []
let actions = []
if (Array.isArray(data._form_script)) {
data._form_script.forEach((script) => {
actions = actions.concat(getActionsFromScript(script, obj))
})
} else {
actions = getActionsFromScript(data._form_script, obj)
}
data._customActions = actions
return { statuses, actions }
}
function getActionsFromListScript(script, obj) {
async function getListScript(script, obj) {
let scriptFn = new Function(script + '\nreturn setupList')()
let listScript = scriptFn(obj)
return {
actions: listScript?.actions || [],
bulk_actions: listScript?.bulk_actions || [],
}
let listScript = await scriptFn(obj)
return listScript || {}
}
export function setupListActions(data, obj = {}) {
export async function setupListCustomizations(data, obj = {}) {
if (!data.list_script) return []
let actions = []
let bulkActions = []
if (Array.isArray(data.list_script)) {
data.list_script.forEach((script) => {
let _actions = getActionsFromListScript(script, obj)
actions = actions.concat(_actions.actions)
bulkActions = bulkActions.concat(_actions.bulk_actions)
})
for (let script of data.list_script) {
let _script = await getListScript(script, obj)
actions = actions.concat(_script?.actions || [])
bulkActions = bulkActions.concat(_script?.bulk_actions || [])
}
} else {
let _actions = getActionsFromListScript(data.list_script, obj)
actions = _actions.actions
bulkActions = _actions.bulk_actions
let _script = await getListScript(data.list_script, obj)
actions = _script?.actions || []
bulkActions = _script?.bulk_actions || []
}
data.listActions = actions
data.bulkActions = bulkActions
return { actions, bulkActions }
}
export function errorMessage(title, message) {
@ -235,7 +226,7 @@ export function isEmoji(str) {
}
export function isTouchScreenDevice() {
return "ontouchstart" in document.documentElement;
return 'ontouchstart' in document.documentElement
}
export function convertArrayToString(array) {
@ -282,4 +273,4 @@ export function evaluate_depends_on_value(expression, doc) {
}
return out
}
}