fix deletable rows
This commit is contained in:
parent
bad17f7cd5
commit
350fa9170c
2 changed files with 24 additions and 21 deletions
|
@ -9,6 +9,9 @@ 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
|
||||||
|
|
||||||
|
@ -162,6 +165,15 @@ class App.ControllerTable extends App.Controller
|
||||||
attribute.width = "#{@headerWidth[attribute.name]}px"
|
attribute.width = "#{@headerWidth[attribute.name]}px"
|
||||||
@headers.push attribute
|
@headers.push attribute
|
||||||
|
|
||||||
|
if destroy
|
||||||
|
@headers.push
|
||||||
|
name: 'destroy'
|
||||||
|
display: 'Delete'
|
||||||
|
width: '70px'
|
||||||
|
unresizable: true
|
||||||
|
parentClass: 'js-delete'
|
||||||
|
icon: 'trash'
|
||||||
|
|
||||||
if @orderDirection && @orderBy
|
if @orderDirection && @orderBy
|
||||||
for header in @headers
|
for header in @headers
|
||||||
if header.name is @orderBy
|
if header.name is @orderBy
|
||||||
|
@ -193,8 +205,6 @@ class App.ControllerTable extends App.Controller
|
||||||
for callback in @callbackHeader
|
for callback in @callbackHeader
|
||||||
@headers = callback(@headers)
|
@headers = callback(@headers)
|
||||||
|
|
||||||
@headers = @adjustHeaderWidths @headers
|
|
||||||
|
|
||||||
# group by
|
# group by
|
||||||
if @groupBy
|
if @groupBy
|
||||||
|
|
||||||
|
@ -297,19 +307,6 @@ class App.ControllerTable extends App.Controller
|
||||||
callback(id, checked, e)
|
callback(id, checked, e)
|
||||||
)
|
)
|
||||||
|
|
||||||
# bind on delete dialog
|
|
||||||
if @model && destroy
|
|
||||||
table.delegate('[data-type="destroy"]', 'click', (e) =>
|
|
||||||
e.stopPropagation()
|
|
||||||
e.preventDefault()
|
|
||||||
itemId = $(e.target).parents('tr').data('id')
|
|
||||||
item = @model.find(itemId)
|
|
||||||
new App.ControllerGenericDestroyConfirm(
|
|
||||||
item: item
|
|
||||||
container: @container
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
# if we have a personalised table
|
# if we have a personalised table
|
||||||
if @table_id
|
if @table_id
|
||||||
|
|
||||||
|
@ -347,6 +344,16 @@ class App.ControllerTable extends App.Controller
|
||||||
|
|
||||||
table
|
table
|
||||||
|
|
||||||
|
# bind on delete dialog
|
||||||
|
deleteRow: (e) =>
|
||||||
|
e.stopPropagation()
|
||||||
|
e.preventDefault()
|
||||||
|
itemId = $(e.target).parents('tr').data('id')
|
||||||
|
item = @model.find(itemId)
|
||||||
|
new App.ControllerGenericDestroyConfirm
|
||||||
|
item: item
|
||||||
|
container: @container
|
||||||
|
|
||||||
adjustHeaderWidths: (headers) ->
|
adjustHeaderWidths: (headers) ->
|
||||||
if !@headers
|
if !@headers
|
||||||
return
|
return
|
||||||
|
|
|
@ -30,9 +30,6 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</th>
|
</th>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @destroy: %>
|
|
||||||
<th><%- @T('Delete') %></th>
|
|
||||||
<% end %>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -88,6 +85,8 @@
|
||||||
<td<%- " class='#{ item.parentClass }'" if item.parentClass %><%- " title='#{ item.title }'" if item.title %><%- " style='text-align:#{ item.align }'" if item.align %>>
|
<td<%- " class='#{ item.parentClass }'" if item.parentClass %><%- " title='#{ item.title }'" if item.title %><%- " style='text-align:#{ item.align }'" if item.align %>>
|
||||||
<% if item.name is 'icon': %>
|
<% if item.name is 'icon': %>
|
||||||
<%- @Icon('task-state', item.class) %>
|
<%- @Icon('task-state', item.class) %>
|
||||||
|
<% else if item.icon: %>
|
||||||
|
<%- @Icon(item.icon) %>
|
||||||
<% else: %>
|
<% else: %>
|
||||||
<% if item.link: %>
|
<% if item.link: %>
|
||||||
<a href="<%- item.link %>" <% if item.target: %>target="<%= item.target %>"<% end %>>
|
<a href="<%- item.link %>" <% if item.target: %>target="<%= item.target %>"<% end %>>
|
||||||
|
@ -107,9 +106,6 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if @destroy: %>
|
|
||||||
<td data-type="destroy"><%- @Icon('trash') %></td>
|
|
||||||
<% end %>
|
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
Loading…
Reference in a new issue