Browse Source

refactor(nc-gui): rename Uncategorized to uncategorized

pull/3818/head
Wing-Kam Wong 2 years ago
parent
commit
8a53ec45a5
  1. 21
      packages/nc-gui/components/smartsheet/Kanban.vue
  2. 20
      packages/nc-gui/composables/useKanbanViewData.ts

21
packages/nc-gui/components/smartsheet/Kanban.vue

@ -97,7 +97,7 @@ const expandFormClick = async (e: MouseEvent, row: RowType) => {
}
}
/** Block dragging the stack to first index (reserved for Uncategorized) **/
/** Block dragging the stack to first index (reserved for uncategorized) **/
function onMoveCallback(event: any) {
if (event.draggedContext.futureIndex === 0) {
return false
@ -121,7 +121,7 @@ async function onMoveStack(event: any) {
async function onMove(event: any, stackKey: string) {
if (event.added) {
const ele = event.added.element
ele.row[groupingField.value] = stackKey === 'Uncategorized' ? null : stackKey
ele.row[groupingField.value] = stackKey === 'uncategorized' ? null : stackKey
countByStack.value[stackKey] += 1
await updateOrSaveRow(ele)
} else if (event.removed) {
@ -162,9 +162,9 @@ const handleCollapseStack = async (stackIdx: number) => {
const handleExpandedFormCancel = () => {
// remove the empty record
formattedData.value.Uncategorized.pop()
formattedData.value.uncategorized.pop()
// decrease total count by 1
countByStack.value.Uncategorized -= 1
countByStack.value.uncategorized -= 1
}
openNewRecordFormHook?.on(async (stackTitle) => {
@ -174,7 +174,7 @@ openNewRecordFormHook?.on(async (stackTitle) => {
[groupingField.value]: stackTitle,
}
// increase total count by 1
countByStack.value.Uncategorized += 1
countByStack.value.uncategorized += 1
// open the expanded form
expandForm(newRow)
})
@ -215,7 +215,10 @@ onMounted(() => {
<a-layout-header>
<div class="nc-kanban-stack-head font-bold flex items-center px-[15px]">
<a-dropdown :trigger="['click']" overlay-class-name="nc-dropdown-kanban-stack-context-menu">
<div class="flex items-center cursor-pointer w-full">
<div
class="flex items-center cursor-pointer w-full"
:class="{ capitalize: stack.title === 'uncategorized' }"
>
<GeneralTruncateText>{{ stack.title }}</GeneralTruncateText>
<span class="w-full flex">
<mdi-menu-down class="text-grey text-lg ml-auto" />
@ -224,7 +227,7 @@ onMounted(() => {
<template #overlay>
<a-menu class="ml-6 !text-sm !px-0 !py-2 !rounded">
<a-menu-item
@click="openNewRecordFormHook.trigger(stack.title === 'Uncategorized' ? null : stack.title)"
@click="openNewRecordFormHook.trigger(stack.title === 'uncategorized' ? null : stack.title)"
>
<div class="py-2 flex gap-2 items-center">
<mdi-plus class="text-gray-500" />
@ -239,7 +242,7 @@ onMounted(() => {
Collapse Stack
</div>
</a-menu-item>
<a-menu-item v-if="stack.title !== 'Uncategorized'" @click="handleDeleteStackClick(stack.title)">
<a-menu-item v-if="stack.title !== 'uncategorized'" @click="handleDeleteStackClick(stack.title)">
<div class="py-2 flex gap-2 items-center">
<mdi-delete class="text-gray-500" />
<!-- TODO: i18n -->
@ -313,7 +316,7 @@ onMounted(() => {
<div v-if="formattedData[stack.title] && countByStack[stack.title] >= 0" class="mt-5 text-center">
<mdi-plus
class="text-pint-500 text-lg text-primary cursor-pointer"
@click="openNewRecordFormHook.trigger(stack.title === 'Uncategorized' ? null : stack.title)"
@click="openNewRecordFormHook.trigger(stack.title === 'uncategorized' ? null : stack.title)"
/>
<div class="nc-kanban-data-count">
{{ formattedData[stack.title].length }} / {{ countByStack[stack.title] }}

20
packages/nc-gui/composables/useKanbanViewData.ts

@ -47,7 +47,7 @@ export function useKanbanViewData(
// countByStack structure
// {
// "Uncategorized": 0,
// "uncategorized": 0,
// [val1]: 10,
// [val2]: 20
// }
@ -79,7 +79,7 @@ export function useKanbanViewData(
await Promise.all(
groupingFieldColOptions.value.map(async (option: GroupingFieldColOptionsType) => {
const where =
option.title === 'Uncategorized' ? `(${groupingField.value},is,null)` : `(${groupingField.value},eq,${option.title})`
option.title === 'uncategorized' ? `(${groupingField.value},is,null)` : `(${groupingField.value},eq,${option.title})`
const response = await api.dbViewRow.list('noco', project.value.id!, meta.value!.id!, viewMeta.value!.id!, {
where,
})
@ -93,7 +93,7 @@ export function useKanbanViewData(
async function loadMoreKanbanData(stackTitle: string, params: Parameters<Api<any>['dbViewRow']['list']>[4] = {}) {
if ((!project?.value?.id || !meta.value?.id || !viewMeta.value?.id) && !isPublic.value) return
let where = `(${groupingField.value},eq,${stackTitle})`
if (stackTitle === 'Uncategorized') {
if (stackTitle === 'uncategorized') {
where = `(${groupingField.value},is,null)`
}
const response = await api.dbViewRow.list('noco', project.value.id!, meta.value!.id!, viewMeta.value!.id!, {
@ -166,7 +166,7 @@ export function useKanbanViewData(
groupingFieldColOptions.value = [
...((groupingFieldColumn.value?.colOptions as SelectOptionsType & { collapsed: boolean })?.options ?? []),
// enrich uncategorized stack
{ id: 'uncategorized', title: 'Uncategorized', order: 0, color: enumColor.light[2] },
{ id: 'uncategorized', title: 'uncategorized', order: 0, color: enumColor.light[2] },
]
// sort by initial order
.sort((a, b) => a.order! - b.order!)
@ -297,9 +297,9 @@ export function useKanbanViewData(
[groupingField.value]: null,
},
}))
// merge the 'deleted' stack to Uncategorized stack
formattedData.value.Uncategorized = [...formattedData.value.Uncategorized, ...formattedData.value[stackTitle]]
countByStack.value.Uncategorized += countByStack.value[stackTitle]
// merge the 'deleted' stack to uncategorized stack
formattedData.value.uncategorized = [...formattedData.value.uncategorized, ...formattedData.value[stackTitle]]
countByStack.value.uncategorized += countByStack.value[stackTitle]
// clear the 'deleted' stack
formattedData.value[stackTitle] = []
countByStack.value[stackTitle] = 0
@ -308,13 +308,13 @@ export function useKanbanViewData(
}
}
function addEmptyRow(addAfter = formattedData.value.Uncategorized?.length) {
formattedData.value.Uncategorized.splice(addAfter, 0, {
function addEmptyRow(addAfter = formattedData.value.uncategorized?.length) {
formattedData.value.uncategorized.splice(addAfter, 0, {
row: {},
oldRow: {},
rowMeta: { new: true },
})
return formattedData.value.Uncategorized[addAfter]
return formattedData.value.uncategorized[addAfter]
}
return {

Loading…
Cancel
Save