Last active
July 21, 2020 14:49
-
-
Save betocantu93/4f843b83e321ea7829b1a5bc82096552 to your computer and use it in GitHub Desktop.
Revisions
-
betocantu93 revised this gist
Jul 21, 2020 . 1 changed file with 1 addition and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,11 +7,7 @@ export default Route.extend({ model() { console.log(this.store) this.store.push({ }) } }); -
betocantu93 revised this gist
Jul 21, 2020 . 1 changed file with 1 addition and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,14 +10,7 @@ export default Route.extend({ data: { id: "ref:document:1", type: "ref:document", } }) } -
betocantu93 revised this gist
Jul 21, 2020 . No changes.There are no files selected for viewing
-
betocantu93 revised this gist
Jul 21, 2020 . 2 changed files with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,8 +8,8 @@ export default Route.extend({ console.log(this.store) this.store.push({ data: { id: "ref:document:1", type: "ref:document", attributes: { prop1: { a: 5, This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,12 +30,13 @@ let computeValue = function (key, value, modelName, schemaInterface) { attributes: value, }); } return value; }; export default class Schema extends DefaultSchema { includesModel(modelName) { console.log(modelName) return RefRegExp.test(modelName); } -
betocantu93 revised this gist
Jul 21, 2020 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ export { default } from 'ember-m3/services/store'; -
betocantu93 revised this gist
Jul 21, 2020 . 1 changed file with 52 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ import DefaultSchema from "ember-m3/services/m3-schema"; const RefRegExp = /^ref:/; const EDMRegExp = /^EDM:/; let computeValue = function (key, value, modelName, schemaInterface) { if (Array.isArray(value)) { return null; } if (typeof value === "string" && RefRegExp.test(value)) { return schemaInterface.reference({ id: value, type: null, }); } if (typeof value === "string" && EDMRegExp.test(value)) { let [_, modelName, id] = value.split(':'); return schemaInterface.reference({ id, type: modelName, }); } if (value !== null && typeof value === "object") { return schemaInterface.nested({ id: key, type: value.type, attributes: value, }); } return value; }; export default class Schema extends DefaultSchema { includesModel(modelName) { return RefRegExp.test(modelName); } computeAttribute(key, value, modelName, schemaInterface) { if (Array.isArray(value)) { let nested = value.map((v) => { return computeValue(key, v, modelName, schemaInterface); }); return schemaInterface.managedArray(nested); } else { return computeValue(key, value, modelName, schemaInterface); } } } -
betocantu93 created this gist
Jul 21, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ import Controller from '@ember/controller'; export default class ApplicationController extends Controller { appName = 'Ember Twiddle'; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ import Route from '@ember/routing/route'; import { inject as service } from '@ember/service'; export default Route.extend({ model() { console.log(this.store) this.store.push({ data: { id: "1", type: "ref:some", attributes: { prop1: { a: 5, b: [1, 2, 3] }, prop2: 10, prop3: ["10"] } } }) } }); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ <h1>Welcome to {{this.appName}}</h1> <br> <br> {{outlet}} <br> <br> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ { "version": "0.17.1", "EmberENV": { "FEATURES": {}, "_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false, "_APPLICATION_TEMPLATE_WRAPPER": true, "_JQUERY_INTEGRATION": true }, "options": { "use_pods": false, "enable-testing": false }, "dependencies": { "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js", "ember": "3.16.7", "ember-template-compiler": "3.16.7", "ember-testing": "3.16.7" }, "addons": { "@glimmer/component": "1.0.0", "ember-data": "3.18.0", "ember-m3": "3.0.0" } }