Browse Source

Merge pull request #7837 from nocodb/nc-fix/7808-column-reorder

Nc fix/7808 column reorder
pull/6831/head
Ramesh Mane 9 months ago committed by GitHub
parent
commit
540f8187f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 92
      packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue
  2. 4
      packages/nocodb/src/controllers/view-columns.controller.ts

92
packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue

@ -83,58 +83,62 @@ const gridDisplayValueField = computed(() => {
})
const onMove = async (_event: { moved: { newIndex: number; oldIndex: number } }, undo = false) => {
// todo : sync with server
if (!fields.value) return
try {
// todo : sync with server
if (!fields.value) return
if (!undo) {
addUndo({
undo: {
fn: () => {
if (!fields.value) return
const temp = fields.value[_event.moved.newIndex]
fields.value[_event.moved.newIndex] = fields.value[_event.moved.oldIndex]
fields.value[_event.moved.oldIndex] = temp
onMove(
{
moved: {
newIndex: _event.moved.oldIndex,
oldIndex: _event.moved.newIndex,
if (!undo) {
addUndo({
undo: {
fn: () => {
if (!fields.value) return
const temp = fields.value[_event.moved.newIndex]
fields.value[_event.moved.newIndex] = fields.value[_event.moved.oldIndex]
fields.value[_event.moved.oldIndex] = temp
onMove(
{
moved: {
newIndex: _event.moved.oldIndex,
oldIndex: _event.moved.newIndex,
},
},
},
true,
)
true,
)
},
args: [],
},
args: [],
},
redo: {
fn: () => {
if (!fields.value) return
const temp = fields.value[_event.moved.oldIndex]
fields.value[_event.moved.oldIndex] = fields.value[_event.moved.newIndex]
fields.value[_event.moved.newIndex] = temp
onMove(_event, true)
redo: {
fn: () => {
if (!fields.value) return
const temp = fields.value[_event.moved.oldIndex]
fields.value[_event.moved.oldIndex] = fields.value[_event.moved.newIndex]
fields.value[_event.moved.newIndex] = temp
onMove(_event, true)
},
args: [],
},
args: [],
},
scope: defineViewScope({ view: activeView.value }),
})
}
scope: defineViewScope({ view: activeView.value }),
})
}
if (fields.value.length < 2) return
if (fields.value.length < 2) return
await Promise.all(
fields.value.map(async (field, index) => {
if (field.order !== index + 1) {
field.order = index + 1
await saveOrUpdate(field, index, true)
}
}),
)
await Promise.all(
fields.value.map(async (field, index) => {
if (field.order !== index + 1) {
field.order = index + 1
await saveOrUpdate(field, index, true)
}
}),
)
await loadViewColumns()
reloadViewDataHook?.trigger()
await loadViewColumns()
reloadViewDataHook?.trigger()
$e('a:fields:reorder')
$e('a:fields:reorder')
} catch (e) {
message.error(await extractSdkResponseErrorMsg(e))
}
}
const coverOptions = computed<SelectProps['options']>(() => {

4
packages/nocodb/src/controllers/view-columns.controller.ts

@ -58,8 +58,8 @@ export class ViewColumnsController {
'/api/v1/db/meta/views/:viewId/columns/:columnId',
'/api/v2/meta/views/:viewId/columns/:columnId',
])
@Acl('columnUpdate')
async columnUpdate(
@Acl('viewColumnUpdate')
async viewColumnUpdate(
@Param('viewId') viewId: string,
@Param('columnId') columnId: string,
@Body() body: ViewColumnReqType,

Loading…
Cancel
Save