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

fix boolean edit #2595

Merged
merged 10 commits into from
Jul 30, 2024
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
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
Loading