@miso.ai/client-sdk-ui 1.11.0-beta.4 → 1.11.0-beta.5

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.
@@ -161,10 +161,10 @@ class FacetsLayout extends _template.default {
161
161
  }
162
162
  _render(element, data, controls) {
163
163
  super._render(element, data, controls);
164
- this._syncSelections();
165
164
  }
166
165
  _afterRender(element, state) {
167
166
  this._syncBindings(element, state);
167
+ this._syncSelections();
168
168
  }
169
169
  _unrender() {
170
170
  this._clearBindings();
@@ -270,6 +270,10 @@ class FacetsLayout extends _template.default {
270
270
  return Array.from(element.querySelectorAll(`[data-role="option"]`));
271
271
  }
272
272
  _handleClick(event) {
273
+ // only left click
274
+ if (event.button !== 0) {
275
+ return;
276
+ }
273
277
  const element = event.target.closest(`[data-role="option"]`);
274
278
  if (!element) {
275
279
  return;
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = exports.default = '1.11.0-beta.4';
7
+ var _default = exports.default = '1.11.0-beta.5';
@@ -10,7 +10,8 @@ var _index = require("../actor/index.js");
10
10
  var _constants = require("../constants.js");
11
11
  var _options = require("./options.js");
12
12
  var _processors = require("./processors.js");
13
- const _excluded = ["filters"];
13
+ const _excluded = ["filters"],
14
+ _excluded2 = ["filters"];
14
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
16
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
16
17
  const ROLES_CONFIG = Object.freeze({
@@ -49,8 +50,7 @@ class HybridSearchResults extends _base.default {
49
50
  // get stored query from sibling
50
51
  const query = this._superworkflow._answer._hub.states[_index.fields.query()];
51
52
  const payload = this._buildPayload(Object.assign({}, query, {
52
- filters,
53
- answer: false
53
+ filters
54
54
  }));
55
55
  const {
56
56
  session
@@ -69,11 +69,32 @@ class HybridSearchResults extends _base.default {
69
69
  payload = _objectWithoutPropertiesLoose(_ref, _excluded);
70
70
  // borrow the work from the sibling
71
71
  payload = this._superworkflow._answer._buildPayload(payload);
72
+ payload = this._writeFqToPayload(Object.assign({}, payload, {
73
+ filters
74
+ }));
75
+ payload = this._writeQuestionIdToPayload(payload);
76
+ return Object.assign({}, payload, {
77
+ answer: false
78
+ });
79
+ }
80
+ _writeFqToPayload() {
81
+ let _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
82
+ let {
83
+ filters
84
+ } = _ref2,
85
+ payload = _objectWithoutPropertiesLoose(_ref2, _excluded2);
72
86
  const fq = (0, _processors.composeFq)(filters); // TODO: combine with fq in payload?
73
87
  return (0, _commons.trimObj)(Object.assign({}, payload, {
74
88
  fq
75
89
  }));
76
90
  }
91
+ _writeQuestionIdToPayload(payload) {
92
+ return Object.assign({}, payload, {
93
+ _meta: (0, _commons.trimObj)(Object.assign({}, payload._meta, {
94
+ question_id: this._superworkflow._answer.questionId
95
+ }))
96
+ });
97
+ }
77
98
  _request(event) {
78
99
  this._hub.update(_index.fields.request(), event);
79
100
  }
@@ -106,7 +106,8 @@ function composeFq(filters) {
106
106
  if (!values || !values.length) {
107
107
  continue; // just in case
108
108
  }
109
- clauses.push(`${field}:(${values.map(v => `"${v}"`).join(' OR ')})`);
109
+ const vstr = values.length === 1 ? `"${values[0]}"` : `(${values.map(v => `"${v}"`).join(' OR ')})`;
110
+ clauses.push(`${field}:${vstr}`);
110
111
  }
111
- return clauses.map(c => `(${c})`).join(' AND ');
112
+ return clauses.map(c => `(${c})`).join(' AND ') || undefined;
112
113
  }
package/package.json CHANGED
@@ -26,7 +26,7 @@
26
26
  "url": "https://github.com/MisoAI/miso-client-js-sdk/issues"
27
27
  },
28
28
  "dependencies": {
29
- "@miso.ai/commons": "1.11.0-beta.4"
29
+ "@miso.ai/commons": "1.11.0-beta.5"
30
30
  },
31
- "version": "1.11.0-beta.4"
31
+ "version": "1.11.0-beta.5"
32
32
  }
@@ -125,11 +125,11 @@ export default class FacetsLayout extends TemplateBasedLayout {
125
125
 
126
126
  _render(element, data, controls) {
127
127
  super._render(element, data, controls);
128
- this._syncSelections();
129
128
  }
130
129
 
131
130
  _afterRender(element, state) {
132
131
  this._syncBindings(element, state);
132
+ this._syncSelections();
133
133
  }
134
134
 
135
135
  _unrender() {
@@ -220,6 +220,10 @@ export default class FacetsLayout extends TemplateBasedLayout {
220
220
  }
221
221
 
222
222
  _handleClick(event) {
223
+ // only left click
224
+ if (event.button !== 0) {
225
+ return;
226
+ }
223
227
  const element = event.target.closest(`[data-role="option"]`);
224
228
  if (!element) {
225
229
  return;
package/src/version.js CHANGED
@@ -1 +1 @@
1
- export default '1.11.0-beta.4';
1
+ export default '1.11.0-beta.5';
@@ -48,7 +48,7 @@ export default class HybridSearchResults extends Workflow {
48
48
 
49
49
  // get stored query from sibling
50
50
  const query = this._superworkflow._answer._hub.states[fields.query()];
51
- const payload = this._buildPayload({ ...query, filters, answer: false });
51
+ const payload = this._buildPayload({ ...query, filters });
52
52
  const { session } = this;
53
53
  const event = mergeApiOptions(this._options.resolved.api, { payload, session });
54
54
 
@@ -58,6 +58,12 @@ export default class HybridSearchResults extends Workflow {
58
58
  _buildPayload({ filters, ...payload } = {}) {
59
59
  // borrow the work from the sibling
60
60
  payload = this._superworkflow._answer._buildPayload(payload);
61
+ payload = this._writeFqToPayload({ ...payload, filters });
62
+ payload = this._writeQuestionIdToPayload(payload);
63
+ return { ...payload, answer: false };
64
+ }
65
+
66
+ _writeFqToPayload({ filters, ...payload } = {}) {
61
67
  const fq = composeFq(filters); // TODO: combine with fq in payload?
62
68
  return trimObj({
63
69
  ...payload,
@@ -65,6 +71,16 @@ export default class HybridSearchResults extends Workflow {
65
71
  });
66
72
  }
67
73
 
74
+ _writeQuestionIdToPayload(payload) {
75
+ return {
76
+ ...payload,
77
+ _meta: trimObj({
78
+ ...payload._meta,
79
+ question_id: this._superworkflow._answer.questionId,
80
+ }),
81
+ };
82
+ }
83
+
68
84
  _request(event) {
69
85
  this._hub.update(fields.request(), event);
70
86
  }
@@ -84,7 +84,8 @@ export function composeFq(filters) {
84
84
  if (!values || !values.length) {
85
85
  continue; // just in case
86
86
  }
87
- clauses.push(`${field}:(${values.map(v => `"${v}"`).join(' OR ')})`);
87
+ const vstr = values.length === 1 ? `"${values[0]}"` : `(${values.map(v => `"${v}"`).join(' OR ')})`;
88
+ clauses.push(`${field}:${vstr}`);
88
89
  }
89
- return clauses.map(c => `(${c})`).join(' AND ');
90
+ return clauses.map(c => `(${c})`).join(' AND ') || undefined;
90
91
  }