Skip to content

Commit

Permalink
Merge pull request #7007 from nocodb/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Nov 16, 2023
2 parents 258c6e9 + 8fbb468 commit 39fde48
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 18 deletions.
39 changes: 29 additions & 10 deletions packages/nc-gui/components/smartsheet/column/SelectOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const { optionsMagic: _optionsMagic } = useNocoEe()
const optionsWrapperDomRef = ref<HTMLElement>()
const options = ref<(Option & { status?: 'remove' })[]>([])
const options = ref<(Option & { status?: 'remove'; index?: number })[]>([])
const isAddingOption = ref(false)
Expand All @@ -38,7 +38,7 @@ const OPTIONS_PAGE_COUNT = 20
const loadedOptionAnchor = ref(OPTIONS_PAGE_COUNT)
const isReverseLazyLoad = ref(false)
const renderedOptions = ref<(Option & { status?: 'remove' })[]>([])
const renderedOptions = ref<(Option & { status?: 'remove'; index?: number })[]>([])
const savedDefaultOption = ref<Option | null>(null)
const savedCdf = ref<string | null>(null)
Expand Down Expand Up @@ -98,6 +98,12 @@ onMounted(() => {
options.value = vModel.value.colOptions.options
let indexCounter = 0
options.value.map((el) => {
el.index = indexCounter++
return el
})
loadedOptionAnchor.value = Math.min(loadedOptionAnchor.value, options.value.length)
renderedOptions.value = [...options.value].slice(0, loadedOptionAnchor.value)
Expand Down Expand Up @@ -135,6 +141,7 @@ const addNewOption = () => {
const tempOption = {
title: '',
color: getNextColor(),
index: options.value.length,
}
options.value.push(tempOption)
Expand Down Expand Up @@ -168,20 +175,29 @@ const addNewOption = () => {
// }
const syncOptions = () => {
vModel.value.colOptions.options = options.value.filter((op) => op.status !== 'remove')
vModel.value.colOptions.options = options.value
.filter((op) => op.status !== 'remove')
.sort((a, b) => {
const renderA = renderedOptions.value.findIndex((el) => a.index !== undefined && el.index === a.index)
const renderB = renderedOptions.value.findIndex((el) => a.index !== undefined && el.index === b.index)
if (renderA === -1 || renderB === -1) return 0
return renderA - renderB
})
.map((op) => {
const { index: _i, status: _s, ...rest } = op
return rest
})
}
const removeRenderedOption = (index: number) => {
const renderedOption = renderedOptions.value[index]
const option = options.value[loadedOptionAnchor.value + index]
renderedOption.status = 'remove'
option.status = 'remove'
if (renderedOption.index === undefined || isNaN(renderedOption.index)) return
const option = options.value[renderedOption.index]
renderedOption.status = 'remove'
if (option) {
option.status = 'remove'
}
option.status = 'remove'
syncOptions()
Expand All @@ -204,7 +220,10 @@ const optionChanged = (changedId: string) => {
const undoRemoveRenderedOption = (index: number) => {
const renderedOption = renderedOptions.value[index]
const option = options.value[loadedOptionAnchor.value + index]
if (renderedOption.index === undefined || isNaN(renderedOption.index)) return
const option = options.value[renderedOption.index]
renderedOption.status = undefined
option.status = undefined
Expand Down
2 changes: 1 addition & 1 deletion packages/nc-gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"locale-codes": "^1.3.1",
"monaco-editor": "^0.33.0",
"monaco-sql-languages": "^0.11.0",
"nocodb-sdk": "0.202.6",
"nocodb-sdk": "workspace:^",
"papaparse": "^5.3.2",
"parse-github-url": "^1.0.2",
"pinia": "^2.1.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/nocodb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
"ncp": "^2.0.0",
"nestjs-kafka": "^1.0.6",
"nestjs-throttler-storage-redis": "^0.3.0",
"nocodb-sdk": "0.202.6",
"nocodb-sdk": "workspace:^",
"nodemailer": "^6.4.10",
"object-hash": "^3.0.0",
"object-sizeof": "^2.6.1",
Expand Down Expand Up @@ -228,4 +228,4 @@
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
}
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 39fde48

Please sign in to comment.