Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
foxhound87 committed Sep 14, 2017
1 parent a613349 commit 616ce5e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default class Form extends Base {
}

@computed get hasError() {
return this.validator.error
return !!this.validator.error
|| this.check('hasError', true);
}

Expand Down
7 changes: 1 addition & 6 deletions src/shared/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,8 @@ export default {
delete obj[field.key]; // eslint-disable-line
if (removeValue) return obj;


const data = utils.hasUnifiedProps({ fields: [value] })
? value[prop]
: value;

return Object.assign(obj, {
[field.key]: parser.parseCheckArray(field, data, prop),
[field.key]: parser.parseCheckArray(field, value, prop),
});
}

Expand Down
11 changes: 11 additions & 0 deletions tests/data/forms/fixes/form.q.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ const fields = [
'incident[].type',
'incident[].value',
'incident[].options',
'arrayFieldA[]',
'arrayFieldA[].id',
'arrayFieldA[].name',
'arrayFieldB[]',
'arrayFieldB[].id',
'arrayFieldB[].name',
'arrayFieldB[].value',
];

class NewForm extends Form {
Expand All @@ -15,6 +22,10 @@ class NewForm extends Form {
onInit() {
// FIX: #282 (reserved keywords)
this.$('incident').add();

// TO FIX #324
this.update({ arrayFieldA: [{ id: 1, name: 'name' }] });
this.update({ arrayFieldB: [{ id: 1, name: 'name', value: 'some val' }] });
},
};
}
Expand Down
17 changes: 17 additions & 0 deletions tests/fixes.values.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,23 @@ describe('Check Fixes $P values', () => {
expect($.$P.$('address').labels()).to.be.deep.equal(labels));
});

describe('Check Fixes $Q values', () => {
const a = [{ id: 1, name: 'name' }];
const b = [{ id: 1, name: 'name', value: 'some val' }];

it('$Q arrayFieldA values() check', () =>
expect($.$Q.$('arrayFieldA').values()).to.be.deep.equal(a));

it('$Q arrayFieldB values() check', () =>
expect($.$Q.$('arrayFieldB').values()).to.be.deep.equal(b));

it('$Q arrayFieldA value check', () =>
expect($.$Q.$('arrayFieldA').value).to.be.deep.equal(a));

it('$Q arrayFieldB value check', () =>
expect($.$Q.$('arrayFieldB').value).to.be.deep.equal(b));
});

describe('Check Fixes $R values', () => {
const a = $.$R.values().organization;
const b = $.$R.$('organization').value;
Expand Down

0 comments on commit 616ce5e

Please sign in to comment.