Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jamesdixon/58e68f49e02a2e0d8daf748daf41e315 to your computer and use it in GitHub Desktop.
Save jamesdixon/58e68f49e02a2e0d8daf748daf41e315 to your computer and use it in GitHub Desktop.

Revisions

  1. jamesdixon revised this gist Mar 31, 2017. 2 changed files with 2 additions and 18 deletions.
    18 changes: 1 addition & 17 deletions templates.application.hbs
    Original file line number Diff line number Diff line change
    @@ -9,21 +9,5 @@ Currencies Dropdown
    options=currencies
    optionLabelPath="name"
    includeBlank=true
    promptText="Select a currency"
    update=(action (mut model.currency2))
    }}

    <h2>Unexpected behaviour</h2>

    Selected Currency:
    {{model.currency.name}}
    <br>
    Currencies Dropdown
    {{one-way-select
    model.currency
    options=currencies
    optionLabelPath="name"
    includeBlank=true
    promptText="Select a currency"
    update=(action (mut model.currency))
    }}
    }}
    2 changes: 1 addition & 1 deletion twiddle.json
    Original file line number Diff line number Diff line change
    @@ -15,6 +15,6 @@
    "ember-testing": "2.8.0"
    },
    "addons": {
    "ember-one-way-controls": "1.1.1"
    "ember-one-way-controls": "2.0.0"
    }
    }
  2. @mvuckovic mvuckovic revised this gist Oct 14, 2016. 1 changed file with 0 additions and 7 deletions.
    7 changes: 0 additions & 7 deletions templates.application.hbs
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,3 @@
    <h1>Welcome to {{appName}}</h1>
    <br>
    <br>
    {{outlet}}
    <br>
    <br>

    <h2>Expected behaviour</h2>

    Selected Currency:
  3. @mvuckovic mvuckovic created this gist Oct 14, 2016.
    5 changes: 5 additions & 0 deletions controllers.application.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    import Ember from 'ember';

    export default Ember.Controller.extend({
    appName: 'Ember Twiddle'
    });
    7 changes: 7 additions & 0 deletions models.currency.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    import Model from "ember-data/model";
    import attr from "ember-data/attr";
    import { belongsTo, hasMany } from "ember-data/relationships";

    export default Model.extend({
    name: attr("string")
    });
    9 changes: 9 additions & 0 deletions models.product.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    import Model from "ember-data/model";
    import attr from "ember-data/attr";
    import { belongsTo, hasMany } from "ember-data/relationships";

    export default Model.extend({
    name: attr("name"),
    currency: belongsTo(),
    currency2: attr()
    });
    15 changes: 15 additions & 0 deletions routes.application.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    import Ember from 'ember';

    export default Ember.Route.extend({
    model() {
    this.store.createRecord('currency', { id: 1, name: "USD" });
    this.store.createRecord('currency', { id: 2, name: "EUR" });
    this.store.createRecord('currency', { id: 3, name: "YEN" });

    return this.store.createRecord('product');
    },
    setupController(controller, model) {
    controller.set('model', model);
    controller.set('currencies', this.store.peekAll('currency'));
    }
    });
    36 changes: 36 additions & 0 deletions templates.application.hbs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    <h1>Welcome to {{appName}}</h1>
    <br>
    <br>
    {{outlet}}
    <br>
    <br>

    <h2>Expected behaviour</h2>

    Selected Currency:
    {{model.currency2.name}}
    <br>
    Currencies Dropdown
    {{one-way-select
    model.currency2
    options=currencies
    optionLabelPath="name"
    includeBlank=true
    promptText="Select a currency"
    update=(action (mut model.currency2))
    }}

    <h2>Unexpected behaviour</h2>

    Selected Currency:
    {{model.currency.name}}
    <br>
    Currencies Dropdown
    {{one-way-select
    model.currency
    options=currencies
    optionLabelPath="name"
    includeBlank=true
    promptText="Select a currency"
    update=(action (mut model.currency))
    }}
    20 changes: 20 additions & 0 deletions twiddle.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    {
    "version": "0.10.5",
    "EmberENV": {
    "FEATURES": {}
    },
    "options": {
    "use_pods": false,
    "enable-testing": false
    },
    "dependencies": {
    "jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
    "ember": "2.8.0",
    "ember-data": "2.8.0",
    "ember-template-compiler": "2.8.0",
    "ember-testing": "2.8.0"
    },
    "addons": {
    "ember-one-way-controls": "1.1.1"
    }
    }