@iankibetsh/vue-streamline 1.2.8 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iankibetsh/vue-streamline",
3
- "version": "1.2.8",
3
+ "version": "1.3.0",
4
4
  "description": "Vue library for streamlining laravel backend services with @iankibet/streamline composer package",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/App.vue CHANGED
@@ -22,19 +22,23 @@ const findPaybill = async ()=>{
22
22
  console.log(err)
23
23
  })
24
24
  }
25
+ const refresh = ()=>{
26
+ paybillService.refresh()
27
+ }
25
28
  </script>
26
29
 
27
30
  <template>
28
31
  <div>
29
32
  <hr/>
30
- <!-- <h3>Destructed: {{ testKey }}</h3>-->
31
- <!-- <h3>Original: {{ props.testKey }}</h3>-->
32
- <!-- <h3>Original: {{ props.testKey }}</h3>-->
33
- <!-- <h3>Original: {{ props.testKey }}</h3>-->
34
- <!-- <h3>Original: {{ props.testKey }}</h3>-->
35
- <!-- <h3 class="text-success" >Loading : {{ loading }}</h3>-->
36
- <!-- <h1 @click="findPaybill">Get Paybill</h1>-->
37
- <!-- {{ foundPaybill }}-->
33
+ <h3>Destructed: {{ testKey }}</h3>
34
+ <h3>Original: {{ props.testKey }}</h3>
35
+ <h3>Original: {{ props.testKey }}</h3>
36
+ <h3>Original: {{ props.testKey }}</h3>
37
+ <h3>Original: {{ props.testKey }}</h3>
38
+ <h3 class="text-success" >Loading : {{ loading }}</h3>
39
+ <h1 @click="findPaybill">Get Paybill</h1>
40
+ <h1 @click="refresh">Refresh</h1>
41
+ {{ foundPaybill }}
38
42
  </div>
39
43
  </template>
40
44
 
@@ -29,8 +29,10 @@ const useStreamline = (stream, ...initialArgs) => {
29
29
  }
30
30
  })
31
31
 
32
- const fetchServiceProperties = async () => {
33
- if (loading.value || propertiesFetched.value) return
32
+ const fetchServiceProperties = async (force) => {
33
+ if(!force){
34
+ if (loading.value || propertiesFetched.value) return
35
+ }
34
36
 
35
37
  try {
36
38
  loading.value = true
@@ -62,6 +64,9 @@ const useStreamline = (stream, ...initialArgs) => {
62
64
  }
63
65
 
64
66
  return (...args) => {
67
+ if(prop === 'refresh' || prop === 'reload'){
68
+ return fetchServiceProperties(true)
69
+ }
65
70
  if(prop === 'confirm'){
66
71
  return confirmAction(args[0] ?? 'Are you sure?')
67
72
  }
@@ -112,17 +117,25 @@ const useStreamline = (stream, ...initialArgs) => {
112
117
  if(action.includes(':')){
113
118
  [newStream, action] = action.split(':')
114
119
  }
115
- const params = new URLSearchParams({
120
+ const post = {
116
121
  action,
117
- stream: newStream
118
- })
119
-
120
- // Add each arg as a separate param
121
- args.forEach((arg, index) => {
122
- params.append(`params[${index}]`, typeof arg === 'object' ? JSON.stringify(arg) : arg)
123
- })
124
-
125
- return `${streamlineUrl}?${params.toString()}`
122
+ stream:newStream,
123
+ params: args
124
+ }
125
+ return `${streamlineUrl}?${new URLSearchParams(post).toString()}`
126
+
127
+ // // Add each arg as a separate param
128
+ // args.forEach((arg, index) => {
129
+ // let value = arg;
130
+ // if (typeof arg === 'object' && !(arg instanceof Date)) {
131
+ // value = JSON.stringify(arg);
132
+ // } else if (arg instanceof Date) {
133
+ // value = arg.toISOString();
134
+ // }
135
+ // params.append(`params[${index}]`, value);
136
+ // })
137
+
138
+ // return `${streamlineUrl}?${params.toString()}`
126
139
  }
127
140
 
128
141
  const service = reactive({})