@questwork/vue-q-list-vue3 3.1.1 → 3.1.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.
- package/dist/q-list.min.css +1 -1
- package/dist/q-list.min.js +15 -13
- package/dist/q-list.min.js.LICENSE.txt +21 -0
- package/lib/helpers/getValidation.js +3 -82
- package/lib/helpers/getValue.js +9 -11
- package/lib/models/qListButton/qListButton.js +8 -141
- package/lib/models/qRow/qRow.js +20 -0
- package/package.json +4 -1
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
Name: @questwork/q-utilities
|
|
2
|
+
Version: 0.1.16
|
|
3
|
+
License: MIT
|
|
4
|
+
Private: false
|
|
5
|
+
Description: Questwork QUtilities
|
|
6
|
+
Author: Questwork Consulting Limited <info@questwork.com> (https://questwork.com/)
|
|
7
|
+
License Copyright:
|
|
8
|
+
===
|
|
9
|
+
|
|
10
|
+
Copyright 2019 Questwork Consulting Limited
|
|
11
|
+
|
|
12
|
+
This project is free software released under the MIT/X11 license:
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
1
22
|
Name: moment
|
|
2
23
|
Version: 2.30.1
|
|
3
24
|
License: MIT
|
|
@@ -1,88 +1,9 @@
|
|
|
1
1
|
const { getValue } = require('./getValue')
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
if (!rule) {
|
|
5
|
-
return true
|
|
6
|
-
}
|
|
7
|
-
const { key = '', value } = rule
|
|
8
|
-
const [valueAttribute] = Object.keys(value || {})
|
|
9
|
-
|
|
10
|
-
if (!key) {
|
|
11
|
-
switch (valueAttribute) {
|
|
12
|
-
case '$and': {
|
|
13
|
-
const arr = value['$and']
|
|
14
|
-
return arr.reduce((acc, item) => (acc && getValidation({ rule: item, data })), true)
|
|
15
|
-
}
|
|
16
|
-
case '$or': {
|
|
17
|
-
const arr = value['$or']
|
|
18
|
-
return arr.reduce((acc, item) => (acc || getValidation({ rule: item, data })), false)
|
|
19
|
-
}
|
|
20
|
-
default:
|
|
21
|
-
return false
|
|
22
|
-
}
|
|
23
|
-
}
|
|
3
|
+
const { getValidation: _getValidation, KeyValueObject } = require('@questwork/q-utilities')
|
|
24
4
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
case '$empty': {
|
|
28
|
-
return !rowValue === !!value['$empty']
|
|
29
|
-
}
|
|
30
|
-
case '$eq': {
|
|
31
|
-
return rowValue === value['$eq']
|
|
32
|
-
}
|
|
33
|
-
case '$gt': {
|
|
34
|
-
return rowValue > value['$gt']
|
|
35
|
-
}
|
|
36
|
-
case '$gte': {
|
|
37
|
-
return rowValue >= value['$gte']
|
|
38
|
-
}
|
|
39
|
-
case '$in': {
|
|
40
|
-
if (Array.isArray(rowValue)) {
|
|
41
|
-
return !!rowValue.find((e) => (value['$in'].includes(e)))
|
|
42
|
-
}
|
|
43
|
-
if (typeof rowValue !== 'object') {
|
|
44
|
-
return !!value['$in'].includes(rowValue)
|
|
45
|
-
}
|
|
46
|
-
return false
|
|
47
|
-
}
|
|
48
|
-
case '$lt': {
|
|
49
|
-
return rowValue < value['$lt']
|
|
50
|
-
}
|
|
51
|
-
case '$lte': {
|
|
52
|
-
return rowValue <= value['$lte']
|
|
53
|
-
}
|
|
54
|
-
case '$ne': {
|
|
55
|
-
return rowValue !== value['$ne']
|
|
56
|
-
}
|
|
57
|
-
case '$notIn': {
|
|
58
|
-
if (Array.isArray(rowValue)) {
|
|
59
|
-
return !rowValue.find((e) => (value['$notIn'].includes(e)))
|
|
60
|
-
}
|
|
61
|
-
if (typeof rowValue !== 'object') {
|
|
62
|
-
return !value['$notIn'].includes(rowValue)
|
|
63
|
-
}
|
|
64
|
-
return false
|
|
65
|
-
}
|
|
66
|
-
case '$intervalTimeGt': {
|
|
67
|
-
const now = new Date().getTime()
|
|
68
|
-
const timestamp = new Date(rowValue).getTime()
|
|
69
|
-
return (now - timestamp) > value['$intervalTimeGt']
|
|
70
|
-
}
|
|
71
|
-
case '$intervalTimeLt': {
|
|
72
|
-
const now = new Date().getTime()
|
|
73
|
-
const timestamp = new Date(rowValue).getTime()
|
|
74
|
-
return (now - timestamp) < value['$intervalTimeLt']
|
|
75
|
-
}
|
|
76
|
-
case '$range': {
|
|
77
|
-
const [min, max] = value['$range']
|
|
78
|
-
if (typeof min === 'number' && typeof max === 'number' && rowValue >= min && rowValue <= max) {
|
|
79
|
-
return true
|
|
80
|
-
}
|
|
81
|
-
return false
|
|
82
|
-
}
|
|
83
|
-
default:
|
|
84
|
-
return false
|
|
85
|
-
}
|
|
5
|
+
function getValidation({ rule, data }) {
|
|
6
|
+
return _getValidation(rule, data, getValue, KeyValueObject)
|
|
86
7
|
}
|
|
87
8
|
|
|
88
9
|
module.exports = {
|
package/lib/helpers/getValue.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
return getValueInObj({ keys: key.split('.'), obj: value })
|
|
3
|
-
}
|
|
1
|
+
const { getValueByKeys: _getValueByKeys } = require('@questwork/q-utilities')
|
|
4
2
|
|
|
5
|
-
function
|
|
6
|
-
if (
|
|
7
|
-
return
|
|
8
|
-
}
|
|
9
|
-
const firstKey = keys.shift()
|
|
10
|
-
if (obj && obj.hasOwnProperty(firstKey)) {
|
|
11
|
-
return getValueInObj({ keys, obj: obj[firstKey] })
|
|
3
|
+
function getValue(key, data) {
|
|
4
|
+
if (data && typeof data.get === 'function') {
|
|
5
|
+
return data.get(key)
|
|
12
6
|
}
|
|
13
|
-
return
|
|
7
|
+
return getValueByKeys(key, data)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function getValueByKeys(key, value) {
|
|
11
|
+
return _getValueByKeys(key.split('.'), value)
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
module.exports = {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// const { getValidation: _getValidation } = require('@questwork/q-utilities')
|
|
2
|
+
const { getValidation } = require('../../helpers')
|
|
1
3
|
const { KeyValueObject } = require('../keyValueObject')
|
|
2
4
|
class QListButton {
|
|
3
5
|
constructor(options = {}) {
|
|
@@ -87,154 +89,19 @@ class QListButton {
|
|
|
87
89
|
|
|
88
90
|
return getValidation({
|
|
89
91
|
rule: visibleRule,
|
|
90
|
-
|
|
92
|
+
data: this.qRow,
|
|
91
93
|
})
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
|
|
95
|
-
// function getValidation({ rule, qRow }) {
|
|
96
|
-
// const { key = '', value } = rule
|
|
97
|
-
// const [valueAttribute] = Object.keys(value)
|
|
98
|
-
|
|
99
|
-
// if (!key) {
|
|
100
|
-
// switch(valueAttribute) {
|
|
101
|
-
// case '$and': {
|
|
102
|
-
// const arr = value['$and']
|
|
103
|
-
// return arr.reduce((acc, item) => {
|
|
104
|
-
// return acc && getValidation({ rule: item, qRow})
|
|
105
|
-
// }, true)
|
|
106
|
-
// }
|
|
107
|
-
// case '$or': {
|
|
108
|
-
// const arr = value['$or']
|
|
109
|
-
// return arr.reduce((acc, item) => {
|
|
110
|
-
// return acc || getValidation({ rule: item, qRow})
|
|
111
|
-
// }, false)
|
|
112
|
-
// }
|
|
113
|
-
// }
|
|
114
|
-
// return false
|
|
115
|
-
// }
|
|
116
97
|
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
// case '$empty': {
|
|
120
|
-
// return !rowValue === value['$empty']
|
|
121
|
-
// }
|
|
122
|
-
// case '$lte': {
|
|
123
|
-
// return rowValue <= value['$lte']
|
|
124
|
-
// }
|
|
125
|
-
// }
|
|
126
|
-
// return false
|
|
98
|
+
// function getDataByKey(key, data) {
|
|
99
|
+
// return data.get(key)
|
|
127
100
|
// }
|
|
128
101
|
|
|
129
|
-
function
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
if (!getDataByKey || typeof getDataByKey !== 'function') {
|
|
134
|
-
return false
|
|
135
|
-
}
|
|
136
|
-
const { key = '', value } = rule
|
|
137
|
-
const [valueAttribute] = Object.keys(value)
|
|
138
|
-
|
|
139
|
-
if (!key) {
|
|
140
|
-
switch (valueAttribute) {
|
|
141
|
-
case '$and': {
|
|
142
|
-
const arr = value['$and']
|
|
143
|
-
return arr.reduce((acc, item) => (acc && _getValidation(item, data, getDataByKey)), true)
|
|
144
|
-
}
|
|
145
|
-
case '$or': {
|
|
146
|
-
const arr = value['$or']
|
|
147
|
-
return arr.reduce((acc, item) => (acc || _getValidation(item, data, getDataByKey)), false)
|
|
148
|
-
}
|
|
149
|
-
default:
|
|
150
|
-
return false
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const rowValue = getDataByKey(key, data)
|
|
155
|
-
switch (valueAttribute) {
|
|
156
|
-
case '$empty': {
|
|
157
|
-
return !rowValue === !!value['$empty']
|
|
158
|
-
}
|
|
159
|
-
case '$eq': {
|
|
160
|
-
return rowValue === value['$eq']
|
|
161
|
-
}
|
|
162
|
-
case '$gt': {
|
|
163
|
-
return rowValue > value['$gt']
|
|
164
|
-
}
|
|
165
|
-
case '$gte': {
|
|
166
|
-
return rowValue >= value['$gte']
|
|
167
|
-
}
|
|
168
|
-
case '$lt': {
|
|
169
|
-
return rowValue < value['$lt']
|
|
170
|
-
}
|
|
171
|
-
case '$lte': {
|
|
172
|
-
return rowValue <= value['$lte']
|
|
173
|
-
}
|
|
174
|
-
case '$in': {
|
|
175
|
-
debugger
|
|
176
|
-
console.log('rowValuda', rowValue)
|
|
177
|
-
if (Array.isArray(rowValue)) {
|
|
178
|
-
return !!rowValue.find((e) => (value['$in'].includes(e)))
|
|
179
|
-
}
|
|
180
|
-
if (typeof rowValue !== 'object') {
|
|
181
|
-
return !!value['$in'].includes(rowValue)
|
|
182
|
-
}
|
|
183
|
-
return false
|
|
184
|
-
}
|
|
185
|
-
case '$inValue': {
|
|
186
|
-
const result = getDataByKey(value['$inValue'], data)
|
|
187
|
-
const _value = Array.isArray(result) ? result : []
|
|
188
|
-
if (Array.isArray(rowValue)) {
|
|
189
|
-
return !!rowValue.find((e) => (_value.includes(e)))
|
|
190
|
-
}
|
|
191
|
-
if (typeof rowValue === 'string') {
|
|
192
|
-
return !!_value.includes(rowValue)
|
|
193
|
-
}
|
|
194
|
-
return false
|
|
195
|
-
}
|
|
196
|
-
case '$ne': {
|
|
197
|
-
return rowValue !== value['$ne']
|
|
198
|
-
}
|
|
199
|
-
case '$notIn': {
|
|
200
|
-
if (Array.isArray(rowValue)) {
|
|
201
|
-
return !rowValue.find((e) => (value['$notIn'].includes(e)))
|
|
202
|
-
}
|
|
203
|
-
if (typeof rowValue !== 'object') {
|
|
204
|
-
return !value['$notIn'].includes(rowValue)
|
|
205
|
-
}
|
|
206
|
-
return false
|
|
207
|
-
}
|
|
208
|
-
case '$notInValue': {
|
|
209
|
-
const result = getDataByKey(value['$notInValue'], data)
|
|
210
|
-
const _value = Array.isArray(result) ? result : []
|
|
211
|
-
if (Array.isArray(rowValue)) {
|
|
212
|
-
return !rowValue.find((e) => (_value.includes(e)))
|
|
213
|
-
}
|
|
214
|
-
if (typeof rowValue !== 'object') {
|
|
215
|
-
return !_value.includes(rowValue)
|
|
216
|
-
}
|
|
217
|
-
return false
|
|
218
|
-
}
|
|
219
|
-
case '$range': {
|
|
220
|
-
const [min, max] = value['$range']
|
|
221
|
-
if (typeof min === 'number' && typeof max === 'number' && rowValue >= min && rowValue <= max) {
|
|
222
|
-
return true
|
|
223
|
-
}
|
|
224
|
-
return false
|
|
225
|
-
}
|
|
226
|
-
default:
|
|
227
|
-
return false
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function getDataByKey(key, data) {
|
|
232
|
-
return data.get(key)
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
function getValidation({ rule, qRow }) {
|
|
236
|
-
return _getValidation(rule, qRow, getDataByKey)
|
|
237
|
-
}
|
|
102
|
+
// function getValidation({ rule, qRow }) {
|
|
103
|
+
// return _getValidation(rule, qRow, getDataByKey, KeyValueObject)
|
|
104
|
+
// }
|
|
238
105
|
|
|
239
106
|
module.exports = {
|
|
240
107
|
QListButton
|
package/lib/models/qRow/qRow.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const { dateHelper } = require('@questwork/utilities/lib/dateHelper')
|
|
2
|
+
const { TemplateCompiler } = require('@questwork/q-utilities')
|
|
2
3
|
|
|
3
4
|
class QRow {
|
|
4
5
|
constructor(options = {}) {
|
|
@@ -18,6 +19,7 @@ class QRow {
|
|
|
18
19
|
this.shouldBeVisible = setShouldBeVisible(options.shouldBeVisible || null)
|
|
19
20
|
this.uniqueKey = options.uniqueKey
|
|
20
21
|
this.unread = options.unread || false
|
|
22
|
+
this._templateCompiler = TemplateCompiler.init(this.row)
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
// Class methods
|
|
@@ -81,6 +83,10 @@ class QRow {
|
|
|
81
83
|
// const realKey = arr[1]
|
|
82
84
|
// return this[realKey]
|
|
83
85
|
}
|
|
86
|
+
// check if regular expr
|
|
87
|
+
if (_useTemplateCompiler(key)) {
|
|
88
|
+
return this._templateCompiler.pipe(key)
|
|
89
|
+
}
|
|
84
90
|
if (key.includes('.')) {
|
|
85
91
|
const arr = key.split('.')
|
|
86
92
|
return getRecursiveValue(this.row, arr)
|
|
@@ -146,6 +152,15 @@ class QRow {
|
|
|
146
152
|
return cssArr
|
|
147
153
|
}
|
|
148
154
|
|
|
155
|
+
// pipe(templateCompiler) {
|
|
156
|
+
// if (!this._templateCompiler && typeof templateCompiler.init === 'function') {
|
|
157
|
+
// this._templateCompiler = templateCompiler.init(this.row)
|
|
158
|
+
// }
|
|
159
|
+
// return (expr) => {
|
|
160
|
+
// return this._templateCompiler.pipe(expr)
|
|
161
|
+
// }
|
|
162
|
+
// }
|
|
163
|
+
|
|
149
164
|
removeCss(className) {
|
|
150
165
|
this.cssNames = this.cssNames.filter((e) => (e !== className))
|
|
151
166
|
return this
|
|
@@ -212,6 +227,11 @@ function setShouldBeVisible(shouldBeVisible) {
|
|
|
212
227
|
}
|
|
213
228
|
}
|
|
214
229
|
|
|
230
|
+
function _useTemplateCompiler(key) {
|
|
231
|
+
key = key.trim()
|
|
232
|
+
return (key.indexOf('{{') === 0) || (key.indexOf('<%') === 0)
|
|
233
|
+
}
|
|
234
|
+
|
|
215
235
|
module.exports = {
|
|
216
236
|
QRow,
|
|
217
237
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@questwork/vue-q-list-vue3",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "Questwork vue component for displaying a list",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
"url": "http://www.questwork.com/"
|
|
16
16
|
},
|
|
17
17
|
"license": "MIT",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@questwork/q-utilities": "^0.1.16"
|
|
20
|
+
},
|
|
18
21
|
"devDependencies": {
|
|
19
22
|
"@babel/core": "^7.17.8",
|
|
20
23
|
"@babel/eslint-parser": "^7.17.0",
|