@mythpe/quasar-ui-qui 0.3.10 → 0.3.12

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.10",
3
+ "version": "0.3.12",
4
4
  "description": "MyTh Quasar UI Kit App Extension",
5
5
  "author": {
6
6
  "name": "MyTh Ahmed Faiz",
@@ -91,6 +91,7 @@ type Props = {
91
91
  descColumns?: MDatatableProps['descColumns'];
92
92
  help?: MDatatableProps['help'];
93
93
  noWrapBtn?: boolean;
94
+ lockValue?: MDatatableProps['lockValue'];
94
95
  }
95
96
 
96
97
  const props = withDefaults(defineProps<Props>(), {
@@ -160,7 +161,8 @@ const props = withDefaults(defineProps<Props>(), {
160
161
  copyColumns: undefined,
161
162
  descColumns: undefined,
162
163
  help: undefined,
163
- noWrapBtn: undefined
164
+ noWrapBtn: undefined,
165
+ lockValue: undefined
164
166
  })
165
167
 
166
168
  interface Emits {
@@ -214,6 +216,7 @@ const {
214
216
  onUpdateSelectedItems,
215
217
  pagination,
216
218
  search,
219
+ onSearchInput,
217
220
  searchColumnsRef,
218
221
  getSearchColumnsHeaders,
219
222
  isSearchSelectedAll,
@@ -412,6 +415,22 @@ const copyColumnsProp = computed<string[]>(() => toValue(props.copyColumns || []
412
415
  const descColumnsProp = computed<string[]>(() => toValue(props.descColumns || []))
413
416
  const noWrapBtnProp = computed(() => getProp.value('noWrapBtn'))
414
417
  const wrapCellsRef = ref<boolean>(!1)
418
+ const onSearchEnter = () => {
419
+ if (loading.value) {
420
+ return
421
+ }
422
+ refreshNoUpdate()
423
+ }
424
+ const lockValueProp = computed<string>(() => getProp.value('lockValue') || 'id')
425
+ const lockSearch = computed<boolean>(() => searchColumnsRef.value.length === 1 && searchColumnsRef.value[0] === lockValueProp.value)
426
+ const tempSearch = ref<string[]>([])
427
+ const onLockSearch = () => {
428
+ if (!lockSearch.value) {
429
+ tempSearch.value = toValue(searchColumnsRef)
430
+ }
431
+ searchColumnsRef.value = !lockSearch.value ? [lockValueProp.value] : tempSearch.value
432
+ // lockSearch.value = !lockSearch.value
433
+ }
415
434
  onMounted(() => {
416
435
  wrapCellsRef.value = getProp.value('wrapCells') ?? !1
417
436
  refresh()
@@ -533,7 +552,7 @@ defineExpose({
533
552
  v-model:fullscreen="fullscreen"
534
553
  v-model:pagination="pagination"
535
554
  v-model:selected="selected"
536
- :class="`m-datatable ` + (isSmall ? 'm-datatable-grid' : '')"
555
+ :class="['m-datatable',{'m-datatable-grid' : isSmall}]"
537
556
  :columns="getHeaders"
538
557
  :filter="search"
539
558
  :grid="isGrid"
@@ -544,6 +563,7 @@ defineExpose({
544
563
  :selection="getShowSelection ? (multiSelection ? 'multiple' : 'single') : 'none'"
545
564
  :visible-columns="visibleHeaders"
546
565
  card-container-class="m-datatable-container"
566
+ color="primary"
547
567
  table-class="m-datatable-container"
548
568
  v-bind="{
549
569
  virtualScroll: !0,
@@ -754,10 +774,10 @@ defineExpose({
754
774
  name="top-search"
755
775
  />
756
776
  <MInput
757
- v-if="!hideSearch && !formDialogModel"
758
- v-model="search"
777
+ v-if="!hideSearch"
759
778
  :debounce="searchDebounce"
760
779
  :dense="dense === undefined ? (pluginOptions.datatable?.dense !== undefined ? pluginOptions.datatable?.dense : !0) : dense"
780
+ :model-value="search"
761
781
  :placeholder="searchPlaceholder"
762
782
  autocomplete="none"
763
783
  col="12"
@@ -765,6 +785,8 @@ defineExpose({
765
785
  name="search"
766
786
  outlined
767
787
  v-bind="pluginOptions.dt?.searchInput?.props as any"
788
+ @update:model-value="onSearchInput($event)"
789
+ @keyup.enter="onSearchEnter()"
768
790
  >
769
791
  <template #prepend>
770
792
  <q-icon
@@ -871,6 +893,16 @@ defineExpose({
871
893
  </MTooltip>
872
894
  </q-btn>
873
895
  </template>
896
+ <template #append>
897
+ <q-btn
898
+ :icon="`ion-ios-${lockSearch ? 'magnet' : 'lock'}`"
899
+ fab-mini
900
+ flat
901
+ @click="onLockSearch"
902
+ >
903
+ <q-tooltip>{{ __(`labels.${lockSearch ? 'unlock' : 'lock'}_search`, { name: __(lockValueProp) }) }}</q-tooltip>
904
+ </q-btn>
905
+ </template>
874
906
  </MInput>
875
907
  <slot
876
908
  :dt="datatableItemsScope"
@@ -85,10 +85,10 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>) => {
85
85
  return !0
86
86
  })
87
87
 
88
- const filterDialogModel = ref(!1)
89
- const showDialogModel = ref(!1)
90
- const formDialogModel = ref(!1)
91
- const isUpdateDialog = ref(!1)
88
+ const filterDialogModel = ref<boolean>(!1)
89
+ const showDialogModel = ref<boolean>(!1)
90
+ const formDialogModel = ref<boolean>(!1)
91
+ const isUpdateDialog = ref<boolean>(!1)
92
92
  const dialogItem = ref<MDtItem | undefined>(undefined)
93
93
  const setDialogItem = (value: any) => {
94
94
  dialogItem.value = toValue(value) as any
@@ -133,7 +133,11 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>) => {
133
133
 
134
134
  const meta = ref<MDatatableMetaServer>({ ...initMetaServer })
135
135
  const pagination = ref<MDatatablePagination>({ ...initPaginationOptions })
136
- const search = ref<string | null>(null)
136
+ const search = ref<string | null | undefined>(undefined)
137
+ const onSearchInput = (value: any) => {
138
+ if (value === search.value) return
139
+ search.value = value
140
+ }
137
141
  const searchColumnsRef = ref<string[]>([])
138
142
  const getSearchColumnsHeaders = computed(() => getHeaders.value.filter(e => e.field !== props.controlKey))
139
143
  const isSearchSelectedAll = computed(() => searchColumnsRef.value.length === getSearchColumnsHeaders.value.length)
@@ -943,6 +947,7 @@ export const useDtHelpers = (options: MaybeRefOrGetter<MDatatableProps>) => {
943
947
  meta,
944
948
  pagination,
945
949
  search,
950
+ onSearchInput,
946
951
  searchColumnsRef,
947
952
  getSearchColumnsHeaders,
948
953
  isSearchSelectedAll,
@@ -83,7 +83,7 @@ export type MDatatableOptions = {
83
83
  // Table is loading
84
84
  loading: Ref<boolean>;
85
85
  // Search input
86
- search: Ref<string | null>;
86
+ search: Ref<string | null | undefined>;
87
87
  // Table pagination
88
88
  pagination: Ref<MDatatablePagination>;
89
89
  // Server meta data
@@ -332,6 +332,10 @@ export type MDatatableProps<I extends GenericFormValues = GenericFormValues> = O
332
332
  * Show, hide wrap the button in the table.
333
333
  */
334
334
  noWrapBtn?: boolean;
335
+ /**
336
+ * Column name to lock the value.
337
+ */
338
+ lockValue?: string;
335
339
  }
336
340
 
337
341
  export interface MDtAvatarProps extends QAvatarProps {