Implement destroy via @bindCol param.
This commit is contained in:
parent
746f825c8f
commit
1909463c02
1 changed files with 10 additions and 7 deletions
|
@ -9,9 +9,6 @@ class App.ControllerTable extends App.Controller
|
||||||
elements:
|
elements:
|
||||||
'.js-tableHead': 'tableHead'
|
'.js-tableHead': 'tableHead'
|
||||||
|
|
||||||
events:
|
|
||||||
'click .js-delete': 'deleteRow'
|
|
||||||
|
|
||||||
constructor: (params) ->
|
constructor: (params) ->
|
||||||
super
|
super
|
||||||
|
|
||||||
|
@ -165,6 +162,7 @@ class App.ControllerTable extends App.Controller
|
||||||
attribute.width = "#{@headerWidth[attribute.name]}px"
|
attribute.width = "#{@headerWidth[attribute.name]}px"
|
||||||
@headers.push attribute
|
@headers.push attribute
|
||||||
|
|
||||||
|
# add destroy header and col binding
|
||||||
if destroy
|
if destroy
|
||||||
@headers.push
|
@headers.push
|
||||||
name: 'destroy'
|
name: 'destroy'
|
||||||
|
@ -174,6 +172,12 @@ class App.ControllerTable extends App.Controller
|
||||||
parentClass: 'js-delete'
|
parentClass: 'js-delete'
|
||||||
icon: 'trash'
|
icon: 'trash'
|
||||||
|
|
||||||
|
if !@bindCol
|
||||||
|
@bindCol = {}
|
||||||
|
@bindCol['destroy'] =
|
||||||
|
events:
|
||||||
|
click: @deleteRow
|
||||||
|
|
||||||
if @orderDirection && @orderBy
|
if @orderDirection && @orderBy
|
||||||
for header in @headers
|
for header in @headers
|
||||||
if header.name is @orderBy
|
if header.name is @orderBy
|
||||||
|
@ -345,11 +349,10 @@ class App.ControllerTable extends App.Controller
|
||||||
table
|
table
|
||||||
|
|
||||||
# bind on delete dialog
|
# bind on delete dialog
|
||||||
deleteRow: (e) =>
|
deleteRow: (id, e) =>
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
itemId = $(e.target).parents('tr').data('id')
|
item = @model.find(id)
|
||||||
item = @model.find(itemId)
|
|
||||||
new App.ControllerGenericDestroyConfirm
|
new App.ControllerGenericDestroyConfirm
|
||||||
item: item
|
item: item
|
||||||
container: @container
|
container: @container
|
||||||
|
|
Loading…
Reference in a new issue