Browse Source

feat(gui-v2): add addAllColumns & removeAllColumns

pull/3030/head
Wing-Kam Wong 2 years ago
parent
commit
8beed14956
  1. 34
      packages/nc-gui-v2/components/smartsheet/Form.vue

34
packages/nc-gui-v2/components/smartsheet/Form.vue

@ -116,14 +116,14 @@ function onMove(event: any) {
element.show = false element.show = false
saveOrUpdate(element, oldIndex) saveOrUpdate(element, oldIndex)
} else { } else {
if (!columns.value.length || columns.value.length === 1) { if (!localColumns.value.length || localColumns.value.length === 1) {
element.order = 1 element.order = 1
} else if (columns.value.length - 1 === newIndex) { } else if (localColumns.value.length - 1 === newIndex) {
element.order = (columns.value[newIndex - 1]?.order || 0) + 1 element.order = (localColumns.value[newIndex - 1]?.order || 0) + 1
} else if (newIndex === 0) { } else if (newIndex === 0) {
element.order = (columns.value[1]?.order || 0) / 2 element.order = (localColumns.value[1]?.order || 0) / 2
} else { } else {
element.order = (columns.value[newIndex - 1]?.order || 0) + (columns.value[newIndex + 1].order || 0) / 2 element.order = (localColumns.value[newIndex - 1]?.order || 0) + (localColumns.value[newIndex + 1].order || 0) / 2
} }
saveOrUpdate(element, newIndex) saveOrUpdate(element, newIndex)
} }
@ -149,9 +149,27 @@ function hideColumn(idx: number) {
$e('a:form-view:hide-columns') $e('a:form-view:hide-columns')
} }
async function addAllColumns() {} async function addAllColumns() {
for (const col of (formColumnData as Record<string, any>)?.value) {
if (!systemFieldsIds.value.includes(col.fk_column_id)) {
console.log(col)
col.show = true
}
}
await showAll(systemFieldsIds.value)
$e('a:form-view:add-all')
}
async function removeAllColumns() {} async function removeAllColumns() {
for (const col of (formColumnData as Record<string, any>)?.value) {
if (isDbRequired(col)) {
continue
}
col.show = false
}
await hideAll((localColumns as Record<string, any>)?.value.filter(isDbRequired).map((f: Record<string, any>) => f.fk_column_id))
$e('a:form-view:remove-all')
}
async function checkSMTPStatus() {} async function checkSMTPStatus() {}
@ -211,7 +229,7 @@ watch(
v-if="hiddenColumns.length" v-if="hiddenColumns.length"
class="mr-2" class="mr-2"
style="border-bottom: 2px solid rgb(218, 218, 218)" style="border-bottom: 2px solid rgb(218, 218, 218)"
@click="addAllColumns()" @click="addAllColumns"
> >
<!-- Add all --> <!-- Add all -->
{{ $t('general.addAll') }} {{ $t('general.addAll') }}

Loading…
Cancel
Save