Merge branch 'develop' of github.com:martini/zammad into develop

This commit is contained in:
Felix Niklas 2015-11-05 12:05:54 +01:00
commit 0208186967
4 changed files with 117 additions and 22 deletions

View file

@ -119,7 +119,8 @@ class Navbar extends App.Controller
$(event.currentTarget).addClass('active')
release: =>
$(window).off 'resize.navbar', @autoFoldTabs
if @vertical
$(window).off 'resize.navbar', @autoFoldTabs
if @bindId
App.OverviewIndexCollection.unbind(@bindId)

View file

@ -305,26 +305,28 @@ class App.TicketZoom extends App.Controller
new App.TicketZoomTitle(
ticket: @ticket
overview_id: @overview_id
el: @el.find('.ticket-title')
el: @$('.ticket-title')
task_key: @task_key
)
new App.TicketZoomMeta(
ticket: @ticket
el: @el.find('.ticket-meta')
el: @$('.ticket-meta')
)
new App.TicketZoomAttributeBar(
ticket: @ticket
el: @el.find('.js-attributeBar')
callback: @submit
ticket: @ticket
el: @$('.js-attributeBar')
overview_id: @overview_id
callback: @submit
task_key: @task_key
)
@form_id = App.ControllerForm.formId()
new App.TicketZoomArticleNew(
ticket: @ticket
el: @el.find('.article-new')
el: @$('.article-new')
form_meta: @form_meta
form_id: @form_id
defaults: @taskGet('article')
@ -338,7 +340,7 @@ class App.TicketZoom extends App.Controller
@article_view = new App.TicketZoomArticleView(
ticket: @ticket
el: @el.find('.ticket-article')
el: @$('.ticket-article')
ui: @
highligher: @highligher
)
@ -351,7 +353,7 @@ class App.TicketZoom extends App.Controller
size: 50
)
@sidebar = new App.TicketZoomSidebar(
el: @el.find('.tabsSidebar')
el: @$('.tabsSidebar')
sidebarState: @sidebarState
ticket: @ticket
taskGet: @taskGet
@ -485,6 +487,9 @@ class App.TicketZoom extends App.Controller
submit: (e, macro = {}) =>
e.stopPropagation()
e.preventDefault()
taskAction = @$('.js-secondaryActionButtonLabel').data('type')
ticketParams = @formParam( @$('.edit') )
# validate ticket
@ -638,6 +643,44 @@ class App.TicketZoom extends App.Controller
# reset form after save
@reset()
if taskAction is 'closeNextInOverview'
if @overview_id
current_position = 0
overview = App.Overview.find(@overview_id)
list = App.OverviewCollection.get(overview.link)
for ticket_id in list.ticket_ids
current_position += 1
if ticket_id is @ticket_id
next = list.ticket_ids[current_position]
if next
# close task
App.TaskManager.remove(@task_key)
# open task via task manager to get overview information
App.TaskManager.execute(
key: 'Ticket-' + next
controller: 'TicketZoom'
params:
ticket_id: next
overview_id: @overview_id
show: true
)
@navigate "ticket/zoom/#{next}"
return
# fallback, close task
taskAction = 'closeTab'
if taskAction is 'closeTab'
App.TaskManager.remove(@task_key)
nextTaskUrl = App.TaskManager.nextTaskUrl()
if nextTaskUrl
@navigate nextTaskUrl
return
@navigate '#'
return
@autosaveStart()
App.TaskManager.mute(@task_key)

View file

@ -1,6 +1,7 @@
class App.TicketZoomAttributeBar extends App.Controller
elements:
'.buttonDropdown': 'buttonDropdown'
'.js-submitDropdown': 'buttonDropdown'
'.js-secondaryActionButtonLabel': 'secondaryActionButton'
events:
'mousedown .js-openDropdownMacro': 'toggleDropdownMacro'
@ -8,10 +9,15 @@ class App.TicketZoomAttributeBar extends App.Controller
'mouseup .js-dropdownActionMacro': 'performTicketMacro'
'mouseenter .js-dropdownActionMacro': 'onActionMacroMouseEnter'
'mouseleave .js-dropdownActionMacro': 'onActionMacroMouseLeave'
'click .js-secondaryAction': 'chooseSecondaryAction'
constructor: ->
super
@secondaryAction = @preferencesGet() || 'stayOnTab'
if !@overview_id && @secondaryAction is 'closeNextInOverview'
@secondaryAction = 'closeTab'
@subscribeId = App.Macro.subscribe(@render)
@render()
@ -25,7 +31,9 @@ class App.TicketZoomAttributeBar extends App.Controller
@html App.view('ticket_zoom/attribute_bar')(
macros: macros
macroDisabled: macroDisabled
overview_id: @overview_id
)
@setSecondaryAction()
toggleDropdownMacro: =>
if @buttonDropdown.hasClass 'is-open'
@ -39,8 +47,8 @@ class App.TicketZoomAttributeBar extends App.Controller
$(document).unbind 'click.buttonDropdown'
performTicketMacro: (e) =>
macroId = $(e.target).data('id')
console.log "perform action", @$(e.currentTarget).text(), macroId
macroId = $(e.currentTarget).data('id')
console.log 'perform action', @$(e.currentTarget).text(), macroId
macro = App.Macro.find(macroId)
@callback(e, macro.perform)
@ -50,4 +58,23 @@ class App.TicketZoomAttributeBar extends App.Controller
@$(e.currentTarget).addClass('is-active')
onActionMacroMouseLeave: (e) =>
@$(e.currentTarget).removeClass('is-active')
@$(e.currentTarget).removeClass('is-active')
chooseSecondaryAction: (e) =>
type = $(e.currentTarget).find('.js-secondaryActionLabel').data('type')
@setSecondaryAction(type)
setSecondaryAction: (type = @secondaryAction) =>
element = @$(".js-secondaryActionLabel[data-type=#{type}]")
text = element.text()
@$('.js-secondaryAction .js-selectedIcon.is-selected').removeClass('is-selected')
element.closest('.js-secondaryAction').find('.js-selectedIcon').addClass('is-selected')
@secondaryActionButton.text(text)
@secondaryActionButton.data('type', type)
App.LocalStorage.set(@preferencesStoreKey(), type, @Session.get('id'))
preferencesGet: =>
App.LocalStorage.get(@preferencesStoreKey(), @Session.get('id'))
preferencesStoreKey: =>
"ticketZoom:taskAktion:#{@ticket_id}"

View file

@ -1,14 +1,38 @@
<div class="btn js-reset hide"><%- @T('Discard your unsaved changes.') %></div>
<% if @macroDisabled: %>
<div class="btn btn--primary js-submit"><%- @T('Update') %></div>
<% else: %>
<div class="buttonDropdown dropdown dropup">
<div class="btn btn--primary btn--split--first js-submit"><%- @T('Update') %></div>
<div class="btn btn--primary btn--slim btn--split--last js-openDropdownMacro"><%- @Icon('arrow-up') %></div>
<ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="userAction">
<% for macro in @macros: %>
<li class="js-dropdownActionMacro" role="menuitem" data-id="<%= macro.id %>"><%- @T(macro.displayName()) %>
<div class="buttonDropdown dropdown dropdown--actions dropup">
<div class="btn btn--text btn--icon--last" data-toggle="dropdown">
<span class="js-secondaryActionButtonLabel">xx</span> <%- @Icon('arrow-up') %>
</div>
<ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="secondaryAction">
<li class="js-secondaryAction" role="menuitem">
<span class="js-secondaryActionLabel" data-type="closeTab"><%- @T('Close tab') %></span>
<span class="dropdown-selectedSpacer js-selectedIcon">
<%- @Icon('checkmark') %>
</span>
<% if @overview_id: %>
<li class="js-secondaryAction" role="menuitem">
<span class="js-secondaryActionLabel" data-type="closeNextInOverview"><%- @T('Close & next in overview') %></span>
<span class="dropdown-selectedSpacer js-selectedIcon">
<%- @Icon('checkmark') %>
</span>
<% end %>
<li class="js-secondaryAction" role="menuitem">
<span class="js-secondaryActionLabel" data-type="stayOnTab"><%- @T('Stay on tab') %></span>
<span class="dropdown-selectedSpacer js-selectedIcon">
<%- @Icon('checkmark') %>
</span>
</ul>
</div>
<% if @macroDisabled: %>
<div class="btn btn--primary js-submit"><%- @T('Update') %></div>
<% else: %>
<div class="buttonDropdown dropdown dropup js-submitDropdown">
<div class="btn btn--primary btn--split--first js-submit"><%- @T('Update') %></div>
<div class="btn btn--primary btn--slim btn--split--last js-openDropdownMacro"><%- @Icon('arrow-up') %></div>
<ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="userAction">
<% for macro in @macros: %>
<li class="js-dropdownActionMacro" role="menuitem" data-id="<%= macro.id %>"><%- @T(macro.displayName()) %>
<% end %>
</ul>
</div>
<% end %>