Fixed issue#392. Improved variable naming and enable table size feature for generic tables.

This commit is contained in:
Martin Edenhofer 2016-11-11 15:41:53 +01:00
parent 3e2711909a
commit f4f1ca2b43
8 changed files with 33 additions and 28 deletions

View file

@ -169,6 +169,7 @@ class App.ControllerGenericIndex extends App.Controller
# append content table # append content table
params = _.extend( params = _.extend(
{ {
tableId: "#{@genericObject}-generic-overview"
el: @$('.table-overview') el: @$('.table-overview')
model: App[ @genericObject ] model: App[ @genericObject ]
objects: objects objects: objects

View file

@ -14,14 +14,16 @@ class App.ControllerTable extends App.Controller
super super
# apply personal preferences # apply personal preferences
data = @preferencesGet() data = {}
if data['order'] if @tableId
for key, value of data['order'] data = @preferencesGet()
@[key] = value if data.order
for key, value of data.order
@[key] = value
@headerWidth = {} @headerWidth = {}
if data['headerWidth'] if data.headerWidth
for key, value of data['headerWidth'] for key, value of data.headerWidth
@headerWidth[key] = value @headerWidth[key] = value
@availableWidth = @el.width() @availableWidth = @el.width()
@ -91,7 +93,7 @@ class App.ControllerTable extends App.Controller
value value
new App.ControllerTable( new App.ControllerTable(
table_id: 'some_id_to_idientify_user_based_table_preferences' tableId: 'some_id_to_idientify_user_based_table_preferences'
el: element el: element
overview: ['host', 'user', 'adapter', 'active'] overview: ['host', 'user', 'adapter', 'active']
model: App.Channel model: App.Channel
@ -282,12 +284,12 @@ class App.ControllerTable extends App.Controller
@objects = @objects.concat groupObjects[group] @objects = @objects.concat groupObjects[group]
groupObjects[group] = [] # release old array groupObjects[group] = [] # release old array
if @table_id if @tableId
@calculateHeaderWidths() @calculateHeaderWidths()
# get content # get content
table = App.view('generic/table')( table = App.view('generic/table')(
table_id: @table_id tableId: @tableId
header: @headers header: @headers
attributes: attributes attributes: attributes
objects: @objects objects: @objects
@ -363,7 +365,7 @@ class App.ControllerTable extends App.Controller
) )
# if we have a personalised table # if we have a personalised table
if @table_id if @tableId
# enable resize column # enable resize column
table.on 'mousedown', '.js-col-resize', @onColResizeMousedown table.on 'mousedown', '.js-col-resize', @onColResizeMousedown
table.on 'click', '.js-col-resize', @stopPropagation table.on 'click', '.js-col-resize', @stopPropagation
@ -551,4 +553,4 @@ class App.ControllerTable extends App.Controller
data data
preferencesStoreKey: => preferencesStoreKey: =>
"tablePrefs:#{@table_id}" "tablePrefs:#{@tableId}"

View file

@ -37,7 +37,7 @@ class Index extends App.ControllerSubContent
new App.ControllerTable( new App.ControllerTable(
el: @$('.js-appList') el: @$('.js-appList')
model: App.Application model: App.Application
table_id: 'applications' tableId: 'applications'
objects: App.Application.all() objects: App.Application.all()
bindRow: bindRow:
events: events:

View file

@ -156,7 +156,7 @@ class App.Search extends App.Controller
for item in localList for item in localList
ticket_ids.push item.id ticket_ids.push item.id
new App.TicketList( new App.TicketList(
table_id: "find_#{model}" tableId: "find_#{model}"
el: @$('.js-content') el: @$('.js-content')
columns: [ 'number', 'title', 'customer', 'group', 'owner', 'created_at' ] columns: [ 'number', 'title', 'customer', 'group', 'owner', 'created_at' ]
ticket_ids: ticket_ids ticket_ids: ticket_ids
@ -167,10 +167,10 @@ class App.Search extends App.Controller
object = App[@model].fullLocal(id) object = App[@model].fullLocal(id)
@navigate object.uiUrl() @navigate object.uiUrl()
new App.ControllerTable( new App.ControllerTable(
table_id: "find_#{model}" tableId: "find_#{model}"
el: @$('.js-content') el: @$('.js-content')
model: App[model] model: App[model]
objects: list objects: list
bindRow: bindRow:
events: events:
'click': openObject 'click': openObject

View file

@ -457,7 +457,7 @@ class Table extends App.Controller
value value
new App.ControllerTable( new App.ControllerTable(
table_id: "ticket_overview_#{@overview.id}" tableId: "ticket_overview_#{@overview.id}"
overview: @overview.view.s overview: @overview.view.s
el: @$('.table-overview') el: @$('.table-overview')
model: App.Ticket model: App.Ticket

View file

@ -112,10 +112,11 @@ class Index extends App.ControllerSubContent
@$('.table-overview').html('') @$('.table-overview').html('')
new App.ControllerTable( new App.ControllerTable(
el: @$('.table-overview') tableId: 'users_admin_overview'
model: App.User el: @$('.table-overview')
objects: users model: App.User
class: 'user-list' objects: users
class: 'user-list'
callbackHeader: [callbackHeader] callbackHeader: [callbackHeader]
callbackAttributes: callbackAttributes:
switch_to: [ switch_to: [
@ -166,12 +167,13 @@ class Index extends App.ControllerSubContent
data: data:
limit: 40 limit: 40
role_ids: role_ids role_ids: role_ids
full: 1 full: 1
processData: true, processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
App.Collection.loadAssets(data.assets) App.Collection.loadAssets(data.assets)
@renderResult(data.user_ids) @renderResult(data.user_ids)
complete: => @stopLoading()
error: =>
@stopLoading() @stopLoading()
) )

View file

@ -50,7 +50,7 @@ class App.TicketList extends App.Controller
list.push ticketItem list.push ticketItem
@el.html('') @el.html('')
new App.ControllerTable( new App.ControllerTable(
table_id: @table_id tableId: @tableId
el: @el el: @el
overview: @columns || [ 'number', 'title', 'customer', 'group', 'created_at' ] overview: @columns || [ 'number', 'title', 'customer', 'group', 'created_at' ]
model: App.Ticket model: App.Ticket

View file

@ -18,7 +18,7 @@
<% end %> <% end %>
<% for item, i in @header: %> <% for item, i in @header: %>
<th class="js-tableHead<%= " #{ item.className }" if item.className %><%= " align-#{ item.align }" if item.align %>" style="<% if item.displayWidth: %>width:<%= item.displayWidth %>px<% end %>" data-column-key="<%= item.name %>"> <th class="js-tableHead<%= " #{ item.className }" if item.className %><%= " align-#{ item.align }" if item.align %>" style="<% if item.displayWidth: %>width:<%= item.displayWidth %>px<% end %>" data-column-key="<%= item.name %>">
<div class="table-column-head<%= ' js-sort' if @table_id %>"> <div class="table-column-head<%= ' js-sort' if @tableId %>">
<div class="table-column-title"> <div class="table-column-title">
<%- @T(item.display) %> <%- @T(item.display) %>
</div> </div>
@ -28,7 +28,7 @@
<% end %> <% end %>
</div> </div>
</div> </div>
<% if @table_id && !item.unresizable && i < @header.length - 1: %> <% if @tableId && !item.unresizable && i < @header.length - 1: %>
<div class="table-col-resize js-col-resize"></div> <div class="table-col-resize js-col-resize"></div>
<% end %> <% end %>
</th> </th>