Skip to content

Commit

Permalink
HBW-159 Submit each form on it's own button
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Smirnov committed Sep 9, 2019
1 parent e449169 commit 32e4bc6
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ v1.7.4 [unreleased]
### Bugfixes
- [#315](https://github.com/latera/homs/pull/315) Add additional exceptions for Oracle's date formats.
- [#316](https://github.com/latera/homs/pull/316) Fix the way ajax request are made in lookup select.
- [#323](https://github.com/latera/homs/pull/323) Submit each form on it's own button.

v1.7.3 [2019-06-28]
-------------------
Expand Down
7 changes: 5 additions & 2 deletions hbw/app/javascript/packs/hbw/components/entity_task.js.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ modulejs.define(
loading: true,
pending: null,
form: null,
collapsed: this.props.collapsed || false
collapsed: this.props.collapsed || false,
id: this.props.getComponentId()
};

componentDidMount () {
this.loadForm(this.props.task.id);
this.props.bind('hbw:submit-form', this.submitForm);
this.props.bind(`hbw:submit-form-${this.state.id}`, this.submitForm);

const e = jQuery(this.rootNode);
e.on('hidden.bs.collapse', this.choose);
Expand Down Expand Up @@ -63,6 +64,8 @@ modulejs.define(
renderForm = () => {
if (this.state.form) {
const opts = {
id: this.state.id,
// form: { ...this.state.form, id: this.state.id },
form: this.state.form,
env: this.props.env,
error: this.state.error,
Expand Down
8 changes: 5 additions & 3 deletions hbw/app/javascript/packs/hbw/components/form.js.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ modulejs.define('HBWForm', ['React', 'jQuery', 'HBWError', 'HBWFormDatetime',
};

componentDidMount () {
console.log(this.props);
jQuery(':input:enabled:visible:first').focus();
this.props.bind('hbw:submit-form', () => this.setState({ submitting: true }));
this.props.bind(`hbw:submit-form-${this.props.id}`, () => this.setState({ submitting: true }));
this.props.bind('hbw:form-submitting-failed', () => this.setState({ submitting: false }));
this.props.bind('hbw:file-upload-started', () => this.setState({ fileUploading: true }));
this.props.bind('hbw:file-upload-finished', () => this.setState({ fileUploading: false }));
Expand All @@ -43,6 +44,7 @@ modulejs.define('HBWForm', ['React', 'jQuery', 'HBWError', 'HBWFormDatetime',
const opts = {
name,
params,
id: this.props.id,
value: this.props.variables[name],
formSubmitting: this.state.submitting || this.state.fileUploading,
env: this.props.env,
Expand Down Expand Up @@ -128,10 +130,10 @@ modulejs.define('HBWForm', ['React', 'jQuery', 'HBWError', 'HBWFormDatetime',
return null;
}

this.props.trigger('hbw:validate-form');
this.props.trigger(`hbw:validate-form-${this.props.id}`);

if (this.isFormValid()) {
return this.props.trigger('hbw:submit-form', this.serializeForm());
return this.props.trigger(`hbw:submit-form-${this.props.id}`, this.serializeForm());
}

return null;
Expand Down
1 change: 1 addition & 0 deletions hbw/app/javascript/packs/hbw/components/form/group.js.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ modulejs.define('HBWFormGroup', ['React', 'HBWFormDatetime',
const opts = {
name,
params,
id: this.props.id,
value: this.props.variables[name],
formSubmitting: this.props.formSubmitting,
env: this.props.env
Expand Down
2 changes: 1 addition & 1 deletion hbw/app/javascript/packs/hbw/components/form/select.js.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ modulejs.define('HBWFormSelect',
}

validateOnSubmit = () => {
this.props.bind('hbw:validate-form', this.onFormSubmit);
this.props.bind(`hbw:validate-form-${this.props.id}`, this.onFormSubmit);
};

onFormSubmit = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ modulejs.define('HBWFormSelectTable',
}

validateOnSubmit = () => {
this.props.bind('hbw:validate-form', this.onFormSubmit);
this.props.bind(`hbw:validate-form-${this.props.id}`, this.onFormSubmit);
};

onFormSubmit = () => {
Expand Down
2 changes: 1 addition & 1 deletion hbw/app/javascript/packs/hbw/components/form/string.js.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ modulejs.define('HBWFormString', ['React'], (React) => {
}

validateOnSubmit = () => {
this.props.bind('hbw:validate-form', this.onFormSubmit);
this.props.bind(`hbw:validate-form-${this.props.id}`, this.onFormSubmit);
};

hijackFormatter = () => {
Expand Down

0 comments on commit 32e4bc6

Please sign in to comment.