Skip to content

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

fix(nc-gui): add copy from another view option in sort menu

Ramesh Mane070c005fae9d
diff --git a/packages/nc-gui/components/smartsheet/toolbar/GroupByMenu.vue b/packages/nc-gui/components/smartsheet/toolbar/GroupByMenu.vue
index a7909a78d3..f5a2a600aa 100644
--- a/packages/nc-gui/components/smartsheet/toolbar/GroupByMenu.vue
+++ b/packages/nc-gui/components/smartsheet/toolbar/GroupByMenu.vue
@@ -388,6 +388,16 @@ const getFieldsToGroupBy = (currentGroup: Group) => {
}"
@on-open="open = false"
/>
+ <div
+ v-else-if="view && !_groupBy.length"
+ class="flex items-center justify-end empty:hidden pl-3 pr-2 py-1.5 border-t-1 border-nc-border-gray-medium"
+ >
+ <LazyGeneralCopyFromAnotherViewActionBtn
+ :view="view"
+ :default-options="[ViewSettingOverrideOptions.GROUP]"
+ @open="open = false"
+ />
+ </div>
</div>
</template>
</NcDropdown>
diff --git a/packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue b/packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue
index c9e8ed00e5..5dbceb6fe8 100644
--- a/packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue
+++ b/packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue
@@ -223,57 +223,63 @@ onMounted(() => {
</div>
</div>
- <NcDropdown
- v-if="availableColumns.length"
- v-model:visible="showCreateSort"
- :trigger="['click']"
- :disabled="isLocked"
- overlay-class-name="nc-toolbar-dropdown"
- >
- <template v-if="isEeUI && !isPublic">
- <NcButton
- v-if="sorts.length < getPlanLimit(PlanLimitTypes.LIMIT_SORT_PER_VIEW)"
- v-e="['c:sort:add']"
- class="mt-1 mb-2"
- :class="{
- '!text-brand-500': !isLocked,
- }"
- type="text"
- size="small"
- :disabled="isLocked"
- @click.stop="showCreateSort = true"
- >
- <div class="flex gap-1 items-center">
- <component :is="iconMap.plus" />
- <!-- Add Sort Option -->
- {{ $t('activity.addSort') }}
- </div>
- </NcButton>
- <span v-else></span>
- </template>
- <template v-else>
- <NcButton
- v-e="['c:sort:add']"
- class="mt-1 mb-2"
- :class="{
- '!text-brand-500': !isLocked,
- }"
- type="text"
- size="small"
- :disabled="isLocked"
- @click.stop="showCreateSort = true"
- >
- <div class="flex gap-1 items-center">
- <component :is="iconMap.plus" />
- <!-- Add Sort Option -->
- {{ $t('activity.addSort') }}
- </div>
- </NcButton>
- </template>
- <template #overlay>
- <SmartsheetToolbarCreateSort :is-parent-open="showCreateSort" @created="addSort" />
- </template>
- </NcDropdown>
+ <div class="flex items-center justify-between children:flex-none empty:hidden pr-4 mt-1 mb-2">
+ <NcDropdown
+ v-if="availableColumns.length"
+ v-model:visible="showCreateSort"
+ :trigger="['click']"
+ :disabled="isLocked"
+ overlay-class-name="nc-toolbar-dropdown"
+ >
+ <template v-if="isEeUI && !isPublic">
+ <NcButton
+ v-if="sorts.length < getPlanLimit(PlanLimitTypes.LIMIT_SORT_PER_VIEW)"
+ v-e="['c:sort:add']"
+ :class="{
+ '!text-brand-500': !isLocked,
+ }"
+ type="text"
+ size="small"
+ :disabled="isLocked"
+ @click.stop="showCreateSort = true"
+ >
+ <div class="flex gap-1 items-center">
+ <component :is="iconMap.plus" />
+ <!-- Add Sort Option -->
+ {{ $t('activity.addSort') }}
+ </div>
+ </NcButton>
+ <span v-else></span>
+ </template>
+ <template v-else>
+ <NcButton
+ v-e="['c:sort:add']"
+ :class="{
+ '!text-brand-500': !isLocked,
+ }"
+ type="text"
+ size="small"
+ :disabled="isLocked"
+ @click.stop="showCreateSort = true"
+ >
+ <div class="flex gap-1 items-center">
+ <component :is="iconMap.plus" />
+ <!-- Add Sort Option -->
+ {{ $t('activity.addSort') }}
+ </div>
+ </NcButton>
+ </template>
+ <template #overlay>
+ <SmartsheetToolbarCreateSort :is-parent-open="showCreateSort" @created="addSort" />
+ </template>
+ </NcDropdown>
+ <LazyGeneralCopyFromAnotherViewActionBtn
+ v-if="view"
+ :view="view"
+ :default-options="[ViewSettingOverrideOptions.SORT]"
+ @open="open = false"
+ />
+ </div>
</div>
<GeneralLockedViewFooter
v-if="isLocked"
@@ -282,6 +288,16 @@ onMounted(() => {
}"
@on-open="open = false"
/>
+ <div
+ v-else-if="view && !sorts.length"
+ class="flex items-center justify-end empty:hidden pl-3 pr-2 py-1.5 border-t-1 border-nc-border-gray-medium"
+ >
+ <LazyGeneralCopyFromAnotherViewActionBtn
+ :view="view"
+ :default-options="[ViewSettingOverrideOptions.SORT]"
+ @open="open = false"
+ />
+ </div>
</div>
</template>
</NcDropdown>
diff --git a/packages/nc-gui/store/views.ts b/packages/nc-gui/store/views.ts
index 8a3082401a..7bb581088d 100644
--- a/packages/nc-gui/store/views.ts
+++ b/packages/nc-gui/store/views.ts
@@ -848,11 +848,11 @@ export const useViewsStore = defineStore('viewsStore', () => {
}
const onOpenCopyViewConfigFromAnotherViewModal = ({
- defaultSelectedCopyViewConfigTypes,
+ defaultOptions,
destView = activeView.value,
onCopy = (_: ViewSettingOverrideOptions[]) => undefined,
}: {
- defaultSelectedCopyViewConfigTypes?: ViewSettingOverrideOptions[]
+ defaultOptions?: ViewSettingOverrideOptions[]
destView?: ViewType
onCopy?: (selectedCopyViewConfigTypes: ViewSettingOverrideOptions[]) => void
} = {}) => {
@@ -869,7 +869,7 @@ export const useViewsStore = defineStore('viewsStore', () => {
'modelValue': isOpen,
'onUpdate:modelValue': closeDialog,
'destView': destView,
- 'defaultSelectedCopyViewConfigTypes': defaultSelectedCopyViewConfigTypes,
+ 'defaultSelectedCopyViewConfigTypes': defaultOptions,
'onCopy': onCopy,
})