@iankibetsh/shframework 0.5.2 → 0.5.3

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.
@@ -31,6 +31,21 @@
31
31
  opacity: 0.5;
32
32
  }
33
33
 
34
+ .sh-selected-item{
35
+ line-height: unset!important;
36
+ }
37
+ .sh-suggestion-input{
38
+ padding: 0.375rem 0.75rem;
39
+ }
40
+ .sh-suggest{
41
+ margin-bottom: 1rem;
42
+ }
43
+ .sh-suggest-control::after{
44
+ margin-top: auto;
45
+ margin-bottom: auto;
46
+ margin-right: 0.255em;
47
+ }
48
+
34
49
  :root {
35
50
  --ck-z-default: 10555 !important;
36
51
  --ck-z-modal: calc(var(--ck-z-default) + 999) !important;
@@ -51,18 +66,3 @@
51
66
  width: 100% !important;
52
67
  }
53
68
  }
54
-
55
- .sh-selected-item{
56
- line-height: unset!important;
57
- }
58
- .sh-suggestion-input{
59
- padding: 0.375rem 0.75rem;
60
- }
61
- .sh-suggest{
62
- margin-bottom: 1rem;
63
- }
64
- .sh-suggest-control::after{
65
- margin-top: auto;
66
- margin-bottom: auto;
67
- margin-right: 0.255em;
68
- }
package/dist/library.js CHANGED
@@ -3,19 +3,19 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var Axios = require('axios');
6
+ var pinia = require('pinia');
7
+ var moment = require('moment');
6
8
  var NProgress = require('nprogress');
7
9
  var vue = require('vue');
8
10
  var Editor = require('@tinymce/tinymce-vue');
9
- var moment = require('moment');
10
11
  var Swal = require('sweetalert2');
11
- var pinia = require('pinia');
12
12
 
13
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
14
 
15
15
  var Axios__default = /*#__PURE__*/_interopDefaultLegacy(Axios);
16
+ var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
16
17
  var NProgress__default = /*#__PURE__*/_interopDefaultLegacy(NProgress);
17
18
  var Editor__default = /*#__PURE__*/_interopDefaultLegacy(Editor);
18
- var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
19
19
  var Swal__default = /*#__PURE__*/_interopDefaultLegacy(Swal);
20
20
 
21
21
  function setItem (key, value) {
@@ -38,6 +38,92 @@ var shstorage = {
38
38
  removeItem
39
39
  };
40
40
 
41
+ const useUserStore = pinia.defineStore('user-store', {
42
+ state: () => ({
43
+ user: null,
44
+ role: null,
45
+ permissions: null,
46
+ menus: [],
47
+ loggedOut: false
48
+ }),
49
+ actions: {
50
+ setUser (){
51
+ const user = shstorage.getItem('user') ? JSON.parse(shstorage.getItem('user')) : null;
52
+ if (user) {
53
+ user.isAllowedTo = function (slug) {
54
+ if (this.permissions) {
55
+ let permissions = [];
56
+ if (typeof this.permissions === 'string') {
57
+ permissions = JSON.parse(this.permissions);
58
+ } else {
59
+ permissions = this.permissions;
60
+ }
61
+ return permissions.includes(slug)
62
+ }
63
+ return false
64
+ };
65
+ }
66
+ this.user = user;
67
+ apis.doGet('auth/user').then(res => {
68
+ const user = res.data;
69
+ shstorage.setItem('user',res.data);
70
+ user.isAllowedTo = function (slug) {
71
+ if (this.permissions) {
72
+ let permissions = [];
73
+ if (typeof this.permissions === 'string') {
74
+ permissions = JSON.parse(this.permissions);
75
+ } else {
76
+ permissions = this.permissions;
77
+ }
78
+ return permissions.includes(slug)
79
+ }
80
+ return false
81
+ };
82
+ this.user = user;
83
+ }).catch((reason) => {
84
+ if (reason.response && reason.response.status) {
85
+ this.loggedOut = true;
86
+ }
87
+ });
88
+ if (this.user) {
89
+ if (typeof this.user.permissions === 'string') {
90
+ this.permissions = JSON.parse(this.user.permissions);
91
+ } else {
92
+ this.permissions = this.user.permissions;
93
+ }
94
+ }
95
+ },
96
+ signOut () {
97
+ shstorage.setItem('user',null);
98
+ shstorage.setItem('access_token',null);
99
+ this.user = null;
100
+ },
101
+ logOut () {
102
+ this.signOut();
103
+ },
104
+ getUser () {
105
+ this.setUser();
106
+ },
107
+ setAccessToken (accessToken) {
108
+ shstorage.setItem('access_token', accessToken);
109
+ this.setUser();
110
+ }
111
+ },
112
+ getters: {
113
+ userId (state) {
114
+ return state.user === null ? null:state.user.id
115
+ }
116
+ }
117
+ });
118
+
119
+ const shSetSessionChecker = () => {
120
+
121
+ };
122
+
123
+ var shSession = {
124
+ shSetSessionChecker
125
+ };
126
+
41
127
  let apiUrl = undefined.VITE_APP_API_URL;
42
128
  // eslint-disable-next-line no-undef
43
129
  if (process.env.NODE_ENV === 'production') {
@@ -47,6 +133,7 @@ const axios = Axios__default["default"].create({
47
133
  baseURL: apiUrl
48
134
  });
49
135
  function doGet (endPoint, data) {
136
+ shSession.shSetSessionChecker();
50
137
  return axios.get(endPoint, {
51
138
  params: data,
52
139
  crossOrigin: true,
@@ -57,6 +144,7 @@ function doGet (endPoint, data) {
57
144
  })
58
145
  }
59
146
  function doPost (endPoint, data) {
147
+ shSession.shSetSessionChecker();
60
148
  return axios.post(endPoint,
61
149
  data,
62
150
  {
@@ -1651,7 +1739,7 @@ function render$7(_ctx, _cache, $props, $setup, $data, $options) {
1651
1739
  }
1652
1740
 
1653
1741
  script$8.render = render$7;
1654
- script$8.__file = "src/views/ShPhone.vue";
1742
+ script$8.__file = "src/lib/components/ShPhone.vue";
1655
1743
 
1656
1744
  var script$7 = {
1657
1745
  name: 'ShEditor',
@@ -1728,7 +1816,7 @@ function render$6(_ctx, _cache, $props, $setup, $data, $options) {
1728
1816
  }
1729
1817
 
1730
1818
  script$7.render = render$6;
1731
- script$7.__file = "src/views/FormComponent/ShEditor.vue";
1819
+ script$7.__file = "src/lib/components/FormComponent/ShEditor.vue";
1732
1820
 
1733
1821
  const _hoisted_1$6 = {
1734
1822
  key: 0,
@@ -1738,7 +1826,7 @@ const _hoisted_2$6 = ["id"];
1738
1826
  const _hoisted_3$6 = { class: "badge bg-secondary m-1 sh-selected-item" };
1739
1827
  const _hoisted_4$6 = ["onClick"];
1740
1828
  const _hoisted_5$5 = ["id"];
1741
- const _hoisted_6$3 = ["aria-labelledby"];
1829
+ const _hoisted_6$3 = ["id", "aria-labelledby"];
1742
1830
  const _hoisted_7$3 = { key: 0 };
1743
1831
  const _hoisted_8$2 = ["onClick"];
1744
1832
  const _hoisted_9$2 = {
@@ -1776,7 +1864,7 @@ function resetData(){
1776
1864
  }
1777
1865
  function addSuggestion(sgn){
1778
1866
  let selected = selectedSuggestions.value;
1779
- if(selected.length > 0 && !props.fillSelects.allow_multiple){
1867
+ if(selected.length > 0 && !props.fillSelects.allowMultiple){
1780
1868
  selected = [];
1781
1869
  }
1782
1870
  if(!selected.includes(sgn)){
@@ -1790,7 +1878,7 @@ function updateModelValue(){
1790
1878
  let selectedItems = selectedSuggestions.value;
1791
1879
  if(selectedItems.length === 0) {
1792
1880
  emit('update:modelValue', null);
1793
- } else if (!props.fillSelects.allow_multiple) {
1881
+ } else if (!props.fillSelects.allowMultiple) {
1794
1882
  emit('update:modelValue', selectedItems[0].id);
1795
1883
  } else {
1796
1884
  const ids = selectedItems.map(item => {
@@ -1809,6 +1897,10 @@ function removeSuggestion(sgt){
1809
1897
  }
1810
1898
  let searchText = vue.ref(null);
1811
1899
  function filterData(e){
1900
+ let dropdownElem = document.getElementById('dropwdown_section' + id.value);
1901
+ if(!dropdownElem.classList.contains('show')){
1902
+ dropdownElem.classList.add('show');
1903
+ }
1812
1904
  let filterValue = e.target.innerText;
1813
1905
  searchText.value = filterValue;
1814
1906
  if(props.fillSelects.data) {
@@ -1857,6 +1949,7 @@ return (_ctx, _cache) => {
1857
1949
  ], 8 /* PROPS */, _hoisted_2$6),
1858
1950
  vue.createElementVNode("ul", {
1859
1951
  class: "dropdown-menu w-100",
1952
+ id: 'dropwdown_section' + vue.unref(id),
1860
1953
  "aria-labelledby": vue.unref(id)
1861
1954
  }, [
1862
1955
  (vue.unref(suggestions) && vue.unref(suggestions).length > 0)
@@ -1886,8 +1979,8 @@ return (_ctx, _cache) => {
1886
1979
 
1887
1980
  };
1888
1981
 
1889
- script$6.__scopeId = "data-v-043a2b8f";
1890
- script$6.__file = "src/views/FormComponent/ShSuggest.vue";
1982
+ script$6.__scopeId = "data-v-5b767123";
1983
+ script$6.__file = "src/lib/components/FormComponent/ShSuggest.vue";
1891
1984
 
1892
1985
  var script$5 = {
1893
1986
  name: 'ShForm',
@@ -1915,6 +2008,8 @@ var script$5 = {
1915
2008
  data: function () {
1916
2009
  return {
1917
2010
  form_elements: {},
2011
+ errorStatusCode: 0,
2012
+ errorText: null,
1918
2013
  form_errors: {},
1919
2014
  form_status: 0,
1920
2015
  error_res: null,
@@ -2047,6 +2142,9 @@ var script$5 = {
2047
2142
  }
2048
2143
  }
2049
2144
  },
2145
+ hideError: function (){
2146
+ this.form_status = 0;
2147
+ },
2050
2148
  closeModal: function () {
2051
2149
  document.body.style = '';
2052
2150
  setTimeout(() => {
@@ -2066,6 +2164,7 @@ var script$5 = {
2066
2164
  }, 1500);
2067
2165
  },
2068
2166
  submitForm: async function () {
2167
+ this.errorText = null;
2069
2168
  // return false;
2070
2169
  // if (!this.validateEssentials()) {
2071
2170
  // return false
@@ -2110,6 +2209,7 @@ var script$5 = {
2110
2209
  this.form_status = 3;
2111
2210
  if (typeof reason !== 'undefined') {
2112
2211
  if (typeof reason.response !== 'undefined') {
2212
+ this.errorText = reason.message;
2113
2213
  this.setErrors(reason.response);
2114
2214
  } else {
2115
2215
  console.log('catch error');
@@ -2118,6 +2218,10 @@ var script$5 = {
2118
2218
  } else {
2119
2219
  console.log(reason);
2120
2220
  }
2221
+ const self = this;
2222
+ setTimeout(() => {
2223
+ self.hideError();
2224
+ }, 4000);
2121
2225
  });
2122
2226
  return false
2123
2227
  },
@@ -2197,17 +2301,18 @@ var script$5 = {
2197
2301
  }
2198
2302
  };
2199
2303
 
2200
- const _hoisted_1$5 = { ref: "ShAutoForm" };
2304
+ const _hoisted_1$5 = {
2305
+ ref: "ShAutoForm",
2306
+ class: "sh-form"
2307
+ };
2201
2308
  const _hoisted_2$5 = {
2202
2309
  key: 0,
2203
- class: "alert alert-danger"
2310
+ class: "alert alert-danger alert-dismissible fade show sh-form-submission-error",
2311
+ role: "alert"
2204
2312
  };
2205
- const _hoisted_3$5 = /*#__PURE__*/vue.createElementVNode("i", { class: "fa fa-warning" }, null, -1 /* HOISTED */);
2206
- const _hoisted_4$5 = /*#__PURE__*/vue.createTextVNode(" Error");
2207
- const _hoisted_5$4 = [
2208
- _hoisted_3$5,
2209
- _hoisted_4$5
2210
- ];
2313
+ const _hoisted_3$5 = /*#__PURE__*/vue.createElementVNode("i", { class: "bi-exclamation-triangle-fill me-1" }, null, -1 /* HOISTED */);
2314
+ const _hoisted_4$5 = { key: 0 };
2315
+ const _hoisted_5$4 = { key: 1 };
2211
2316
  const _hoisted_6$2 = { class: "row" };
2212
2317
  const _hoisted_7$2 = { class: "fg-label control-label text-capitalize control-bel col-md-12 request-form-label mb-2" };
2213
2318
  const _hoisted_8$1 = { class: "col-md-12" };
@@ -2245,12 +2350,16 @@ const _hoisted_22$2 = [
2245
2350
  _hoisted_20$2,
2246
2351
  _hoisted_21$2
2247
2352
  ];
2248
- const _hoisted_23$2 = {
2249
- key: 0,
2250
- style: {"height":"1rem"},
2251
- class: "float-left",
2252
- src: "/assets/img/spinner.gif"
2253
- };
2353
+ const _hoisted_23$2 = /*#__PURE__*/vue.createElementVNode("span", {
2354
+ class: "spinner-border spinner-border-sm",
2355
+ role: "status",
2356
+ "aria-hidden": "true"
2357
+ }, null, -1 /* HOISTED */);
2358
+ const _hoisted_24$1 = /*#__PURE__*/vue.createTextVNode(" Processing... ");
2359
+ const _hoisted_25$1 = [
2360
+ _hoisted_23$2,
2361
+ _hoisted_24$1
2362
+ ];
2254
2363
 
2255
2364
  function render$5(_ctx, _cache, $props, $setup, $data, $options) {
2256
2365
  const _component_ShPhone = vue.resolveComponent("ShPhone");
@@ -2261,11 +2370,22 @@ function render$5(_ctx, _cache, $props, $setup, $data, $options) {
2261
2370
  vue.createCommentVNode(" <div v-if=\"form_status == 1\" class=\"alert alert-info\">Processing...</div>"),
2262
2371
  vue.createCommentVNode(" <div v-if=\"form_status == 2\" class=\"alert alert-success\">Success</div>"),
2263
2372
  (_ctx.form_status == 3)
2264
- ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$5, _hoisted_5$4))
2373
+ ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$5, [
2374
+ _hoisted_3$5,
2375
+ (_ctx.errorText)
2376
+ ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_4$5, vue.toDisplayString(_ctx.errorText), 1 /* TEXT */))
2377
+ : (vue.openBlock(), vue.createElementBlock("span", _hoisted_5$4, "Unexpected Error Occurred")),
2378
+ vue.createElementVNode("button", {
2379
+ onClick: _cache[0] || (_cache[0] = (...args) => ($options.hideError && $options.hideError(...args))),
2380
+ type: "button",
2381
+ class: "btn-close",
2382
+ "aria-label": "Close"
2383
+ })
2384
+ ]))
2265
2385
  : vue.createCommentVNode("v-if", true),
2266
2386
  vue.withDirectives(vue.createElementVNode("input", {
2267
2387
  type: "hidden",
2268
- "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => ((_ctx.form_elements['id']) = $event))
2388
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = $event => ((_ctx.form_elements['id']) = $event))
2269
2389
  }, null, 512 /* NEED_PATCH */), [
2270
2390
  [vue.vModelText, _ctx.form_elements['id']]
2271
2391
  ]),
@@ -2434,22 +2554,25 @@ function render$5(_ctx, _cache, $props, $setup, $data, $options) {
2434
2554
  ($props.hasTerms)
2435
2555
  ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_19$2, _hoisted_22$2))
2436
2556
  : vue.createCommentVNode("v-if", true),
2437
- vue.createElementVNode("button", {
2438
- "data-cy": "sh_form_submit",
2439
- class: vue.normalizeClass(["mb-2 form-submit-btn", _ctx.form_status == 1 ? $options.getSubmitBtnClass() + ' disabled': $options.getSubmitBtnClass()]),
2440
- type: "button",
2441
- onClick: _cache[1] || (_cache[1] = (...args) => ($options.submitForm && $options.submitForm(...args)))
2442
- }, [
2443
- vue.createTextVNode(vue.toDisplayString($props.actionLabel ? $props.actionLabel:'Submit') + " ", 1 /* TEXT */),
2444
- (_ctx.form_status == 1)
2445
- ? (vue.openBlock(), vue.createElementBlock("img", _hoisted_23$2))
2446
- : vue.createCommentVNode("v-if", true)
2447
- ], 2 /* CLASS */)
2557
+ (_ctx.form_status == 1)
2558
+ ? (vue.openBlock(), vue.createElementBlock("button", {
2559
+ key: 2,
2560
+ class: vue.normalizeClass(["btn btn-primary", $options.getSubmitBtnClass()]),
2561
+ type: "button",
2562
+ disabled: ""
2563
+ }, _hoisted_25$1, 2 /* CLASS */))
2564
+ : (vue.openBlock(), vue.createElementBlock("button", {
2565
+ key: 3,
2566
+ "data-cy": "sh_form_submit",
2567
+ class: vue.normalizeClass(["mb-2 form-submit-btn", $options.getSubmitBtnClass()]),
2568
+ type: "button",
2569
+ onClick: _cache[2] || (_cache[2] = (...args) => ($options.submitForm && $options.submitForm(...args)))
2570
+ }, vue.toDisplayString($props.actionLabel ? $props.actionLabel:'Submit'), 3 /* TEXT, CLASS */))
2448
2571
  ], 512 /* NEED_PATCH */))
2449
2572
  }
2450
2573
 
2451
2574
  script$5.render = render$5;
2452
- script$5.__file = "src/views/ShForm.vue";
2575
+ script$5.__file = "src/lib/components/ShForm.vue";
2453
2576
 
2454
2577
  var script$4 = {
2455
2578
  name: 'ShCanvas',
@@ -2502,7 +2625,7 @@ function render$4(_ctx, _cache, $props, $setup, $data, $options) {
2502
2625
  }
2503
2626
 
2504
2627
  script$4.render = render$4;
2505
- script$4.__file = "src/views/ShCanvas.vue";
2628
+ script$4.__file = "src/lib/components/ShCanvas.vue";
2506
2629
 
2507
2630
  var script$3 = {
2508
2631
  name: 'ShModal',
@@ -2550,7 +2673,7 @@ function render$3(_ctx, _cache, $props, $setup, $data, $options) {
2550
2673
  }
2551
2674
 
2552
2675
  script$3.render = render$3;
2553
- script$3.__file = "src/views/ShModal.vue";
2676
+ script$3.__file = "src/lib/components/ShModal.vue";
2554
2677
 
2555
2678
  var script$2 = {
2556
2679
  name: 'Pagination',
@@ -2743,7 +2866,7 @@ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
2743
2866
  }
2744
2867
 
2745
2868
  script$2.render = render$2;
2746
- script$2.__file = "src/views/list_templates/Pagination.vue";
2869
+ script$2.__file = "src/lib/components/list_templates/Pagination.vue";
2747
2870
 
2748
2871
  function swalSuccess (message) {
2749
2872
  Swal__default["default"].fire('Success!', message, 'success');
@@ -3624,7 +3747,7 @@ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
3624
3747
  }
3625
3748
 
3626
3749
  script$1.render = render$1;
3627
- script$1.__file = "src/views/ShTable.vue";
3750
+ script$1.__file = "src/lib/components/ShTable.vue";
3628
3751
 
3629
3752
  var script = {
3630
3753
  name: 'ShTabs',
@@ -3779,85 +3902,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
3779
3902
  }
3780
3903
 
3781
3904
  script.render = render;
3782
- script.__file = "src/views/ShTabs.vue";
3783
-
3784
- const useUserStore = pinia.defineStore('user-store', {
3785
- state: () => ({
3786
- user: null,
3787
- role: null,
3788
- permissions: null,
3789
- menus: [],
3790
- loggedOut: false
3791
- }),
3792
- actions: {
3793
- setUser (){
3794
- const user = shstorage.getItem('user') ? JSON.parse(shstorage.getItem('user')) : null;
3795
- if (user) {
3796
- user.isAllowedTo = function (slug) {
3797
- if (this.permissions) {
3798
- let permissions = [];
3799
- if (typeof this.permissions === 'string') {
3800
- permissions = JSON.parse(this.permissions);
3801
- } else {
3802
- permissions = this.permissions;
3803
- }
3804
- return permissions.includes(slug)
3805
- }
3806
- return false
3807
- };
3808
- }
3809
- this.user = user;
3810
- apis.doGet('auth/user').then(res => {
3811
- shstorage.setItem('user',res.data);
3812
- const user = res.data;
3813
- user.isAllowedTo = function (slug) {
3814
- if (this.permissions) {
3815
- let permissions = [];
3816
- if (typeof this.permissions === 'string') {
3817
- permissions = JSON.parse(this.permissions);
3818
- } else {
3819
- permissions = this.permissions;
3820
- }
3821
- return permissions.includes(slug)
3822
- }
3823
- return false
3824
- };
3825
- this.user = user;
3826
- }).catch((reason) => {
3827
- if (reason.response && reason.response.status) {
3828
- this.loggedOut = true;
3829
- }
3830
- });
3831
- if (this.user) {
3832
- if (typeof this.user.permissions === 'string') {
3833
- this.permissions = JSON.parse(this.user.permissions);
3834
- } else {
3835
- this.permissions = this.user.permissions;
3836
- }
3837
- }
3838
- },
3839
- signOut () {
3840
- shstorage.setItem('user',null);
3841
- shstorage.setItem('access_token',null);
3842
- this.user = null;
3843
- },
3844
- logOut () {
3845
- this.signOut();
3846
- },
3847
- getUser () {
3848
- this.setUser();
3849
- },
3850
- setAccessToken (accessToken) {
3851
- shstorage.setItem('access_token', accessToken);
3852
- this.setUser();
3853
- }
3854
- },
3855
- getters: {
3856
- userId (state) {
3857
- return state.user === null ? null:state.user.id
3858
- }
3859
- }
3860
- });
3905
+ script.__file = "src/lib/components/ShTabs.vue";
3861
3906
 
3862
3907
  exports.ShCanvas = script$4;
3863
3908
  exports.ShForm = script$5;
package/dist/library.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import Axios from 'axios';
2
+ import { defineStore } from 'pinia';
3
+ import moment from 'moment';
2
4
  import NProgress from 'nprogress';
3
5
  import { openBlock, createElementBlock, createElementVNode, createTextVNode, toDisplayString, createCommentVNode, withDirectives, Fragment, renderList, vModelSelect, vModelText, resolveComponent, withModifiers, createVNode, ref, onMounted, unref, normalizeClass, createBlock, renderSlot, createStaticVNode, withCtx } from 'vue';
4
6
  import Editor from '@tinymce/tinymce-vue';
5
- import moment from 'moment';
6
7
  import Swal from 'sweetalert2';
7
- import { defineStore } from 'pinia';
8
8
 
9
9
  function setItem (key, value) {
10
10
  let toStore = value;
@@ -26,6 +26,92 @@ var shstorage = {
26
26
  removeItem
27
27
  };
28
28
 
29
+ const useUserStore = defineStore('user-store', {
30
+ state: () => ({
31
+ user: null,
32
+ role: null,
33
+ permissions: null,
34
+ menus: [],
35
+ loggedOut: false
36
+ }),
37
+ actions: {
38
+ setUser (){
39
+ const user = shstorage.getItem('user') ? JSON.parse(shstorage.getItem('user')) : null;
40
+ if (user) {
41
+ user.isAllowedTo = function (slug) {
42
+ if (this.permissions) {
43
+ let permissions = [];
44
+ if (typeof this.permissions === 'string') {
45
+ permissions = JSON.parse(this.permissions);
46
+ } else {
47
+ permissions = this.permissions;
48
+ }
49
+ return permissions.includes(slug)
50
+ }
51
+ return false
52
+ };
53
+ }
54
+ this.user = user;
55
+ apis.doGet('auth/user').then(res => {
56
+ const user = res.data;
57
+ shstorage.setItem('user',res.data);
58
+ user.isAllowedTo = function (slug) {
59
+ if (this.permissions) {
60
+ let permissions = [];
61
+ if (typeof this.permissions === 'string') {
62
+ permissions = JSON.parse(this.permissions);
63
+ } else {
64
+ permissions = this.permissions;
65
+ }
66
+ return permissions.includes(slug)
67
+ }
68
+ return false
69
+ };
70
+ this.user = user;
71
+ }).catch((reason) => {
72
+ if (reason.response && reason.response.status) {
73
+ this.loggedOut = true;
74
+ }
75
+ });
76
+ if (this.user) {
77
+ if (typeof this.user.permissions === 'string') {
78
+ this.permissions = JSON.parse(this.user.permissions);
79
+ } else {
80
+ this.permissions = this.user.permissions;
81
+ }
82
+ }
83
+ },
84
+ signOut () {
85
+ shstorage.setItem('user',null);
86
+ shstorage.setItem('access_token',null);
87
+ this.user = null;
88
+ },
89
+ logOut () {
90
+ this.signOut();
91
+ },
92
+ getUser () {
93
+ this.setUser();
94
+ },
95
+ setAccessToken (accessToken) {
96
+ shstorage.setItem('access_token', accessToken);
97
+ this.setUser();
98
+ }
99
+ },
100
+ getters: {
101
+ userId (state) {
102
+ return state.user === null ? null:state.user.id
103
+ }
104
+ }
105
+ });
106
+
107
+ const shSetSessionChecker = () => {
108
+
109
+ };
110
+
111
+ var shSession = {
112
+ shSetSessionChecker
113
+ };
114
+
29
115
  let apiUrl = import.meta.env.VITE_APP_API_URL;
30
116
  // eslint-disable-next-line no-undef
31
117
  if (process.env.NODE_ENV === 'production') {
@@ -35,6 +121,7 @@ const axios = Axios.create({
35
121
  baseURL: apiUrl
36
122
  });
37
123
  function doGet (endPoint, data) {
124
+ shSession.shSetSessionChecker();
38
125
  return axios.get(endPoint, {
39
126
  params: data,
40
127
  crossOrigin: true,
@@ -45,6 +132,7 @@ function doGet (endPoint, data) {
45
132
  })
46
133
  }
47
134
  function doPost (endPoint, data) {
135
+ shSession.shSetSessionChecker();
48
136
  return axios.post(endPoint,
49
137
  data,
50
138
  {
@@ -1639,7 +1727,7 @@ function render$7(_ctx, _cache, $props, $setup, $data, $options) {
1639
1727
  }
1640
1728
 
1641
1729
  script$8.render = render$7;
1642
- script$8.__file = "src/views/ShPhone.vue";
1730
+ script$8.__file = "src/lib/components/ShPhone.vue";
1643
1731
 
1644
1732
  var script$7 = {
1645
1733
  name: 'ShEditor',
@@ -1716,7 +1804,7 @@ function render$6(_ctx, _cache, $props, $setup, $data, $options) {
1716
1804
  }
1717
1805
 
1718
1806
  script$7.render = render$6;
1719
- script$7.__file = "src/views/FormComponent/ShEditor.vue";
1807
+ script$7.__file = "src/lib/components/FormComponent/ShEditor.vue";
1720
1808
 
1721
1809
  const _hoisted_1$6 = {
1722
1810
  key: 0,
@@ -1726,7 +1814,7 @@ const _hoisted_2$6 = ["id"];
1726
1814
  const _hoisted_3$6 = { class: "badge bg-secondary m-1 sh-selected-item" };
1727
1815
  const _hoisted_4$6 = ["onClick"];
1728
1816
  const _hoisted_5$5 = ["id"];
1729
- const _hoisted_6$3 = ["aria-labelledby"];
1817
+ const _hoisted_6$3 = ["id", "aria-labelledby"];
1730
1818
  const _hoisted_7$3 = { key: 0 };
1731
1819
  const _hoisted_8$2 = ["onClick"];
1732
1820
  const _hoisted_9$2 = {
@@ -1764,7 +1852,7 @@ function resetData(){
1764
1852
  }
1765
1853
  function addSuggestion(sgn){
1766
1854
  let selected = selectedSuggestions.value;
1767
- if(selected.length > 0 && !props.fillSelects.allow_multiple){
1855
+ if(selected.length > 0 && !props.fillSelects.allowMultiple){
1768
1856
  selected = [];
1769
1857
  }
1770
1858
  if(!selected.includes(sgn)){
@@ -1778,7 +1866,7 @@ function updateModelValue(){
1778
1866
  let selectedItems = selectedSuggestions.value;
1779
1867
  if(selectedItems.length === 0) {
1780
1868
  emit('update:modelValue', null);
1781
- } else if (!props.fillSelects.allow_multiple) {
1869
+ } else if (!props.fillSelects.allowMultiple) {
1782
1870
  emit('update:modelValue', selectedItems[0].id);
1783
1871
  } else {
1784
1872
  const ids = selectedItems.map(item => {
@@ -1797,6 +1885,10 @@ function removeSuggestion(sgt){
1797
1885
  }
1798
1886
  let searchText = ref(null);
1799
1887
  function filterData(e){
1888
+ let dropdownElem = document.getElementById('dropwdown_section' + id.value);
1889
+ if(!dropdownElem.classList.contains('show')){
1890
+ dropdownElem.classList.add('show');
1891
+ }
1800
1892
  let filterValue = e.target.innerText;
1801
1893
  searchText.value = filterValue;
1802
1894
  if(props.fillSelects.data) {
@@ -1845,6 +1937,7 @@ return (_ctx, _cache) => {
1845
1937
  ], 8 /* PROPS */, _hoisted_2$6),
1846
1938
  createElementVNode("ul", {
1847
1939
  class: "dropdown-menu w-100",
1940
+ id: 'dropwdown_section' + unref(id),
1848
1941
  "aria-labelledby": unref(id)
1849
1942
  }, [
1850
1943
  (unref(suggestions) && unref(suggestions).length > 0)
@@ -1874,8 +1967,8 @@ return (_ctx, _cache) => {
1874
1967
 
1875
1968
  };
1876
1969
 
1877
- script$6.__scopeId = "data-v-043a2b8f";
1878
- script$6.__file = "src/views/FormComponent/ShSuggest.vue";
1970
+ script$6.__scopeId = "data-v-5b767123";
1971
+ script$6.__file = "src/lib/components/FormComponent/ShSuggest.vue";
1879
1972
 
1880
1973
  var script$5 = {
1881
1974
  name: 'ShForm',
@@ -1903,6 +1996,8 @@ var script$5 = {
1903
1996
  data: function () {
1904
1997
  return {
1905
1998
  form_elements: {},
1999
+ errorStatusCode: 0,
2000
+ errorText: null,
1906
2001
  form_errors: {},
1907
2002
  form_status: 0,
1908
2003
  error_res: null,
@@ -2035,6 +2130,9 @@ var script$5 = {
2035
2130
  }
2036
2131
  }
2037
2132
  },
2133
+ hideError: function (){
2134
+ this.form_status = 0;
2135
+ },
2038
2136
  closeModal: function () {
2039
2137
  document.body.style = '';
2040
2138
  setTimeout(() => {
@@ -2054,6 +2152,7 @@ var script$5 = {
2054
2152
  }, 1500);
2055
2153
  },
2056
2154
  submitForm: async function () {
2155
+ this.errorText = null;
2057
2156
  // return false;
2058
2157
  // if (!this.validateEssentials()) {
2059
2158
  // return false
@@ -2098,6 +2197,7 @@ var script$5 = {
2098
2197
  this.form_status = 3;
2099
2198
  if (typeof reason !== 'undefined') {
2100
2199
  if (typeof reason.response !== 'undefined') {
2200
+ this.errorText = reason.message;
2101
2201
  this.setErrors(reason.response);
2102
2202
  } else {
2103
2203
  console.log('catch error');
@@ -2106,6 +2206,10 @@ var script$5 = {
2106
2206
  } else {
2107
2207
  console.log(reason);
2108
2208
  }
2209
+ const self = this;
2210
+ setTimeout(() => {
2211
+ self.hideError();
2212
+ }, 4000);
2109
2213
  });
2110
2214
  return false
2111
2215
  },
@@ -2185,17 +2289,18 @@ var script$5 = {
2185
2289
  }
2186
2290
  };
2187
2291
 
2188
- const _hoisted_1$5 = { ref: "ShAutoForm" };
2292
+ const _hoisted_1$5 = {
2293
+ ref: "ShAutoForm",
2294
+ class: "sh-form"
2295
+ };
2189
2296
  const _hoisted_2$5 = {
2190
2297
  key: 0,
2191
- class: "alert alert-danger"
2298
+ class: "alert alert-danger alert-dismissible fade show sh-form-submission-error",
2299
+ role: "alert"
2192
2300
  };
2193
- const _hoisted_3$5 = /*#__PURE__*/createElementVNode("i", { class: "fa fa-warning" }, null, -1 /* HOISTED */);
2194
- const _hoisted_4$5 = /*#__PURE__*/createTextVNode(" Error");
2195
- const _hoisted_5$4 = [
2196
- _hoisted_3$5,
2197
- _hoisted_4$5
2198
- ];
2301
+ const _hoisted_3$5 = /*#__PURE__*/createElementVNode("i", { class: "bi-exclamation-triangle-fill me-1" }, null, -1 /* HOISTED */);
2302
+ const _hoisted_4$5 = { key: 0 };
2303
+ const _hoisted_5$4 = { key: 1 };
2199
2304
  const _hoisted_6$2 = { class: "row" };
2200
2305
  const _hoisted_7$2 = { class: "fg-label control-label text-capitalize control-bel col-md-12 request-form-label mb-2" };
2201
2306
  const _hoisted_8$1 = { class: "col-md-12" };
@@ -2233,12 +2338,16 @@ const _hoisted_22$2 = [
2233
2338
  _hoisted_20$2,
2234
2339
  _hoisted_21$2
2235
2340
  ];
2236
- const _hoisted_23$2 = {
2237
- key: 0,
2238
- style: {"height":"1rem"},
2239
- class: "float-left",
2240
- src: "/assets/img/spinner.gif"
2241
- };
2341
+ const _hoisted_23$2 = /*#__PURE__*/createElementVNode("span", {
2342
+ class: "spinner-border spinner-border-sm",
2343
+ role: "status",
2344
+ "aria-hidden": "true"
2345
+ }, null, -1 /* HOISTED */);
2346
+ const _hoisted_24$1 = /*#__PURE__*/createTextVNode(" Processing... ");
2347
+ const _hoisted_25$1 = [
2348
+ _hoisted_23$2,
2349
+ _hoisted_24$1
2350
+ ];
2242
2351
 
2243
2352
  function render$5(_ctx, _cache, $props, $setup, $data, $options) {
2244
2353
  const _component_ShPhone = resolveComponent("ShPhone");
@@ -2249,11 +2358,22 @@ function render$5(_ctx, _cache, $props, $setup, $data, $options) {
2249
2358
  createCommentVNode(" <div v-if=\"form_status == 1\" class=\"alert alert-info\">Processing...</div>"),
2250
2359
  createCommentVNode(" <div v-if=\"form_status == 2\" class=\"alert alert-success\">Success</div>"),
2251
2360
  (_ctx.form_status == 3)
2252
- ? (openBlock(), createElementBlock("div", _hoisted_2$5, _hoisted_5$4))
2361
+ ? (openBlock(), createElementBlock("div", _hoisted_2$5, [
2362
+ _hoisted_3$5,
2363
+ (_ctx.errorText)
2364
+ ? (openBlock(), createElementBlock("span", _hoisted_4$5, toDisplayString(_ctx.errorText), 1 /* TEXT */))
2365
+ : (openBlock(), createElementBlock("span", _hoisted_5$4, "Unexpected Error Occurred")),
2366
+ createElementVNode("button", {
2367
+ onClick: _cache[0] || (_cache[0] = (...args) => ($options.hideError && $options.hideError(...args))),
2368
+ type: "button",
2369
+ class: "btn-close",
2370
+ "aria-label": "Close"
2371
+ })
2372
+ ]))
2253
2373
  : createCommentVNode("v-if", true),
2254
2374
  withDirectives(createElementVNode("input", {
2255
2375
  type: "hidden",
2256
- "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => ((_ctx.form_elements['id']) = $event))
2376
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = $event => ((_ctx.form_elements['id']) = $event))
2257
2377
  }, null, 512 /* NEED_PATCH */), [
2258
2378
  [vModelText, _ctx.form_elements['id']]
2259
2379
  ]),
@@ -2422,22 +2542,25 @@ function render$5(_ctx, _cache, $props, $setup, $data, $options) {
2422
2542
  ($props.hasTerms)
2423
2543
  ? (openBlock(), createElementBlock("div", _hoisted_19$2, _hoisted_22$2))
2424
2544
  : createCommentVNode("v-if", true),
2425
- createElementVNode("button", {
2426
- "data-cy": "sh_form_submit",
2427
- class: normalizeClass(["mb-2 form-submit-btn", _ctx.form_status == 1 ? $options.getSubmitBtnClass() + ' disabled': $options.getSubmitBtnClass()]),
2428
- type: "button",
2429
- onClick: _cache[1] || (_cache[1] = (...args) => ($options.submitForm && $options.submitForm(...args)))
2430
- }, [
2431
- createTextVNode(toDisplayString($props.actionLabel ? $props.actionLabel:'Submit') + " ", 1 /* TEXT */),
2432
- (_ctx.form_status == 1)
2433
- ? (openBlock(), createElementBlock("img", _hoisted_23$2))
2434
- : createCommentVNode("v-if", true)
2435
- ], 2 /* CLASS */)
2545
+ (_ctx.form_status == 1)
2546
+ ? (openBlock(), createElementBlock("button", {
2547
+ key: 2,
2548
+ class: normalizeClass(["btn btn-primary", $options.getSubmitBtnClass()]),
2549
+ type: "button",
2550
+ disabled: ""
2551
+ }, _hoisted_25$1, 2 /* CLASS */))
2552
+ : (openBlock(), createElementBlock("button", {
2553
+ key: 3,
2554
+ "data-cy": "sh_form_submit",
2555
+ class: normalizeClass(["mb-2 form-submit-btn", $options.getSubmitBtnClass()]),
2556
+ type: "button",
2557
+ onClick: _cache[2] || (_cache[2] = (...args) => ($options.submitForm && $options.submitForm(...args)))
2558
+ }, toDisplayString($props.actionLabel ? $props.actionLabel:'Submit'), 3 /* TEXT, CLASS */))
2436
2559
  ], 512 /* NEED_PATCH */))
2437
2560
  }
2438
2561
 
2439
2562
  script$5.render = render$5;
2440
- script$5.__file = "src/views/ShForm.vue";
2563
+ script$5.__file = "src/lib/components/ShForm.vue";
2441
2564
 
2442
2565
  var script$4 = {
2443
2566
  name: 'ShCanvas',
@@ -2490,7 +2613,7 @@ function render$4(_ctx, _cache, $props, $setup, $data, $options) {
2490
2613
  }
2491
2614
 
2492
2615
  script$4.render = render$4;
2493
- script$4.__file = "src/views/ShCanvas.vue";
2616
+ script$4.__file = "src/lib/components/ShCanvas.vue";
2494
2617
 
2495
2618
  var script$3 = {
2496
2619
  name: 'ShModal',
@@ -2538,7 +2661,7 @@ function render$3(_ctx, _cache, $props, $setup, $data, $options) {
2538
2661
  }
2539
2662
 
2540
2663
  script$3.render = render$3;
2541
- script$3.__file = "src/views/ShModal.vue";
2664
+ script$3.__file = "src/lib/components/ShModal.vue";
2542
2665
 
2543
2666
  var script$2 = {
2544
2667
  name: 'Pagination',
@@ -2731,7 +2854,7 @@ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
2731
2854
  }
2732
2855
 
2733
2856
  script$2.render = render$2;
2734
- script$2.__file = "src/views/list_templates/Pagination.vue";
2857
+ script$2.__file = "src/lib/components/list_templates/Pagination.vue";
2735
2858
 
2736
2859
  function swalSuccess (message) {
2737
2860
  Swal.fire('Success!', message, 'success');
@@ -3612,7 +3735,7 @@ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
3612
3735
  }
3613
3736
 
3614
3737
  script$1.render = render$1;
3615
- script$1.__file = "src/views/ShTable.vue";
3738
+ script$1.__file = "src/lib/components/ShTable.vue";
3616
3739
 
3617
3740
  var script = {
3618
3741
  name: 'ShTabs',
@@ -3767,84 +3890,6 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
3767
3890
  }
3768
3891
 
3769
3892
  script.render = render;
3770
- script.__file = "src/views/ShTabs.vue";
3771
-
3772
- const useUserStore = defineStore('user-store', {
3773
- state: () => ({
3774
- user: null,
3775
- role: null,
3776
- permissions: null,
3777
- menus: [],
3778
- loggedOut: false
3779
- }),
3780
- actions: {
3781
- setUser (){
3782
- const user = shstorage.getItem('user') ? JSON.parse(shstorage.getItem('user')) : null;
3783
- if (user) {
3784
- user.isAllowedTo = function (slug) {
3785
- if (this.permissions) {
3786
- let permissions = [];
3787
- if (typeof this.permissions === 'string') {
3788
- permissions = JSON.parse(this.permissions);
3789
- } else {
3790
- permissions = this.permissions;
3791
- }
3792
- return permissions.includes(slug)
3793
- }
3794
- return false
3795
- };
3796
- }
3797
- this.user = user;
3798
- apis.doGet('auth/user').then(res => {
3799
- shstorage.setItem('user',res.data);
3800
- const user = res.data;
3801
- user.isAllowedTo = function (slug) {
3802
- if (this.permissions) {
3803
- let permissions = [];
3804
- if (typeof this.permissions === 'string') {
3805
- permissions = JSON.parse(this.permissions);
3806
- } else {
3807
- permissions = this.permissions;
3808
- }
3809
- return permissions.includes(slug)
3810
- }
3811
- return false
3812
- };
3813
- this.user = user;
3814
- }).catch((reason) => {
3815
- if (reason.response && reason.response.status) {
3816
- this.loggedOut = true;
3817
- }
3818
- });
3819
- if (this.user) {
3820
- if (typeof this.user.permissions === 'string') {
3821
- this.permissions = JSON.parse(this.user.permissions);
3822
- } else {
3823
- this.permissions = this.user.permissions;
3824
- }
3825
- }
3826
- },
3827
- signOut () {
3828
- shstorage.setItem('user',null);
3829
- shstorage.setItem('access_token',null);
3830
- this.user = null;
3831
- },
3832
- logOut () {
3833
- this.signOut();
3834
- },
3835
- getUser () {
3836
- this.setUser();
3837
- },
3838
- setAccessToken (accessToken) {
3839
- shstorage.setItem('access_token', accessToken);
3840
- this.setUser();
3841
- }
3842
- },
3843
- getters: {
3844
- userId (state) {
3845
- return state.user === null ? null:state.user.id
3846
- }
3847
- }
3848
- });
3893
+ script.__file = "src/lib/components/ShTabs.vue";
3849
3894
 
3850
3895
  export { script$4 as ShCanvas, script$5 as ShForm, script$3 as ShModal, script$8 as ShPhone, script$1 as ShTable, script as ShTabs, apis as shApis, helpers as shRepo, shstorage as shStorage, useUserStore };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iankibetsh/shframework",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Vue library for handling laravel backend",
5
5
  "main": "dist/library.js",
6
6
  "module": "dist/library.mjs",
@@ -21,23 +21,23 @@
21
21
  "peerDependencies": {
22
22
  "@tinymce/tinymce-vue": "^4.0.7",
23
23
  "axios": "^0.27.2",
24
+ "bootstrap": "^5.2.0",
25
+ "bootstrap-icons": "^1.9.1",
24
26
  "moment": "^2.29.3",
25
27
  "nprogress": "^0.2.0",
26
- "pinia": "^2.0.13",
28
+ "pinia": "^2.0.22",
27
29
  "sweetalert2": "^11.4.14",
28
30
  "vue": "^3.2.37"
29
31
  },
30
32
  "devDependencies": {
31
33
  "@vitejs/plugin-vue": "^3.0.3",
32
- "bootstrap": "^5.2.0",
33
- "bootstrap-icons": "^1.9.1",
34
34
  "rollup": "^2.75.7",
35
35
  "rollup-plugin-css-only": "^3.1.0",
36
+ "rollup-plugin-dotenv": "^0.3.0",
36
37
  "rollup-plugin-peer-deps-external": "^2.2.4",
37
38
  "rollup-plugin-vue": "^6.0.0",
38
39
  "vite": "^3.0.7",
39
- "vuepress": "^2.0.0-beta.48",
40
- "rollup-plugin-dotenv": "^0.3.0"
40
+ "vuepress": "^2.0.0-beta.48"
41
41
  },
42
42
  "dependencies": {
43
43
  "vue-router": "^4.1.4"