@mythpe/quasar-ui-qui 0.1.57 → 0.1.59

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.1.57",
3
+ "version": "0.1.59",
4
4
  "description": "MyTh Quasar UI Kit App Extension",
5
5
  "author": {
6
6
  "name": "MyTh Ahmed Faiz",
@@ -7,8 +7,9 @@
7
7
  */
8
8
 
9
9
  import { boot } from 'quasar/wrappers'
10
- import Plugin from '../utils/vue-plugin'
10
+ import { install } from '../utils'
11
+ import type { InstallOptions } from '../types'
11
12
 
12
13
  export default boot(({ app }) => {
13
- app.use(Plugin)
14
+ app.use(install, {} as InstallOptions)
14
15
  })
@@ -13,7 +13,7 @@
13
13
  import type { MDatatableProps } from '../../types'
14
14
  import type { InvalidSubmissionHandler, SubmissionHandler } from 'vee-validate'
15
15
  import { useForm } from 'vee-validate'
16
- import { computed, onMounted, ref, toValue, watch } from 'vue'
16
+ import { onMounted, ref, toValue, watch } from 'vue'
17
17
  import { is as quasarHelpers, QCardSection, QTable, useQuasar } from 'quasar'
18
18
  import lodash from 'lodash'
19
19
  import { useDtHelpers, useMyth } from '../../composable'
@@ -237,6 +237,7 @@ const {
237
237
  deleteSelectionItem,
238
238
  logoutDatatable,
239
239
  contextmenuItems,
240
+ activeContextItems,
240
241
  datatableItemsScope,
241
242
  onCloneItem,
242
243
  imageDialog,
@@ -380,9 +381,6 @@ watch(formDialogModel, (v) => {
380
381
  dialogErrors.value = {}
381
382
  }
382
383
  })
383
- const activeContextItems = computed(() => {
384
- return contextmenuItems.value.filter((e, i) => typeof e.showIf === 'function' ? e.showIf(e, i) : e.showIf !== !1) as Required<MDatatableProps['contextItems']> || []
385
- })
386
384
  const table = ref<InstanceType<typeof QTable>>()
387
385
  defineOptions({
388
386
  name: 'MDatatable',
@@ -670,8 +668,8 @@ defineExpose({
670
668
  </div>
671
669
  <div class="col">
672
670
  <div
673
- class="text-h5 bordered-bottom ellipsis"
674
671
  v-if="!!getTableTitle"
672
+ class="text-h5 bordered-bottom ellipsis"
675
673
  >
676
674
  {{ getTableTitle }}
677
675
  </div>
@@ -24,8 +24,8 @@ const props = withDefaults(defineProps<Props>(), {
24
24
  append: !1
25
25
  })
26
26
 
27
- const { te, n } = useI18n({ useScope: 'global' })
28
- const { __, toFixedFormatted } = useMyth()
27
+ const { te } = useI18n({ useScope: 'global' })
28
+ const { __, formatMoney } = useMyth()
29
29
  const getText = computed<string | undefined>(() => {
30
30
  if (!props.text?.toString().length) {
31
31
  return props.text
@@ -37,7 +37,7 @@ const getText = computed<string | undefined>(() => {
37
37
  if (props.string) {
38
38
  return te(`labels.${text}`) ? __(`labels.${text}`) : __(text)
39
39
  }
40
- const v = isNaN(text) ? toFixedFormatted(text || '') : toFixedFormatted(n(parseFloat(text || '0') || 0))
40
+ const v = formatMoney(text)
41
41
 
42
42
  return v !== null && v !== undefined ? (v?.toString?.() || v) : undefined
43
43
  })
@@ -7,7 +7,8 @@ import type {
7
7
  MDatatableMetaServer,
8
8
  MDatatableOptions,
9
9
  MDatatablePagination,
10
- MDatatableProps, MDatatableScope,
10
+ MDatatableProps,
11
+ MDatatableScope,
11
12
  MDtExportOptions,
12
13
  MDtHeadersParameter,
13
14
  MDtItem,
@@ -102,8 +103,13 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>) => {
102
103
  dialogErrors.value = {}
103
104
  }
104
105
 
105
- const getHeaders = computed<any[]>(() => parseHeaders(props.headers as MDtHeadersParameter,
106
- { noSort: props.imageColumns }) || [])
106
+ const getHeaders = computed<any[]>(() => {
107
+ const h = parseHeaders(props.headers as MDtHeadersParameter, { noSort: props.imageColumns }) || []
108
+ if (!activeContextItems.value.length) {
109
+ return h.filter(e => e.name !== props.controlKey)
110
+ }
111
+ return h
112
+ })
107
113
  const visibleHeaders = ref<string[]>([])
108
114
 
109
115
  const contextmenu = ref(!1)
@@ -253,10 +259,7 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>) => {
253
259
  }
254
260
  return v.join(',') ?? null
255
261
  }
256
- const getDatatableParams = ({
257
- pagination,
258
- filter
259
- }: FetchRowsArgs = {}, merge: Partial<ApiServiceParams> = {}): ApiServiceParams => {
262
+ const getDatatableParams = ({ pagination, filter }: FetchRowsArgs = {}, merge: Partial<ApiServiceParams> = {}): ApiServiceParams => {
260
263
  const headerItems = getHeaders.value.map((e: any) => e.name).join(',')
261
264
  // console.log(headerItems)
262
265
  let params: ApiServiceParams = {
@@ -745,6 +748,7 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>) => {
745
748
  },
746
749
  ...(props.contextItems || [])
747
750
  ].sort((a, b) => (a.order ?? 0) - (b.order ?? 0))))
751
+ const activeContextItems = computed(() => contextmenuItems.value.filter((e, i) => typeof e.showIf === 'function' ? e.showIf(e, i) : e.showIf !== !1) as Required<MDatatableProps['contextItems']> || [])
748
752
  const onCloneItem = (item: MDtItem) => {
749
753
  item = toValue(item)
750
754
  confirmMessage()
@@ -824,6 +828,9 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>) => {
824
828
  if (props.hideSelection) {
825
829
  return !1
826
830
  }
831
+ if (!activeContextItems.value.length && !props.pdf && !props.excel) {
832
+ return !1
833
+ }
827
834
  return props.showSelection
828
835
  })
829
836
  const defaultTopBtnProps: any = {
@@ -937,6 +944,7 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>) => {
937
944
  deleteSelectionItem,
938
945
  logoutDatatable,
939
946
  contextmenuItems,
947
+ activeContextItems,
940
948
  datatableItemsScope,
941
949
  onCloneItem,
942
950
  openImageDialog,
@@ -303,24 +303,16 @@ export const Helpers = {
303
303
  }
304
304
  return `//${path}`
305
305
  },
306
- toFixedFormatted (value: any, prefix?: string) {
307
- value = value || '0.00'
308
- if (value) {
309
- const text: string = value?.toString() || ''
310
- const def = prefix ? (value + ` ${prefix}`) : value
311
- if (!text) {
312
- return def
313
- }
314
- const after: string = (text.split?.('.')[1] || '')?.toString() || ''
315
- if (!after) {
316
- return def
317
- }
318
- if (after?.length === 1) {
319
- value = `${value}0`
320
- }
321
- return value?.toString() + (prefix ? ` ${prefix}` : '')
306
+ formatMoney (value: any = '', suffix: string = ''): string {
307
+ let numValue = typeof value !== 'number' ? parseFloat(value) : value
308
+ if (isNaN(numValue)) {
309
+ numValue = 0.00
322
310
  }
323
- return value
311
+ const formattedValue = numValue.toLocaleString('en-US', {
312
+ minimumFractionDigits: 2,
313
+ maximumFractionDigits: 2
314
+ })
315
+ return `${formattedValue} ${suffix}`.trim()
324
316
  },
325
317
  calculateAspectRatio: (width: number | string, height: number | string): [number, string] => {
326
318
  width = Number(width)
@@ -23,7 +23,6 @@ import { MythKey } from './const'
23
23
  function install (app: App, options: InstallOptions) {
24
24
  const myth = createMyth(options)
25
25
  app.provide(MythKey, myth)
26
- // defineOptions(options)
27
26
  if (options?.asyncComponents) {
28
27
  defineAsyncComponents(app)
29
28
  } else {