Skip to content

Commit

Permalink
Merge pull request #342 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 10, 2024
2 parents 5ce81aa + 49082be commit f452a99
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 45 deletions.
11 changes: 5 additions & 6 deletions frontend/src/components/Activities/EmailArea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
</div>
</div>
</div>
<div class="flex flex-col gap-1 text-base text-gray-800">
<div class="flex flex-col gap-1 text-base leading-5 text-gray-800">
<div>{{ activity.data.subject }}</div>
<div>
<span class="mr-1 text-gray-600"> {{ __('To') }}: </span>
<span>{{ activity.data.recipients }}</span>
Expand All @@ -66,12 +67,8 @@
</span>
<span v-if="activity.data.bcc">{{ activity.data.bcc }}</span>
</div>
<div>
<span class="mr-1 text-gray-600"> {{ __('Subject') }}: </span>
<span>{{ activity.data.subject }}</span>
</div>
</div>
<div class="border-0 border-t my-3.5 border-gray-200" />
<div class="border-0 border-t mt-3 mb-1 border-gray-200" />
<EmailContent :content="activity.data.content" />
<div v-if="activity.data?.attachments?.length" class="flex flex-wrap gap-2">
<AttachmentItem
Expand Down Expand Up @@ -108,6 +105,8 @@ function reply(email, reply_all = false) {
if (!email.subject.startsWith('Re:')) {
editor.subject = `Re: ${email.subject}`
} else {
editor.subject = email.subject
}
if (reply_all) {
Expand Down
14 changes: 9 additions & 5 deletions frontend/src/components/Settings/InviteMemberPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
{{ __('Send Invites To') }}
</h2>
<div class="flex-1 overflow-y-auto">
<label class="block text-xs text-gray-600 mb-1.5">
{{ __('Invite by email') }}
</label>
<MultiValueInput
v-model="invitees"
:validate="validateEmail"
Expand All @@ -26,17 +29,17 @@
<ErrorMessage class="mt-2" v-if="error" :message="error" />
<template v-if="pendingInvitations.data?.length && !invitees.length">
<div
class="mt-4 flex items-center justify-between border-b py-2 text-base text-gray-600"
class="mt-6 flex items-center justify-between py-4 text-base font-semibold"
>
<div class="w-4/5">{{ __('Pending Invites') }}</div>
<div>{{ __('Pending Invites') }}</div>
</div>
<ul class="divide-y overflow-auto">
<ul class="flex flex-col gap-1">
<li
class="flex items-center justify-between py-2"
class="flex items-center justify-between px-2 py-1 rounded-lg bg-gray-50"
v-for="user in pendingInvitations.data"
:key="user.name"
>
<div class="w-4/5 text-base">
<div class="text-base">
<span class="text-gray-900">
{{ user.email }}
</span>
Expand All @@ -46,6 +49,7 @@
<Tooltip text="Delete Invitation">
<Button
icon="x"
variant="ghost"
:loading="
pendingInvitations.delete.loading &&
pendingInvitations.delete.params.name === user.name
Expand Down
17 changes: 9 additions & 8 deletions frontend/src/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import './index.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import { createDialog } from './utils/dialogs'
import { initSocket } from './socket'
import router from './router'
import translationPlugin from './translation'
import { posthogPlugin } from './telemetry'
import App from './App.vue'

import {
FrappeUI,
Button,
Expand All @@ -14,14 +23,6 @@ import {
frappeRequest,
FeatherIcon,
} from 'frappe-ui'
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import { createDialog } from './utils/dialogs'
import { initSocket } from './socket'
import router from './router'
import translationPlugin from './translation'
import { posthogPlugin } from './telemetry'
import App from './App.vue'

let globalComponents = {
Button,
Expand Down
19 changes: 12 additions & 7 deletions frontend/src/pages/Deal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
@click="showAssignmentModal = true"
/>
</component>
<Dropdown :options="statusOptions('deal', updateField)">
<Dropdown
:options="statusOptions('deal', updateField, deal.data._customStatuses)"
>
<template #default="{ open }">
<Button
:label="deal.data.status"
Expand Down Expand Up @@ -212,7 +214,7 @@
/>
</div>
<div class="flex items-center">
<Dropdown :options="contactOptions(contact.name)">
<Dropdown :options="contactOptions(contact)">
<Button
icon="more-horizontal"
class="text-gray-600"
Expand Down Expand Up @@ -339,6 +341,7 @@ import {
createToast,
setupAssignees,
setupCustomActions,
setupCustomStatuses,
errorMessage,
copyToClipboard,
} from '@/utils'
Expand Down Expand Up @@ -380,16 +383,18 @@ const deal = createResource({
params: { name: props.dealId },
cache: ['deal', props.dealId],
onSuccess: (data) => {
setupAssignees(data)
setupCustomActions(data, {
let obj = {
doc: data,
$dialog,
router,
updateField,
createToast,
deleteDoc: deleteDeal,
call,
})
}
setupAssignees(data)
setupCustomStatuses(data, obj)
setupCustomActions(data, obj)
},
})
Expand Down Expand Up @@ -567,9 +572,9 @@ const _contact = ref({})
function contactOptions(contact) {
let options = [
{
label: __('Delete'),
label: __('Remove'),
icon: 'trash-2',
onClick: () => removeContact(contact),
onClick: () => removeContact(contact.name),
},
]
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Deals.vue
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ function parseRows(rows) {
...(deal.deal_owner && getUser(deal.deal_owner)),
}
} else if (row == '_assign') {
let assignees = JSON.parse(deal._assign) || []
let assignees = JSON.parse(deal._assign || '[]')
if (!assignees.length && deal.deal_owner) {
assignees = [deal.deal_owner]
}
Expand Down
11 changes: 7 additions & 4 deletions frontend/src/pages/Lead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@click="showAssignmentModal = true"
/>
</component>
<Dropdown :options="statusOptions('lead', updateField)">
<Dropdown :options="statusOptions('lead', updateField, lead.data._customStatuses)">
<template #default="{ open }">
<Button
:label="lead.data.status"
Expand Down Expand Up @@ -308,6 +308,7 @@ import {
createToast,
setupAssignees,
setupCustomActions,
setupCustomStatuses,
errorMessage,
copyToClipboard,
} from '@/utils'
Expand Down Expand Up @@ -354,16 +355,18 @@ const lead = createResource({
params: { name: props.leadId },
cache: ['lead', props.leadId],
onSuccess: (data) => {
setupAssignees(data)
setupCustomActions(data, {
let obj = {
doc: data,
$dialog,
router,
updateField,
createToast,
deleteDoc: deleteLead,
call,
})
}
setupAssignees(data)
setupCustomStatuses(data, obj)
setupCustomActions(data, obj)
},
})
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Leads.vue
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ function parseRows(rows) {
...(lead.lead_owner && getUser(lead.lead_owner)),
}
} else if (row == '_assign') {
let assignees = JSON.parse(lead._assign) || []
let assignees = JSON.parse(lead._assign || '[]')
if (!assignees.length && lead.lead_owner) {
assignees = [lead.lead_owner]
}
Expand Down
21 changes: 16 additions & 5 deletions frontend/src/pages/MobileDeal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
</template>
</Breadcrumbs>
<div class="absolute right-0">
<Dropdown :options="statusOptions('deal', updateField)">
<Dropdown
:options="
statusOptions('deal', updateField, deal.data._customStatuses)
"
>
<template #default="{ open }">
<Button
:label="deal.data.status"
Expand Down Expand Up @@ -274,7 +278,12 @@ 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 } from '@/utils'
import {
createToast,
setupAssignees,
setupCustomActions,
setupCustomStatuses,
} from '@/utils'
import { getView } from '@/utils/view'
import { globalStore } from '@/stores/global'
import { organizationsStore } from '@/stores/organizations'
Expand Down Expand Up @@ -313,16 +322,18 @@ const deal = createResource({
params: { name: props.dealId },
cache: ['deal', props.dealId],
onSuccess: (data) => {
setupAssignees(data)
setupCustomActions(data, {
let obj = {
doc: data,
$dialog,
router,
updateField,
createToast,
deleteDoc: deleteDeal,
call,
})
}
setupAssignees(data)
setupCustomStatuses(data, obj)
setupCustomActions(data, obj)
},
})
Expand Down
21 changes: 16 additions & 5 deletions frontend/src/pages/MobileLead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
</template>
</Breadcrumbs>
<div class="absolute right-0">
<Dropdown :options="statusOptions('lead', updateField)">
<Dropdown
:options="
statusOptions('lead', updateField, lead.data._customStatuses)
"
>
<template #default="{ open }">
<Button
:label="lead.data.status"
Expand Down Expand Up @@ -195,7 +199,12 @@ 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 } from '@/utils'
import {
createToast,
setupAssignees,
setupCustomActions,
setupCustomStatuses,
} from '@/utils'
import { getView } from '@/utils/view'
import { globalStore } from '@/stores/global'
import { contactsStore } from '@/stores/contacts'
Expand Down Expand Up @@ -236,16 +245,18 @@ const lead = createResource({
params: { name: props.leadId },
cache: ['lead', props.leadId],
onSuccess: (data) => {
setupAssignees(data)
setupCustomActions(data, {
let obj = {
doc: data,
$dialog,
router,
updateField,
createToast,
deleteDoc: deleteLead,
call,
})
}
setupAssignees(data)
setupCustomStatuses(data, obj)
setupCustomActions(data, obj)
},
})
Expand Down
14 changes: 11 additions & 3 deletions frontend/src/stores/statuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ export const statusesStore = defineStore('crm-statuses', () => {
} else if (['gray', 'green'].includes(color)) {
textColor = `!text-${color}-700`
}

let bgColor = `!bg-${color}-100 hover:!bg-${color}-200 active:!bg-${color}-300`

return [textColor, onlyIcon ? '' : bgColor]
}

Expand All @@ -91,9 +91,17 @@ export const statusesStore = defineStore('crm-statuses', () => {
return communicationStatuses[name]
}

function statusOptions(doctype, action) {
function statusOptions(doctype, action, statuses = []) {
let statusesByName =
doctype == 'deal' ? dealStatusesByName : leadStatusesByName

if (statuses.length) {
statusesByName = statuses.reduce((acc, status) => {
acc[status] = statusesByName[status]
return acc
}, {})
}

let options = []
for (const status in statusesByName) {
options.push({
Expand Down
21 changes: 21 additions & 0 deletions frontend/src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,27 @@ function getActionsFromScript(script, obj) {
return formScript?.actions || []
}

function getStatusFromScript(script, obj) {
let scriptFn = new Function(script + '\nreturn setupForm')()
let formScript = scriptFn(obj)
return formScript?.statuses || []
}

export function setupCustomStatuses(data, obj) {
if (!data._form_script) return []

let statuses = []
if (Array.isArray(data._form_script)) {
data._form_script.forEach((script) => {
statuses = statuses.concat(getStatusFromScript(script, obj))
})
} else {
statuses = getStatusFromScript(data._form_script, data)
}

data._customStatuses = statuses
}

export function setupCustomActions(data, obj) {
if (!data._form_script) return []

Expand Down

0 comments on commit f452a99

Please sign in to comment.