glib-web 0.6.0 → 0.6.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.
Files changed (57) hide show
  1. package/action.js +7 -4
  2. package/actions/analytics/logEvent.js +1 -1
  3. package/actions/auth/creditCard.js +4 -4
  4. package/actions/auth/saveCsrfToken.js +4 -4
  5. package/actions/cables/push.js +0 -12
  6. package/actions/commands/copy.js +12 -0
  7. package/actions/dialogs/alert.js +2 -2
  8. package/actions/dialogs/close.js +2 -4
  9. package/actions/dialogs/notification.js +2 -2
  10. package/actions/dialogs/open.js +2 -4
  11. package/actions/dialogs/show.js +3 -2
  12. package/actions/forms/submit.js +2 -12
  13. package/actions/http/delete.js +1 -1
  14. package/actions/http/patch.js +1 -1
  15. package/actions/http/post.js +1 -1
  16. package/actions/http/put.js +1 -1
  17. package/actions/runMultiple.js +2 -2
  18. package/actions/timeouts/set.js +2 -2
  19. package/actions/windows/close.js +2 -2
  20. package/actions/windows/closeAll.js +2 -2
  21. package/actions/windows/closeWithReload.js +1 -1
  22. package/actions/windows/open.js +1 -1
  23. package/actions/windows/reload.js +1 -1
  24. package/actions/ws/push.js +1 -1
  25. package/app.vue +5 -3
  26. package/components/button.vue +10 -10
  27. package/components/calendar.vue +1 -1
  28. package/components/chip.vue +38 -13
  29. package/components/component.vue +4 -0
  30. package/components/fields/check.vue +20 -10
  31. package/components/fields/creditCard.vue +22 -13
  32. package/components/fields/googlePlace.vue +80 -52
  33. package/components/fields/radioGroup.vue +1 -0
  34. package/components/mixins/chart/tooltip.js +5 -2
  35. package/components/mixins/dataset.js +10 -0
  36. package/components/mixins/events.js +4 -5
  37. package/components/mixins/generic.js +6 -0
  38. package/components/mixins/list/autoload.js +2 -3
  39. package/components/mixins/table/autoload.js +2 -2
  40. package/components/mixins/tooltip.js +11 -0
  41. package/components/mixins/tour.js +75 -0
  42. package/components/mixins/ws/actionCable.js +1 -1
  43. package/components/multimedia/video.vue +87 -0
  44. package/components/panels/form.vue +13 -3
  45. package/components/panels/list.vue +1 -1
  46. package/components/switch.vue +2 -2
  47. package/index.js +3 -0
  48. package/nav/appbar.vue +1 -1
  49. package/nav/dialog.vue +2 -2
  50. package/nav/sheet.vue +1 -2
  51. package/nav/snackbar.vue +1 -2
  52. package/package.json +3 -2
  53. package/utils/form.js +1 -5
  54. package/utils/http.js +2 -2
  55. package/utils/launch.js +25 -18
  56. package/utils/private/ws.js +1 -1
  57. package/utils/uploader.js +4 -22
package/action.js CHANGED
@@ -45,6 +45,8 @@ import ActionsCreditCard from "./actions/auth/creditCard";
45
45
 
46
46
  import ActionsAnalyticsLogEvent from "./actions/analytics/logEvent";
47
47
 
48
+ import ActionCommandsCopy from "./actions/commands/copy";
49
+
48
50
  const actions = {
49
51
  runMultiple: ActionsRunMultiple,
50
52
 
@@ -89,11 +91,12 @@ const actions = {
89
91
  "auth/restart": ActionsAuthRestart,
90
92
  "auth/creditCard": ActionsCreditCard,
91
93
 
92
- "analytics/logEvent": ActionsAnalyticsLogEvent
94
+ "analytics/logEvent": ActionsAnalyticsLogEvent,
95
+ "commands/copy": ActionCommandsCopy
93
96
  };
94
97
 
95
98
  export default class Action {
96
- static execute(spec, target, component, params = {}) {
99
+ static execute(spec, component, params = {}) {
97
100
  if (!TypeUtils.isObject(spec)) {
98
101
  return;
99
102
  }
@@ -141,7 +144,7 @@ export default class Action {
141
144
  if (!logDisabled) {
142
145
  console.log(`Executing "${actionName}"`);
143
146
  }
144
- action.execute(spec, null, component, params);
147
+ action.execute(spec, component, params);
145
148
  } catch (e) {
146
149
  console.log(
147
150
  "Failed executing command",
@@ -159,7 +162,7 @@ export default class Action {
159
162
  }
160
163
 
161
164
  window.vueApp.temp.analytics = response.analytics;
162
- GLib.action.execute(response.onResponse, null, component);
165
+ GLib.action.execute(response.onResponse, component);
163
166
  window.vueApp.temp.analytics = null;
164
167
  }
165
168
  }
@@ -3,7 +3,7 @@ export default class {
3
3
  return true;
4
4
  }
5
5
 
6
- execute(properties, target, component) {
6
+ execute(properties, component) {
7
7
  if (Utils.settings.isDev) {
8
8
  return;
9
9
  }
@@ -9,9 +9,9 @@ export default class {
9
9
  Utils.http.stopIndicator(component);
10
10
 
11
11
  if (result.error) {
12
- GLib.action.execute(properties.onFailure, {}, component);
12
+ GLib.action.execute(properties.onFailure, component);
13
13
  } else {
14
- GLib.action.execute(properties.onSuccess, {}, component);
14
+ GLib.action.execute(properties.onSuccess, component);
15
15
  }
16
16
  });
17
17
  } else {
@@ -19,9 +19,9 @@ export default class {
19
19
  Utils.http.stopIndicator(component);
20
20
 
21
21
  if (result.error) {
22
- GLib.action.execute(properties.onFailure, {}, component);
22
+ GLib.action.execute(properties.onFailure, component);
23
23
  } else {
24
- GLib.action.execute(properties.onSuccess, {}, component);
24
+ GLib.action.execute(properties.onSuccess, component);
25
25
  }
26
26
  });
27
27
  }
@@ -2,11 +2,11 @@
2
2
  // import Keys from '../../keys'
3
3
 
4
4
  export default class {
5
- execute(properties, target, component) {
5
+ execute(properties, component) {
6
6
  // console.log(properties['token'])
7
7
  // Storage.setLocal(Keys.Db.csrfToken, properties['token'])
8
-
9
- Utils.dom.setCsrf(properties['token'])
10
- Action.execute(properties['onSave'], target, component)
8
+
9
+ Utils.dom.setCsrf(properties["token"]);
10
+ Action.execute(properties["onSave"], component);
11
11
  }
12
12
  }
@@ -1,17 +1,5 @@
1
1
  export default class {
2
2
  execute(properties) {
3
- // const spec = Object.assign({}, properties, {
4
- // buttons: [
5
- // {
6
- // text: "OK",
7
- // onClick: properties.onClose
8
- // }
9
- // ]
10
- // });
11
- // Launch.dialog(spec);
12
-
13
- // const ws = window.vueApp.actionCable;
14
-
15
3
  Utils.type.ifString(properties.channel, channelName => {
16
4
  const ws = window.vueApp.actionCable;
17
5
  const channel = ws.channels[channelName];
@@ -0,0 +1,12 @@
1
+ export default class {
2
+ execute(properties) {
3
+ let spec = Object.assign({}, properties, {
4
+ message: "Copied",
5
+ styleClasses: ["success"]
6
+ });
7
+ navigator.clipboard.writeText(properties.text).then(
8
+ () => Utils.launch.snackbar.open(spec),
9
+ reason => console.error("Could not copy text: " + reason)
10
+ );
11
+ }
12
+ }
@@ -1,7 +1,7 @@
1
1
  import Launch from "../../utils/launch";
2
2
 
3
3
  export default class {
4
- execute(properties) {
4
+ execute(properties, component) {
5
5
  const spec = Object.assign({}, properties, {
6
6
  buttons: [
7
7
  {
@@ -10,6 +10,6 @@ export default class {
10
10
  }
11
11
  ]
12
12
  });
13
- Launch.dialog(spec);
13
+ Utils.launch.dialog.open(spec, component);
14
14
  }
15
15
  }
@@ -1,7 +1,5 @@
1
- import Launch from '../../utils/launch'
2
-
3
1
  export default class {
4
- execute(properties, target, component) {
5
- Launch.closeDialog(properties, target, component)
2
+ execute(spec, component) {
3
+ Utils.launch.dialog.close(spec, component);
6
4
  }
7
5
  }
@@ -1,12 +1,12 @@
1
1
  import Push from "push.js";
2
2
 
3
3
  export default class {
4
- execute(properties, target, component) {
4
+ execute(properties, component) {
5
5
  Push.create(properties.title, {
6
6
  body: properties.message,
7
7
  onClick() {
8
8
  const onClick = properties.onClick;
9
- GLib.action.execute(onClick, null, component);
9
+ GLib.action.execute(onClick, component);
10
10
  this.close();
11
11
  }
12
12
  });
@@ -1,7 +1,5 @@
1
- import Launch from "../../utils/launch";
2
-
3
1
  export default class {
4
- execute(properties) {
5
- Launch.dialog(properties);
2
+ execute(spec, component) {
3
+ Utils.launch.dialog.open(spec, component);
6
4
  }
7
5
  }
@@ -1,5 +1,6 @@
1
1
  export default class {
2
- execute(properties) {
3
- Utils.launch.dialog(properties);
2
+ execute(spec, component) {
3
+ console.log("P1", spec);
4
+ Utils.launch.dialog.open(spec, component);
4
5
  }
5
6
  }
@@ -1,15 +1,5 @@
1
1
  export default class {
2
- execute(properties, target, component) {
3
- const form = component.$closest("panels-form");
4
- if (form != null) {
5
- form.submit();
6
- }
7
-
8
- // const vm = this;
9
- // // Allows time for things to get finalized. For example, select.vue needs time to insert values
10
- // // into hidden fields before they get submitted.
11
- // setTimeout(() => {
12
- // vm.submit(target, component);
13
- // }, 10);
2
+ execute(properties, component) {
3
+ component.$dispatchEvent("forms/directSubmit");
14
4
  }
15
5
  }
@@ -1,5 +1,5 @@
1
1
  export default class {
2
- execute(properties, target, controller) {
2
+ execute(properties, controller) {
3
3
  GLib.http.execute(properties, "DELETE", controller, response =>
4
4
  GLib.action.handleResponse(response, controller)
5
5
  );
@@ -1,5 +1,5 @@
1
1
  export default class {
2
- execute(properties, target, controller) {
2
+ execute(properties, controller) {
3
3
  GLib.http.execute(properties, "PATCH", controller, response =>
4
4
  GLib.action.handleResponse(response, controller)
5
5
  );
@@ -1,5 +1,5 @@
1
1
  export default class {
2
- execute(properties, target, controller) {
2
+ execute(properties, controller) {
3
3
  GLib.http.execute(properties, "POST", controller, response =>
4
4
  GLib.action.handleResponse(response, controller)
5
5
  );
@@ -1,5 +1,5 @@
1
1
  export default class {
2
- execute(properties, target, controller) {
2
+ execute(properties, controller) {
3
3
  GLib.http.execute(properties, "PUT", controller, response =>
4
4
  GLib.action.handleResponse(response, controller)
5
5
  );
@@ -3,9 +3,9 @@ export default class {
3
3
  return true;
4
4
  }
5
5
 
6
- execute(properties, target, component) {
6
+ execute(properties, component) {
7
7
  for (const action of properties.childActions) {
8
- GLib.action.execute(action, null, component);
8
+ GLib.action.execute(action, component);
9
9
  }
10
10
  }
11
11
  }
@@ -1,5 +1,5 @@
1
1
  export default class {
2
- execute(properties, target, component) {
2
+ execute(properties, component) {
3
3
  component.$data._isBusy = true;
4
4
 
5
5
  if (properties.repeat) {
@@ -15,6 +15,6 @@ export default class {
15
15
 
16
16
  onTimeout(properties, component) {
17
17
  component.$data._isBusy = false;
18
- GLib.action.execute(properties.onTimeout, null, component);
18
+ GLib.action.execute(properties.onTimeout, component);
19
19
  }
20
20
  }
@@ -1,12 +1,12 @@
1
1
  export default class {
2
- execute(properties, target, component) {
2
+ execute(properties, component) {
3
3
  Utils.history.back();
4
4
 
5
5
  Utils.type.ifObject(properties["onClose"], it => {
6
6
  // Allow time for history.back() to complete, which is important for actions that need
7
7
  // to use window.location.href such as windows/reload
8
8
  setTimeout(function() {
9
- GLib.action.execute(it, null, component);
9
+ GLib.action.execute(it, component);
10
10
  }, 100);
11
11
  });
12
12
  }
@@ -1,7 +1,7 @@
1
1
  import Type from "../../utils/type";
2
2
 
3
3
  export default class {
4
- execute(properties, target, component) {
4
+ execute(properties, component) {
5
5
  // TODO
6
6
  // window.history.deleteAll()
7
7
 
@@ -9,7 +9,7 @@ export default class {
9
9
  // Allow time for history.back() to complete, which is important for actions that need
10
10
  // to use window.location.href such as windows/reload
11
11
  setTimeout(function() {
12
- GLib.action.execute(it, null, component);
12
+ GLib.action.execute(it, component);
13
13
  }, 100);
14
14
  });
15
15
  }
@@ -1,7 +1,7 @@
1
1
  import Hash from "../../utils/hash";
2
2
 
3
3
  export default class {
4
- execute(properties, target, component) {
4
+ execute(properties, component) {
5
5
  const fallbackUrl = new Hash(properties).remove("fallbackUrl");
6
6
  const data = Object.assign({}, properties);
7
7
  if (!Utils.history.back()) {
@@ -1,5 +1,5 @@
1
1
  export default class {
2
- execute(properties, target, component) {
2
+ execute(properties, component) {
3
3
  Utils.http.load(properties, null, component);
4
4
  }
5
5
  }
@@ -1,5 +1,5 @@
1
1
  export default class {
2
- execute(properties, target, component) {
2
+ execute(properties, component) {
3
3
  if (Utils.settings.reactive) {
4
4
  // const currentUrl = window.location.href;
5
5
  // const data = {
@@ -1,5 +1,5 @@
1
1
  export default class {
2
- execute(properties, target, component, params) {
2
+ execute(properties, component, params) {
3
3
  Utils.type.ifString(properties.topic, topicName => {
4
4
  const ws = window.vueApp.webSocket;
5
5
  const channel = ws.channels[topicName];
package/app.vue CHANGED
@@ -42,13 +42,14 @@ import Utils from "./utils/helper";
42
42
  import ContentLayout from "./nav/content";
43
43
  import phoenixSocketMixin from "./components/mixins/ws/phoenixSocket.js";
44
44
  import actionCableMixin from "./components/mixins/ws/actionCable.js";
45
+ import tourMixin from "./components/mixins/tour";
45
46
 
46
47
  export default {
47
48
  components: {
48
49
  "nav-appbar": NavAppBar,
49
50
  "layouts-content": ContentLayout
50
51
  },
51
- mixins: [phoenixSocketMixin, actionCableMixin],
52
+ mixins: [phoenixSocketMixin, actionCableMixin, tourMixin],
52
53
  props: {
53
54
  page: { type: Object, required: true }
54
55
  },
@@ -103,12 +104,13 @@ export default {
103
104
  if (Utils.history.isPoppedState(this.page)) {
104
105
  setTimeout(() => {
105
106
  // Wait until page is rendered
106
- GLib.action.execute(this.page.onRefocus, null, this);
107
+ GLib.action.execute(this.page.onRefocus, this);
107
108
  });
108
109
  } else {
109
110
  setTimeout(() => {
110
111
  // Wait until page is rendered
111
- GLib.action.execute(this.page.onLoad, null, this);
112
+ GLib.action.execute(this.page.onLoad, this);
113
+ this.startTour();
112
114
  });
113
115
  }
114
116
  }
@@ -2,10 +2,10 @@
2
2
  <div>
3
3
  <v-tooltip
4
4
  v-if="spec.tooltip"
5
- :top="tooltipClasses('top')"
6
- :right="tooltipClasses('right')"
7
- :bottom="tooltipClasses('bottom')"
8
- :left="tooltipClasses('left')"
5
+ :top="tooltipPositionMatches('top')"
6
+ :right="tooltipPositionMatches('right')"
7
+ :bottom="tooltipPositionMatches('bottom')"
8
+ :left="tooltipPositionMatches('left')"
9
9
  >
10
10
  <template v-slot:activator="{ on }">
11
11
  <div v-on="on">
@@ -21,17 +21,17 @@
21
21
  </template>
22
22
 
23
23
  <script>
24
+ import tooltipMixin from "./mixins/tooltip";
25
+ import tourMixin from "./mixins/tour";
26
+
24
27
  export default {
28
+ mixins: [tooltipMixin, tourMixin],
25
29
  props: {
26
30
  spec: { type: Object, required: true }
27
31
  },
28
32
  methods: {
29
- tooltipClasses(position) {
30
- if (this.spec.tooltip.position) {
31
- return position == this.spec.tooltip.position;
32
- } else {
33
- return position == "bottom";
34
- }
33
+ $ready() {
34
+ this.registerTour();
35
35
  }
36
36
  }
37
37
  };
@@ -98,7 +98,7 @@ export default {
98
98
  });
99
99
  },
100
100
  showEvent({ event, target }) {
101
- Action.execute(event.onClick, target, this);
101
+ Action.execute(event.onClick, this);
102
102
  }
103
103
  }
104
104
  };
@@ -1,24 +1,49 @@
1
1
  <template>
2
- <v-chip
3
- v-if="spec.onClick"
4
- :style="genericStyles()"
5
- :class="$classes()"
6
- :href="$href()"
7
- @click="$onClick()"
2
+ <v-tooltip
3
+ :disabled="!spec.tooltip"
4
+ :top="tooltipPositionMatches('top')"
5
+ :right="tooltipPositionMatches('right')"
6
+ :bottom="tooltipPositionMatches('bottom')"
7
+ :left="tooltipPositionMatches('left')"
8
8
  >
9
- {{ spec.text }}
10
- <common-badge :spec="spec" />
11
- </v-chip>
12
- <v-chip v-else :style="genericStyles()" :class="$classes()">
13
- {{ spec.text }}
14
- <common-badge :spec="spec" />
15
- </v-chip>
9
+ <template v-slot:activator="{ on }">
10
+ <div v-on="on">
11
+ <v-chip
12
+ v-if="spec.onClick"
13
+ :style="genericStyles()"
14
+ :class="$classes()"
15
+ :href="$href()"
16
+ @click="$onClick()"
17
+ >
18
+ {{ spec.text }}
19
+ <common-badge :spec="spec" />
20
+ </v-chip>
21
+ <v-chip v-else :style="genericStyles()" :class="$classes()">
22
+ {{ spec.text }}
23
+ <common-badge :spec="spec" />
24
+ </v-chip>
25
+ </div>
26
+ </template>
27
+ <span>{{ tooltip.text }}</span>
28
+ </v-tooltip>
16
29
  </template>
17
30
 
18
31
  <script>
32
+ import TooltipMixins from "./mixins/tooltip";
19
33
  export default {
34
+ mixins: [TooltipMixins],
20
35
  props: {
21
36
  spec: { type: Object, required: true }
37
+ },
38
+ data: function() {
39
+ return {
40
+ tooltip: {}
41
+ };
42
+ },
43
+ methods: {
44
+ $ready() {
45
+ this.tooltip = this.spec.tooltip || {};
46
+ }
22
47
  }
23
48
  };
24
49
  </script>
@@ -105,6 +105,8 @@ import ResponsivePanel from "./panels/responsive";
105
105
  import UlPanel from "./panels/ul";
106
106
  import WebPanel from "./panels/web";
107
107
 
108
+ import MultimediaVideo from "./multimedia/video";
109
+
108
110
  import AlertBanner from "./banners/alert";
109
111
  import SelectBanner from "./banners/select";
110
112
 
@@ -185,6 +187,8 @@ export default {
185
187
  "panels-ul": UlPanel,
186
188
  "panels-web": WebPanel,
187
189
 
190
+ "multimedia-video": MultimediaVideo,
191
+
188
192
  "banners-alert": AlertBanner,
189
193
  "banners-select": SelectBanner,
190
194
 
@@ -1,6 +1,9 @@
1
1
  <template>
2
2
  <div :class="$classes()" :style="$styles()">
3
- <fields-hidden v-if="uncheckSpec" :spec="uncheckSpec" />
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" />
4
7
  <v-checkbox
5
8
  v-model="fieldModel"
6
9
  :name="fieldName"
@@ -15,20 +18,20 @@
15
18
  </template>
16
19
 
17
20
  <script>
18
- import HiddenField from "./hidden";
21
+ // import HiddenField from "./hidden";
19
22
 
20
23
  export default {
21
- components: {
22
- "fields-hidden": HiddenField
23
- },
24
+ // components: {
25
+ // "fields-hidden": HiddenField
26
+ // },
24
27
  props: {
25
28
  spec: { type: Object, required: true }
26
29
  },
27
30
  data() {
28
31
  return {
29
32
  groupName: null,
30
- fieldType: null,
31
- uncheckSpec: null
33
+ fieldType: null
34
+ // uncheckSpec: null
32
35
  };
33
36
  },
34
37
  methods: {
@@ -42,6 +45,7 @@ export default {
42
45
  );
43
46
 
44
47
  this.fieldName = this.spec.name || groupName;
48
+
45
49
  this.fieldModel = this.spec.checked
46
50
  ? this.spec.checkValue
47
51
  : this.spec.value;
@@ -52,9 +56,9 @@ export default {
52
56
  }
53
57
  });
54
58
 
55
- Utils.type.ifNotNull(this.spec.uncheckValue, value => {
56
- this.uncheckSpec = { name: this.spec.name, value: value };
57
- });
59
+ // Utils.type.ifNotNull(this.spec.uncheckValue, value => {
60
+ // this.uncheckSpec = { name: this.spec.name, value: value };
61
+ // });
58
62
  },
59
63
  changed(event) {
60
64
  // Execute later to ensure the checkbox's checked state has been updated.
@@ -69,6 +73,12 @@ export default {
69
73
  this.$dispatchEvent("forms/submit");
70
74
  }, 200);
71
75
  }
76
+ },
77
+ $internalizeValue(val) {
78
+ if (val == this.spec.checkValue) {
79
+ return val;
80
+ }
81
+ return this.spec.uncheckValue;
72
82
  }
73
83
  }
74
84
  };
@@ -1,18 +1,20 @@
1
1
  <template>
2
2
  <div :style="genericStyles()" :class="$classes()">
3
- <StripeIndividualFields
4
- v-if="$classes().includes('individual')"
5
- :spec="spec"
6
- :on-complete="_retrieveToken"
7
- :on-error="_displayError"
8
- />
9
- <StripeFields
10
- v-else
11
- :spec="spec"
12
- :on-complete="_retrieveToken"
13
- :on-error="_displayError"
14
- />
15
- <div ref="error" style="color: red;"></div>
3
+ <div class="stretcher">
4
+ <StripeIndividualFields
5
+ v-if="$classes().includes('individual')"
6
+ :spec="spec"
7
+ :on-complete="_retrieveToken"
8
+ :on-error="_displayError"
9
+ />
10
+ <StripeFields
11
+ v-else
12
+ :spec="spec"
13
+ :on-complete="_retrieveToken"
14
+ :on-error="_displayError"
15
+ />
16
+ <div ref="error" style="color: red;"></div>
17
+ </div>
16
18
  <!-- <input ref="token" type="hidden" :name="spec.name" /> -->
17
19
 
18
20
  <input
@@ -103,3 +105,10 @@ export default {
103
105
  }
104
106
  };
105
107
  </script>
108
+
109
+ <style lang="scss" scoped>
110
+ // Without this, this view will have minimal width when displayed using showIf.
111
+ .stretcher {
112
+ width: 100%;
113
+ }
114
+ </style>