Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Stop! Ember Time!

Stop! Ember Time!

Carl Woodward

October 08, 2013
Tweet

Other Decks in Technology

Transcript

  1. WeightsProgram.ExerciseRoute  =  Ember.Route.extend    model:  (params)  -­‐>      

     WeightsProgram.Exercise.find  params["exercise_id"] * Using Ember Model Wednesday, 9 October 13
  2. WeightsProgram.AuthenticatedExerciseController  =   Ember.ObjectController.extend    actions:        saveReps:

     -­‐>            @get("content").set("current_max",   @get("content").get("new_max"))            @get("content").save()            @transitionToRoute("authenticated.week",   @get("content.week")) * Using Ember Model Wednesday, 9 October 13
  3. if  isEditing    form.post-­‐form  role="form"  submit="create"        .form-­‐group

               button.btn.btn-­‐primary  click="stopEditing"  View Emblem Wednesday, 9 October 13
  4. <h2>Week  {{number}}</h2> <div  class="menu">    {{#each  exercise  in  exercises}}  

         <h3>            {{#link-­‐to  "authenticated.exercise"  exercise}}                {{exercise.movement.name}}            {{/link-­‐to}}        </h3>    {{/each}} </div> Handlebars Wednesday, 9 October 13
  5. <div  class="container  work">    <div  class="row">        <div

     class="col-­‐sm-­‐12">            <h1>Strength  Program</h1>        </div>    </div>    <div  class="row">        <div  class="col-­‐sm-­‐12">            {{  outlet  }}        </div>    </div> </div> Handlebars Wednesday, 9 October 13
  6. WeightsProgram.Exercise  =  Ember.Model.extend    id:  Ember.attr()    reps:  Ember.attr()  

     initial_max_value:  Ember.attr()    movement:  Ember.belongsTo("WeightsProgram.Movement",   key:  "movement_id",  embedded:  false)    accessories:   Ember.hasMany("WeightsProgram.Accessory",  key:   "accessory_ids",  embedded:  false) WeightsProgram.Exercise.url  =  "/exercises" WeightsProgram.Exercise.adapter  =   Ember.RESTAdapter.create() WeightsProgram.Exercise.rootKey  =  "exercise" WeightsProgram.Exercise.collectionKey  =  "exercises" Ember Model Wednesday, 9 October 13
  7. WeightsProgram.AuthenticatedProgramController  =   Ember.ObjectController.extend    actions:        createWeek:

     -­‐>            number  =  @get("weeks.lastObject.number")  +  1            week  =  WeightsProgram.Week.create  program_id:   @get("id"),  number:  number            week.on  "didCreateRecord",  =>                @get("model").reload()                @transitionToRoute("authenticated.program",   @get("model"))            week.save() Ember Model Wednesday, 9 October 13
  8. WeightsProgram.AuthenticatedProgramController WeightsProgram.Router.map  -­‐>    @resource  "authenticated",  path:  "/",  -­‐>  

         @route  "program",  path:  "/programs/:program_id" WeightsProgram.AuthenticatedProgramView app/assets/javascripts/views/authenticated/program.hbs Wednesday, 9 October 13