Skip to content

Instantly share code, notes, and snippets.

View kenelliott's full-sized avatar

Ken Elliott kenelliott

  • Jupiter
View GitHub Profile
watch:
options:
livereload: true
templates:
files: "#{srcFolder}/templates/**/*.hbs"
options:
nospawn: true
coffee:
files: "#{srcFolder}/**/*.coffee"
options:
# rollback target and related models
# http://stackoverflow.com/questions/19362584/how-to-rollback-changes-to-hasmany-in-ember-data
rollbackDirtyRecords = (context, transition) ->
relationships = Em.get(App[context.modelName.camelize().titleize()], "relationshipsByName")
content = context.get('controller.content')
transition.then ->
relationships.forEach (name, relationship) ->
relatedModel = content.get(name)
relatedModel.rollback() if relatedModel? and relatedModel.get('isDirty')
beforeModel: (transition) ->
# Attempt #1
# @store.unloadAll(transition.targetName.split('.').shift().singularize().camelize())
# # console.log transition.targetName.split('.').shift().singularize().camelize().titleize()
# relationships = Em.get(App[transition.targetName.split('.').shift().singularize().camelize().titleize()], "relationshipsByName")
# relationshipNames = []
# relationships.forEach (name, relationship) ->
# # console.log name, relationship
# relationshipNames.push(relationship.type.toString())
@kenelliott
kenelliott / gruntfile.coffee
Created January 22, 2014 22:19
ember grunt file
module.exports = (grunt) ->
# IMPORTS
# ------------------------------------------------------------------------------------
grunt.loadNpmTasks "grunt-contrib-clean"
grunt.loadNpmTasks "grunt-contrib-coffee"
grunt.loadNpmTasks "grunt-contrib-copy"
grunt.loadNpmTasks "grunt-contrib-connect"
grunt.loadNpmTasks "grunt-contrib-less"
grunt.loadNpmTasks "grunt-contrib-watch"
Ember.Handlebars.helper "eachProperty", (obj, options) ->
key = undefined
result = undefined
value = undefined
result = ""
for key of obj
value = obj[key]
result += options.fn(
key: key
value: value
ken@Ken-Elliotts-MacBook-Air:~/dev/employee_portal$ grunt test
Running "coffeelint:gruntfile" (coffeelint) task
>> 1 file lint free.
Running "coffeelint:sources" (coffeelint) task
>> 0 files lint free.
Running "clean:dev" (clean) task
Cleaning ./dev/app...OK
Cleaning ./dev/assets...OK
App.Router.map ->
@resource "teams", ->
@route "new"
@resource "team", path: "/:team_id", ->
@route "edit"
App.TeamEditRoute = Ember.Route.extend
model: ->
@modelFor "team"
renderTemplate: ->
# AMS API Mocker
$.mockjax
url: "*"
responseTime: 0
response: (mobject) ->
url = mobject.url.slice(1).split('/')
object = url.shift()
type = mobject.type
mobject.data = [] unless mobject.data
payload = {}
foo = "bar"
data = [
id:1
name: "bat"
,
id: 2
name: "baz"
]
# how can I interpolate foo into this data structure?