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