@finema/core 1.4.54 → 1.4.55

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/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "1.4.54",
3
+ "version": "1.4.55",
4
4
  "configKey": "core",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.7.4"
package/dist/module.mjs CHANGED
@@ -2,7 +2,7 @@ import { defineNuxtModule, createResolver, installModule, addPlugin, addComponen
2
2
  import 'lodash-es';
3
3
 
4
4
  const name = "@finema/core";
5
- const version = "1.4.54";
5
+ const version = "1.4.55";
6
6
 
7
7
  const colors = {
8
8
  black: "#20243E",
@@ -13,36 +13,36 @@
13
13
  <template v-for="column in columns" #[`${column.key}-data`]="{ row }" :key="column.key">
14
14
  <ColumnNumber
15
15
  v-if="column.type === COLUMN_TYPES.NUMBER"
16
- :value="row[column.key]"
16
+ :value="transformValue(column, row)"
17
17
  :column="column"
18
18
  :row="row"
19
19
  />
20
20
  <ColumnImage
21
21
  v-else-if="column.type === COLUMN_TYPES.IMAGE"
22
- :value="row[column.key]"
22
+ :value="transformValue(column, row)"
23
23
  :column="column"
24
24
  :row="row"
25
25
  />
26
26
  <ColumnDateTime
27
27
  v-else-if="column.type === COLUMN_TYPES.DATE_TIME"
28
- :value="row[column.key]"
28
+ :value="transformValue(column, row)"
29
29
  :column="column"
30
30
  :row="row"
31
31
  />
32
32
  <ColumnDate
33
33
  v-else-if="column.type === COLUMN_TYPES.DATE"
34
- :value="row[column.key]"
34
+ :value="transformValue(column, row)"
35
35
  :column="column"
36
36
  :row="row"
37
37
  />
38
38
  <component
39
39
  :is="column.component"
40
40
  v-else-if="column.type === COLUMN_TYPES.COMPONENT"
41
- :value="row[column.key]"
41
+ :value="transformValue(column, row)"
42
42
  :column="column"
43
43
  :row="row"
44
44
  />
45
- <ColumnText v-else :value="row[column.key]" :column="column" :row="row" />
45
+ <ColumnText v-else :value="transformValue(column, row)" :column="column" :row="row" />
46
46
  </template>
47
47
 
48
48
  <template v-for="(_, slot) of $slots" #[slot]="scope">
@@ -54,7 +54,7 @@
54
54
  ผลลัพธ์ {{ pageBetween }} ของ {{ totalCountWithComma }} รายการ
55
55
  </p>
56
56
  <UPagination
57
- v-if="pageOptions.totalPage > 1 && !isSimplePagination"
57
+ v-if="pageOptions.totalPage > 1 && !isSimplePagination && !isHideBottomPagination"
58
58
  v-model="page"
59
59
  :page-count="pageOptions.limit"
60
60
  :total="pageOptions.totalCount"
@@ -69,7 +69,7 @@
69
69
  </template>
70
70
 
71
71
  <script lang="ts" setup>
72
- import { COLUMN_TYPES, type ITableOptions } from '#core/components/Table/types'
72
+ import { COLUMN_TYPES, type IColumn, type ITableOptions } from '#core/components/Table/types'
73
73
  import ColumnNumber from '#core/components/Table/ColumnNumber.vue'
74
74
  import ColumnImage from '#core/components/Table/ColumnImage.vue'
75
75
  import { computed, type PropType } from 'vue'
@@ -102,6 +102,10 @@ const props = defineProps({
102
102
  type: Boolean as PropType<ITableOptions['isSimplePagination']>,
103
103
  default: false,
104
104
  },
105
+ isHideBottomPagination: {
106
+ type: Boolean as PropType<ITableOptions['isHideBottomPagination']>,
107
+ default: false,
108
+ },
105
109
  })
106
110
 
107
111
  const page = ref(props.pageOptions?.currentPage || 1)
@@ -119,6 +123,10 @@ const pageBetween = computed((): string => {
119
123
  return `${start} - ${end}`
120
124
  })
121
125
 
126
+ const transformValue = (column: IColumn, row: any) => {
127
+ return column.transform ? column.transform(row[column.key], row, column) : row[column.key]
128
+ }
129
+
122
130
  const totalCountWithComma = computed((): string => {
123
131
  return !props.pageOptions!.totalCount
124
132
  ? '0'
@@ -5,6 +5,8 @@
5
5
  :raw-data="itemsByPage"
6
6
  :status="options.status"
7
7
  :page-options="pageOptions"
8
+ :is-simple-pagination="isShowSimplePagination"
9
+ :is-hide-bottom-pagination="options.isHideBottomPagination"
8
10
  @page-change="onPageChange"
9
11
  >
10
12
  <template v-for="(_, slot) of $slots" #[slot]="slotProps">
@@ -17,12 +19,17 @@ import { computed, type PropType, ref } from 'vue'
17
19
  import { type ISimpleTableOptions } from '#core/components/Table/types'
18
20
  import Base from '#core/components/Table/Base.vue'
19
21
  import { initPageOptions } from '#core/composables/loaderPage'
22
+ import { useCoreConfig } from '#core/composables/useConfig'
20
23
 
21
24
  const props = defineProps({
22
25
  options: { type: Object as PropType<ISimpleTableOptions>, required: true },
23
26
  })
24
27
 
25
28
  const currentPage = ref(1)
29
+ const coreConfig = useCoreConfig()
30
+ const isShowSimplePagination = computed(
31
+ (): boolean => props.options.isSimplePagination ?? coreConfig.is_simple_pagination
32
+ )
26
33
 
27
34
  const pageOptions = computed(() => {
28
35
  if (!props.options?.limit) {
@@ -14,6 +14,7 @@
14
14
  :status="options.status"
15
15
  :page-options="options.pageOptions"
16
16
  :is-simple-pagination="isShowSimplePagination"
17
+ :is-hide-bottom-pagination="options.isHideBottomPagination"
17
18
  @page-change="onPageChange"
18
19
  >
19
20
  <template v-for="(_, slot) of $slots" #[slot]="slotProps">
@@ -14,6 +14,7 @@ export interface IColumn<P extends Record<string, any> = Record<string, any>, O
14
14
  class?: string;
15
15
  component?: any;
16
16
  type?: COLUMN_TYPES;
17
+ transform?: (value: any, row: any, column: IColumn) => any;
17
18
  props?: P;
18
19
  on?: O;
19
20
  }
@@ -22,16 +23,15 @@ export interface IBaseTableOptions<T = object> {
22
23
  primary: string;
23
24
  status: IStatus;
24
25
  columns: IColumn[];
26
+ isHideBottomPagination?: boolean;
27
+ isHideTopPagination?: boolean;
28
+ isSimplePagination?: boolean;
25
29
  }
26
30
  export interface ITableOptions<T = object> extends IBaseTableOptions<T> {
27
31
  pageOptions: IPageOptions;
28
32
  isHideToolbar?: boolean;
29
33
  isEnabledSearch?: boolean;
30
34
  searchPlaceholder?: string;
31
- deleteStatus?: IStatus;
32
- isHideBottomPagination?: boolean;
33
- isHideTopPagination?: boolean;
34
- isSimplePagination?: boolean;
35
35
  isPreventRouteChange: boolean;
36
36
  }
37
37
  export interface ISimpleTableOptions<T = object> extends IBaseTableOptions<T> {
@@ -26,7 +26,6 @@ export const createTableOptions = (repo, columns, options) => {
26
26
  pageOptions: get(repo.fetchOptions),
27
27
  columns,
28
28
  status: get(repo.fetchStatus),
29
- deleteStatus: get(repo.deleteStatus),
30
29
  primary: get(repo.fetchOptions).primary ?? config.default_primary_key,
31
30
  isPreventRouteChange: false,
32
31
  ...options
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finema/core",
3
- "version": "1.4.54",
3
+ "version": "1.4.55",
4
4
  "repository": "https://gitlab.finema.co/finema/ui-kit",
5
5
  "license": "MIT",
6
6
  "author": "Finema Dev Core Team",