@mythpe/quasar-ui-qui 0.0.68 → 0.0.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/datatable/MDatatable.vue +65 -53
- package/src/components/datatable/MDtContextmenuItems.vue +2 -0
- package/src/composable/useMyth.ts +9 -3
- package/src/style/main.sass +8 -2
- package/src/types/components.d.ts +1 -1
- package/src/types/m-datatable.d.ts +1 -0
package/package.json
CHANGED
|
@@ -33,6 +33,7 @@ import { is as quasarHelpers, QCardSection, QTable, useQuasar } from 'quasar'
|
|
|
33
33
|
import lodash from 'lodash'
|
|
34
34
|
import { useRoute, useRouter } from 'vue-router'
|
|
35
35
|
import { useMyth } from '../../composable'
|
|
36
|
+
import { useI18n } from 'vue-i18n'
|
|
36
37
|
|
|
37
38
|
const initPaginationOptions: MDatatablePagination = {
|
|
38
39
|
sortBy: undefined,
|
|
@@ -51,6 +52,7 @@ interface Props {
|
|
|
51
52
|
controlKey?: MDatatableProps['controlKey'];
|
|
52
53
|
defaultItem?: MDatatableProps['defaultItem'];
|
|
53
54
|
contextItems?: MDatatableProps['contextItems'];
|
|
55
|
+
contextItemsLength?: MDatatableProps['contextItemsLength'];
|
|
54
56
|
hideAutoMessage?: MDatatableProps['hideAutoMessage'];
|
|
55
57
|
headers: MDatatableProps['headers'];
|
|
56
58
|
serviceName?: MDatatableProps['serviceName'];
|
|
@@ -109,6 +111,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
109
111
|
controlKey: () => 'control',
|
|
110
112
|
defaultItem: undefined,
|
|
111
113
|
contextItems: undefined,
|
|
114
|
+
contextItemsLength: 4,
|
|
112
115
|
hideAutoMessage: undefined,
|
|
113
116
|
headers: () => ([]),
|
|
114
117
|
serviceName: () => '',
|
|
@@ -182,11 +185,22 @@ const {
|
|
|
182
185
|
isSmall,
|
|
183
186
|
api
|
|
184
187
|
} = useMyth()
|
|
188
|
+
|
|
185
189
|
const slots = useSlots()
|
|
186
190
|
const router = useRouter()
|
|
187
191
|
const route = useRoute()
|
|
188
192
|
const $q = useQuasar()
|
|
193
|
+
const { te } = useI18n({ useScope: 'global' })
|
|
189
194
|
const defaultItem = computed(() => props.defaultItem)
|
|
195
|
+
const getTableTitle = computed(() => {
|
|
196
|
+
if (props.title) {
|
|
197
|
+
if (te(props.title)) {
|
|
198
|
+
return __(props.title)
|
|
199
|
+
}
|
|
200
|
+
return __('replace.index', { name: __(props.title) })
|
|
201
|
+
}
|
|
202
|
+
return undefined
|
|
203
|
+
})
|
|
190
204
|
const formRef = useForm<any, any>()
|
|
191
205
|
const formScope = reactive(formRef)
|
|
192
206
|
const { resetForm: resetDialogForm, setValues, handleSubmit } = formRef
|
|
@@ -284,8 +298,7 @@ const search = ref<string | null>(null)
|
|
|
284
298
|
const searchColumnsProp = computed(() => props.searchColumns)
|
|
285
299
|
const searchColumnsRef = ref<string[]>(parseHeaders(searchColumnsProp.value || headersProp.value)
|
|
286
300
|
.filter(e => e?.field !== props.controlKey)
|
|
287
|
-
.map(
|
|
288
|
-
e => e.name))
|
|
301
|
+
.map(e => e.name))
|
|
289
302
|
const searchPlaceholder = computed<string>(() => {
|
|
290
303
|
if (searchColumnsRef.value.length > 0) {
|
|
291
304
|
return __('myth.datatable.searchInputPlaceholder',
|
|
@@ -624,15 +637,16 @@ const openDialogTimeout = 100
|
|
|
624
637
|
* Filter Dialog
|
|
625
638
|
*/
|
|
626
639
|
const openFilterDialog = () => {
|
|
627
|
-
|
|
628
|
-
tempFilterForm.value = { ...tableOptions.filter }
|
|
629
|
-
}
|
|
630
|
-
const saveFilterDialog = () => {
|
|
631
|
-
filterForm.value = { ...tableOptions.tempFilter }
|
|
640
|
+
resetDialogForm({ values: {}, errors: {} }, { force: !0 })
|
|
632
641
|
nextTick(() => {
|
|
633
|
-
|
|
642
|
+
tempFilterForm.value = { ...tableOptions.filter }
|
|
643
|
+
dialogs.filter = !0
|
|
634
644
|
})
|
|
635
645
|
}
|
|
646
|
+
const saveFilterDialog = () => {
|
|
647
|
+
dialogs.filter = !1
|
|
648
|
+
nextTick(() => (filterForm.value = { ...tableOptions.tempFilter }))
|
|
649
|
+
}
|
|
636
650
|
const closeFilterDialog = () => {
|
|
637
651
|
dialogs.filter = !1
|
|
638
652
|
tempFilterForm.value = { ...tableOptions.filter }
|
|
@@ -997,14 +1011,15 @@ const onRowContextmenu = (e: MouseEvent | Event, row: MDtItem, index: number | u
|
|
|
997
1011
|
}
|
|
998
1012
|
const contextmenuItemsProp = computed(() => props.contextItems)
|
|
999
1013
|
const contextmenuItems = computed<any>(() => ([
|
|
1000
|
-
...(contextmenuItemsProp.value || [])
|
|
1014
|
+
...(contextmenuItemsProp.value || []),
|
|
1001
1015
|
{
|
|
1002
1016
|
name: 'show',
|
|
1003
1017
|
label: pluginOptions.value?.dt?.contextmenu?.btnStyle?.showLabel ? 'labels.show' : undefined,
|
|
1004
1018
|
click: (item: MDtItem, index: MDtItemIndex) => {
|
|
1005
1019
|
openShowDialog(item, index)
|
|
1006
1020
|
},
|
|
1007
|
-
showIf: hasShowBtn.value
|
|
1021
|
+
showIf: hasShowBtn.value,
|
|
1022
|
+
order: 100
|
|
1008
1023
|
},
|
|
1009
1024
|
{
|
|
1010
1025
|
name: 'update',
|
|
@@ -1012,7 +1027,8 @@ const contextmenuItems = computed<any>(() => ([
|
|
|
1012
1027
|
click: (item: MDtItem, index: MDtItemIndex) => {
|
|
1013
1028
|
openUpdateDialog(item, index)
|
|
1014
1029
|
},
|
|
1015
|
-
showIf: hasUpdateBtn.value
|
|
1030
|
+
showIf: hasUpdateBtn.value,
|
|
1031
|
+
order: 200
|
|
1016
1032
|
},
|
|
1017
1033
|
{
|
|
1018
1034
|
name: 'destroy',
|
|
@@ -1024,9 +1040,10 @@ const contextmenuItems = computed<any>(() => ([
|
|
|
1024
1040
|
showIf: hasDestroyBtn.value,
|
|
1025
1041
|
attr: {
|
|
1026
1042
|
color: 'negative'
|
|
1027
|
-
}
|
|
1043
|
+
},
|
|
1044
|
+
order: 300
|
|
1028
1045
|
}
|
|
1029
|
-
]))
|
|
1046
|
+
].sort((a, b) => (a.order ?? 0) - (b.order ?? 0))))
|
|
1030
1047
|
const endReach = computed<boolean>(() => Boolean(props.endReach))
|
|
1031
1048
|
const rowsPerPageOptions = computed(() => props.rowsPerPageOptions)
|
|
1032
1049
|
const getRowsPerPageOptions = computed<any[]>(() => endReach.value ? [0] : (rowsPerPageOptions.value || [0]))
|
|
@@ -1105,8 +1122,7 @@ const getShowSelection = computed<boolean | undefined>(() => {
|
|
|
1105
1122
|
})
|
|
1106
1123
|
const defaultTopBtnProps: any = {
|
|
1107
1124
|
dense: !0,
|
|
1108
|
-
flat: !0
|
|
1109
|
-
fabMini: !0
|
|
1125
|
+
flat: !0
|
|
1110
1126
|
}
|
|
1111
1127
|
const table = ref<InstanceType<typeof QTable>>()
|
|
1112
1128
|
defineExpose({
|
|
@@ -1225,7 +1241,6 @@ defineOptions({
|
|
|
1225
1241
|
:rows="getRows"
|
|
1226
1242
|
:rows-per-page-options="getRowsPerPageOptions"
|
|
1227
1243
|
:selection="getShowSelection ? (multiSelection ? 'multiple' : 'single') : 'none'"
|
|
1228
|
-
:title="title"
|
|
1229
1244
|
:visible-columns="visibleHeaders"
|
|
1230
1245
|
card-container-class="m--datatable-container"
|
|
1231
1246
|
table-class="m--datatable-container"
|
|
@@ -1234,6 +1249,7 @@ defineOptions({
|
|
|
1234
1249
|
wrapCells:!0,
|
|
1235
1250
|
...pluginOptions.datatable,
|
|
1236
1251
|
...$attrs,
|
|
1252
|
+
title: getTableTitle,
|
|
1237
1253
|
bordered: bordered === undefined ? pluginOptions.datatable?.bordered : bordered,
|
|
1238
1254
|
dense: dense === undefined ? ( theme.inputs.dense !== undefined ? theme.inputs.dense : pluginOptions.datatable?.dense) : dense,
|
|
1239
1255
|
flat: flat === undefined ? pluginOptions.datatable?.flat : flat,
|
|
@@ -1399,13 +1415,30 @@ defineOptions({
|
|
|
1399
1415
|
name="title"
|
|
1400
1416
|
>
|
|
1401
1417
|
<MCol
|
|
1402
|
-
v-if="!!
|
|
1418
|
+
v-if="!!getTableTitle"
|
|
1403
1419
|
col="12"
|
|
1404
1420
|
>
|
|
1405
|
-
<div
|
|
1406
|
-
class="
|
|
1407
|
-
|
|
1408
|
-
|
|
1421
|
+
<div class="row justify-between q-col-gutter-md">
|
|
1422
|
+
<div class="col">
|
|
1423
|
+
<div class="text-h5 bordered-bottom ellipsis">
|
|
1424
|
+
{{ getTableTitle }}
|
|
1425
|
+
</div>
|
|
1426
|
+
</div>
|
|
1427
|
+
|
|
1428
|
+
<!-- Add Btn -->
|
|
1429
|
+
<template
|
|
1430
|
+
v-if="hasAddBtn && (addTopBtn===undefined?(pluginOptions.datatable?.addTopBtn===undefined?!0:pluginOptions.datatable?.addTopBtn):addTopBtn)"
|
|
1431
|
+
>
|
|
1432
|
+
<div class="col-auto">
|
|
1433
|
+
<MBtn
|
|
1434
|
+
:label="getFormTitle"
|
|
1435
|
+
icon="ion-ios-add"
|
|
1436
|
+
no-caps
|
|
1437
|
+
@click="openCreateDialog()"
|
|
1438
|
+
/>
|
|
1439
|
+
</div>
|
|
1440
|
+
</template>
|
|
1441
|
+
</div>
|
|
1409
1442
|
</MCol>
|
|
1410
1443
|
</slot>
|
|
1411
1444
|
<slot
|
|
@@ -1516,7 +1549,7 @@ defineOptions({
|
|
|
1516
1549
|
/>
|
|
1517
1550
|
</MRow>
|
|
1518
1551
|
<!--Buttons-->
|
|
1519
|
-
<MRow class="row q-gutter-x-sm q-gutter-xs-y-sm items-center
|
|
1552
|
+
<MRow class="row q-gutter-x-sm q-gutter-xs-y-sm items-center">
|
|
1520
1553
|
<!--More Menu-->
|
|
1521
1554
|
<MDtBtn
|
|
1522
1555
|
v-if="hasMenu"
|
|
@@ -1524,11 +1557,12 @@ defineOptions({
|
|
|
1524
1557
|
:disable="tableOptions.loading"
|
|
1525
1558
|
icon="ion-ios-options"
|
|
1526
1559
|
tooltip="myth.datatable.hints.more"
|
|
1560
|
+
label="myth.datatable.hints.options"
|
|
1527
1561
|
v-bind="{...defaultTopBtnProps,...pluginOptions.dt?.buttons?.more}"
|
|
1528
1562
|
>
|
|
1529
1563
|
<MModalMenu
|
|
1530
1564
|
:offset="[10,10]"
|
|
1531
|
-
position="
|
|
1565
|
+
position="bottom"
|
|
1532
1566
|
v-bind="pluginOptions.dt?.buttons?.moreMenu as any"
|
|
1533
1567
|
>
|
|
1534
1568
|
<q-list
|
|
@@ -1637,12 +1671,14 @@ defineOptions({
|
|
|
1637
1671
|
key="filter-selection-btn"
|
|
1638
1672
|
icon="o_filter_alt"
|
|
1639
1673
|
tooltip="myth.datatable.hints.filter"
|
|
1674
|
+
label="myth.datatable.hints.filter"
|
|
1640
1675
|
v-bind="{...defaultTopBtnProps,...pluginOptions.dt?.buttons?.filter}"
|
|
1641
1676
|
@click="openFilterDialog()"
|
|
1642
1677
|
>
|
|
1643
1678
|
<MModalMenu
|
|
1644
1679
|
no-close-btn
|
|
1645
1680
|
persistent
|
|
1681
|
+
position="top"
|
|
1646
1682
|
v-bind="pluginOptions.dt?.filterDialogProps"
|
|
1647
1683
|
>
|
|
1648
1684
|
<q-card
|
|
@@ -1724,7 +1760,6 @@ defineOptions({
|
|
|
1724
1760
|
v-bind="{...defaultTopBtnProps,...pluginOptions.dt?.buttons?.fullscreen}"
|
|
1725
1761
|
@click="tableOptions.fullscreen = !tableOptions.fullscreen"
|
|
1726
1762
|
/>
|
|
1727
|
-
|
|
1728
1763
|
<template v-if="hasSelectedItem">
|
|
1729
1764
|
<MDtBtn
|
|
1730
1765
|
v-if="hasUpdateBtn && isSingleSelectedItem"
|
|
@@ -1766,18 +1801,6 @@ defineOptions({
|
|
|
1766
1801
|
/>
|
|
1767
1802
|
</template>
|
|
1768
1803
|
</template>
|
|
1769
|
-
|
|
1770
|
-
<q-space />
|
|
1771
|
-
<!-- Add Btn -->
|
|
1772
|
-
<template
|
|
1773
|
-
v-if="hasAddBtn && (addTopBtn===undefined?(pluginOptions.datatable?.addTopBtn===undefined?!0:pluginOptions.datatable?.addTopBtn):addTopBtn)"
|
|
1774
|
-
>
|
|
1775
|
-
<MBtn
|
|
1776
|
-
:label="getFormTitle"
|
|
1777
|
-
icon="ion-ios-add"
|
|
1778
|
-
@click="openCreateDialog()"
|
|
1779
|
-
/>
|
|
1780
|
-
</template>
|
|
1781
1804
|
</MRow>
|
|
1782
1805
|
|
|
1783
1806
|
<!-- Manage Columns -->
|
|
@@ -1899,7 +1922,7 @@ defineOptions({
|
|
|
1899
1922
|
<q-td :props="noBodyProps">
|
|
1900
1923
|
<!--Control-->
|
|
1901
1924
|
<q-btn-dropdown
|
|
1902
|
-
v-if="contextmenuItems.length>
|
|
1925
|
+
v-if="contextmenuItems.length>contextItemsLength"
|
|
1903
1926
|
v-close-popup
|
|
1904
1927
|
:menu-offset="[0,10]"
|
|
1905
1928
|
color="primary"
|
|
@@ -1929,7 +1952,7 @@ defineOptions({
|
|
|
1929
1952
|
</q-btn-dropdown>
|
|
1930
1953
|
<MRow
|
|
1931
1954
|
v-else
|
|
1932
|
-
class="m--dt-context_menu_items"
|
|
1955
|
+
class="m--dt-context_menu_items justify-end"
|
|
1933
1956
|
gutter
|
|
1934
1957
|
space="xs"
|
|
1935
1958
|
>
|
|
@@ -2048,21 +2071,11 @@ defineOptions({
|
|
|
2048
2071
|
v-model="dialogs.form"
|
|
2049
2072
|
v-bind="pluginOptions.dt?.formDialogProps"
|
|
2050
2073
|
>
|
|
2051
|
-
<div
|
|
2052
|
-
class="m--form__container full-height no-wrap"
|
|
2053
|
-
>
|
|
2074
|
+
<div class="m--form__container full-height no-wrap">
|
|
2054
2075
|
<form
|
|
2055
2076
|
class="m--form column full-height justify-between no-wrap"
|
|
2056
2077
|
@submit="defaultSubmitItem"
|
|
2057
2078
|
>
|
|
2058
|
-
<!--<MForm-->
|
|
2059
|
-
<!-- v-slot="form"-->
|
|
2060
|
-
<!-- :errors="dialogs.errors"-->
|
|
2061
|
-
<!-- :form="dialogs.item"-->
|
|
2062
|
-
<!-- :form-props="{class: 'column full-height justify-between no-wrap'}"-->
|
|
2063
|
-
<!-- class="full-height no-wrap"-->
|
|
2064
|
-
<!-- @submit="defaultSubmitItem"-->
|
|
2065
|
-
<!-->-->
|
|
2066
2079
|
<q-card class="m--dialog-card">
|
|
2067
2080
|
<q-card-section ref="formTitle">
|
|
2068
2081
|
<q-toolbar :class="{'q-pa-none': $q.screen.lt.md}">
|
|
@@ -2086,13 +2099,13 @@ defineOptions({
|
|
|
2086
2099
|
</template>
|
|
2087
2100
|
<template v-else>
|
|
2088
2101
|
<q-btn
|
|
2089
|
-
|
|
2090
|
-
fab-mini
|
|
2102
|
+
color="negative"
|
|
2091
2103
|
flat
|
|
2104
|
+
icon="close"
|
|
2092
2105
|
@click="closeFormDialog"
|
|
2093
2106
|
>
|
|
2094
2107
|
<q-tooltip class="m--dt-btn-tooltip">
|
|
2095
|
-
{{ __('myth.titles.
|
|
2108
|
+
{{ __('myth.titles.close') }}
|
|
2096
2109
|
</q-tooltip>
|
|
2097
2110
|
</q-btn>
|
|
2098
2111
|
{{ getFormTitle }}
|
|
@@ -2177,7 +2190,6 @@ defineOptions({
|
|
|
2177
2190
|
/>
|
|
2178
2191
|
</q-card-actions>
|
|
2179
2192
|
</q-card>
|
|
2180
|
-
<!--</MForm>-->
|
|
2181
2193
|
</form>
|
|
2182
2194
|
</div>
|
|
2183
2195
|
</MDialog>
|
|
@@ -47,6 +47,8 @@ defineOptions({ name: 'MDtContextmenuItems', inheritAttrs: !1 })
|
|
|
47
47
|
undefined)"
|
|
48
48
|
:list-item="itemMode"
|
|
49
49
|
:tooltip="m.tooltip !== undefined ? m.tooltip : (m.label === undefined ? m.name : undefined)"
|
|
50
|
+
flat
|
|
51
|
+
dense
|
|
50
52
|
v-bind="m.attr"
|
|
51
53
|
@click="m.click ? m.click(item,index) : undefined"
|
|
52
54
|
/>
|
|
@@ -14,18 +14,25 @@ import { copyToClipboard, extend, useQuasar } from 'quasar'
|
|
|
14
14
|
import { Helpers, MythKey, type MythType, Str, veeRules } from '../utils'
|
|
15
15
|
import type { MDtColumn, MDtHeadersParameter, ParseHeaderOptions, Vue3MAlertMessage, Vue3MAlertMessageOptions, Vue3MConfirmMessage } from '../types'
|
|
16
16
|
import { computed, inject } from 'vue'
|
|
17
|
+
import { useRoute } from 'vue-router'
|
|
17
18
|
|
|
18
19
|
export const useMyth = () => {
|
|
19
20
|
const plugin = inject(MythKey) as MythType
|
|
20
21
|
const { t, te } = useI18n({ useScope: 'global' })
|
|
21
22
|
const pluginOptions = computed(() => plugin.props.value)
|
|
22
23
|
const q = useQuasar()
|
|
24
|
+
const $route = useRoute()
|
|
23
25
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
24
26
|
// @ts-ignore
|
|
25
27
|
const __ = (key: any, ...rest: unknown[]) => !key ? '' : te(`attributes.${key}`) ? t(`attributes.${key}`, ...rest) : te(key) ? t(key, ...rest) : key
|
|
26
|
-
const getPageTitle = (route
|
|
28
|
+
const getPageTitle = (route?: RouteLocationNormalizedLoaded | number | string, number?: number | string): string => {
|
|
29
|
+
if (typeof route !== 'object') {
|
|
30
|
+
number = route
|
|
31
|
+
route = $route
|
|
32
|
+
}
|
|
27
33
|
number = number || 2
|
|
28
34
|
number = parseInt(number.toString())
|
|
35
|
+
route = route || $route
|
|
29
36
|
const defaultValue = ''
|
|
30
37
|
// Not is route
|
|
31
38
|
// No page title
|
|
@@ -36,8 +43,7 @@ export const useMyth = () => {
|
|
|
36
43
|
const routePath = route?.path?.toString() || null
|
|
37
44
|
const routeName = route?.name?.toString() || null
|
|
38
45
|
|
|
39
|
-
// Not is
|
|
40
|
-
// No page title
|
|
46
|
+
// # Not is Route, No page title
|
|
41
47
|
if (!routePath || !routeName) {
|
|
42
48
|
return defaultValue
|
|
43
49
|
}
|
package/src/style/main.sass
CHANGED
|
@@ -162,7 +162,13 @@ pre
|
|
|
162
162
|
line-height: 1.25rem
|
|
163
163
|
letter-spacing: 0.03333em
|
|
164
164
|
|
|
165
|
-
$control-max-width:
|
|
165
|
+
$control-max-width: 200px !default
|
|
166
|
+
|
|
166
167
|
.m--control-cell,
|
|
167
168
|
.m--control-header
|
|
168
|
-
|
|
169
|
+
width: $control-max-width
|
|
170
|
+
|
|
171
|
+
.screen--xs,
|
|
172
|
+
.screen--sm
|
|
173
|
+
.m--dt-btn-tooltip
|
|
174
|
+
display: none
|
|
@@ -833,7 +833,7 @@ export interface MOptionsSlots extends QOptionGroupSlots, QFieldSlots, BaseInput
|
|
|
833
833
|
|
|
834
834
|
export interface MToggleProps extends Omit<BaseInputsProps, 'placeholder' | 'topLabel' | 'autocomplete' | 'modelValue'>,
|
|
835
835
|
Omit<QToggleProps, 'modelValue' | 'label' | 'name'> {
|
|
836
|
-
modelValue?:
|
|
836
|
+
modelValue?: any;
|
|
837
837
|
/**
|
|
838
838
|
* Customize the label when the toggle is true.
|
|
839
839
|
* Default is: Yes.
|
|
@@ -210,6 +210,7 @@ export type MDatatableProps<I extends GenericFormValues = GenericFormValues> = O
|
|
|
210
210
|
controlKey?: string;
|
|
211
211
|
defaultItem?: Partial<MDtItem<I>>
|
|
212
212
|
contextItems?: GenericMDtBtn[];
|
|
213
|
+
contextItemsLength?: number;
|
|
213
214
|
hideAutoMessage?: boolean;
|
|
214
215
|
headers: string[] | Partial<QTableProps['columns']> | any[];
|
|
215
216
|
serviceName?: MDtServiceNameStringProp | MDtServiceNameCallbackProp;
|