From 7095344bb7ef1777ee76996f47bddacddb992183 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Thu, 4 Aug 2022 15:06:56 +0530 Subject: [PATCH 01/34] refactor(gui-v2): replace column with reactive object Signed-off-by: Pranav C --- .../nc-gui-v2/components/cell/Checkbox.vue | 2 +- .../nc-gui-v2/components/cell/Currency.vue | 2 +- .../nc-gui-v2/components/cell/DatePicker.vue | 2 +- .../nc-gui-v2/components/cell/Duration.vue | 2 +- .../nc-gui-v2/components/cell/MultiSelect.vue | 2 +- .../nc-gui-v2/components/cell/Percent.vue | 4 +- packages/nc-gui-v2/components/cell/Rating.vue | 2 +- .../components/cell/SingleSelect.vue | 2 +- packages/nc-gui-v2/components/cell/Url.vue | 2 +- .../components/cell/attachment/utils.ts | 2 +- .../components/smartsheet-header/Cell.vue | 6 +- .../components/smartsheet-header/CellIcon.vue | 10 +- .../components/smartsheet-header/Menu.vue | 6 +- .../smartsheet-header/VirtualCell.vue | 4 +- .../smartsheet-header/VirtualCellIcon.vue | 10 +- .../nc-gui-v2/components/smartsheet/Cell.vue | 10 +- .../components/smartsheet/VirtualCell.vue | 3 +- .../composables/useColumnCreateStore.ts | 352 +++++++++--------- .../nc-gui-v2/composables/useVirtualCell.ts | 22 +- packages/nc-gui-v2/context/index.ts | 2 +- 20 files changed, 228 insertions(+), 219 deletions(-) diff --git a/packages/nc-gui-v2/components/cell/Checkbox.vue b/packages/nc-gui-v2/components/cell/Checkbox.vue index ec6fb56386..f24d797de5 100644 --- a/packages/nc-gui-v2/components/cell/Checkbox.vue +++ b/packages/nc-gui-v2/components/cell/Checkbox.vue @@ -26,7 +26,7 @@ const checkboxMeta = $computed(() => { unchecked: 'mdi-checkbox-blank-circle-outline', }, color: 'primary', - ...(column?.meta || {}), + ...(column?.value?.meta || {}), } }) diff --git a/packages/nc-gui-v2/components/cell/Currency.vue b/packages/nc-gui-v2/components/cell/Currency.vue index fe99200482..71c1e639d0 100644 --- a/packages/nc-gui-v2/components/cell/Currency.vue +++ b/packages/nc-gui-v2/components/cell/Currency.vue @@ -22,7 +22,7 @@ const currencyMeta = computed(() => { return { currency_locale: 'en-US', currency_code: 'USD', - ...(column && column.meta ? column.meta : {}), + ...(column?.value?.meta ? column?.value?.meta : {}), } }) const currency = computed(() => { diff --git a/packages/nc-gui-v2/components/cell/DatePicker.vue b/packages/nc-gui-v2/components/cell/DatePicker.vue index 19e59b98a6..ee373db17b 100644 --- a/packages/nc-gui-v2/components/cell/DatePicker.vue +++ b/packages/nc-gui-v2/components/cell/DatePicker.vue @@ -14,7 +14,7 @@ const columnMeta = inject(ColumnInj, null) const readOnlyMode = inject(ReadonlyInj, false) let isDateInvalid = $ref(false) -const dateFormat = columnMeta?.meta?.date_format ?? 'YYYY-MM-DD' +const dateFormat = columnMeta?.value?.meta?.date_format ?? 'YYYY-MM-DD' const localState = $computed({ get() { diff --git a/packages/nc-gui-v2/components/cell/Duration.vue b/packages/nc-gui-v2/components/cell/Duration.vue index 9a19351556..5ef2e9a2e3 100644 --- a/packages/nc-gui-v2/components/cell/Duration.vue +++ b/packages/nc-gui-v2/components/cell/Duration.vue @@ -16,7 +16,7 @@ const column = inject(ColumnInj) const showWarningMessage = ref(false) const durationInMS = ref(0) const isEdited = ref(false) -const durationType = ref(column?.meta?.duration || 0) +const durationType = ref(column?.value?.meta?.duration || 0) const durationPlaceholder = computed(() => durationOptions[durationType.value].title) const localState = computed({ diff --git a/packages/nc-gui-v2/components/cell/MultiSelect.vue b/packages/nc-gui-v2/components/cell/MultiSelect.vue index fffc9f347c..12260eb12f 100644 --- a/packages/nc-gui-v2/components/cell/MultiSelect.vue +++ b/packages/nc-gui-v2/components/cell/MultiSelect.vue @@ -14,7 +14,7 @@ const column = inject(ColumnInj) const isForm = inject('isForm', false) const editEnabled = inject(EditModeInj, ref(false)) -const options = computed(() => column?.dtxp?.split(',').map((v) => v.replace(/\\'/g, "'").replace(/^'|'$/g, '')) || []) +const options = computed(() => column?.value?.dtxp?.split(',').map((v) => v.replace(/\\'/g, "'").replace(/^'|'$/g, '')) || []) const localState = computed({ get() { diff --git a/packages/nc-gui-v2/components/cell/Percent.vue b/packages/nc-gui-v2/components/cell/Percent.vue index dde455185c..746e86739c 100644 --- a/packages/nc-gui-v2/components/cell/Percent.vue +++ b/packages/nc-gui-v2/components/cell/Percent.vue @@ -17,7 +17,7 @@ const percent = ref() const isEdited = ref(false) -const percentType = computed(() => column?.meta?.precision || 0) +const percentType = computed(() => column?.value?.meta?.precision || 0) const percentStep = computed(() => getPercentStep(percentType.value)) @@ -27,7 +27,7 @@ const localState = computed({ }, set: (val) => { if (val === null) val = 0 - if (isValidPercent(val, column?.meta?.negative)) { + if (isValidPercent(val, column?.value?.meta?.negative)) { percent.value = val / 100 } }, diff --git a/packages/nc-gui-v2/components/cell/Rating.vue b/packages/nc-gui-v2/components/cell/Rating.vue index 08bce5f227..fe4b782d64 100644 --- a/packages/nc-gui-v2/components/cell/Rating.vue +++ b/packages/nc-gui-v2/components/cell/Rating.vue @@ -26,7 +26,7 @@ const ratingMeta = computed(() => { }, color: '#fcb401', max: 5, - ...(column?.meta || {}), + ...(column?.value?.meta || {}), } }) diff --git a/packages/nc-gui-v2/components/cell/SingleSelect.vue b/packages/nc-gui-v2/components/cell/SingleSelect.vue index 66570ef61c..c63efc7d2d 100644 --- a/packages/nc-gui-v2/components/cell/SingleSelect.vue +++ b/packages/nc-gui-v2/components/cell/SingleSelect.vue @@ -19,7 +19,7 @@ const vModel = computed({ set: (val) => emit('update:modelValue', val), }) -const options = computed(() => column?.dtxp?.split(',').map((v) => v.replace(/\\'/g, "'").replace(/^'|'$/g, '')) || []) +const options = computed(() => column?.value?.dtxp?.split(',').map((v) => v.replace(/\\'/g, "'").replace(/^'|'$/g, '')) || [])