@questwork/vue-q-list-vue3 3.1.2 → 3.1.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/dist/q-list.min.css +1 -1
- package/dist/q-list.min.js +19 -12
- package/dist/q-list.min.js.LICENSE.txt +22 -22
- package/lib/helpers/checkIfUsingTemplateCompiler.js +9 -0
- package/lib/helpers/getValue.js +8 -13
- package/lib/helpers/index.js +2 -0
- package/lib/models/qListButton/qListButton.js +18 -142
- package/lib/models/qRow/qRow.js +18 -4
- package/package.json +2 -2
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
Name: @questwork/q-utilities
|
|
2
|
+
Version: 0.1.17
|
|
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
|
|
@@ -103,25 +124,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
103
124
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
104
125
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
105
126
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
106
|
-
THE SOFTWARE.
|
|
107
|
-
|
|
108
|
-
---
|
|
109
|
-
|
|
110
|
-
Name: @questwork/q-utilities
|
|
111
|
-
Version: 0.1.12
|
|
112
|
-
License: MIT
|
|
113
|
-
Private: false
|
|
114
|
-
Description: Questwork QUtilities
|
|
115
|
-
Author: Questwork Consulting Limited <info@questwork.com> (https://questwork.com/)
|
|
116
|
-
License Copyright:
|
|
117
|
-
===
|
|
118
|
-
|
|
119
|
-
Copyright 2019 Questwork Consulting Limited
|
|
120
|
-
|
|
121
|
-
This project is free software released under the MIT/X11 license:
|
|
122
|
-
|
|
123
|
-
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:
|
|
124
|
-
|
|
125
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
126
|
-
|
|
127
|
-
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.
|
|
127
|
+
THE SOFTWARE.
|
package/lib/helpers/getValue.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
const { getValueByKeys} = require('@questwork/q-utilities')
|
|
1
|
+
const { getValueByKeys: _getValueByKeys } = require('@questwork/q-utilities')
|
|
2
2
|
|
|
3
|
-
function getValue(key,
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
function getValue(key, data) {
|
|
4
|
+
if (data && typeof data.get === 'function') {
|
|
5
|
+
return data.get(key)
|
|
6
|
+
}
|
|
7
|
+
return getValueByKeys(key, data)
|
|
6
8
|
}
|
|
7
9
|
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
return obj
|
|
11
|
-
}
|
|
12
|
-
const firstKey = keys.shift()
|
|
13
|
-
if (obj && obj.hasOwnProperty(firstKey)) {
|
|
14
|
-
return getValueInObj({ keys, obj: obj[firstKey] })
|
|
15
|
-
}
|
|
16
|
-
return obj
|
|
10
|
+
function getValueByKeys(key, value) {
|
|
11
|
+
return _getValueByKeys(key.split('.'), value)
|
|
17
12
|
}
|
|
18
13
|
|
|
19
14
|
module.exports = {
|
package/lib/helpers/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const { checkIfUsingTemplateCompiler } = require('./checkIfUsingTemplateCompiler')
|
|
1
2
|
const { getPopupPosition } = require('./getPopupPosition')
|
|
2
3
|
const { getTitle } = require('./getTitle')
|
|
3
4
|
const { getTooltipPosition } = require('./getTooltipPosition')
|
|
@@ -5,6 +6,7 @@ const { getValidation } = require('./getValidation')
|
|
|
5
6
|
const { getValue } = require('./getValue')
|
|
6
7
|
|
|
7
8
|
module.exports = {
|
|
9
|
+
checkIfUsingTemplateCompiler,
|
|
8
10
|
getPopupPosition,
|
|
9
11
|
getTitle,
|
|
10
12
|
getTooltipPosition,
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
const { getValidation, getValue, checkIfUsingTemplateCompiler } = require('../../helpers')
|
|
1
2
|
const { KeyValueObject } = require('../keyValueObject')
|
|
3
|
+
const { TemplateCompiler } = require('@questwork/q-utilities')
|
|
4
|
+
|
|
2
5
|
class QListButton {
|
|
3
6
|
constructor(options = {}) {
|
|
4
7
|
options = options || {}
|
|
@@ -10,7 +13,6 @@ class QListButton {
|
|
|
10
13
|
this.endpoint = options.endpoint
|
|
11
14
|
this.httpMethod = options.httpMethod
|
|
12
15
|
this.icon = options.icon
|
|
13
|
-
this.label = options.label
|
|
14
16
|
this.linkTarget = options.linkTarget
|
|
15
17
|
this.onClick = options.onClick
|
|
16
18
|
this.owner = options.owner
|
|
@@ -21,6 +23,8 @@ class QListButton {
|
|
|
21
23
|
this.showLabel = options.showLabel
|
|
22
24
|
this.title = options.title
|
|
23
25
|
this.url = options.url
|
|
26
|
+
this._templateCompiler = TemplateCompiler.init(this.qRow)
|
|
27
|
+
this.label = this.getLabel(options.label)
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
static init(options) {
|
|
@@ -75,6 +79,13 @@ class QListButton {
|
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
81
|
|
|
82
|
+
getLabel(label = '') {
|
|
83
|
+
if (checkIfUsingTemplateCompiler(label)) {
|
|
84
|
+
return this._templateCompiler.pipe(label)
|
|
85
|
+
}
|
|
86
|
+
return label
|
|
87
|
+
}
|
|
88
|
+
|
|
78
89
|
makeCss() {
|
|
79
90
|
return `__q-list-button ${this.css.element || ''}`
|
|
80
91
|
}
|
|
@@ -87,154 +98,19 @@ class QListButton {
|
|
|
87
98
|
|
|
88
99
|
return getValidation({
|
|
89
100
|
rule: visibleRule,
|
|
90
|
-
|
|
101
|
+
data: this.qRow,
|
|
91
102
|
})
|
|
92
103
|
}
|
|
93
104
|
}
|
|
94
105
|
|
|
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
106
|
|
|
117
|
-
//
|
|
118
|
-
//
|
|
119
|
-
// case '$empty': {
|
|
120
|
-
// return !rowValue === value['$empty']
|
|
121
|
-
// }
|
|
122
|
-
// case '$lte': {
|
|
123
|
-
// return rowValue <= value['$lte']
|
|
124
|
-
// }
|
|
125
|
-
// }
|
|
126
|
-
// return false
|
|
107
|
+
// function getDataByKey(key, data) {
|
|
108
|
+
// return data.get(key)
|
|
127
109
|
// }
|
|
128
110
|
|
|
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
|
-
}
|
|
111
|
+
// function getValidation({ rule, qRow }) {
|
|
112
|
+
// return _getValidation(rule, qRow, getDataByKey, KeyValueObject)
|
|
113
|
+
// }
|
|
238
114
|
|
|
239
115
|
module.exports = {
|
|
240
116
|
QListButton
|
package/lib/models/qRow/qRow.js
CHANGED
|
@@ -84,8 +84,17 @@ class QRow {
|
|
|
84
84
|
// return this[realKey]
|
|
85
85
|
}
|
|
86
86
|
// check if regular expr
|
|
87
|
-
if (
|
|
88
|
-
|
|
87
|
+
if (_hasTemplateDelimiters(key)) {
|
|
88
|
+
const regex = /(\{\{ \w+\((['"])(.*?)\2\) \}\})|([^{]+)/g
|
|
89
|
+
const result = key.match(regex)?.filter(Boolean) || [key]
|
|
90
|
+
return result.reduce((acc, k) => {
|
|
91
|
+
if (_hasTemplateDelimiters(k)) {
|
|
92
|
+
acc += this._templateCompiler.pipe(k)
|
|
93
|
+
} else {
|
|
94
|
+
acc += k
|
|
95
|
+
}
|
|
96
|
+
return acc
|
|
97
|
+
}, '')
|
|
89
98
|
}
|
|
90
99
|
if (key.includes('.')) {
|
|
91
100
|
const arr = key.split('.')
|
|
@@ -227,9 +236,14 @@ function setShouldBeVisible(shouldBeVisible) {
|
|
|
227
236
|
}
|
|
228
237
|
}
|
|
229
238
|
|
|
230
|
-
function
|
|
239
|
+
function _hasTemplateDelimiters(key) {
|
|
231
240
|
key = key.trim()
|
|
232
|
-
|
|
241
|
+
// Check for {{ }} pattern
|
|
242
|
+
const doubleCurlyRegex = /\{\{.*?\}\}/
|
|
243
|
+
// Check for <% %> pattern
|
|
244
|
+
const anglePercentRegex = /<%.*?%>/
|
|
245
|
+
|
|
246
|
+
return doubleCurlyRegex.test(key) || anglePercentRegex.test(key)
|
|
233
247
|
}
|
|
234
248
|
|
|
235
249
|
module.exports = {
|
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.4",
|
|
4
4
|
"description": "Questwork vue component for displaying a list",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@questwork/q-utilities": "^0.1.
|
|
19
|
+
"@questwork/q-utilities": "^0.1.16"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@babel/core": "^7.17.8",
|