From 87862c960304ca9a5be928bcb178ffb4232a3dd2 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Tue, 28 Nov 2023 12:15:41 +0530 Subject: [PATCH] feat: edit column label & width --- frontend/src/components/ViewSettings.vue | 178 ++++++++++++++++------- 1 file changed, 126 insertions(+), 52 deletions(-) diff --git a/frontend/src/components/ViewSettings.vue b/frontend/src/components/ViewSettings.vue index 76f6af1b..89072b52 100644 --- a/frontend/src/components/ViewSettings.vue +++ b/frontend/src/components/ViewSettings.vue @@ -11,54 +11,99 @@
- - - -
- + - - + +
+ + + +
+
+
+
+
+ + +
+
+
+
@@ -72,8 +117,8 @@ import DragIcon from '@/components/Icons/DragIcon.vue' import NestedPopover from '@/components/NestedPopover.vue' import Autocomplete from '@/components/frappe-ui/Autocomplete.vue' import Draggable from 'vuedraggable' -import { computed, defineModel } from 'vue' -import { FeatherIcon, call } from 'frappe-ui' +import { computed, defineModel, ref } from 'vue' +import { FeatherIcon, FormControl, call } from 'frappe-ui' const props = defineProps({ doctype: { @@ -83,6 +128,13 @@ const props = defineProps({ }) const list = defineModel() +const edit = ref(false) +const column = ref({ + old: {}, + label: '', + key: '', + width: '10rem', +}) const columns = computed({ get: () => list.value?.data?.columns, @@ -108,24 +160,46 @@ const fields = computed(() => { }) async function addColumn(c) { - let column = { + let _column = { label: c.label, key: c.value, width: '10rem', } - columns.value.push(column) + columns.value.push(_column) rows.value.push(c.value) - await onEnd() + await updateColumnDetails() list.value.reload() } function removeColumn(c) { columns.value = columns.value.filter((column) => column.key !== c.key) rows.value = rows.value.filter((row) => row !== c.key) - onEnd() + updateColumnDetails() } -async function onEnd() { +function editColumn(c) { + edit.value = true + column.value = c + column.value.old = { ...c } +} + +function updateColumn(c) { + edit.value = false + let index = columns.value.findIndex((column) => column.key === c.key) + columns.value[index].label = c.label + columns.value[index].width = c.width + updateColumnDetails() +} + +function cancelUpdate() { + edit.value = false + column.value = { + ...column.value.old, + old: {}, + } +} + +async function updateColumnDetails() { await call( 'crm.fcrm.doctype.crm_list_view_settings.crm_list_view_settings.update', {