Browse Source

wip(gui-v2): sidebar

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/2716/head
Pranav C 2 years ago
parent
commit
09a920c9ff
  1. 18
      packages/nc-gui-v2/components/smartsheet-toolbar/FieldsMenu.vue
  2. 170
      packages/nc-gui-v2/components/smartsheet/Sidebar.vue
  3. 7
      packages/nc-gui-v2/components/tabs/Smartsheet.vue
  4. 1
      packages/nc-gui-v2/composables/useMeta.ts
  5. 15
      packages/nc-gui-v2/composables/useViews.ts
  6. 2
      packages/nc-gui-v2/pages/nc/[projectId].vue
  7. 2
      packages/nc-gui-v2/utils/viewIcons.ts
  8. 11
      packages/nc-gui-v2/utils/viewUtils.ts

18
packages/nc-gui-v2/components/smartsheet-toolbar/FieldsMenu.vue

@ -303,7 +303,7 @@ export default {
</v-btn>
</v-badge>
</template>
<!--
<v-list dense class="pt-0" min-width="280" @click.stop>
<template v-if="isGallery && _isUIAllowed('updateCoverImage')">
<div class="pa-2">
@ -360,15 +360,15 @@ export default {
hide-details
@click.stop
>
<!-- <template v-slot:prepend-inner>
&lt;!&ndash; <template v-slot:prepend-inner>
<v-icon small color="grey" class="mt-2">
mdi-magnify
</v-icon>
</template> -->
</template> &ndash;&gt;
</v-text-field>
</v-list-item>
<div class="nc-fields-list py-1">
<!-- <Draggable v-model="fields" @start="drag = true" @end="drag = false" @change="onMove($event)"> -->
&lt;!&ndash; <Draggable v-model="fields" @start="drag = true" @end="drag = false" @change="onMove($event)"> &ndash;&gt;
<template v-for="(field, i) in fields">
<v-list-item
v-show="
@ -390,7 +390,7 @@ export default {
<v-icon small color="grey" :class="`align-self-center drag-icon nc-child-draggable-icon-${field}`"> mdi-drag </v-icon>
</v-list-item>
</template>
<!-- </Draggable> -->
&lt;!&ndash; </Draggable> &ndash;&gt;
</div>
<v-divider class="my-2" />
@ -398,7 +398,7 @@ export default {
<v-checkbox v-model="showSystemFieldsLoc" class="mt-0 pt-0" dense hide-details @click.stop>
<template #label>
<span class="caption">
<!-- Show System Fields -->
&lt;!&ndash; Show System Fields &ndash;&gt;
{{ $t('activity.showSystemFields') }}
</span>
</template>
@ -406,15 +406,15 @@ export default {
</v-list-item>
<v-list-item dense class="mt-2 list-btn mb-3">
<v-btn small class="elevation-0 grey&#45;&#45;text" @click.stop="showAll">
<!-- Show All -->
&lt;!&ndash; Show All &ndash;&gt;
{{ $t('general.showAll') }}
</v-btn>
<v-btn small class="elevation-0 grey&#45;&#45;text" @click.stop="hideAll">
<!-- Hide All -->
&lt;!&ndash; Hide All &ndash;&gt;
{{ $t('general.hideAll') }}
</v-btn>
</v-list-item>
</v-list>
</v-list> -->
</v-menu>
<!-- <v-menu offset-y transition="slide-y-transition">
<template #activator="{ on }">

170
packages/nc-gui-v2/components/smartsheet/Sidebar.vue

@ -0,0 +1,170 @@
<script setup lang="ts">
import { inject } from "@vue/runtime-core";
import { TableType } from "nocodb-sdk";
import { onMounted, Ref } from "vue";
import { MetaInj } from "~/components";
import useViews from "~/composables/useViews";
import { viewIcons } from "~/utils/viewUtils";
const meta = inject(MetaInj);
const { views, loadViews } = useViews(meta as Ref<TableType>);
const _isUIAllowed = (view: string) => {
};
onMounted(loadViews);
const selectedViewIdLocal = ref("");
</script>
<template>
<div
class="views-navigation-drawer flex-item-stretch pa-4 elevation-1"
:style="{
maxWidth: toggleDrawer ? '0' : '220px',
minWidth: toggleDrawer ? '0' : '220px',
}"
>
<div class="d-flex flex-column h-100">
<div class="flex-grow-1">
<v-list v-if="views && views.length" dense>
<v-list-item dense>
<!-- Views -->
<span class="body-2 font-weight-medium">{{
$t("objects.views")
}}</span>
</v-list-item>
<v-list-group
v-model="selectedViewIdLocal"
mandatory
color="primary"
>
<!--
todo: add sortable
<draggable
:is="_isUIAllowed('viewlist-drag-n-drop') ? 'draggable' : 'div'"
v-model="viewsList"
draggable="div"
v-bind="dragOptions"
@change="onMove($event)"
>-->
<!-- <transition-group
type="transition"
:name="!drag ? 'flip-list' : null"
>-->
<v-list-item
v-for="(view, i) in views"
:key="view.id"
v-t="['a:view:open', { view: view.type }]"
dense
:value="view.id"
active-class="x-active--text">
<!-- :class="`body-2 view nc-view-item nc-draggable-child nc-${
viewTypeAlias[view.type]
}-view-item`"
@click="$emit('rerender')"-->
<v-icon
v-if="_isUIAllowed('viewlist-drag-n-drop')"
small
:class="`nc-child-draggable-icon nc-child-draggable-icon-${view.title}`"
@click.stop
>
mdi-drag-vertical
</v-icon>
<v-list-item-icon class="mr-n1">
<v-icon
v-if="viewIcons[view.type]"
x-small
:color="viewIcons[view.type].color"
>
{{ viewIcons[view.type].icon }}
</v-icon>
<v-icon v-else color="primary" small>
mdi-table
</v-icon>
</v-list-item-icon>
<v-list-item-title>
<v-tooltip bottom>
<template #activator="{ on }">
<div
class="font-weight-regular"
style="overflow: hidden; text-overflow: ellipsis"
>
<input
v-if="view.edit"
:ref="`input${i}`"
v-model="view.title_temp">
<!-- @click.stop
@keydown.enter.stop="updateViewName(view, i)"
@blur="updateViewName(view, i)"-->
<template v-else>
<span v-on="on">{{
view.alias || view.title
}}</span>
</template>
</div>
</template>
{{ view.alias || view.title }}
</v-tooltip>
</v-list-item-title>
<v-spacer />
<template v-if="_isUIAllowed('virtualViewsCreateOrEdit')">
<!-- Copy view -->
<x-icon
v-if="!view.edit"
:tooltip="$t('activity.copyView')"
x-small
color="primary"
icon-class="view-icon nc-view-copy-icon"
@click.stop="copyView(view, i)"
>
mdi-content-copy
</x-icon>
<!-- Rename view -->
<x-icon
v-if="!view.edit"
:tooltip="$t('activity.renameView')"
x-small
color="primary"
icon-class="view-icon nc-view-edit-icon"
@click.stop="showRenameTextBox(view, i)"
>
mdi-pencil
</x-icon>
<!-- Delete view" -->
<x-icon
v-if="!view.is_default"
:tooltip="$t('activity.deleteView')"
small
color="error"
icon-class="view-icon nc-view-delete-icon"
@click.stop="deleteView(view)"
>
mdi-delete-outline
</x-icon>
</template>
<v-icon
v-if="view.id === selectedViewId"
small
class="check-icon"
>
mdi-check-bold
</v-icon>
</v-list-item>
</transition-group>
</draggable>
</v-list-group>
</v-list>
</div>
</div>
</div>
</template>
<style scoped></style>

7
packages/nc-gui-v2/components/tabs/Smartsheet.vue

@ -30,7 +30,12 @@ watch(
<div class="overflow-auto">
<SmartsheetToolbar />
<template v-if="meta && tabMeta">
<SmartsheetGrid />
<div class="d-flex">
<div class="flex-grow-1" style="min-width: 0">
<SmartsheetGrid />
</div>
<SmartsheetSidebar />
</div>
</template>
</div>
</template>

1
packages/nc-gui-v2/composables/useMeta.ts

@ -1,4 +1,3 @@
import { TableType } from 'nocodb-sdk'
import useMetas from '~/composables/useMetas'
export default function (metaIdOrTitle: string) {

15
packages/nc-gui-v2/composables/useViews.ts

@ -0,0 +1,15 @@
import { useNuxtApp } from "#app";
import { TableType } from "nocodb-sdk";
import { Ref } from "vue";
export default function(meta: Ref<TableType>) {
const views = ref();
const { $api } = useNuxtApp();
const loadViews = async () => {
if (meta.value?.id)
views.value = (await $api.dbView.list(meta.value?.id)).list;
};
return { views, loadViews };
}

2
packages/nc-gui-v2/pages/nc/[projectId].vue

@ -34,7 +34,7 @@ watch(
</v-navigation-drawer>
</template>
<v-container>
<v-container fluid>
<DashboardTabView />
</v-container>
</NuxtLayout>

2
packages/nc-gui/helpers/viewIcons.js → packages/nc-gui-v2/utils/viewIcons.ts

@ -1,6 +1,6 @@
import { ViewTypes } from 'nocodb-sdk'
export default {
export const viewIcons = {
[ViewTypes.GRID]: { icon: 'mdi-grid-large', color: 'blue' },
// [ViewTypes.GRID]: { icon: "mdi-grid-large", color: "blue" },
[ViewTypes.FORM]: { icon: 'mdi-form-select', color: 'pink' },

11
packages/nc-gui-v2/utils/viewUtils.ts

@ -0,0 +1,11 @@
import { ViewTypes } from 'nocodb-sdk'
export const viewIcons = {
[ViewTypes.GRID]: { icon: 'mdi-grid-large', color: 'blue' },
// [ViewTypes.GRID]: { icon: "mdi-grid-large", color: "blue" },
[ViewTypes.FORM]: { icon: 'mdi-form-select', color: 'pink' },
calendar: { icon: 'mdi-calendar', color: 'purple' },
[ViewTypes.GALLERY]: { icon: 'mdi-camera-image', color: 'orange' },
[ViewTypes.KANBAN]: { icon: 'mdi-tablet-dashboard', color: 'green' },
view: { icon: 'mdi-eye-circle-outline', color: 'blue' }
}
Loading…
Cancel
Save