@mythpe/quasar-ui-qui 0.4.2 → 0.4.3

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.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "MyTh Quasar UI Kit App Extension",
5
5
  "author": {
6
6
  "name": "MyTh Ahmed Faiz",
@@ -298,10 +298,7 @@ const {
298
298
  activeContextItems,
299
299
  datatableItemsScope,
300
300
  onCloneItem,
301
- imageDialog,
302
- openImageDialog,
303
- closeImageDialog,
304
-
301
+ openAttachmentDialog,
305
302
  importDialogModel,
306
303
  onOpenImportDialog,
307
304
  onCloseImportDialog,
@@ -557,8 +554,6 @@ defineExpose({
557
554
  onDeleteItem,
558
555
  deleteSelectionItem,
559
556
  logoutDatatable,
560
- openImageDialog,
561
- closeImageDialog,
562
557
  isUpdateMode,
563
558
  setIsUpdateMode
564
559
  })
@@ -703,7 +698,7 @@ defineExpose({
703
698
  :image-mode="getProp('imageMode')"
704
699
  :image-size="getProp('imageSize')"
705
700
  :value="col.value"
706
- @click="openImageDialog(col.value)"
701
+ @click="openAttachmentDialog(col.value,{ image: true })"
707
702
  />
708
703
  </template>
709
704
  <template v-else-if="computedUrlColumns.indexOf(col.name) !== -1">
@@ -1471,21 +1466,6 @@ defineExpose({
1471
1466
  />
1472
1467
  </q-td>
1473
1468
  </template>
1474
- <template
1475
- v-for="imageCol in computedImageColumns"
1476
- :key="`a-image-body-cell-${imageCol}`"
1477
- #[`body-cell-${imageCol}`]="imageColProps"
1478
- >
1479
- <q-td :props="imageColProps">
1480
- <MDtImageColumn
1481
- v-if="imageColProps.row[imageColProps.col.field] !== undefined && imageColProps.row[imageColProps.col.field] !== null"
1482
- :image-mode="getProp('imageMode')"
1483
- :image-size="getProp('imageSize')"
1484
- :value="imageColProps.row[imageColProps.col.field]"
1485
- @click="openImageDialog(imageColProps.row[imageColProps.col.field])"
1486
- />
1487
- </q-td>
1488
- </template>
1489
1469
  <template
1490
1470
  v-for="u in computedUrlColumns"
1491
1471
  :key="`a-u-body-cell-${u}`"
@@ -1501,6 +1481,21 @@ defineExpose({
1501
1481
  />
1502
1482
  </q-td>
1503
1483
  </template>
1484
+ <template
1485
+ v-for="imageCol in computedImageColumns"
1486
+ :key="`a-image-body-cell-${imageCol}`"
1487
+ #[`body-cell-${imageCol}`]="imageColProps"
1488
+ >
1489
+ <q-td :props="imageColProps">
1490
+ <MDtImageColumn
1491
+ v-if="imageColProps.row[imageColProps.col.field] !== undefined && imageColProps.row[imageColProps.col.field] !== null"
1492
+ :image-mode="getProp('imageMode')"
1493
+ :image-size="getProp('imageSize')"
1494
+ :value="imageColProps.row[imageColProps.col.field]"
1495
+ @click="openAttachmentDialog(imageColProps.row[imageColProps.col.field],{ image: true })"
1496
+ />
1497
+ </q-td>
1498
+ </template>
1504
1499
  <template
1505
1500
  v-for="cc in computedColorColumns"
1506
1501
  :key="`a-cc-body-cell-${cc}`"
@@ -1811,54 +1806,6 @@ defineExpose({
1811
1806
  </q-card>
1812
1807
  </MDialog>
1813
1808
 
1814
- <!-- Image Dialog -->
1815
- <MDialog v-model="imageDialog.value">
1816
- <q-card>
1817
- <div class="row full-height">
1818
- <MCol col="12">
1819
- <MRow class="q-pa-sm justify-between items-center">
1820
- <q-btn
1821
- :href="imageDialog.src"
1822
- :label="__('myth.titles.download')"
1823
- flat
1824
- icon="ion-ios-cloud-download"
1825
- target="_blank"
1826
- />
1827
- <q-btn
1828
- fab-mini
1829
- flat
1830
- icon="ion-ios-close"
1831
- round
1832
- @click="closeImageDialog()"
1833
- />
1834
- </MRow>
1835
- <q-separator />
1836
- </MCol>
1837
- <MCol
1838
- class="text-center"
1839
- col="12"
1840
- >
1841
- <q-img
1842
- v-if="imageDialog.src && !imageDialog.asAttachment"
1843
- :height="`${$q.screen.height - 70}px`"
1844
- :src="imageDialog.src"
1845
- class="self-center"
1846
- fit="contain"
1847
- />
1848
- <iframe
1849
- v-if="imageDialog.src && imageDialog.asAttachment"
1850
- :height="`${$q.screen.height - 70}px`"
1851
- :src="imageDialog.src"
1852
- allowfullscreen
1853
- class="full-width"
1854
- frameborder="0"
1855
- scrolling="no"
1856
- />
1857
- </MCol>
1858
- </div>
1859
- </q-card>
1860
- </MDialog>
1861
-
1862
1809
  <!-- Add Btn -->
1863
1810
  <q-page-sticky
1864
1811
  v-if="hasAddBtn && (addFabBtn === undefined ? !!pluginOptions.datatable?.addFabBtn : addFabBtn)"
@@ -8,7 +8,7 @@
8
8
 
9
9
  <script lang="ts" setup>
10
10
  import { useDialogPluginComponent, useQuasar } from 'quasar'
11
- import { computed, ref } from 'vue'
11
+ import { computed } from 'vue'
12
12
  import { useMyth } from '../../composable'
13
13
  import type { MFrameDialogProps as Props } from '../../types'
14
14
 
@@ -17,22 +17,29 @@ interface P {
17
17
  height?: Props['height'];
18
18
  noDownload?: boolean;
19
19
  iframeProps?: Record<string, any>;
20
+ image?: boolean;
20
21
  }
21
22
 
22
23
  const props = defineProps<P>()
23
- const $q = useQuasar()
24
24
  defineEmits([
25
25
  ...useDialogPluginComponent.emits
26
26
  ])
27
27
  const { dialogRef, onDialogHide, onDialogOK } = useDialogPluginComponent()
28
+ const $q = useQuasar()
29
+ $q.loading.show()
28
30
  const { openWindow } = useMyth()
29
31
 
30
- const loading = ref(!0)
32
+ const loading = computed({
33
+ get: () => $q.loading.isActive,
34
+ set: (v: boolean) => (v ? $q.loading.show() : $q.loading.hide())
35
+ })
31
36
  const src = computed<string | null>(() => props.url || null)
32
37
  const onCloseClick = () => {
33
38
  onDialogOK()
34
39
  }
35
-
40
+ const onLoad = () => {
41
+ $q.loading.hide()
42
+ }
36
43
  const onDownloadClick = () => {
37
44
  if (src.value) {
38
45
  openWindow(src.value)
@@ -49,46 +56,71 @@ defineOptions({
49
56
  ref="dialogRef"
50
57
  maximized
51
58
  no-shake
52
- transition-hide="slide-up"
53
- transition-show="slide-down"
59
+ transition-hide="fade"
60
+ transition-show="fade"
54
61
  @hide="onDialogHide"
55
62
  >
56
- <q-card class="q-dialog-plugin">
57
- <q-card-section style="max-height: 80px">
58
- <MContainer
59
- dense
60
- fluid
63
+ <div class="q-dialog-plugin">
64
+ <MContainer
65
+ class="no-padding"
66
+ dense
67
+ fluid
68
+ >
69
+ <q-card
70
+ flat
71
+ square
61
72
  >
62
- <MRow class="items-center">
63
- <MBtn
64
- v-if="!noDownload"
65
- icon="ion-ios-open"
66
- label="labels.download"
67
- @click="onDownloadClick()"
68
- />
69
- <q-space />
70
- <MBtn
71
- flat
72
- icon="close"
73
- padding="3px"
74
- text-color="body"
75
- @click="onCloseClick()"
73
+ <q-card-section style="max-height: 80px">
74
+ <MRow class="items-center">
75
+ <MBtn
76
+ v-if="!noDownload"
77
+ icon="ion-ios-open"
78
+ label="labels.download"
79
+ @click="onDownloadClick()"
80
+ />
81
+ <q-space />
82
+ <MBtn
83
+ flat
84
+ icon="close"
85
+ padding="3px"
86
+ text-color="body"
87
+ @click="onCloseClick()"
88
+ />
89
+ </MRow>
90
+ </q-card-section>
91
+ <q-separator />
92
+ <template v-if="!!src">
93
+ <q-img
94
+ v-if="image"
95
+ :height="`${$q.screen.height - 70}px`"
96
+ :src="src"
97
+ class="self-center"
98
+ fit="contain"
99
+ no-spinner
100
+ @error="onLoad()"
101
+ @load="onLoad()"
102
+ >
103
+ <template #loading>
104
+ <q-skeleton
105
+ height="100%"
106
+ width="100%"
107
+ />
108
+ </template>
109
+ </q-img>
110
+ <iframe
111
+ v-else
112
+ :height="height ?? ($q.screen.height - 80) + 'px'"
113
+ :src="src"
114
+ frameborder="0"
115
+ style="width: 100%;"
116
+ v-bind="iframeProps"
117
+ width="100%"
118
+ @load="loading = !1"
76
119
  />
77
- </MRow>
78
- </MContainer>
79
- </q-card-section>
80
- <template v-if="!!src">
81
- <iframe
82
- :height="height ?? ($q.screen.height - 80) + 'px'"
83
- :src="src"
84
- frameborder="0"
85
- v-bind="iframeProps"
86
- width="100%"
87
- @load="loading = !1"
88
- />
89
- <slot />
90
- <MInnerLoading :showing="loading" />
91
- </template>
92
- </q-card>
120
+ <slot />
121
+ </template>
122
+ </q-card>
123
+ </MContainer>
124
+ </div>
93
125
  </q-dialog>
94
126
  </template>
@@ -9,7 +9,6 @@ import type {
9
9
  MDatatableOptions,
10
10
  MDatatablePagination,
11
11
  MDatatableProps,
12
- MDatatableScope,
13
12
  MDtExportOptions,
14
13
  MDtHeadersParameter,
15
14
  MDtItem,
@@ -22,6 +21,7 @@ import { is, useQuasar } from 'quasar'
22
21
  import { useRoute, useRouter } from 'vue-router'
23
22
  import type { AxiosRequestConfig } from 'axios'
24
23
  import { useResetForm, useSetFormValues } from 'vee-validate'
24
+ import { MFrameDialog } from '../components'
25
25
 
26
26
  const initPaginationOptions: MDatatablePagination = {
27
27
  sortBy: undefined,
@@ -824,26 +824,15 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>) => {
824
824
  const rowsPerPageOptions = computed(() => props.rowsPerPageOptions)
825
825
  const getRowsPerPageOptions = computed<any[]>(() => endReach.value ? [0] : (rowsPerPageOptions.value || [0]))
826
826
 
827
- const imageDialog = reactive<MDatatableScope['imageDialog']>({
828
- value: !1,
829
- src: undefined,
830
- asAttachment: undefined
831
- })
832
- const openImageDialog = (src: string, opts?: { asAttachment?: boolean }) => {
833
- imageDialog.src = src
834
- imageDialog.asAttachment = opts?.asAttachment
835
- nextTick(() => {
836
- imageDialog.value = !0
837
- })
838
- }
839
- const closeImageDialog = () => {
840
- imageDialog.value = !1
841
- nextTick(() => {
842
- imageDialog.src = undefined
843
- imageDialog.asAttachment = undefined
827
+ const openAttachmentDialog = (src: string, opts?: { image?: boolean }) => {
828
+ $q.dialog({
829
+ component: MFrameDialog,
830
+ componentProps: {
831
+ url: src,
832
+ ...opts
833
+ }
844
834
  })
845
835
  }
846
-
847
836
  const tableOptions = reactive<MDatatableOptions>({
848
837
  search,
849
838
  loading,
@@ -874,9 +863,7 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>) => {
874
863
  firstSelectedItem,
875
864
  updateDatatableItem,
876
865
  updateSelectedItems,
877
- imageDialog,
878
- openImageDialog,
879
- closeImageDialog,
866
+ openAttachmentDialog,
880
867
  setFilterOptions,
881
868
  updateFilterOptions,
882
869
  openFilterDialog,
@@ -957,7 +944,6 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>) => {
957
944
  downloadingExample,
958
945
  onDownloadExample,
959
946
 
960
- imageDialog,
961
947
  onRowContextmenu,
962
948
  getRowsPerPageOptions,
963
949
  getShowSelection,
@@ -1053,7 +1039,6 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>) => {
1053
1039
  activeContextItems,
1054
1040
  datatableItemsScope,
1055
1041
  onCloneItem,
1056
- openImageDialog,
1057
- closeImageDialog
1042
+ openAttachmentDialog
1058
1043
  }
1059
1044
  }
@@ -13,6 +13,7 @@ export type MFrameDialogProps = {
13
13
  height?: string;
14
14
  noDownload?: boolean;
15
15
  iframeProps?: Record<string, any>;
16
+ image?: boolean;
16
17
  }
17
18
 
18
19
  export type MFrameDialogSlots = {
@@ -156,9 +156,6 @@ export type MDatatableScope = {
156
156
  firstSelectedItem: ComputedRef<MDtItem>;
157
157
  updateDatatableItem: (item: MDtItem, index?: MDtItemIndex) => void;
158
158
  updateSelectedItems: ((selected: MDtItem[]) => void);
159
- imageDialog: UnwrapNestedRefs<{ value: boolean, src?: string, asAttachment?: boolean }>;
160
- openImageDialog: (src: string, opts?: { asAttachment?: boolean }) => void;
161
- closeImageDialog: () => void;
162
159
  setFilterOptions: (data: any) => void;
163
160
  updateFilterOptions: (data: any) => void;
164
161
  openFilterDialog: () => void;