@mythpe/quasar-ui-qui 0.3.90 → 0.3.91

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.3.90",
3
+ "version": "0.3.91",
4
4
  "description": "MyTh Quasar UI Kit App Extension",
5
5
  "author": {
6
6
  "name": "MyTh Ahmed Faiz",
@@ -100,6 +100,8 @@ type Props = {
100
100
  noWrapBtn?: boolean;
101
101
  lockValue?: MDatatableProps['lockValue'];
102
102
  align?: MDatatableProps['align'];
103
+ importBtn?: MDatatableProps['importBtn'];
104
+ noExampleBtn?: MDatatableProps['noExampleBtn'];
103
105
  }
104
106
 
105
107
  const props = withDefaults(defineProps<Props>(), {
@@ -176,7 +178,9 @@ const props = withDefaults(defineProps<Props>(), {
176
178
  subtitleClass: undefined,
177
179
  noWrapBtn: undefined,
178
180
  lockValue: undefined,
179
- align: 'left'
181
+ align: 'left',
182
+ importBtn: undefined,
183
+ noExampleBtn: undefined
180
184
  })
181
185
 
182
186
  interface Emits {
@@ -294,7 +298,13 @@ const {
294
298
  onCloneItem,
295
299
  imageDialog,
296
300
  openImageDialog,
297
- closeImageDialog
301
+ closeImageDialog,
302
+
303
+ importDialogModel,
304
+ onOpenImportDialog,
305
+ onCloseImportDialog,
306
+ downloadingExample,
307
+ onDownloadExample
298
308
  } = useDtHelpers(() => props)
299
309
 
300
310
  // Prevent user from back
@@ -554,12 +564,13 @@ defineExpose({
554
564
 
555
565
  <template>
556
566
  <div
557
- :class="{
558
- 'm-datatable-component': !0,
559
- 'm-datatable-component__fixed': fixed === undefined ? ( pluginOptions.datatable?.fixed === undefined ? undefined : pluginOptions.datatable?.fixed) : fixed,
560
- 'm-datatable-component__too_small': $q.screen.height < 900,
561
- 'm-datatable-component__fab': hasAddBtn && (addFabBtn === undefined ? !!pluginOptions.datatable?.addFabBtn : addFabBtn)
562
- }"
567
+ :class="[
568
+ 'm-datatable-component',
569
+ {
570
+ 'm-datatable-component__fixed': fixed === undefined ? ( pluginOptions?.datatable?.fixed === undefined ? undefined : pluginOptions.datatable?.fixed) : fixed,
571
+ 'm-datatable-component__too_small': $q.screen.height < 900,
572
+ 'm-datatable-component__fab': hasAddBtn && (addFabBtn === undefined ? !!pluginOptions.datatable?.addFabBtn : addFabBtn)
573
+ }]"
563
574
  >
564
575
  <!-- Context Menu -->
565
576
  <MModalMenu
@@ -840,6 +851,22 @@ defineExpose({
840
851
  </div>
841
852
  </slot>
842
853
  </MCol>
854
+
855
+ <!--Import Btn-->
856
+ <MCol
857
+ v-if="!!importBtn"
858
+ auto
859
+ >
860
+ <MDtBtn
861
+ color="green"
862
+ icon="far fa-file-excel"
863
+ label="labels.import"
864
+ no-caps
865
+ text-color="white"
866
+ @click="onOpenImportDialog()"
867
+ />
868
+ </MCol>
869
+
843
870
  <!-- Add Btn -->
844
871
  <MCol
845
872
  v-if="hasAddBtn && (addTopBtn===undefined?(pluginOptions.datatable?.addTopBtn===undefined?!0:pluginOptions.datatable?.addTopBtn):addTopBtn)"
@@ -1532,6 +1559,68 @@ defineExpose({
1532
1559
  />
1533
1560
  </q-pull-to-refresh>
1534
1561
 
1562
+ <!--Import Dialog-->
1563
+ <MDialog
1564
+ v-model="importDialogModel"
1565
+ allow-focus-outside
1566
+ full-width
1567
+ no-backdrop-dismiss
1568
+ no-esc-dismiss
1569
+ no-shake
1570
+ position="top"
1571
+ transition-hide="slide-up"
1572
+ transition-show="slide-down"
1573
+ v-bind="pluginOptions.dt?.formDialogProps"
1574
+ >
1575
+ <q-card class="q-dialog-plugin">
1576
+ <q-card-section>
1577
+ <MContainer>
1578
+ <MRow class="justify-between items-start">
1579
+ <div>
1580
+ <div class="text-h6">
1581
+ {{ __('replace.import', { name: title ? __(title) : __('data') }) }}
1582
+ </div>
1583
+ <div
1584
+ v-if="!noExampleBtn"
1585
+ class="q-mt-lg"
1586
+ >
1587
+ <MBtn
1588
+ :disable="loading"
1589
+ :loading="downloadingExample"
1590
+ icon="far fa-file-excel"
1591
+ label="labels.download_example_file"
1592
+ outline
1593
+ text-color="green"
1594
+ @click="onDownloadExample()"
1595
+ />
1596
+ </div>
1597
+ </div>
1598
+ <q-btn
1599
+ flat
1600
+ icon="close"
1601
+ padding="3px"
1602
+ text-color="body"
1603
+ @click="onCloseImportDialog()"
1604
+ >
1605
+ <q-tooltip class="m-dt-btn-tooltip">
1606
+ {{ __('myth.titles.close') }}
1607
+ </q-tooltip>
1608
+ </q-btn>
1609
+ </MRow>
1610
+ </MContainer>
1611
+ </q-card-section>
1612
+ <q-separator />
1613
+ <slot
1614
+ :close="onCloseImportDialog"
1615
+ :download-example="onDownloadExample"
1616
+ :downloading="downloadingExample"
1617
+ :dt="datatableItemsScope"
1618
+ :open="onOpenImportDialog"
1619
+ name="import"
1620
+ />
1621
+ </q-card>
1622
+ </MDialog>
1623
+
1535
1624
  <!-- Form Dialog -->
1536
1625
  <MDialog
1537
1626
  v-model="formDialogModel"
@@ -1,6 +1,7 @@
1
1
  import type { MaybeRefOrGetter } from 'vue'
2
2
  import { computed, nextTick, reactive, ref, toRef, toValue, useSlots } from 'vue'
3
3
  import type {
4
+ ApiInterface,
4
5
  ApiServiceParams,
5
6
  FetchRowsArgs,
6
7
  MDatatableFilterForm,
@@ -51,7 +52,8 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>) => {
51
52
  api,
52
53
  alertError,
53
54
  alertSuccess,
54
- confirmMessage
55
+ confirmMessage,
56
+ openWindow
55
57
  } = useMyth()
56
58
  const props = toValue(options)
57
59
  const getRows = ref<MDtItem[]>([])
@@ -917,7 +919,41 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>) => {
917
919
  }
918
920
  }
919
921
 
922
+ const importDialogModel = ref<boolean>(!1)
923
+ const onOpenImportDialog = () => {
924
+ importDialogModel.value = !0
925
+ }
926
+ const onCloseImportDialog = () => {
927
+ importDialogModel.value = !1
928
+ }
929
+ const downloadingExample = ref<boolean>(false)
930
+ const onDownloadExample = async (config?: AxiosRequestConfig) => {
931
+ downloadingExample.value = true
932
+ return await getMythApiServicesSchema().exampleUrl(config)
933
+ .then((result: ApiInterface) => {
934
+ const { _data } = result
935
+ if (_data.url) {
936
+ openWindow(_data.url)
937
+ }
938
+ return result
939
+ })
940
+ .catch((error: ApiInterface) => {
941
+ const { _message } = error
942
+ alertError(_message)
943
+ return error
944
+ })
945
+ .finally(() => {
946
+ downloadingExample.value = false
947
+ })
948
+ }
949
+
920
950
  return {
951
+ importDialogModel,
952
+ onOpenImportDialog,
953
+ onCloseImportDialog,
954
+ downloadingExample,
955
+ onDownloadExample,
956
+
921
957
  imageDialog,
922
958
  onRowContextmenu,
923
959
  getRowsPerPageOptions,
@@ -6,7 +6,7 @@
6
6
  * Github: https://github.com/mythpe
7
7
  */
8
8
 
9
- import type { AxiosResponse } from 'axios'
9
+ import type { AxiosRequestConfig, AxiosResponse } from 'axios'
10
10
  import type { NamedColor, QAvatarProps, QAvatarSlots, QTableProps, QTableSlots, VueClassProp } from 'quasar'
11
11
  import type { ComputedRef, MaybeRef, MaybeRefOrGetter, Ref, UnwrapNestedRefs, UnwrapRef, VNode } from 'vue'
12
12
  import type { RouteLocationRaw } from 'vue-router'
@@ -190,6 +190,14 @@ type MDatatableMainScope = {
190
190
 
191
191
  type MDatatableSlotFn<T = any> = (scope: T) => VNode[];
192
192
 
193
+ interface ImportScopes {
194
+ dt: MDatatableScope;
195
+ open: () => void;
196
+ close: () => void;
197
+ downloading: Ref<boolean>;
198
+ download: (config?: AxiosRequestConfig) => Promise<ApiInterface>;
199
+ }
200
+
193
201
  export interface MDatatableSlots extends Omit<QTableSlots, 'top'> {
194
202
  tools: MDatatableSlotFn<{ dt: MDatatableScope }>;
195
203
  selection: MDatatableSlotFn<MDatatableMainScope>;
@@ -205,6 +213,7 @@ export interface MDatatableSlots extends Omit<QTableSlots, 'top'> {
205
213
  'form-title': MDatatableSlotFn<MDatatableMainScope>;
206
214
  'form-title-left': MDatatableSlotFn<MDatatableMainScope>;
207
215
  'form-title-right': MDatatableSlotFn<MDatatableMainScope>;
216
+ import: MDatatableSlotFn<ImportScopes>;
208
217
 
209
218
  [key: `body-cell-${string}`]: MDatatableSlotFn<
210
219
  Parameters<QTableSlots['body-cell']>[0] & MDatatableMainScope
@@ -234,6 +243,8 @@ export type MDatatableProps<I extends GenericFormValues = GenericFormValues> = O
234
243
  pdf?: boolean;
235
244
  excel?: boolean;
236
245
  exportUrl?: MDtExportOptions | boolean;
246
+ importBtn?: boolean;
247
+ noExampleBtn?: boolean;
237
248
  hideSearch?: boolean;
238
249
  hideTitle?: boolean;
239
250
  searchDebounce?: string | number;