Some small bug fixed, improved error handling.
This commit is contained in:
parent
fdbceaf39e
commit
511aa44b7d
9 changed files with 108 additions and 38 deletions
|
@ -707,7 +707,7 @@ class App.ControllerForm extends App.Controller
|
||||||
# richtext
|
# richtext
|
||||||
else if attribute.tag is 'richtext'
|
else if attribute.tag is 'richtext'
|
||||||
item = $( App.view('generic/richtext')( attribute: attribute ) )
|
item = $( App.view('generic/richtext')( attribute: attribute ) )
|
||||||
item.ce(
|
item.find('[contenteditable]').ce(
|
||||||
mode: attribute.type
|
mode: attribute.type
|
||||||
maxlength: attribute.maxlength
|
maxlength: attribute.maxlength
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,12 +2,12 @@ class App.clickCatcher extends Spine.Controller
|
||||||
# clickCatcher has no template because it's a plain <div>
|
# clickCatcher has no template because it's a plain <div>
|
||||||
className: 'clickCatcher'
|
className: 'clickCatcher'
|
||||||
|
|
||||||
constructor: (holder, callback, zIndexScale) ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
@render() if @callback and @holder
|
@render() if @callback and @holder
|
||||||
|
|
||||||
triggerCallback: (event) =>
|
triggerCallback: (e) =>
|
||||||
event.stopPropagation()
|
e.stopPropagation()
|
||||||
@callback()
|
@callback()
|
||||||
@remove()
|
@remove()
|
||||||
|
|
||||||
|
|
|
@ -272,7 +272,7 @@ class App.TicketCreate extends App.Controller
|
||||||
|
|
||||||
# show text module UI
|
# show text module UI
|
||||||
@textModule = new App.WidgetTextModule(
|
@textModule = new App.WidgetTextModule(
|
||||||
el: @el.find('[data-name="body"]')
|
el: @el.find('[data-name="body"]').parent()
|
||||||
)
|
)
|
||||||
|
|
||||||
new Sidebar(
|
new Sidebar(
|
||||||
|
|
|
@ -594,6 +594,7 @@ class App.TicketZoom extends App.Controller
|
||||||
)
|
)
|
||||||
|
|
||||||
taskGet: (area) =>
|
taskGet: (area) =>
|
||||||
|
return {} if !App.TaskManager.get(@task_key)
|
||||||
@localTaskData = App.TaskManager.get(@task_key).state || {}
|
@localTaskData = App.TaskManager.get(@task_key).state || {}
|
||||||
if area
|
if area
|
||||||
if !@localTaskData[area]
|
if !@localTaskData[area]
|
||||||
|
@ -967,11 +968,12 @@ class Edit extends App.Controller
|
||||||
options:
|
options:
|
||||||
duration: duration
|
duration: duration
|
||||||
|
|
||||||
add_textarea_catcher: ->
|
add_textarea_catcher: =>
|
||||||
@textareaCatcher = new App.clickCatcher
|
if @ticketEdit.is(':visible')
|
||||||
holder: @ticketEdit.offsetParent()
|
@textareaCatcher = new App.clickCatcher
|
||||||
callback: @close_textarea
|
holder: @ticketEdit.offsetParent()
|
||||||
zIndexScale: 4
|
callback: @close_textarea
|
||||||
|
zIndexScale: 4
|
||||||
|
|
||||||
remove_textarea_catcher: ->
|
remove_textarea_catcher: ->
|
||||||
return if !@textareaCatcher
|
return if !@textareaCatcher
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
class App.UserOrganizationAutocompletion extends App.Controller
|
class App.UserOrganizationAutocompletion extends App.Controller
|
||||||
|
className: 'dropdown js-recipientDropdown zIndex-2'
|
||||||
events:
|
events:
|
||||||
'hide.bs.dropdown .js-recipientDropdown': 'hideOrganisationMembers'
|
'hide.bs.dropdown .js-recipientDropdown': 'hideOrganisationMembers'
|
||||||
'click .js-organisation': 'showOrganisationMembers'
|
'click .js-organisation': 'showOrganisationMembers'
|
||||||
'click .js-back': 'hideOrganisationMembers'
|
'click .js-back': 'hideOrganisationMembers'
|
||||||
'click .js-user': 'selectUser'
|
'click .js-user': 'selectUser'
|
||||||
'click .js-user-new': 'newUser'
|
'click .js-user-new': 'newUser'
|
||||||
|
'focus input': 'open'
|
||||||
|
|
||||||
constructor: (params) ->
|
constructor: (params) ->
|
||||||
super
|
super
|
||||||
|
@ -18,14 +20,29 @@ class App.UserOrganizationAutocompletion extends App.Controller
|
||||||
element: =>
|
element: =>
|
||||||
@el
|
@el
|
||||||
|
|
||||||
|
open: =>
|
||||||
|
@el.addClass('open')
|
||||||
|
@catcher = new App.clickCatcher
|
||||||
|
holder: @el.offsetParent()
|
||||||
|
callback: @close
|
||||||
|
zIndexScale: 1
|
||||||
|
|
||||||
|
close: =>
|
||||||
|
@el.removeClass('open')
|
||||||
|
if @catcher
|
||||||
|
@catcher.remove()
|
||||||
|
|
||||||
selectUser: (e) ->
|
selectUser: (e) ->
|
||||||
userId = $(e.target).parents('.recipientList-entry').data('user-id')
|
userId = $(e.target).parents('.recipientList-entry').data('user-id')
|
||||||
if !userId
|
if !userId
|
||||||
userId = $(e.target).data('user-id')
|
userId = $(e.target).data('user-id')
|
||||||
|
@setUser(userId)
|
||||||
|
@close()
|
||||||
|
|
||||||
|
setUser: (userId) =>
|
||||||
@el.find('[name="' + @attribute.name + '"]').val( userId ).trigger('change')
|
@el.find('[name="' + @attribute.name + '"]').val( userId ).trigger('change')
|
||||||
|
|
||||||
setUser: ->
|
executeCallback: ->
|
||||||
userId = @el.find('[name="' + @attribute.name + '"]').val()
|
userId = @el.find('[name="' + @attribute.name + '"]').val()
|
||||||
return if !userId
|
return if !userId
|
||||||
return if !App.User.exists(userId)
|
return if !App.User.exists(userId)
|
||||||
|
@ -63,14 +80,17 @@ class App.UserOrganizationAutocompletion extends App.Controller
|
||||||
@el.html App.view('generic/user_search/input')(
|
@el.html App.view('generic/user_search/input')(
|
||||||
attribute: @attribute
|
attribute: @attribute
|
||||||
)
|
)
|
||||||
|
if !@attribute.disableCreateUser
|
||||||
|
@el.find('.recipientList').append( @buildUserNew() )
|
||||||
|
|
||||||
@el.find('[name="' + @attribute.name + '"]').on(
|
@el.find('[name="' + @attribute.name + '"]').on(
|
||||||
'change',
|
'change',
|
||||||
(e) =>
|
(e) =>
|
||||||
@setUser()
|
@executeCallback()
|
||||||
)
|
)
|
||||||
|
|
||||||
@el.find('[name="' + @attribute.name + '_completion"]').on(
|
@el.find('[name="' + @attribute.name + '_completion"]').on(
|
||||||
'keyup',
|
'keydown',
|
||||||
(e) =>
|
(e) =>
|
||||||
item = $(e.target).val().trim()
|
item = $(e.target).val().trim()
|
||||||
|
|
||||||
|
@ -78,14 +98,61 @@ class App.UserOrganizationAutocompletion extends App.Controller
|
||||||
|
|
||||||
# clean input field on ESC
|
# clean input field on ESC
|
||||||
if e.keyCode is 27
|
if e.keyCode is 27
|
||||||
|
|
||||||
|
# if org member selection is shwon, go back to member list
|
||||||
|
if @$('.recipientList-backClickArea').is(':visible')
|
||||||
|
@$('.recipientList-backClickArea').click()
|
||||||
|
return
|
||||||
|
|
||||||
|
# empty user selection and close
|
||||||
$(e.target).val('')
|
$(e.target).val('')
|
||||||
item = ''
|
item = ''
|
||||||
|
@close()
|
||||||
|
|
||||||
# ignore arrow keys
|
# ignore arrow keys
|
||||||
return if e.keyCode is 37
|
if e.keyCode is 37
|
||||||
return if e.keyCode is 38
|
return
|
||||||
return if e.keyCode is 39
|
|
||||||
return if e.keyCode is 40
|
if e.keyCode is 39
|
||||||
|
return
|
||||||
|
|
||||||
|
# up / select upper item
|
||||||
|
if e.keyCode is 38
|
||||||
|
e.preventDefault()
|
||||||
|
recipientList = @$('.recipientList')
|
||||||
|
if recipientList.find('li.is-active').length is 0
|
||||||
|
recipientList.find('li').last().addClass('is-active')
|
||||||
|
else
|
||||||
|
if recipientList.find('li.is-active').prev().length isnt 0
|
||||||
|
recipientList.find('li.is-active').removeClass('is-active').prev().addClass('is-active')
|
||||||
|
return
|
||||||
|
|
||||||
|
# down / select lower item
|
||||||
|
if e.keyCode is 40
|
||||||
|
e.preventDefault()
|
||||||
|
recipientList = @$('.recipientList')
|
||||||
|
if recipientList.find('li.is-active').length is 0
|
||||||
|
recipientList.find('li').first().addClass('is-active')
|
||||||
|
else
|
||||||
|
if recipientList.find('li.is-active').next().length isnt 0
|
||||||
|
recipientList.find('li.is-active').removeClass('is-active').next().addClass('is-active')
|
||||||
|
return
|
||||||
|
|
||||||
|
# enter / take item
|
||||||
|
if e.keyCode is 13
|
||||||
|
e.preventDefault()
|
||||||
|
userId = @$('.recipientList').find('li.is-active').data('user-id')
|
||||||
|
if !userId
|
||||||
|
organisationId = @$('.recipientList').find('li.is-active').data('organisation-id')
|
||||||
|
if organisationId
|
||||||
|
@showOrganisationMembers(undefined, @$('.recipientList').find('li.is-active'))
|
||||||
|
return
|
||||||
|
if userId is 'new'
|
||||||
|
@newUser()
|
||||||
|
else
|
||||||
|
@setUser(userId)
|
||||||
|
@close()
|
||||||
|
return
|
||||||
|
|
||||||
# ignore shift
|
# ignore shift
|
||||||
return if e.keyCode is 16
|
return if e.keyCode is 16
|
||||||
|
@ -97,10 +164,10 @@ class App.UserOrganizationAutocompletion extends App.Controller
|
||||||
return if e.keyCode is 18
|
return if e.keyCode is 18
|
||||||
|
|
||||||
# hide dropdown
|
# hide dropdown
|
||||||
@el.find('.recipientList').html('')
|
@$('.recipientList').empty()
|
||||||
@el.find('.recipientList-organisationMembers').remove()
|
@$('.recipientList-organisationMembers').remove()
|
||||||
if !item && !@attribute.disableCreateUser
|
if !item && !@attribute.disableCreateUser
|
||||||
@el.find('.recipientList').append( @buildUserNew() )
|
@$('.recipientList').append( @buildUserNew() )
|
||||||
|
|
||||||
# show dropdown
|
# show dropdown
|
||||||
if item && ( !@attribute.minLengt || @attribute.minLengt <= item.length )
|
if item && ( !@attribute.minLengt || @attribute.minLengt <= item.length )
|
||||||
|
@ -142,10 +209,11 @@ class App.UserOrganizationAutocompletion extends App.Controller
|
||||||
@el.find('.recipientList').append( @buildUserNew() )
|
@el.find('.recipientList').append( @buildUserNew() )
|
||||||
)
|
)
|
||||||
|
|
||||||
showOrganisationMembers: (e) =>
|
showOrganisationMembers: (e,listEntry) =>
|
||||||
e.stopPropagation()
|
if e
|
||||||
|
e.stopPropagation()
|
||||||
|
listEntry = $(e.currentTarget)
|
||||||
|
|
||||||
listEntry = $(e.currentTarget)
|
|
||||||
organisationId = listEntry.data('organisation-id')
|
organisationId = listEntry.data('organisation-id')
|
||||||
|
|
||||||
@recipientList = @$('.recipientList')
|
@recipientList = @$('.recipientList')
|
||||||
|
@ -195,7 +263,8 @@ class App.UserOrganizationAutocompletion extends App.Controller
|
||||||
complete: => @organisationList.addClass('hide')
|
complete: => @organisationList.addClass('hide')
|
||||||
|
|
||||||
newUser: (e) =>
|
newUser: (e) =>
|
||||||
e.preventDefault()
|
if e
|
||||||
|
e.preventDefault()
|
||||||
new UserNew(
|
new UserNew(
|
||||||
parent: @
|
parent: @
|
||||||
)
|
)
|
||||||
|
@ -249,6 +318,7 @@ class UserNew extends App.ControllerModal
|
||||||
# force to reload object
|
# force to reload object
|
||||||
callbackReload = (user) ->
|
callbackReload = (user) ->
|
||||||
ui.parent.el.find('[name=customer_id]').val( user.id ).trigger('change')
|
ui.parent.el.find('[name=customer_id]').val( user.id ).trigger('change')
|
||||||
|
ui.parent.close()
|
||||||
|
|
||||||
# start customer info controller
|
# start customer info controller
|
||||||
ui.hide()
|
ui.hide()
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
<div contenteditable="true" id="<%= @attribute.id %>" data-name="<%= @attribute.name %>" class="form-control <%= @attribute.class %>"><%= @attribute.value %></div>
|
<div class="richtext">
|
||||||
|
<div contenteditable="true" id="<%= @attribute.id %>" data-name="<%= @attribute.name %>" class="form-control <%= @attribute.class %>"><%= @attribute.value %></div>
|
||||||
|
</div>
|
|
@ -1,12 +1,8 @@
|
||||||
<div class="dropdown js-recipientDropdown">
|
<div class="u-positionOrigin">
|
||||||
|
<input type="hidden" name="<%- @attribute.name %>" value="<%= @attribute.value %>">
|
||||||
<div class="dropdown-toggle u-positionOrigin" data-toggle="dropdown">
|
<input name="<%- @attribute.name %>_completion" class="ui-autocomplete-input form-control" autocapitalize="off" placeholder="<%- @attribute.placeholder %>" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">
|
||||||
<input type="hidden" name="<%- @attribute.name %>" value="<%= @attribute.value %>">
|
</div>
|
||||||
<input name="<%- @attribute.name %>_completion" class="ui-autocomplete-input form-control" autocapitalize="off" placeholder="<%- @attribute.placeholder %>" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">
|
|
||||||
</div>
|
<div class="dropdown-menu" aria-labelledby="customer_id">
|
||||||
|
<ul class="recipientList" role="menu"></ul>
|
||||||
<div class="dropdown-menu" aria-labelledby="customer_id">
|
|
||||||
<ul class="recipientList" role="menu"></ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
|
@ -1,4 +1,4 @@
|
||||||
<li class="recipientList-entry recipientList-new u-clickable horizontal center js-user-new">
|
<li class="recipientList-entry recipientList-new u-clickable horizontal center js-user-new" data-user-id="new">
|
||||||
<div class="recipientList-iconSpacer centered">
|
<div class="recipientList-iconSpacer centered">
|
||||||
<div class="white plus icon"></div>
|
<div class="white plus icon"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -442,7 +442,7 @@ label {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-group .controls {
|
.form-group .controls .richtext {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue