Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

refactor: remove redundant emit calls in selector components since v-model handles updates

DarkPhoenix2704459c7ecb61c0
diff --git a/packages/nc-gui/components/nc/List/AggregationSelector.vue b/packages/nc-gui/components/nc/List/AggregationSelector.vue
index 116ef2bb70..b182e88b96 100644
--- a/packages/nc-gui/components/nc/List/AggregationSelector.vue
+++ b/packages/nc-gui/components/nc/List/AggregationSelector.vue
@@ -36,7 +36,6 @@ const isOpenAggregationSelectDropdown = ref(false)
const handleValueUpdate = (value: any) => {
const stringValue = String(value)
modelValue.value = stringValue
- emit('update:value', stringValue)
}
const column = ref<ColumnType | null>(null)
@@ -121,9 +120,8 @@ watch(aggregationList, (newAggregationList) => {
// Check if current value exists in the new aggregation list
if (modelValue.value && !newAggregationListMap.has(modelValue.value)) {
- // Current value is not in the list, emit null to clear it
+ // Current value is not in the list, set null to clear it
modelValue.value = undefined
- emit('update:value', undefined)
return
}
@@ -132,7 +130,6 @@ watch(aggregationList, (newAggregationList) => {
const newAggregationValue = newAggregationList[0]?.value
modelValue.value = newAggregationValue
- emit('update:value', newAggregationValue)
}
}
}, { immediate: true })
diff --git a/packages/nc-gui/components/nc/List/ColumnSelector.vue b/packages/nc-gui/components/nc/List/ColumnSelector.vue
index 48b3772e23..bdd520a5e4 100644
--- a/packages/nc-gui/components/nc/List/ColumnSelector.vue
+++ b/packages/nc-gui/components/nc/List/ColumnSelector.vue
@@ -37,7 +37,6 @@ const isOpenColumnSelectDropdown = ref(false)
const handleValueUpdate = (value: any) => {
const stringValue = String(value)
modelValue.value = stringValue
- emit('update:value', stringValue)
}
const columnList = computedAsync(async () => {
@@ -92,9 +91,8 @@ watch(columnList, (newColumnList) => {
// Check if current value exists in the new column list
if (modelValue.value && !newColumnListMap.has(modelValue.value)) {
- // Current value is not in the list, emit null to clear it
+ // Current value is not in the list, set null to clear it
modelValue.value = undefined
- emit('update:value', undefined)
return
}
@@ -108,10 +106,8 @@ watch(columnList, (newColumnList) => {
if (columnObj && columnObj.ncItemDisabled && columnObj.value === newColumnList[0]?.value) {
const selectedValue = newColumnList.find((column) => !column.ncItemDisabled)?.value || newColumnList[0]?.value
modelValue.value = selectedValue
- emit('update:value', selectedValue)
} else {
modelValue.value = newColumnId
- emit('update:value', newColumnId)
}
}
}
diff --git a/packages/nc-gui/components/nc/List/TableSelector.vue b/packages/nc-gui/components/nc/List/TableSelector.vue
index 6b87c238d3..94641fe651 100644
--- a/packages/nc-gui/components/nc/List/TableSelector.vue
+++ b/packages/nc-gui/components/nc/List/TableSelector.vue
@@ -37,7 +37,6 @@ const isOpenTableSelectDropdown = ref(false)
const handleValueUpdate = (value: any) => {
const stringValue = String(value)
modelValue.value = stringValue
- emit('update:value', stringValue)
}
const tableList = computedAsync(async () => {
@@ -85,9 +84,8 @@ watch(tableList, (newTableList) => {
// Check if current value exists in the new table list
if (modelValue.value && !newTableListMap.has(modelValue.value)) {
- // Current value is not in the list, emit null to clear it
+ // Current value is not in the list, set null to clear it
modelValue.value = null
- emit('update:value', null)
return
}
@@ -100,10 +98,8 @@ watch(tableList, (newTableList) => {
if (tableObj && tableObj.ncItemDisabled && tableObj.value === newTableList[0]?.value) {
const selectedValue = newTableList.find((table) => !table.ncItemDisabled)?.value || newTableList[0]?.value
modelValue.value = selectedValue
- emit('update:value', selectedValue)
} else {
modelValue.value = newTableId
- emit('update:value', newTableId)
}
}
}
diff --git a/packages/nc-gui/components/nc/List/ViewSelector.vue b/packages/nc-gui/components/nc/List/ViewSelector.vue
index ad52198593..dd4164d759 100644
--- a/packages/nc-gui/components/nc/List/ViewSelector.vue
+++ b/packages/nc-gui/components/nc/List/ViewSelector.vue
@@ -40,7 +40,6 @@ const isOpenViewSelectDropdown = ref(false)
const handleValueUpdate = (value: any) => {
const stringValue = String(value)
modelValue.value = stringValue
- emit('update:value', stringValue)
}
const viewList = computedAsync(async () => {
@@ -97,9 +96,8 @@ watch(viewList, (newViewList) => {
// Check if current value exists in the new view list
if (modelValue.value && !newViewListMap.has(modelValue.value)) {
- // Current value is not in the list, emit null to clear it
+ // Current value is not in the list, set null to clear it
modelValue.value = undefined
- emit('update:value', undefined)
return
}
@@ -113,10 +111,8 @@ watch(viewList, (newViewList) => {
if (viewObj && viewObj.ncItemDisabled && viewObj.value === newViewList[0]?.value) {
const selectedValue = newViewList.find((view) => !view.ncItemDisabled)?.value || newViewList[0]?.value
modelValue.value = selectedValue
- emit('update:value', selectedValue)
} else {
modelValue.value = newViewId
- emit('update:value', newViewId)
}
}
}