Fixed M-View.
This commit is contained in:
parent
76345309a8
commit
5410205800
8 changed files with 77 additions and 56 deletions
|
@ -124,16 +124,11 @@ class App.Controller extends Spine.Controller
|
|||
dataTypesForCols = data.overview_extended
|
||||
|
||||
# generate content data
|
||||
objects = _.clone( data.objects )
|
||||
for object in objects
|
||||
for object in data.objects
|
||||
|
||||
# check if info for each col. is already there
|
||||
for row in dataTypesForCols
|
||||
|
||||
# execute callback on content
|
||||
if row.callback
|
||||
object[row.name] = row.callback( object[row.name] )
|
||||
|
||||
# lookup relation
|
||||
if !object[row.name]
|
||||
rowWithoutId = row.name + '_id'
|
||||
|
@ -143,11 +138,11 @@ class App.Controller extends Spine.Controller
|
|||
record = App.Collection.find( attribute.relation, object[rowWithoutId] )
|
||||
object[row.name] = record.name
|
||||
|
||||
@log 'table', 'header', header, 'overview', dataTypesForCols, 'objects', objects
|
||||
@log 'table', 'header', header, 'overview', dataTypesForCols, 'objects', data.objects
|
||||
table = App.view('generic/table')(
|
||||
header: header,
|
||||
overview: dataTypesForCols,
|
||||
objects: objects,
|
||||
objects: data.objects,
|
||||
checkbox: data.checkbox,
|
||||
)
|
||||
# @log 'ttt', $(table).find('span')
|
||||
|
|
|
@ -4,7 +4,7 @@ class Index extends App.Controller
|
|||
events:
|
||||
'click [data-type=edit]': 'zoom'
|
||||
'click [data-type=settings]': 'settings'
|
||||
'click [data-type=view-mode]': 'view_mode'
|
||||
'click [data-type=viewmode]': 'viewmode'
|
||||
'click [data-type=page]': 'page'
|
||||
|
||||
constructor: ->
|
||||
|
@ -13,8 +13,8 @@ class Index extends App.Controller
|
|||
# check authentication
|
||||
return if !@authenticate()
|
||||
|
||||
@log 'view:', @view
|
||||
@view_mode = localStorage.getItem( "mode:#{@view}" ) || 's'
|
||||
@log 'view:', @view, @view_mode
|
||||
|
||||
# set title
|
||||
@title ''
|
||||
|
@ -99,6 +99,10 @@ class Index extends App.Controller
|
|||
pages_total = parseInt( ( @tickets_count / @overview.view[@view_mode].per_page ) + 0.99999 ) || 1
|
||||
|
||||
# render init page
|
||||
edit = true
|
||||
if @isRole('Customer')
|
||||
checkbox = false
|
||||
edit = false
|
||||
view_modes = [
|
||||
{
|
||||
name: 'S',
|
||||
|
@ -117,6 +121,7 @@ class Index extends App.Controller
|
|||
pages_total: pages_total,
|
||||
start_page: @start_page,
|
||||
checkbox: true,
|
||||
edit: edit,
|
||||
)
|
||||
html = $(html)
|
||||
# html.find('li').removeClass('active')
|
||||
|
@ -125,10 +130,6 @@ class Index extends App.Controller
|
|||
|
||||
# create table/overview
|
||||
checkbox = true
|
||||
edit = true
|
||||
if @isRole('Customer')
|
||||
checkbox = false
|
||||
edit = false
|
||||
table = ''
|
||||
if @view_mode is 'm'
|
||||
table = App.view('agent_ticket_view/detail')(
|
||||
|
@ -150,7 +151,6 @@ class Index extends App.Controller
|
|||
model: App.Ticket,
|
||||
objects: @ticket_list_show,
|
||||
checkbox: checkbox,
|
||||
edit: edit,
|
||||
)
|
||||
|
||||
# append content table
|
||||
|
@ -183,12 +183,12 @@ class Index extends App.Controller
|
|||
@start_page = id
|
||||
@fetch()
|
||||
|
||||
view_mode: (e) =>
|
||||
viewmode: (e) =>
|
||||
e.preventDefault()
|
||||
@start_page = 1
|
||||
id = $(e.target).data('mode')
|
||||
@view_mode = id
|
||||
localStorage.setItem( "mode:#{@view}", id )
|
||||
mode = $(e.target).data('mode')
|
||||
@view_mode = mode
|
||||
localStorage.setItem( "mode:#{@view}", mode )
|
||||
@fetch()
|
||||
@render()
|
||||
|
||||
|
@ -373,9 +373,12 @@ class Settings extends App.ControllerModal
|
|||
# item_class: 'keepleft',
|
||||
# },
|
||||
]
|
||||
form = @formGen( model: { configure_attributes: @configure_attributes_article } )
|
||||
|
||||
@el.find('.setting').append(form)
|
||||
new App.ControllerForm(
|
||||
el: @el.find('#form-setting'),
|
||||
model: { configure_attributes: @configure_attributes_article },
|
||||
autofocus: false,
|
||||
)
|
||||
|
||||
@modalShow()
|
||||
|
||||
|
|
|
@ -39,17 +39,23 @@ class App extends Spine.Controller
|
|||
template = ( params = {} ) =>
|
||||
|
||||
# define print name helper
|
||||
params.P = ( item ) ->
|
||||
params.P = ( item, row = {} ) ->
|
||||
return item if !item
|
||||
|
||||
# if date is a object, get name of the object
|
||||
if typeof item is 'object'
|
||||
if item.displayNameLong
|
||||
item.displayNameLong()
|
||||
return item.displayNameLong()
|
||||
else if item.displayName
|
||||
item.displayName()
|
||||
else
|
||||
item.name
|
||||
else
|
||||
item
|
||||
return item.displayName()
|
||||
return item.name
|
||||
|
||||
# execute callback on content
|
||||
if row.callback
|
||||
return row.callback( item )
|
||||
|
||||
# return raw data
|
||||
item
|
||||
|
||||
# define translation helper
|
||||
params.T = ( item ) ->
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<ul>
|
||||
<% for item in @view_modes: %>
|
||||
<li class="<%= item.class %>">
|
||||
<a href="#" data-type="view-mode" data-mode="<%= item.type %>"><%= item.name %></a>
|
||||
<a href="#" data-type="viewmode" data-mode="<%= item.type %>"><%= item.name %></a>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
|
|
@ -1,27 +1,45 @@
|
|||
<div>
|
||||
<input type="checkbox" value="" name="bulk_all"/>
|
||||
<% for ticket in @objects: %>
|
||||
<div class="row" data-id="<%= ticket.id %>">
|
||||
<div class="row">
|
||||
<div class="span1">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" value="<%= ticket.id %>" name="bulk" class="keepleft"/>
|
||||
</td>
|
||||
<td>
|
||||
<img class="thumbnail user-data" data-id="<%= ticket.customer_id %>" src="<%= ticket.customer.image %>" alt="">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="span11">
|
||||
<h3><a href="#" data-type="edit"><%= ticket.title %></a> <small><%= ticket.number %></small></h3>
|
||||
<b>State:</b> <%= ticket.ticket_state.name %>
|
||||
<b>Priority:</b> <%= ticket.ticket_priority.name %>
|
||||
<b>Group:</b> <%= ticket.group.name %>
|
||||
<b>Owner:</b> <%= ticket.owner.displayName() %>
|
||||
<input type="checkbox" value="" name="bulk_all"/>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<table class="table table-striped table-hover">
|
||||
<% for ticket in @objects: %>
|
||||
<tr data-id="<%= ticket.id %>">
|
||||
<td class="" style="width: 10px;">
|
||||
<input type="checkbox" value="<%= ticket.id %>" name="bulk" class="keepleft"/>
|
||||
</td>
|
||||
<td class="span1">
|
||||
<img class="thumbnail user-data" data-id="<%= ticket.customer_id %>" src="<%= ticket.customer.image %>" alt="">
|
||||
</td>
|
||||
<td class="span10">
|
||||
<h3><a href="#" data-type="edit"><%= ticket.title %></a> <small><%= ticket.number %> <span class="humanTimeFromNow" data-time="<%= ticket.created_at %>">?</span></small></h3>
|
||||
<div class="row">
|
||||
<div class="span2">
|
||||
<b><%- @T( 'State' ) %></b> <%- @T( ticket.ticket_state.name ) %>
|
||||
</div>
|
||||
<div class="span2">
|
||||
<b><%- @T( 'Group' ) %></b> <%= ticket.group.name %>
|
||||
</div>
|
||||
<div class="span2">
|
||||
<b><%- @T( 'Customer' ) %></b> <%= ticket.customer.displayName() %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span2">
|
||||
<b><%- @T( 'Priority' ) %></b> <%- @T( ticket.ticket_priority.name ) %>
|
||||
</div>
|
||||
<div class="span2">
|
||||
<b><%- @T( 'Owner' ) %></b> <%= ticket.owner.displayName() %>
|
||||
</div>
|
||||
<div class="span2">
|
||||
<b><%- @T( 'Organization' ) %></b> <%= ticket.customer.organization.name %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</div>
|
||||
</table>
|
||||
</div>
|
|
@ -23,12 +23,12 @@
|
|||
</td>
|
||||
<% end %>
|
||||
<% for row in @overview: %>
|
||||
<% displayName = @P( object[row.name] ) %>
|
||||
<% displayName = @P( object[row.name], row ) %>
|
||||
<% if row.translate: %><% displayName = @T( displayName ) %><% end %>
|
||||
<% if row.title: %>
|
||||
<% displayNameTitle = displayName %>
|
||||
<% if object[row.title]: %>
|
||||
<% displayNameTitle = @P( object[row.title] ) %>
|
||||
<% displayNameTitle = @P( object[row.title], row ) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<td <% if row.title: %>title="<%= displayNameTitle %>"<% end %>>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<% if item.navheader: %>
|
||||
<li class="nav-header"><%- @T( item.navheader ) %></li>
|
||||
<% end %>
|
||||
<li class="<% if @active_tab[item.target] : %>active<% end %>"><a href="<%= item.target %>"><%- @T( item.name ) %><% if item['count'] isnt undefined: %><span class="badge count"><%= item['count'] %></span><% end %></a></li>
|
||||
<li class="<% if @active_tab[item.target] : %>active<% end %>"><a href="<%= item.target %>"><%- @T( item.name ) %><% if item['count'] isnt undefined: %><span class="badge count pull-right"><%= item['count'] %></span><% end %></a></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -42,7 +42,7 @@
|
|||
<% if item.navheader: %>
|
||||
<li class="nav-header"><%- @T( item.navheader ) %></li>
|
||||
<% end %>
|
||||
<li class="<% if @active_tab[item.target] : %>active<% end %>"><a href="<%= item.target %>"><%- @T( item.name ) %><% if item['count'] isnt undefined: %><span class="badge count"><%= item['count'] %>)</span><% end %></a></li>
|
||||
<li class="<% if @active_tab[item.target] : %>active<% end %>"><a href="<%= item.target %>"><%- @T( item.name ) %><% if item['count'] isnt undefined: %><span class="badge count pull-right"><%= item['count'] %>)</span><% end %></a></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</li>
|
||||
|
|
|
@ -99,7 +99,6 @@ h3 {
|
|||
}
|
||||
|
||||
.dropdown-menu .count {
|
||||
float: right;
|
||||
padding-top: 1px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue