Sha256: 575fb30556faa9cee039f0067feab377728e82da14642c9fe3703c5dfe732de7
Contents?: true
Size: 1.83 KB
Versions: 3
Compression:
Stored size: 1.83 KB
Contents
class Lanes.Components.Grid.Editor extends Lanes.Components.Base session: grid: 'object' # n.b. - not 'state'. Doing so causes stack overflow since grid also has a 'editor' session var events: 'click .save': 'saveChanges' 'click .cancel': 'cancelEditing' ui: form: 'form' constructor: (config)-> super this.grid = this.parent move: (row)-> if @row this.$el.trigger('cancel-edit',@row) @row=row @model = this.grid.modelForRow(@row) this.render() unless this.rendered this.grid.$('.dataTables_scrollBody').append(this.el) this.updateFields() updateFields: -> for input, index in this.$('input') if definition = this.getColumn(input.name) Lanes.dom.setAttribute(input, 'value', this.model.get(definition.field) ) this.$('input').first().focus() persistFields: -> for input, index in this.$('input') if definition = this.getColumn(input.name) @model.set( definition.field, Lanes.dom.getAttribute(input,'value') ) getColumn: (name)-> _.findWhere(this.grid.column_definitions, { field: name }) saveChanges: -> this.persistFields() @model.save().then => @updateGridRow() updateGridRow: -> this.$el.trigger('row-updated', @row) @grid.updateRow(@row,@model) this.cancelEditing() cancelEditing: -> this.$el.trigger('cancel-edit',@row) this.detach() this.model = null deleteCurrent: -> @model.destroy().then => @grid.removeRow(@row) @cancelEditing() fields: -> _.map(this.ui.form.children(), (input,index)-> { index: index, input: Lanes.$(input), column: this.grid.column_definitions[index] } ,this)
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lanes-0.1.0 | client/lanes/components/grid/Editor.coffee |
lanes-0.0.8 | client/lanes/components/grid/Editor.coffee |
lanes-0.0.5 | client/lanes/components/grid/Editor.coffee |