@fleetbase/ember-ui 0.3.17 → 0.3.19
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/addon/components/button.js +14 -1
- package/addon/components/dropdown-button.js +15 -2
- package/addon/components/filters-picker.js +11 -0
- package/addon/components/input-group.hbs +1 -1
- package/addon/components/layout/header/dropdown/item.js +1 -1
- package/addon/services/modals-manager.js +13 -1
- package/package.json +1 -1
|
@@ -12,6 +12,13 @@ export default class ButtonComponent extends Component {
|
|
|
12
12
|
*/
|
|
13
13
|
@service abilities;
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Inject events service for event tracking.
|
|
17
|
+
*
|
|
18
|
+
* @memberof ButtonComponent
|
|
19
|
+
*/
|
|
20
|
+
@service events;
|
|
21
|
+
|
|
15
22
|
/**
|
|
16
23
|
* Determines if the button should be disabled
|
|
17
24
|
*
|
|
@@ -111,12 +118,18 @@ export default class ButtonComponent extends Component {
|
|
|
111
118
|
* @void
|
|
112
119
|
*/
|
|
113
120
|
@action onClick() {
|
|
114
|
-
const { onClick } = this.args;
|
|
121
|
+
const { onClick, eventName, eventArgs } = this.args;
|
|
115
122
|
|
|
116
123
|
if (this.isDisabled) {
|
|
117
124
|
return;
|
|
118
125
|
}
|
|
119
126
|
|
|
127
|
+
// Trigger analytics event if eventName is provided
|
|
128
|
+
if (eventName && this.events) {
|
|
129
|
+
const args = eventArgs || [];
|
|
130
|
+
this.events.trackEvent(eventName, ...args);
|
|
131
|
+
}
|
|
132
|
+
|
|
120
133
|
if (typeof onClick === 'function') {
|
|
121
134
|
onClick(...arguments);
|
|
122
135
|
}
|
|
@@ -5,6 +5,7 @@ import { action } from '@ember/object';
|
|
|
5
5
|
|
|
6
6
|
export default class DropdownButtonComponent extends Component {
|
|
7
7
|
@service abilities;
|
|
8
|
+
@service events;
|
|
8
9
|
@tracked type = 'default';
|
|
9
10
|
@tracked buttonSize = 'md';
|
|
10
11
|
@tracked buttonComponentArgs = {};
|
|
@@ -37,9 +38,21 @@ export default class DropdownButtonComponent extends Component {
|
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
@action onRegisterAPI() {
|
|
41
|
+
@action onRegisterAPI(dropdown) {
|
|
42
|
+
// Trigger dropdown opened event when dropdown is opened
|
|
43
|
+
if (dropdown && this.events) {
|
|
44
|
+
const originalOpen = dropdown.actions.open;
|
|
45
|
+
dropdown.actions.open = (...args) => {
|
|
46
|
+
const { eventName, eventArgs } = this.args;
|
|
47
|
+
if (eventName) {
|
|
48
|
+
this.events.trackEvent(eventName, ...(eventArgs || []));
|
|
49
|
+
}
|
|
50
|
+
return originalOpen.call(dropdown.actions, ...args);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
41
54
|
if (typeof this.args.registerAPI === 'function') {
|
|
42
|
-
this.args.registerAPI(
|
|
55
|
+
this.args.registerAPI(dropdown);
|
|
43
56
|
}
|
|
44
57
|
}
|
|
45
58
|
|
|
@@ -7,6 +7,7 @@ import getUrlParam from '../utils/get-url-param';
|
|
|
7
7
|
|
|
8
8
|
export default class FiltersPickerComponent extends Component {
|
|
9
9
|
@service hostRouter;
|
|
10
|
+
@service events;
|
|
10
11
|
@tracked filters = [];
|
|
11
12
|
|
|
12
13
|
get activeFilters() {
|
|
@@ -69,6 +70,11 @@ export default class FiltersPickerComponent extends Component {
|
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
@action applyFilters() {
|
|
73
|
+
// Trigger filter applied event
|
|
74
|
+
if (this.events) {
|
|
75
|
+
this.events.trackEvent('ui.filter.applied', this.activeFilters);
|
|
76
|
+
}
|
|
77
|
+
|
|
72
78
|
if (typeof this.args.onApply === 'function') {
|
|
73
79
|
this.args.onApply();
|
|
74
80
|
}
|
|
@@ -87,6 +93,11 @@ export default class FiltersPickerComponent extends Component {
|
|
|
87
93
|
}
|
|
88
94
|
|
|
89
95
|
@action async clearFilters(...args) {
|
|
96
|
+
// Trigger filter cleared event
|
|
97
|
+
if (this.events) {
|
|
98
|
+
this.events.trackEvent('ui.filter.cleared');
|
|
99
|
+
}
|
|
100
|
+
|
|
90
101
|
if (typeof this.args.onClear === 'function') {
|
|
91
102
|
this.args.onClear(...args);
|
|
92
103
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<div class="input-group {{@wrapperClass}}">
|
|
2
2
|
{{#if (and @name (not @hideLabel))}}
|
|
3
|
-
<InputLabel for={{this.id}} @labelText={{@name}} @helpText={{@helpText}} @required={{@required}} @wrapperClass={{@labelWrapperClass}} />
|
|
3
|
+
<InputLabel for={{this.id}} @labelText={{@name}} @helpText={{@helpText}} @required={{@required}} @wrapperClass={{@labelWrapperClass}} class={{@labelClass}} />
|
|
4
4
|
{{/if}}
|
|
5
5
|
{{#if (has-block)}}
|
|
6
6
|
{{yield this.id @name}}
|
|
@@ -21,7 +21,7 @@ export default class LayoutHeaderDropdownItemComponent extends Component {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
@computed('args.item.{component,onClick}') get isComponent() {
|
|
24
|
-
if (this.args.item.component instanceof ExtensionComponent) return true;
|
|
24
|
+
if (this.args.item.component instanceof ExtensionComponent && typeof this.args.item.onClick !== 'function') return true;
|
|
25
25
|
|
|
26
26
|
return this.args.item && typeof this.args.item.component === 'string' && typeof this.args.item.onClick !== 'function';
|
|
27
27
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Service from '@ember/service';
|
|
1
|
+
import Service, { inject as service } from '@ember/service';
|
|
2
2
|
import { tracked } from '@glimmer/tracking';
|
|
3
3
|
import { action, set, get, getProperties, setProperties } from '@ember/object';
|
|
4
4
|
import { assert } from '@ember/debug';
|
|
@@ -9,6 +9,8 @@ import { guidFor } from '@ember/object/internals';
|
|
|
9
9
|
const { assign } = Object;
|
|
10
10
|
|
|
11
11
|
export default class ModalsManagerService extends Service {
|
|
12
|
+
@service events;
|
|
13
|
+
|
|
12
14
|
@tracked modals = [];
|
|
13
15
|
@tracked defaultOptions = {
|
|
14
16
|
title: null,
|
|
@@ -115,6 +117,11 @@ export default class ModalsManagerService extends Service {
|
|
|
115
117
|
// Add modal to the stack
|
|
116
118
|
this.modals = [...this.modals, modal];
|
|
117
119
|
|
|
120
|
+
// Trigger modal opened event
|
|
121
|
+
if (this.events) {
|
|
122
|
+
this.events.trackEvent('ui.modal.opened', component, opts);
|
|
123
|
+
}
|
|
124
|
+
|
|
118
125
|
return modalDefer.promise;
|
|
119
126
|
}
|
|
120
127
|
|
|
@@ -352,6 +359,11 @@ export default class ModalsManagerService extends Service {
|
|
|
352
359
|
// Remove modal from the stack
|
|
353
360
|
this.modals = this.modals.filter((m) => m.id !== modal.id);
|
|
354
361
|
|
|
362
|
+
// Trigger modal closed event
|
|
363
|
+
if (this.events) {
|
|
364
|
+
this.events.trackEvent('ui.modal.closed', modal.componentToRender, action, modal.options);
|
|
365
|
+
}
|
|
366
|
+
|
|
355
367
|
// Resolve the modal's promise
|
|
356
368
|
modal.defer?.resolve(this);
|
|
357
369
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fleetbase/ember-ui",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.19",
|
|
4
4
|
"description": "Fleetbase UI provides all the interface components, helpers, services and utilities for building a Fleetbase extension into the Console.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fleetbase-ui",
|