Moved to new table backend.
This commit is contained in:
parent
8bdd4a315a
commit
507eae63bb
7 changed files with 154 additions and 144 deletions
|
@ -45,125 +45,6 @@ class App.Controller extends Spine.Controller
|
||||||
formValidate: (data) ->
|
formValidate: (data) ->
|
||||||
App.ControllerForm.validate(data)
|
App.ControllerForm.validate(data)
|
||||||
|
|
||||||
###
|
|
||||||
|
|
||||||
table = @table(
|
|
||||||
header: ['Host', 'User', 'Adapter', 'Active'],
|
|
||||||
overview: ['host', 'user', 'adapter', 'active'],
|
|
||||||
model: App.Channel,
|
|
||||||
objects: data,
|
|
||||||
)
|
|
||||||
|
|
||||||
table = @table(
|
|
||||||
overview_extended: [
|
|
||||||
{ name: 'number', link: true },
|
|
||||||
{ name: 'title', link: true },
|
|
||||||
{ name: 'customer', class: 'user-data', data: { id: true } },
|
|
||||||
{ name: 'ticket_state', translate: true },
|
|
||||||
{ name: 'ticket_priority', translate: true },
|
|
||||||
{ name: 'group' },
|
|
||||||
{ name: 'owner', class: 'user-data', data: { id: true } },
|
|
||||||
{ name: 'created_at', callback: @frontendTime },
|
|
||||||
{ name: 'last_contact', callback: @frontendTime },
|
|
||||||
{ name: 'last_contact_agent', callback: @frontendTime },
|
|
||||||
{ name: 'last_contact_customer', callback: @frontendTime },
|
|
||||||
{ name: 'first_response', callback: @frontendTime },
|
|
||||||
{ name: 'close_time', callback: @frontendTime },
|
|
||||||
],
|
|
||||||
model: App.Ticket,
|
|
||||||
objects: tickets,
|
|
||||||
)
|
|
||||||
|
|
||||||
###
|
|
||||||
|
|
||||||
table: (data) ->
|
|
||||||
overview = data.overview || data.model.configure_overview || []
|
|
||||||
attributes = data.attributes || data.model.configure_attributes || {}
|
|
||||||
header = data.header
|
|
||||||
|
|
||||||
# define normal header
|
|
||||||
if header
|
|
||||||
header_new = []
|
|
||||||
for key in header
|
|
||||||
header_new.push {
|
|
||||||
display: key
|
|
||||||
}
|
|
||||||
header = header_new
|
|
||||||
else if !data.overview_extended
|
|
||||||
header = []
|
|
||||||
for row in overview
|
|
||||||
if attributes
|
|
||||||
for attribute in attributes
|
|
||||||
if row is attribute.name
|
|
||||||
header.push attribute
|
|
||||||
else
|
|
||||||
rowWithoutId = row + '_id'
|
|
||||||
if rowWithoutId is attribute.name
|
|
||||||
header.push attribute
|
|
||||||
|
|
||||||
dataTypesForCols = []
|
|
||||||
for row in overview
|
|
||||||
dataTypesForCols.push {
|
|
||||||
name: row,
|
|
||||||
link: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
# extended table format
|
|
||||||
if data.overview_extended
|
|
||||||
if !header
|
|
||||||
header = []
|
|
||||||
for row in data.overview_extended
|
|
||||||
for attribute in attributes
|
|
||||||
if row.name is attribute.name
|
|
||||||
header.push attribute
|
|
||||||
else
|
|
||||||
rowWithoutId = row.name + '_id'
|
|
||||||
if rowWithoutId is attribute.name
|
|
||||||
header.push attribute
|
|
||||||
|
|
||||||
dataTypesForCols = data.overview_extended
|
|
||||||
|
|
||||||
# generate content data
|
|
||||||
for object in data.objects
|
|
||||||
|
|
||||||
# check if info for each col. is already there
|
|
||||||
for row in dataTypesForCols
|
|
||||||
|
|
||||||
# lookup relation
|
|
||||||
if !object[row.name]
|
|
||||||
rowWithoutId = row.name + '_id'
|
|
||||||
for attribute in attributes
|
|
||||||
if rowWithoutId is attribute.name
|
|
||||||
if attribute.relation && App[attribute.relation]
|
|
||||||
record = App.Collection.find( attribute.relation, object[rowWithoutId] )
|
|
||||||
object[row.name] = record.name
|
|
||||||
|
|
||||||
@log 'table', 'header', header, 'overview', dataTypesForCols, 'objects', data.objects
|
|
||||||
table = App.view('generic/table')(
|
|
||||||
header: header,
|
|
||||||
overview: dataTypesForCols,
|
|
||||||
objects: data.objects,
|
|
||||||
checkbox: data.checkbox,
|
|
||||||
)
|
|
||||||
# @log 'ttt', $(table).find('span')
|
|
||||||
# $(table).find('span').bind('click', ->
|
|
||||||
# console.log('----------click---------')
|
|
||||||
# )
|
|
||||||
|
|
||||||
# convert to jquery object
|
|
||||||
table = $(table)
|
|
||||||
|
|
||||||
# enable checkbox bulk selection
|
|
||||||
if data.checkbox
|
|
||||||
table.delegate('[name="bulk_all"]', 'click', (e) ->
|
|
||||||
if $(e.target).attr('checked')
|
|
||||||
$(e.target).parents().find('[name="bulk"]').attr( 'checked', true );
|
|
||||||
else
|
|
||||||
$(e.target).parents().find('[name="bulk"]').attr( 'checked', false );
|
|
||||||
)
|
|
||||||
|
|
||||||
return table
|
|
||||||
|
|
||||||
ticketTableAttributes: (attributes) =>
|
ticketTableAttributes: (attributes) =>
|
||||||
all_attributes = [
|
all_attributes = [
|
||||||
{ name: 'number', link: true, title: 'title' },
|
{ name: 'number', link: true, title: 'title' },
|
||||||
|
|
|
@ -183,11 +183,11 @@ class App.ControllerGenericIndex extends App.Controller
|
||||||
)
|
)
|
||||||
|
|
||||||
# append content table
|
# append content table
|
||||||
table = @table(
|
new App.ControllerTable(
|
||||||
|
el: @el.find('.table-overview'),
|
||||||
model: @genericObject,
|
model: @genericObject,
|
||||||
objects: objects,
|
objects: objects,
|
||||||
)
|
)
|
||||||
@el.find('.table-overview').append(table)
|
|
||||||
|
|
||||||
edit: (e) =>
|
edit: (e) =>
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
|
@ -0,0 +1,132 @@
|
||||||
|
class App.ControllerTable extends App.Controller
|
||||||
|
constructor: (params) ->
|
||||||
|
for key, value of params
|
||||||
|
@[key] = value
|
||||||
|
|
||||||
|
@table = @tableGen(params)
|
||||||
|
if @el
|
||||||
|
@el.append( @table )
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
new App.ControllerTable(
|
||||||
|
header: ['Host', 'User', 'Adapter', 'Active'],
|
||||||
|
overview: ['host', 'user', 'adapter', 'active'],
|
||||||
|
model: App.Channel,
|
||||||
|
objects: data,
|
||||||
|
)
|
||||||
|
|
||||||
|
new App.ControllerTable(
|
||||||
|
overview_extended: [
|
||||||
|
{ name: 'number', link: true },
|
||||||
|
{ name: 'title', link: true },
|
||||||
|
{ name: 'customer', class: 'user-data', data: { id: true } },
|
||||||
|
{ name: 'ticket_state', translate: true },
|
||||||
|
{ name: 'ticket_priority', translate: true },
|
||||||
|
{ name: 'group' },
|
||||||
|
{ name: 'owner', class: 'user-data', data: { id: true } },
|
||||||
|
{ name: 'created_at', callback: @frontendTime },
|
||||||
|
{ name: 'last_contact', callback: @frontendTime },
|
||||||
|
{ name: 'last_contact_agent', callback: @frontendTime },
|
||||||
|
{ name: 'last_contact_customer', callback: @frontendTime },
|
||||||
|
{ name: 'first_response', callback: @frontendTime },
|
||||||
|
{ name: 'close_time', callback: @frontendTime },
|
||||||
|
],
|
||||||
|
model: App.Ticket,
|
||||||
|
objects: tickets,
|
||||||
|
)
|
||||||
|
|
||||||
|
###
|
||||||
|
|
||||||
|
tableGen: (data) ->
|
||||||
|
overview = data.overview || data.model.configure_overview || []
|
||||||
|
attributes = data.attributes || data.model.configure_attributes || {}
|
||||||
|
header = data.header
|
||||||
|
|
||||||
|
if _.isEmpty(data.objects)
|
||||||
|
table = ''
|
||||||
|
table = '-none-'
|
||||||
|
return $(table)
|
||||||
|
|
||||||
|
# define normal header
|
||||||
|
if header
|
||||||
|
header_new = []
|
||||||
|
for key in header
|
||||||
|
header_new.push {
|
||||||
|
display: key
|
||||||
|
}
|
||||||
|
header = header_new
|
||||||
|
else if !data.overview_extended
|
||||||
|
header = []
|
||||||
|
for row in overview
|
||||||
|
if attributes
|
||||||
|
for attribute in attributes
|
||||||
|
if row is attribute.name
|
||||||
|
header.push attribute
|
||||||
|
else
|
||||||
|
rowWithoutId = row + '_id'
|
||||||
|
if rowWithoutId is attribute.name
|
||||||
|
header.push attribute
|
||||||
|
|
||||||
|
dataTypesForCols = []
|
||||||
|
for row in overview
|
||||||
|
dataTypesForCols.push {
|
||||||
|
name: row,
|
||||||
|
link: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
# extended table format
|
||||||
|
if data.overview_extended
|
||||||
|
if !header
|
||||||
|
header = []
|
||||||
|
for row in data.overview_extended
|
||||||
|
for attribute in attributes
|
||||||
|
if row.name is attribute.name
|
||||||
|
header.push attribute
|
||||||
|
else
|
||||||
|
rowWithoutId = row.name + '_id'
|
||||||
|
if rowWithoutId is attribute.name
|
||||||
|
header.push attribute
|
||||||
|
|
||||||
|
dataTypesForCols = data.overview_extended
|
||||||
|
|
||||||
|
# generate content data
|
||||||
|
for object in data.objects
|
||||||
|
|
||||||
|
# check if info for each col. is already there
|
||||||
|
for row in dataTypesForCols
|
||||||
|
|
||||||
|
# lookup relation
|
||||||
|
if !object[row.name]
|
||||||
|
rowWithoutId = row.name + '_id'
|
||||||
|
for attribute in attributes
|
||||||
|
if rowWithoutId is attribute.name
|
||||||
|
if attribute.relation && App[attribute.relation]
|
||||||
|
record = App.Collection.find( attribute.relation, object[rowWithoutId] )
|
||||||
|
object[row.name] = record.name
|
||||||
|
|
||||||
|
@log 'table', 'header', header, 'overview', dataTypesForCols, 'objects', data.objects
|
||||||
|
table = App.view('generic/table')(
|
||||||
|
header: header,
|
||||||
|
overview: dataTypesForCols,
|
||||||
|
objects: data.objects,
|
||||||
|
checkbox: data.checkbox,
|
||||||
|
)
|
||||||
|
# @log 'ttt', $(table).find('span')
|
||||||
|
# $(table).find('span').bind('click', ->
|
||||||
|
# console.log('----------click---------')
|
||||||
|
# )
|
||||||
|
|
||||||
|
# convert to jquery object
|
||||||
|
table = $(table)
|
||||||
|
|
||||||
|
# enable checkbox bulk selection
|
||||||
|
if data.checkbox
|
||||||
|
table.delegate('[name="bulk_all"]', 'click', (e) ->
|
||||||
|
if $(e.target).attr('checked')
|
||||||
|
$(e.target).parents().find('[name="bulk"]').attr( 'checked', true );
|
||||||
|
else
|
||||||
|
$(e.target).parents().find('[name="bulk"]').attr( 'checked', false );
|
||||||
|
)
|
||||||
|
|
||||||
|
return table
|
|
@ -61,12 +61,12 @@ class App.ChannelEmailFilter extends App.Controller
|
||||||
|
|
||||||
html = $('<div></div>')
|
html = $('<div></div>')
|
||||||
|
|
||||||
table = @table(
|
new App.ControllerTable(
|
||||||
|
el: html,
|
||||||
model: App.PostmasterFilter,
|
model: App.PostmasterFilter,
|
||||||
objects: data,
|
objects: data,
|
||||||
)
|
)
|
||||||
|
|
||||||
html.append( table )
|
|
||||||
html.append( '<a data-type="new" class="btn">' + App.i18n.translateContent('New') + '</a>' )
|
html.append( '<a data-type="new" class="btn">' + App.i18n.translateContent('New') + '</a>' )
|
||||||
@html html
|
@html html
|
||||||
|
|
||||||
|
@ -154,12 +154,12 @@ class App.ChannelEmailAddress extends App.Controller
|
||||||
|
|
||||||
html = $('<div></div>')
|
html = $('<div></div>')
|
||||||
|
|
||||||
table = @table(
|
new App.ControllerTable(
|
||||||
|
el: html,
|
||||||
model: App.EmailAddress,
|
model: App.EmailAddress,
|
||||||
objects: data,
|
objects: data,
|
||||||
)
|
)
|
||||||
|
|
||||||
html.append( table )
|
|
||||||
html.append( '<a data-type="new" class="btn">' + App.i18n.translateContent('New') + '</a>' )
|
html.append( '<a data-type="new" class="btn">' + App.i18n.translateContent('New') + '</a>' )
|
||||||
@html html
|
@html html
|
||||||
|
|
||||||
|
@ -245,12 +245,12 @@ class App.ChannelEmailSignature extends App.Controller
|
||||||
|
|
||||||
html = $('<div></div>')
|
html = $('<div></div>')
|
||||||
|
|
||||||
table = @table(
|
new App.ControllerTable(
|
||||||
|
el: html,
|
||||||
model: App.Signature,
|
model: App.Signature,
|
||||||
objects: data,
|
objects: data,
|
||||||
)
|
)
|
||||||
|
|
||||||
html.append( table )
|
|
||||||
html.append( '<a data-type="new" class="btn">' + App.i18n.translateContent('New') + '</a>' )
|
html.append( '<a data-type="new" class="btn">' + App.i18n.translateContent('New') + '</a>' )
|
||||||
@html html
|
@html html
|
||||||
|
|
||||||
|
@ -335,7 +335,6 @@ class App.ChannelEmailInbound extends App.Controller
|
||||||
render: =>
|
render: =>
|
||||||
channels = App.Channel.all()
|
channels = App.Channel.all()
|
||||||
|
|
||||||
html = $('<div></div>')
|
|
||||||
data = []
|
data = []
|
||||||
for channel in channels
|
for channel in channels
|
||||||
if channel.area is 'Email::Inbound'
|
if channel.area is 'Email::Inbound'
|
||||||
|
@ -343,14 +342,15 @@ class App.ChannelEmailInbound extends App.Controller
|
||||||
channel.user = channel.options['user']
|
channel.user = channel.options['user']
|
||||||
data.push channel
|
data.push channel
|
||||||
|
|
||||||
table = @table(
|
html = $('<div></div>')
|
||||||
header: ['Host', 'User', 'Adapter', 'Active'],
|
|
||||||
|
new App.ControllerTable(
|
||||||
|
el: html, header: ['Host', 'User', 'Adapter', 'Active'],
|
||||||
overview: ['host', 'user', 'adapter', 'active'],
|
overview: ['host', 'user', 'adapter', 'active'],
|
||||||
model: App.Channel,
|
model: App.Channel,
|
||||||
objects: data,
|
objects: data,
|
||||||
)
|
)
|
||||||
|
|
||||||
html.append( table )
|
|
||||||
html.append( '<a data-type="new" class="btn">' + App.i18n.translateContent('New') + '</a>' )
|
html.append( '<a data-type="new" class="btn">' + App.i18n.translateContent('New') + '</a>' )
|
||||||
@html html
|
@html html
|
||||||
|
|
||||||
|
|
|
@ -87,19 +87,14 @@ class App.DashboardTicket extends App.Controller
|
||||||
@tickets_in_table.push App.Collection.find( 'Ticket', @ticket_list[ i - 1 ] )
|
@tickets_in_table.push App.Collection.find( 'Ticket', @ticket_list[ i - 1 ] )
|
||||||
|
|
||||||
shown_all_attributes = @ticketTableAttributes( App.Overview.find(@overview.id).view.d.overview )
|
shown_all_attributes = @ticketTableAttributes( App.Overview.find(@overview.id).view.d.overview )
|
||||||
table = @table(
|
new App.ControllerTable(
|
||||||
|
el: html.find('.table-overview'),
|
||||||
overview_extended: shown_all_attributes,
|
overview_extended: shown_all_attributes,
|
||||||
model: App.Ticket,
|
model: App.Ticket,
|
||||||
objects: @tickets_in_table,
|
objects: @tickets_in_table,
|
||||||
checkbox: false,
|
checkbox: false,
|
||||||
)
|
)
|
||||||
|
|
||||||
if _.isEmpty(@ticket_list)
|
|
||||||
table = ''
|
|
||||||
table = '-none-'
|
|
||||||
|
|
||||||
# append content table
|
|
||||||
html.find('.table-overview').append(table)
|
|
||||||
@html html
|
@html html
|
||||||
|
|
||||||
# show frontend times
|
# show frontend times
|
||||||
|
|
|
@ -144,18 +144,17 @@ class Index extends App.Controller
|
||||||
else
|
else
|
||||||
$(e.target).parents().find('[name="bulk"]').attr('checked', false)
|
$(e.target).parents().find('[name="bulk"]').attr('checked', false)
|
||||||
)
|
)
|
||||||
|
@el.find('.table-overview').append(table)
|
||||||
else
|
else
|
||||||
shown_all_attributes = @ticketTableAttributes( App.Overview.find(@overview.id).view.s.overview )
|
shown_all_attributes = @ticketTableAttributes( App.Overview.find(@overview.id).view.s.overview )
|
||||||
table = @table(
|
new App.ControllerTable(
|
||||||
|
el: @el.find('.table-overview'),
|
||||||
overview_extended: shown_all_attributes,
|
overview_extended: shown_all_attributes,
|
||||||
model: App.Ticket,
|
model: App.Ticket,
|
||||||
objects: @ticket_list_show,
|
objects: @ticket_list_show,
|
||||||
checkbox: checkbox,
|
checkbox: checkbox,
|
||||||
)
|
)
|
||||||
|
|
||||||
# append content table
|
|
||||||
@el.find('.table-overview').append(table)
|
|
||||||
|
|
||||||
# start user popups
|
# start user popups
|
||||||
@userPopups()
|
@userPopups()
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,11 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="table_history"></div>
|
<div class="table_history"></div>
|
||||||
<%- @T( 'Merge to Ticket#' ) %>:
|
<h4><%- @T( 'Merge to Ticket#' ) %></h4>
|
||||||
<input type="text" name="master_ticket_number" value=""/>
|
<input type="text" name="master_ticket_number" value=""/>
|
||||||
|
|
||||||
|
<h4><%- @T( 'Recent Customer Tickets' ) %></h4>
|
||||||
|
<div id="ticket-merge-customer-tickets"></div>
|
||||||
<!--
|
<!--
|
||||||
<ul>
|
<ul>
|
||||||
<li>Ticket#</li>
|
<li>Ticket#</li>
|
||||||
|
|
Loading…
Reference in a new issue