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
params = _.extend(
{
tableId: "#{@genericObject}-generic-overview"
el: @$('.table-overview')
model: App[ @genericObject ]
objects: objects

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -18,7 +18,7 @@
<% end %>
<% 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 %>">
<div class="table-column-head<%= ' js-sort' if @table_id %>">
<div class="table-column-head<%= ' js-sort' if @tableId %>">
<div class="table-column-title">
<%- @T(item.display) %>
</div>
@ -28,7 +28,7 @@
<% end %>
</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>
<% end %>
</th>