Skip to content

Commit

Permalink
Merge pull request #384 from frappe/develop
Browse files Browse the repository at this point in the history
chore: Merge develop to main
  • Loading branch information
shariquerik authored Sep 28, 2024
2 parents e19f867 + a0c95db commit 6a7793b
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 12 deletions.
5 changes: 3 additions & 2 deletions crm/api/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,10 +611,10 @@ def get_field_obj(field):
"all_properties": field,
}

obj["placeholder"] = "Add " + field.label + "..."
obj["placeholder"] = field.placeholder or "Add " + field.label + "..."

if field.fieldtype == "Link":
obj["placeholder"] = "Select " + field.label + "..."
obj["placeholder"] = field.placeholder or "Select " + field.label + "..."
obj["doctype"] = field.options
elif field.fieldtype == "Select" and field.options:
obj["options"] = [{"label": option, "value": option} for option in field.options.split("\n")]
Expand Down Expand Up @@ -686,6 +686,7 @@ def get_fields(doctype: str, allow_all_fieldtypes: bool = False):
"mandatory_depends_on": field.mandatory_depends_on,
"read_only_depends_on": field.read_only_depends_on,
"link_filters": field.get("link_filters"),
"placeholder": field.placeholder,
})

return _fields
Expand Down
1 change: 1 addition & 0 deletions crm/api/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def get_notifications():
def mark_as_read(user=None, doc=None):
user = user or frappe.session.user
filters = {"to_user": user, "read": False}
or_filters = []
if doc:
or_filters = [
{"comment": doc},
Expand Down
1 change: 1 addition & 0 deletions crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def get_fields_layout(doctype: str, type: str):
"type": field.fieldtype,
"options": field.options,
"mandatory": field.reqd,
"placeholder": field.placeholder,
}
section["fields"][section.get("fields").index(field["name"])] = field

Expand Down
1 change: 1 addition & 0 deletions crm/fcrm/doctype/crm_form_script/crm_form_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ frappe.ui.form.on("CRM Form Script", {
function setupForm({ doc }) {
return {
actions: [],
statuses: [],
}
}`.trim();
}
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/SectionFields.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ import { computed } from 'vue'
const props = defineProps({
fields: {
type: Object,
required: true,
},
isLastSection: {
type: Boolean,
Expand All @@ -146,7 +145,7 @@ const _fields = computed(() => {
if (df?.depends_on) evaluate_depends_on(df.depends_on, field)
all_fields.push({
...field,
filters: df.link_filters && JSON.parse(df.link_filters),
filters: df?.link_filters && JSON.parse(df.link_filters),
placeholder: field.placeholder || field.label,
})
})
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Settings/SidePanelModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
v-for="(section, i) in sections.data"
:key="section.label"
class="flex flex-col py-1.5 px-1"
:class="{ 'border-b': i !== sections.data.length - 1 }"
:class="{ 'border-b': i !== sections.data?.length - 1 }"
>
<Section :is-opened="section.opened" :label="section.label">
<SectionFields
:fields="section.fields"
:isLastSection="i == section.data.length - 1"
:isLastSection="i == section.data?.length - 1"
v-model="data"
/>
</Section>
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/composables/useActiveTabManager.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { ref, watch } from 'vue'
import { useRoute } from 'vue-router'
import { useRoute, useRouter } from 'vue-router'
import { useDebounceFn, useStorage } from '@vueuse/core'

export function useActiveTabManager(tabs, storageKey) {
const activieTab = useStorage(storageKey, 'activity')
const route = useRoute()
const router = useRouter()

const preserveLastVisitedTab = useDebounceFn((tabName) => {
activieTab.value = tabName.toLowerCase()
}, 300)

function setActiveTabInUrl(tabName) {
window.location.hash = '#' + tabName.toLowerCase()
let hash = '#' + tabName.toLowerCase()
router.push({ ...route, hash })
}

function getActiveTabFromUrl() {
Expand Down Expand Up @@ -46,7 +48,6 @@ export function useActiveTabManager(tabs, storageKey) {

let lastVisitedTab = getActiveTabFromLocalStorage()
if (lastVisitedTab) {
setActiveTabInUrl(lastVisitedTab)
return getTabIndex(lastVisitedTab)
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Deal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ function contactOptions(contact) {
options.push({
label: __('Set as Primary Contact'),
icon: h(SuccessIcon, { class: 'h-4 w-4' }),
onClick: () => setPrimaryContact(contact),
onClick: () => setPrimaryContact(contact.name),
})
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/MobileDeal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ function contactOptions(contact) {
options.push({
label: __('Set as Primary Contact'),
icon: h(SuccessIcon, { class: 'h-4 w-4' }),
onClick: () => setPrimaryContact(contact),
onClick: () => setPrimaryContact(contact.name),
})
}
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,14 @@ router.beforeEach(async (to, from, next) => {
if (to.name === 'Home' && isLoggedIn) {
next({ name: 'Leads' })
} else if (!isLoggedIn) {
window.location.href = "/login?redirect-to=/crm";
window.location.href = '/login?redirect-to=/crm'
} else if (to.matched.length === 0) {
next({ name: 'Invalid Page' })
} else if (['Deal', 'Lead'].includes(to.name) && !to.hash) {
let storageKey = to.name === 'Deal' ? 'lastDealTab' : 'lastLeadTab'
const activeTab = localStorage.getItem(storageKey) || 'activity'
const hash = '#' + activeTab
next({ ...to, hash })
} else {
next()
}
Expand Down

0 comments on commit 6a7793b

Please sign in to comment.