Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📱 make Tables responsive #104

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ declare module 'vue' {
NDataTable: typeof import('naive-ui')['NDataTable']
NDialogProvider: typeof import('naive-ui')['NDialogProvider']
NDropdown: typeof import('naive-ui')['NDropdown']
NForm: typeof import('naive-ui')['NForm']
NFormItem: typeof import('naive-ui')['NFormItem']
NIcon: typeof import('naive-ui')['NIcon']
NInput: typeof import('naive-ui')['NInput']
NLayout: typeof import('naive-ui')['NLayout']
Expand Down
7 changes: 3 additions & 4 deletions src/components/Brand/BrandManagement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import { useDialog, useMessage } from 'naive-ui'

const { t } = useI18n()
const store = useBrandStore()
const { brands, isLoading } = storeToRefs(store)
const dialog = useDialog()
const message = useMessage()
onMounted(getItems)
const columns: DataTableColumns<RowData> = [
{
title: 'Brand',
key: 'name',
fixed: 'left',
},
{
title: 'Slog',
Expand Down Expand Up @@ -110,9 +110,8 @@ function createBrand() {
</NButton>
</n-space>
<n-data-table
remote :columns="columns" :data="brands" :loading="isLoading" :pagination="options"
:row-key="rowKey" @update:filters="handleFiltersChange"
@update:page="handlePageChange"
remote :columns="columns" :data="store.brands" :loading="store.isLoading" :pagination="options"
:row-key="rowKey" :scroll-x="1000" @update:filters="handleFiltersChange" @update:page="handlePageChange"
/>
</n-layout-content>

Expand Down
7 changes: 3 additions & 4 deletions src/components/Category/CategoryManagement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import { useDialog, useMessage } from 'naive-ui'
const { t } = useI18n()
const collapsed = ref(false)
const store = useCategoryStore()
const { categories, isLoading } = storeToRefs(store)
const dialog = useDialog()
const message = useMessage()
onMounted(getItems)
const columns: DataTableColumns<RowData> = [
{
title: 'Category',
key: 'name',
fixed: 'left',
},
{
title: 'Products Count',
Expand Down Expand Up @@ -117,9 +117,8 @@ function createCategory() {
</NButton>
</n-space>
<n-data-table
remote :columns="columns" :data="categories" :loading="isLoading" :pagination="options"
selectable
:row-key="rowKey" @update:sorter="handleSorterChange" @update:filters="handleFiltersChange"
remote :columns="columns" :data="store.categories" :loading="store.isLoading" :pagination="options" selectable
:scroll-x="1000" :row-key="rowKey" @update:sorter="handleSorterChange" @update:filters="handleFiltersChange"
@update:page="handlePageChange"
/>
</div>
Expand Down
7 changes: 3 additions & 4 deletions src/components/Color/ColorManagement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { useDialog, useMessage } from 'naive-ui'

const { t } = useI18n()
const store = useColorStore()
const { colors, isLoading } = storeToRefs(store)
const dialog = useDialog()
const message = useMessage()
onMounted(getItems)
Expand All @@ -20,6 +19,7 @@ const columns: DataTableColumns<RowData> = [
title: 'Color',
key: 'color',
width: 250,
fixed: 'left',
render(row) {
return h(
'span',
Expand Down Expand Up @@ -121,9 +121,8 @@ function createColor() {
</NButton>
</n-space>
<n-data-table
remote :columns="columns" :data="colors" :loading="isLoading" :pagination="options"
:row-key="rowKey" @update:filters="handleFiltersChange"
@update:page="handlePageChange"
remote :columns="columns" :data="store.colors" :loading="store.isLoading" :pagination="options"
:row-key="rowKey" :scroll-x="1000" @update:filters="handleFiltersChange" @update:page="handlePageChange"
/>
</div>
</n-layout-content>
Expand Down
10 changes: 5 additions & 5 deletions src/components/Customers/CustomerManagement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

const { t } = useI18n()
const store = useCustomerStore()
const { customers, isLoading } = storeToRefs(store)
const dialog = useDialog()
const message = useMessage()
const router = useRouter()
Expand All @@ -23,6 +22,7 @@
const columns: DataTableColumns<RowData> = [
{
type: 'selection',
fixed: 'left',
},
{
title: 'NAME',
Expand Down Expand Up @@ -104,14 +104,14 @@
return () => h(NIcon, null, { default: () => h(icon) })
}

function handleDeleteItem(row: RowData) {

Check warning on line 107 in src/components/Customers/CustomerManagement.vue

View workflow job for this annotation

GitHub Actions / lint

'row' is defined but never used. Allowed unused args must match /^_/u
dialog.error({
title: 'Confirm',
content: 'Are you sure?',
positiveText: 'Yes, Delete',
negativeText: 'Cancel',
onPositiveClick: () => {
store.deleteProduct(row.id)
// store.deleteProduct(row.id)
message.success('Product was deleted!')
},
})
Expand Down Expand Up @@ -154,9 +154,9 @@
</NButton>
</NSpace>
<n-data-table
remote :columns="columns" :data="customers" :loading="isLoading" :pagination="options"
selectable :row-key="rowKey" @update:sorter="handleSorterChange" @update:filters="handleFiltersChange"
@update:page="handlePageChange"
remote :columns="columns" :data="store.customers" :loading="store.isLoading" :pagination="options"
selectable :row-key="rowKey" :scroll-x="1000" @update:sorter="handleSorterChange"
@update:filters="handleFiltersChange" @update:page="handlePageChange"
/>
</div>
</n-layout-content>
Expand Down
9 changes: 4 additions & 5 deletions src/components/Orders/OrderManagement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

const { t } = useI18n()
const store = useOrderStore()
const { orders, isLoading } = storeToRefs(store)
const dialog = useDialog()
const message = useMessage()
const router = useRouter()
Expand All @@ -23,7 +22,7 @@
{
title: 'Customer',
key: 'customer',

fixed: 'left',
},
{
title: 'Date',
Expand Down Expand Up @@ -102,14 +101,14 @@
}
}

function handleDeleteItem(row: RowData) {

Check warning on line 104 in src/components/Orders/OrderManagement.vue

View workflow job for this annotation

GitHub Actions / lint

'row' is defined but never used. Allowed unused args must match /^_/u
dialog.error({
title: 'Confirm',
content: 'Are you sure?',
positiveText: 'Yes, Delete',
negativeText: 'Cancel',
onPositiveClick: () => {
store.deleteProduct(row.id)
// store.deleteProduct(row.id)
message.success('Product was deleted!')
},
})
Expand Down Expand Up @@ -152,8 +151,8 @@
</NButton>
</NSpace>
<n-data-table
:columns="columns" :data="orders" :loading="isLoading" :pagination="options"
:row-key="rowKey" @update:sorter="handleSorterChange" @update:filters="handleFiltersChange"
:columns="columns" :data="store.orders" :loading="store.isLoading" :pagination="options" :row-key="rowKey"
:scroll-x="1000" @update:sorter="handleSorterChange" @update:filters="handleFiltersChange"
@update:page="handlePageChange"
/>
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/components/Products/ProductsManagement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { ProductStatus } from '~/models/Product'

const { t } = useI18n()
const store = useProductStore()
const { products, isLoading } = storeToRefs(store)
const dialog = useDialog()
const message = useMessage()
const router = useRouter()
Expand All @@ -21,6 +20,7 @@ onMounted(getItems)
const columns: DataTableColumns<RowData> = [
{
type: 'selection',
fixed: 'left',
},
{
title: 'PRODUCT',
Expand Down Expand Up @@ -157,9 +157,9 @@ function handleFiltersChange() {
</NButton>
</NSpace>
<n-data-table
remote :columns="columns" :data="products" :loading="isLoading" :pagination="options" selectable
:row-key="rowKey" @update:sorter="handleSorterChange" @update:filters="handleFiltersChange"
@update:page="handlePageChange"
remote :columns="columns" :data="store.products" :loading="store.isLoading" :pagination="options" selectable
:row-key="rowKey" :scroll-x="1000" @update:sorter="handleSorterChange"
@update:filters="handleFiltersChange" @update:page="handlePageChange"
/>
</div>
</n-layout-content>
Expand Down
10 changes: 5 additions & 5 deletions src/components/Review/ReviewManagement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import { useDialog, useMessage } from 'naive-ui'

const store = useReviewStore()
const { reviews, isLoading } = storeToRefs(store)
const dialog = useDialog()
const message = useMessage()

Expand All @@ -22,6 +21,7 @@
h(NRate, { color: 'gold', readonly: true, defaultValue: row.rate, allowHalf: true }),
]
},
fixed: 'left',
},
{
title: 'COMMENT',
Expand Down Expand Up @@ -89,14 +89,14 @@
return () => h(NIcon, null, { default: () => h(icon) })
}

function handleDeleteItem(row: RowData) {

Check warning on line 92 in src/components/Review/ReviewManagement.vue

View workflow job for this annotation

GitHub Actions / lint

'row' is defined but never used. Allowed unused args must match /^_/u
dialog.error({
title: 'Confirm',
content: 'Are you sure?',
positiveText: 'Yes, Delete',
negativeText: 'Cancel',
onPositiveClick: () => {
store.deleteProduct(row.id)
/// store.deleteProduct(row.id)
message.success('Product was deleted!')
},
})
Expand Down Expand Up @@ -128,9 +128,9 @@
<n-layout-content>
<div class="px-3">
<n-data-table
remote :columns="columns" :data="reviews" :loading="isLoading" :pagination="options"
selectable :row-key="rowKey" @update:sorter="handleSorterChange" @update:filters="handleFiltersChange"
@update:page="handlePageChange"
remote :columns="columns" :data="store.reviews" :loading="store.isLoading" :pagination="options" selectable
:row-key="rowKey" :scroll-x="1000" @update:sorter="handleSorterChange"
@update:filters="handleFiltersChange" @update:page="handlePageChange"
/>
</div>
</n-layout-content>
Expand Down
1 change: 1 addition & 0 deletions src/store/order.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const useOrderStore = defineStore('Order', () => {
getOrders,
getOrderDetail,
isSaving,
isLoading,
}
})
if (import.meta.hot)
Expand Down
Loading