diff --git a/app/helpers/stringify.js b/app/helpers/stringify.js new file mode 100644 index 0000000..854f0c0 --- /dev/null +++ b/app/helpers/stringify.js @@ -0,0 +1,5 @@ +import { helper } from '@ember/component/helper'; + +export default helper(function stringify([value] /*, named*/) { + return JSON.stringify(value, null, 1); +}); diff --git a/app/helpers/type-of.js b/app/helpers/type-of.js new file mode 100644 index 0000000..91c9de2 --- /dev/null +++ b/app/helpers/type-of.js @@ -0,0 +1,5 @@ +import { helper } from '@ember/component/helper'; + +export default helper(function typeOf([value]) { + return typeof value; +}); diff --git a/app/templates/admin/indexes/item/data.hbs b/app/templates/admin/indexes/item/data.hbs index 4f598a2..fb635a0 100644 --- a/app/templates/admin/indexes/item/data.hbs +++ b/app/templates/admin/indexes/item/data.hbs @@ -25,7 +25,9 @@ {{#each-in item as |key value|}}
{{key}}
-
{{value}}
+
+ {{if (eq (type-of value) "object") (stringify value) value}} +
{{/each-in}} diff --git a/tests/integration/helpers/stringify-test.js b/tests/integration/helpers/stringify-test.js new file mode 100644 index 0000000..ba4dd77 --- /dev/null +++ b/tests/integration/helpers/stringify-test.js @@ -0,0 +1,17 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Helper | stringify', function (hooks) { + setupRenderingTest(hooks); + + // TODO: Replace this with your real tests. + test('it renders', async function (assert) { + this.set('inputValue', '1234'); + + await render(hbs`{{stringify this.inputValue}}`); + + assert.dom(this.element).hasText('1234'); + }); +}); diff --git a/tests/integration/helpers/type-of-test.js b/tests/integration/helpers/type-of-test.js new file mode 100644 index 0000000..f3bb0c7 --- /dev/null +++ b/tests/integration/helpers/type-of-test.js @@ -0,0 +1,17 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Helper | type-of', function (hooks) { + setupRenderingTest(hooks); + + // TODO: Replace this with your real tests. + test('it renders', async function (assert) { + this.set('inputValue', '1234'); + + await render(hbs`{{type-of this.inputValue}}`); + + assert.dom(this.element).hasText('1234'); + }); +});