Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBW-90 Add payload to widget's requests #213

Merged
merged 1 commit into from
Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
10 changes: 8 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,14 @@ modulejs.define('HBWConnection', ['jQuery'], (jQuery) => {
this.channels = {};
}

request (...args) {
return jQuery.ajax(...args);
request (opts) {
return jQuery.ajax({
...opts,
data: {
...opts.data,
payload: this.options.payload || {}
}
});
}

createChannel (options) {
Expand Down
5 changes: 2 additions & 3 deletions hbw/app/javascript/packs/hbw/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@ modulejs.define('HBWForms', ['jQuery'], (jQuery) => {
return this.connection.request({
url: this.formURL(params.taskId),
method: 'PUT',
contentType: 'application/json',
data: JSON.stringify({
data: {
form_data: params.variables,
entity_class: this.entityClass
}),
},
headers: {
'X-CSRF-Token': params.token
}
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