Skip to content

Commit

Permalink
fix boolean edit (#2595)
Browse files Browse the repository at this point in the history
Co-authored-by: Robbie Wagner <[email protected]>
  • Loading branch information
patricklx and RobbieTheWagner authored Jul 30, 2024
1 parent e17d105 commit d8d9d53
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/components/object-inspector/property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default class ObjectInspectorProperty extends Component<ObjectInspectorPr

get cannotEdit() {
if (this.args.model.name === '...' || !this.isCalculated || this.readOnly) return true;
return this.args.model?.value?.type !== 'type-string' && this.args.model?.value?.type !== 'type-number';
return !['type-string', 'type-number', 'type-boolean'].includes(this.args.model?.value?.type);
}

@action
Expand Down
61 changes: 61 additions & 0 deletions tests/acceptance/object-inspector-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,67 @@ module('Object Inspector', function (hooks) {
assert.dom('[data-test-object-property-value]').hasText(date.toString());
});

test('Boolean fields are editable', async function (assert) {
assert.expect(4);

await visit('/');

await sendMessage({
type: 'objectInspector:updateObject',
name: 'My Object',
objectId: 'myObject',
details: [
{
name: 'First Detail',
expand: false,
properties: [
{
name: 'booleanProperty',
value: {
inspect: true.toString(),
type: 'type-boolean',
isCalculated: true,
},
},
],
},
],
});

respondWith(
'objectInspector:saveProperty',
({ objectId, property, value }) => {
assert.strictEqual(typeof value, 'boolean', 'sent as boolean');

return {
type: 'objectInspector:updateProperty',
objectId,
property,
mixinIndex: 0,
value: {
inspect: false.toString(),
type: 'type-boolean',
isCalculated: false,
},
};
}
);

await click('[data-test-object-detail-name]');

assert.dom('[data-test-object-property-value]').hasText(true.toString());

await click('[data-test-object-property-value]');

let field = find('[data-test-object-property-value-txt]');
assert.ok(field);

await fillIn(field, 'false');
await triggerKeyEvent(field, 'keyup', 13);

assert.dom('[data-test-object-property-value]').hasText(false.toString());
});

test('Errors are correctly displayed', async function (assert) {
assert.expect(8);

Expand Down

0 comments on commit d8d9d53

Please sign in to comment.