@telia-ace/knowledge-widget-plugins 1.0.2 → 1.0.8

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.txt CHANGED
@@ -1,6 +1,6 @@
1
- Copyright © 2021, Telia Company AB. All rights reserved.
2
-
3
- THIS PACKAGE AND CONTAINING SOFTWARE IS PART OF
4
- THE HUMANY SERVICE. BY USING THIS SOFTWARE YOU
5
- AGREE TO THE FOLLOWING TERMS AND CONDITIONS:
1
+ Copyright © 2021, Telia Company AB. All rights reserved.
2
+
3
+ THIS PACKAGE AND CONTAINING SOFTWARE IS PART OF
4
+ THE HUMANY SERVICE. BY USING THIS SOFTWARE YOU
5
+ AGREE TO THE FOLLOWING TERMS AND CONDITIONS:
6
6
  http://www.humany.com/legal
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
- # `@telia-ace/knowledge-widget-plugins`
2
-
3
- Plugins for ACE Widgets.
1
+ # `@telia-ace/knowledge-widget-plugins`
2
+
3
+ Plugins for ACE Knowledge Widgets.
@@ -44,67 +44,83 @@ var STORAGE_KEY = 'misc-behavior:hideBackValue';
44
44
  * is only a single contact method in the contact-list.
45
45
  */
46
46
  exports.default = (function (container, settings) { return __awaiter(void 0, void 0, void 0, function () {
47
- var hideBackOnSingleContactMethod, mainWidget, widget, name, implementation, hideBackValue_1, storedHideBackValue, componentPlatform, widgetHeaders, dataClient, result, _a, categories, _b, contactMethods;
48
- return __generator(this, function (_c) {
49
- switch (_c.label) {
50
- case 0:
51
- hideBackOnSingleContactMethod = settings.hideBackOnSingleContactMethod;
52
- widget = container.get('$widget');
53
- name = widget.name, implementation = widget.implementation;
54
- if (name.endsWith('_contact')) {
55
- mainWidget = implementation.widgets.get(name.replace('_contact', ''));
56
- }
57
- else if (!name.endsWith('_contact-method')) {
58
- mainWidget = widget;
59
- }
60
- if (!mainWidget) return [3 /*break*/, 7];
61
- hideBackValue_1 = null;
62
- return [4 /*yield*/, (0, widget_services_1.readStorage)(mainWidget.container, STORAGE_KEY)];
63
- case 1:
64
- storedHideBackValue = _c.sent();
65
- return [4 /*yield*/, mainWidget.container.getAsync('components')];
66
- case 2:
67
- componentPlatform = _c.sent();
68
- widgetHeaders = componentPlatform.components().ofType('widget-header').select();
69
- if (!(typeof storedHideBackValue === 'boolean')) return [3 /*break*/, 3];
70
- hideBackValue_1 = storedHideBackValue;
71
- return [3 /*break*/, 6];
72
- case 3:
73
- if (!hideBackOnSingleContactMethod) return [3 /*break*/, 6];
74
- return [4 /*yield*/, container.getAsync('dataClient')];
75
- case 4:
76
- dataClient = _c.sent();
77
- return [4 /*yield*/, (dataClient === null || dataClient === void 0 ? void 0 : dataClient.fetch(knowledge_widget_types_grid_1.DataType.ContactMethodCategories, {}))];
78
- case 5:
79
- result = (_c.sent()) ||
80
- Promise.resolve();
81
- if (result) {
82
- _a = result.categories, categories = _a === void 0 ? [] : _a, _b = result.contactMethods, contactMethods = _b === void 0 ? [] : _b;
83
- if (hideBackValue_1 === null) {
84
- hideBackValue_1 = categories.length === 0 && contactMethods.length === 1;
85
- (0, widget_services_1.createStorageWriter)(mainWidget.container, STORAGE_KEY, widget_services_1.StorageCategory.Necessary).then(function (write) { return write(hideBackValue_1); });
86
- }
87
- }
88
- _c.label = 6;
89
- case 6:
90
- /* if hideBackOnSingleContactMethod == true
91
- * or if we have a hideBackValue (from session storage)
92
- * hide back if hideBackValue == true
93
- * and add show-back action watcher
94
- */
95
- if (hideBackOnSingleContactMethod || typeof hideBackValue_1 === 'boolean') {
96
- if (hideBackValue_1) {
97
- widgetHeaders.actions.dispatch('show-back', false);
47
+ var writeToStorage, events;
48
+ return __generator(this, function (_a) {
49
+ writeToStorage = function (mainWidget, hideBackValue) {
50
+ return container.getAsync('dataClient').then(function (dataClient) {
51
+ return dataClient
52
+ .fetch(knowledge_widget_types_grid_1.DataType.ContactMethodCategories, {})
53
+ .then(function (result) {
54
+ if (result) {
55
+ var _a = result.categories, categories = _a === void 0 ? [] : _a, _b = result.contactMethods, contactMethods = _b === void 0 ? [] : _b;
56
+ if (hideBackValue === null) {
57
+ hideBackValue = categories.length === 0 && contactMethods.length === 1;
58
+ return (0, widget_services_1.createStorageWriter)(mainWidget.container, STORAGE_KEY, widget_services_1.StorageCategory.Functional).then(function (write) { return write(hideBackValue); });
59
+ }
98
60
  }
99
- widgetHeaders.actions.watch('show-back', function (data, next) {
100
- if (hideBackValue_1 && data) {
101
- return next(false);
61
+ });
62
+ });
63
+ };
64
+ events = container.get('$widget').events;
65
+ events.subscribe('widget:render-state-changed', function (event, data) { return __awaiter(void 0, void 0, void 0, function () {
66
+ var hideBackOnSingleContactMethod, mainWidget, widget, name_1, implementation, hideBackValue_1, storedHideBackValue, componentPlatform, widgetHeaders;
67
+ return __generator(this, function (_a) {
68
+ switch (_a.label) {
69
+ case 0:
70
+ if (!(event.target.state === 'activated' && data.next === 'open')) return [3 /*break*/, 6];
71
+ hideBackOnSingleContactMethod = settings.hideBackOnSingleContactMethod;
72
+ mainWidget = void 0;
73
+ widget = container.get('$widget');
74
+ name_1 = widget.name, implementation = widget.implementation;
75
+ if (name_1.endsWith('_contact')) {
76
+ mainWidget = implementation.widgets.get(name_1.replace('_contact', ''));
77
+ }
78
+ else if (!name_1.endsWith('_contact-method')) {
79
+ mainWidget = widget;
80
+ }
81
+ if (!mainWidget) return [3 /*break*/, 6];
82
+ hideBackValue_1 = null;
83
+ return [4 /*yield*/, (0, widget_services_1.readStorage)(mainWidget.container, STORAGE_KEY)];
84
+ case 1:
85
+ storedHideBackValue = _a.sent();
86
+ return [4 /*yield*/, mainWidget.container.getAsync('components')];
87
+ case 2:
88
+ componentPlatform = _a.sent();
89
+ widgetHeaders = componentPlatform
90
+ .components()
91
+ .ofType('widget-header')
92
+ .select();
93
+ if (!(typeof storedHideBackValue === 'boolean')) return [3 /*break*/, 3];
94
+ hideBackValue_1 = storedHideBackValue;
95
+ return [3 /*break*/, 5];
96
+ case 3:
97
+ if (!hideBackOnSingleContactMethod) return [3 /*break*/, 5];
98
+ return [4 /*yield*/, writeToStorage(mainWidget, hideBackValue_1)];
99
+ case 4:
100
+ _a.sent();
101
+ _a.label = 5;
102
+ case 5:
103
+ /* if hideBackOnSingleContactMethod == true
104
+ * or if we have a hideBackValue (from session storage)
105
+ * hide back if hideBackValue == true
106
+ * and add show-back action watcher
107
+ */
108
+ if (hideBackOnSingleContactMethod || typeof hideBackValue_1 === 'boolean') {
109
+ if (hideBackValue_1) {
110
+ widgetHeaders.actions.dispatch('show-back', false);
111
+ }
112
+ widgetHeaders.actions.watch('show-back', function (data, next) {
113
+ if (hideBackValue_1 && data) {
114
+ return next(false);
115
+ }
116
+ return next(data);
117
+ });
102
118
  }
103
- return next(data);
104
- });
119
+ _a.label = 6;
120
+ case 6: return [2 /*return*/];
105
121
  }
106
- _c.label = 7;
107
- case 7: return [2 /*return*/, []];
108
- }
122
+ });
123
+ }); });
124
+ return [2 /*return*/, []];
109
125
  });
110
126
  }); });
@@ -42,67 +42,83 @@ var STORAGE_KEY = 'misc-behavior:hideBackValue';
42
42
  * is only a single contact method in the contact-list.
43
43
  */
44
44
  export default (function (container, settings) { return __awaiter(void 0, void 0, void 0, function () {
45
- var hideBackOnSingleContactMethod, mainWidget, widget, name, implementation, hideBackValue_1, storedHideBackValue, componentPlatform, widgetHeaders, dataClient, result, _a, categories, _b, contactMethods;
46
- return __generator(this, function (_c) {
47
- switch (_c.label) {
48
- case 0:
49
- hideBackOnSingleContactMethod = settings.hideBackOnSingleContactMethod;
50
- widget = container.get('$widget');
51
- name = widget.name, implementation = widget.implementation;
52
- if (name.endsWith('_contact')) {
53
- mainWidget = implementation.widgets.get(name.replace('_contact', ''));
54
- }
55
- else if (!name.endsWith('_contact-method')) {
56
- mainWidget = widget;
57
- }
58
- if (!mainWidget) return [3 /*break*/, 7];
59
- hideBackValue_1 = null;
60
- return [4 /*yield*/, readStorage(mainWidget.container, STORAGE_KEY)];
61
- case 1:
62
- storedHideBackValue = _c.sent();
63
- return [4 /*yield*/, mainWidget.container.getAsync('components')];
64
- case 2:
65
- componentPlatform = _c.sent();
66
- widgetHeaders = componentPlatform.components().ofType('widget-header').select();
67
- if (!(typeof storedHideBackValue === 'boolean')) return [3 /*break*/, 3];
68
- hideBackValue_1 = storedHideBackValue;
69
- return [3 /*break*/, 6];
70
- case 3:
71
- if (!hideBackOnSingleContactMethod) return [3 /*break*/, 6];
72
- return [4 /*yield*/, container.getAsync('dataClient')];
73
- case 4:
74
- dataClient = _c.sent();
75
- return [4 /*yield*/, (dataClient === null || dataClient === void 0 ? void 0 : dataClient.fetch(DataType.ContactMethodCategories, {}))];
76
- case 5:
77
- result = (_c.sent()) ||
78
- Promise.resolve();
79
- if (result) {
80
- _a = result.categories, categories = _a === void 0 ? [] : _a, _b = result.contactMethods, contactMethods = _b === void 0 ? [] : _b;
81
- if (hideBackValue_1 === null) {
82
- hideBackValue_1 = categories.length === 0 && contactMethods.length === 1;
83
- createStorageWriter(mainWidget.container, STORAGE_KEY, StorageCategory.Necessary).then(function (write) { return write(hideBackValue_1); });
84
- }
85
- }
86
- _c.label = 6;
87
- case 6:
88
- /* if hideBackOnSingleContactMethod == true
89
- * or if we have a hideBackValue (from session storage)
90
- * hide back if hideBackValue == true
91
- * and add show-back action watcher
92
- */
93
- if (hideBackOnSingleContactMethod || typeof hideBackValue_1 === 'boolean') {
94
- if (hideBackValue_1) {
95
- widgetHeaders.actions.dispatch('show-back', false);
45
+ var writeToStorage, events;
46
+ return __generator(this, function (_a) {
47
+ writeToStorage = function (mainWidget, hideBackValue) {
48
+ return container.getAsync('dataClient').then(function (dataClient) {
49
+ return dataClient
50
+ .fetch(DataType.ContactMethodCategories, {})
51
+ .then(function (result) {
52
+ if (result) {
53
+ var _a = result.categories, categories = _a === void 0 ? [] : _a, _b = result.contactMethods, contactMethods = _b === void 0 ? [] : _b;
54
+ if (hideBackValue === null) {
55
+ hideBackValue = categories.length === 0 && contactMethods.length === 1;
56
+ return createStorageWriter(mainWidget.container, STORAGE_KEY, StorageCategory.Functional).then(function (write) { return write(hideBackValue); });
57
+ }
96
58
  }
97
- widgetHeaders.actions.watch('show-back', function (data, next) {
98
- if (hideBackValue_1 && data) {
99
- return next(false);
59
+ });
60
+ });
61
+ };
62
+ events = container.get('$widget').events;
63
+ events.subscribe('widget:render-state-changed', function (event, data) { return __awaiter(void 0, void 0, void 0, function () {
64
+ var hideBackOnSingleContactMethod, mainWidget, widget, name_1, implementation, hideBackValue_1, storedHideBackValue, componentPlatform, widgetHeaders;
65
+ return __generator(this, function (_a) {
66
+ switch (_a.label) {
67
+ case 0:
68
+ if (!(event.target.state === 'activated' && data.next === 'open')) return [3 /*break*/, 6];
69
+ hideBackOnSingleContactMethod = settings.hideBackOnSingleContactMethod;
70
+ mainWidget = void 0;
71
+ widget = container.get('$widget');
72
+ name_1 = widget.name, implementation = widget.implementation;
73
+ if (name_1.endsWith('_contact')) {
74
+ mainWidget = implementation.widgets.get(name_1.replace('_contact', ''));
75
+ }
76
+ else if (!name_1.endsWith('_contact-method')) {
77
+ mainWidget = widget;
78
+ }
79
+ if (!mainWidget) return [3 /*break*/, 6];
80
+ hideBackValue_1 = null;
81
+ return [4 /*yield*/, readStorage(mainWidget.container, STORAGE_KEY)];
82
+ case 1:
83
+ storedHideBackValue = _a.sent();
84
+ return [4 /*yield*/, mainWidget.container.getAsync('components')];
85
+ case 2:
86
+ componentPlatform = _a.sent();
87
+ widgetHeaders = componentPlatform
88
+ .components()
89
+ .ofType('widget-header')
90
+ .select();
91
+ if (!(typeof storedHideBackValue === 'boolean')) return [3 /*break*/, 3];
92
+ hideBackValue_1 = storedHideBackValue;
93
+ return [3 /*break*/, 5];
94
+ case 3:
95
+ if (!hideBackOnSingleContactMethod) return [3 /*break*/, 5];
96
+ return [4 /*yield*/, writeToStorage(mainWidget, hideBackValue_1)];
97
+ case 4:
98
+ _a.sent();
99
+ _a.label = 5;
100
+ case 5:
101
+ /* if hideBackOnSingleContactMethod == true
102
+ * or if we have a hideBackValue (from session storage)
103
+ * hide back if hideBackValue == true
104
+ * and add show-back action watcher
105
+ */
106
+ if (hideBackOnSingleContactMethod || typeof hideBackValue_1 === 'boolean') {
107
+ if (hideBackValue_1) {
108
+ widgetHeaders.actions.dispatch('show-back', false);
109
+ }
110
+ widgetHeaders.actions.watch('show-back', function (data, next) {
111
+ if (hideBackValue_1 && data) {
112
+ return next(false);
113
+ }
114
+ return next(data);
115
+ });
100
116
  }
101
- return next(data);
102
- });
117
+ _a.label = 6;
118
+ case 6: return [2 /*return*/];
103
119
  }
104
- _c.label = 7;
105
- case 7: return [2 /*return*/, []];
106
- }
120
+ });
121
+ }); });
122
+ return [2 /*return*/, []];
107
123
  });
108
124
  }); });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/knowledge-widget-plugins",
3
- "version": "1.0.2",
3
+ "version": "1.0.8",
4
4
  "description": "Plugins for ACE Knowledge Widgets.",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "Telia Company AB",
@@ -26,14 +26,14 @@
26
26
  "typings": "lib/index.d.ts",
27
27
  "dependencies": {
28
28
  "@telia-ace/knowledge-resource-loader": "^1.0.0",
29
- "@telia-ace/knowledge-widget-adapters": "^1.0.2",
30
- "@telia-ace/knowledge-widget-core": "^1.0.2",
31
- "@telia-ace/knowledge-widget-types-grid": "^1.0.2",
32
- "@telia-ace/knowledge-widget-ui": "^1.0.2",
33
- "@telia-ace/widget-routing": "^1.0.1",
34
- "@telia-ace/widget-services": "^1.0.1",
29
+ "@telia-ace/knowledge-widget-adapters": "^1.0.7",
30
+ "@telia-ace/knowledge-widget-core": "^1.0.6",
31
+ "@telia-ace/knowledge-widget-types-grid": "^1.0.7",
32
+ "@telia-ace/knowledge-widget-ui": "^1.0.7",
33
+ "@telia-ace/widget-routing": "^1.0.5",
34
+ "@telia-ace/widget-services": "^1.0.4",
35
35
  "@telia-ace/widget-utilities": "^1.0.1",
36
36
  "@webprovisions/platform": "^1.1.2"
37
37
  },
38
- "gitHead": "59cfcdac000ddd1cbdeb27bb994eb103563660a1"
38
+ "gitHead": "f926c4ce9547bb480c1c83dd7269387456e0e985"
39
39
  }