diff --git a/src/components/VnTable/VnColumn.vue b/src/components/VnTable/VnColumn.vue index 6a52e0158..6cd62d83e 100644 --- a/src/components/VnTable/VnColumn.vue +++ b/src/components/VnTable/VnColumn.vue @@ -9,7 +9,7 @@ import VnInput from 'components/common/VnInput.vue'; import VnInputDate from 'components/common/VnInputDate.vue'; import VnComponent from 'components/common/VnComponent.vue'; -const model = defineModel(); +const model = defineModel(undefined, { required: true }); const $props = defineProps({ column: { type: Object, @@ -17,7 +17,7 @@ const $props = defineProps({ }, row: { type: Object, - required: true, + default: () => {}, }, default: { type: [Object, String], diff --git a/src/components/VnTable/VnFilter.vue b/src/components/VnTable/VnFilter.vue index f0892b8bd..3d489cf73 100644 --- a/src/components/VnTable/VnFilter.vue +++ b/src/components/VnTable/VnFilter.vue @@ -27,7 +27,7 @@ const $props = defineProps({ default: 'params', }, }); -const model = defineModel(); +const model = defineModel(undefined, { required: true }); const arrayData = useArrayData($props.dataKey, { searchUrl: $props.searchUrl }); const columnFilter = computed(() => $props.column?.columnFilter); @@ -96,7 +96,7 @@ const components = { forceAttrs, }, }; -console.log(components); + async function addFilter(value) { value ??= undefined; if (value && typeof value === 'object') value = model.value; @@ -111,32 +111,36 @@ async function addFilter(value) { } function alignRow() { - if ($props.column.align == 'left') return 'justify-start items-start'; - if ($props.column.align == 'right') return 'justify-end items-end'; - return 'flex-center'; + switch ($props.column.align) { + case 'left': + return 'justify-start items-start'; + case 'right': + return 'justify-end items-end'; + default: + return 'flex-center'; + } } + +const showFilter = computed( + () => $props.column?.columnFilter !== false && $props.column.name != 'tableActions' +); diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue index 0d725524e..493f1480e 100644 --- a/src/components/VnTable/VnTable.vue +++ b/src/components/VnTable/VnTable.vue @@ -66,7 +66,9 @@ const route = useRoute(); const router = useRouter(); const quasar = useQuasar(); -const mode = ref('card'); +const DEFAULT_MODE = 'card'; +const TABLE_MODE = 'table'; +const mode = ref(DEFAULT_MODE); const selected = ref([]); const routeQuery = JSON.parse(route?.query[$props.searchUrl] ?? '{}'); const params = ref({ ...routeQuery, ...routeQuery.filter?.where }); @@ -77,17 +79,17 @@ const tableModes = [ { icon: 'view_column', title: t('table view'), - value: 'table', + value: TABLE_MODE, }, { icon: 'grid_view', title: t('grid view'), - value: 'card', + value: DEFAULT_MODE, }, ]; onMounted(() => { - mode.value = quasar.platform.is.mobile ? 'card' : $props.defaultMode; + mode.value = quasar.platform.is.mobile ? DEFAULT_MODE : $props.defaultMode; stateStore.rightDrawer = true; setUserParams(route.query[$props.searchUrl]); }); @@ -172,6 +174,9 @@ function columnName(col) { return name; } +function getColAlign(col) { + return 'text-' + (col.align ?? 'left') +} defineExpose({ reload, redirect: redirectFn, @@ -218,7 +223,7 @@ defineExpose({ :limit="20" ref="CrudModelRef" :search-url="searchUrl" - :disable-infinite-scroll="mode == 'table'" + :disable-infinite-scroll="mode == TABLE_MODE" @save-changes="reload" :has-subtoolbar="isEditable" > @@ -229,11 +234,11 @@ defineExpose({ :columns="splittedColumns.columns" :rows="rows" v-model:selected="selected" - :grid="mode != 'table'" + :grid="mode != TABLE_MODE" table-header-class="bg-header" card-container-class="grid-three" flat - :style="mode == 'table' && 'max-height: 90vh'" + :style="mode == TABLE_MODE && 'max-height: 90vh'" virtual-scroll @virtual-scroll=" (event) => @@ -287,7 +292,7 @@ defineExpose({