lesli_guard 0.2.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.
- checksums.yaml +7 -0
- data/Rakefile +38 -0
- data/app/assets/config/lesli_guard_manifest.js +38 -0
- data/app/assets/images/lesli_guard/guard-logo.svg +160 -0
- data/app/assets/javascripts/lesli_guard/application.js +4787 -0
- data/app/assets/stylesheets/lesli_guard/application.scss +33 -0
- data/app/assets/stylesheets/lesli_guard/dashboards.scss +32 -0
- data/app/assets/stylesheets/lesli_guard/descriptors.scss +32 -0
- data/app/assets/stylesheets/lesli_guard/roles.scss +32 -0
- data/app/assets/stylesheets/lesli_guard/system_controller.scss +32 -0
- data/app/assets/stylesheets/lesli_guard/users.scss +67 -0
- data/app/controllers/lesli_guard/accounts_controller.rb +60 -0
- data/app/controllers/lesli_guard/application_controller.rb +37 -0
- data/app/controllers/lesli_guard/dashboard/components_controller.rb +60 -0
- data/app/controllers/lesli_guard/dashboards_controller.rb +36 -0
- data/app/controllers/lesli_guard/descriptor/activities_controller.rb +122 -0
- data/app/controllers/lesli_guard/descriptor/privileges_controller.rb +112 -0
- data/app/controllers/lesli_guard/descriptors_controller.rb +129 -0
- data/app/controllers/lesli_guard/role/activities_controller.rb +76 -0
- data/app/controllers/lesli_guard/role/descriptors_controller.rb +97 -0
- data/app/controllers/lesli_guard/role/privileges_controller.rb +47 -0
- data/app/controllers/lesli_guard/roles_controller.rb +185 -0
- data/app/controllers/lesli_guard/user/roles_controller.rb +98 -0
- data/app/controllers/lesli_guard/user/sessions_controller.rb +71 -0
- data/app/controllers/lesli_guard/users_controller.rb +206 -0
- data/app/helpers/lesli_guard/accounts_helper.rb +4 -0
- data/app/helpers/lesli_guard/application_helper.rb +4 -0
- data/app/helpers/lesli_guard/dashboards_helper.rb +4 -0
- data/app/helpers/lesli_guard/descriptor/activities_helper.rb +4 -0
- data/app/helpers/lesli_guard/descriptor/privileges_helper.rb +4 -0
- data/app/helpers/lesli_guard/descriptors_helper.rb +4 -0
- data/app/helpers/lesli_guard/role/activities_helper.rb +4 -0
- data/app/helpers/lesli_guard/role/descriptors_helper.rb +4 -0
- data/app/helpers/lesli_guard/role/privileges_helper.rb +4 -0
- data/app/helpers/lesli_guard/roles_helper.rb +4 -0
- data/app/jobs/lesli_guard/application_job.rb +37 -0
- data/app/mailers/lesli_guard/application_mailer.rb +39 -0
- data/app/models/lesli_guard/account.rb +43 -0
- data/app/models/lesli_guard/application_record.rb +37 -0
- data/app/models/lesli_guard/dashboard/component.rb +42 -0
- data/app/models/lesli_guard/dashboard.rb +58 -0
- data/app/models/lesli_guard/descriptor/activity.rb +40 -0
- data/app/models/lesli_guard/descriptor/privilege.rb +40 -0
- data/app/models/lesli_guard/descriptor.rb +41 -0
- data/app/models/lesli_guard/role/activity.rb +40 -0
- data/app/services/lesli_guard/descriptor_privilege_service.rb +74 -0
- data/app/services/lesli_guard/descriptor_service.rb +152 -0
- data/app/services/lesli_guard/role_descriptor_service.rb +61 -0
- data/app/services/lesli_guard/role_service.rb +215 -0
- data/app/services/lesli_guard/user_service.rb +305 -0
- data/app/views/lesli_guard/accounts/_account.html.erb +2 -0
- data/app/views/lesli_guard/accounts/_form.html.erb +17 -0
- data/app/views/lesli_guard/accounts/edit.html.erb +10 -0
- data/app/views/lesli_guard/accounts/index.html.erb +14 -0
- data/app/views/lesli_guard/accounts/new.html.erb +9 -0
- data/app/views/lesli_guard/accounts/show.html.erb +10 -0
- data/app/views/lesli_guard/dashboards/show.html.erb +1 -0
- data/app/views/lesli_guard/descriptor/activities/_form.html.erb +32 -0
- data/app/views/lesli_guard/descriptor/activities/edit.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/activities/index.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/activities/new.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/activities/show.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/privileges/_form.html.erb +32 -0
- data/app/views/lesli_guard/descriptor/privileges/edit.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/privileges/index.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/privileges/new.html.erb +34 -0
- data/app/views/lesli_guard/descriptor/privileges/show.html.erb +34 -0
- data/app/views/lesli_guard/descriptors/_form.html.erb +32 -0
- data/app/views/lesli_guard/descriptors/edit.html.erb +34 -0
- data/app/views/lesli_guard/descriptors/index.html.erb +34 -0
- data/app/views/lesli_guard/descriptors/new.html.erb +34 -0
- data/app/views/lesli_guard/descriptors/show.html.erb +34 -0
- data/app/views/lesli_guard/partials/_engine-navigation.html.erb +38 -0
- data/app/views/lesli_guard/role/activities/_form.html.erb +32 -0
- data/app/views/lesli_guard/role/activities/edit.html.erb +34 -0
- data/app/views/lesli_guard/role/activities/index.html.erb +34 -0
- data/app/views/lesli_guard/role/activities/new.html.erb +34 -0
- data/app/views/lesli_guard/role/activities/show.html.erb +34 -0
- data/app/views/lesli_guard/role/descriptors/_form.html.erb +32 -0
- data/app/views/lesli_guard/role/descriptors/edit.html.erb +34 -0
- data/app/views/lesli_guard/role/descriptors/index.html.erb +34 -0
- data/app/views/lesli_guard/role/descriptors/new.html.erb +34 -0
- data/app/views/lesli_guard/role/descriptors/show.html.erb +34 -0
- data/app/views/lesli_guard/role/privileges/_form.html.erb +32 -0
- data/app/views/lesli_guard/role/privileges/edit.html.erb +34 -0
- data/app/views/lesli_guard/role/privileges/index.html.erb +34 -0
- data/app/views/lesli_guard/role/privileges/new.html.erb +34 -0
- data/app/views/lesli_guard/role/privileges/show.html.erb +34 -0
- data/app/views/lesli_guard/roles/edit.html.erb +34 -0
- data/app/views/lesli_guard/roles/index.html.erb +34 -0
- data/app/views/lesli_guard/roles/new.html.erb +34 -0
- data/app/views/lesli_guard/roles/show.html.erb +34 -0
- data/app/views/lesli_guard/users/edit.html.erb +10 -0
- data/app/views/lesli_guard/users/index.html.erb +34 -0
- data/app/views/lesli_guard/users/new.html.erb +34 -0
- data/app/views/lesli_guard/users/show.html.erb +1 -0
- data/config/locales/translations.en.yml +43 -0
- data/config/locales/translations.es.yml +43 -0
- data/config/routes.rb +90 -0
- data/db/migrate/v1/0801000110_create_lesli_guard_accounts.rb +42 -0
- data/db/migrate/v1/0801050110_create_lesli_guard_dashboards.rb +51 -0
- data/db/migrate/v1/0801050210_create_lesli_guard_dashboard_components.rb +53 -0
- data/lib/lesli_guard/engine.rb +18 -0
- data/lib/lesli_guard/version.rb +4 -0
- data/lib/lesli_guard.rb +6 -0
- data/lib/tasks/lesli_guard_tasks.rake +50 -0
- data/lib/vue/application.js +112 -0
- data/lib/vue/apps/descriptors/components/form.vue +136 -0
- data/lib/vue/apps/descriptors/edit.vue +83 -0
- data/lib/vue/apps/descriptors/index.vue +113 -0
- data/lib/vue/apps/descriptors/new.vue +69 -0
- data/lib/vue/apps/descriptors/show.vue +233 -0
- data/lib/vue/apps/roles/components/descriptors.vue +81 -0
- data/lib/vue/apps/roles/components/form.vue +253 -0
- data/lib/vue/apps/roles/components/privilegeCustom.vue +86 -0
- data/lib/vue/apps/roles/components/privilegeStandard.vue +196 -0
- data/lib/vue/apps/roles/edit.vue +118 -0
- data/lib/vue/apps/roles/index.vue +168 -0
- data/lib/vue/apps/roles/logs.vue +110 -0
- data/lib/vue/apps/roles/new.vue +86 -0
- data/lib/vue/apps/roles/show.vue +109 -0
- data/lib/vue/apps/users/components/information-card.vue +107 -0
- data/lib/vue/apps/users/components/information-form.vue +176 -0
- data/lib/vue/apps/users/components/integrations-information.vue +61 -0
- data/lib/vue/apps/users/components/management-roles.vue +107 -0
- data/lib/vue/apps/users/components/management-security.vue +113 -0
- data/lib/vue/apps/users/components/management-sessions.vue +101 -0
- data/lib/vue/apps/users/components/management-settings.vue +93 -0
- data/lib/vue/apps/users/index.vue +207 -0
- data/lib/vue/apps/users/new.vue +181 -0
- data/lib/vue/apps/users/show.vue +131 -0
- data/lib/vue/stores/descriptor.js +117 -0
- data/lib/vue/stores/descriptors.js +156 -0
- data/lib/vue/stores/role.js +203 -0
- data/lib/vue/stores/roles.js +58 -0
- data/lib/vue/stores/translations.json +98 -0
- data/lib/vue/stores/user.js +331 -0
- data/lib/vue/stores/users.js +176 -0
- data/license +674 -0
- data/readme.md +76 -0
- metadata +199 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
/*
|
|
3
|
+
|
|
4
|
+
Lesli
|
|
5
|
+
|
|
6
|
+
Copyright (c) 2023, Lesli Technologies, S. A.
|
|
7
|
+
|
|
8
|
+
This program is free software: you can redistribute it and/or modify
|
|
9
|
+
it under the terms of the GNU General Public License as published by
|
|
10
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
(at your option) any later version.
|
|
12
|
+
|
|
13
|
+
This program is distributed in the hope that it will be useful,
|
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
GNU General Public License for more details.
|
|
17
|
+
|
|
18
|
+
You should have received a copy of the GNU General Public License
|
|
19
|
+
along with this program. If not, see http://www.gnu.org/licenses/.
|
|
20
|
+
|
|
21
|
+
Lesli · Ruby on Rails SaaS Development Framework.
|
|
22
|
+
|
|
23
|
+
Made with ♥ by https://www.lesli.tech
|
|
24
|
+
Building a better future, one line of code at a time.
|
|
25
|
+
|
|
26
|
+
@contact hello@lesli.tech
|
|
27
|
+
@website https://www.lesli.tech
|
|
28
|
+
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
|
29
|
+
|
|
30
|
+
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
|
31
|
+
// ·
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
// · import vue tools
|
|
37
|
+
import { inject, onMounted, ref } from "vue"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
// · import lesli stores
|
|
41
|
+
import { useDescriptor } from "LesliGuard/stores/descriptor"
|
|
42
|
+
import { useSystemController } from "Lesli/shared/stores/systemController"
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
// · import vue router composable
|
|
46
|
+
import { useRouter, useRoute } from "vue-router"
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
// · initialize/inject plugins
|
|
50
|
+
const route = useRoute()
|
|
51
|
+
const url = inject("url")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
// · implement stores
|
|
55
|
+
const storeDescriptor = useDescriptor()
|
|
56
|
+
const storeSystemController = useSystemController()
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
// · translations
|
|
60
|
+
const translations = {
|
|
61
|
+
core: {
|
|
62
|
+
roles: I18n.t("core.roles"),
|
|
63
|
+
shared: I18n.t("core.shared"),
|
|
64
|
+
descriptors: I18n.t('core.role_descriptors')
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
//
|
|
70
|
+
const tab = ref(0)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
//
|
|
74
|
+
const columns = [{
|
|
75
|
+
field: 'controller',
|
|
76
|
+
label: 'Controller'
|
|
77
|
+
},{
|
|
78
|
+
field: 'list_action',
|
|
79
|
+
label: 'List',
|
|
80
|
+
align: 'center'
|
|
81
|
+
},{
|
|
82
|
+
field: 'index_action',
|
|
83
|
+
label: 'Index',
|
|
84
|
+
align: 'center'
|
|
85
|
+
},{
|
|
86
|
+
field: 'show_action',
|
|
87
|
+
label: 'Show',
|
|
88
|
+
align: 'center'
|
|
89
|
+
},{
|
|
90
|
+
field: 'create_action',
|
|
91
|
+
label: 'Create',
|
|
92
|
+
align: 'center'
|
|
93
|
+
},{
|
|
94
|
+
field: 'update_action',
|
|
95
|
+
label: 'Update',
|
|
96
|
+
align: 'center'
|
|
97
|
+
},{
|
|
98
|
+
field: 'destroy_action',
|
|
99
|
+
label: 'Delete',
|
|
100
|
+
align: 'center'
|
|
101
|
+
}]
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
//
|
|
105
|
+
onMounted(() => {
|
|
106
|
+
storeDescriptor.getDescriptor(route.params.id)
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
//
|
|
111
|
+
function addPrivilege(active, action) {
|
|
112
|
+
if (active) {
|
|
113
|
+
storeDescriptor.postDescriptorPrivilege(action)
|
|
114
|
+
} else {
|
|
115
|
+
storeDescriptor.deleteDescriptorPrivilege(action)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
</script>
|
|
120
|
+
<template>
|
|
121
|
+
<lesli-application-container>
|
|
122
|
+
<lesli-header :title="'Descriptor: '+storeDescriptor.descriptor.name">
|
|
123
|
+
</lesli-header>
|
|
124
|
+
|
|
125
|
+
<lesli-table
|
|
126
|
+
:columns="columns"
|
|
127
|
+
:records="storeDescriptor.privileges"
|
|
128
|
+
:loading="storeDescriptor.privilegesLoading">
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
<!-- table header -->
|
|
132
|
+
|
|
133
|
+
<template #head(list_action)="{ column }">
|
|
134
|
+
<span class="icon-text">
|
|
135
|
+
<span class="icon">
|
|
136
|
+
<span class="material-icons">
|
|
137
|
+
format_list_bulleted
|
|
138
|
+
</span>
|
|
139
|
+
</span>
|
|
140
|
+
<span>{{ column.label }}</span>
|
|
141
|
+
</span>
|
|
142
|
+
</template>
|
|
143
|
+
|
|
144
|
+
<template #head(index_action)="{ column }">
|
|
145
|
+
<span class="icon-text">
|
|
146
|
+
<span class="icon">
|
|
147
|
+
<span class="material-icons">
|
|
148
|
+
format_list_numbered
|
|
149
|
+
</span>
|
|
150
|
+
</span>
|
|
151
|
+
<span>{{ column.label }}</span>
|
|
152
|
+
</span>
|
|
153
|
+
</template>
|
|
154
|
+
|
|
155
|
+
<template #head(show_action)="{ column }">
|
|
156
|
+
<span class="icon-text">
|
|
157
|
+
<span class="icon">
|
|
158
|
+
<span class="material-icons">
|
|
159
|
+
visibility
|
|
160
|
+
</span>
|
|
161
|
+
</span>
|
|
162
|
+
<span>{{ column.label }}</span>
|
|
163
|
+
</span>
|
|
164
|
+
</template>
|
|
165
|
+
|
|
166
|
+
<template #head(create_action)="{ column }">
|
|
167
|
+
<span class="icon-text">
|
|
168
|
+
<span class="icon">
|
|
169
|
+
<span class="material-icons">
|
|
170
|
+
add
|
|
171
|
+
</span>
|
|
172
|
+
</span>
|
|
173
|
+
<span>{{ column.label }}</span>
|
|
174
|
+
</span>
|
|
175
|
+
</template>
|
|
176
|
+
|
|
177
|
+
<template #head(update_action)="{ column }">
|
|
178
|
+
<span class="icon-text">
|
|
179
|
+
<span class="icon">
|
|
180
|
+
<span class="material-icons">
|
|
181
|
+
edit
|
|
182
|
+
</span>
|
|
183
|
+
</span>
|
|
184
|
+
<span>{{ column.label }}</span>
|
|
185
|
+
</span>
|
|
186
|
+
</template>
|
|
187
|
+
|
|
188
|
+
<template #head(destroy_action)="{ column }">
|
|
189
|
+
<span class="icon-text">
|
|
190
|
+
<span class="icon">
|
|
191
|
+
<span class="material-icons">
|
|
192
|
+
delete
|
|
193
|
+
</span>
|
|
194
|
+
</span>
|
|
195
|
+
<span>{{ column.label }}</span>
|
|
196
|
+
</span>
|
|
197
|
+
</template>
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
<!-- table content -->
|
|
201
|
+
|
|
202
|
+
<template #list_action="{ record, value }">
|
|
203
|
+
<lesli-toggle v-if="value" v-model="record.list_active" @update:modelValue="addPrivilege(record.list_active, record.list_action)">
|
|
204
|
+
</lesli-toggle>
|
|
205
|
+
</template>
|
|
206
|
+
|
|
207
|
+
<template #index_action="{ record, value }">
|
|
208
|
+
<lesli-toggle v-if="value" v-model="record.index_active" @update:modelValue="addPrivilege(record.index_active, record.index_action)">
|
|
209
|
+
</lesli-toggle>
|
|
210
|
+
</template>
|
|
211
|
+
|
|
212
|
+
<template #show_action="{ record, value }">
|
|
213
|
+
<lesli-toggle v-if="value" v-model="record.show_active" @update:modelValue="addPrivilege(record.show_active, record.show_action)">
|
|
214
|
+
</lesli-toggle>
|
|
215
|
+
</template>
|
|
216
|
+
|
|
217
|
+
<template #create_action="{ record, value }">
|
|
218
|
+
<lesli-toggle v-if="value" v-model="record.create_active" @update:modelValue="addPrivilege(record.create_active, record.create_action)">
|
|
219
|
+
</lesli-toggle>
|
|
220
|
+
</template>
|
|
221
|
+
|
|
222
|
+
<template #update_action="{ record, value }">
|
|
223
|
+
<lesli-toggle v-if="value" v-model="record.update_active" @update:modelValue="addPrivilege(record.update_active, record.update_action)">
|
|
224
|
+
</lesli-toggle>
|
|
225
|
+
</template>
|
|
226
|
+
|
|
227
|
+
<template #destroy_action="{ record, value }">
|
|
228
|
+
<lesli-toggle v-if="value" v-model="record.destroy_active" @update:modelValue="addPrivilege(record.destroy_active, record.destroy_action)">
|
|
229
|
+
</lesli-toggle>
|
|
230
|
+
</template>
|
|
231
|
+
</lesli-table>
|
|
232
|
+
</lesli-application-container>
|
|
233
|
+
</template>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
/*
|
|
3
|
+
|
|
4
|
+
Lesli
|
|
5
|
+
|
|
6
|
+
Copyright (c) 2023, Lesli Technologies, S. A.
|
|
7
|
+
|
|
8
|
+
This program is free software: you can redistribute it and/or modify
|
|
9
|
+
it under the terms of the GNU General Public License as published by
|
|
10
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
(at your option) any later version.
|
|
12
|
+
|
|
13
|
+
This program is distributed in the hope that it will be useful,
|
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
GNU General Public License for more details.
|
|
17
|
+
|
|
18
|
+
You should have received a copy of the GNU General Public License
|
|
19
|
+
along with this program. If not, see http://www.gnu.org/licenses/.
|
|
20
|
+
|
|
21
|
+
Lesli · Ruby on Rails SaaS Development Framework.
|
|
22
|
+
|
|
23
|
+
Made with ♥ by https://www.lesli.tech
|
|
24
|
+
Building a better future, one line of code at a time.
|
|
25
|
+
|
|
26
|
+
@contact hello@lesli.tech
|
|
27
|
+
@website https://www.lesli.tech
|
|
28
|
+
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
|
29
|
+
|
|
30
|
+
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
|
31
|
+
// ·
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
// · import vue tools
|
|
37
|
+
import { ref, reactive, onMounted, watch, computed } from "vue"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
// · import lesli stores
|
|
41
|
+
import { useRole } from "LesliGuard/stores/role"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
// · implement stores
|
|
45
|
+
const storeRole = useRole()
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
// ·
|
|
49
|
+
const translations = {
|
|
50
|
+
shared: I18n.t("core.shared"),
|
|
51
|
+
passwords: I18n.t("core.users/passwords"),
|
|
52
|
+
users: I18n.t("core.users")
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
// ·
|
|
57
|
+
function updateRole(descriptor) {
|
|
58
|
+
|
|
59
|
+
if (descriptor.active) {
|
|
60
|
+
return storeRole.postDescriptor(descriptor)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return storeRole.deleteDescriptor(descriptor)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
</script>
|
|
67
|
+
<template>
|
|
68
|
+
<lesli-empty v-if="storeRole.descriptors.length == 0"></lesli-empty>
|
|
69
|
+
<div class="media px-6" v-for="descriptor in storeRole.descriptors">
|
|
70
|
+
<div class="media-content pt-4">
|
|
71
|
+
<h4>{{ descriptor.name }}</h4>
|
|
72
|
+
<p style="color:#aaa;">
|
|
73
|
+
{{ descriptor.description }}
|
|
74
|
+
</p>
|
|
75
|
+
</div>
|
|
76
|
+
<div class="media-right pt-4">
|
|
77
|
+
<lesli-toggle v-model="descriptor.active" @change="updateRole(descriptor)">
|
|
78
|
+
</lesli-toggle>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
</template>
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
<script setup>
|
|
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 · Ruby on Rails SaaS Development Framework.
|
|
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://www.lesli.tech
|
|
27
|
+
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
|
28
|
+
|
|
29
|
+
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
|
30
|
+
// ·
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
// · import vue tools
|
|
36
|
+
import { ref, reactive, onMounted, watch, computed, inject } from "vue"
|
|
37
|
+
import { useRouter, useRoute } from "vue-router"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
// · import lesli stores
|
|
41
|
+
import { useRole } from "LesliGuard/stores/role"
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
// · initialize/inject plugins
|
|
45
|
+
const router = useRouter()
|
|
46
|
+
const route = useRoute()
|
|
47
|
+
const msg = inject("msg")
|
|
48
|
+
const url = inject("url")
|
|
49
|
+
const olpSelected = ref(0)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
// ·
|
|
53
|
+
const storeRole = useRole()
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
// · defining props
|
|
57
|
+
const props = defineProps({
|
|
58
|
+
editable: {
|
|
59
|
+
type: Boolean,
|
|
60
|
+
required: false,
|
|
61
|
+
default: false
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
// ·
|
|
67
|
+
const translations = {
|
|
68
|
+
lesli: {
|
|
69
|
+
shared: i18n.t("lesli.shared")
|
|
70
|
+
},
|
|
71
|
+
core: {
|
|
72
|
+
shared: I18n.t('core.shared'),
|
|
73
|
+
roles: I18n.t('core.roles')
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
// ·
|
|
79
|
+
function submitRole() {
|
|
80
|
+
|
|
81
|
+
// role id exists, then just update the role
|
|
82
|
+
if (storeRole.role.id) {
|
|
83
|
+
return storeRole.putRole()
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return storeRole.postRole()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
// ·
|
|
91
|
+
function selectObjectLevelPermission(olpSelectedInForm) {
|
|
92
|
+
olpSelected.value = olpSelectedInForm
|
|
93
|
+
storeRole.role.object_level_permission = olpSelectedInForm
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
// ·
|
|
98
|
+
onMounted(() => {
|
|
99
|
+
if (route.params.id) {
|
|
100
|
+
storeRole.getRole(route.params.id)
|
|
101
|
+
} else {
|
|
102
|
+
storeRole.$reset()
|
|
103
|
+
}
|
|
104
|
+
storeRole.getOptions()
|
|
105
|
+
})
|
|
106
|
+
</script>
|
|
107
|
+
<template>
|
|
108
|
+
<lesli-form :editable="props.editable" @submit="submitRole">
|
|
109
|
+
|
|
110
|
+
<!-- Role name -->
|
|
111
|
+
<div class="field">
|
|
112
|
+
<label class="label">
|
|
113
|
+
Name
|
|
114
|
+
<sup class="has-text-danger">*</sup>
|
|
115
|
+
</label>
|
|
116
|
+
<div class="control">
|
|
117
|
+
<input v-model="storeRole.role.name" class="input" type="text" required />
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
<!-- Role Description -->
|
|
122
|
+
<div class="field">
|
|
123
|
+
<label class="label">
|
|
124
|
+
Description
|
|
125
|
+
</label>
|
|
126
|
+
<div class="control">
|
|
127
|
+
<input v-model="storeRole.role.description" class="input" type="text" />
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
<!-- Role default path -->
|
|
132
|
+
<div class="field">
|
|
133
|
+
<label class="label">Default path</label>
|
|
134
|
+
<div class="control">
|
|
135
|
+
<input v-model="storeRole.role.path_default" class="input" type="text" :placeholder="translations.core.roles.view_placeholder_default_path_at_login">
|
|
136
|
+
</div>
|
|
137
|
+
<p class="help">Default path to redirect after login.</p>
|
|
138
|
+
</div>
|
|
139
|
+
|
|
140
|
+
<hr />
|
|
141
|
+
|
|
142
|
+
<div class="columns">
|
|
143
|
+
<div class="column">
|
|
144
|
+
<!-- Role limited to path -->
|
|
145
|
+
<div class="field">
|
|
146
|
+
<label class="label">
|
|
147
|
+
Limited?
|
|
148
|
+
</label>
|
|
149
|
+
<div class="control">
|
|
150
|
+
<div class="select">
|
|
151
|
+
<lesli-select
|
|
152
|
+
v-model="storeRole.role.path_limited"
|
|
153
|
+
:options="[{
|
|
154
|
+
label: translations.core.roles.view_text_limit_to_path,
|
|
155
|
+
value: true
|
|
156
|
+
}, {
|
|
157
|
+
label: translations.core.roles.view_text_allow_all_paths,
|
|
158
|
+
value: false
|
|
159
|
+
}]">
|
|
160
|
+
</lesli-select>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
<p class="help">Always redirect role to the default path</p>
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
<div class="column">
|
|
167
|
+
<!-- Role is isolated -->
|
|
168
|
+
<div class="field">
|
|
169
|
+
<label class="label">
|
|
170
|
+
Isolated?
|
|
171
|
+
<sup class="has-text-danger">*</sup>
|
|
172
|
+
</label>
|
|
173
|
+
<div class="control">
|
|
174
|
+
<div class="select">
|
|
175
|
+
<lesli-select
|
|
176
|
+
v-model="storeRole.role.isolated"
|
|
177
|
+
:options="[{
|
|
178
|
+
label: translations.core.roles.view_text_restrict_data_access,
|
|
179
|
+
value: true
|
|
180
|
+
}, {
|
|
181
|
+
label: translations.core.roles.view_text_allow_to_see_all_the_data,
|
|
182
|
+
value: false
|
|
183
|
+
}]">
|
|
184
|
+
</lesli-select>
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
<p class="help">Force the role to query only the data that belongs to the current user</p>
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
<div class="column">
|
|
191
|
+
<!-- Enable/disable role -->
|
|
192
|
+
<div class="field">
|
|
193
|
+
<label class="label">
|
|
194
|
+
Status
|
|
195
|
+
<sup class="has-text-danger">*</sup>
|
|
196
|
+
</label>
|
|
197
|
+
<div class="control">
|
|
198
|
+
<div class="select">
|
|
199
|
+
<lesli-select
|
|
200
|
+
v-model="storeRole.role.active"
|
|
201
|
+
:options="[{
|
|
202
|
+
label: translations.core.roles.view_text_active,
|
|
203
|
+
value: true
|
|
204
|
+
},{
|
|
205
|
+
label: translations.core.roles.view_text_disabled,
|
|
206
|
+
value: false
|
|
207
|
+
}]">
|
|
208
|
+
</lesli-select>
|
|
209
|
+
</div>
|
|
210
|
+
</div>
|
|
211
|
+
<p class="help">Activate/deactivate role</p>
|
|
212
|
+
</div>
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
|
|
216
|
+
<!-- Object level permission -->
|
|
217
|
+
<div class="field">
|
|
218
|
+
<label class="label">
|
|
219
|
+
Hierarchical level
|
|
220
|
+
<sup class="has-text-danger">*</sup>
|
|
221
|
+
</label>
|
|
222
|
+
|
|
223
|
+
<ul class="hierarchical_level_selector">
|
|
224
|
+
<li :class="['hover', 'p-1', { 'has-background-info has-text-light' : olpSelected == olp.level }]"
|
|
225
|
+
v-for="(olp, index) in storeRole.options.object_level_permissions" :key="index"
|
|
226
|
+
@click="selectObjectLevelPermission(olp.level)">
|
|
227
|
+
<p class="icon-text">
|
|
228
|
+
<span class="icon">
|
|
229
|
+
<span class="material-icons">
|
|
230
|
+
{{ olpSelected == olp.level ? 'check_box' : 'check_box_outline_blank' }}
|
|
231
|
+
</span>
|
|
232
|
+
<i :class="['fas', olpSelected == olp.level ? 'fa-check' : 'fa-chevron-right']"></i>
|
|
233
|
+
</span>
|
|
234
|
+
<span>
|
|
235
|
+
{{ `${translations.core.roles.view_text_level || 'Level' } ${ index + 1 }` }}
|
|
236
|
+
<i v-if="olp.roles.length">- {{ olp.roles.map(role => role.name).join(', ') }}</i>
|
|
237
|
+
</span>
|
|
238
|
+
</p>
|
|
239
|
+
</li>
|
|
240
|
+
</ul>
|
|
241
|
+
</div>
|
|
242
|
+
|
|
243
|
+
<hr>
|
|
244
|
+
|
|
245
|
+
<div class="field is-grouped" v-if="props.editable">
|
|
246
|
+
<div class="control">
|
|
247
|
+
<lesli-button main icon="save" :loading="storeRole.role.loading">
|
|
248
|
+
{{ translations.lesli.shared.button_save }}
|
|
249
|
+
</lesli-button>
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
</lesli-form>
|
|
253
|
+
</template>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
/*
|
|
3
|
+
|
|
4
|
+
Lesli
|
|
5
|
+
|
|
6
|
+
Copyright (c) 2023, Lesli Technologies, S. A.
|
|
7
|
+
|
|
8
|
+
This program is free software: you can redistribute it and/or modify
|
|
9
|
+
it under the terms of the GNU General Public License as published by
|
|
10
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
11
|
+
(at your option) any later version.
|
|
12
|
+
|
|
13
|
+
This program is distributed in the hope that it will be useful,
|
|
14
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
GNU General Public License for more details.
|
|
17
|
+
|
|
18
|
+
You should have received a copy of the GNU General Public License
|
|
19
|
+
along with this program. If not, see http://www.gnu.org/licenses/.
|
|
20
|
+
|
|
21
|
+
Lesli · Your Smart Business Assistant.
|
|
22
|
+
|
|
23
|
+
Made with ♥ by https://www.lesli.tech
|
|
24
|
+
Building a better future, one line of code at a time.
|
|
25
|
+
|
|
26
|
+
@contact hello@lesli.tech
|
|
27
|
+
@website https://lesli.tech
|
|
28
|
+
@license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
|
|
29
|
+
|
|
30
|
+
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
|
31
|
+
// ·
|
|
32
|
+
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
// · import vue tools
|
|
38
|
+
import { ref, reactive, onMounted, watch, computed, inject } from "vue"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
// · import lesli stores
|
|
42
|
+
import { useRole } from "LesliGuard/stores/role"
|
|
43
|
+
import { useDescriptor } from "LesliGuard/stores/descriptor"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
// · initialize/inject plugins
|
|
47
|
+
const msg = inject("msg")
|
|
48
|
+
const url = inject("url")
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
// ·
|
|
52
|
+
const storeRole = useRole()
|
|
53
|
+
const storeDescriptor = useDescriptor()
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
// ·
|
|
57
|
+
const columnDescriptors = [{
|
|
58
|
+
field: 'name',
|
|
59
|
+
label: 'Name'
|
|
60
|
+
},{
|
|
61
|
+
field: 'action',
|
|
62
|
+
label: 'Status',
|
|
63
|
+
align: 'center'
|
|
64
|
+
}]
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
// ·
|
|
68
|
+
function updateDescriptor(descriptor) {
|
|
69
|
+
storeRole.updateDescriptor(descriptor)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
</script>
|
|
73
|
+
<template>
|
|
74
|
+
<lesli-table
|
|
75
|
+
:columns="columnDescriptors"
|
|
76
|
+
:records="storeRole.descriptorsCustom">
|
|
77
|
+
<template #name="{ record }">
|
|
78
|
+
<p>{{ record.name }}</p>
|
|
79
|
+
<p><small>/{{ record.controller }}</small></p>
|
|
80
|
+
</template>
|
|
81
|
+
<template #action="{ record, value }">
|
|
82
|
+
<lesli-toggle v-if="value != null" v-model="record.active" @change="updateDescriptor(record)">
|
|
83
|
+
</lesli-toggle>
|
|
84
|
+
</template>
|
|
85
|
+
</lesli-table>
|
|
86
|
+
</template>
|