@drax/settings-vue 0.29.0 → 0.30.0

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
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.29.0",
6
+ "version": "0.30.0",
7
7
  "type": "module",
8
8
  "main": "./src/index.ts",
9
9
  "module": "./src/index.ts",
@@ -24,9 +24,10 @@
24
24
  "format": "prettier --write src/"
25
25
  },
26
26
  "dependencies": {
27
- "@drax/common-front": "^0.29.0",
28
- "@drax/settings-front": "^0.29.0",
29
- "@drax/settings-share": "^0.29.0"
27
+ "@drax/common-front": "^0.30.0",
28
+ "@drax/identity-vue": "^0.30.0",
29
+ "@drax/settings-front": "^0.30.0",
30
+ "@drax/settings-share": "^0.30.0"
30
31
  },
31
32
  "peerDependencies": {
32
33
  "pinia": "^2.2.2",
@@ -63,5 +64,5 @@
63
64
  "vue-tsc": "^2.1.10",
64
65
  "vuetify": "^3.7.1"
65
66
  },
66
- "gitHead": "0a3f69beb23eb8768ebe7a3d41d61d4a6d40b104"
67
+ "gitHead": "f7f06578327be29f20dcb7e2c8a2eac9e9145cab"
67
68
  }
@@ -0,0 +1,90 @@
1
+ <script setup lang="ts">
2
+ import {useSetting} from "../composables/UseSetting";
3
+ import SettingField from "./SettingField.vue";
4
+ import SettingEditor from "./SettingEditor.vue";
5
+ import {onMounted, ref} from "vue";
6
+ import {useI18n} from "vue-i18n";
7
+ import type {ISetting} from "@drax/settings-share";
8
+
9
+ const {fetchSettings, settingsGrouped} = useSetting()
10
+ const {t, te} = useI18n()
11
+
12
+ onMounted(async () => {
13
+ await fetchSettings()
14
+ })
15
+
16
+ const settingEditing = ref()
17
+ const editing = ref(false)
18
+
19
+ function edit(setting: ISetting) {
20
+ settingEditing.value = {...setting}
21
+ editing.value = true
22
+ }
23
+
24
+ function clearEdit() {
25
+ editing.value = false
26
+ settingEditing.value = null
27
+ }
28
+
29
+ </script>
30
+
31
+ <template>
32
+ <div>
33
+ <h1 class="mb-6 text-h2">Settings</h1>
34
+
35
+ <setting-editor
36
+ v-if="editing"
37
+ v-model="editing"
38
+ :setting="settingEditing"
39
+ @updateValue="clearEdit"
40
+ ></setting-editor>
41
+
42
+ <v-row>
43
+ <v-col cols="12" v-for="(category,k) in settingsGrouped" class="mt-4">
44
+ <v-card >
45
+ <v-card-title>
46
+ <h4 class="text-h4 mt-2">{{ k }}</h4>
47
+ </v-card-title>
48
+ <v-card-text>
49
+ <v-card border flat rounded="xl" v-for="(setting, i) in category" :key="i" class="mt-3" >
50
+ <v-card-title class="d-flex">
51
+ <h5 class="text-h5 mt-2">{{ setting.label }}</h5>
52
+ <v-spacer></v-spacer>
53
+ <v-chip v-if="setting.permission" density="compact" color="red" class="mt-2">
54
+ {{t('common.permission')}}:
55
+ {{ te('permission.'+setting.permission) ? t('permission.'+setting.permission) : setting.permission }}
56
+ </v-chip>
57
+ <v-chip v-else-if="setting.public" color="green" density="compact" class="mt-2">Public</v-chip>
58
+ <v-chip v-else color="orange" density="compact" class="mt-2">Private</v-chip>
59
+ </v-card-title>
60
+ <v-card-text class="px-12 pt-3">
61
+ <setting-field
62
+ v-model="setting.value"
63
+ :setting="setting"
64
+
65
+ ></setting-field>
66
+ </v-card-text>
67
+ <v-card-actions>
68
+ <v-spacer></v-spacer>
69
+ <v-btn
70
+ class="mr-1 mt-1"
71
+ color="blue"
72
+ variant="text"
73
+ @click="edit(setting)"
74
+ >{{t('action.edit')}}</v-btn>
75
+ </v-card-actions>
76
+
77
+ </v-card>
78
+
79
+
80
+ </v-card-text>
81
+ </v-card>
82
+ </v-col>
83
+
84
+ </v-row>
85
+ </div>
86
+ </template>
87
+
88
+ <style scoped>
89
+
90
+ </style>
@@ -56,7 +56,6 @@ const validateNumberList = computed(() => {
56
56
 
57
57
  <!--string-->
58
58
  <v-text-field v-if="setting.type === 'string'"
59
- prepend-icon="text_snippet"
60
59
  :name="setting.key"
61
60
  v-model="valueModel"
62
61
  :label="setting.label"
@@ -66,6 +65,7 @@ const validateNumberList = computed(() => {
66
65
  :prefix="setting.prefix"
67
66
  :suffix="setting.suffix"
68
67
  :readonly="!editing"
68
+ :hide-details="!editing"
69
69
  :variant="variant"
70
70
  >
71
71
  </v-text-field>
@@ -73,7 +73,6 @@ const validateNumberList = computed(() => {
73
73
  <!--longString-->
74
74
  <v-textarea v-if="setting.type === 'longString'"
75
75
  :rows="2"
76
- prepend-icon="text_snippet"
77
76
  :name="setting.key"
78
77
  v-model="valueModel"
79
78
  :label="setting.label"
@@ -83,6 +82,7 @@ const validateNumberList = computed(() => {
83
82
  :prefix="setting.prefix"
84
83
  :suffix="setting.suffix"
85
84
  :readonly="!editing"
85
+ :hide-details="!editing"
86
86
  :variant="variant"
87
87
  >
88
88
  </v-textarea>
@@ -90,7 +90,6 @@ const validateNumberList = computed(() => {
90
90
 
91
91
  <!--password-->
92
92
  <v-text-field v-if=" setting.type === 'password'"
93
- prepend-icon="text_snippet"
94
93
  :name="setting.key"
95
94
  v-model="valueModel"
96
95
  :label="setting.label"
@@ -103,13 +102,13 @@ const validateNumberList = computed(() => {
103
102
  :prefix="setting.prefix"
104
103
  :suffix="setting.suffix"
105
104
  :readonly="!editing"
105
+ :hide-details="!editing"
106
106
  :variant="variant"
107
107
  >
108
108
  </v-text-field>
109
109
 
110
110
  <!--number-->
111
111
  <v-text-field v-if="setting.type === 'number'"
112
- prepend-icon="text_snippet"
113
112
  type="number"
114
113
  :name="setting.key"
115
114
  v-model.number="valueModel"
@@ -120,13 +119,13 @@ const validateNumberList = computed(() => {
120
119
  :prefix="setting.prefix"
121
120
  :suffix="setting.suffix"
122
121
  :readonly="!editing"
122
+ :hide-details="!editing"
123
123
  :variant="variant"
124
124
  >
125
125
  </v-text-field>
126
126
 
127
127
  <!--boolean-->
128
128
  <v-checkbox v-if="setting.type === 'boolean'"
129
- prepend-icon="text_snippet"
130
129
  :name="setting.key"
131
130
  :value="true"
132
131
  v-model="valueModel"
@@ -134,6 +133,7 @@ const validateNumberList = computed(() => {
134
133
  :placeholder="setting.label"
135
134
  color="secondary"
136
135
  :readonly="!editing"
136
+ :hide-details="!editing"
137
137
  :variant="variant"
138
138
  >
139
139
  </v-checkbox>
@@ -141,7 +141,6 @@ const validateNumberList = computed(() => {
141
141
 
142
142
  <!--enum-->
143
143
  <v-select v-if="setting.type === 'enum'"
144
- prepend-icon="text_snippet"
145
144
  :name="setting.key"
146
145
  :items="setting.options"
147
146
  v-model="valueModel"
@@ -151,6 +150,7 @@ const validateNumberList = computed(() => {
151
150
  :prefix="setting.prefix"
152
151
  :suffix="setting.suffix"
153
152
  :readonly="!editing"
153
+ :hide-details="!editing"
154
154
  :variant="variant"
155
155
  >
156
156
  </v-select>
@@ -160,13 +160,13 @@ const validateNumberList = computed(() => {
160
160
  <v-combobox v-if="setting.type === 'stringList'"
161
161
  chips
162
162
  multiple
163
- prepend-icon="list"
164
163
  :name="setting.key"
165
164
  v-model="valueModel"
166
165
  :label="setting.label"
167
166
  :placeholder="setting.label"
168
167
  color="secondary"
169
168
  :readonly="!editing"
169
+ :hide-details="!editing"
170
170
  :variant="variant"
171
171
  >
172
172
  </v-combobox>
@@ -175,7 +175,6 @@ const validateNumberList = computed(() => {
175
175
  <v-combobox v-if="setting.type === 'numberList'"
176
176
  chips
177
177
  multiple
178
- prepend-icon="list"
179
178
  :name="setting.key"
180
179
  v-model="valueModel"
181
180
  :label="setting.label"
@@ -183,6 +182,7 @@ const validateNumberList = computed(() => {
183
182
  color="secondary"
184
183
  :rules="validateNumberList"
185
184
  :readonly="!editing"
185
+ :hide-details="!editing"
186
186
  :variant="variant"
187
187
  >
188
188
  </v-combobox>
@@ -191,7 +191,6 @@ const validateNumberList = computed(() => {
191
191
  <v-select v-if="setting.type === 'enumList'"
192
192
  multiple
193
193
  chips
194
- prepend-icon="text_snippet"
195
194
  :name="setting.key"
196
195
  :items="setting.options"
197
196
  v-model="valueModel"
@@ -201,6 +200,7 @@ const validateNumberList = computed(() => {
201
200
  :prefix="setting.prefix"
202
201
  :suffix="setting.suffix"
203
202
  :readonly="!editing"
203
+ :hide-details="!editing"
204
204
  :variant="variant"
205
205
  >
206
206
  </v-select>
@@ -0,0 +1,39 @@
1
+ <script setup lang="ts">
2
+ import {useSetting} from "../composables/UseSetting";
3
+ import {useI18n} from "vue-i18n";
4
+
5
+ const {settings} = useSetting()
6
+ const {t, te} = useI18n()
7
+
8
+ </script>
9
+
10
+ <template>
11
+ <v-card variant="outlined" class="ma-2">
12
+ <v-card-title class="text-h4">Settings</v-card-title>
13
+ <v-divider></v-divider>
14
+ <v-card-text>
15
+ <h5 class="text-h5">Public (No requiere auth)</h5>
16
+ <v-chip v-for="(v,k) in settings.filter(s => s.public && !s.permission)" :key="k" class="mt-4" color="blue">
17
+ <b>{{ v.label }}</b>:{{ v.value }}
18
+ </v-chip>
19
+ </v-card-text>
20
+ <v-divider></v-divider>
21
+ <v-card-text>
22
+ <h5 class="text-h5">Private (Requiere auth)</h5>
23
+ <v-chip v-for="(v,k) in settings.filter(s => !s.public && !s.permission)" :key="k" class="mt-4" color="orange">
24
+ <b>{{ v.label }}</b>:{{ v.value }}
25
+ </v-chip>
26
+ </v-card-text>
27
+ <v-divider></v-divider>
28
+ <v-card-text>
29
+ <h5 class="text-h5">Permission (Requiere Permiso Especifico)</h5>
30
+ <v-chip v-for="(v,k) in settings.filter(s => s.permission)" :key="k" class="mt-4" color="purple">
31
+ <b>{{ v.label }}</b>({{v.permission}}):{{ v.value }}
32
+ </v-chip>
33
+ </v-card-text>
34
+ </v-card>
35
+ </template>
36
+
37
+ <style scoped>
38
+
39
+ </style>
@@ -0,0 +1,113 @@
1
+ <script setup lang="ts">
2
+ import {useSetting} from "../composables/UseSetting";
3
+ import SettingField from "./SettingField.vue";
4
+ import SettingEditor from "./SettingEditor.vue";
5
+ import {onMounted, ref} from "vue";
6
+ import {useI18n} from "vue-i18n";
7
+ import type {ISetting} from "@drax/settings-share";
8
+
9
+ const {fetchSettings, settingsGrouped} = useSetting()
10
+ const {t, te} = useI18n()
11
+
12
+ onMounted(async () => {
13
+ await fetchSettings()
14
+ })
15
+
16
+ const settingEditing = ref()
17
+ const editing = ref(false)
18
+
19
+ function edit(setting: ISetting) {
20
+ settingEditing.value = {...setting}
21
+ editing.value = true
22
+ }
23
+
24
+ function clearEdit() {
25
+ editing.value = false
26
+ settingEditing.value = null
27
+ }
28
+
29
+ </script>
30
+
31
+ <template>
32
+ <div>
33
+ <h1 class="mb-6 text-h2">Settings</h1>
34
+
35
+ <setting-editor
36
+ v-if="editing"
37
+ v-model="editing"
38
+ :setting="settingEditing"
39
+ @updateValue="clearEdit"
40
+ ></setting-editor>
41
+
42
+ <v-row>
43
+ <v-col cols="12" v-for="(category,k) in settingsGrouped" class="mt-4">
44
+ <v-card>
45
+ <v-card-title>
46
+ <h4 class="text-h4 mt-2">{{ k }}</h4>
47
+ </v-card-title>
48
+ <v-card-text>
49
+
50
+ <v-data-table
51
+ hide-default-footer
52
+ :headers="[
53
+ { title: t('common.identifier'), key: 'key', width: '130px', minWidth: '130px' },
54
+ { title: t('common.value'), key: 'value' },
55
+ { title: t('common.type'), key: 'type', width: '120px', minWidth: '120px' },
56
+ { title: t('common.scope'), key:'scope', width: '170px', minWidth: '170px' },
57
+ { title: t('common.actions'), key: 'actions', width: '70px' },
58
+
59
+ ]"
60
+ :items="category"
61
+
62
+ >
63
+
64
+ <template v-slot:item.value="{ item }">
65
+ {{ item.prefix }}
66
+ <template v-if="item.type === 'boolean'">
67
+ <v-chip :color="item.value === true ? 'green' : 'red' " tile>
68
+ {{ item.value }}
69
+ </v-chip>
70
+ </template>
71
+ <template v-else-if="['stringList','numberList','enumList'].includes(item.type)">
72
+ <v-chip v-for="(v,i) in item.value" :key="i">{{v}}</v-chip>
73
+ </template>
74
+ <template v-else>
75
+ {{item.value}}
76
+ </template>
77
+ {{ item.suffix }}
78
+ </template>
79
+
80
+ <template v-slot:item.scope="{ item }">
81
+ <div style="width: 200px;">
82
+ <v-chip v-if="item?.permission" density="compact" color="purple">
83
+ {{
84
+ te('permission.' + item?.permission) ? t('permission.' + item?.permission) : item?.permission
85
+ }}
86
+ </v-chip>
87
+ <v-chip v-else-if="item?.public" color="blue" density="compact">Public</v-chip>
88
+ <v-chip v-else color="orange" density="compact">Private</v-chip>
89
+ </div>
90
+ </template>
91
+
92
+ <template v-slot:item.actions="{ item }">
93
+ <v-btn
94
+ class="mr-1 mt-1"
95
+ color="blue"
96
+ variant="text"
97
+ icon="mdi-pencil"
98
+ @click="edit(item)"
99
+ ></v-btn>
100
+ </template>
101
+ </v-data-table>
102
+
103
+ </v-card-text>
104
+ </v-card>
105
+ </v-col>
106
+
107
+ </v-row>
108
+ </div>
109
+ </template>
110
+
111
+ <style scoped>
112
+
113
+ </style>
@@ -1,6 +1,7 @@
1
1
  import {useSettingStore} from "../stores/UseSettingStore";
2
2
  import {computed} from "vue";
3
3
  import {SettingProviderFactory} from "@drax/settings-front";
4
+ import {useAuthStore} from "@drax/identity-vue";
4
5
  import type {ISetting} from "@drax/settings-share";
5
6
 
6
7
  export function useSetting() {
@@ -9,6 +10,33 @@ export function useSetting() {
9
10
  const provider = SettingProviderFactory.getInstance()
10
11
 
11
12
 
13
+ async function suscribeAuth(): Promise<any> {
14
+ const authStore = useAuthStore()
15
+ authStore.$onAction(({name, after}) => {
16
+ if (name === 'setAuthUser' || name === 'clearAuth') {
17
+ after(async () => {
18
+ // console.log('Fetch settings on login/logout')
19
+ await fetchSettings()
20
+ })
21
+ }
22
+ })
23
+ }
24
+
25
+ async function fetchSettings(): Promise<ISetting[]> {
26
+ try {
27
+ store.setLoading(true)
28
+ const settings = await provider.fetchAll()
29
+ store.setSettings(settings)
30
+ return settings
31
+ } catch (e) {
32
+ console.error("UseSettings fetchSettings", e)
33
+ throw e
34
+ } finally {
35
+ store.setLoading(false)
36
+ }
37
+ }
38
+
39
+
12
40
  const loading = computed({
13
41
  get() {
14
42
  return store.loading
@@ -40,19 +68,7 @@ export function useSetting() {
40
68
  })
41
69
 
42
70
 
43
- async function fetchSettings(): Promise<ISetting[]> {
44
- try {
45
- store.setLoading(true)
46
- const settings = await provider.fetchAll()
47
- store.setSettings(settings)
48
- return settings
49
- } catch (e) {
50
- console.error("UseSettings fetchSettings", e)
51
- throw e
52
- } finally {
53
- store.setLoading(false)
54
- }
55
- }
71
+
56
72
 
57
73
  async function updateSettingValue(id:string,value:string): Promise<ISetting> {
58
74
  try {
@@ -72,6 +88,7 @@ export function useSetting() {
72
88
 
73
89
  return {
74
90
  fetchSettings,
91
+ suscribeAuth,
75
92
  updateSettingValue,
76
93
 
77
94
  settings,
package/src/index.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import {useSetting} from "./composables/UseSetting";
2
2
  import {useSettingStore} from "./stores/UseSettingStore";
3
- import SettingConfig from "./components/SettingConfig.vue";
3
+ import SettingCardConfig from "./components/SettingCardConfig.vue";
4
+ import SettingTableConfig from "./components/SettingTableConfig.vue";
5
+ import SettingLoaded from "./components/SettingLoaded.vue";
4
6
  import SettingPage from "./pages/SettingPage.vue";
5
7
  import SettingRoutes from "./routes/SettingRoutes";
6
8
 
@@ -8,7 +10,9 @@ import SettingRoutes from "./routes/SettingRoutes";
8
10
  export{
9
11
  useSetting,
10
12
  useSettingStore,
11
- SettingConfig,
13
+ SettingCardConfig,
14
+ SettingTableConfig,
15
+ SettingLoaded,
12
16
  SettingPage,
13
17
  SettingRoutes
14
18
  }
@@ -0,0 +1,14 @@
1
+ <script setup lang="ts">
2
+ import SettingCardConfig from "../components/SettingCardConfig.vue";
3
+ </script>
4
+
5
+ <template>
6
+ <v-container max-width="1200">
7
+ <setting-card-config></setting-card-config>
8
+ </v-container>
9
+
10
+ </template>
11
+
12
+ <style scoped>
13
+
14
+ </style>
@@ -1,10 +1,10 @@
1
1
  <script setup lang="ts">
2
- import SettingConfig from "../components/SettingConfig.vue";
2
+ import SettingTableConfig from "../components/SettingTableConfig.vue";
3
3
  </script>
4
4
 
5
5
  <template>
6
- <v-container max-width="900">
7
- <setting-config></setting-config>
6
+ <v-container max-width="1200">
7
+ <setting-table-config></setting-table-config>
8
8
  </v-container>
9
9
 
10
10
  </template>
@@ -1,4 +1,5 @@
1
1
  import SettingPage from '../pages/SettingPage.vue'
2
+ import SettingCardPage from '../pages/SettingCardPage.vue'
2
3
 
3
4
  const routes = [
4
5
  {
@@ -10,6 +11,15 @@ const routes = [
10
11
  permission: 'setting:manage'
11
12
  }
12
13
  },
14
+ {
15
+ name: 'SettingCardPage',
16
+ path: '/settings/card',
17
+ component: SettingCardPage,
18
+ meta: {
19
+ auth: true,
20
+ permission: 'setting:manage'
21
+ }
22
+ },
13
23
 
14
24
  ]
15
25
 
@@ -1,78 +0,0 @@
1
- <script setup lang="ts">
2
- import {useSetting} from "../composables/UseSetting";
3
- import SettingField from "./SettingField.vue";
4
- import SettingEditor from "./SettingEditor.vue";
5
- import {onMounted, ref} from "vue";
6
- import type {ISetting} from "@drax/settings-share";
7
-
8
- const {fetchSettings, settingsGrouped} = useSetting()
9
-
10
- onMounted(async () => {
11
- await fetchSettings()
12
- })
13
-
14
- const settingEditing = ref()
15
- const editing = ref(false)
16
-
17
- function edit(setting: ISetting) {
18
- settingEditing.value = {...setting}
19
- editing.value = true
20
- }
21
-
22
- function clearEdit() {
23
- editing.value = false
24
- settingEditing.value = null
25
- }
26
-
27
- </script>
28
-
29
- <template>
30
- <div>
31
- <h1 class="mb-6">Settings</h1>
32
-
33
- <setting-editor
34
- v-if="editing"
35
- v-model="editing"
36
- :setting="settingEditing"
37
- @updateValue="clearEdit"
38
- ></setting-editor>
39
-
40
- <v-row >
41
- <v-col cols="12" v-for="(category,k) in settingsGrouped">
42
- <v-card>
43
- <v-card-title>
44
- {{ k }}
45
- </v-card-title>
46
- <v-card-text>
47
- <v-row v-for="(setting, i) in category" :key="i">
48
- <v-col cols="9">
49
- <setting-field
50
-
51
- v-model="setting.value"
52
- :setting="setting"
53
- ></setting-field>
54
- </v-col>
55
- <v-col cols="3">
56
- <v-btn
57
- icon="mdi-pencil"
58
- class="mr-1"
59
- variant="text"
60
- color="blue"
61
- slim
62
- @click="edit(setting)"
63
- ></v-btn>
64
- </v-col>
65
- </v-row>
66
-
67
-
68
- </v-card-text>
69
- </v-card>
70
- </v-col>
71
-
72
- </v-row>
73
- </div>
74
- </template>
75
-
76
- <style scoped>
77
-
78
- </style>