From db9a6f639a941b78c1ed9cfde6216ac1a6cb63b4 Mon Sep 17 00:00:00 2001 From: Riabov Andrei Date: Sat, 4 May 2019 15:16:31 +0500 Subject: [PATCH] add inject to controllers, change dummy --- app/initializers/storage-service.js | 1 + package-lock.json | 30 ++++++++++++++++++++-------- tests/dummy/app/controllers/index.js | 27 +++++++++++++++++++++++++ tests/dummy/app/styles/app.css | 11 +++++++++- tests/dummy/app/templates/index.hbs | 16 +++++++++++++++ 5 files changed, 76 insertions(+), 9 deletions(-) create mode 100644 tests/dummy/app/controllers/index.js diff --git a/app/initializers/storage-service.js b/app/initializers/storage-service.js index 731d4d7..e4727fe 100644 --- a/app/initializers/storage-service.js +++ b/app/initializers/storage-service.js @@ -2,6 +2,7 @@ export function initialize() { let application = arguments[1] || arguments[0]; application.inject('route', 'storage', 'service:storage'); application.inject('component', 'storage', 'service:storage'); + application.inject('controller', 'storage', 'service:storage'); } export default { diff --git a/package-lock.json b/package-lock.json index 8de69dd..87b0096 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ember-storage", - "version": "1.1.2", + "version": "2.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -4748,13 +4748,15 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -4771,19 +4773,22 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -4914,7 +4919,8 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -4928,6 +4934,7 @@ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -4944,6 +4951,7 @@ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -4952,13 +4960,15 @@ "version": "0.0.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.2.4.tgz", "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==", "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -4979,6 +4989,7 @@ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -5067,7 +5078,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -5081,6 +5093,7 @@ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -5218,6 +5231,7 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/tests/dummy/app/controllers/index.js b/tests/dummy/app/controllers/index.js new file mode 100644 index 0000000..fdacfca --- /dev/null +++ b/tests/dummy/app/controllers/index.js @@ -0,0 +1,27 @@ +import Controller from '@ember/controller'; +import { computed } from '@ember/object'; + +export default Controller.extend({ + storageValues: computed('storage.{name,email,message,mouseX,mouseY}', + function(){ + var obj = {}; + + if(this.get('storage.name') !== undefined){ + obj.name = this.get('storage.name'); + } + if(this.get('storage.email') !== undefined){ + obj.email = this.get('storage.email'); + } + if(this.get('storage.message') !== undefined){ + obj.message = this.get('storage.message'); + } + if(this.get('storage.mouseX') !== undefined){ + obj.mouseX = this.get('storage.mouseX'); + } + if(this.get('storage.mouseY') !== undefined){ + obj.mouseY = this.get('storage.mouseY'); + } + + return obj; + }), +}); diff --git a/tests/dummy/app/styles/app.css b/tests/dummy/app/styles/app.css index 8d0d2dd..4a66adf 100644 --- a/tests/dummy/app/styles/app.css +++ b/tests/dummy/app/styles/app.css @@ -12,7 +12,7 @@ input, textarea { margin: 20px; } textarea { - height: 200px; + height: 50px; } div { width: 100%; @@ -31,3 +31,12 @@ div { border-radius:50%; margin: -4px 0 0 -4px; } + +table { + border-collapse: collapse; +} + +table, th, td { + padding: 5px; + border: 1px solid grey; +} diff --git a/tests/dummy/app/templates/index.hbs b/tests/dummy/app/templates/index.hbs index 5513f45..ff4d101 100644 --- a/tests/dummy/app/templates/index.hbs +++ b/tests/dummy/app/templates/index.hbs @@ -4,6 +4,22 @@ around, and fill out the form. {{storage-demo}} +
+ Storage values + + + + + + {{#each-in storageValues as |key value|}} + + + + + {{/each-in}} +
keyvalue
{{key}}{{value}}
+
+

Download the code