fix: update organization logo handling and add beforeFieldChange functionality to rename organization
(cherry picked from commit 1b7af2096f6bfc18094ce727e3e43754c279e51b)
This commit is contained in:
parent
7a9da275da
commit
8f0e8f3f52
@ -30,14 +30,14 @@
|
|||||||
:image="organization.doc.organization_logo"
|
:image="organization.doc.organization_logo"
|
||||||
/>
|
/>
|
||||||
<component
|
<component
|
||||||
:is="organization.doc.image ? Dropdown : 'div'"
|
:is="organization.doc.organization_logo ? Dropdown : 'div'"
|
||||||
v-bind="
|
v-bind="
|
||||||
organization.doc.image
|
organization.doc.organization_logo
|
||||||
? {
|
? {
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
icon: 'upload',
|
icon: 'upload',
|
||||||
label: organization.doc.image
|
label: organization.doc.organization_logo
|
||||||
? __('Change image')
|
? __('Change image')
|
||||||
: __('Upload image'),
|
: __('Upload image'),
|
||||||
onClick: openFileSelector,
|
onClick: openFileSelector,
|
||||||
@ -105,6 +105,7 @@
|
|||||||
doctype="CRM Organization"
|
doctype="CRM Organization"
|
||||||
:docname="organization.doc.name"
|
:docname="organization.doc.name"
|
||||||
@reload="sections.reload"
|
@reload="sections.reload"
|
||||||
|
@beforeFieldChange="beforeFieldChange"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Resizer>
|
</Resizer>
|
||||||
@ -180,6 +181,7 @@ import WebsiteIcon from '@/components/Icons/WebsiteIcon.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 DeleteLinkedDocModal from '@/components/DeleteLinkedDocModal.vue'
|
||||||
import { showAddressModal, addressProps } from '@/composables/modals'
|
import { showAddressModal, addressProps } from '@/composables/modals'
|
||||||
import { useDocument } from '@/data/document'
|
import { useDocument } from '@/data/document'
|
||||||
import { getSettings } from '@/stores/settings'
|
import { getSettings } from '@/stores/settings'
|
||||||
@ -189,21 +191,19 @@ import { statusesStore } from '@/stores/statuses'
|
|||||||
import { getView } from '@/utils/view'
|
import { getView } from '@/utils/view'
|
||||||
import { formatDate, timeAgo, validateIsImageFile } from '@/utils'
|
import { formatDate, timeAgo, validateIsImageFile } from '@/utils'
|
||||||
import {
|
import {
|
||||||
Tooltip,
|
|
||||||
Breadcrumbs,
|
Breadcrumbs,
|
||||||
Avatar,
|
Avatar,
|
||||||
FileUploader,
|
FileUploader,
|
||||||
Dropdown,
|
Dropdown,
|
||||||
Tabs,
|
Tabs,
|
||||||
call,
|
|
||||||
createListResource,
|
createListResource,
|
||||||
usePageMeta,
|
usePageMeta,
|
||||||
createResource,
|
createResource,
|
||||||
toast,
|
toast,
|
||||||
|
call,
|
||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
import { h, computed, ref } from 'vue'
|
import { h, computed, ref } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute, useRouter } from 'vue-router'
|
||||||
import DeleteLinkedDocModal from '@/components/DeleteLinkedDocModal.vue'
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
organizationId: {
|
organizationId: {
|
||||||
@ -218,6 +218,7 @@ const { getDealStatus } = statusesStore()
|
|||||||
const { doctypeMeta } = getMeta('CRM Organization')
|
const { doctypeMeta } = getMeta('CRM Organization')
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
const errorTitle = ref('')
|
const errorTitle = ref('')
|
||||||
const errorMessage = ref('')
|
const errorMessage = ref('')
|
||||||
@ -277,14 +278,27 @@ async function deleteOrganization() {
|
|||||||
showDeleteLinkedDocModal.value = true
|
showDeleteLinkedDocModal.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
async function changeOrganizationImage(file) {
|
function changeOrganizationImage(file) {
|
||||||
await call('frappe.client.set_value', {
|
organization.setValue.submit({
|
||||||
doctype: 'CRM Organization',
|
organization_logo: file?.file_url || null,
|
||||||
name: props.organizationId,
|
|
||||||
fieldname: 'organization_logo',
|
|
||||||
value: file?.file_url || '',
|
|
||||||
})
|
})
|
||||||
organization.reload()
|
}
|
||||||
|
|
||||||
|
function beforeFieldChange(data) {
|
||||||
|
if (data?.hasOwnProperty('organization_name')) {
|
||||||
|
call('frappe.client.rename_doc', {
|
||||||
|
doctype: 'CRM Organization',
|
||||||
|
old_name: props.organizationId,
|
||||||
|
new_name: data.organization_name,
|
||||||
|
}).then(() => {
|
||||||
|
router.push({
|
||||||
|
name: 'Organization',
|
||||||
|
params: { organizationId: data.organization_name },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
organization.save.submit()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function website(url) {
|
function website(url) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user