lesli 5.0.1 → 5.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/lesli_manifest.js +7 -4
  3. data/app/assets/fonts/lesli/Domine/Domine-VariableFont_wght.ttf +0 -0
  4. data/app/assets/fonts/lesli/Domine/OFL.txt +2 -0
  5. data/app/assets/javascripts/lesli/users/passwords.js +776 -0
  6. data/app/assets/javascripts/lesli/users/registrations.js +776 -0
  7. data/app/assets/javascripts/lesli/users/sessions.js +776 -1
  8. data/app/assets/stylesheets/lesli/users/passwords.scss +5 -6
  9. data/app/assets/stylesheets/lesli/users/registrations.scss +5 -6
  10. data/app/assets/stylesheets/lesli/users/sessions.scss +5 -10
  11. data/app/controllers/lesli/application_lesli_controller.rb +0 -1
  12. data/app/controllers/lesli/interfaces/application/logger.rb +9 -9
  13. data/app/controllers/lesli/roles_controller.rb +43 -0
  14. data/{lib/sass/lesli/devise/registrations.scss.erb → app/controllers/lesli/users_controller.rb} +18 -23
  15. data/app/controllers/users/registrations_controller.rb +137 -58
  16. data/app/helpers/lesli/assets_helper.rb +2 -2
  17. data/app/helpers/lesli/general_helper.rb +1 -1
  18. data/app/helpers/lesli/navigation_helper.rb +7 -10
  19. data/app/helpers/lesli/system_helper.rb +1 -1
  20. data/app/lib/lesli/system.rb +7 -3
  21. data/app/mailers/lesli/application_lesli_mailer.rb +199 -0
  22. data/app/mailers/lesli/application_mailer.rb +7 -0
  23. data/app/mailers/lesli/devise_mailer.rb +33 -0
  24. data/app/models/concerns/user_guard.rb +3 -4
  25. data/app/models/lesli/account.rb +29 -0
  26. data/{lib/sass/lesli/pages/passes.scss → app/models/lesli/descriptor.rb} +14 -8
  27. data/app/models/lesli/role.rb +90 -0
  28. data/app/models/lesli/system_controller.rb +1 -0
  29. data/app/models/lesli/user/detail.rb +55 -0
  30. data/{lib/sass/lesli/pages/otps.scss → app/models/lesli/user/role.rb} +13 -9
  31. data/app/models/lesli/user.rb +4 -3
  32. data/app/services/lesli/role_service.rb +45 -0
  33. data/app/services/lesli/user_service.rb +69 -0
  34. data/app/views/devise/passwords/new.html.erb +72 -12
  35. data/app/views/devise/registrations/new.html.erb +146 -28
  36. data/app/views/devise/sessions/new.html.erb +11 -78
  37. data/app/views/devise/shared/_links.html.erb +96 -25
  38. data/app/views/lesli/emails/devise_mailer/confirmation_instructions.html.erb +23 -0
  39. data/app/views/lesli/emails/user_mailer/invitation.html.erb +23 -0
  40. data/app/views/lesli/layouts/application-devise.html.erb +1 -1
  41. data/app/views/lesli/layouts/application-public.html.erb +2 -2
  42. data/app/views/lesli/layouts/mailer.html.erb +13 -0
  43. data/app/views/lesli/layouts/mailer.text.erb +1 -0
  44. data/app/views/lesli/partials/_application-lesli-header.html.erb +27 -41
  45. data/app/views/lesli/partials/_application-lesli-javascript.html.erb +10 -6
  46. data/app/views/lesli/partials/_application-public-javascript.html.erb +12 -8
  47. data/{lib/sass/lesli/devise/confirmations.scss.erb → app/views/lesli/wrappers/_application-devise-simple.erb} +30 -46
  48. data/app/views/lesli/wrappers/{_application-auth.html.erb → _application-devise.html.erb} +15 -0
  49. data/config/initializers/{lesli_defaults.rb → lesli.rb} +4 -2
  50. data/config/locales/translations.en.yml +7 -0
  51. data/config/locales/translations.es.yml +7 -0
  52. data/config/routes.rb +22 -17
  53. data/db/migrate/v1.0/0010000210_create_lesli_roles.rb +1 -1
  54. data/db/{tables/0010003010_create_user_details.rb → migrate/v1.0/0010003010_create_lesli_user_details.rb} +6 -6
  55. data/db/{tables/0010003510_create_user_roles.rb → migrate/v1.0/0010003410_create_lesli_user_roles.rb} +4 -4
  56. data/db/{tables/0010005010_create_descriptors.rb → migrate/v1.0/0010005010_create_lesli_descriptors.rb} +5 -6
  57. data/db/{tables/0010005110_create_descriptor_privileges.rb → migrate/v1.0/0010005110_create_lesli_descriptor_privileges.rb} +8 -7
  58. data/db/{tables/0010005210_create_descriptor_activities.rb → migrate/v1.0/0010005210_create_lesli_descriptor_activities.rb} +6 -8
  59. data/db/seeds.rb +0 -2
  60. data/lib/lesli/engine.rb +25 -2
  61. data/lib/lesli/routing.rb +26 -0
  62. data/lib/lesli/version.rb +2 -2
  63. data/lib/lesli.rb +1 -0
  64. data/lib/{sass/lesli/pages/mfas.scss → mailer_previews/devise_mailer_preview.rb} +12 -6
  65. data/lib/sass/lesli/bulma/loader.scss +3 -0
  66. data/lib/sass/lesli/elements/header.scss +1 -1
  67. data/lib/sass/lesli/fonts/families.scss +3 -3
  68. data/lib/sass/lesli/layouts/application-container.scss +4 -0
  69. data/lib/sass/lesli/{devise/passwords.scss.erb → pages/devise-simple.scss} +38 -38
  70. data/lib/sass/lesli/{templates → pages}/devise.scss +4 -26
  71. data/lib/sass/lesli/settings/variables.scss +1 -1
  72. data/lib/sass/lesli/templates/application.scss +8 -4
  73. data/lib/sass/lesli/templates/dashboards.scss +8 -0
  74. data/lib/sass/lesli/templates/public.scss +2 -3
  75. data/lib/tasks/lesli/controllers.rake +33 -0
  76. data/lib/tasks/lesli/db.rake +88 -0
  77. data/lib/tasks/lesli/git.rake +74 -0
  78. data/lib/tasks/lesli_tasks.rake +70 -20
  79. data/lib/vue/devise/registrations.js +10 -15
  80. data/lib/vue/layouts/application-container.vue +10 -2
  81. data/lib/vue/layouts/application-header.vue +10 -3
  82. data/lib/vue/stores/account.js +113 -0
  83. data/lib/vue/stores/role.js +243 -0
  84. data/lib/vue/stores/translations.json +86 -0
  85. data/lib/vue/stores/user.js +102 -0
  86. data/lib/{sass/lesli/devise/sessions.scss → vue/translation.js} +14 -5
  87. data/lib/webpack/base.js +2 -2
  88. data/lib/webpack/core.js +2 -0
  89. data/readme.md +74 -55
  90. metadata +196 -51
  91. data/app/assets/fonts/lesli/Domine/Domine-Bold.ttf +0 -0
  92. data/app/assets/fonts/lesli/Domine/Domine-Regular.ttf +0 -0
  93. data/app/assets/stylesheets/lesli/users/devise.scss +0 -32
  94. data/app/controllers/lesli/profiles_controller.rb +0 -60
  95. data/app/helpers/lesli/profiles_helper.rb +0 -4
  96. data/app/models/lesli/profile.rb +0 -4
  97. data/app/views/lesli/devise/sessions/_form.html.erb +0 -17
  98. data/app/views/lesli/devise/sessions/_session.html.erb +0 -2
  99. data/app/views/lesli/devise/sessions/edit.html.erb +0 -10
  100. data/app/views/lesli/devise/sessions/index.html.erb +0 -14
  101. data/app/views/lesli/devise/sessions/new.html.erb +0 -9
  102. data/app/views/lesli/devise/sessions/show.html.erb +0 -10
  103. data/app/views/lesli/profiles/_form.html.erb +0 -17
  104. data/app/views/lesli/profiles/_profile.html.erb +0 -2
  105. data/app/views/lesli/profiles/edit.html.erb +0 -10
  106. data/app/views/lesli/profiles/index.html.erb +0 -14
  107. data/app/views/lesli/profiles/new.html.erb +0 -9
  108. data/app/views/lesli/profiles/show.html.erb +0 -10
  109. data/lib/sass/lesli/pages/dashboards.scss +0 -57
  110. data/lib/tasks/db.rb +0 -76
  111. data/lib/vue/stores/profile.js +0 -90
  112. data/lib/vue/stores/workflow2.js +0 -345
  113. data/lib/vue/stores/workflows/actions.js +0 -327
  114. data/lib/vue/stores/workflows/associations.js +0 -130
  115. data/lib/vue/stores/workflows/checks.js +0 -210
  116. /data/lib/vue/stores/{announcements.js → entities/announcements.js} +0 -0
  117. /data/lib/vue/stores/{dashboard.js → entities/dashboard.js} +0 -0
  118. /data/lib/vue/stores/{workflow.js → entities/workflow.js} +0 -0
  119. /data/lib/vue/stores/{cloud-bell → panels}/notification.js +0 -0
  120. /data/lib/vue/stores/{firebase.js → services/firebase.js} +0 -0
@@ -1,327 +0,0 @@
1
- /*
2
-
3
- Lesli
4
-
5
- Copyright (c) 2023, Lesli Technologies, S. A.
6
-
7
- This program is free software: you can redistribute it and/or modify
8
- it under the terms of the GNU General Public License as published by
9
- the Free Software Foundation, either version 3 of the License, or
10
- (at your option) any later version.
11
-
12
- This program is distributed in the hope that it will be useful,
13
- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- GNU General Public License for more details.
16
-
17
- You should have received a copy of the GNU General Public License
18
- along with this program. If not, see http://www.gnu.org/licenses/.
19
-
20
- Lesli · Your Smart Business Assistant.
21
-
22
- Made with ♥ by https://www.lesli.tech
23
- Building a better future, one line of code at a time.
24
-
25
- @contact hello@lesli.tech
26
- @website https://lesli.tech
27
- @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
-
29
- // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
- // ·
31
-
32
- */
33
-
34
-
35
- // · This store is needed to make http requests, manage the reactivity
36
- // · of a workflow.
37
-
38
- import { defineStore } from "pinia"
39
-
40
- import { useWorkflow } from "Lesli/stores/shared/workflow"
41
- import { useRouter } from "vue-router"
42
-
43
- export const useActions = defineStore("core.shared.workflow.actions", {
44
- state: () => {
45
- return {
46
- storeWorkflow: useWorkflow(),
47
- actions: [],
48
- loading: false,
49
- action: {
50
- active: true,
51
- initial_status_id: null,
52
- final_status_id: null,
53
- name: '',
54
- action_type: null,
55
- execute_immediately: false,
56
- template_path: null,
57
- input_data: {},
58
- system_data: {},
59
- concerning_users: {
60
- list: [
61
- {}
62
- ],
63
- type: ""
64
- },
65
- configuration: {}
66
- },
67
- concerning_users: {
68
- type: null
69
- },
70
- options: {
71
- statuses: [],
72
- action_types: [],
73
- concerning_user_types: [],
74
- users: [],
75
- task_importances: [],
76
- task_types: []
77
- },
78
- file_options: {
79
- templates: {},
80
- file_types: []
81
- },
82
- clone_options: {},
83
- action_unavailable: false
84
- }
85
- },
86
- actions: {
87
- /**
88
- * @description This action is used to fetch the list of actions for a workflow
89
- */
90
- fetchActions() {
91
- this.loading = true
92
-
93
- const url = this.url[this.storeWorkflow.cloudModule](`${this.storeWorkflow.cloudObject}/:workflowId/actions`, { workflowId: this.storeWorkflow.workflow.id })
94
-
95
- this.http.get(url).then(result => {
96
- this.actions = result
97
- }).catch(error => {
98
- this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
99
- }).finally(() => {
100
- this.loading = false
101
- })
102
- },
103
-
104
- /**
105
- * @description This action is used to reset the store
106
- */
107
- reset() {
108
- this.action = {
109
- active: true,
110
- initial_status_id: null,
111
- final_status_id: null,
112
- name: '',
113
- action_type: null,
114
- execute_immediately: false,
115
- template_path: null,
116
- input_data: {},
117
- system_data: {},
118
- concerning_users: {
119
- list: [
120
- {}
121
- ],
122
- type: ""
123
- },
124
- configuration: {},
125
- concerning_user_types: ""
126
- }
127
- },
128
- /**
129
- * @description This action is used to get the information from a action
130
- * @param {Integer} action_id id of the action to be fetched
131
- */
132
- fetchAction (action_id){
133
- const url = this.url[this.storeWorkflow.cloudModule](`${this.storeWorkflow.cloudObject}/:workflowId/actions/:actionId`, { workflowId: this.storeWorkflow.workflow.id, actionId: action_id })
134
-
135
- this.http.get(url).then(result => {
136
- this.action = result
137
- }).catch(error => {
138
- this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
139
- })
140
- },
141
- /**
142
- * @description This action is used to post an action for a workflow
143
- */
144
- postAction (){
145
-
146
- let data = {
147
- workflow_action: this.action
148
- }
149
- const url = this.url[this.storeWorkflow.cloudModule](`${this.storeWorkflow.cloudObject}/:workflowId/actions`, { workflowId: this.storeWorkflow.workflow.id })
150
-
151
- this.http.post(url, data).then(result => {
152
- this.action = {}
153
- this.actions.push(result)
154
- this.msg.success(I18n.t("core.users.messages_success_operation"))
155
- }).catch(error => {
156
- this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
157
- }).finally(()=>{
158
- this.loading = false
159
- })
160
- },
161
- /**
162
- * @description This action is used to update an action for a workflow
163
- */
164
- updateAction (){
165
-
166
- let data = {
167
- workflow_action: this.action
168
- }
169
-
170
- const url = this.url[this.storeWorkflow.cloudModule](`${this.storeWorkflow.cloudObject}/:workflowId/actions/:actionId`, { workflowId: this.storeWorkflow.workflow.id, actionId: this.action.id })
171
-
172
- this.http.put(url, data).then(result => {
173
- this.action = result
174
- this.msg.success(I18n.t("core.users.messages_success_operation"))
175
- }).catch(error => {
176
- this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
177
- }).finally(()=>{
178
- this.loading = false
179
- })
180
- },
181
-
182
- /**
183
- * @description This action is used to translate the options for an enum
184
- * @param {Object, String, String}
185
- */
186
- translateEnum( translations, enum_prefix, value){
187
- const new_value = translations[`${enum_prefix}_${value}`]
188
- if(new_value){
189
- return new_value
190
- }
191
-
192
- return value
193
- },
194
- /**
195
- * @description This action is used to get options for check form
196
- */
197
- getOptions(){
198
- this.options = {
199
- statuses: [],
200
- action_types: [],
201
- concerning_user_types: []
202
- }
203
- const url = this.url[this.storeWorkflow.cloudModule](`${this.storeWorkflow.cloudObject}/:workflowId/actions/options`, { workflowId: this.storeWorkflow.workflow.id })
204
-
205
- this.loading = true
206
-
207
- this.http.get(url).then(result => {
208
-
209
- Object.values(result["statuses"]).forEach((status)=>{
210
- this.options["statuses"].push({
211
- label: status.name,
212
- value: status.id
213
- })
214
- })
215
-
216
- result["action_types"].forEach((type)=>{
217
- this.options["action_types"].push({
218
- label: this.translateEnum(I18n.t('core.workflow/actions'), 'column_enum_action_type', type.text),
219
- value: type.value
220
- })
221
- })
222
-
223
- result["concerning_user_types"].forEach((type)=>{
224
- this.options["concerning_user_types"].push({
225
- label: this.translateEnum(I18n.t('core.workflow/actions'), 'column_enum_action_type', type.text),
226
- value: type.value
227
- })
228
- })
229
-
230
- }).catch(error => {
231
- this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
232
- }).finally(()=>{
233
- this.loading = false
234
- })
235
- },
236
- /**
237
- * @description This action is used to get options for users to assign
238
- */
239
- getUsers(){
240
- this.http.get(this.url.admin("users/list")).then(result => {
241
- this.options["users"] = result
242
- }).catch(error => {
243
- this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
244
- })
245
- },
246
- /**
247
- * @description This action is used to get options for the task form
248
- */
249
- getTasksOptions (){
250
- this.loading = true
251
-
252
- this.options.task_importances = []
253
- this.options.task_types = []
254
-
255
- this.http.get(this.url.focus("tasks/options")).then(result => {
256
-
257
- result["task_types"].forEach((type)=>{
258
- this.options["task_types"].push({
259
- label: type.text,
260
- value: type.value
261
- })
262
- })
263
-
264
- result["importances"].forEach((importance)=>{
265
- this.options["task_importances"].push({
266
- label: importance.text,
267
- value: importance.value
268
- })
269
- })
270
-
271
- this.loading = false
272
- }).catch(error => {
273
- this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
274
- })
275
-
276
- },
277
- /**
278
- * @description This action is used to get options for creating a file
279
- */
280
- getCloudObjectFileOptions(){
281
- this.loading = true
282
-
283
- const url = this.url[this.storeWorkflow.cloudModule](`${this.storeWorkflow.cloudObject}/:workflowId/actions/resources/options_create_cloud_object_file`, { workflowId: this.storeWorkflow.workflow.id })
284
-
285
- this.http.get(url).then(result => {
286
- if(result && result.templates.length > 0){
287
- this.file_options.templates = result.templates
288
- this.file_options.file_types = result.file_types
289
- }else{
290
- this.action_unavailable = true
291
- }
292
- this.loading = false
293
- }).catch(error => {
294
- this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
295
- })
296
- },
297
- /**
298
- * @description This action is used to get options for the clone object form
299
- */
300
- getCloneOptions(){
301
- this.loading = true
302
- const url = this.url[this.storeWorkflow.cloudModule](`${this.storeWorkflow.cloudObject}/:workflowId/actions/resources/options_cloud_object_clone`, { workflowId: this.storeWorkflow.workflow.id })
303
-
304
- this.http.get(url).then(result => {
305
- if(result){
306
- for(let key in result){
307
- this.clone_options[key] = result[key]
308
- }
309
- }else{
310
- this.action_unavailable = true
311
- }
312
- this.loading = false
313
- }).catch(error => {
314
- this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
315
- })
316
- },
317
- /**
318
- * @description This action is used to add a reference to use on backend action
319
- * @param {String, String}
320
- */
321
- addReference(reference, field){
322
- let field_value = this.action.input_data[field] || ''
323
- this.action.input_data[field] = `${field_value} %${reference}% `
324
- }
325
-
326
- }
327
- })
@@ -1,130 +0,0 @@
1
- /*
2
-
3
- Lesli
4
-
5
- Copyright (c) 2023, Lesli Technologies, S. A.
6
-
7
- This program is free software: you can redistribute it and/or modify
8
- it under the terms of the GNU General Public License as published by
9
- the Free Software Foundation, either version 3 of the License, or
10
- (at your option) any later version.
11
-
12
- This program is distributed in the hope that it will be useful,
13
- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- GNU General Public License for more details.
16
-
17
- You should have received a copy of the GNU General Public License
18
- along with this program. If not, see http://www.gnu.org/licenses/.
19
-
20
- Lesli · Your Smart Business Assistant.
21
-
22
- Made with ♥ by https://www.lesli.tech
23
- Building a better future, one line of code at a time.
24
-
25
- @contact hello@lesli.tech
26
- @website https://lesli.tech
27
- @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
-
29
- // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
- // ·
31
-
32
- */
33
-
34
-
35
- // · This store is needed to make http requests, manage the reactivity
36
- // · of a workflow.
37
-
38
- import { defineStore } from "pinia"
39
-
40
- import { useWorkflow } from "Lesli/stores/shared/workflow"
41
-
42
- export const useAssociations = defineStore("core.shared.workflow.associations", {
43
- state: () => {
44
- return {
45
- storeWorkflow: useWorkflow(),
46
- associations: [],
47
- loading: false,
48
- options_select: [],
49
- options: [],
50
- association_details: {},
51
- association: {},
52
- select_details: []
53
- }
54
- },
55
- actions: {
56
- /**
57
- * @description This action is used to fetch the list of options for a workflow association
58
- */
59
- getAssociationOptions(){
60
- this.loading = true
61
- this.options_select = []
62
-
63
- const url = this.url[this.storeWorkflow.cloudModule](`${this.storeWorkflow.cloudObject}/associations/options`)
64
-
65
- this.http.get(url).then(result => {
66
- this.options = result
67
- result.forEach((option)=>{
68
- this.options_select.push({
69
- label: option.name,
70
- value: option.workflow_for
71
- })
72
-
73
- })
74
-
75
- this.loading = false
76
-
77
- }).catch(error => {
78
- this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
79
- })
80
- },
81
- /**
82
- * @description This action is used to post a new association for a workflow
83
- */
84
- postAssociation(){
85
- this.loading = true
86
-
87
- let data = {
88
- workflow_association: this.association
89
- }
90
-
91
- const url = this.url[this.storeWorkflow.cloudModule](`${this.storeWorkflow.cloudObject}/${this.storeWorkflow.workflow.id}/associations`)
92
-
93
- this.http.post(url, data).then(result => {
94
- this.association = {}
95
- this.msg.success(I18n.t("core.users.messages_success_operation"))
96
- this.getAssociations()
97
- }).catch(error => {
98
- this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
99
- }).finally(()=>{
100
- this.loading = false
101
- })
102
- },
103
- /**
104
- * @description This action is used to get workflow associations
105
- */
106
- getAssociations () {
107
- this.loading = true
108
- this.associations = []
109
-
110
- const url = this.url[this.storeWorkflow.cloudModule](`${this.storeWorkflow.cloudObject}/${this.storeWorkflow.workflow.id}/associations`)
111
-
112
- this.http.get(url).then(result => {
113
- this.associations = result
114
- this.loading = false
115
- }).catch(error => {
116
- this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
117
- })
118
- },
119
- deleteAssociation(association_id){
120
- const url = this.url[this.storeWorkflow.cloudModule](`${this.storeWorkflow.cloudObject}/${this.storeWorkflow.workflow.id}/associations/:associationId`, {associationId: association_id})
121
-
122
- this.http.delete(url).then(result => {
123
- this.getAssociations()
124
- this.msg.success(I18n.t("core.users.messages_success_operation"))
125
- }).catch(error => {
126
- this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
127
- })
128
- },
129
- }
130
- })
@@ -1,210 +0,0 @@
1
- /*
2
-
3
- Lesli
4
-
5
- Copyright (c) 2023, Lesli Technologies, S. A.
6
-
7
- This program is free software: you can redistribute it and/or modify
8
- it under the terms of the GNU General Public License as published by
9
- the Free Software Foundation, either version 3 of the License, or
10
- (at your option) any later version.
11
-
12
- This program is distributed in the hope that it will be useful,
13
- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- GNU General Public License for more details.
16
-
17
- You should have received a copy of the GNU General Public License
18
- along with this program. If not, see http://www.gnu.org/licenses/.
19
-
20
- Lesli · Your Smart Business Assistant.
21
-
22
- Made with ♥ by https://www.lesli.tech
23
- Building a better future, one line of code at a time.
24
-
25
- @contact hello@lesli.tech
26
- @website https://lesli.tech
27
- @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
-
29
- // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
- // ·
31
-
32
- */
33
-
34
-
35
- // · This store is needed to make http requests, manage the reactivity
36
- // · of a workflow.
37
-
38
- import { defineStore } from "pinia"
39
-
40
- import { useWorkflow } from "Lesli/stores/shared/workflow"
41
-
42
- export const useChecks = defineStore("core.shared.workflow.checks", {
43
- state: () => {
44
- return {
45
- storeWorkflow: useWorkflow(),
46
- checks: [],
47
- loading: false,
48
- check: {},
49
- showPanel: false,
50
- options: {
51
- users: [],
52
- roles: [],
53
- statuses: [],
54
- user_types: []
55
- }
56
- }
57
- },
58
- actions: {
59
- /**
60
- * @description This action is used to fetch the list of checks for a workflow
61
- */
62
- fetchChecks() {
63
- this.loading = true
64
-
65
- const url = this.url[this.storeWorkflow.cloudModule](`${this.storeWorkflow.cloudObject}/:workflowId/checks`, { workflowId: this.storeWorkflow.workflow.id })
66
-
67
- this.http.get(url).then(result => {
68
- this.checks = result
69
- }).catch(error => {
70
- this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
71
- }).finally(() => {
72
- this.loading = false
73
- })
74
- },
75
-
76
- /**
77
- * @description This action is used to reset the store
78
- */
79
- reset() {
80
- this.check = {
81
- initial_status_id: null,
82
- role_id: null,
83
- user_type: null
84
- }
85
- },
86
- /**
87
- * @description This action is used to get the information from a check
88
- */
89
- async fetchCheck (check_id){
90
- const url = this.url[this.storeWorkflow.cloudModule](`${this.storeWorkflow.cloudObject}/:workflowId/checks/:checkId`, { workflowId: this.storeWorkflow.workflow.id, checkId: check_id })
91
- this.loading = true
92
- return this.http.get(url).then(result => {
93
- this.check = result
94
- this.loading = false
95
- }).catch(error => {
96
- this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
97
- })
98
- },
99
- /**
100
- * @description This action is used to post a check for a workflow
101
- */
102
- postCheck (){
103
- const url = this.url[this.storeWorkflow.cloudModule](`${this.storeWorkflow.cloudObject}/:workflowId/checks`, { workflowId: this.storeWorkflow.workflow.id })
104
-
105
- this.http.post(url, {
106
- workflow_check: this.check
107
- }).then(result => {
108
- this.check = {}
109
- this.checks.push(result)
110
- this.msg.success(I18n.t("core.users.messages_success_operation"))
111
- }).catch(error => {
112
- this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
113
- }).finally(()=>{
114
- this.loading = false
115
- })
116
- },
117
- /**
118
- * @description This action is used to update a check for a workflow
119
- */
120
- putCheck(){
121
- const url = this.url[this.storeWorkflow.cloudModule](`${this.storeWorkflow.cloudObject}/:workflowId/checks/:checkId`, { workflowId: this.storeWorkflow.workflow.id, checkId: this.check.id })
122
- this.loading = true
123
-
124
- this.http.put(url, {
125
- workflow_check: this.check
126
- }).then(result => {
127
- this.msg.success(I18n.t("core.users.messages_success_operation"))
128
- this.loading = false
129
- }).catch(error => {
130
- this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
131
- })
132
- },
133
-
134
- /**
135
- * @description This action is used to get options for check form
136
- */
137
- getCheckOptions(){
138
- this.options = {
139
- users: [],
140
- roles: [],
141
- statuses: [],
142
- user_types: []
143
- }
144
- const url = this.url[this.storeWorkflow.cloudModule](`${this.storeWorkflow.cloudObject}/:workflowId/checks/options`, { workflowId: this.storeWorkflow.workflow.id })
145
-
146
- this.loading = true
147
-
148
- this.http.get(url).then(result => {
149
-
150
- this.options["users"] = result["users"]
151
-
152
- result["roles"].forEach((role)=>{
153
- this.options["roles"].push({
154
- label: role.name,
155
- value: role.id
156
- })
157
- })
158
-
159
- Object.values(result["statuses"]).forEach((status)=>{
160
- this.options["statuses"].push({
161
- label: status.name,
162
- value: status.id
163
- })
164
- })
165
-
166
- result["user_types"].forEach((type)=>{
167
- this.options["user_types"].push({
168
- label: type.text,
169
- value: type.value
170
- })
171
- })
172
-
173
- }).catch(error => {
174
- this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
175
- }).finally(()=>{
176
- this.loading = false
177
- })
178
- },
179
-
180
- /**
181
- * @description This action is used to check if the workflow check exists to create or update the chek
182
- */
183
- formSubmit() {
184
- if (this.check.id) {
185
- this.putCheck()
186
- } else {
187
- this.postCheck()
188
- }
189
- this.reset()
190
- this.fetchChecks()
191
- this.showPanel = false
192
- },
193
- /**
194
- * @description This action is used to delete a check for a workflow
195
- */
196
- deleteCheck(check_id){
197
- this.loading = true
198
- const url = this.url[this.storeWorkflow.cloudModule](`${this.storeWorkflow.cloudObject}/:workflowId/checks/:checkId`, { workflowId: this.storeWorkflow.workflow.id, checkId: check_id })
199
-
200
- this.http.delete(url).then(result => {
201
- this.checks = this.checks.filter(check => check.id != check_id)
202
- this.msg.success(I18n.t("core.users.messages_success_operation"))
203
- this.loading = false
204
- }).catch(error => {
205
- this.msg.danger(I18n.t("core.shared.messages_danger_internal_error"))
206
- })
207
- },
208
-
209
- }
210
- })