@live-change/vue3-components 0.1.15 → 0.2.4
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/form/CommandForm.vue +14 -10
- package/index.js +5 -0
- package/logic/LoadingZone.vue +11 -14
- package/logic/WorkingZone.vue +6 -8
- package/logic/analytics.js +16 -0
- package/logic/index.js +3 -0
- package/package.json +9 -7
package/form/CommandForm.vue
CHANGED
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
</template>
|
|
23
23
|
|
|
24
24
|
<script>
|
|
25
|
-
import DefinedForm from
|
|
25
|
+
import DefinedForm from './DefinedForm.vue'
|
|
26
|
+
import analytics from '../logic/analytics.js'
|
|
26
27
|
import createDebug from 'debug'
|
|
27
28
|
const debug = createDebug("live-change/command-form")
|
|
28
29
|
|
|
@@ -200,20 +201,20 @@
|
|
|
200
201
|
|
|
201
202
|
this.clearValidation()
|
|
202
203
|
|
|
203
|
-
const _commandId = this.$api.
|
|
204
|
+
const _commandId = this.$api.uid()
|
|
204
205
|
|
|
205
206
|
const analyticsValue = this.$refs.defined.formRoot.getAnalyticsValue()
|
|
206
207
|
const analyticsParameters =
|
|
207
208
|
{ ...analyticsValue, ...this.parameters, ...(additionalParameters || {}), _commandId }
|
|
208
209
|
|
|
209
|
-
|
|
210
|
-
this.$analytics.form(this.service, this.action, analyticsParameters)
|
|
210
|
+
analytics.emit('form', { service: this.service, action: this.action, parameters: analyticsParameters })
|
|
211
211
|
|
|
212
212
|
return this.validate({ parameters: {...this.parameters, ...additionalParameters} }).then(validationError => {
|
|
213
213
|
debug("VALIDATION ERROR?", validationError)
|
|
214
214
|
if(validationError) {
|
|
215
|
-
|
|
216
|
-
this
|
|
215
|
+
analytics.emit('formError', {
|
|
216
|
+
service: this.service, action: this.action, parameters: analyticsParameters, error: validationError
|
|
217
|
+
})
|
|
217
218
|
this.workingZone.finished(this.workingTask)
|
|
218
219
|
this.state = 'ready'
|
|
219
220
|
this.scrollToError()
|
|
@@ -229,8 +230,9 @@
|
|
|
229
230
|
|
|
230
231
|
return this.$api.request([this.service, this.action], parameters).then((result) => {
|
|
231
232
|
debug("DATA SUBMITED")
|
|
232
|
-
|
|
233
|
-
this
|
|
233
|
+
analytics.emit('formDone', {
|
|
234
|
+
service: this.service, action: this.action, parameters: analyticsParameters, error: validationError
|
|
235
|
+
})
|
|
234
236
|
if(this.resetOnDone) {
|
|
235
237
|
this.state = 'ready'
|
|
236
238
|
this.reset()
|
|
@@ -242,8 +244,10 @@
|
|
|
242
244
|
this.$emit('done', { result , parameters })
|
|
243
245
|
this.workingZone.finished(this.workingTask)
|
|
244
246
|
}).catch((error) => {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
+
console.error("FORM ERROR", error)
|
|
248
|
+
analytics.emit('formError', {
|
|
249
|
+
service: this.service, action: this.action, parameters: analyticsParameters, error
|
|
250
|
+
})
|
|
247
251
|
this.$refs.defined.formRoot.afterError(this.initialValues)
|
|
248
252
|
if(error.properties) {
|
|
249
253
|
for(let propName in error.properties) {
|
package/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { registerViewComponents } from "./view"
|
|
|
8
8
|
|
|
9
9
|
function registerComponents(app, settings = {}) {
|
|
10
10
|
registerLogicComponents(app, settings)
|
|
11
|
+
console.log("reg", registerFormComponents)
|
|
11
12
|
registerFormComponents(app, settings)
|
|
12
13
|
registerViewComponents(app, settings)
|
|
13
14
|
}
|
|
@@ -17,3 +18,7 @@ export { registerComponents }
|
|
|
17
18
|
import createReactiveObject from "./utils/createReactiveObject.mjs"
|
|
18
19
|
|
|
19
20
|
export { createReactiveObject }
|
|
21
|
+
|
|
22
|
+
import { analytics, useAnalytics, installRouterAnalytics } from "./logic"
|
|
23
|
+
export { analytics, useAnalytics, installRouterAnalytics }
|
|
24
|
+
|
package/logic/LoadingZone.vue
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
<slot name="loading">
|
|
14
14
|
Loading...
|
|
15
15
|
</slot>
|
|
16
|
+
<div style="display: none">SUSPEND FALLBACK</div>
|
|
16
17
|
</div>
|
|
17
18
|
</template>
|
|
18
19
|
</suspense>
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
|
|
31
32
|
<script>
|
|
32
33
|
import { onErrorCaptured, ref, reactive } from 'vue'
|
|
34
|
+
import analytics from './analytics.js'
|
|
33
35
|
import debugLib from 'debug'
|
|
34
36
|
|
|
35
37
|
const info = debugLib('loading:info')
|
|
@@ -74,19 +76,17 @@
|
|
|
74
76
|
methods: {
|
|
75
77
|
loadingStarted(task) {
|
|
76
78
|
if(this.loading.length == 0) {
|
|
77
|
-
|
|
78
|
-
this.$analytics.loadingStarted({ task: task.name })
|
|
79
|
+
analytics.emit('loadingStarted', { task: task.name })
|
|
79
80
|
info('LOADING STARTED!')
|
|
80
81
|
|
|
81
82
|
const loadingBlockId = this.loadingBlockId
|
|
82
|
-
this.
|
|
83
|
+
this.loadingTimeout = setTimeout(() => {
|
|
83
84
|
if(loadingBlockId == this.loadingBlockId && this.loading.length > 0) {
|
|
84
85
|
this.connectionProblem = true
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
})
|
|
86
|
+
analytics.emit('loadingError', {
|
|
87
|
+
task: 'View loading', reason: "connection problem",
|
|
88
|
+
tasks: this.loading.map(t => t.name)
|
|
89
|
+
})
|
|
90
90
|
}
|
|
91
91
|
}, 4000)
|
|
92
92
|
}
|
|
@@ -106,8 +106,7 @@
|
|
|
106
106
|
if(this.loading.length == 0) {
|
|
107
107
|
this.loadingBlockId++
|
|
108
108
|
clearTimeout(this.loadingTimeout)
|
|
109
|
-
|
|
110
|
-
this.$analytics.loadingDone({ task: task.name })
|
|
109
|
+
analytics.emit('loadingDone', { task: task.name })
|
|
111
110
|
this.$nextTick(this.$router.loadingDone)
|
|
112
111
|
}
|
|
113
112
|
},
|
|
@@ -117,9 +116,7 @@
|
|
|
117
116
|
clearTimeout(this.loadingTimeout)
|
|
118
117
|
|
|
119
118
|
this.errors.push({ task, reason })
|
|
120
|
-
|
|
121
|
-
this.$analytics.loadingError({ task: task.name, reason })
|
|
122
|
-
}
|
|
119
|
+
analytics.emit('loadingError', { task: task.name, reason })
|
|
123
120
|
let id = this.loading.indexOf(task)
|
|
124
121
|
if(id == -1) {
|
|
125
122
|
this.errors.push({ task, reason: "unknown task "+task.name })
|
|
@@ -143,7 +140,7 @@
|
|
|
143
140
|
promise
|
|
144
141
|
.then((result) => this.loadingFinished(task))
|
|
145
142
|
return promise
|
|
146
|
-
}
|
|
143
|
+
},
|
|
147
144
|
},
|
|
148
145
|
provide() {
|
|
149
146
|
return {
|
package/logic/WorkingZone.vue
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
</template>
|
|
15
15
|
|
|
16
16
|
<script>
|
|
17
|
+
import analytics from '../logic/analytics.js'
|
|
17
18
|
import debugLib from 'debug'
|
|
18
19
|
|
|
19
20
|
const info = debugLib('working:info')
|
|
@@ -43,16 +44,15 @@
|
|
|
43
44
|
methods: {
|
|
44
45
|
workingStarted(task) {
|
|
45
46
|
if(this.working.length == 0) {
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
analytics.emit('workingStarted', { task: task.name })
|
|
48
|
+
|
|
48
49
|
info('WORKING STARTED!')
|
|
49
50
|
|
|
50
51
|
const workingBlockId = this.workingBlockId
|
|
51
52
|
this.loagindTimeout = setTimeout(() => {
|
|
52
53
|
if(workingBlockId == this.workingBlockId && this.working.length > 0) {
|
|
53
54
|
this.connectionProblem = true
|
|
54
|
-
|
|
55
|
-
this.$analytics.workingError({
|
|
55
|
+
analytics.emit('workingError', {
|
|
56
56
|
task: "View working", reason: "connection problem",
|
|
57
57
|
tasks: this.working.map(t => t.name)
|
|
58
58
|
})
|
|
@@ -75,8 +75,7 @@
|
|
|
75
75
|
if(this.working.length == 0) {
|
|
76
76
|
this.workingBlockId++
|
|
77
77
|
clearTimeout(this.workingTimeout)
|
|
78
|
-
|
|
79
|
-
this.$analytics.workingDone({ task: task.name })
|
|
78
|
+
analytics.emit('workingDone', { task: task.name })
|
|
80
79
|
this.$nextTick(this.$router.workingDone)
|
|
81
80
|
}
|
|
82
81
|
},
|
|
@@ -86,8 +85,7 @@
|
|
|
86
85
|
clearTimeout(this.workingTimeout)
|
|
87
86
|
|
|
88
87
|
this.errors.push({ task, reason })
|
|
89
|
-
|
|
90
|
-
this.$analytics.workingError({ task: task.name, reason })
|
|
88
|
+
analytics.emit('workingError', { task: task.name, reason })
|
|
91
89
|
|
|
92
90
|
let id = this.working.indexOf(task)
|
|
93
91
|
if(id == -1) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import mitt from "mitt"
|
|
2
|
+
|
|
3
|
+
const analytics = mitt()
|
|
4
|
+
|
|
5
|
+
function useAnalytics() {
|
|
6
|
+
return analytics
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function installRouterAnalytics(router) {
|
|
10
|
+
router.afterEach((to, from) => {
|
|
11
|
+
analytics.emit('pageView', { ...to })
|
|
12
|
+
})
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { analytics, useAnalytics, installRouterAnalytics }
|
|
16
|
+
export default analytics
|
package/logic/index.js
CHANGED
|
@@ -5,6 +5,9 @@ import Observe from "./Observe.vue"
|
|
|
5
5
|
|
|
6
6
|
export { Loading, LoadingZone, WorkingZone, Observe }
|
|
7
7
|
|
|
8
|
+
import { analytics, useAnalytics, installRouterAnalytics } from "./analytics.js"
|
|
9
|
+
export { analytics, useAnalytics, installRouterAnalytics }
|
|
10
|
+
|
|
8
11
|
function registerLogicComponents(app) {
|
|
9
12
|
app.component("loading", Loading)
|
|
10
13
|
app.component("loading-zone", LoadingZone)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/vue3-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Live Change Framework - vue components",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/live-change/vue3
|
|
11
|
+
"url": "git+https://github.com/live-change/live-change-framework-vue3.git"
|
|
12
12
|
},
|
|
13
13
|
"author": {
|
|
14
14
|
"email": "m8@em8.pl",
|
|
@@ -17,12 +17,14 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"bugs": {
|
|
20
|
-
"url": "https://github.com/live-change/vue3
|
|
20
|
+
"url": "https://github.com/live-change/live-change-framework-vue3/issues"
|
|
21
21
|
},
|
|
22
|
-
"homepage": "https://github.com/live-change/vue3
|
|
22
|
+
"homepage": "https://github.com/live-change/live-change-framework-vue3",
|
|
23
23
|
"dependencies": {
|
|
24
|
+
"@live-change/vue3-ssr": "^0.2.4",
|
|
24
25
|
"debug": "^4.3.2",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
}
|
|
26
|
+
"mitt": "3.0.0",
|
|
27
|
+
"vue": "^3.2.31"
|
|
28
|
+
},
|
|
29
|
+
"gitHead": "fc932e431ba4a6bde00e4e9f24f56c47e8fff33b"
|
|
28
30
|
}
|