@mythpe/quasar-ui-qui 0.0.70 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mythpe/quasar-ui-qui",
3
- "version": "0.0.70",
3
+ "version": "0.0.71",
4
4
  "description": "MyTh Quasar UI Kit App Extension",
5
5
  "author": {
6
6
  "name": "MyTh Ahmed Faiz",
@@ -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,
@@ -184,11 +185,22 @@ const {
184
185
  isSmall,
185
186
  api
186
187
  } = useMyth()
188
+
187
189
  const slots = useSlots()
188
190
  const router = useRouter()
189
191
  const route = useRoute()
190
192
  const $q = useQuasar()
193
+ const { te } = useI18n({ useScope: 'global' })
191
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
+ })
192
204
  const formRef = useForm<any, any>()
193
205
  const formScope = reactive(formRef)
194
206
  const { resetForm: resetDialogForm, setValues, handleSubmit } = formRef
@@ -286,8 +298,7 @@ const search = ref<string | null>(null)
286
298
  const searchColumnsProp = computed(() => props.searchColumns)
287
299
  const searchColumnsRef = ref<string[]>(parseHeaders(searchColumnsProp.value || headersProp.value)
288
300
  .filter(e => e?.field !== props.controlKey)
289
- .map(
290
- e => e.name))
301
+ .map(e => e.name))
291
302
  const searchPlaceholder = computed<string>(() => {
292
303
  if (searchColumnsRef.value.length > 0) {
293
304
  return __('myth.datatable.searchInputPlaceholder',
@@ -455,7 +466,10 @@ const getRequestWith = (type: 'withIndex' | 'withShow' | 'withUpdate' | 'withSto
455
466
  }
456
467
  return v.join(',') ?? null
457
468
  }
458
- const getDatatableParams = ({ pagination, filter }: FetchRowsArgs = {}, merge: Partial<ApiServiceParams> = {}): ApiServiceParams => {
469
+ const getDatatableParams = ({
470
+ pagination,
471
+ filter
472
+ }: FetchRowsArgs = {}, merge: Partial<ApiServiceParams> = {}): ApiServiceParams => {
459
473
  let params: ApiServiceParams = {
460
474
  // filter: tableOptions.filter,
461
475
  // search: filter || undefined,
@@ -623,15 +637,16 @@ const openDialogTimeout = 100
623
637
  * Filter Dialog
624
638
  */
625
639
  const openFilterDialog = () => {
626
- dialogs.filter = !0
627
- tempFilterForm.value = { ...tableOptions.filter }
628
- }
629
- const saveFilterDialog = () => {
630
- filterForm.value = { ...tableOptions.tempFilter }
640
+ resetDialogForm({ values: {}, errors: {} }, { force: !0 })
631
641
  nextTick(() => {
632
- dialogs.filter = !1
642
+ tempFilterForm.value = { ...tableOptions.filter }
643
+ dialogs.filter = !0
633
644
  })
634
645
  }
646
+ const saveFilterDialog = () => {
647
+ dialogs.filter = !1
648
+ nextTick(() => (filterForm.value = { ...tableOptions.tempFilter }))
649
+ }
635
650
  const closeFilterDialog = () => {
636
651
  dialogs.filter = !1
637
652
  tempFilterForm.value = { ...tableOptions.filter }
@@ -1107,8 +1122,7 @@ const getShowSelection = computed<boolean | undefined>(() => {
1107
1122
  })
1108
1123
  const defaultTopBtnProps: any = {
1109
1124
  dense: !0,
1110
- flat: !0,
1111
- fabMini: !0
1125
+ flat: !0
1112
1126
  }
1113
1127
  const table = ref<InstanceType<typeof QTable>>()
1114
1128
  defineExpose({
@@ -1227,7 +1241,6 @@ defineOptions({
1227
1241
  :rows="getRows"
1228
1242
  :rows-per-page-options="getRowsPerPageOptions"
1229
1243
  :selection="getShowSelection ? (multiSelection ? 'multiple' : 'single') : 'none'"
1230
- :title="title"
1231
1244
  :visible-columns="visibleHeaders"
1232
1245
  card-container-class="m--datatable-container"
1233
1246
  table-class="m--datatable-container"
@@ -1236,6 +1249,7 @@ defineOptions({
1236
1249
  wrapCells:!0,
1237
1250
  ...pluginOptions.datatable,
1238
1251
  ...$attrs,
1252
+ title: getTableTitle,
1239
1253
  bordered: bordered === undefined ? pluginOptions.datatable?.bordered : bordered,
1240
1254
  dense: dense === undefined ? ( theme.inputs.dense !== undefined ? theme.inputs.dense : pluginOptions.datatable?.dense) : dense,
1241
1255
  flat: flat === undefined ? pluginOptions.datatable?.flat : flat,
@@ -1401,13 +1415,30 @@ defineOptions({
1401
1415
  name="title"
1402
1416
  >
1403
1417
  <MCol
1404
- v-if="!!title"
1418
+ v-if="!!getTableTitle"
1405
1419
  col="12"
1406
1420
  >
1407
- <div
1408
- class="text-h5 bordered-bottom"
1409
- v-text="title"
1410
- />
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>
1411
1442
  </MCol>
1412
1443
  </slot>
1413
1444
  <slot
@@ -1518,7 +1549,7 @@ defineOptions({
1518
1549
  />
1519
1550
  </MRow>
1520
1551
  <!--Buttons-->
1521
- <MRow class="row q-gutter-x-sm q-gutter-xs-y-sm items-center justify-between">
1552
+ <MRow class="row q-gutter-x-sm q-gutter-xs-y-sm items-center">
1522
1553
  <!--More Menu-->
1523
1554
  <MDtBtn
1524
1555
  v-if="hasMenu"
@@ -1526,11 +1557,12 @@ defineOptions({
1526
1557
  :disable="tableOptions.loading"
1527
1558
  icon="ion-ios-options"
1528
1559
  tooltip="myth.datatable.hints.more"
1560
+ label="myth.datatable.hints.options"
1529
1561
  v-bind="{...defaultTopBtnProps,...pluginOptions.dt?.buttons?.more}"
1530
1562
  >
1531
1563
  <MModalMenu
1532
1564
  :offset="[10,10]"
1533
- position="top"
1565
+ position="bottom"
1534
1566
  v-bind="pluginOptions.dt?.buttons?.moreMenu as any"
1535
1567
  >
1536
1568
  <q-list
@@ -1639,12 +1671,14 @@ defineOptions({
1639
1671
  key="filter-selection-btn"
1640
1672
  icon="o_filter_alt"
1641
1673
  tooltip="myth.datatable.hints.filter"
1674
+ label="myth.datatable.hints.filter"
1642
1675
  v-bind="{...defaultTopBtnProps,...pluginOptions.dt?.buttons?.filter}"
1643
1676
  @click="openFilterDialog()"
1644
1677
  >
1645
1678
  <MModalMenu
1646
1679
  no-close-btn
1647
1680
  persistent
1681
+ position="top"
1648
1682
  v-bind="pluginOptions.dt?.filterDialogProps"
1649
1683
  >
1650
1684
  <q-card
@@ -1726,7 +1760,6 @@ defineOptions({
1726
1760
  v-bind="{...defaultTopBtnProps,...pluginOptions.dt?.buttons?.fullscreen}"
1727
1761
  @click="tableOptions.fullscreen = !tableOptions.fullscreen"
1728
1762
  />
1729
-
1730
1763
  <template v-if="hasSelectedItem">
1731
1764
  <MDtBtn
1732
1765
  v-if="hasUpdateBtn && isSingleSelectedItem"
@@ -1768,18 +1801,6 @@ defineOptions({
1768
1801
  />
1769
1802
  </template>
1770
1803
  </template>
1771
-
1772
- <q-space />
1773
- <!-- Add Btn -->
1774
- <template
1775
- v-if="hasAddBtn && (addTopBtn===undefined?(pluginOptions.datatable?.addTopBtn===undefined?!0:pluginOptions.datatable?.addTopBtn):addTopBtn)"
1776
- >
1777
- <MBtn
1778
- :label="getFormTitle"
1779
- icon="ion-ios-add"
1780
- @click="openCreateDialog()"
1781
- />
1782
- </template>
1783
1804
  </MRow>
1784
1805
 
1785
1806
  <!-- Manage Columns -->
@@ -2050,21 +2071,11 @@ defineOptions({
2050
2071
  v-model="dialogs.form"
2051
2072
  v-bind="pluginOptions.dt?.formDialogProps"
2052
2073
  >
2053
- <div
2054
- class="m--form__container full-height no-wrap"
2055
- >
2074
+ <div class="m--form__container full-height no-wrap">
2056
2075
  <form
2057
2076
  class="m--form column full-height justify-between no-wrap"
2058
2077
  @submit="defaultSubmitItem"
2059
2078
  >
2060
- <!--<MForm-->
2061
- <!-- v-slot="form"-->
2062
- <!-- :errors="dialogs.errors"-->
2063
- <!-- :form="dialogs.item"-->
2064
- <!-- :form-props="{class: 'column full-height justify-between no-wrap'}"-->
2065
- <!-- class="full-height no-wrap"-->
2066
- <!-- @submit="defaultSubmitItem"-->
2067
- <!--&gt;-->
2068
2079
  <q-card class="m--dialog-card">
2069
2080
  <q-card-section ref="formTitle">
2070
2081
  <q-toolbar :class="{'q-pa-none': $q.screen.lt.md}">
@@ -2088,13 +2099,13 @@ defineOptions({
2088
2099
  </template>
2089
2100
  <template v-else>
2090
2101
  <q-btn
2091
- :icon="`ion-ios-arrow-${$q.lang.rtl ? 'forward' : 'back'}`"
2092
- fab-mini
2102
+ color="negative"
2093
2103
  flat
2104
+ icon="close"
2094
2105
  @click="closeFormDialog"
2095
2106
  >
2096
2107
  <q-tooltip class="m--dt-btn-tooltip">
2097
- {{ __('myth.titles.back') }}
2108
+ {{ __('myth.titles.close') }}
2098
2109
  </q-tooltip>
2099
2110
  </q-btn>
2100
2111
  {{ getFormTitle }}
@@ -2179,7 +2190,6 @@ defineOptions({
2179
2190
  />
2180
2191
  </q-card-actions>
2181
2192
  </q-card>
2182
- <!--</MForm>-->
2183
2193
  </form>
2184
2194
  </div>
2185
2195
  </MDialog>
@@ -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: RouteLocationNormalizedLoaded, number?: number | string): string => {
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 route
40
- // No page title
46
+ // # Not is Route, No page title
41
47
  if (!routePath || !routeName) {
42
48
  return defaultValue
43
49
  }
@@ -167,3 +167,8 @@ $control-max-width: 200px !default
167
167
  .m--control-cell,
168
168
  .m--control-header
169
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?: number;
836
+ modelValue?: any;
837
837
  /**
838
838
  * Customize the label when the toggle is true.
839
839
  * Default is: Yes.