glib-web 0.5.98 → 0.6.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.
Files changed (204) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +0 -0
  3. package/action.js +167 -167
  4. package/actions/analytics/logEvent.js +0 -0
  5. package/actions/auth/creditCard.js +0 -0
  6. package/actions/auth/restart.js +0 -0
  7. package/actions/auth/saveCsrfToken.js +0 -0
  8. package/actions/cables/push.js +0 -0
  9. package/actions/dialogs/alert.js +0 -0
  10. package/actions/dialogs/notification.js +0 -0
  11. package/actions/dialogs/oauth.js +0 -0
  12. package/actions/dialogs/open.js +0 -0
  13. package/actions/dialogs/options.js +0 -0
  14. package/actions/dialogs/show.js +0 -0
  15. package/actions/forms/submit.js +0 -0
  16. package/actions/http/delete.js +0 -0
  17. package/actions/http/patch.js +0 -0
  18. package/actions/http/post.js +0 -0
  19. package/actions/http/put.js +0 -0
  20. package/actions/panels/scrollTo.js +18 -18
  21. package/actions/panels/scrollToBottom.js +0 -0
  22. package/actions/runMultiple.js +0 -0
  23. package/actions/sheets/select.js +0 -0
  24. package/actions/snackbars/alert.js +0 -0
  25. package/actions/snackbars/select.js +0 -0
  26. package/actions/timeouts/set.js +20 -20
  27. package/actions/windows/close.js +0 -0
  28. package/actions/windows/closeAll.js +0 -0
  29. package/actions/windows/closeWithReload.js +0 -0
  30. package/actions/windows/open.js +0 -0
  31. package/actions/windows/openWeb.js +0 -0
  32. package/actions/windows/refreshState.js +5 -5
  33. package/actions/windows/reload.js +0 -0
  34. package/actions/ws/push.js +0 -0
  35. package/app.vue +180 -180
  36. package/components/_badge.vue +23 -23
  37. package/components/_button.vue +107 -107
  38. package/components/_dropdownMenu.vue +76 -76
  39. package/components/_icon.vue +50 -50
  40. package/components/_message.vue +0 -0
  41. package/components/avatar.vue +18 -18
  42. package/components/banners/alert.vue +0 -0
  43. package/components/banners/select.vue +82 -82
  44. package/components/button.vue +33 -40
  45. package/components/calendar.vue +0 -0
  46. package/components/charts/column.vue +47 -34
  47. package/components/charts/line.vue +67 -65
  48. package/components/chip.vue +51 -26
  49. package/components/component.vue +225 -225
  50. package/components/datetime.vue +0 -0
  51. package/components/fab.vue +0 -0
  52. package/components/fields/_patternText.vue +65 -65
  53. package/components/fields/_select.vue +86 -86
  54. package/components/fields/autocomplete.vue +73 -73
  55. package/components/fields/check.vue +91 -81
  56. package/components/fields/checkGroup.vue +58 -58
  57. package/components/fields/country/countries.js +0 -0
  58. package/components/fields/country/field.vue +0 -0
  59. package/components/fields/country/regions.js +0 -0
  60. package/components/fields/creditCard.vue +22 -13
  61. package/components/fields/date.vue +24 -24
  62. package/components/fields/datetime.vue +0 -0
  63. package/components/fields/dynamicGroup.vue +0 -0
  64. package/components/fields/dynamicSelect.vue +0 -0
  65. package/components/fields/file.vue +0 -0
  66. package/components/fields/googlePlace.vue +0 -0
  67. package/components/fields/hidden.vue +0 -0
  68. package/components/fields/location.vue +198 -198
  69. package/components/fields/newRichText.vue +0 -0
  70. package/components/fields/phone/countries.js +315 -315
  71. package/components/fields/phone/field.vue +351 -351
  72. package/components/fields/phone/sprite.css +1071 -1071
  73. package/components/fields/radio.vue +16 -16
  74. package/components/fields/radioGroup.vue +42 -42
  75. package/components/fields/rating.vue +0 -0
  76. package/components/fields/richText.vue +0 -0
  77. package/components/fields/select.vue +17 -17
  78. package/components/fields/stripe/stripeFields.vue +93 -93
  79. package/components/fields/stripe/stripeIndividualFields.vue +207 -207
  80. package/components/fields/stripeExternalAccount.vue +135 -135
  81. package/components/fields/text.vue +0 -0
  82. package/components/fields/textarea.vue +0 -0
  83. package/components/fields/timeZone.vue +22 -22
  84. package/components/fields/timer.vue +83 -83
  85. package/components/h1.vue +28 -28
  86. package/components/h2.vue +28 -20
  87. package/components/h3.vue +29 -22
  88. package/components/h4.vue +28 -20
  89. package/components/h5.vue +28 -20
  90. package/components/h6.vue +28 -20
  91. package/components/hr.vue +0 -0
  92. package/components/html.vue +0 -0
  93. package/components/icon.vue +25 -25
  94. package/components/image.vue +0 -0
  95. package/components/label.vue +62 -62
  96. package/components/map.vue +0 -0
  97. package/components/markdown.vue +0 -0
  98. package/components/mixins/{chart.js → chart/annotation.js} +73 -73
  99. package/components/mixins/chart/tooltip.js +31 -0
  100. package/components/mixins/events.js +178 -178
  101. package/components/mixins/generic.js +0 -0
  102. package/components/mixins/list/autoload.js +0 -0
  103. package/components/mixins/longClick.js +0 -0
  104. package/components/mixins/scrolling.js +0 -0
  105. package/components/mixins/styles.js +222 -222
  106. package/components/mixins/table/autoload.js +0 -0
  107. package/components/mixins/table/export.js +0 -0
  108. package/components/mixins/table/import.js +0 -0
  109. package/components/mixins/text.js +20 -20
  110. package/components/mixins/tooltip.js +11 -0
  111. package/components/mixins/ws/actionCable.js +48 -48
  112. package/components/mixins/ws/phoenixSocket.js +0 -0
  113. package/components/p.vue +0 -0
  114. package/components/panels/carousel.vue +55 -55
  115. package/components/panels/column.vue +0 -0
  116. package/components/panels/custom.vue +0 -0
  117. package/components/panels/flow.vue +81 -81
  118. package/components/panels/form.vue +130 -130
  119. package/components/panels/horizontal.vue +0 -0
  120. package/components/panels/list.vue +247 -247
  121. package/components/panels/responsive.vue +94 -94
  122. package/components/panels/scroll.vue +0 -0
  123. package/components/panels/split.vue +0 -0
  124. package/components/panels/table.vue +0 -0
  125. package/components/panels/ul.vue +34 -34
  126. package/components/panels/vertical.vue +0 -0
  127. package/components/panels/web.vue +11 -11
  128. package/components/progressbar.vue +36 -36
  129. package/components/spacer.vue +0 -0
  130. package/components/switch.vue +42 -42
  131. package/components/tabBar.vue +68 -68
  132. package/extensions/array.js +0 -0
  133. package/extensions/string.js +21 -21
  134. package/index.js +199 -199
  135. package/keys.js +0 -0
  136. package/nav/appbar.vue +136 -136
  137. package/nav/content.vue +0 -0
  138. package/nav/dialog.vue +127 -127
  139. package/nav/drawer.vue +105 -105
  140. package/nav/drawerButton.vue +31 -31
  141. package/nav/drawerLabel.vue +0 -0
  142. package/nav/sheet.vue +0 -0
  143. package/nav/snackbar.vue +0 -0
  144. package/package.json +44 -44
  145. package/settings.json.example +0 -0
  146. package/static/plugins/alignment/alignment.js +0 -0
  147. package/static/plugins/alignment/alignment.min.js +0 -0
  148. package/static/plugins/beyondgrammar/beyondgrammar.js +0 -0
  149. package/static/plugins/beyondgrammar/beyondgrammar.min.js +0 -0
  150. package/static/plugins/blockcode/blockcode.js +0 -0
  151. package/static/plugins/blockcode/blockcode.min.js +0 -0
  152. package/static/plugins/clips/clips.js +0 -0
  153. package/static/plugins/clips/clips.min.js +0 -0
  154. package/static/plugins/counter/counter.js +0 -0
  155. package/static/plugins/counter/counter.min.js +0 -0
  156. package/static/plugins/definedlinks/definedlinks.js +0 -0
  157. package/static/plugins/definedlinks/definedlinks.min.js +0 -0
  158. package/static/plugins/handle/handle.js +0 -0
  159. package/static/plugins/handle/handle.min.js +0 -0
  160. package/static/plugins/icons/icons.js +0 -0
  161. package/static/plugins/icons/icons.min.js +0 -0
  162. package/static/plugins/imageposition/imageposition.js +0 -0
  163. package/static/plugins/imageposition/imageposition.min.js +0 -0
  164. package/static/plugins/inlineformat/inlineformat.js +0 -0
  165. package/static/plugins/inlineformat/inlineformat.min.js +0 -0
  166. package/static/plugins/removeformat/removeformat.js +0 -0
  167. package/static/plugins/removeformat/removeformat.min.js +0 -0
  168. package/static/plugins/selector/selector.js +0 -0
  169. package/static/plugins/selector/selector.min.js +0 -0
  170. package/static/plugins/specialchars/specialchars.js +0 -0
  171. package/static/plugins/specialchars/specialchars.min.js +0 -0
  172. package/static/plugins/textdirection/textdirection.js +0 -0
  173. package/static/plugins/textdirection/textdirection.min.js +0 -0
  174. package/static/plugins/textexpander/textexpander.js +0 -0
  175. package/static/plugins/textexpander/textexpander.min.js +0 -0
  176. package/static/plugins/underline/underline.js +0 -0
  177. package/static/plugins/underline/underline.min.js +0 -0
  178. package/static/redactorx.css +0 -0
  179. package/static/redactorx.js +0 -0
  180. package/static/redactorx.min.css +0 -0
  181. package/static/redactorx.min.js +0 -0
  182. package/static/redactorx.usm.min.js +0 -0
  183. package/styles/test.sass +0 -0
  184. package/styles/test.scss +0 -0
  185. package/templates/_menu.vue +38 -38
  186. package/templates/comment.vue +202 -202
  187. package/templates/featured.vue +32 -32
  188. package/templates/thumbnail.vue +145 -145
  189. package/templates/unsupported.vue +12 -12
  190. package/utils/app.js +0 -0
  191. package/utils/dom.js +0 -0
  192. package/utils/form.js +0 -0
  193. package/utils/hash.js +0 -0
  194. package/utils/helper.js +0 -0
  195. package/utils/history.js +70 -70
  196. package/utils/http.js +209 -209
  197. package/utils/launch.js +135 -135
  198. package/utils/private/ws.js +0 -0
  199. package/utils/public.js +0 -0
  200. package/utils/settings.js +0 -0
  201. package/utils/storage.js +0 -0
  202. package/utils/type.js +0 -0
  203. package/utils/uploader.js +0 -0
  204. package/utils/url.js +136 -136
File without changes
@@ -1,65 +1,65 @@
1
- <template>
2
- <div :style="$styles()" :class="classes()">
3
- <!-- See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date for why we need to use `pattern` -->
4
- <v-text-field
5
- v-model="fieldModel"
6
- :name="fieldName"
7
- :label="spec.label"
8
- :value="spec.value"
9
- :hint="spec.hint"
10
- :type="type"
11
- :readonly="spec.readOnly || false"
12
- :disabled="spec.readOnly"
13
- :min="$sanitizeValue(spec.min)"
14
- :max="$sanitizeValue(spec.max)"
15
- :pattern="pattern"
16
- :outlined="$classes().includes('outlined')"
17
- :style="$styles()"
18
- clearable
19
- />
20
- </div>
21
- </template>
22
-
23
- <script>
24
- export default {
25
- props: {
26
- spec: { type: Object, required: true },
27
- type: { type: String, required: true },
28
- pattern: { type: String, required: true }
29
- },
30
- methods: {
31
- $internalizeValue(val) {
32
- if (Utils.type.isString(val)) {
33
- return new Date(val).getTime() / 1000;
34
- }
35
- return null;
36
- },
37
- $externalizeValue(val) {
38
- if (Utils.type.isNumber(val)) {
39
- const date = new Date(val * 1000);
40
- return Utils.format.local_iso8601(date);
41
- }
42
- return null;
43
- },
44
- $sanitizeValue(val) {
45
- if (val) {
46
- switch (this.type) {
47
- case "date":
48
- return val.slice(0, 10);
49
- case "month":
50
- return val.slice(0, 7);
51
- case "datetime-local":
52
- return val.slice(0, 16);
53
- default:
54
- return val;
55
- }
56
- }
57
- },
58
- classes() {
59
- return this.$classes().concat("g-text-field--hintless");
60
- }
61
- }
62
- };
63
- </script>
64
-
65
- <style scoped></style>
1
+ <template>
2
+ <div :style="$styles()" :class="classes()">
3
+ <!-- See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date for why we need to use `pattern` -->
4
+ <v-text-field
5
+ v-model="fieldModel"
6
+ :name="fieldName"
7
+ :label="spec.label"
8
+ :value="spec.value"
9
+ :hint="spec.hint"
10
+ :type="type"
11
+ :readonly="spec.readOnly || false"
12
+ :disabled="spec.readOnly"
13
+ :min="$sanitizeValue(spec.min)"
14
+ :max="$sanitizeValue(spec.max)"
15
+ :pattern="pattern"
16
+ :outlined="$classes().includes('outlined')"
17
+ :style="$styles()"
18
+ clearable
19
+ />
20
+ </div>
21
+ </template>
22
+
23
+ <script>
24
+ export default {
25
+ props: {
26
+ spec: { type: Object, required: true },
27
+ type: { type: String, required: true },
28
+ pattern: { type: String, required: true }
29
+ },
30
+ methods: {
31
+ $internalizeValue(val) {
32
+ if (Utils.type.isString(val)) {
33
+ return new Date(val).getTime() / 1000;
34
+ }
35
+ return null;
36
+ },
37
+ $externalizeValue(val) {
38
+ if (Utils.type.isNumber(val)) {
39
+ const date = new Date(val * 1000);
40
+ return Utils.format.local_iso8601(date);
41
+ }
42
+ return null;
43
+ },
44
+ $sanitizeValue(val) {
45
+ if (val) {
46
+ switch (this.type) {
47
+ case "date":
48
+ return val.slice(0, 10);
49
+ case "month":
50
+ return val.slice(0, 7);
51
+ case "datetime-local":
52
+ return val.slice(0, 16);
53
+ default:
54
+ return val;
55
+ }
56
+ }
57
+ },
58
+ classes() {
59
+ return this.$classes().concat("g-text-field--hintless");
60
+ }
61
+ }
62
+ };
63
+ </script>
64
+
65
+ <style scoped></style>
@@ -1,86 +1,86 @@
1
- <template>
2
- <div :style="$styles()" :class="classes()">
3
- <v-autocomplete
4
- v-model="fieldModel"
5
- :label="spec.label"
6
- :items="options"
7
- :chips="spec.multiple"
8
- :deletable-chips="spec.multiple"
9
- :multiple="spec.multiple"
10
- :disabled="spec.readOnly"
11
- :clearable="!spec.readOnly"
12
- :hint="spec.hint"
13
- :placeholder="spec.placeholder"
14
- :rules="rules"
15
- validate-on-blur
16
- persistent-hint
17
- :class="$classes()"
18
- :outlined="$classes().includes('outlined')"
19
- :append-icon="append.icon"
20
- />
21
-
22
- <input
23
- v-for="(item, index) in values"
24
- :key="index"
25
- type="hidden"
26
- :name="fieldName"
27
- :value="item"
28
- />
29
- </div>
30
- </template>
31
-
32
- <script>
33
- export default {
34
- props: {
35
- spec: { type: Object, required: true },
36
- defaultValue: { type: String, default: null }
37
- },
38
- data() {
39
- return {
40
- options: null,
41
- append: {},
42
- rules: []
43
- };
44
- },
45
- computed: {
46
- values() {
47
- // Depends on whether the field is single or multiple
48
- if (this.$type.isArray(this.fieldModel)) {
49
- return this.fieldModel.length > 0 ? this.fieldModel : this.emptyValue;
50
- } else {
51
- return [this.fieldModel];
52
- }
53
- // return this.emptyValue;
54
- },
55
- // To avoid empty param error
56
- emptyValue() {
57
- return [null];
58
- }
59
- },
60
- methods: {
61
- $ready() {
62
- this.options = this.normalizedOptions();
63
- this.append = this.spec.append || {};
64
- this.rules = this.$validation();
65
- if (this.defaultValue) {
66
- this.fieldModel = this.defaultValue;
67
- }
68
- },
69
- normalizedOptions() {
70
- return this.spec.options.map(i => {
71
- switch (i.type) {
72
- case "label":
73
- return { header: i.text };
74
- case "divider":
75
- return { divider: true };
76
- default:
77
- return i;
78
- }
79
- });
80
- },
81
- classes() {
82
- return this.$classes().concat("g-text-field--hintless");
83
- }
84
- }
85
- };
86
- </script>
1
+ <template>
2
+ <div :style="$styles()" :class="classes()">
3
+ <v-autocomplete
4
+ v-model="fieldModel"
5
+ :label="spec.label"
6
+ :items="options"
7
+ :chips="spec.multiple"
8
+ :deletable-chips="spec.multiple"
9
+ :multiple="spec.multiple"
10
+ :disabled="spec.readOnly"
11
+ :clearable="!spec.readOnly"
12
+ :hint="spec.hint"
13
+ :placeholder="spec.placeholder"
14
+ :rules="rules"
15
+ validate-on-blur
16
+ persistent-hint
17
+ :class="$classes()"
18
+ :outlined="$classes().includes('outlined')"
19
+ :append-icon="append.icon"
20
+ />
21
+
22
+ <input
23
+ v-for="(item, index) in values"
24
+ :key="index"
25
+ type="hidden"
26
+ :name="fieldName"
27
+ :value="item"
28
+ />
29
+ </div>
30
+ </template>
31
+
32
+ <script>
33
+ export default {
34
+ props: {
35
+ spec: { type: Object, required: true },
36
+ defaultValue: { type: String, default: null }
37
+ },
38
+ data() {
39
+ return {
40
+ options: null,
41
+ append: {},
42
+ rules: []
43
+ };
44
+ },
45
+ computed: {
46
+ values() {
47
+ // Depends on whether the field is single or multiple
48
+ if (this.$type.isArray(this.fieldModel)) {
49
+ return this.fieldModel.length > 0 ? this.fieldModel : this.emptyValue;
50
+ } else {
51
+ return [this.fieldModel];
52
+ }
53
+ // return this.emptyValue;
54
+ },
55
+ // To avoid empty param error
56
+ emptyValue() {
57
+ return [null];
58
+ }
59
+ },
60
+ methods: {
61
+ $ready() {
62
+ this.options = this.normalizedOptions();
63
+ this.append = this.spec.append || {};
64
+ this.rules = this.$validation();
65
+ if (this.defaultValue) {
66
+ this.fieldModel = this.defaultValue;
67
+ }
68
+ },
69
+ normalizedOptions() {
70
+ return this.spec.options.map(i => {
71
+ switch (i.type) {
72
+ case "label":
73
+ return { header: i.text };
74
+ case "divider":
75
+ return { divider: true };
76
+ default:
77
+ return i;
78
+ }
79
+ });
80
+ },
81
+ classes() {
82
+ return this.$classes().concat("g-text-field--hintless");
83
+ }
84
+ }
85
+ };
86
+ </script>
@@ -1,73 +1,73 @@
1
- <!-- TODO: Remove (deprecated) -->
2
- <template>
3
- <div :style="genericStyles()">
4
- <v-combobox
5
- v-model="fieldModel"
6
- :label="spec.label"
7
- :items="options"
8
- :chips="spec.multiple"
9
- :deletable-chips="spec.multiple"
10
- :multiple="spec.multiple"
11
- :readonly="spec.readOnly"
12
- :disabled="spec.readOnly"
13
- :hint="spec.hint"
14
- :placeholder="spec.placeholder"
15
- :outlined="$classes().includes('outlined')"
16
- :append-icon="append.icon"
17
- />
18
-
19
- <input
20
- v-for="(item, index) in values"
21
- :key="index"
22
- type="hidden"
23
- :name="fieldName"
24
- :value="item"
25
- />
26
- </div>
27
- </template>
28
-
29
- <script>
30
- export default {
31
- props: {
32
- spec: { type: Object, required: true }
33
- },
34
- data() {
35
- return {
36
- options: null,
37
- append: {}
38
- };
39
- },
40
- computed: {
41
- values() {
42
- // Depends on whether the field is single or multiple
43
- if (this.$type.isArray(this.fieldModel)) {
44
- return this.fieldModel.length > 0 ? this.fieldModel : this.emptyValue;
45
- } else {
46
- return [this.fieldModel];
47
- }
48
- return this.emptyValue;
49
- },
50
- // To avoid empty param error
51
- emptyValue() {
52
- return [null];
53
- }
54
- },
55
- methods: {
56
- $ready() {
57
- const spec = this.spec;
58
- const options = spec.options;
59
-
60
- if (Utils.type.isArray(options)) {
61
- // It can be really confusing if the options are not strings (e.g. value-text pair)
62
- this.options = options.map(i =>
63
- Utils.type.isString(i)
64
- ? i
65
- : console.warn("Option needs to be a string", i)
66
- );
67
- }
68
-
69
- this.append = spec.append || {};
70
- }
71
- }
72
- };
73
- </script>
1
+ <!-- TODO: Remove (deprecated) -->
2
+ <template>
3
+ <div :style="genericStyles()">
4
+ <v-combobox
5
+ v-model="fieldModel"
6
+ :label="spec.label"
7
+ :items="options"
8
+ :chips="spec.multiple"
9
+ :deletable-chips="spec.multiple"
10
+ :multiple="spec.multiple"
11
+ :readonly="spec.readOnly"
12
+ :disabled="spec.readOnly"
13
+ :hint="spec.hint"
14
+ :placeholder="spec.placeholder"
15
+ :outlined="$classes().includes('outlined')"
16
+ :append-icon="append.icon"
17
+ />
18
+
19
+ <input
20
+ v-for="(item, index) in values"
21
+ :key="index"
22
+ type="hidden"
23
+ :name="fieldName"
24
+ :value="item"
25
+ />
26
+ </div>
27
+ </template>
28
+
29
+ <script>
30
+ export default {
31
+ props: {
32
+ spec: { type: Object, required: true }
33
+ },
34
+ data() {
35
+ return {
36
+ options: null,
37
+ append: {}
38
+ };
39
+ },
40
+ computed: {
41
+ values() {
42
+ // Depends on whether the field is single or multiple
43
+ if (this.$type.isArray(this.fieldModel)) {
44
+ return this.fieldModel.length > 0 ? this.fieldModel : this.emptyValue;
45
+ } else {
46
+ return [this.fieldModel];
47
+ }
48
+ return this.emptyValue;
49
+ },
50
+ // To avoid empty param error
51
+ emptyValue() {
52
+ return [null];
53
+ }
54
+ },
55
+ methods: {
56
+ $ready() {
57
+ const spec = this.spec;
58
+ const options = spec.options;
59
+
60
+ if (Utils.type.isArray(options)) {
61
+ // It can be really confusing if the options are not strings (e.g. value-text pair)
62
+ this.options = options.map(i =>
63
+ Utils.type.isString(i)
64
+ ? i
65
+ : console.warn("Option needs to be a string", i)
66
+ );
67
+ }
68
+
69
+ this.append = spec.append || {};
70
+ }
71
+ }
72
+ };
73
+ </script>
@@ -1,81 +1,91 @@
1
- <template>
2
- <div :class="$classes()" :style="$styles()">
3
- <fields-hidden v-if="uncheckSpec" :spec="uncheckSpec" />
4
- <v-checkbox
5
- v-model="fieldModel"
6
- :name="fieldName"
7
- :value="spec.checkValue"
8
- :label="fieldModel ? spec.onLabel || spec.label : spec.label"
9
- :on-icon="spec.onIcon"
10
- :off-icon="spec.offIcon"
11
- hide-details
12
- @change="changed"
13
- ></v-checkbox>
14
- </div>
15
- </template>
16
-
17
- <script>
18
- import HiddenField from "./hidden";
19
-
20
- export default {
21
- components: {
22
- "fields-hidden": HiddenField
23
- },
24
- props: {
25
- spec: { type: Object, required: true }
26
- },
27
- data() {
28
- return {
29
- groupName: null,
30
- fieldType: null,
31
- uncheckSpec: null
32
- };
33
- },
34
- methods: {
35
- $ready() {
36
- this.groupElement = this.$el.closest("[data-component=checkGroup]");
37
-
38
- let groupName = null;
39
- this.$type.ifObject(
40
- this.groupElement,
41
- val => (groupName = val.getAttribute("name"))
42
- );
43
-
44
- this.fieldName = this.spec.name || groupName;
45
- this.fieldModel = this.spec.checked
46
- ? this.spec.checkValue
47
- : this.spec.value;
48
-
49
- Utils.type.ifArray(this.spec.styleClasses, classes => {
50
- if (classes.remove("switch")) {
51
- this.fieldType = "switch";
52
- }
53
- });
54
-
55
- Utils.type.ifNotNull(this.spec.uncheckValue, value => {
56
- this.uncheckSpec = { name: this.spec.name, value: value };
57
- });
58
- },
59
- changed(event) {
60
- // Execute later to ensure the checkbox's checked state has been updated.
61
- setTimeout(() => {
62
- this.$type.ifObject(this.groupElement, val =>
63
- val.dispatchEvent(new Event("change"))
64
- );
65
- }, 100);
66
-
67
- if (this.spec.submitOnChange) {
68
- setTimeout(() => {
69
- this.$dispatchEvent("forms/submit");
70
- }, 200);
71
- }
72
- }
73
- }
74
- };
75
- </script>
76
-
77
- <style scoped>
78
- .v-input--selection-controls {
79
- margin-top: 0;
80
- }
81
- </style>
1
+ <template>
2
+ <div :class="$classes()" :style="$styles()">
3
+ <!-- <fields-hidden v-if="uncheckSpec" :spec="uncheckSpec" /> -->
4
+ <!-- This hidden field should always be there to make sure the submitted param is not empty,
5
+ which could cause "Not accessible" error on the server. -->
6
+ <input type="hidden" :name="fieldName" :value="spec.uncheckValue" />
7
+ <v-checkbox
8
+ v-model="fieldModel"
9
+ :name="fieldName"
10
+ :value="spec.checkValue"
11
+ :label="fieldModel ? spec.onLabel || spec.label : spec.label"
12
+ :on-icon="spec.onIcon"
13
+ :off-icon="spec.offIcon"
14
+ hide-details
15
+ @change="changed"
16
+ ></v-checkbox>
17
+ </div>
18
+ </template>
19
+
20
+ <script>
21
+ // import HiddenField from "./hidden";
22
+
23
+ export default {
24
+ // components: {
25
+ // "fields-hidden": HiddenField
26
+ // },
27
+ props: {
28
+ spec: { type: Object, required: true }
29
+ },
30
+ data() {
31
+ return {
32
+ groupName: null,
33
+ fieldType: null
34
+ // uncheckSpec: null
35
+ };
36
+ },
37
+ methods: {
38
+ $ready() {
39
+ this.groupElement = this.$el.closest("[data-component=checkGroup]");
40
+
41
+ let groupName = null;
42
+ this.$type.ifObject(
43
+ this.groupElement,
44
+ val => (groupName = val.getAttribute("name"))
45
+ );
46
+
47
+ this.fieldName = this.spec.name || groupName;
48
+
49
+ this.fieldModel = this.spec.checked
50
+ ? this.spec.checkValue
51
+ : this.spec.value;
52
+
53
+ Utils.type.ifArray(this.spec.styleClasses, classes => {
54
+ if (classes.remove("switch")) {
55
+ this.fieldType = "switch";
56
+ }
57
+ });
58
+
59
+ // Utils.type.ifNotNull(this.spec.uncheckValue, value => {
60
+ // this.uncheckSpec = { name: this.spec.name, value: value };
61
+ // });
62
+ },
63
+ changed(event) {
64
+ // Execute later to ensure the checkbox's checked state has been updated.
65
+ setTimeout(() => {
66
+ this.$type.ifObject(this.groupElement, val =>
67
+ val.dispatchEvent(new Event("change"))
68
+ );
69
+ }, 100);
70
+
71
+ if (this.spec.submitOnChange) {
72
+ setTimeout(() => {
73
+ this.$dispatchEvent("forms/submit");
74
+ }, 200);
75
+ }
76
+ },
77
+ $internalizeValue(val) {
78
+ if (val == this.spec.checkValue) {
79
+ return val;
80
+ }
81
+ return this.spec.uncheckValue;
82
+ }
83
+ }
84
+ };
85
+ </script>
86
+
87
+ <style scoped>
88
+ .v-input--selection-controls {
89
+ margin-top: 0;
90
+ }
91
+ </style>