Skip to content

Commit

Permalink
HBW-90 Add payload to widget's requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Smirnov committed Nov 15, 2018
1 parent e617df3 commit 29d90ae
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ v1.6.0 [unreleased]
- [#209](https://github.com/latera/homs/pull/209) Drop react-rails & react_ujs dependencies.
- [#205](https://github.com/latera/homs/pull/205) Use higher order component instead of HBWSelectMixin.
- [#214](https://github.com/latera/homs/pull/214) Update ruby version to 2.5.3.
- [#213](https://github.com/latera/homs/pull/213) Add payload to widget's requests.

### Bugfixes
- [#194](https://github.com/latera/homs/pull/194) Set limit on the number of choices in lookup select from sql requests.
Expand Down
13 changes: 11 additions & 2 deletions hbw/app/javascript/packs/hbw/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,17 @@ modulejs.define('HBWConnection', ['jQuery'], (jQuery) => {
this.channels = {};
}

request (...args) {
return jQuery.ajax(...args);
request (opts) {
let data;
const payload = this.options.payload || {};

if (typeof opts.data === 'string') {
data = JSON.stringify({ ...JSON.parse(opts.data), payload });
} else {
data = { ...opts.data, payload };
}

return jQuery.ajax({ ...opts, data });
}

createChannel (options) {
Expand Down
3 changes: 2 additions & 1 deletion hbw/app/javascript/packs/hbw/widget.js.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ modulejs.define(
this.options = options;
const connection = new Connection({
path: this.options.widgetPath,
host: this.options.widgetHost
host: this.options.widgetHost,
payload: this.options.payload
});

this.env = {
Expand Down

0 comments on commit 29d90ae

Please sign in to comment.