@qikdev/vue-ui 0.0.1 → 0.0.2
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 +6 -2
- package/src/components.js +209 -6
- package/src/content/browser.vue +477 -0
- package/src/content/item.vue +48 -0
- package/src/content/render/field.vue +423 -0
- package/src/content/render/group.vue +65 -0
- package/src/content/render/render-mixin.js +101 -0
- package/src/content/render/render.vue +86 -0
- package/src/filter/FilterBuilder.vue +147 -0
- package/src/filter/FilterCondition.vue +335 -0
- package/src/filter/FilterRule.vue +257 -0
- package/src/form/expressions/index.js +83 -0
- package/src/form/field.vue +624 -0
- package/src/form/form.vue +280 -0
- package/src/form/getDefaultValue.js +224 -0
- package/src/form/inputs/button-select.vue +208 -0
- package/src/form/inputs/checkbox.vue +91 -0
- package/src/form/inputs/content-select.vue +187 -0
- package/src/form/inputs/currency.vue +205 -0
- package/src/form/inputs/datefield.vue +132 -0
- package/src/form/inputs/group.vue +155 -0
- package/src/form/inputs/input-mixin.js +440 -0
- package/src/form/inputs/native-select-old.vue +43 -0
- package/src/form/inputs/object-field.vue +50 -0
- package/src/form/inputs/option.vue +19 -0
- package/src/form/inputs/options-manager.vue +244 -0
- package/src/form/inputs/phone-number-input.vue +235 -0
- package/src/form/inputs/search.vue +117 -0
- package/src/form/inputs/select.vue +211 -0
- package/src/form/inputs/switch.vue +87 -0
- package/src/form/inputs/textarea.vue +80 -0
- package/src/form/inputs/textfield.vue +165 -0
- package/src/form/inputs/timezone.vue +642 -0
- package/src/form/inputs/upload/filedrop.vue +72 -0
- package/src/form/inputs/upload/upload.vue +323 -0
- package/src/form/parseBoolean.js +24 -0
- package/src/layout/flex-body.vue +3 -2
- package/src/layout/flex-cell.vue +45 -0
- package/src/layout/flex-column.vue +1 -1
- package/src/layout/flex-footer.vue +3 -2
- package/src/layout/flex-header.vue +3 -2
- package/src/layout/flex-row.vue +35 -0
- package/src/layout/flex-spacer.vue +17 -0
- package/src/layout/panel-body.vue +13 -0
- package/src/layout/panel-footer.vue +20 -0
- package/src/layout/panel-header.vue +20 -0
- package/src/layout/panel.vue +23 -0
- package/src/modal/ConfirmModal.vue +50 -0
- package/src/modal/ContentModal.vue +99 -0
- package/src/modal/Modal.vue +85 -0
- package/src/modal/ModalMixin.js +21 -0
- package/src/modal/OptionsModal.vue +31 -0
- package/src/modal/PromptModal.vue +31 -0
- package/src/services/selection.js +140 -0
- package/src/table/Table.vue +269 -0
- package/src/table/TableCell.vue +64 -0
- package/src/table/TableRow.vue +94 -0
- package/src/table/cells/TableCellMixin.js +15 -0
- package/src/table/cells/Thumbnail.vue +38 -0
- package/src/ui/button.vue +254 -0
- package/src/ui/checkbox.vue +79 -0
- package/src/ui/icon.vue +57 -0
- package/src/ui/image.vue +158 -0
- package/src/ui/link.vue +62 -0
- package/src/ui/list-item.vue +16 -0
- package/src/ui/list.vue +26 -0
- package/src/ui/menu.vue +135 -0
- package/src/ui/progressbar.vue +77 -0
- package/src/ui/spinner.vue +26 -0
- package/src/ui/switch.vue +89 -0
- package/yarn-error.log +2923 -0
- package/index.js +0 -14
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<flex-column class="filter-builder">
|
|
3
|
+
<flex-body>
|
|
4
|
+
<div class="filters">
|
|
5
|
+
<div class="top">
|
|
6
|
+
<div class="summary">
|
|
7
|
+
Match <native-select v-model="model.operator" :field="operatorField">
|
|
8
|
+
{{summary}}
|
|
9
|
+
</native-select> of the following rules
|
|
10
|
+
</div>
|
|
11
|
+
</div>
|
|
12
|
+
<filter-rule :enableRemove="model.filters.length > 1" :key="`rule-${index}`" @remove="removeRule(index)" :definition="definition" v-model="model.filters[index]" :index="index" v-for="(rule, index) in model.filters" />
|
|
13
|
+
<ux-button @click="addRule()">Add Rule</ux-button>
|
|
14
|
+
</div>
|
|
15
|
+
</flex-body>
|
|
16
|
+
</flex-column>
|
|
17
|
+
</template>
|
|
18
|
+
<script>
|
|
19
|
+
import NativeSelect from '../form/inputs/select.vue';
|
|
20
|
+
|
|
21
|
+
import FilterRule from './FilterRule.vue';
|
|
22
|
+
import debounce from 'lodash/debounce';
|
|
23
|
+
|
|
24
|
+
export default {
|
|
25
|
+
components: {
|
|
26
|
+
FilterRule,
|
|
27
|
+
NativeSelect,
|
|
28
|
+
},
|
|
29
|
+
methods: {
|
|
30
|
+
removeRule(index) {
|
|
31
|
+
this.model.filters.splice(index, 1);
|
|
32
|
+
},
|
|
33
|
+
addRule() {
|
|
34
|
+
this.model.filters.push({
|
|
35
|
+
operator: 'and',
|
|
36
|
+
filters: [{
|
|
37
|
+
|
|
38
|
+
}],
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
computed: {
|
|
43
|
+
summary() {
|
|
44
|
+
switch (this.model.operator) {
|
|
45
|
+
case 'or':
|
|
46
|
+
return `any`;
|
|
47
|
+
break;
|
|
48
|
+
case 'nor':
|
|
49
|
+
return `none`;
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
return `all`;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
operatorField() {
|
|
57
|
+
return {
|
|
58
|
+
minimum: 1,
|
|
59
|
+
maximum: 1,
|
|
60
|
+
options: [{
|
|
61
|
+
title: 'All',
|
|
62
|
+
value: 'and',
|
|
63
|
+
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
title: 'Any',
|
|
67
|
+
value: 'or',
|
|
68
|
+
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
title: 'None',
|
|
72
|
+
value: 'nor',
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
watch: {
|
|
80
|
+
modelValue(v) {
|
|
81
|
+
var currentString = JSON.stringify(this.model)
|
|
82
|
+
var stringed = JSON.stringify(v);
|
|
83
|
+
|
|
84
|
+
if (currentString != stringed) {
|
|
85
|
+
this.model = JSON.parse(stringed)
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
model: {
|
|
89
|
+
handler: debounce(function(v) {
|
|
90
|
+
this.$emit('update:modelValue', v);
|
|
91
|
+
}, 300),
|
|
92
|
+
deep: true,
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
props: {
|
|
96
|
+
definition: {
|
|
97
|
+
type: Object,
|
|
98
|
+
require: true,
|
|
99
|
+
},
|
|
100
|
+
modelValue: {
|
|
101
|
+
type: Object,
|
|
102
|
+
default () {
|
|
103
|
+
return {
|
|
104
|
+
operator: 'and',
|
|
105
|
+
filters: [{
|
|
106
|
+
operator: 'and',
|
|
107
|
+
filters: [],
|
|
108
|
+
}],
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
data() {
|
|
114
|
+
return {
|
|
115
|
+
model: JSON.parse(JSON.stringify(this.modelValue))
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
</script>
|
|
120
|
+
<style lang="scss" scoped>
|
|
121
|
+
.filter-builder {
|
|
122
|
+
background: rgba(#000, 0.1);
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
.filters {
|
|
126
|
+
padding:0.7em;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.summary {
|
|
130
|
+
font-size: 0.8em;
|
|
131
|
+
opacity: 0.8;
|
|
132
|
+
padding:0.3em 0.7em;
|
|
133
|
+
|
|
134
|
+
.native-select {
|
|
135
|
+
display: inline-block;
|
|
136
|
+
border: 1px solid transparent;
|
|
137
|
+
border-radius: 0.3em;
|
|
138
|
+
padding: 0.2em;
|
|
139
|
+
|
|
140
|
+
&:hover {
|
|
141
|
+
background: #fff;
|
|
142
|
+
border-color: $primary;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
</style>
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="filter-condition" v-if="comparators">
|
|
3
|
+
<flex-row>
|
|
4
|
+
<flex-cell>
|
|
5
|
+
<native-select title="Select field" v-model="model.key" :field="keyField" />
|
|
6
|
+
</flex-cell>
|
|
7
|
+
<flex-cell v-if="model.key">
|
|
8
|
+
<native-select title="Select comparator" v-model="model.comparator" :field="comparatorField" />
|
|
9
|
+
</flex-cell>
|
|
10
|
+
<flex-cell v-if="model.comparator">
|
|
11
|
+
<div v-if="inputType == 'array'">
|
|
12
|
+
<text-field :field="arrayField" v-model="model.values" />
|
|
13
|
+
</div>
|
|
14
|
+
<div v-if="inputType == 'range'">
|
|
15
|
+
<text-field :field="normalField" v-model="model.value" />
|
|
16
|
+
And
|
|
17
|
+
<text-field :field="normalField" v-model="model.value2" />
|
|
18
|
+
</div>
|
|
19
|
+
<div v-if="inputType == 'daterelative'">
|
|
20
|
+
<flex-row>
|
|
21
|
+
<flex-cell style="width:80px">
|
|
22
|
+
<text-field :field="relativeNumberField" v-model="model.value" />
|
|
23
|
+
</flex-cell>
|
|
24
|
+
<flex-cell>
|
|
25
|
+
<native-select v-model="model.value2" :field="relativePeriodField" />
|
|
26
|
+
<!-- <text-field :field="relativePeriodField" v-model="model.value" /> -->
|
|
27
|
+
</flex-cell>
|
|
28
|
+
</flex-row>
|
|
29
|
+
</div>
|
|
30
|
+
<div v-if="inputType == 'daterange'">
|
|
31
|
+
<date-field :field="dateField" v-model="model.value" />
|
|
32
|
+
And
|
|
33
|
+
<date-field :field="dateField" v-model="model.value2" />
|
|
34
|
+
</div>
|
|
35
|
+
<div v-if="inputType == 'date'">
|
|
36
|
+
<date-field :field="dateField" v-model="model.value" />
|
|
37
|
+
</div>
|
|
38
|
+
<div v-if="inputType == 'reference'">
|
|
39
|
+
<content-select :field="singleReferenceField" v-model="model.value" />
|
|
40
|
+
</div>
|
|
41
|
+
<div v-if="inputType == 'multireference'">
|
|
42
|
+
<content-select :field="multiReferenceField" v-model="model.values" />
|
|
43
|
+
</div>
|
|
44
|
+
<div v-if="inputType == 'boolean'">
|
|
45
|
+
<input type="checkbox" v-model="model.value" />
|
|
46
|
+
</div>
|
|
47
|
+
<div v-if="inputType == 'none'">
|
|
48
|
+
</div>
|
|
49
|
+
<div v-if="inputType == 'number'">
|
|
50
|
+
<text-field :field="normalField" v-model="model.value" />
|
|
51
|
+
</div>
|
|
52
|
+
<div v-if="inputType == 'normal'">
|
|
53
|
+
<text-field :field="normalField" v-model="model.value" />
|
|
54
|
+
</div>
|
|
55
|
+
<!-- <pre>{{inputType}}</pre> -->
|
|
56
|
+
<!-- <pre>{{comparator}}</pre>
|
|
57
|
+
<native-select v-model="model.value" :field="comparatorField">
|
|
58
|
+
{{model.comparator || 'Select Value'}}
|
|
59
|
+
</native-select> -->
|
|
60
|
+
</flex-cell>
|
|
61
|
+
<flex-cell shrink v-if="enableRemove">
|
|
62
|
+
<ux-button icon @click="$emit('remove')">
|
|
63
|
+
<ux-icon icon="fa-times" />
|
|
64
|
+
</ux-button>
|
|
65
|
+
</flex-cell>
|
|
66
|
+
</flex-row>
|
|
67
|
+
</div>
|
|
68
|
+
</template>
|
|
69
|
+
<script>
|
|
70
|
+
import DateField from '../form/inputs/datefield.vue';
|
|
71
|
+
import TextField from '../form/inputs/textfield.vue';
|
|
72
|
+
import NativeSelect from '../form/inputs/select.vue';
|
|
73
|
+
|
|
74
|
+
export default {
|
|
75
|
+
props: {
|
|
76
|
+
fields: {
|
|
77
|
+
type: Array,
|
|
78
|
+
default () {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
enableRemove: {
|
|
83
|
+
type: Boolean,
|
|
84
|
+
},
|
|
85
|
+
modelValue: {
|
|
86
|
+
type: Object,
|
|
87
|
+
default () {
|
|
88
|
+
return {
|
|
89
|
+
key: '',
|
|
90
|
+
comparator: '',
|
|
91
|
+
value: null,
|
|
92
|
+
value2: null,
|
|
93
|
+
values: [],
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
watch: {
|
|
99
|
+
modelValue(m) {
|
|
100
|
+
if (m != this.model) {
|
|
101
|
+
this.model = m;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
async created() {
|
|
106
|
+
this.comparators = await this.$qik.content.comparators();
|
|
107
|
+
},
|
|
108
|
+
data() {
|
|
109
|
+
return {
|
|
110
|
+
comparators: null,
|
|
111
|
+
model: this.modelValue,
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
computed: {
|
|
115
|
+
fieldHash() {
|
|
116
|
+
return this.fields.reduce(function(set, field) {
|
|
117
|
+
|
|
118
|
+
set[field.path] = field;
|
|
119
|
+
return set;
|
|
120
|
+
}, {})
|
|
121
|
+
},
|
|
122
|
+
keyOptions() {
|
|
123
|
+
return this.fields.reduce(function(set, entry) {
|
|
124
|
+
switch (entry.type) {
|
|
125
|
+
case 'group':
|
|
126
|
+
break;
|
|
127
|
+
default:
|
|
128
|
+
set.push({
|
|
129
|
+
title: entry.titles.join(' > '),
|
|
130
|
+
value: entry.path || entry.key,
|
|
131
|
+
})
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
return set;
|
|
137
|
+
|
|
138
|
+
}, [])
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
keyField() {
|
|
142
|
+
return {
|
|
143
|
+
minimum: 1,
|
|
144
|
+
maximum: 1,
|
|
145
|
+
options: this.keyOptions,
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
field() {
|
|
149
|
+
return this.fieldHash[this.model.key];
|
|
150
|
+
},
|
|
151
|
+
fieldType() {
|
|
152
|
+
if (!this.field) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return this.field.type;
|
|
157
|
+
},
|
|
158
|
+
inputType() {
|
|
159
|
+
if (!this.comparator) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
var inputType = this.comparator.inputType;
|
|
164
|
+
|
|
165
|
+
switch (inputType) {
|
|
166
|
+
case 'none':
|
|
167
|
+
case 'range':
|
|
168
|
+
case 'daterange':
|
|
169
|
+
case 'daterelative':
|
|
170
|
+
break;
|
|
171
|
+
case 'array':
|
|
172
|
+
switch (this.fieldType) {
|
|
173
|
+
case 'reference':
|
|
174
|
+
inputType = 'multireference';
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
178
|
+
default:
|
|
179
|
+
|
|
180
|
+
inputType = 'normal';
|
|
181
|
+
switch (this.fieldType) {
|
|
182
|
+
case 'reference':
|
|
183
|
+
case 'boolean':
|
|
184
|
+
case 'date':
|
|
185
|
+
inputType = this.fieldType;
|
|
186
|
+
break;
|
|
187
|
+
case 'integer':
|
|
188
|
+
case 'decimal':
|
|
189
|
+
case 'float':
|
|
190
|
+
case 'number':
|
|
191
|
+
inputType = 'number';
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return inputType;
|
|
198
|
+
},
|
|
199
|
+
comparator() {
|
|
200
|
+
return this.comparatorLookup[this.model.comparator];
|
|
201
|
+
},
|
|
202
|
+
comparatorLookup() {
|
|
203
|
+
return this.comparators.hash;
|
|
204
|
+
},
|
|
205
|
+
comparatorOptions() {
|
|
206
|
+
if (!this.fieldType) {
|
|
207
|
+
return [];
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
var relevantComparators = this.comparators.available[this.fieldType] || [];
|
|
211
|
+
var options = relevantComparators.map(function(entry) {
|
|
212
|
+
return {
|
|
213
|
+
title: entry.title,
|
|
214
|
+
value: entry.operator,
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
return options;
|
|
219
|
+
|
|
220
|
+
},
|
|
221
|
+
|
|
222
|
+
comparatorField() {
|
|
223
|
+
return {
|
|
224
|
+
minimum: 1,
|
|
225
|
+
maximum: 1,
|
|
226
|
+
options: this.comparatorOptions,
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
referenceType() {
|
|
230
|
+
if (!this.field) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return this.field.referenceType;
|
|
235
|
+
},
|
|
236
|
+
relativeNumberField() {
|
|
237
|
+
return {
|
|
238
|
+
type: 'integer',
|
|
239
|
+
maximum: 1,
|
|
240
|
+
minimum: 1,
|
|
241
|
+
placeholder: '0',
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
relativePeriodField() {
|
|
245
|
+
return {
|
|
246
|
+
type: 'string',
|
|
247
|
+
maximum: 1,
|
|
248
|
+
minimum: 1,
|
|
249
|
+
widget: 'select',
|
|
250
|
+
options: [{
|
|
251
|
+
title: 'Minutes',
|
|
252
|
+
value: 'minutes',
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
title: 'Hours',
|
|
256
|
+
value: 'hours',
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
title: 'Days',
|
|
260
|
+
value: 'days',
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
title: 'Weeks',
|
|
264
|
+
value: 'weeks',
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
title: 'Months',
|
|
268
|
+
value: 'months',
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
title: 'Years',
|
|
272
|
+
value: 'years',
|
|
273
|
+
}
|
|
274
|
+
]
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
dateField() {
|
|
278
|
+
return {
|
|
279
|
+
type: this.fieldType,
|
|
280
|
+
maximum: 1,
|
|
281
|
+
minimum: 1,
|
|
282
|
+
placeholder: this.field.title,
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
normalField() {
|
|
286
|
+
return {
|
|
287
|
+
type: this.fieldType,
|
|
288
|
+
maximum: 1,
|
|
289
|
+
minimum: 1,
|
|
290
|
+
placeholder: this.field.title,
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
arrayField() {
|
|
294
|
+
return {
|
|
295
|
+
title: this.field.title,
|
|
296
|
+
type: this.fieldType,
|
|
297
|
+
maximum: 0,
|
|
298
|
+
minimum: 1,
|
|
299
|
+
}
|
|
300
|
+
},
|
|
301
|
+
singleReferenceField() {
|
|
302
|
+
return {
|
|
303
|
+
type: 'reference',
|
|
304
|
+
referenceType,
|
|
305
|
+
maximum: 1,
|
|
306
|
+
minimum: 1,
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
multiReferenceField() {
|
|
310
|
+
return {
|
|
311
|
+
type: 'reference',
|
|
312
|
+
referenceType,
|
|
313
|
+
maximum: 0,
|
|
314
|
+
minimum: 1,
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
methods: {},
|
|
319
|
+
|
|
320
|
+
components: {
|
|
321
|
+
TextField,
|
|
322
|
+
DateField,
|
|
323
|
+
NativeSelect,
|
|
324
|
+
},
|
|
325
|
+
}
|
|
326
|
+
</script>
|
|
327
|
+
<style lang="scss">
|
|
328
|
+
.filter-condition {
|
|
329
|
+
padding: 0.2em;
|
|
330
|
+
border-radius: 0.3em;
|
|
331
|
+
background: #fff;
|
|
332
|
+
border: 1px solid rgba(#000, 0.1);
|
|
333
|
+
margin: 0.5em;
|
|
334
|
+
}
|
|
335
|
+
</style>
|