diff --git a/app/assets/javascripts/app/controllers/_application_controller_table.coffee b/app/assets/javascripts/app/controllers/_application_controller_table.coffee
index 60c1511d03c1..32dbefa06cfa 100644
--- a/app/assets/javascripts/app/controllers/_application_controller_table.coffee
+++ b/app/assets/javascripts/app/controllers/_application_controller_table.coffee
@@ -88,8 +88,8 @@ class App.ControllerTable extends App.Controller
console.log('new header is', headers)
headers
- callbackAttributes = (value, object, attribute, header, refObject) ->
- console.log('data of item col', value, object, attribute, header, refObject)
+ callbackAttributes = (value, object, attribute, header) ->
+ console.log('data of item col', value, object, attribute, header)
value = 'New Data To Show'
value
@@ -288,19 +288,44 @@ class App.ControllerTable extends App.Controller
if @tableId
@calculateHeaderWidths()
- # get content
+ # generate content
+ position = 0
+ columnsLength = @headers.length
+ if @checkbox || @radio
+ columnsLength++
+ groupLast = ''
+ tableBody = ''
+ for object in @objects
+ if @groupBy
+ groupByName = App.viewPrint(object, @groupBy, attributes)
+ if groupLast isnt groupByName
+ groupLast = groupByName
+ tableBody += App.view('generic/table_row_group_by')(
+ position: position
+ groupByName: groupByName
+ columnsLength: columnsLength
+ )
+ position++
+ tableBody += App.view('generic/table_row')(
+ headers: @headers
+ attributes: attributes
+ checkbox: @checkbox
+ radio: @radio
+ callbacks: @callbackAttributes
+ sortable: @dndCallback
+ position: position
+ object: object
+ )
+
+ # generate full table
table = App.view('generic/table')(
tableId: @tableId
- header: @headers
- attributes: attributes
- objects: @objects
+ headers: @headers
checkbox: @checkbox
radio: @radio
- groupBy: @groupBy
class: @class
- destroy: destroy
- callbacks: @callbackAttributes
sortable: @dndCallback
+ tableBody: tableBody
)
# convert to jquery object
diff --git a/app/assets/javascripts/app/controllers/api.coffee b/app/assets/javascripts/app/controllers/api.coffee
index 89fdbd0a0087..fbc576f1cdb1 100644
--- a/app/assets/javascripts/app/controllers/api.coffee
+++ b/app/assets/javascripts/app/controllers/api.coffee
@@ -46,11 +46,11 @@ class Index extends App.ControllerSubContent
headers.splice(4, 0, attribute)
headers
- callbackViewAttributes = (value, object, attribute, header, refObject) ->
+ callbackViewAttributes = (value, object, attribute, header) ->
value = 'X'
value
- callbackTokenAttributes = (value, object, attribute, header, refObject) ->
+ callbackTokenAttributes = (value, object, attribute, header) ->
value = 'X'
value
diff --git a/app/assets/javascripts/app/controllers/ticket_overview.coffee b/app/assets/javascripts/app/controllers/ticket_overview.coffee
index 4df9b2a7f20c..432b1e0d6839 100644
--- a/app/assets/javascripts/app/controllers/ticket_overview.coffee
+++ b/app/assets/javascripts/app/controllers/ticket_overview.coffee
@@ -608,48 +608,6 @@ class App.TicketOverview extends App.Controller
valid_user_ids.push user_id
group.valid_user_ids = valid_user_ids
- ###
- users = [
- App.User.find(2),
- App.User.find(2),
- App.User.find(2),
- ]
- macros = [
- {
- name: 'Close Beispiel für eine besonders'
- },
- {
- name: 'Close Beispiel für eine besonders'
- },
- {
- name: 'Close Beispiel für eine besonders'
- },
- {
- name: 'Close Beispiel für eine besonders'
- },
- {
- name: 'Close Beispiel für eine besonders'
- },
- {
- name: 'Close Beispiel für eine besonders'
- },
- {
- name: 'Close Beispiel für eine besonders'
- },
- {
- name: 'Close & Tag as Spam'
- },
- {
- name: 'Close & Reply we\'re on Holidays'
- },
- {
- name: 'Escalate to 2nd level'
- },
- {
- name: '1st Close'
- },
- ]
- ###
@batchAssignInner.html $(App.view('ticket_overview/batch_overlay_user_group')(
users: users
groups: groups
@@ -1036,23 +994,30 @@ class Table extends App.Controller
show: true
)
@navigate ticket.uiUrl()
- callbackTicketTitleAdd = (value, object, attribute, attributes, refObject) ->
+ callbackTicketTitleAdd = (value, object, attribute, attributes) ->
attribute.title = object.title
value
- callbackLinkToTicket = (value, object, attribute, attributes, refObject) ->
+ callbackLinkToTicket = (value, object, attribute, attributes) ->
attribute.link = object.uiUrl()
value
- callbackUserPopover = (value, object, attribute, attributes, refObject) ->
- return value if !refObject
+ callbackUserPopover = (value, object, attribute, attributes) ->
+ return value if !object
+ refObjectId = undefined
+ if attribute.name is 'customer_id'
+ refObjectId = object.customer_id
+ if attribute.name is 'owner_id'
+ refObjectId = object.owner_id
+ return value if !refObjectId
attribute.class = 'user-popover'
attribute.data =
- id: refObject.id
+ id: refObjectId
value
- callbackOrganizationPopover = (value, object, attribute, attributes, refObject) ->
- return value if !refObject
+ callbackOrganizationPopover = (value, object, attribute, attributes) ->
+ return value if !object
+ return value if !object.organization_id
attribute.class = 'organization-popover'
attribute.data =
- id: refObject.id
+ id: object.organization_id
value
callbackCheckbox = (id, checked, e) =>
if @$('table').find('input[name="bulk"]:checked').length == 0
@@ -1089,7 +1054,7 @@ class Table extends App.Controller
headers.unshift(0)
headers[0] = attribute
headers
- callbackIcon = (value, object, attribute, header, refObject) ->
+ callbackIcon = (value, object, attribute, header) ->
value = ' '
attribute.class = object.iconClass()
attribute.link = ''
diff --git a/app/assets/javascripts/app/controllers/users.coffee b/app/assets/javascripts/app/controllers/users.coffee
index a2a703cac440..03e2ba13d2b7 100644
--- a/app/assets/javascripts/app/controllers/users.coffee
+++ b/app/assets/javascripts/app/controllers/users.coffee
@@ -56,7 +56,7 @@ class Index extends App.ControllerSubContent
header.push attribute
header
- callbackAttributes = (value, object, attribute, header, refObject) ->
+ callbackAttributes = (value, object, attribute, header) ->
text = App.i18n.translateInline('View from user\'s perspective')
value = ' '
attribute.raw = ' ' + App.Utils.icon('switchView') + text + ' '
diff --git a/app/assets/javascripts/app/controllers/widget/ticket_list.coffee b/app/assets/javascripts/app/controllers/widget/ticket_list.coffee
index 8118af319ecc..9ab9ef4c141d 100644
--- a/app/assets/javascripts/app/controllers/widget/ticket_list.coffee
+++ b/app/assets/javascripts/app/controllers/widget/ticket_list.coffee
@@ -9,23 +9,30 @@ class App.TicketList extends App.Controller
openTicket = (id,e) =>
ticket = App.Ticket.findNative(id)
@navigate ticket.uiUrl()
- callbackTicketTitleAdd = (value, object, attribute, attributes, refObject) ->
+ callbackTicketTitleAdd = (value, object, attribute, attributes) ->
attribute.title = object.title
value
- callbackLinkToTicket = (value, object, attribute, attributes, refObject) ->
+ callbackLinkToTicket = (value, object, attribute, attributes) ->
attribute.link = object.uiUrl()
value
- callbackUserPopover = (value, object, attribute, attributes, refObject) ->
- return value if !refObject
+ callbackUserPopover = (value, object, attribute, attributes) ->
+ return value if !object
+ refObjectId = undefined
+ if attribute.name is 'customer_id'
+ refObjectId = object.customer_id
+ if attribute.name is 'owner_id'
+ refObjectId = object.owner_id
+ return value if !refObjectId
attribute.class = 'user-popover'
attribute.data =
- id: refObject.id
+ id: refObjectId
value
- callbackOrganizationPopover = (value, object, attribute, attributes, refObject) ->
- return value if !refObject
+ callbackOrganizationPopover = (value, object, attribute, attributes) ->
+ return value if !object
+ return value if !object.organization_id
attribute.class = 'organization-popover'
attribute.data =
- id: refObject.id
+ id: object.organization_id
value
callbackIconHeader = (headers) ->
@@ -39,7 +46,8 @@ class App.TicketList extends App.Controller
headers.unshift(0)
headers[0] = attribute
headers
- callbackIcon = (value, object, attribute, header, refObject) ->
+
+ callbackIcon = (value, object, attribute, header) ->
value = ' '
attribute.class = object.iconClass()
attribute.link = ''
diff --git a/app/assets/javascripts/app/index.coffee b/app/assets/javascripts/app/index.coffee
index 9ee17d8323df..0f0db9b9d386 100644
--- a/app/assets/javascripts/app/index.coffee
+++ b/app/assets/javascripts/app/index.coffee
@@ -9,58 +9,57 @@
#= require_tree ./lib/app_post
class App extends Spine.Controller
- @viewPrint: (object, attribute_name, attributes) ->
+ @viewPrint: (object, attributeName, attributes) ->
if !attributes
attributes = {}
if object.constructor.attributesGet
attributes = object.constructor.attributesGet()
- attribute_config = attributes[attribute_name]
- value = object[attribute_name]
- valueRef = undefined
+ attributeConfig = attributes[attributeName]
+ value = object[attributeName]
+ valueRef = undefined
# check if relation is requested
- if !attribute_config
- attribute_name_new = "#{attribute_name}_id"
- attribute_config = attributes[attribute_name_new]
- if attribute_config
- attribute_name = attribute_name_new
- if object[attribute_name]
+ if !attributeConfig
+ attributeNameNew = "#{attributeName}_id"
+ attributeConfig = attributes[attributeNameNew]
+ if attributeConfig
+ attributeName = attributeNameNew
+ if object[attributeName]
valueRef = value
- value = object[attribute_name]
+ value = object[attributeName]
# in case of :: key, get the sub value
if !value
- parts = attribute_name.split('::')
+ parts = attributeName.split('::')
if parts[0] && parts[1] && object[ parts[0] ]
value = object[ parts[0] ][ parts[1] ]
# if we have no config, get output this way
- if !attribute_config
+ if !attributeConfig
return @viewPrintItem(value)
# check if valueRef already exists, no lookup needed later
if !valueRef
- attribute_name_without_ref = attribute_name.substr(attribute_name.length-3, attribute_name.length)
- if attribute_name_without_ref is '_id'
- attribute_name_without_ref = attribute_name.substr(0, attribute_name.length-3)
- if object[attribute_name_without_ref]
- valueRef = object[attribute_name_without_ref]
+ if attributeName.substr(attributeName.length-3, attributeName.length) is '_id'
+ attributeNameWithoutRef = attributeName.substr(0, attributeName.length-3)
+ if object[attributeNameWithoutRef]
+ valueRef = object[attributeNameWithoutRef]
- @viewPrintItem(value, attribute_config, valueRef)
+ @viewPrintItem(value, attributeConfig, valueRef)
# define print name helper
- @viewPrintItem: (item, attribute_config = {}, valueRef) ->
+ @viewPrintItem: (item, attributeConfig = {}, valueRef) ->
return '-' if item is undefined
return '-' if item is ''
return item if item is null
result = item
# lookup relation
- if attribute_config.relation || valueRef
+ if attributeConfig.relation || valueRef
if valueRef
item = valueRef
else
- item = App[attribute_config.relation].find(item)
+ item = App[attributeConfig.relation].find(item)
# if date is a object, get name of the object
isObject = false
@@ -74,57 +73,57 @@ class App extends Spine.Controller
result = item.name
# execute callback on content
- if attribute_config.callback
- result = attribute_config.callback(result, attribute_config)
+ if attributeConfig.callback
+ result = attributeConfig.callback(result, attributeConfig)
# text2html in textarea view
isHtmlEscape = false
- if attribute_config.tag is 'textarea'
+ if attributeConfig.tag is 'textarea'
isHtmlEscape = true
result = App.Utils.text2html(result)
# remember, html snippets are already escaped
- else if attribute_config.tag is 'richtext'
+ else if attributeConfig.tag is 'richtext'
isHtmlEscape = true
# fillup options
- if !_.isEmpty(attribute_config.options)
- if attribute_config.options[result]
- result = attribute_config.options[result]
+ if !_.isEmpty(attributeConfig.options)
+ if attributeConfig.options[result]
+ result = attributeConfig.options[result]
# transform boolean
- if attribute_config.tag is 'boolean'
+ if attributeConfig.tag is 'boolean'
if result is true
result = 'yes'
else if result is false
result = 'no'
# translate content
- if attribute_config.translate || (isObject && item.translate && item.translate())
+ if attributeConfig.translate || (isObject && item.translate && item.translate())
isHtmlEscape = true
result = App.i18n.translateContent(result)
# transform date
- if attribute_config.tag is 'date'
+ if attributeConfig.tag is 'date'
isHtmlEscape = true
result = App.i18n.translateDate(result)
# transform input tel|url to make it clickable
- if attribute_config.tag is 'input'
- if attribute_config.type is 'tel'
+ if attributeConfig.tag is 'input'
+ if attributeConfig.type is 'tel'
result = "#{App.Utils.htmlEscape(result)} "
- else if attribute_config.type is 'url'
+ else if attributeConfig.type is 'url'
result = App.Utils.linkify(result)
else
result = App.Utils.htmlEscape(result)
isHtmlEscape = true
# use pretty time for datetime
- else if attribute_config.tag is 'datetime'
+ else if attributeConfig.tag is 'datetime'
isHtmlEscape = true
timestamp = App.i18n.translateTimestamp(result)
escalation = false
- cssClass = attribute_config.class || ''
+ cssClass = attributeConfig.class || ''
if cssClass.match 'escalation'
escalation = true
humanTime = App.PrettyDate.humanTime(result, escalation)
@@ -139,8 +138,8 @@ class App extends Spine.Controller
template = (params = {}) ->
# define print name helper
- params.P = (object, attribute_name, attributes) ->
- App.viewPrint(object, attribute_name, attributes)
+ params.P = (object, attributeName, attributes) ->
+ App.viewPrint(object, attributeName, attributes)
# define date format helper
params.date = (time) ->
diff --git a/app/assets/javascripts/app/views/agent_ticket_view/detail.jst.eco b/app/assets/javascripts/app/views/agent_ticket_view/detail.jst.eco
index cc150522435a..050a35b40305 100644
--- a/app/assets/javascripts/app/views/agent_ticket_view/detail.jst.eco
+++ b/app/assets/javascripts/app/views/agent_ticket_view/detail.jst.eco
@@ -13,37 +13,36 @@
<%- ticket.customer.avatar("50", "", "userInfo-avatar") %>
-
- <%- @T( 'Number' ) %> <%- @P( ticket, 'number' ) %>
+ <%- @T('Number') %> <%- @P(ticket, 'number') %>
- <%- @T( 'State' ) %> <%- @P( ticket, 'state' ) %>
+ <%- @T('State') %> <%- @P(ticket, 'state') %>
- <%- @T( 'Group' ) %> <%- @P( ticket, 'group' ) %>
+ <%- @T('Group') %> <%- @P(ticket, 'group') %>
- <%- @T( 'Customer' ) %> <%- @P( ticket, 'customer' ) %>
+ <%- @T('Customer') %> <%- @P(ticket, 'customer') %>
- <%- @T( 'Erstellt' ) %> <%- @P( ticket, 'created_at' ) %>
+ <%- @T('Erstellt') %> <%- @P(ticket, 'created_at') %>
- <%- @T( 'Priority' ) %> <%- @P( ticket, 'priority' ) %>
+ <%- @T('Priority') %> <%- @P(ticket, 'priority') %>
- <%- @T( 'Owner' ) %> <%- @P( ticket, 'owner' ) %>
+ <%- @T('Owner') %> <%- @P(ticket, 'owner') %>
- <%- @T( 'Organization' ) %> <%- @P( ticket, 'organization' ) %>
+ <%- @T('Organization') %> <%- @P(ticket, 'organization') %>
diff --git a/app/assets/javascripts/app/views/generic/table.jst.eco b/app/assets/javascripts/app/views/generic/table.jst.eco
index d535c3e45bc8..7bfdcbe4c38d 100644
--- a/app/assets/javascripts/app/views/generic/table.jst.eco
+++ b/app/assets/javascripts/app/views/generic/table.jst.eco
@@ -17,103 +17,24 @@
<% if @radio: %>
<% end %>
- <% for item, i in @header: %>
-
<%= " align-#{ item.align }" if item.align %>" style="<% if item.displayWidth: %>width:<%= item.displayWidth %>px<% end %>" data-column-key="<%= item.name %>">
+ <% for header, i in @headers: %>
+ <%= " align-#{ header.align }" if header.align %>" style="<% if header.displayWidth: %>width:<%= header.displayWidth %>px<% end %>" data-column-key="<%= header.name %>">
- <%- @T(item.display) %>
+ <%- @T(header.display) %>
- <% if item.sortOrderIcon: %>
- <%- @Icon(item.sortOrderIcon[0], item.sortOrderIcon[1]) %>
+ <% if header.sortOrderIcon: %>
+ <%- @Icon(header.sortOrderIcon[0], header.sortOrderIcon[1]) %>
<% end %>
- <% if @tableId && !item.unresizable && i < @header.length - 1: %>
+ <% if @tableId && !header.unresizable && i < @headers.length - 1: %>
<% end %>
<% end %>
-
-<% position = 0 %>
-<% length = @header.length %>
-<% if @checkbox || @radio: %>
-<% length++ %>
-<% end %>
-<% groupLast = '' %>
-<% for object in @objects: %>
- <% if @groupBy: %>
- <% groupByName = @P(object, @groupBy, @attributes) %>
- <% if groupLast isnt groupByName: %>
- <%= groupByName %>
- <% groupLast = groupByName %>
- <% end %>
- <% end %>
- <% position++ %>
-
- <% if @sortable: %>
- <%- @Icon('draggable') %>
- <% end %>
- <% if @checkbox: %>
-
-
-
- <%- @Icon('checkbox', 'icon-unchecked') %>
- <%- @Icon('checkbox-checked', 'icon-checked') %>
-
-
- <% end %>
- <% if @radio: %>
-
-
-
- <%- @Icon('radio', 'icon-unchecked') %>
- <%- @Icon('radio-checked', 'icon-checked') %>
-
-
- <% end %>
- <% for item in @header: %>
- <% value = @P(object, item.name, @attributes) %>
- <% if @callbacks: %>
- <% if item.name.substr(item.name.length-3, item.name.length) is '_id' && object[ item.name.substr(0, item.name.length-3) ]: %>
- <% refObject = object[ item.name.substr(0, item.name.length-3) ] %>
- <% end %>
- <% for attribute, callbacksAll of @callbacks: %>
- <% if attribute is item.name: %>
- <% for callback in callbacksAll: %>
- <% value = callback(value, object, item, @header, refObject) %>
- <% end %>
- <% end %>
- <% end %>
- <% end %>
-
- <%- " title='#{ item.title }'" if item.title %><%- " style='text-align:#{ item.align }'" if item.align %>>
- <% if item.name is 'icon': %>
- <%- @Icon('task-state', item.class) %>
- <% else if item.icon: %>
- <%- @Icon(item.icon) %>
- <% else: %>
- <% if item.link: %>
- target="<%= item.target %>"<% end %>>
- <% end %>
- <% if item.raw: %>
- <%- item.raw %>
- <% else: %>
- <% if item.class || item.data: %>
- class="<%= item.class %>"<% end %> <% if item.data: %><% for data_key, data_item of item.data: %>data-<%- data_key %>="<%= data_item %>" <% end %><% end %>>
- <% end %>
- <%- value %>
- <% if item.class || item.data: %>
-
- <% end %>
- <% end %>
- <% if item.link: %> <% end %>
- <% end %>
-
- <% end %>
-
-<% end %>
-
+
<%- @tableBody %>
\ No newline at end of file
diff --git a/app/assets/javascripts/app/views/generic/table_row.jst.eco b/app/assets/javascripts/app/views/generic/table_row.jst.eco
new file mode 100644
index 000000000000..ca85df9d7b6f
--- /dev/null
+++ b/app/assets/javascripts/app/views/generic/table_row.jst.eco
@@ -0,0 +1,56 @@
+
+<% if @sortable: %>
+ <%- @Icon('draggable') %>
+<% end %>
+<% if @checkbox: %>
+
+
+
+ <%- @Icon('checkbox', 'icon-unchecked') %>
+ <%- @Icon('checkbox-checked', 'icon-checked') %>
+
+
+<% end %>
+<% if @radio: %>
+
+
+
+ <%- @Icon('radio', 'icon-unchecked') %>
+ <%- @Icon('radio-checked', 'icon-checked') %>
+
+
+<% end %>
+<% for header in @headers: %>
+ <% value = @P(@object, header.name, @attributes) %>
+ <% if @callbacks: %>
+ <% for attribute, callbacksAll of @callbacks: %>
+ <% if attribute is header.name: %>
+ <% for callback in callbacksAll: %>
+ <% value = callback(value, @object, header, @headers) %>
+ <% end %>
+ <% end %>
+ <% end %>
+ <% end %>
+
+<% end %>
+
\ No newline at end of file
diff --git a/app/assets/javascripts/app/views/generic/table_row_group_by.jst.eco b/app/assets/javascripts/app/views/generic/table_row_group_by.jst.eco
new file mode 100644
index 000000000000..5b61703b0c4b
--- /dev/null
+++ b/app/assets/javascripts/app/views/generic/table_row_group_by.jst.eco
@@ -0,0 +1,3 @@
+
+ <%= @groupByName %>
+
diff --git a/app/assets/javascripts/app/views/popover/ticket.jst.eco b/app/assets/javascripts/app/views/popover/ticket.jst.eco
index 23a0cdc106ff..819ffdaa750c 100644
--- a/app/assets/javascripts/app/views/popover/ticket.jst.eco
+++ b/app/assets/javascripts/app/views/popover/ticket.jst.eco
@@ -24,18 +24,18 @@
#
-
<%- @P( @ticket, 'number' ) %>
+
<%- @P(@ticket, 'number') %>
-
<%- @T( 'Priority' ) %>
-
<%- @P( @ticket, 'priority' ) %>
+
<%- @T('Priority') %>
+
<%- @P(@ticket, 'priority') %>
-
<%- @T( 'Created' ) %>
-
<%- @P( @ticket, 'created_at' ) %>
+
<%- @T('Created') %>
+
<%- @P(@ticket, 'created_at') %>
-
<%- @T( 'Group' ) %>
-
<%- @P( @ticket, 'group' ) %>
+
<%- @T('Group') %>
+
<%- @P(@ticket, 'group') %>
\ No newline at end of file
diff --git a/app/assets/javascripts/app/views/popover/user.jst.eco b/app/assets/javascripts/app/views/popover/user.jst.eco
index b5563113d355..7fcc636ee71a 100644
--- a/app/assets/javascripts/app/views/popover/user.jst.eco
+++ b/app/assets/javascripts/app/views/popover/user.jst.eco
@@ -5,30 +5,30 @@
<% for row in @userData: %>
<% if @user[row.name]: %>
- <%- @T( row.display ) %>
- <%- @P( @user, row.name ) %>
+ <%- @T(row.display) %>
+ <%- @P(@user, row.name) %>
<% end %>
<% end %>
<% if !_.isEmpty(@user['accounts']): %>
-
<%- @T( 'Linked Accounts' ) %>
+
<%- @T('Linked Accounts') %>
<% for account of @user['accounts']: %>
<%= account %>
<% end %>
<% end %>
-<% if !_.isEmpty( @user['links'] ): %>
+<% if !_.isEmpty(@user['links']): %>
<% for link in @user['links']: %>