From: dsc Date: Wed, 4 Apr 2012 20:36:30 +0000 (-0700) Subject: Fixes saving bug. X-Git-Url: http://git.less.ly:3516/?a=commitdiff_plain;h=1d264116fb32793e5e642034a44183684e33420b;p=limn.git Fixes saving bug. --- diff --git a/lib/graph/graph-edit-view.co b/lib/graph/graph-edit-view.co index c95a6e8..92d2ff7 100644 --- a/lib/graph/graph-edit-view.co +++ b/lib/graph/graph-edit-view.co @@ -114,7 +114,7 @@ GraphEditView = exports.GraphEditView = BaseView.extend do # {{{ save: -> console.log "#this.save!" - id = @model.id or @model.get('slug') + id = @model.get('slug') or @model.id @model.save {id}, {+wait} false @@ -326,7 +326,7 @@ GraphEditView = exports.GraphEditView = BaseView.extend do # {{{ changes = @model.changedAttributes() options = @model.getOptions() # console.log "Graph.changed( options ) ->\n\tchanges: #{JSON.stringify changes}\n\toptions: #{JSON.stringify options}" #"\n\t^opts: #{JSON.stringify _.intersection _.keys(changes), _.keys(options)}" - @chart.updateOptions file:that if changes?.dataset + @chart?.updateOptions file:that if changes?.dataset @chartOptions options, {+silent} if changes?.options onScaffoldChange: (scaffold, value, key, field) -> diff --git a/lib/main.co b/lib/main.co index dffeb9e..61d2da9 100644 --- a/lib/main.co +++ b/lib/main.co @@ -45,7 +45,7 @@ main = -> (v, k) -> [ k, dyglib.parseOption(k,v) ] # Extract id from URL - if match = /\/graph\/(?!view)([^\/?]+)/i.exec loc + if match = /\/graphs\/([^\/?]+)/i.exec loc data.id = data.slug = match[1] # _.dump _.clone(data.options), 'data.options' diff --git a/lib/server/controllers/graph.co b/lib/server/controllers/graph.co index 8017081..d557f74 100644 --- a/lib/server/controllers/graph.co +++ b/lib/server/controllers/graph.co @@ -32,6 +32,8 @@ class GraphController extends Controller parser = yaml.load err, data <- fs.readFile file, 'utf8' + if 'ENOENT' is err?.code + return cb null, {} if err console.error "GraphController.autoload(#id, #{typeof cb}) -->\nerr" return cb err @@ -47,11 +49,17 @@ class GraphController extends Controller # GET /graphs/:graph show: (req, res) -> - res.send req.graph + if req.format is 'json' + res.send req.graph + else + res.render 'graph/view' # GET /graphs/:graph/edit edit: (req, res) -> - res.send req.graph + if req.format is 'json' + res.send req.graph + else + res.render 'graph/edit' # GET /graphs/new new: (req, res) ->