glib-web 3.0.8 → 3.0.10

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/LICENSE CHANGED
File without changes
File without changes
File without changes
File without changes
@@ -8,14 +8,27 @@ export default class {
8
8
  console.debug("Scrolling to", selector);
9
9
  const element = pageBody.querySelector(selector);
10
10
 
11
- this.scrollIfNeeded(element, spec, component);
11
+ let alignment = "center"
12
+ switch (spec.placement) {
13
+ case "top":
14
+ alignment = "start"
15
+ break;
16
+ case "bottom":
17
+ alignment = "end"
18
+ break;
19
+ }
20
+
21
+ // this.scrollIfNeeded(element, spec, component);
22
+ this.scrollIfNeeded(element, spec, component, alignment);
12
23
 
13
24
  element.classList.add("glib-scrollto");
14
25
  element.classList.add("glib-scrollto--highlighted");
15
26
  }
16
27
 
17
28
  // From https://gist.github.com/hsablonniere/2581101
18
- scrollIfNeeded(element, spec, component, centerIfNeeded = true) {
29
+ // scrollIfNeeded(element, spec, component, centerIfNeeded = true) {
30
+
31
+ scrollIfNeeded(element, spec, component, alignment) {
19
32
  const vm = this;
20
33
  const observerOptions = {
21
34
  threshold: 1 // Trigger callback when 100% of the element becomes/unbecomes visible
@@ -23,11 +36,13 @@ export default class {
23
36
  new IntersectionObserver(function([entry]) {
24
37
  const ratio = entry.intersectionRatio;
25
38
  if (ratio < 1) {
26
- const place = ratio <= 0 && centerIfNeeded ? "center" : "nearest";
39
+ // const place = ratio <= 0 && centerIfNeeded ? "center" : "nearest";
40
+ const place = ratio <= 0 ? alignment : "nearest";
27
41
  element.scrollIntoView({
28
42
  block: place,
29
43
  inline: place,
30
- behavior: spec["animate"] ? "smooth" : "auto"
44
+ behavior: spec["animate"] ? "smooth" : "auto",
45
+
31
46
  });
32
47
  } else {
33
48
  vm.onScrollEnd(element, spec, component);
@@ -6,6 +6,7 @@
6
6
  :rounded="$classes().includes('rounded') || null"
7
7
  :density="density"
8
8
  :size="size"
9
+ :color="color"
9
10
  :icon="$classes().includes('icon') ? $vuetify : null"
10
11
  @click.prevent="
11
12
  type == 'submit' ? $dispatchEvent('forms/submit') : $onClick()
@@ -18,7 +19,7 @@
18
19
  </template>
19
20
 
20
21
  <script>
21
- import { determineDensity, determineVariant, determineSize } from '../utils/constant'
22
+ import { determineColor, determineDensity, determineVariant, determineSize } from '../utils/constant'
22
23
 
23
24
  export default {
24
25
  props: {
@@ -35,6 +36,9 @@ export default {
35
36
  };
36
37
  },
37
38
  computed: {
39
+ color() {
40
+ return determineColor(this.spec.styleClasses)
41
+ },
38
42
  density() {
39
43
  return determineDensity(this.spec.styleClasses)
40
44
  },
File without changes
File without changes
File without changes
@@ -5,7 +5,7 @@
5
5
  :readonly="spec.readOnly || false" :disabled="spec.readOnly" :min="$sanitizeValue(spec.min)"
6
6
  :max="$sanitizeValue(spec.max)" :pattern="pattern" :rules="$validation()" :style="$styles()"
7
7
  :density="$classes().includes('compact') ? 'compact' : 'default'"
8
- clearable @input="onChange" :variant="variant" validate-on="blur"
8
+ clearable @change="onChange" :variant="variant" validate-on="blur"
9
9
  persistent-placeholder />
10
10
  </div>
11
11
  </template>
@@ -3,8 +3,8 @@
3
3
  <v-autocomplete v-model="fieldModel" :label="spec.label" :items="options || []" :chips="spec.multiple"
4
4
  :multiple="spec.multiple" :disabled="spec.readOnly" :clearable="!spec.readOnly" :hint="spec.hint"
5
5
  :placeholder="spec.placeholder" :rules="rules" persistent-hint :class="$classes()" :append-icon="append.icon"
6
- @change="onChange" validate-on="blur" item-title='text' :variant="variant" :closable-chips="spec.multiple"
7
- :density="density" persistent-placeholder />
6
+ validate-on="blur" item-title='text' :variant="variant" :closable-chips="spec.multiple" :density="density"
7
+ persistent-placeholder @update:modelValue="onChange" />
8
8
 
9
9
  <input v-for="(item, index) in values" :key="index" type="hidden" :name="fieldName" :value="item" />
10
10
  </div>
@@ -20,7 +20,7 @@ export default {
20
20
  spec: { type: Object, required: true },
21
21
  defaultValue: { type: String, default: null }
22
22
  },
23
- data() {
23
+ data () {
24
24
  return {
25
25
  options: null,
26
26
  append: {},
@@ -28,7 +28,7 @@ export default {
28
28
  };
29
29
  },
30
30
  computed: {
31
- values() {
31
+ values () {
32
32
  // Depends on whether the field is single or multiple
33
33
  if (this.$type.isArray(this.fieldModel)) {
34
34
  return this.fieldModel.length > 0 ? this.fieldModel : this.emptyValue;
@@ -38,18 +38,18 @@ export default {
38
38
  // return this.emptyValue;
39
39
  },
40
40
  // To avoid empty param error
41
- emptyValue() {
41
+ emptyValue () {
42
42
  return [null];
43
43
  },
44
- density() {
44
+ density () {
45
45
  return determineDensity(this.spec.styleClasses)
46
46
  }
47
47
  },
48
48
  methods: {
49
- $ready() {
49
+ $ready () {
50
50
  this.updateData(false);
51
51
  },
52
- normalizedOptions() {
52
+ normalizedOptions () {
53
53
  return this.spec.options.map(i => {
54
54
  switch (i.type) {
55
55
  case "label":
@@ -61,13 +61,13 @@ export default {
61
61
  }
62
62
  });
63
63
  },
64
- classes() {
64
+ classes () {
65
65
  return this.$classes().concat("g-text-field--hintless");
66
66
  },
67
- onChange() {
67
+ onChange () {
68
68
  this.$executeOnChange();
69
69
  },
70
- updateData(reinitValue) {
70
+ updateData (reinitValue) {
71
71
  this.options = this.normalizedOptions();
72
72
  this.append = this.spec.append || {};
73
73
  this.rules = this.$validation();
@@ -80,7 +80,7 @@ export default {
80
80
  this.fieldModel = this.defaultValue;
81
81
  }
82
82
  },
83
- $registryEnabled() {
83
+ $registryEnabled () {
84
84
  return false;
85
85
  }
86
86
  }
File without changes
File without changes
package/components/hr.vue CHANGED
File without changes
File without changes
@@ -19,17 +19,20 @@ export default {
19
19
  // }
20
20
  // },
21
21
  methods: {
22
- enableInfiniteScrollIfApplicable: function () {
22
+ async enableInfiniteScrollIfApplicable(spec) {
23
+ // Make sure `page_body` has been initialized.
24
+ await this.$nextTick()
25
+
23
26
  this.$removeViewportChangeListeners(this.topScrollHandler);
24
27
  this.$removeViewportChangeListeners(this.bottomScrollHandler);
25
28
 
26
- const prevPage = this.spec.prevPage || {};
27
- const nextPage = this.spec.nextPage || {};
29
+ const prevPage = spec.prevPage || {};
30
+ const nextPage = spec.nextPage || {};
28
31
 
29
32
  this.infiniteScroll =
30
33
  nextPage.autoload == "asNeeded" || prevPage.autoload == "asNeeded";
31
- const onScrollToBottom = this.spec.onScrollToBottom;
32
- const onScrollToTop = this.spec.onScrollToTop;
34
+ const onScrollToBottom = spec.onScrollToBottom;
35
+ const onScrollToTop = spec.onScrollToTop;
33
36
 
34
37
  // Reset state for reuse.
35
38
  this.nextPageUrl = null;
File without changes
File without changes
File without changes
File without changes
@@ -1,50 +1,79 @@
1
1
  <template>
2
- <!-- <component
3
- :is="componentName"
4
- :class="cssClasses"
5
- :style="cssStyles"
6
- :href="$href()"
7
- @click="$onClick()"
8
- >
9
- <template
10
- v-for="(item, index) in spec.childViews"
11
- :key="index"
12
- >
13
- <glib-component :spec="item" />
14
- </template>
15
- </component> -->
16
2
  <component :is="componentName" :style="parentStyles" :class="parentClasses" :href="$href()" @click="$onClick()">
17
3
  <!-- <draggable :style="childStyles" :class="childClasses" ghost-class="ghost" -->
18
4
  <!-- :group="dragSupport ? dragSupport.groupId || 'common' : 'common'" :data-dragPanelId="spec.id"
19
5
  :disabled="!$type.isObject(spec.dragSupport)" @start="onDragStart" @end="onDragEnd"> -->
20
6
  <!-- Using `item.id` as key is important to make sure the item gets updated
21
7
  when dragging ends. -->
22
- <div :style="childStyles" :class="childClasses">
8
+ <!-- <div :style="childStyles" :class="childClasses">
23
9
  <template v-for="(item, index) in spec.childViews" :key="item.id || index">
24
10
  <glib-component :spec="item" />
25
11
  </template>
26
- </div>
12
+ </div> -->
27
13
  <!-- </draggable> -->
14
+
15
+
16
+ <!-- :disabled="!$type.isObject(dragSupport)" -->
17
+ <draggable
18
+ :style="childStyles"
19
+ :class="childClasses"
20
+ handle=".handle"
21
+ v-model="spec.childViews"
22
+ ghost-class="ghost"
23
+ :group="dragSupport ? dragSupport.groupId || 'common' : 'common'"
24
+ :data-dragPanelId="spec.id"
25
+ :disabled="!dragEnabled"
26
+ @start="onDragStart"
27
+ @end="onDragEnd"
28
+ item-key="id"
29
+ >
30
+ <!--
31
+ * Wrap `glib-component` with `div` to prevent errors when `glib-component` doesn't resolve to a
32
+ div (e.g. a button). See https://www.cnblogs.com/pphboy/p/17320226.html
33
+ * Use `data-dragItemId` instead of `id` because `id` is supposed to be unique and it might have
34
+ been taken by the wrapped component.
35
+ -->
36
+ <template #item="{element}">
37
+ <div :data-dragItemId="element.id">
38
+ <v-icon v-if="dragEnabled" class="handle">drag_handle</v-icon>
39
+ <!-- <v-icon v-if="dragEnabled" class="handle">drag_indicator</v-icon> -->
40
+ <!-- <v-icon class="handle">reorder</v-icon> -->
41
+ <glib-component :spec="element" />
42
+ </div>
43
+ </template>
44
+
45
+ <!-- <glib-component :spec="element" /> -->
46
+ <!-- <div :data-dragItemId="element.id">
47
+ <glib-component :spec="element" />
48
+ </div> -->
49
+ </draggable>
28
50
  </component>
29
51
  </template>
30
52
 
31
53
  <script>
32
- // import draggable from "vuedraggable";
54
+ import { vueApp } from "../../store";
55
+ import draggable from "vuedraggable";
33
56
 
34
57
  export default {
35
58
  components: {
36
- // draggable
59
+ draggable
37
60
  },
38
61
  props: {
39
62
  spec: { type: Object, required: true },
40
63
  },
41
64
  data: function () {
42
65
  return {
43
- dragSupport: null,
66
+ // dragSupport: null,
44
67
  // childViews: [],
45
68
  };
46
69
  },
47
70
  computed: {
71
+ dragEnabled() {
72
+ return this.$type.isObject(this.dragSupport)
73
+ },
74
+ dragSupport() {
75
+ return this.spec.dragSupport;
76
+ },
48
77
  parentClasses: function () {
49
78
  return this.$classes();
50
79
  },
@@ -103,10 +132,6 @@ export default {
103
132
  },
104
133
  },
105
134
  methods: {
106
- $ready() {
107
- this.dragSupport = this.spec.dragSupport;
108
- // this.childViews = this.spec.childViews || [];
109
- },
110
135
  $displayValue() {
111
136
  return "flex";
112
137
  },
@@ -124,7 +149,7 @@ export default {
124
149
  }
125
150
 
126
151
  // Ensure $ready() of its children gets called.
127
- this.$recursiveUpdate();
152
+ // this.$recursiveUpdate();
128
153
 
129
154
  const itemId = event.clone.dataset.dragitemid; // The item that got dragged/dropped
130
155
  const oldPanelId = event.from.dataset.dragpanelid;
@@ -151,6 +176,10 @@ export default {
151
176
  </script>
152
177
 
153
178
  <style lang="scss" scoped>
179
+ .handle {
180
+ cursor: move;
181
+ }
182
+
154
183
  .layouts-horizontal {
155
184
  display: flex;
156
185
  /* overflow: hidden; */
@@ -14,19 +14,31 @@
14
14
  :group="dragSupport ? dragSupport.groupId || 'common' : 'common'" :data-dragListId="spec.id"
15
15
  :data-dragSectionIndex="sectionIndex" :disabled="!$type.isObject(dragSupport)" @start="onDragStart"
16
16
  @end="onDragEnd"> -->
17
- <div v-for="(row, rowIndex) in section.rows" :key="`${sectionIndex}_${rowIndex}`"
18
- :ref="`row_${sectionIndex}_${rowIndex}`" :data-dragRowId="row.id">
19
- <!-- <v-divider v-if="!spec.responsiveCols && rowIndex == 0" /> -->
20
17
 
18
+ <draggable
19
+ v-model="section.rows"
20
+ ghost-class="ghost"
21
+ :group="dragSupport ? dragSupport.groupId || 'common' : 'common'"
22
+ :data-dragListId="spec.id"
23
+ :data-dragSectionIndex="sectionIndex"
24
+ :disabled="!$type.isObject(dragSupport)"
25
+ @start="onDragStart"
26
+ @end="onDragEnd"
27
+ item-key="id"
28
+ >
29
+ <template #item="{element}">
30
+ <component
31
+ :is="template(element)"
32
+ :spec="rowSpec(element)"
33
+ :responsive-cols="spec.responsiveCols"
34
+ :data-dragRowId="element.id" />
35
+ </template>
36
+ </draggable>
37
+
38
+ <!-- <div v-for="(row, rowIndex) in section.rows" :key="`${sectionIndex}_${rowIndex}`"
39
+ :ref="`row_${sectionIndex}_${rowIndex}`" :data-dragRowId="row.id">
21
40
  <component :is="template(row)" :spec="rowSpec(row)" :responsive-cols="spec.responsiveCols" :index="rowIndex" />
22
- <!-- <v-divider
23
- v-if="
24
- !spec.responsiveCols &&
25
- (rowIndex != section.rows.length - 1 ||
26
- sectionIndex != sections.length - 1)
27
- "
28
- /> -->
29
- </div>
41
+ </div> -->
30
42
  <!-- </draggable> -->
31
43
 
32
44
  <panels-responsive v-if="section.footer" :spec="section.footer" />
@@ -42,7 +54,8 @@
42
54
  </template>
43
55
 
44
56
  <script>
45
- // import draggable from "vuedraggable";
57
+ import { vueApp } from "../../store";
58
+ import draggable from "vuedraggable";
46
59
  import autoloadMixin from "../mixins/list/autoload.js";
47
60
  import ThumbnailTemplate from "../../templates/thumbnail.vue";
48
61
  import FeaturedTemplate from "../../templates/featured.vue";
@@ -51,7 +64,7 @@ import actionCableMixin from "../mixins/ws/actionCable.js";
51
64
 
52
65
  export default {
53
66
  components: {
54
- // draggable,
67
+ draggable,
55
68
  "template-thumbnail": ThumbnailTemplate,
56
69
  "template-featured": FeaturedTemplate,
57
70
  "template-commentOutgoing": CommentTemplate,
@@ -63,28 +76,45 @@ export default {
63
76
  },
64
77
  data: function () {
65
78
  return {
66
- // sections: [],
79
+ sections: [],
67
80
  dragSupport: null
68
81
  };
69
82
  },
70
- computed: {
71
- sections() {
72
- return this.spec.sections || [];
83
+ // computed: {
84
+ // sections() {
85
+ // return this.spec.sections || [];
86
+ // }
87
+ // },
88
+ watch: {
89
+ spec: {
90
+ handler(spec) {
91
+ this.sections = spec.sections || [];
92
+ this.dragSupport = spec.dragSupport;
93
+ this.autoloadAll(spec.nextPage);
94
+ this.enableInfiniteScrollIfApplicable(spec);
95
+ this.$wsSubscribeEvents(spec.phoenixSocket);
96
+ this.$wsInitActionCable(spec.actionCable);
97
+
98
+ for (const section of this.sections) {
99
+ section.rows = section.rows || [];
100
+ }
101
+ },
102
+ immediate: true
73
103
  }
74
104
  },
75
105
  methods: {
76
- $ready() {
77
- // this.sections = this.spec.sections || [];
78
- this.dragSupport = this.spec.dragSupport;
79
- this.autoloadAll(this.spec.nextPage);
80
- this.enableInfiniteScrollIfApplicable();
81
- this.$wsSubscribeEvents(this.spec.phoenixSocket);
82
- this.$wsInitActionCable(this.spec.actionCable);
106
+ // $ready() {
107
+ // // this.sections = this.spec.sections || [];
108
+ // this.dragSupport = this.spec.dragSupport;
109
+ // this.autoloadAll(this.spec.nextPage);
110
+ // this.enableInfiniteScrollIfApplicable();
111
+ // this.$wsSubscribeEvents(this.spec.phoenixSocket);
112
+ // this.$wsInitActionCable(this.spec.actionCable);
83
113
 
84
- for (const section of this.sections) {
85
- section.rows = section.rows || [];
86
- }
87
- },
114
+ // for (const section of this.sections) {
115
+ // section.rows = section.rows || [];
116
+ // }
117
+ // },
88
118
  rowSpec(row) {
89
119
  if (this.spec.fieldPrefix) {
90
120
  const prefix = `${this.spec.fieldPrefix}[${row.recordId}]`;
@@ -191,7 +221,7 @@ export default {
191
221
  }
192
222
 
193
223
  // Ensure $ready() of its children gets called.
194
- this.$recursiveUpdate();
224
+ // this.$recursiveUpdate();
195
225
 
196
226
  const targetSectionIndex = this.getSectionIndex(event.to);
197
227
 
@@ -1,19 +1,19 @@
1
1
  <template>
2
2
  <!-- Paddings cannot be applied to v-timeline directly -->
3
3
  <div :style="$styles()" :class="$classes()">
4
- <v-timeline v-if="events" :dense="true" align-top>
5
- <v-timeline-item v-for="(item, index) in events" :key="index" :color="item.backgroundColor || 'white'"
6
- :small="itemClasses(item).includes('small') || null" :large="itemClasses(item).includes('large')"
7
- :hide-dot="item.hide_dot" fill-dot>
4
+ <v-timeline v-if="events" :density="density" :truncate-line="spec.truncateLine" align-top>
5
+ <!-- <v-timeline-item v-for="(item, index) in events" :key="index" :color="item.backgroundColor || 'white'" -->
6
+ <v-timeline-item v-for="(item, index) in events" :key="index"
7
+ :density="density" :size="itemSize(item)" :dot-color="item.backgroundColor || 'transparent'"
8
+ :hide-dot="item.hideDot" :fill-dot="item.fillDot">
8
9
  <template v-slot:icon>
9
- <div :class="itemClasses(item).includes('outlined') ? 'outlined-dots' : ''
10
- ">
10
+ <div :class="itemClasses(item).includes('outlined') ? 'outlined-dots' : ''">
11
11
  <div v-if="item.text" class="number-circle" :style="{ color: item.color }">
12
12
  {{ item.text }}
13
13
  </div>
14
14
  <div v-else class="icon">
15
15
  <common-icon :spec="{
16
- material: { name: item.icon, size: iconSize(item) },
16
+ material: { name: item.icon },
17
17
  color: item.color
18
18
  }" />
19
19
  </div>
@@ -26,10 +26,17 @@
26
26
  </template>
27
27
 
28
28
  <script>
29
+ import { determineDensity, determineSize } from "../../utils/constant";
30
+
29
31
  export default {
30
32
  props: {
31
33
  spec: { type: Object, required: true }
32
34
  },
35
+ computed: {
36
+ density() {
37
+ return determineDensity(this.spec.styleClasses)
38
+ },
39
+ },
33
40
  data() {
34
41
  return {
35
42
  events: null,
@@ -41,6 +48,9 @@ export default {
41
48
  this.events = this.spec.events;
42
49
  this.childViews = this.spec.childViews;
43
50
  },
51
+ itemSize(itemSpec) {
52
+ return determineSize(itemSpec.styleClasses)
53
+ },
44
54
  iconSize(item) {
45
55
  return this.itemClasses(item).includes("small") ? 20 : 24;
46
56
  },
@@ -1,7 +1,21 @@
1
1
  <template>
2
- <common-responsive :style="floatingStyles" v-if="toggle" :spec="spec" />
2
+ <!-- Placement options:
3
+ | 'top'
4
+ | 'top-start'
5
+ | 'top-end'
6
+ | 'right'
7
+ | 'right-start'
8
+ | 'right-end'
9
+ | 'bottom'
10
+ | 'bottom-start'
11
+ | 'bottom-end'
12
+ | 'left'
13
+ | 'left-start'
14
+ | 'left-end'
15
+ -->
16
+ <common-responsive :style="floatingStyles" v-if="toggle" :spec="spec" />
3
17
  </template>
4
-
18
+
5
19
  <script>
6
20
  import bus from "../utils/eventBus";
7
21
 
@@ -34,6 +48,5 @@ export default {
34
48
  }
35
49
  };
36
50
  </script>
37
-
51
+
38
52
  <style scoped></style>
39
-
package/keys.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glib-web",
3
- "version": "3.0.8",
3
+ "version": "3.0.10",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -19,6 +19,7 @@
19
19
  "json-logic-js": "^2.0.0",
20
20
  "lodash.merge": "^4.6.2",
21
21
  "marked": "^4.0.0",
22
+ "moment": "^2.29.4",
22
23
  "phoenix": "^1.5.3",
23
24
  "push.js": "^1.0.12",
24
25
  "quill-image-drop-and-paste": "^1.2.14",
@@ -30,6 +31,7 @@
30
31
  "vue-social-sharing": "^4.0.0-alpha4",
31
32
  "vue2-gmap-custom-marker": "^6.1.1",
32
33
  "vue2-google-maps": "^0.10.6",
34
+ "vuedraggable": "^4.1.0",
33
35
  "vuetify": "^3.3.2"
34
36
  },
35
37
  "devDependencies": {
File without changes
package/styles/test.sass CHANGED
File without changes
package/styles/test.scss CHANGED
File without changes
File without changes
package/utils/dom.js CHANGED
File without changes
package/utils/storage.js CHANGED
File without changes
package/utils/url.js CHANGED
File without changes