@iankibetsh/shframework 1.4.6 → 1.4.8

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.
@@ -1,36 +1,4 @@
1
1
 
2
- .colored-toast.swal2-icon-success {
3
- background-color: #a5dc86 !important;
4
- }
5
-
6
- .colored-toast.swal2-icon-error {
7
- background-color: #f27474 !important;
8
- }
9
-
10
- .colored-toast.swal2-icon-warning {
11
- background-color: #f8bb86 !important;
12
- }
13
-
14
- .colored-toast.swal2-icon-info {
15
- background-color: #3fc3ee !important;
16
- }
17
-
18
- .colored-toast.swal2-icon-question {
19
- background-color: #87adbd !important;
20
- }
21
-
22
- .colored-toast .swal2-title {
23
- color: white;
24
- }
25
-
26
- .colored-toast .swal2-close {
27
- color: white;
28
- }
29
-
30
- .colored-toast .swal2-html-container {
31
- color: white;
32
- }
33
-
34
2
  .sh-phone{
35
3
  display: flex;
36
4
  width: 100%;
@@ -63,6 +31,38 @@
63
31
  opacity: 0.5;
64
32
  }
65
33
 
34
+ .colored-toast.swal2-icon-success {
35
+ background-color: #a5dc86 !important;
36
+ }
37
+
38
+ .colored-toast.swal2-icon-error {
39
+ background-color: #f27474 !important;
40
+ }
41
+
42
+ .colored-toast.swal2-icon-warning {
43
+ background-color: #f8bb86 !important;
44
+ }
45
+
46
+ .colored-toast.swal2-icon-info {
47
+ background-color: #3fc3ee !important;
48
+ }
49
+
50
+ .colored-toast.swal2-icon-question {
51
+ background-color: #87adbd !important;
52
+ }
53
+
54
+ .colored-toast .swal2-title {
55
+ color: white;
56
+ }
57
+
58
+ .colored-toast .swal2-close {
59
+ color: white;
60
+ }
61
+
62
+ .colored-toast .swal2-html-container {
63
+ color: white;
64
+ }
65
+
66
66
  .permissions-main {
67
67
  background: #edeff2;
68
68
  }
@@ -79,8 +79,8 @@
79
79
  position: relative;
80
80
  top: 0;
81
81
  left: 0;
82
- background: white;
83
- border-radius: 10px 0 0 10px;
82
+ background: #88b3b370;
83
+ border-radius: 10px;
84
84
  }
85
85
  .permissions-main div#permissions-nav ul li {
86
86
  list-style: none;
@@ -95,6 +95,21 @@
95
95
  flex-grow: 1;
96
96
  }
97
97
 
98
+ .sh-selected-item{
99
+ line-height: unset!important;
100
+ }
101
+ .sh-suggestion-input{
102
+ padding: 0.375rem 0.75rem;
103
+ }
104
+ .sh-suggest{
105
+ margin-bottom: 1rem;
106
+ }
107
+ .sh-suggest-control::after{
108
+ margin-top: auto;
109
+ margin-bottom: auto;
110
+ margin-right: 0.255em;
111
+ }
112
+
98
113
  :root {
99
114
  --ck-z-default: 10555 !important;
100
115
  --ck-z-modal: calc(var(--ck-z-default) + 999) !important;
@@ -116,21 +131,6 @@
116
131
  }
117
132
  }
118
133
 
119
- .sh-selected-item{
120
- line-height: unset!important;
121
- }
122
- .sh-suggestion-input{
123
- padding: 0.375rem 0.75rem;
124
- }
125
- .sh-suggest{
126
- margin-bottom: 1rem;
127
- }
128
- .sh-suggest-control::after{
129
- margin-top: auto;
130
- margin-bottom: auto;
131
- margin-right: 0.255em;
132
- }
133
-
134
134
  .sh-forgot-link, .sh-register-link{
135
135
  cursor: pointer;
136
136
  }
package/dist/library.js CHANGED
@@ -2559,7 +2559,7 @@ const _hoisted_11$3 = ["data-cy", "placeholder", "name", "onFocus", "onUpdate:mo
2559
2559
  const _hoisted_12$3 = ["data-cy", "placeholder", "name", "onFocus", "onUpdate:modelValue"];
2560
2560
  const _hoisted_13$3 = ["data-cy", "placeholder", "name", "onFocus", "onUpdate:modelValue"];
2561
2561
  const _hoisted_14$3 = ["data-cy", "name", "onFocus", "onUpdate:modelValue"];
2562
- const _hoisted_15$2 = ["disabled", "placeholder", "name", "onFocus", "onUpdate:modelValue"];
2562
+ const _hoisted_15$3 = ["disabled", "placeholder", "name", "onFocus", "onUpdate:modelValue"];
2563
2563
  const _hoisted_16$2 = ["name", "onFocus", "onUpdate:modelValue"];
2564
2564
  const _hoisted_17$2 = ["name", "onFocus", "onUpdate:modelValue"];
2565
2565
  const _hoisted_18$2 = ["value"];
@@ -2753,7 +2753,7 @@ function render$5(_ctx, _cache, $props, $setup, $data, $options) {
2753
2753
  class: vue.normalizeClass([_ctx.form_errors[field] == null ? ' field_' + field:'is-invalid ' + field, "form-control"]),
2754
2754
  "onUpdate:modelValue": $event => ((_ctx.form_elements[field]) = $event),
2755
2755
  type: "text"
2756
- }, null, 42 /* CLASS, PROPS, HYDRATE_EVENTS */, _hoisted_15$2)), [
2756
+ }, null, 42 /* CLASS, PROPS, HYDRATE_EVENTS */, _hoisted_15$3)), [
2757
2757
  [vue.vModelText, _ctx.form_elements[field]]
2758
2758
  ])
2759
2759
  : vue.createCommentVNode("v-if", true),
@@ -3629,7 +3629,7 @@ const _hoisted_14$2 = {
3629
3629
  key: 1,
3630
3630
  class: "page-link"
3631
3631
  };
3632
- const _hoisted_15$1 = ["onClick"];
3632
+ const _hoisted_15$2 = ["onClick"];
3633
3633
  const _hoisted_16$1 = { key: 1 };
3634
3634
  const _hoisted_17$1 = {
3635
3635
  key: 0,
@@ -3691,7 +3691,7 @@ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
3691
3691
  key: 2,
3692
3692
  onClick: $event => ($options.changeTableKey('page',page)),
3693
3693
  class: "page-link"
3694
- }, vue.toDisplayString(page), 9 /* TEXT, PROPS */, _hoisted_15$1))
3694
+ }, vue.toDisplayString(page), 9 /* TEXT, PROPS */, _hoisted_15$2))
3695
3695
  ], 2 /* CLASS */))
3696
3696
  }), 128 /* KEYED_FRAGMENT */)),
3697
3697
  vue.createElementVNode("li", {
@@ -4210,7 +4210,7 @@ const _hoisted_14$1 = {
4210
4210
  key: 1,
4211
4211
  class: "alert alert-danger"
4212
4212
  };
4213
- const _hoisted_15 = { colspan: 2 };
4213
+ const _hoisted_15$1 = { colspan: 2 };
4214
4214
  const _hoisted_16 = {
4215
4215
  key: 0,
4216
4216
  class: "text-center"
@@ -4379,7 +4379,7 @@ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
4379
4379
  ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_11$1, _hoisted_13$1))
4380
4380
  : ($data.loading === 'error')
4381
4381
  ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_14$1, [
4382
- vue.createElementVNode("span", _hoisted_15, vue.toDisplayString($data.loading_error), 1 /* TEXT */)
4382
+ vue.createElementVNode("span", _hoisted_15$1, vue.toDisplayString($data.loading_error), 1 /* TEXT */)
4383
4383
  ]))
4384
4384
  : vue.createCommentVNode("v-if", true),
4385
4385
  ($data.loading === 'done')
@@ -4984,38 +4984,138 @@ return (_ctx, _cache) => {
4984
4984
 
4985
4985
  script$4.__file = "src/lib/components/ShDynamicTabs.vue";
4986
4986
 
4987
+ const useUserStore = pinia.defineStore('user-store', {
4988
+ state: () => ({
4989
+ user: null,
4990
+ role: null,
4991
+ permissions: null,
4992
+ menus: [],
4993
+ loggedOut: false
4994
+ }),
4995
+ actions: {
4996
+ setUser (){
4997
+ let user = null;
4998
+ try {
4999
+ user = ShStorage.getItem('user') ? ShStorage.getItem('user') : null;
5000
+ } catch (error) {
5001
+ user= null;
5002
+ }
5003
+ if (user) {
5004
+ user.isAllowedTo = function (slug) {
5005
+ if (this.permissions) {
5006
+ let permissions = [];
5007
+ if (typeof this.permissions === 'string') {
5008
+ permissions = this.permissions;
5009
+ } else {
5010
+ permissions = this.permissions;
5011
+ }
5012
+ return permissions.includes(slug)
5013
+ }
5014
+ return false
5015
+ };
5016
+ }
5017
+ this.user = user;
5018
+ shApis.doGet('auth/user').then(res => {
5019
+ let user = res.data.user;
5020
+ if (typeof(user) === 'undefined') {
5021
+ user = res.data;
5022
+ }
5023
+ ShStorage.setItem('user',user);
5024
+ user.signOut = this.signOut;
5025
+ user.logout = this.signOut;
5026
+ user.logOut = this.signOut;
5027
+ user.isAllowedTo = function (slug) {
5028
+ if(!slug){
5029
+ return true
5030
+ }
5031
+ if (this.permissions) {
5032
+ let permissions = [];
5033
+ if (typeof this.permissions === 'string') {
5034
+ permissions = this.permissions;
5035
+ } else {
5036
+ permissions = this.permissions;
5037
+ }
5038
+ return permissions.includes(slug)
5039
+ }
5040
+ return false
5041
+ };
5042
+ this.user = user;
5043
+ }).catch((reason) => {
5044
+ if (reason.response && reason.response.status) {
5045
+ if(reason.response.status === 401) {
5046
+ ShStorage.setItem('user',null);
5047
+ this.user = null;
5048
+ }
5049
+ this.loggedOut = true;
5050
+ }
5051
+ });
5052
+ if (this.user) {
5053
+ if (typeof this.user.permissions === 'string') {
5054
+ this.permissions = this.user.permissions;
5055
+ } else {
5056
+ this.permissions = this.user.permissions;
5057
+ }
5058
+ }
5059
+ const timeNow = moment__default["default"]().toISOString();
5060
+ ShStorage.setItem('session_start',timeNow);
5061
+ },
5062
+ signOut () {
5063
+ shRepo.signOutUser();
5064
+ },
5065
+ logOut () {
5066
+ this.signOut();
5067
+ },
5068
+ getUser () {
5069
+ this.setUser();
5070
+ },
5071
+ setAccessToken (accessToken) {
5072
+ ShStorage.setItem('access_token', accessToken);
5073
+ this.setUser();
5074
+ }
5075
+ },
5076
+ getters: {
5077
+ userId (state) {
5078
+ return state.user === null ? null:state.user.id
5079
+ }
5080
+ }
5081
+ });
5082
+
4987
5083
  const _withScopeId$1 = n => (vue.pushScopeId("data-v-0d4fa0ac"),n=n(),vue.popScopeId(),n);
4988
5084
  const _hoisted_1$3 = { class: "row permissions-main d-flex" };
4989
5085
  const _hoisted_2$3 = {
4990
5086
  id: "permissions-nav",
4991
- class: "col-md-2 d-flex align-items-center py-4"
5087
+ class: "col-md-3 d-flex align-items-center py-4"
4992
5088
  };
4993
- const _hoisted_3$3 = ["disabled", "checked"];
4994
- const _hoisted_4$3 = ["onClick"];
4995
- const _hoisted_5$3 = {
5089
+ const _hoisted_3$3 = { class: "d-flex flex-column w-100 px-2" };
5090
+ const _hoisted_4$3 = ["checked", "disabled"];
5091
+ const _hoisted_5$3 = ["onClick"];
5092
+ const _hoisted_6$2 = {
4996
5093
  id: "permissions-content",
4997
- class: "col-md-10 py-4 pe-4 ps-0"
5094
+ class: "col-md-9 py-4 px-4"
4998
5095
  };
4999
- const _hoisted_6$2 = { class: "p-2 rounded-2 bg-white h-100" };
5000
- const _hoisted_7$1 = {
5096
+ const _hoisted_7$1 = { class: "p-2 rounded-2 bg-white h-100" };
5097
+ const _hoisted_8$1 = {
5001
5098
  key: 0,
5002
5099
  class: "alert alert-info"
5003
5100
  };
5004
- const _hoisted_8$1 = { key: 1 };
5005
- const _hoisted_9$1 = { class: "row row-cols-4" };
5006
- const _hoisted_10 = { class: "col py-3" };
5007
- const _hoisted_11 = ["value"];
5008
- const _hoisted_12 = {
5101
+ const _hoisted_9$1 = { key: 1 };
5102
+ const _hoisted_10 = { class: "row row-cols-3" };
5103
+ const _hoisted_11 = { class: "col" };
5104
+ const _hoisted_12 = ["value"];
5105
+ const _hoisted_13 = {
5009
5106
  key: 0,
5010
5107
  class: "w-100 row"
5011
5108
  };
5012
- const _hoisted_13 = { class: "col-md-3" };
5013
- const _hoisted_14 = /*#__PURE__*/ _withScopeId$1(() => /*#__PURE__*/vue.createElementVNode("i", { class: "bi-check" }, null, -1 /* HOISTED */));
5109
+ const _hoisted_14 = { class: "col-md-3" };
5110
+ const _hoisted_15 = /*#__PURE__*/ _withScopeId$1(() => /*#__PURE__*/vue.createElementVNode("i", { class: "bi-check" }, null, -1 /* HOISTED */));
5111
+
5014
5112
 
5015
5113
  var script$3 = {
5016
5114
  __name: 'ManagePermissions',
5017
5115
  setup(__props) {
5018
5116
 
5117
+ const userStore =useUserStore();
5118
+
5019
5119
  const route = vueRouter.useRoute();
5020
5120
  const modules = vue.ref([]);
5021
5121
  const selectedModule = vue.ref('tasks');
@@ -5024,6 +5124,8 @@ const modulePermissions = vue.ref(null);
5024
5124
  const selectedPermissions = vue.ref([]);
5025
5125
  const permissionsChanged = vue.ref(false);
5026
5126
  const departmentId = route.params.id;
5127
+ const department = vue.ref(null);
5128
+ const departmentModules = vue.ref([]);
5027
5129
  const setModule = module=>{
5028
5130
  (selectedModule.value !== module) && (selectedModule.value = module) && getModulePermissions();
5029
5131
  };
@@ -5031,8 +5133,10 @@ vue.onMounted(() => {
5031
5133
  getDepartmentModules();
5032
5134
  });
5033
5135
  const getDepartmentModules = ()=>{
5034
- shApis.doGet(`admin/departments/department/list-all-modules/admin`).then(res=>{
5136
+ shApis.doGet(`admin/departments/department/list-all-modules/admin/${departmentId}`).then(res=>{
5035
5137
  modules.value = res.data.modules;
5138
+ department.value = res.data.department;
5139
+ departmentModules.value = res.data.departmentModules;
5036
5140
  selectedModule.value = res.data.modules[0];
5037
5141
  getModulePermissions();
5038
5142
  });
@@ -5048,6 +5152,10 @@ const getModulePermissions = () => {
5048
5152
  permissionsChanged.value = false;
5049
5153
  });
5050
5154
  };
5155
+ const permissionsUpdated = (res)=>{
5156
+ userStore.setUser();
5157
+ departmentModules.value = res.data.departmentModules;
5158
+ };
5051
5159
  function reformatModulePermissions(mPs){
5052
5160
  let mpModules = {};
5053
5161
  mPs.map(mp=>{
@@ -5068,6 +5176,7 @@ const checkAllPermissions = ()=>{
5068
5176
  if(selectedPermissions.value.length > 0) {
5069
5177
  selectedPermissions.value = [];
5070
5178
  } else {
5179
+ departmentModules.value.push(selectedModule);
5071
5180
  console.log(modulePermissions.value);
5072
5181
  const all = modulePermissions.value;
5073
5182
  Object.keys(all).map(key=>{
@@ -5091,37 +5200,34 @@ const getPermissionStyle = permission => {
5091
5200
  return (_ctx, _cache) => {
5092
5201
  return (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$3, [
5093
5202
  vue.createElementVNode("div", _hoisted_2$3, [
5094
- (vue.openBlock(), vue.createElementBlock("ul", {
5095
- class: "d-flex flex-column w-100 ps-2",
5096
- key: selectedModule.value ? selectedModule.value:0
5097
- }, [
5203
+ vue.createElementVNode("ul", _hoisted_3$3, [
5098
5204
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(modules.value, (module) => {
5099
5205
  return (vue.openBlock(), vue.createElementBlock("li", {
5100
5206
  class: vue.normalizeClass(selectedModule.value === module && 'active'),
5101
5207
  key: selectedModule.value
5102
5208
  }, [
5103
5209
  vue.createElementVNode("input", {
5104
- onClick: _cache[0] || (_cache[0] = $event => (checkAllPermissions())),
5210
+ checked: departmentModules.value.includes(module),
5211
+ onClick: checkAllPermissions,
5105
5212
  disabled: selectedModule.value !== module,
5106
- checked: selectedPermissions.value.length > 0 && selectedModule.value === module,
5107
5213
  type: "checkbox"
5108
- }, null, 8 /* PROPS */, _hoisted_3$3),
5214
+ }, null, 8 /* PROPS */, _hoisted_4$3),
5109
5215
  vue.createElementVNode("label", {
5110
5216
  class: "text-capitalize",
5111
5217
  onClick: $event => (setModule(module))
5112
- }, vue.toDisplayString(module.replaceAll('_',' ')), 9 /* TEXT, PROPS */, _hoisted_4$3)
5218
+ }, vue.toDisplayString(module.replaceAll('_',' ')), 9 /* TEXT, PROPS */, _hoisted_5$3)
5113
5219
  ], 2 /* CLASS */))
5114
5220
  }), 128 /* KEYED_FRAGMENT */))
5115
- ]))
5221
+ ])
5116
5222
  ]),
5117
- vue.createElementVNode("div", _hoisted_5$3, [
5118
- vue.createElementVNode("div", _hoisted_6$2, [
5223
+ vue.createElementVNode("div", _hoisted_6$2, [
5224
+ vue.createElementVNode("div", _hoisted_7$1, [
5119
5225
  (loading.value)
5120
- ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_7$1, " loading ... "))
5121
- : (vue.openBlock(), vue.createElementBlock("div", _hoisted_8$1, [
5122
- vue.createElementVNode("div", _hoisted_9$1, [
5226
+ ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_8$1, " loading ... "))
5227
+ : (vue.openBlock(), vue.createElementBlock("div", _hoisted_9$1, [
5228
+ vue.createElementVNode("div", _hoisted_10, [
5123
5229
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(modulePermissions.value, (permissions) => {
5124
- return (vue.openBlock(), vue.createElementBlock("div", _hoisted_10, [
5230
+ return (vue.openBlock(), vue.createElementBlock("div", _hoisted_11, [
5125
5231
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(permissions, (permission) => {
5126
5232
  return (vue.openBlock(), vue.createElementBlock("label", {
5127
5233
  onClick: setPermissionsChanged,
@@ -5129,10 +5235,10 @@ return (_ctx, _cache) => {
5129
5235
  style: vue.normalizeStyle(getPermissionStyle(permission))
5130
5236
  }, [
5131
5237
  vue.withDirectives(vue.createElementVNode("input", {
5132
- "onUpdate:modelValue": _cache[1] || (_cache[1] = $event => ((selectedPermissions).value = $event)),
5238
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => ((selectedPermissions).value = $event)),
5133
5239
  value: permission,
5134
5240
  type: "checkbox"
5135
- }, null, 8 /* PROPS */, _hoisted_11), [
5241
+ }, null, 8 /* PROPS */, _hoisted_12), [
5136
5242
  [vue.vModelCheckbox, selectedPermissions.value]
5137
5243
  ]),
5138
5244
  vue.createTextVNode(" " + vue.toDisplayString(getLabel(permission)), 1 /* TEXT */)
@@ -5142,15 +5248,16 @@ return (_ctx, _cache) => {
5142
5248
  }), 256 /* UNKEYED_FRAGMENT */))
5143
5249
  ]),
5144
5250
  (permissionsChanged.value)
5145
- ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_12, [
5146
- vue.createElementVNode("div", _hoisted_13, [
5147
- vue.createVNode(script$8, {
5251
+ ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_13, [
5252
+ vue.createElementVNode("div", _hoisted_14, [
5253
+ vue.createVNode(script$7, {
5254
+ onSuccess: permissionsUpdated,
5148
5255
  url: `admin/departments/department/permissions/${vue.unref(departmentId)}/${selectedModule.value}`,
5149
5256
  data: {permissions: selectedPermissions.value},
5150
5257
  class: "btn btn-primary d-block"
5151
5258
  }, {
5152
5259
  default: vue.withCtx(() => [
5153
- _hoisted_14,
5260
+ _hoisted_15,
5154
5261
  vue.createTextVNode(" Save")
5155
5262
  ]),
5156
5263
  _: 1 /* STABLE */
@@ -5170,102 +5277,6 @@ return (_ctx, _cache) => {
5170
5277
  script$3.__scopeId = "data-v-0d4fa0ac";
5171
5278
  script$3.__file = "src/lib/components/core/Departments/department/ManagePermissions.vue";
5172
5279
 
5173
- const useUserStore = pinia.defineStore('user-store', {
5174
- state: () => ({
5175
- user: null,
5176
- role: null,
5177
- permissions: null,
5178
- menus: [],
5179
- loggedOut: false
5180
- }),
5181
- actions: {
5182
- setUser (){
5183
- let user = null;
5184
- try {
5185
- user = ShStorage.getItem('user') ? ShStorage.getItem('user') : null;
5186
- } catch (error) {
5187
- user= null;
5188
- }
5189
- if (user) {
5190
- user.isAllowedTo = function (slug) {
5191
- if (this.permissions) {
5192
- let permissions = [];
5193
- if (typeof this.permissions === 'string') {
5194
- permissions = this.permissions;
5195
- } else {
5196
- permissions = this.permissions;
5197
- }
5198
- return permissions.includes(slug)
5199
- }
5200
- return false
5201
- };
5202
- }
5203
- this.user = user;
5204
- shApis.doGet('auth/user').then(res => {
5205
- let user = res.data.user;
5206
- if (typeof(user) === 'undefined') {
5207
- user = res.data;
5208
- }
5209
- ShStorage.setItem('user',user);
5210
- user.signOut = this.signOut;
5211
- user.logout = this.signOut;
5212
- user.logOut = this.signOut;
5213
- user.isAllowedTo = function (slug) {
5214
- if(!slug){
5215
- return true
5216
- }
5217
- if (this.permissions) {
5218
- let permissions = [];
5219
- if (typeof this.permissions === 'string') {
5220
- permissions = this.permissions;
5221
- } else {
5222
- permissions = this.permissions;
5223
- }
5224
- return permissions.includes(slug)
5225
- }
5226
- return false
5227
- };
5228
- this.user = user;
5229
- }).catch((reason) => {
5230
- if (reason.response && reason.response.status) {
5231
- if(reason.response.status === 401) {
5232
- ShStorage.setItem('user',null);
5233
- this.user = null;
5234
- }
5235
- this.loggedOut = true;
5236
- }
5237
- });
5238
- if (this.user) {
5239
- if (typeof this.user.permissions === 'string') {
5240
- this.permissions = this.user.permissions;
5241
- } else {
5242
- this.permissions = this.user.permissions;
5243
- }
5244
- }
5245
- const timeNow = moment__default["default"]().toISOString();
5246
- ShStorage.setItem('session_start',timeNow);
5247
- },
5248
- signOut () {
5249
- shRepo.signOutUser();
5250
- },
5251
- logOut () {
5252
- this.signOut();
5253
- },
5254
- getUser () {
5255
- this.setUser();
5256
- },
5257
- setAccessToken (accessToken) {
5258
- ShStorage.setItem('access_token', accessToken);
5259
- this.setUser();
5260
- }
5261
- },
5262
- getters: {
5263
- userId (state) {
5264
- return state.user === null ? null:state.user.id
5265
- }
5266
- }
5267
- });
5268
-
5269
5280
  const _hoisted_1$2 = /*#__PURE__*/vue.createElementVNode("h5", null, "Departments", -1 /* HOISTED */);
5270
5281
  const _hoisted_2$2 = { class: "card sh-departments-card shadow" };
5271
5282
  const _hoisted_3$2 = { class: "card-body" };
@@ -5316,7 +5327,7 @@ return (_ctx, _cache) => {
5316
5327
  actions: [
5317
5328
  {
5318
5329
  label: 'Permissions',
5319
- path: '/sh-departments/permissions/{id}',
5330
+ path: '/sh-departments/manage-permissions/{id}',
5320
5331
  class: 'btn btn-info bi-lock btn-sm'
5321
5332
  }
5322
5333
  ]
package/dist/library.mjs CHANGED
@@ -2546,7 +2546,7 @@ const _hoisted_11$3 = ["data-cy", "placeholder", "name", "onFocus", "onUpdate:mo
2546
2546
  const _hoisted_12$3 = ["data-cy", "placeholder", "name", "onFocus", "onUpdate:modelValue"];
2547
2547
  const _hoisted_13$3 = ["data-cy", "placeholder", "name", "onFocus", "onUpdate:modelValue"];
2548
2548
  const _hoisted_14$3 = ["data-cy", "name", "onFocus", "onUpdate:modelValue"];
2549
- const _hoisted_15$2 = ["disabled", "placeholder", "name", "onFocus", "onUpdate:modelValue"];
2549
+ const _hoisted_15$3 = ["disabled", "placeholder", "name", "onFocus", "onUpdate:modelValue"];
2550
2550
  const _hoisted_16$2 = ["name", "onFocus", "onUpdate:modelValue"];
2551
2551
  const _hoisted_17$2 = ["name", "onFocus", "onUpdate:modelValue"];
2552
2552
  const _hoisted_18$2 = ["value"];
@@ -2740,7 +2740,7 @@ function render$5(_ctx, _cache, $props, $setup, $data, $options) {
2740
2740
  class: normalizeClass([_ctx.form_errors[field] == null ? ' field_' + field:'is-invalid ' + field, "form-control"]),
2741
2741
  "onUpdate:modelValue": $event => ((_ctx.form_elements[field]) = $event),
2742
2742
  type: "text"
2743
- }, null, 42 /* CLASS, PROPS, HYDRATE_EVENTS */, _hoisted_15$2)), [
2743
+ }, null, 42 /* CLASS, PROPS, HYDRATE_EVENTS */, _hoisted_15$3)), [
2744
2744
  [vModelText, _ctx.form_elements[field]]
2745
2745
  ])
2746
2746
  : createCommentVNode("v-if", true),
@@ -3616,7 +3616,7 @@ const _hoisted_14$2 = {
3616
3616
  key: 1,
3617
3617
  class: "page-link"
3618
3618
  };
3619
- const _hoisted_15$1 = ["onClick"];
3619
+ const _hoisted_15$2 = ["onClick"];
3620
3620
  const _hoisted_16$1 = { key: 1 };
3621
3621
  const _hoisted_17$1 = {
3622
3622
  key: 0,
@@ -3678,7 +3678,7 @@ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
3678
3678
  key: 2,
3679
3679
  onClick: $event => ($options.changeTableKey('page',page)),
3680
3680
  class: "page-link"
3681
- }, toDisplayString(page), 9 /* TEXT, PROPS */, _hoisted_15$1))
3681
+ }, toDisplayString(page), 9 /* TEXT, PROPS */, _hoisted_15$2))
3682
3682
  ], 2 /* CLASS */))
3683
3683
  }), 128 /* KEYED_FRAGMENT */)),
3684
3684
  createElementVNode("li", {
@@ -4197,7 +4197,7 @@ const _hoisted_14$1 = {
4197
4197
  key: 1,
4198
4198
  class: "alert alert-danger"
4199
4199
  };
4200
- const _hoisted_15 = { colspan: 2 };
4200
+ const _hoisted_15$1 = { colspan: 2 };
4201
4201
  const _hoisted_16 = {
4202
4202
  key: 0,
4203
4203
  class: "text-center"
@@ -4366,7 +4366,7 @@ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
4366
4366
  ? (openBlock(), createElementBlock("div", _hoisted_11$1, _hoisted_13$1))
4367
4367
  : ($data.loading === 'error')
4368
4368
  ? (openBlock(), createElementBlock("div", _hoisted_14$1, [
4369
- createElementVNode("span", _hoisted_15, toDisplayString($data.loading_error), 1 /* TEXT */)
4369
+ createElementVNode("span", _hoisted_15$1, toDisplayString($data.loading_error), 1 /* TEXT */)
4370
4370
  ]))
4371
4371
  : createCommentVNode("v-if", true),
4372
4372
  ($data.loading === 'done')
@@ -4971,38 +4971,138 @@ return (_ctx, _cache) => {
4971
4971
 
4972
4972
  script$4.__file = "src/lib/components/ShDynamicTabs.vue";
4973
4973
 
4974
+ const useUserStore = defineStore('user-store', {
4975
+ state: () => ({
4976
+ user: null,
4977
+ role: null,
4978
+ permissions: null,
4979
+ menus: [],
4980
+ loggedOut: false
4981
+ }),
4982
+ actions: {
4983
+ setUser (){
4984
+ let user = null;
4985
+ try {
4986
+ user = ShStorage.getItem('user') ? ShStorage.getItem('user') : null;
4987
+ } catch (error) {
4988
+ user= null;
4989
+ }
4990
+ if (user) {
4991
+ user.isAllowedTo = function (slug) {
4992
+ if (this.permissions) {
4993
+ let permissions = [];
4994
+ if (typeof this.permissions === 'string') {
4995
+ permissions = this.permissions;
4996
+ } else {
4997
+ permissions = this.permissions;
4998
+ }
4999
+ return permissions.includes(slug)
5000
+ }
5001
+ return false
5002
+ };
5003
+ }
5004
+ this.user = user;
5005
+ shApis.doGet('auth/user').then(res => {
5006
+ let user = res.data.user;
5007
+ if (typeof(user) === 'undefined') {
5008
+ user = res.data;
5009
+ }
5010
+ ShStorage.setItem('user',user);
5011
+ user.signOut = this.signOut;
5012
+ user.logout = this.signOut;
5013
+ user.logOut = this.signOut;
5014
+ user.isAllowedTo = function (slug) {
5015
+ if(!slug){
5016
+ return true
5017
+ }
5018
+ if (this.permissions) {
5019
+ let permissions = [];
5020
+ if (typeof this.permissions === 'string') {
5021
+ permissions = this.permissions;
5022
+ } else {
5023
+ permissions = this.permissions;
5024
+ }
5025
+ return permissions.includes(slug)
5026
+ }
5027
+ return false
5028
+ };
5029
+ this.user = user;
5030
+ }).catch((reason) => {
5031
+ if (reason.response && reason.response.status) {
5032
+ if(reason.response.status === 401) {
5033
+ ShStorage.setItem('user',null);
5034
+ this.user = null;
5035
+ }
5036
+ this.loggedOut = true;
5037
+ }
5038
+ });
5039
+ if (this.user) {
5040
+ if (typeof this.user.permissions === 'string') {
5041
+ this.permissions = this.user.permissions;
5042
+ } else {
5043
+ this.permissions = this.user.permissions;
5044
+ }
5045
+ }
5046
+ const timeNow = moment().toISOString();
5047
+ ShStorage.setItem('session_start',timeNow);
5048
+ },
5049
+ signOut () {
5050
+ shRepo.signOutUser();
5051
+ },
5052
+ logOut () {
5053
+ this.signOut();
5054
+ },
5055
+ getUser () {
5056
+ this.setUser();
5057
+ },
5058
+ setAccessToken (accessToken) {
5059
+ ShStorage.setItem('access_token', accessToken);
5060
+ this.setUser();
5061
+ }
5062
+ },
5063
+ getters: {
5064
+ userId (state) {
5065
+ return state.user === null ? null:state.user.id
5066
+ }
5067
+ }
5068
+ });
5069
+
4974
5070
  const _withScopeId$1 = n => (pushScopeId("data-v-0d4fa0ac"),n=n(),popScopeId(),n);
4975
5071
  const _hoisted_1$3 = { class: "row permissions-main d-flex" };
4976
5072
  const _hoisted_2$3 = {
4977
5073
  id: "permissions-nav",
4978
- class: "col-md-2 d-flex align-items-center py-4"
5074
+ class: "col-md-3 d-flex align-items-center py-4"
4979
5075
  };
4980
- const _hoisted_3$3 = ["disabled", "checked"];
4981
- const _hoisted_4$3 = ["onClick"];
4982
- const _hoisted_5$3 = {
5076
+ const _hoisted_3$3 = { class: "d-flex flex-column w-100 px-2" };
5077
+ const _hoisted_4$3 = ["checked", "disabled"];
5078
+ const _hoisted_5$3 = ["onClick"];
5079
+ const _hoisted_6$2 = {
4983
5080
  id: "permissions-content",
4984
- class: "col-md-10 py-4 pe-4 ps-0"
5081
+ class: "col-md-9 py-4 px-4"
4985
5082
  };
4986
- const _hoisted_6$2 = { class: "p-2 rounded-2 bg-white h-100" };
4987
- const _hoisted_7$1 = {
5083
+ const _hoisted_7$1 = { class: "p-2 rounded-2 bg-white h-100" };
5084
+ const _hoisted_8$1 = {
4988
5085
  key: 0,
4989
5086
  class: "alert alert-info"
4990
5087
  };
4991
- const _hoisted_8$1 = { key: 1 };
4992
- const _hoisted_9$1 = { class: "row row-cols-4" };
4993
- const _hoisted_10 = { class: "col py-3" };
4994
- const _hoisted_11 = ["value"];
4995
- const _hoisted_12 = {
5088
+ const _hoisted_9$1 = { key: 1 };
5089
+ const _hoisted_10 = { class: "row row-cols-3" };
5090
+ const _hoisted_11 = { class: "col" };
5091
+ const _hoisted_12 = ["value"];
5092
+ const _hoisted_13 = {
4996
5093
  key: 0,
4997
5094
  class: "w-100 row"
4998
5095
  };
4999
- const _hoisted_13 = { class: "col-md-3" };
5000
- const _hoisted_14 = /*#__PURE__*/ _withScopeId$1(() => /*#__PURE__*/createElementVNode("i", { class: "bi-check" }, null, -1 /* HOISTED */));
5096
+ const _hoisted_14 = { class: "col-md-3" };
5097
+ const _hoisted_15 = /*#__PURE__*/ _withScopeId$1(() => /*#__PURE__*/createElementVNode("i", { class: "bi-check" }, null, -1 /* HOISTED */));
5098
+
5001
5099
 
5002
5100
  var script$3 = {
5003
5101
  __name: 'ManagePermissions',
5004
5102
  setup(__props) {
5005
5103
 
5104
+ const userStore =useUserStore();
5105
+
5006
5106
  const route = useRoute();
5007
5107
  const modules = ref([]);
5008
5108
  const selectedModule = ref('tasks');
@@ -5011,6 +5111,8 @@ const modulePermissions = ref(null);
5011
5111
  const selectedPermissions = ref([]);
5012
5112
  const permissionsChanged = ref(false);
5013
5113
  const departmentId = route.params.id;
5114
+ const department = ref(null);
5115
+ const departmentModules = ref([]);
5014
5116
  const setModule = module=>{
5015
5117
  (selectedModule.value !== module) && (selectedModule.value = module) && getModulePermissions();
5016
5118
  };
@@ -5018,8 +5120,10 @@ onMounted(() => {
5018
5120
  getDepartmentModules();
5019
5121
  });
5020
5122
  const getDepartmentModules = ()=>{
5021
- shApis.doGet(`admin/departments/department/list-all-modules/admin`).then(res=>{
5123
+ shApis.doGet(`admin/departments/department/list-all-modules/admin/${departmentId}`).then(res=>{
5022
5124
  modules.value = res.data.modules;
5125
+ department.value = res.data.department;
5126
+ departmentModules.value = res.data.departmentModules;
5023
5127
  selectedModule.value = res.data.modules[0];
5024
5128
  getModulePermissions();
5025
5129
  });
@@ -5035,6 +5139,10 @@ const getModulePermissions = () => {
5035
5139
  permissionsChanged.value = false;
5036
5140
  });
5037
5141
  };
5142
+ const permissionsUpdated = (res)=>{
5143
+ userStore.setUser();
5144
+ departmentModules.value = res.data.departmentModules;
5145
+ };
5038
5146
  function reformatModulePermissions(mPs){
5039
5147
  let mpModules = {};
5040
5148
  mPs.map(mp=>{
@@ -5055,6 +5163,7 @@ const checkAllPermissions = ()=>{
5055
5163
  if(selectedPermissions.value.length > 0) {
5056
5164
  selectedPermissions.value = [];
5057
5165
  } else {
5166
+ departmentModules.value.push(selectedModule);
5058
5167
  console.log(modulePermissions.value);
5059
5168
  const all = modulePermissions.value;
5060
5169
  Object.keys(all).map(key=>{
@@ -5078,37 +5187,34 @@ const getPermissionStyle = permission => {
5078
5187
  return (_ctx, _cache) => {
5079
5188
  return (openBlock(), createElementBlock("div", _hoisted_1$3, [
5080
5189
  createElementVNode("div", _hoisted_2$3, [
5081
- (openBlock(), createElementBlock("ul", {
5082
- class: "d-flex flex-column w-100 ps-2",
5083
- key: selectedModule.value ? selectedModule.value:0
5084
- }, [
5190
+ createElementVNode("ul", _hoisted_3$3, [
5085
5191
  (openBlock(true), createElementBlock(Fragment, null, renderList(modules.value, (module) => {
5086
5192
  return (openBlock(), createElementBlock("li", {
5087
5193
  class: normalizeClass(selectedModule.value === module && 'active'),
5088
5194
  key: selectedModule.value
5089
5195
  }, [
5090
5196
  createElementVNode("input", {
5091
- onClick: _cache[0] || (_cache[0] = $event => (checkAllPermissions())),
5197
+ checked: departmentModules.value.includes(module),
5198
+ onClick: checkAllPermissions,
5092
5199
  disabled: selectedModule.value !== module,
5093
- checked: selectedPermissions.value.length > 0 && selectedModule.value === module,
5094
5200
  type: "checkbox"
5095
- }, null, 8 /* PROPS */, _hoisted_3$3),
5201
+ }, null, 8 /* PROPS */, _hoisted_4$3),
5096
5202
  createElementVNode("label", {
5097
5203
  class: "text-capitalize",
5098
5204
  onClick: $event => (setModule(module))
5099
- }, toDisplayString(module.replaceAll('_',' ')), 9 /* TEXT, PROPS */, _hoisted_4$3)
5205
+ }, toDisplayString(module.replaceAll('_',' ')), 9 /* TEXT, PROPS */, _hoisted_5$3)
5100
5206
  ], 2 /* CLASS */))
5101
5207
  }), 128 /* KEYED_FRAGMENT */))
5102
- ]))
5208
+ ])
5103
5209
  ]),
5104
- createElementVNode("div", _hoisted_5$3, [
5105
- createElementVNode("div", _hoisted_6$2, [
5210
+ createElementVNode("div", _hoisted_6$2, [
5211
+ createElementVNode("div", _hoisted_7$1, [
5106
5212
  (loading.value)
5107
- ? (openBlock(), createElementBlock("div", _hoisted_7$1, " loading ... "))
5108
- : (openBlock(), createElementBlock("div", _hoisted_8$1, [
5109
- createElementVNode("div", _hoisted_9$1, [
5213
+ ? (openBlock(), createElementBlock("div", _hoisted_8$1, " loading ... "))
5214
+ : (openBlock(), createElementBlock("div", _hoisted_9$1, [
5215
+ createElementVNode("div", _hoisted_10, [
5110
5216
  (openBlock(true), createElementBlock(Fragment, null, renderList(modulePermissions.value, (permissions) => {
5111
- return (openBlock(), createElementBlock("div", _hoisted_10, [
5217
+ return (openBlock(), createElementBlock("div", _hoisted_11, [
5112
5218
  (openBlock(true), createElementBlock(Fragment, null, renderList(permissions, (permission) => {
5113
5219
  return (openBlock(), createElementBlock("label", {
5114
5220
  onClick: setPermissionsChanged,
@@ -5116,10 +5222,10 @@ return (_ctx, _cache) => {
5116
5222
  style: normalizeStyle(getPermissionStyle(permission))
5117
5223
  }, [
5118
5224
  withDirectives(createElementVNode("input", {
5119
- "onUpdate:modelValue": _cache[1] || (_cache[1] = $event => ((selectedPermissions).value = $event)),
5225
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => ((selectedPermissions).value = $event)),
5120
5226
  value: permission,
5121
5227
  type: "checkbox"
5122
- }, null, 8 /* PROPS */, _hoisted_11), [
5228
+ }, null, 8 /* PROPS */, _hoisted_12), [
5123
5229
  [vModelCheckbox, selectedPermissions.value]
5124
5230
  ]),
5125
5231
  createTextVNode(" " + toDisplayString(getLabel(permission)), 1 /* TEXT */)
@@ -5129,15 +5235,16 @@ return (_ctx, _cache) => {
5129
5235
  }), 256 /* UNKEYED_FRAGMENT */))
5130
5236
  ]),
5131
5237
  (permissionsChanged.value)
5132
- ? (openBlock(), createElementBlock("div", _hoisted_12, [
5133
- createElementVNode("div", _hoisted_13, [
5134
- createVNode(script$8, {
5238
+ ? (openBlock(), createElementBlock("div", _hoisted_13, [
5239
+ createElementVNode("div", _hoisted_14, [
5240
+ createVNode(script$7, {
5241
+ onSuccess: permissionsUpdated,
5135
5242
  url: `admin/departments/department/permissions/${unref(departmentId)}/${selectedModule.value}`,
5136
5243
  data: {permissions: selectedPermissions.value},
5137
5244
  class: "btn btn-primary d-block"
5138
5245
  }, {
5139
5246
  default: withCtx(() => [
5140
- _hoisted_14,
5247
+ _hoisted_15,
5141
5248
  createTextVNode(" Save")
5142
5249
  ]),
5143
5250
  _: 1 /* STABLE */
@@ -5157,102 +5264,6 @@ return (_ctx, _cache) => {
5157
5264
  script$3.__scopeId = "data-v-0d4fa0ac";
5158
5265
  script$3.__file = "src/lib/components/core/Departments/department/ManagePermissions.vue";
5159
5266
 
5160
- const useUserStore = defineStore('user-store', {
5161
- state: () => ({
5162
- user: null,
5163
- role: null,
5164
- permissions: null,
5165
- menus: [],
5166
- loggedOut: false
5167
- }),
5168
- actions: {
5169
- setUser (){
5170
- let user = null;
5171
- try {
5172
- user = ShStorage.getItem('user') ? ShStorage.getItem('user') : null;
5173
- } catch (error) {
5174
- user= null;
5175
- }
5176
- if (user) {
5177
- user.isAllowedTo = function (slug) {
5178
- if (this.permissions) {
5179
- let permissions = [];
5180
- if (typeof this.permissions === 'string') {
5181
- permissions = this.permissions;
5182
- } else {
5183
- permissions = this.permissions;
5184
- }
5185
- return permissions.includes(slug)
5186
- }
5187
- return false
5188
- };
5189
- }
5190
- this.user = user;
5191
- shApis.doGet('auth/user').then(res => {
5192
- let user = res.data.user;
5193
- if (typeof(user) === 'undefined') {
5194
- user = res.data;
5195
- }
5196
- ShStorage.setItem('user',user);
5197
- user.signOut = this.signOut;
5198
- user.logout = this.signOut;
5199
- user.logOut = this.signOut;
5200
- user.isAllowedTo = function (slug) {
5201
- if(!slug){
5202
- return true
5203
- }
5204
- if (this.permissions) {
5205
- let permissions = [];
5206
- if (typeof this.permissions === 'string') {
5207
- permissions = this.permissions;
5208
- } else {
5209
- permissions = this.permissions;
5210
- }
5211
- return permissions.includes(slug)
5212
- }
5213
- return false
5214
- };
5215
- this.user = user;
5216
- }).catch((reason) => {
5217
- if (reason.response && reason.response.status) {
5218
- if(reason.response.status === 401) {
5219
- ShStorage.setItem('user',null);
5220
- this.user = null;
5221
- }
5222
- this.loggedOut = true;
5223
- }
5224
- });
5225
- if (this.user) {
5226
- if (typeof this.user.permissions === 'string') {
5227
- this.permissions = this.user.permissions;
5228
- } else {
5229
- this.permissions = this.user.permissions;
5230
- }
5231
- }
5232
- const timeNow = moment().toISOString();
5233
- ShStorage.setItem('session_start',timeNow);
5234
- },
5235
- signOut () {
5236
- shRepo.signOutUser();
5237
- },
5238
- logOut () {
5239
- this.signOut();
5240
- },
5241
- getUser () {
5242
- this.setUser();
5243
- },
5244
- setAccessToken (accessToken) {
5245
- ShStorage.setItem('access_token', accessToken);
5246
- this.setUser();
5247
- }
5248
- },
5249
- getters: {
5250
- userId (state) {
5251
- return state.user === null ? null:state.user.id
5252
- }
5253
- }
5254
- });
5255
-
5256
5267
  const _hoisted_1$2 = /*#__PURE__*/createElementVNode("h5", null, "Departments", -1 /* HOISTED */);
5257
5268
  const _hoisted_2$2 = { class: "card sh-departments-card shadow" };
5258
5269
  const _hoisted_3$2 = { class: "card-body" };
@@ -5303,7 +5314,7 @@ return (_ctx, _cache) => {
5303
5314
  actions: [
5304
5315
  {
5305
5316
  label: 'Permissions',
5306
- path: '/sh-departments/permissions/{id}',
5317
+ path: '/sh-departments/manage-permissions/{id}',
5307
5318
  class: 'btn btn-info bi-lock btn-sm'
5308
5319
  }
5309
5320
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iankibetsh/shframework",
3
- "version": "1.4.6",
3
+ "version": "1.4.8",
4
4
  "description": "Vue library for handling laravel backend",
5
5
  "main": "dist/library.js",
6
6
  "module": "dist/library.mjs",