Replaced App.ControllerModal by App.ControllerModalNice to support also translation inline feature (ctrl+alt+t) for modal dialog screens.

This commit is contained in:
Martin Edenhofer 2015-11-20 02:59:35 +01:00
parent 3a649527bc
commit 8800b6b61a
40 changed files with 589 additions and 646 deletions

View file

@ -152,7 +152,7 @@ class App.Controller extends Spine.Controller
shakeMe( element, position, 20 ) shakeMe( element, position, 20 )
isRole: (name) -> isRole: (name) ->
roles = @Session.get( 'roles' ) roles = @Session.get('roles')
return false if !roles return false if !roles
for role in roles for role in roles
return true if role.name is name return true if role.name is name
@ -568,55 +568,79 @@ class App.ControllerContent extends App.Controller
$('#content').removeClass('hide') $('#content').removeClass('hide')
@navShow() @navShow()
class App.ControllerModal extends App.Controller class App.ControllerModalNice extends App.Controller
elements: backdrop: true
'.modal-body': 'body' keyboard: true
large: false
head: '?'
container: null
buttonClass: 'btn--success'
centerButtons: []
buttonClose: true
buttonCancel: false
buttonSubmit: true
headPrefix: ''
shown: true
events: events:
'submit form': 'onSubmit' 'submit form': 'submit'
'click .js-submit:not(.is-disabled)': 'onSubmit' 'click .js-submit:not(.is-disabled)': 'submit'
'click .js-cancel': 'hide' 'click .js-cancel': 'cancel'
'click .js-close': 'hide' 'click .js-close': 'close'
className: 'modal fade' className: 'modal fade'
constructor: (options = {}) -> constructor: ->
defaults = @className += ' modal--large' if @large
backdrop: true super
keyboard: true
close: true
large: false
head: '?'
buttonClass: 'btn--success'
centerButtons: []
container: null
options = _.extend( defaults, options )
@className += ' modal--large' if options.large
super(options)
# rerender view, e. g. on langauge change
@bind('ui:rerender', =>
@update()
'modal'
)
if @shown if @shown
@show() @render()
show: (content) -> content: ->
if @button is true 'You need to implement a one @content()!'
@button = 'Submit'
@html App.view('modal') update: =>
if @message
content = App.i18n.translateContent(@message)
else if @contentInline
content = @contentInline
else
content = @content()
modal = $(App.view('modal')
head: @head head: @head
headPrefix: @headPrefix
message: @message message: @message
detail: @detail detail: @detail
close: @close buttonClose: @buttonClose
cancel: @cancel buttonCancel: @buttonCancel
button: @button buttonSubmit: @buttonSubmit
buttonClass: @buttonClass buttonClass: @buttonClass
centerButtons: @centerButtons centerButtons: @centerButtons
content: content )
modal.find('.modal-body').html content
if !@initRenderingDone
@initRenderingDone = true
@html modal
else
@$('.modal-dialog').replaceWith(modal)
@post()
if @content post: =>
@body.html @content # nothing
render: =>
if @buttonSubmit is true
@buttonSubmit = 'Submit'
if @buttonCancel is true
@buttonCancel = 'Cancel & Go Back'
@update()
if @container if @container
@el.addClass('modal--local') @el.addClass('modal--local')
@ -629,52 +653,57 @@ class App.ControllerModal extends App.Controller
.on .on
'show.bs.modal': @onShow 'show.bs.modal': @onShow
'shown.bs.modal': @onShown 'shown.bs.modal': @onShown
'hide.bs.modal': @onClose
'hidden.bs.modal': => 'hidden.bs.modal': =>
@onHide() @onClosed()
# remove modal from dom # remove modal from dom
$('.modal').remove() $('.modal').remove()
hide: (e) => close: (e) =>
if e if e
e.preventDefault() e.preventDefault()
@el.modal('hide') @el.modal('hide')
onShown: ->
console.log('modal shown: do nothing')
# do nothing
onShow: -> onShow: ->
console.log('modal rendered: do nothing')
# do nothing # do nothing
onHide: -> onShown: ->
console.log('modal removed: do nothing')
# do nothing # do nothing
onSubmit: (e) => onClose: ->
# do nothing
onClosed: ->
# do nothing
onSubmit: ->
# do nothing
onCancel: ->
# do nothing
cancel: (e) =>
@close(e)
@onCancel(e)
submit: (e) =>
e.preventDefault() e.preventDefault()
if @onSubmitCallback @onSubmit(e)
@onSubmitCallback()
@log 'error', 'You need to implement your own "onSubmit" method!'
class App.ErrorModal extends App.ControllerModal class App.SessionMessage extends App.ControllerModalNice
constructor: -> onCancel: (e) =>
super if @forceReload
@show() @reload(e)
class App.SessionMessage extends App.ControllerModal onClose: (e) =>
constructor: ->
super
@show(@content)
# reload page on modal hidden
onHide: (e) =>
if @forceReload if @forceReload
@reload(e) @reload(e)
onSubmit: (e) => onSubmit: (e) =>
if @forceReload if @forceReload
@reload(e) @reload(e)
else
@close()
reload: (e) -> reload: (e) ->
if e if e

View file

@ -1,25 +1,21 @@
class App.ControllerGenericNew extends App.ControllerModal class App.ControllerGenericNew extends App.ControllerModalNice
constructor: (params) -> buttonClose: true
super buttonCancel: true
buttonSubmit: true
@head = App.i18n.translateContent( 'New' ) + ': ' + App.i18n.translateContent( @pageData.object ) headPrefix: 'New'
@cancel = true
@button = true
content: =>
@head = @pageData.object
controller = new App.ControllerForm( controller = new App.ControllerForm(
model: App[ @genericObject ] model: App[ @genericObject ]
params: @item params: @item
screen: @screen || 'edit' screen: @screen || 'edit'
autofocus: true autofocus: true
) )
controller.form
@content = controller.form
@show()
onSubmit: (e) -> onSubmit: (e) ->
e.preventDefault() params = @formParam(e.target)
params = @formParam( e.target )
object = new App[ @genericObject ] object = new App[ @genericObject ]
object.load(params) object.load(params)
@ -40,22 +36,23 @@ class App.ControllerGenericNew extends App.ControllerModal
done: -> done: ->
if ui.callback if ui.callback
item = App[ ui.genericObject ].fullLocal(@id) item = App[ ui.genericObject ].fullLocal(@id)
ui.callback( item ) ui.callback(item)
ui.hide() ui.close()
fail: -> fail: ->
ui.log 'errors' ui.log 'errors'
ui.hide() ui.close()
) )
class App.ControllerGenericEdit extends App.ControllerModal class App.ControllerGenericEdit extends App.ControllerModalNice
constructor: (params) -> buttonClose: true
super buttonCancel: true
@item = App[ @genericObject ].find( params.id ) buttonSubmit: true
headPrefix: 'Edit'
@head = App.i18n.translateContent( 'Edit' ) + ': ' + App.i18n.translateContent( @pageData.object ) content: =>
@cancel = true @item = App[ @genericObject ].find( @id )
@button = true @head = @pageData.object
controller = new App.ControllerForm( controller = new App.ControllerForm(
model: App[ @genericObject ] model: App[ @genericObject ]
@ -63,12 +60,9 @@ class App.ControllerGenericEdit extends App.ControllerModal
screen: @screen || 'edit' screen: @screen || 'edit'
autofocus: true autofocus: true
) )
@content = controller.form controller.form
@show()
onSubmit: (e) -> onSubmit: (e) ->
e.preventDefault()
params = @formParam(e.target) params = @formParam(e.target)
@item.load(params) @item.load(params)
@ -88,12 +82,12 @@ class App.ControllerGenericEdit extends App.ControllerModal
done: -> done: ->
if ui.callback if ui.callback
item = App[ ui.genericObject ].fullLocal(@id) item = App[ ui.genericObject ].fullLocal(@id)
ui.callback( item ) ui.callback(item)
ui.hide() ui.close()
fail: -> fail: ->
ui.log 'errors' ui.log 'errors'
ui.hide() ui.close()
) )
class App.ControllerGenericIndex extends App.Controller class App.ControllerGenericIndex extends App.Controller
@ -214,19 +208,17 @@ class App.ControllerGenericIndex extends App.Controller
container: @container container: @container
) )
class App.ControllerGenericDescription extends App.ControllerModal class App.ControllerGenericDescription extends App.ControllerModalNice
constructor: -> buttonClose: true
super buttonCancel: false
@head = 'Description' buttonSubmit: 'Close'
@cancel = false head: 'Description'
@button = 'Close'
description = marked(@description)
@show(description) content: =>
marked(@description)
onSubmit: (e) -> onSubmit: =>
e.preventDefault() @close()
@hide()
class App.ControllerModalLoading extends App.Controller class App.ControllerModalLoading extends App.Controller
className: 'modal fade' className: 'modal fade'
@ -270,25 +262,25 @@ class App.ControllerModalLoading extends App.Controller
return return
App.Delay.set(remove, delay * 1000) App.Delay.set(remove, delay * 1000)
class App.ControllerGenericDestroyConfirm extends App.ControllerModal class App.ControllerGenericDestroyConfirm extends App.ControllerModalNice
constructor: -> buttonClose: true
super buttonCancel: true
@head = 'Confirm' buttonSubmit: 'yes'
@cancel = true buttonClass: 'btn--danger'
@button = 'Yes' head: 'Confirm'
@message = 'Sure to delete this object?'
@show()
onSubmit: (e) -> content: =>
e.preventDefault() App.i18n.translateContent('Sure to delete this object?')
onSubmit: =>
@item.destroy( @item.destroy(
done: => done: =>
if @callback if @callback
@callback() @callback()
@hide() @close()
fail: => fail: =>
@log 'errors' @log 'errors'
@hide() @close()
) )
class App.ControllerDrox extends App.Controller class App.ControllerDrox extends App.Controller
@ -439,40 +431,35 @@ class App.ControllerNavSidbar extends App.ControllerContent
el: @$('.main') el: @$('.main')
) )
class App.GenericHistory extends App.ControllerModal class App.GenericHistory extends App.ControllerModalNice
buttonClose: true
buttonCancel: false
buttonSubmit: false
head: 'History'
shown: false
constructor: -> constructor: ->
super super
@head = 'History' @fetch()
@close = true
render: -> content: =>
localItem = @reworkItems(@items)
localItem = @reworkItems( @items ) content = $ App.view('generic/history')(
@content = $ App.view('generic/history')(
items: localItem items: localItem
) )
content.find('a[data-type="sortorder"]').bind('click', (e) =>
@onShow() e.preventDefault()
@sortorder()
@content.find('a[data-type="sortorder"]').bind(
'click',
(e) =>
e.preventDefault()
@sortorder()
) )
if !@isShown content
@isShown = true
@show()
onShow: => onShown: =>
# enable user popups
@userPopups() @userPopups()
sortorder: => sortorder: =>
@items = @items.reverse() @items = @items.reverse()
@update()
@render()
T: (name) -> T: (name) ->
App.i18n.translateInline(name) App.i18n.translateInline(name)

View file

@ -73,15 +73,13 @@ With Filters you can e. g. dispatch new Tickets into certain groups or set a cer
container: @el.closest('.content') container: @el.closest('.content')
) )
class App.ChannelEmailFilterEdit extends App.ControllerModal class App.ChannelEmailFilterEdit extends App.ControllerModalNice
constructor: -> buttonClose: true
super buttonCancel: true
buttonSubmit: true
@head = 'Postmaster Filter' head: 'Postmaster Filter'
@button = true
@close = true
@cancel = true
content: =>
if @object if @object
@form = new App.ControllerForm( @form = new App.ControllerForm(
model: App.PostmasterFilter, model: App.PostmasterFilter,
@ -94,8 +92,7 @@ class App.ChannelEmailFilterEdit extends App.ControllerModal
autofocus: true, autofocus: true,
) )
@content = @form.form @form.form
@show()
onSubmit: (e) => onSubmit: (e) =>
e.preventDefault() e.preventDefault()
@ -108,7 +105,7 @@ class App.ChannelEmailFilterEdit extends App.ControllerModal
object.load(params) object.load(params)
# validate form # validate form
errors = @form.validate( params ) errors = @form.validate(params)
# show errors in form # show errors in form
if errors if errors
@ -122,9 +119,9 @@ class App.ChannelEmailFilterEdit extends App.ControllerModal
# save object # save object
object.save( object.save(
done: => done: =>
@hide() @close()
fail: => fail: =>
@hide() @close()
) )
class App.ChannelEmailSignature extends App.Controller class App.ChannelEmailSignature extends App.Controller
@ -172,15 +169,13 @@ Once you have created a signature here, you need also to edit the groups where y
container: @el.closest('.content') container: @el.closest('.content')
) )
class App.ChannelEmailSignatureEdit extends App.ControllerModal class App.ChannelEmailSignatureEdit extends App.ControllerModalNice
constructor: -> buttonClose: true
super buttonCancel: true
buttonSubmit: true
@head = 'Signature' head: 'Signature'
@button = true
@close = true
@cancel = true
content: =>
if @object if @object
@form = new App.ControllerForm( @form = new App.ControllerForm(
model: App.Signature model: App.Signature
@ -193,12 +188,9 @@ class App.ChannelEmailSignatureEdit extends App.ControllerModal
autofocus: true autofocus: true
) )
@content = @form.form @form.form
@show()
onSubmit: (e) => onSubmit: (e) =>
e.preventDefault()
# get params # get params
params = @formParam(e.target) params = @formParam(e.target)
@ -207,7 +199,7 @@ class App.ChannelEmailSignatureEdit extends App.ControllerModal
object.load(params) object.load(params)
# validate form # validate form
errors = @form.validate( params ) errors = @form.validate(params)
# show errors in form # show errors in form
if errors if errors
@ -221,9 +213,9 @@ class App.ChannelEmailSignatureEdit extends App.ControllerModal
# save object # save object
object.save( object.save(
done: => done: =>
@hide() @close()
fail: => fail: =>
@hide() @formEnable(e)
) )
class App.ChannelEmailAccountOverview extends App.Controller class App.ChannelEmailAccountOverview extends App.Controller
@ -399,15 +391,13 @@ class App.ChannelEmailAccountOverview extends App.Controller
channelDriver: @channelDriver channelDriver: @channelDriver
) )
class App.ChannelEmailEdit extends App.ControllerModal class App.ChannelEmailEdit extends App.ControllerModalNice
constructor: -> buttonClose: true
super buttonCancel: true
buttonSubmit: true
@head = 'Channel' head: 'Channel'
@button = true
@close = true
@cancel = true
content: =>
configureAttributesBase = [ configureAttributesBase = [
{ name: 'group_id', display: 'Destination Group', tag: 'select', null: false, relation: 'Group', nulloption: true }, { name: 'group_id', display: 'Destination Group', tag: 'select', null: false, relation: 'Group', nulloption: true },
] ]
@ -417,18 +407,15 @@ class App.ChannelEmailEdit extends App.ControllerModal
className: '' className: ''
params: @item params: @item
) )
@form.form
@content = @form.form
@show()
onSubmit: (e) => onSubmit: (e) =>
e.preventDefault()
# get params # get params
params = @formParam(e.target) params = @formParam(e.target)
# validate form # validate form
errors = @form.validate( params ) errors = @form.validate(params)
# show errors in form # show errors in form
if errors if errors
@ -448,9 +435,9 @@ class App.ChannelEmailEdit extends App.ControllerModal
processData: true processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
@callback() @callback()
@hide() @close()
fail: => fail: =>
@enable(e) @formEnable(e)
) )
class App.ChannelEmailAccountWizard extends App.Wizard class App.ChannelEmailAccountWizard extends App.Wizard

View file

@ -10,7 +10,7 @@ class App.ChannelForm extends App.Controller
@render() @render()
@updateParams() @updateParams()
new App.SettingsArea( new App.SettingsArea(
el: @el.find('.js-settings') el: @$('.js-settings')
area: 'Form::Base' area: 'Form::Base'
) )
@ -21,16 +21,19 @@ class App.ChannelForm extends App.Controller
updateParams: -> updateParams: ->
quote = (string) -> quote = (string) ->
string.replace('\'', '\\\'') string = string.replace('\'', '\\\'')
.replace(/\</g, '&lt;')
.replace(/\>/g, '&gt;')
params = @formParam(@$('.js-params')) params = @formParam(@$('.js-params'))
paramString = '' paramString = ''
for key, value of params for key, value of params
if paramString != '' if value != ''
paramString += ",\n" if paramString != ''
if value == 'true' || value == 'false' paramString += ",\n"
paramString += " #{key}: #{value}" if value == 'true' || value == 'false'
else paramString += " #{key}: #{value}"
paramString += " #{key}: '#{quote(value)}'" else
paramString += " #{key}: '#{quote(value)}'"
@$('.js-modal-params').html(paramString) @$('.js-modal-params').html(paramString)
App.Config.set( 'Form', { prio: 2000, name: 'Form', parent: '#channels', target: '#channels/form', controller: App.ChannelForm, role: ['Admin'] }, 'NavBarAdmin' ) App.Config.set( 'Form', { prio: 2000, name: 'Form', parent: '#channels', target: '#channels/form', controller: App.ChannelForm, role: ['Admin'] }, 'NavBarAdmin' )

View file

@ -146,20 +146,20 @@ class Index extends App.Controller
App.Config.set( 'Avatar', { prio: 1100, name: 'Avatar', parent: '#profile', target: '#profile/avatar', controller: Index }, 'NavBarProfile' ) App.Config.set( 'Avatar', { prio: 1100, name: 'Avatar', parent: '#profile', target: '#profile/avatar', controller: Index }, 'NavBarProfile' )
class ImageCropper extends App.ControllerModal class ImageCropper extends App.ControllerModalNice
buttonClose: true
buttonCancel: true
buttonSubmit: 'Save'
head: 'Crop Image'
elements: elements:
'.imageCropper-image': 'image' '.imageCropper-image': 'image'
'.imageCropper-holder': 'holder' '.imageCropper-holder': 'holder'
constructor: (options) -> content: =>
super App.view('profile/imageCropper')()
@head = 'Crop Image'
@cancel = true
@button = 'Save'
@buttonClass = 'btn--success'
@show( App.view('profile/imageCropper')() )
post: =>
@size = 256 @size = 256
orientationTransform = orientationTransform =
@ -168,7 +168,7 @@ class ImageCropper extends App.ControllerModal
6: 90 6: 90
8: -90 8: -90
@angle = orientationTransform[ @options.orientation ] @angle = orientationTransform[ @orientation ]
if @angle == undefined if @angle == undefined
@angle = 0 @angle = 0
@ -177,9 +177,9 @@ class ImageCropper extends App.ControllerModal
@isOrientating = true @isOrientating = true
image = new Image() image = new Image()
image.addEventListener 'load', @orientateImage image.addEventListener 'load', @orientateImage
image.src = @options.imageSource image.src = @imageSource
else else
@image.attr src: @options.imageSource @image.attr src: @imageSource
orientateImage: (e) => orientateImage: (e) =>
image = e.currentTarget image = e.currentTarget
@ -215,14 +215,23 @@ class ImageCropper extends App.ControllerModal
minContainerHeight: 300 minContainerHeight: 300
preview: '.imageCropper-preview' preview: '.imageCropper-preview'
onSubmit: (e) => onSubmit: =>
e.preventDefault() @callback( @image.cropper('getCroppedCanvas').toDataURL() )
@options.callback( @image.cropper('getCroppedCanvas').toDataURL() )
@image.cropper('destroy') @image.cropper('destroy')
@hide() @close()
class Camera extends App.ControllerModal class Camera extends App.ControllerModalNice
buttonClose: true
buttonCancel: true
buttonSubmit: 'Save'
buttonClass: 'btn--success is-disabled'
centerButtons: [{
className: 'btn--success js-shoot is-disabled',
text: 'Shoot'
}]
head: 'Camera'
elements: elements:
'.js-shoot': 'shootButton' '.js-shoot': 'shootButton'
'.js-submit': 'submitButton' '.js-submit': 'submitButton'
@ -233,23 +242,14 @@ class Camera extends App.ControllerModal
events: events:
'click .js-shoot:not(.is-disabled)': 'onShootClick' 'click .js-shoot:not(.is-disabled)': 'onShootClick'
constructor: (options) -> content: =>
super App.view('profile/camera')()
post: =>
@size = 256 @size = 256
@photoTaken = false @photoTaken = false
@backgroundColor = 'white' @backgroundColor = 'white'
@head = 'Camera'
@cancel = true
@button = 'Save'
@buttonClass = 'btn--success is-disabled'
@centerButtons = [{
className: 'btn--success js-shoot is-disabled',
text: 'Shoot'
}]
@show( App.view('profile/camera')() )
@ctx = @preview.get(0).getContext('2d') @ctx = @preview.get(0).getContext('2d')
requestWebcam = Modernizr.prefixed('getUserMedia', navigator) requestWebcam = Modernizr.prefixed('getUserMedia', navigator)
@ -312,7 +312,7 @@ class Camera extends App.ControllerModal
'ConstraintNotSatisfiedError': App.i18n.translateInline('No camera found.') 'ConstraintNotSatisfiedError': App.i18n.translateInline('No camera found.')
alert convertToHumanReadable[error.name] alert convertToHumanReadable[error.name]
@hide() @close()
setupPreview: => setupPreview: =>
@video.attr 'height', @size @video.attr 'height', @size
@ -400,14 +400,13 @@ class Camera extends App.ControllerModal
# reset video height # reset video height
@video.attr height: @size @video.attr height: @size
onHide: => onClose: =>
@stream.stop() if @stream @stream.stop() if @stream
@hidden = true @hidden = true
onSubmit: (e) => onSubmit: =>
e.preventDefault()
# send picture to the callback # send picture to the callback
console.log @cache.get(0).toDataURL() console.log @cache.get(0).toDataURL()
window.file = @cache.get(0).toDataURL() window.file = @cache.get(0).toDataURL()
@options.callback @cache.get(0).toDataURL() @callback @cache.get(0).toDataURL()
@hide() @close()

View file

@ -1,73 +1,64 @@
class App.TicketMerge extends App.ControllerModal class App.TicketMerge extends App.ControllerModalNice
buttonClose: true
buttonCancel: true
buttonSubmit: true
head: 'Merge'
shown: false
constructor: -> constructor: ->
super super
@head = 'Merge'
@button = true
@cancel = true
@fetch() @fetch()
fetch: -> fetch: ->
# merge tickets
@ajax( @ajax(
id: 'ticket_related' id: 'ticket_related'
type: 'GET' type: 'GET'
url: @apiPath + '/ticket_related/' + @ticket.id url: "#{@apiPath}/ticket_related/#{@ticket.id}"
processData: true, processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
App.Collection.loadAssets(data.assets)
App.Collection.loadAssets( data.assets )
@ticket_ids_by_customer = data.ticket_ids_by_customer @ticket_ids_by_customer = data.ticket_ids_by_customer
@ticket_ids_recent_viewed = data.ticket_ids_recent_viewed @ticket_ids_recent_viewed = data.ticket_ids_recent_viewed
@render() @render()
) )
render: -> content: =>
content = $( App.view('agent_ticket_merge')() )
@content = $( App.view('agent_ticket_merge')() )
new App.TicketList( new App.TicketList(
el: @content.find('#ticket-merge-customer-tickets') el: content.find('#ticket-merge-customer-tickets')
ticket_ids: @ticket_ids_by_customer ticket_ids: @ticket_ids_by_customer
radio: true radio: true
) )
new App.TicketList( new App.TicketList(
el: @content.find('#ticket-merge-recent-tickets'), el: content.find('#ticket-merge-recent-tickets')
ticket_ids: @ticket_ids_recent_viewed ticket_ids: @ticket_ids_recent_viewed
radio: true radio: true
) )
@content.delegate('[name="master_ticket_number"]', 'focus', (e) -> content.delegate('[name="master_ticket_number"]', 'focus', (e) ->
$(e.target).parents().find('[name="radio"]').prop('checked', false) $(e.target).parents().find('[name="radio"]').prop('checked', false)
) )
@content.delegate('[name="radio"]', 'click', (e) -> content.delegate('[name="radio"]', 'click', (e) ->
if $(e.target).prop('checked') if $(e.target).prop('checked')
ticket_id = $(e.target).val() ticket_id = $(e.target).val()
ticket = App.Ticket.fullLocal( ticket_id ) ticket = App.Ticket.fullLocal(ticket_id)
$(e.target).parents().find('[name="master_ticket_number"]').val( ticket.number ) $(e.target).parents().find('[name="master_ticket_number"]').val(ticket.number)
) )
@show() content
onSubmit: (e) => onSubmit: (e) =>
e.preventDefault()
# disable form
@formDisable(e) @formDisable(e)
params = @formParam(e.target) params = @formParam(e.target)
# merge tickets # merge tickets
@ajax( @ajax(
id: 'ticket_merge', id: 'ticket_merge'
type: 'GET', type: 'GET'
url: @apiPath + '/ticket_merge/' + @ticket.id + '/' + params['master_ticket_number'], url: "#{@apiPath}/ticket_merge/#{@ticket.id}/#{params['master_ticket_number']}"
data: {
# view: @view
}
processData: true, processData: true,
success: (data, status, xhr) => success: (data, status, xhr) =>
@ -78,7 +69,7 @@ class App.TicketMerge extends App.ControllerModal
App.Collection.load( type: 'Ticket', data: [data.slave_ticket] ) App.Collection.load( type: 'Ticket', data: [data.slave_ticket] )
# hide dialog # hide dialog
@hide() @close()
# view ticket # view ticket
@log 'notice', 'nav...', App.Ticket.find( data.master_ticket['id'] ) @log 'notice', 'nav...', App.Ticket.find( data.master_ticket['id'] )
@ -105,4 +96,3 @@ class App.TicketMerge extends App.ControllerModal
error: => error: =>
@formEnable(e) @formEnable(e)
) )

View file

@ -413,23 +413,15 @@ class ContentSidebarRightSidebarOptional extends App.ControllerContent
App.Config.set( 'layout_ref/content_sidebar_right_sidebar_optional', ContentSidebarRightSidebarOptional, 'Routes' ) App.Config.set( 'layout_ref/content_sidebar_right_sidebar_optional', ContentSidebarRightSidebarOptional, 'Routes' )
class ModalForm extends App.ControllerModal class ModalForm extends App.ControllerModalNice
constructor: -> head: '123 some title'
super
@head = '123 some title'
@cancel = true
@button = true
@render() content: ->
render: ->
controller = new App.ControllerForm( controller = new App.ControllerForm(
model: App.User model: App.User
autofocus: true autofocus: true
) )
@content = controller.form controller.form
@show()
onHide: -> onHide: ->
window.history.back() window.history.back()
@ -442,15 +434,10 @@ class ModalForm extends App.ControllerModal
App.Config.set( 'layout_ref/modal_form', ModalForm, 'Routes' ) App.Config.set( 'layout_ref/modal_form', ModalForm, 'Routes' )
class ModalText extends App.ControllerModal class ModalText extends App.ControllerModalNice
constructor: ->
super
@head = '123 some title'
@render() content: ->
App.view('layout_ref/content')()
render: ->
@show( App.view('layout_ref/content')() )
onHide: -> onHide: ->
window.history.back() window.history.back()
@ -458,7 +445,6 @@ class ModalText extends App.ControllerModal
App.Config.set( 'layout_ref/modal_text', ModalText, 'Routes' ) App.Config.set( 'layout_ref/modal_text', ModalText, 'Routes' )
class ContentSidebarTabsRight extends App.ControllerContent class ContentSidebarTabsRight extends App.ControllerContent
elements: elements:
'.tabsSidebar' : 'sidebar' '.tabsSidebar' : 'sidebar'
@ -1380,12 +1366,13 @@ class SlaRef extends App.ControllerContent
checkbox.closest('tr').toggleClass('is-active', checkbox.prop('checked')) checkbox.closest('tr').toggleClass('is-active', checkbox.prop('checked'))
createNew: => createNew: =>
@newItemModal = new App.ControllerModal @newItemModal = new App.ControllerModalNice
head: 'New Service Level Agreement (SLA)' head: 'Service Level Agreement (SLA)'
content: App.view('layout_ref/sla_modal')() headPrefox: 'New'
button: 'Create SLA' contentInline: App.view('layout_ref/sla_modal')()
buttonSubmit: 'Create SLA'
shown: true shown: true
cancel: true buttonCancel: true
container: @el container: @el
onShown: => onShown: =>
@$('.js-responseTime').timepicker @$('.js-responseTime').timepicker
@ -1419,12 +1406,13 @@ class SchedulersRef extends App.ControllerContent
.text(if isInactive then 'Enable' else 'Disable') .text(if isInactive then 'Enable' else 'Disable')
createNew: => createNew: =>
new App.ControllerModal new App.ControllerModalNice
head: 'New Scheduler' head: 'Scheduler'
content: App.view('layout_ref/scheduler_modal')() headPrefix: 'New'
button: 'Create Schedule' buttonSubmit: 'Create'
buttonCancel: true
contentInline: App.view('layout_ref/scheduler_modal')()
shown: true shown: true
cancel: true
container: @el container: @el
select: (event) => select: (event) =>
@ -1655,13 +1643,13 @@ class MergeCustomerRef extends App.ControllerContent
render: -> render: ->
@html App.view('layout_ref/merge_customer_view') @html App.view('layout_ref/merge_customer_view')
new App.ControllerModal new App.ControllerModalNice
large: true large: true
head: "Merge #{@mergeSource.firstname} #{@mergeSource.lastname}" head: "#{@mergeSource.firstname} #{@mergeSource.lastname}"
content: App.view('layout_ref/merge_customer')() headPrefix: 'Merge'
button: 'Merge' contentInline: App.view('layout_ref/merge_customer')()
shown: true buttonSubmit: 'Merge'
cancel: true buttonCancel: true
container: @el container: @el
onChange: -> onChange: ->

View file

@ -152,15 +152,14 @@ class Items extends App.ControllerContent
@load() @load()
) )
class Edit extends App.ControllerModal class Edit extends App.ControllerModalNice
constructor: (params) -> buttonClose: true
super buttonCancel: true
buttonSubmit: true
head: 'Edit'
@head = App.i18n.translateContent( 'Edit' ) content: =>
@cancel = true content = $( App.view('object_manager/edit')(
@button = true
@content = $( App.view('object_manager/edit')(
head: @object head: @object
items: [] items: []
) ) ) )
@ -183,11 +182,11 @@ class Edit extends App.ControllerModal
{ name: 'data_type', display: 'Format', tag: 'select', multiple: false, nulloption: true, null: false, options: options, translate: true }, { name: 'data_type', display: 'Format', tag: 'select', multiple: false, nulloption: true, null: false, options: options, translate: true },
] ]
controller = new App.ControllerForm( controller = new App.ControllerForm(
model: { configure_attributes: configureAttributesTop, className: '' }, model: { configure_attributes: configureAttributesTop, className: '' },
params: item params: item
#screen: @screen || 'edit' #screen: @screen || 'edit'
el: @content.find('.js-top') el: content.find('.js-top')
autofocus: true autofocus: true
) )
# input # input
@ -201,10 +200,10 @@ class Edit extends App.ControllerModal
{ name: 'data_option::note', display: 'Note', tag: 'input', type: 'text', limit: 100, null: true }, { name: 'data_option::note', display: 'Note', tag: 'input', type: 'text', limit: 100, null: true },
] ]
controller = new App.ControllerForm( controller = new App.ControllerForm(
model: { configure_attributes: configureAttributesInput, className: '' }, model: { configure_attributes: configureAttributesInput, className: '' },
params: item params: item
el: @content.find('.js-input') el: content.find('.js-input')
autofocus: true autofocus: true
) )
# textarea # textarea
@ -215,10 +214,10 @@ class Edit extends App.ControllerModal
{ name: 'data_option::note', display: 'autocomplete', tag: 'input', type: 'text', limit: 100, null: true }, { name: 'data_option::note', display: 'autocomplete', tag: 'input', type: 'text', limit: 100, null: true },
] ]
controller = new App.ControllerForm( controller = new App.ControllerForm(
model: { configure_attributes: configureAttributesTextarea, className: '' }, model: { configure_attributes: configureAttributesTextarea, className: '' },
params: item params: item
el: @content.find('.js-textarea') el: content.find('.js-textarea')
autofocus: true autofocus: true
) )
# select # select
@ -233,7 +232,7 @@ class Edit extends App.ControllerModal
controller = new App.ControllerForm( controller = new App.ControllerForm(
model: { configure_attributes: configureAttributesSelect, className: '' }, model: { configure_attributes: configureAttributesSelect, className: '' },
params: item params: item
el: @content.find('.js-select') el: content.find('.js-select')
autofocus: true autofocus: true
) )
@ -245,32 +244,26 @@ class Edit extends App.ControllerModal
}, },
### ###
@content.find('[name=data_type]').on( content.find('[name=data_type]').on(
'change', 'change',
(e) => (e) =>
dataType = $( e.target ).val() dataType = $( e.target ).val()
@content.find('.js-middle > div').addClass('hide') content.find('.js-middle > div').addClass('hide')
@content.find(".js-#{dataType}").removeClass('hide') content.find(".js-#{dataType}").removeClass('hide')
) )
@content.find('[name=data_type]').trigger('change') content.find('[name=data_type]').trigger('change')
configureAttributesBottom = [ configureAttributesBottom = [
{ name: 'active', display: 'Active', tag: 'active', default: true }, { name: 'active', display: 'Active', tag: 'active', default: true },
] ]
controller = new App.ControllerForm( controller = new App.ControllerForm(
model: { configure_attributes: configureAttributesBottom, className: '' }, model: { configure_attributes: configureAttributesBottom, className: '' },
params: item params: item
#screen: @screen || 'edit' #screen: @screen || 'edit'
el: @content.find('.js-bottom') el: content.find('.js-bottom')
) )
#@content = controller.form controller.form
#@show(content)
@show()
App.Config.set( 'SystemObject', { prio: 1700, parent: '#system', name: 'Objects', target: '#system/object_manager', controller: Index, role: ['Admin'] }, 'NavBarAdmin' ) App.Config.set( 'SystemObject', { prio: 1700, parent: '#system', name: 'Objects', target: '#system/object_manager', controller: Index, role: ['Admin'] }, 'NavBarAdmin' )

View file

@ -1,22 +1,11 @@
class App.OrganizationHistory extends App.GenericHistory class App.OrganizationHistory extends App.GenericHistory
constructor: -> fetch: =>
super
@fetch()
fetch: ->
# get data
@ajax( @ajax(
id: 'organization_history' id: 'organization_history'
type: 'GET' type: 'GET'
url: @apiPath + '/organizations/history/' + @organization_id url: "#{@apiPath}/organizations/history/#{@organization_id}"
success: (data, status, xhr) => success: (data, status, xhr) =>
App.Collection.loadAssets(data.assets)
# load assets
App.Collection.loadAssets( data.assets )
@items = data.history @items = data.history
# render page
@render() @render()
) )

View file

@ -108,7 +108,10 @@ class Object extends App.Controller
# start action controller # start action controller
showHistory = -> showHistory = ->
new App.OrganizationHistory( organization_id: organization.id ) new App.OrganizationHistory(
organization_id: organization.id
container: @el.closest('.content')
)
editOrganization = => editOrganization = =>
new App.ControllerGenericEdit( new App.ControllerGenericEdit(
id: organization.id id: organization.id

View file

@ -6,4 +6,4 @@ App.Config.set( 'profile/:target', Index, 'Routes' )
App.Config.set( 'Profile', { prio: 1000, name: 'Profile', target: '#profile' }, 'NavBarProfile' ) App.Config.set( 'Profile', { prio: 1000, name: 'Profile', target: '#profile' }, 'NavBarProfile' )
App.Config.set( 'Profile', { prio: 1700, parent: '#current_user', name: 'Profile', target: '#profile', role: [ 'Agent', 'Customer' ] }, 'NavBarRight' ) App.Config.set( 'Profile', { prio: 1700, parent: '#current_user', name: 'Profile', target: '#profile', translate: true, role: [ 'Agent', 'Customer' ] }, 'NavBarRight' )

View file

@ -112,18 +112,16 @@ class App.TaskbarWidget extends App.Controller
@navigate '#' @navigate '#'
class Remove extends App.ControllerModal class Remove extends App.ControllerModalNice
constructor: -> buttonClose: true
super buttonCancel: true
@head = 'Confirm' buttonSubmit: 'Discared changes'
@message = 'Tab has changed, you really want to close it?' buttonClass: 'btn--danger'
@cancel = true head: 'Confirm'
@close = true
@button = 'Discared changes' content: =>
@buttonClass = 'btn--danger' App.i18n.translateContent('Tab has changed, you really want to close it?')
@show()
onSubmit: (e) => onSubmit: (e) =>
e.preventDefault() @close()
@hide()
@ui.remove(e, @key, true) @ui.remove(e, @key, true)

View file

@ -1,29 +1,21 @@
class App.TicketCustomer extends App.ControllerModal class App.TicketCustomer extends App.ControllerModalNice
constructor: -> buttonClose: true
super buttonCancel: true
buttonSubmit: true
@head = 'Change Customer' head: 'Change Customer'
@close = true
@cancel = true
@button = true
content: =>
configure_attributes = [ configure_attributes = [
{ name: 'customer_id', display: 'Customer', tag: 'user_autocompletion', null: false, placeholder: 'Enter Person or Organization/Company', minLengt: 2, disableCreateUser: true }, { name: 'customer_id', display: 'Customer', tag: 'user_autocompletion', null: false, placeholder: 'Enter Person or Organization/Company', minLengt: 2, disableCreateUser: true },
] ]
controller = new App.ControllerForm( controller = new App.ControllerForm(
model: model:
configure_attributes: configure_attributes, configure_attributes: configure_attributes,
autofocus: true autofocus: true
) )
controller.form
@content = controller.form
@show()
onSubmit: (e) => onSubmit: (e) =>
e.preventDefault()
params = @formParam(e.target) params = @formParam(e.target)
@customer_id = params['customer_id'] @customer_id = params['customer_id']
@ -31,7 +23,7 @@ class App.TicketCustomer extends App.ControllerModal
callback = => callback = =>
# close modal # close modal
@hide() @close()
# update ticket # update ticket
@ticket.updateAttributes( @ticket.updateAttributes(

View file

@ -1,22 +1,11 @@
class App.TicketHistory extends App.GenericHistory class App.TicketHistory extends App.GenericHistory
constructor: -> fetch: =>
super
@fetch()
fetch: ->
# get data
@ajax( @ajax(
id: 'ticket_history', id: 'ticket_history'
type: 'GET', type: 'GET'
url: @apiPath + '/ticket_history/' + @ticket_id, url: "#{@apiPath}/ticket_history/#{@ticket_id}"
success: (data, status, xhr) => success: (data, status, xhr) =>
App.Collection.loadAssets(data.assets)
# load assets
App.Collection.loadAssets( data.assets )
@items = data.history @items = data.history
# render page
@render() @render()
) )

View file

@ -620,10 +620,15 @@ class BulkForm extends App.Controller
msg: App.i18n.translateContent('Bulk-Action executed!') msg: App.i18n.translateContent('Bulk-Action executed!')
} }
class App.OverviewSettings extends App.ControllerModal class App.OverviewSettings extends App.ControllerModalNice
constructor: -> buttonClose: true
super buttonCancel: true
buttonSubmit: true
headPrefix: 'Edit'
content: =>
@overview = App.Overview.find(@overview_id) @overview = App.Overview.find(@overview_id)
@head = @overview.name
@configure_attributes_article = [] @configure_attributes_article = []
if @view_mode is 'd' if @view_mode is 'd'
@ -715,19 +720,13 @@ class App.OverviewSettings extends App.ControllerModal
owner: 'Owner' owner: 'Owner'
}) })
@head = App.i18n.translateContent( 'Edit' ) + ': ' + App.i18n.translateContent( @overview.name )
@close = true
@cancel = true
@button = true
controller = new App.ControllerForm( controller = new App.ControllerForm(
model: { configure_attributes: @configure_attributes_article } model: { configure_attributes: @configure_attributes_article }
autofocus: false autofocus: false
) )
@content = controller.form controller.form
@show()
onSubmit: (e) => onSubmit: (e) =>
e.preventDefault()
params = @formParam(e.target) params = @formParam(e.target)
# check if re-fetch is needed # check if re-fetch is needed
@ -756,8 +755,8 @@ class App.OverviewSettings extends App.ControllerModal
App.OverviewIndexCollection.trigger() App.OverviewIndexCollection.trigger()
App.OverviewCollection.trigger(@overview.link) App.OverviewCollection.trigger(@overview.link)
# hide modal # close modal
@hide() @close()
) )
class TicketOverviewRouter extends App.ControllerPermanent class TicketOverviewRouter extends App.ControllerPermanent

View file

@ -1,22 +1,11 @@
class App.UserHistory extends App.GenericHistory class App.UserHistory extends App.GenericHistory
constructor: -> fetch: =>
super
@fetch()
fetch: ->
# get data
@ajax( @ajax(
id: 'user_history', id: 'user_history'
type: 'GET', type: 'GET'
url: @apiPath + '/users/history/' + @user_id, url: "#{@apiPath}/users/history/#{@user_id}"
success: (data, status, xhr) => success: (data, status, xhr) =>
App.Collection.loadAssets(data.assets)
# load assets
App.Collection.loadAssets( data.assets )
@items = data.history @items = data.history
# render page
@render() @render()
) )

View file

@ -110,8 +110,11 @@ class Object extends App.Controller
}) })
# start action controller # start action controller
showHistory = -> showHistory = =>
new App.UserHistory( user_id: user.id ) new App.UserHistory(
user_id: user.id
container: @el.closest('.content')
)
editUser = => editUser = =>
new App.ControllerGenericEdit( new App.ControllerGenericEdit(

View file

@ -1,7 +1,7 @@
class App.WidgetLink extends App.Controller class App.WidgetLink extends App.Controller
events: events:
'click .js-add': 'add', 'click .js-add': 'add'
'click .js-remove': 'remove', 'click .js-delete': 'delete'
constructor: -> constructor: ->
super super
@ -16,25 +16,20 @@ class App.WidgetLink extends App.Controller
# fetch item on demand # fetch item on demand
# get data # get data
@ajax( @ajax(
id: 'links_' + @object.id + '_' + @object_type, id: "links_#{@object.id}_#{@object_type}"
type: 'GET', type: 'GET'
url: @apiPath + '/links', url: "#{@apiPath}/links"
data: { data:
link_object: @object_type, link_object: @object_type
link_object_value: @object.id, link_object_value: @object.id
} processData: true
processData: true,
success: (data, status, xhr) => success: (data, status, xhr) =>
@links = data.links @links = data.links
App.Collection.loadAssets(data.assets)
# load assets
App.Collection.loadAssets( data.assets )
@render() @render()
) )
render: => render: =>
list = {} list = {}
for item in @links for item in @links
if !list[ item['link_type'] ] if !list[ item['link_type'] ]
@ -51,7 +46,7 @@ class App.WidgetLink extends App.Controller
links: list links: list
) )
remove: (e) => delete: (e) =>
e.preventDefault() e.preventDefault()
link_type = $(e.target).data('link-type') link_type = $(e.target).data('link-type')
link_object_source = $(e.target).data('object') link_object_source = $(e.target).data('object')
@ -61,17 +56,16 @@ class App.WidgetLink extends App.Controller
# get data # get data
@ajax( @ajax(
id: 'links_remove_' + @object.id + '_' + @object_type, id: "links_remove_#{@object.id}_#{@object_type}"
type: 'GET', type: 'GET'
url: @apiPath + '/links/remove', url: "#{@apiPath}/links/remove"
data: { data:
link_type: link_type, link_type: link_type
link_object_source: link_object_source, link_object_source: link_object_source
link_object_source_value: link_object_source_value, link_object_source_value: link_object_source_value
link_object_target: link_object_target, link_object_target: link_object_target
link_object_target_value: link_object_target_value, link_object_target_value: link_object_target_value
} processData: true
processData: true,
success: (data, status, xhr) => success: (data, status, xhr) =>
@fetch() @fetch()
) )
@ -86,42 +80,37 @@ class App.WidgetLink extends App.Controller
container: @container container: @container
) )
class App.LinkAdd extends App.ControllerModal class App.LinkAdd extends App.ControllerModalNice
buttonClose: true
buttonCancel: true
buttonSubmit: true
head: 'Link'
shown: false
constructor: -> constructor: ->
super super
@head = 'Links'
@button = true
@cancel = true
@ticket = @object @ticket = @object
@fetch() @fetch()
fetch: -> fetch: ->
# merge tickets
@ajax( @ajax(
id: 'ticket_related' id: 'ticket_related'
type: 'GET' type: 'GET'
url: @apiPath + '/ticket_related/' + @ticket.id url: "#{@apiPath}/ticket_related/#{@ticket.id}"
processData: true, processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
App.Collection.loadAssets(data.assets)
# load assets
App.Collection.loadAssets( data.assets )
@ticket_ids_by_customer = data.ticket_ids_by_customer @ticket_ids_by_customer = data.ticket_ids_by_customer
@ticket_ids_recent_viewed = data.ticket_ids_recent_viewed @ticket_ids_recent_viewed = data.ticket_ids_recent_viewed
@render() @render()
) )
content: =>
render: -> content = $( App.view('link/add')(
@content = $ App.view('link/add')( link_object: @link_object
link_object: @link_object, link_object_id: @link_object_id
link_object_id: @link_object_id, object: @object
object: @object, ))
)
list = [] list = []
for ticket_id in @ticket_ids_by_customer for ticket_id in @ticket_ids_by_customer
@ -129,11 +118,11 @@ class App.LinkAdd extends App.ControllerModal
ticketItem = App.Ticket.fullLocal( ticket_id ) ticketItem = App.Ticket.fullLocal( ticket_id )
list.push ticketItem list.push ticketItem
new App.ControllerTable( new App.ControllerTable(
el: @content.find('#ticket-merge-customer-tickets'), el: content.find('#ticket-merge-customer-tickets')
overview: [ 'number', 'title', 'state', 'group', 'created_at' ] overview: [ 'number', 'title', 'state', 'group', 'created_at' ]
model: App.Ticket, model: App.Ticket
objects: list, objects: list
radio: true, radio: true
) )
list = [] list = []
@ -142,28 +131,26 @@ class App.LinkAdd extends App.ControllerModal
ticketItem = App.Ticket.fullLocal( ticket_id ) ticketItem = App.Ticket.fullLocal( ticket_id )
list.push ticketItem list.push ticketItem
new App.ControllerTable( new App.ControllerTable(
el: @content.find('#ticket-merge-recent-tickets'), el: content.find('#ticket-merge-recent-tickets')
overview: [ 'number', 'title', 'state', 'group', 'created_at' ] overview: [ 'number', 'title', 'state', 'group', 'created_at' ]
model: App.Ticket, model: App.Ticket
objects: list, objects: list
radio: true, radio: true
) )
@content.delegate('[name="ticket_number"]', 'focus', (e) -> content.delegate('[name="ticket_number"]', 'focus', (e) ->
$(e.target).parents().find('[name="radio"]').prop( 'checked', false ) $(e.target).parents().find('[name="radio"]').prop( 'checked', false )
) )
@content.delegate('[name="radio"]', 'click', (e) -> content.delegate('[name="radio"]', 'click', (e) ->
if $(e.target).prop('checked') if $(e.target).prop('checked')
ticket_id = $(e.target).val() ticket_id = $(e.target).val()
ticket = App.Ticket.fullLocal( ticket_id ) ticket = App.Ticket.fullLocal( ticket_id )
$(e.target).parents().find('[name="ticket_number"]').val( ticket.number ) $(e.target).parents().find('[name="ticket_number"]').val( ticket.number )
) )
content
@show()
onSubmit: (e) => onSubmit: (e) =>
e.preventDefault()
params = @formParam(e.target) params = @formParam(e.target)
if !params['ticket_number'] if !params['ticket_number']
@ -175,18 +162,17 @@ class App.LinkAdd extends App.ControllerModal
# get data # get data
@ajax( @ajax(
id: 'links_add_' + @object.id + '_' + @object_type, id: "links_add_#{@object.id}_#{@object_type}"
type: 'GET', type: 'GET'
url: @apiPath + '/links/add', url: "#{@apiPath}/links/add"
data: { data:
link_type: params['link_type'], link_type: params['link_type']
link_object_target: 'Ticket', link_object_target: 'Ticket'
link_object_target_value: @object.id, link_object_target_value: @object.id
link_object_source: 'Ticket', link_object_source: 'Ticket'
link_object_source_number: params['ticket_number'], link_object_source_number: params['ticket_number']
} processData: true
processData: true,
success: (data, status, xhr) => success: (data, status, xhr) =>
@hide() @close()
@parent.fetch() @parent.fetch()
) )

View file

@ -15,19 +15,21 @@ class Widget extends App.Controller
if message.reload if message.reload
@disconnectClient() @disconnectClient()
button = 'Continue session' button = 'Continue session'
else
button = 'Close'
# convert to html and linkify # convert to html and linkify
message.message = App.Utils.textCleanup( message.message ) message.message = App.Utils.textCleanup( message.message )
message.message = App.Utils.text2html( message.message ) message.message = App.Utils.text2html( message.message )
new App.SessionMessage( new App.SessionMessage(
head: message.head head: message.head
content: message.message contentInline: message.message
keyboard: true keyboard: true
backdrop: true backdrop: true
close: true buttonClose: true
button: button buttonSubmit: button
forceReload: message.reload forceReload: message.reload
) )
App.Config.set( 'maintenance', Widget, 'Widgets' ) App.Config.set( 'maintenance', Widget, 'Widgets' )

View file

@ -39,13 +39,13 @@ class Widget extends App.Controller
# only if new client id isnt own client id # only if new client id isnt own client id
if data.taskbar_id isnt App.TaskManager.TaskbarId() if data.taskbar_id isnt App.TaskManager.TaskbarId()
@error = new App.SessionMessage( @error = new App.SessionMessage(
head: 'Session' head: 'Session'
message: App.i18n.translateInline('A new session with your account was created. This session will be stopped to prevent a conflict.') message: 'A new session with your account was created. This session will be stopped to prevent a conflict.'
keyboard: false keyboard: false
backdrop: true backdrop: true
close: false buttonClose: false
button: 'Continue session' buttonSubmit: 'Continue session'
forceReload: true forceReload: true
) )
@disconnectClient() @disconnectClient()
'maintenance' 'maintenance'

View file

@ -32,11 +32,12 @@ class Widget extends App.Controller
# observe if text has been translated # observe if text has been translated
$('body') $('body')
.on '.translation', 'focus', (e) -> .on 'focus.translation', '.translation', (e) ->
element = $(e.target) element = $(e.target)
element.data 'before', element.html() element.data 'before', element.html()
element element
.on '.translation', 'blur', (e) => .on 'blur.translation', '.translation', (e) =>
console.log('blur')
element = $(e.target) element = $(e.target)
source = element.attr('title') source = element.attr('title')
@ -66,16 +67,17 @@ class Widget extends App.Controller
else else
translation = new App.Translation translation = new App.Translation
translation.load( translation.load(
locale: @locale locale: App.i18n.get()
source: source source: source
target: translation_new target: translation_new
initial_target: ''
) )
translation.save() translation.save()
element element
disable: -> disable: ->
$('body').off('.translation') $('body').off('focus.translation blur.translation')
# disable translation inline # disable translation inline
App.Config.set('translation_inline', false) App.Config.set('translation_inline', false)

View file

@ -20,23 +20,9 @@ class TranslationSupport extends App.Controller
meta = App.i18n.meta() meta = App.i18n.meta()
percent = parseInt( meta.translated / (meta.total / 100) ) percent = parseInt( meta.translated / (meta.total / 100) )
return if percent > 95 return if percent > 95
message = App.i18n.translateContent('Only %s% of this language is translated, help to improve Zammad and complete the translation.', percent)
if percent > 80
message = App.i18n.translateContent('Up to %s% of this language is translated, help to make Zammad even better and complete the translation.', percent)
# show message # show message
modal = new App.ControllerModal( new Modal(percent: percent)
head: App.i18n.translateContent('Help to improve Zammad!')
message: message
cancel: false
close: true
shown: true
button: 'Complete translations'
buttonClass: 'btn--success'
onSubmitCallback: =>
@navigate '#system/translation'
modal.hide()
)
@bind 'i18n:language:change', => @bind 'i18n:language:change', =>
@delay(check, 2500, 'translation_support') @delay(check, 2500, 'translation_support')
@ -44,4 +30,33 @@ class TranslationSupport extends App.Controller
@bind 'auth:login', => @bind 'auth:login', =>
@delay(check, 2500, 'translation_support') @delay(check, 2500, 'translation_support')
App.Config.set( 'translaton_support', TranslationSupport, 'Widgets' ) App.Config.set( 'translaton_support', TranslationSupport, 'Widgets' )
class Modal extends App.ControllerModalNice
buttonClose: true
buttonCancel: 'No Thanks!'
buttonSubmit: 'Complete translations'
head: 'Help to improve Zammad!'
shown: false
constructor: ->
super
return if App.LocalStorage.get('translation_support_no', @Session.get('id'))
@render()
content: =>
better = false
if @percent > 80
better = true
App.view('translation/support')(
percent: @percent
better: better
)
onCancel: =>
App.LocalStorage.set('translation_support_no', true, @Session.get('id'))
@onClose()
onSubmit: =>
@navigate '#system/translation'
@onClose()

View file

@ -73,10 +73,10 @@ class _ajaxSingleton
return if status is 502 return if status is 502
# show error message # show error message
new App.ErrorModal( new App.ControllerModalNice(
message: 'StatusCode: ' + status head: 'StatusCode: ' + status
detail: detail contentInline: '<pre>' + App.Utils.htmlEscape(detail) + '</pre>'
close: true buttonClose: true
) )
) )

View file

@ -40,8 +40,11 @@ class App.Browser
# disable id older # disable id older
if data.browser if data.browser
if map[data.browser.name] && data.browser.major < map[data.browser.name] if map[data.browser.name] && data.browser.major < map[data.browser.name]
@message(data, map[data.browser.name]) new Modal(
console.log('Browser not supported') data: data
version: map[data.browser.name]
)
App.Log.error('Browser', 'Browser not supported')
return false return false
# allow browser # allow browser
@ -73,12 +76,13 @@ class App.Browser
localStorage.setItem('fingerprint', fingerprint) localStorage.setItem('fingerprint', fingerprint)
fingerprint fingerprint
@message: (data, version) -> class Modal extends App.ControllerModalNice
new App.ControllerModal( buttonClose: false
head: 'Browser too old!' buttonCancel: false
message: "Your Browser is not supported (#{data.browser.name} #{data.browser.major} on #{data.os.name}). Please use a newer one (e. g. #{data.browser.name} #{version} or higher)." buttonSubmit: false
close: false backdrop: false
backdrop: false keyboard: false
keyboard: false head: 'Browser too old!'
shown: true
) content: ->
"Your Browser is not supported (#{@data.browser.name} #{@data.browser.major} on #{@data.os.name}). Please use a newer one (e. g. #{@data.browser.name} #{@version} or higher)."

View file

@ -294,26 +294,22 @@ class App.UserOrganizationAutocompletion extends App.Controller
container: @el.closest('.content') container: @el.closest('.content')
) )
class UserNew extends App.ControllerModal class UserNew extends App.ControllerModalNice
constructor: -> buttonClose: true
super buttonCancel: true
@head = 'New User' buttonSubmit: true
@cancel = true head: 'User'
@button = true headPrefix: 'New'
content: ->
controller = new App.ControllerForm( controller = new App.ControllerForm(
model: App.User model: App.User
screen: 'edit' screen: 'edit'
autofocus: true autofocus: true
) )
controller.form
@content = controller.form onSubmit: (e) =>
@show()
onSubmit: (e) ->
e.preventDefault()
params = @formParam(e.target) params = @formParam(e.target)
# if no login is given, use emails as fallback # if no login is given, use emails as fallback
@ -321,8 +317,8 @@ class UserNew extends App.ControllerModal
params.login = params.email params.login = params.email
# find role_id # find role_id
if !params.role_ids || _.isEmpty( params.role_ids ) if !params.role_ids || _.isEmpty(params.role_ids)
role = App.Role.findByAttribute( 'name', 'Customer' ) role = App.Role.findByAttribute('name', 'Customer')
params.role_ids = role.id params.role_ids = role.id
@log 'notice', 'updateAttributes', params @log 'notice', 'updateAttributes', params
@ -346,9 +342,9 @@ class UserNew extends App.ControllerModal
ui.parent.close() ui.parent.close()
# start customer info controller # start customer info controller
ui.hide() ui.close()
App.User.full( @id, callbackReload , true ) App.User.full(@id, callbackReload , true)
fail: -> fail: ->
ui.hide() ui.close()
) )

View file

@ -256,14 +256,7 @@ class _webSocketSingleton extends App.Controller
message = => message = =>
# show reconnect message # show reconnect message
@error = new App.ControllerModal( @error = new Modal()
head: 'Lost network connection!'
message: 'Trying to reconnect...'
backdrop: false
keyboard: false
close: false
shown: true
)
if !@tryToConnect if !@tryToConnect
App.Delay.set message, 7000, 'websocket-no-connection-try-reconnect-message', 'ws' App.Delay.set message, 7000, 'websocket-no-connection-try-reconnect-message', 'ws'
@tryToConnect = true @tryToConnect = true
@ -380,3 +373,14 @@ class _webSocketSingleton extends App.Controller
@_ajaxInit( force: true ) @_ajaxInit( force: true )
@_ajaxReceiveWorking = false @_ajaxReceiveWorking = false
) )
class Modal extends App.ControllerModalNice
buttonClose: false
buttonCancel: false
buttonSubmit: false
backdrop: 'static'
keyboard: false
head: 'Lost network connection!'
content: ->
'Trying to reconnect...'

View file

@ -5,7 +5,7 @@ class App.Calendar extends App.Model
@configure_attributes = [ @configure_attributes = [
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, null: false }, { name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, null: false },
{ name: 'timezone', display: 'Time zone', tag: 'timezone', null: false } { name: 'timezone', display: 'Timezone', tag: 'timezone', null: false }
{ name: 'business_hours', display: 'Business Hours', tag: 'business_hours', null: true } { name: 'business_hours', display: 'Business Hours', tag: 'business_hours', null: true }
{ name: 'ical_url', display: 'Holidays iCalendar Feed', tag: 'ical_feed', placeholder: 'http://example.com/public_holidays.ical', null: true } { name: 'ical_url', display: 'Holidays iCalendar Feed', tag: 'ical_feed', placeholder: 'http://example.com/public_holidays.ical', null: true }
{ name: 'public_holidays',display: 'Holidays', tag: 'holiday_selector', null: true } { name: 'public_holidays',display: 'Holidays', tag: 'holiday_selector', null: true }

View file

@ -1,4 +1,4 @@
class App.Translation extends App.Model class App.Translation extends App.Model
@configure 'Translation', 'source', 'target', 'locale' @configure 'Translation', 'source', 'target', 'target_initial', 'locale'
@extend Spine.Model.Ajax @extend Spine.Model.Ajax
@url: @apiPath + '/translations' @url: @apiPath + '/translations'

View file

@ -22,20 +22,20 @@
<div class="action-flow action-flow--row"> <div class="action-flow action-flow--row">
<div class="action-row"> <div class="action-row">
<div class="action-flow action-flow--noWrap"> <div class="action-flow action-flow--noWrap">
<h2><% if !_.isEmpty(calendar.ical_url): %><span title="<%- @T('Last sync at') %>: <%= @Ttimestamp(calendar.last_sync) %><% if calendar.last_log: %>: <%= calendar.last_log %><% end %>"> <h2><% if !_.isEmpty(calendar.ical_url): %><span title="<%- @Ti('Last sync at') %>: <%- @Ttimestamp(calendar.last_sync) %><% if calendar.last_log: %>: <%= calendar.last_log %><% end %>">
<% if calendar.last_log: %> <% if calendar.last_log: %>
<%- @Icon('status', 'error inline') %> <%- @Icon('status', 'error inline') %>
<% else: %> <% else: %>
<%- @Icon('status', 'ok inline') %> <%- @Icon('status', 'ok inline') %>
<% end %></span><% end %> <%= calendar.name %></h2> <% end %></span><% end %> <%= calendar.name %></h2>
<% if calendar.default: %> <% if calendar.default: %>
<div class="action-label">Default</div> <div class="action-label"><%- @T('Default') %></div>
<% end %> <% end %>
</div> </div>
</div> </div>
<% if calendar.last_log: %><div class="action-row"><div class="alert alert--danger"><%= calendar.last_log %></div></div><% end %> <% if calendar.last_log: %><div class="action-row"><div class="alert alert--danger"><%= calendar.last_log %></div></div><% end %>
<div class="action-row"> <div class="action-row">
<div class="label"><%- @T('Time zone') %></div> <%= calendar.timezone %> <div class="label"><%- @T('Timezone') %></div> <%= calendar.timezone %>
</div> </div>
<div class="action-block action-block--flex"> <div class="action-block action-block--flex">
<div class="label"><%- @T('Business Hours') %></div> <div class="label"><%- @T('Business Hours') %></div>

View file

@ -19,7 +19,7 @@
<label for="form-message-title"><%- @T('Title of the form') %></label> <label for="form-message-title"><%- @T('Title of the form') %></label>
</div> </div>
<div class="controls"> <div class="controls">
<input type="text" id="form-message-title" name="messageTitle" value="<%- @T('Feedback Form') %>"> <input type="text" id="form-message-title" name="messageTitle" value="<%- @Ti('Feedback Form') %>">
</div> </div>
</div> </div>
<div class="input form-group"> <div class="input form-group">
@ -27,7 +27,7 @@
<label for="form-message-submit"><%- @T('Name of form submit button') %></label> <label for="form-message-submit"><%- @T('Name of form submit button') %></label>
</div> </div>
<div class="controls"> <div class="controls">
<input type="text" id="form-message-submit" name="messageSubmit" value="<%- @T('Submit') %>"> <input type="text" id="form-message-submit" name="messageSubmit" value="<%- @Ti('Submit') %>">
</div> </div>
</div> </div>
<div class="input form-group"> <div class="input form-group">
@ -35,7 +35,7 @@
<label for="form-message-thank-you"><%- @T('Message after sending form') %></label> <label for="form-message-thank-you"><%- @T('Message after sending form') %></label>
</div> </div>
<div class="controls"> <div class="controls">
<textarea type="text" id="form-message-thank-you" name="messageThankYou" rows="3"><%- @T('Thank you for your inquiry! We\'ll contact you soon as possible.') %></textarea> <textarea type="text" id="form-message-thank-you" name="messageThankYou" rows="3"><%- @Ti('Thank you for your inquiry! We\'ll contact you soon as possible.') %></textarea>
</div> </div>
</div> </div>
</fieldset> </fieldset>

View file

@ -1,4 +1,4 @@
<p><%= @T(@explanation) %></p> <p><%- @T(@explanation) %></p>
<table class="table table--placeholder"> <table class="table table--placeholder">
<thead><tr><th><%- @T('No Entries') %> <thead><tr><th><%- @T('No Entries') %>

View file

@ -17,7 +17,7 @@
</div> </div>
</div> </div>
<div class="page-header-meta"> <div class="page-header-meta">
<div class="btn btn--action" data-type="settings"><%= @T('Settings') %></div> <div class="btn btn--action" data-type="settings"><%- @T('Settings') %></div>
</div> </div>
</div> </div>
<div class="chat-workspace"></div> <div class="chat-workspace"></div>

View file

@ -16,5 +16,5 @@
</div> </div>
<div class="chat-controls"> <div class="chat-controls">
<div class="chat-input form-control form-control--small form-control--multiline js-customerChatInput" contenteditable="true"></div> <div class="chat-input form-control form-control--small form-control--multiline js-customerChatInput" contenteditable="true"></div>
<div class="btn btn--primary btn--slim btn--small js-send"><%= @T('Send') %></div> <div class="btn btn--primary btn--slim btn--small js-send"><%- @T('Send') %></div>
</div> </div>

View file

@ -2,38 +2,30 @@
<form> <form>
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<% if @close: %> <% if @buttonClose: %>
<div class="modal-close js-close"> <div class="modal-close js-close">
<%- @Icon('diagonal-cross') %> <%- @Icon('diagonal-cross') %>
</div> </div>
<% end %> <% end %>
<h1 class="modal-title"><%- @T( @head ) %></h1> <h1 class="modal-title"><% if @headPrefix: %><%- @T(@headPrefix) %>: <% end %><%- @T(@head) %></h1>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<% if @message: %> <%- @content %>
<p><%= @message %></p>
<% end %>
<% if @detail: %>
<pre><%= @detail %></pre>
<% end %>
<% if @content: %>
<%- @content %>
<% end %>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<% if @cancel: %> <% if @buttonCancel: %>
<div class="modal-leftFooter"> <div class="modal-leftFooter">
<a class="btn btn--text btn--subtle js-cancel align-left" href="#/"><%- @T( 'Cancel & Go Back' ) %></a> <a class="btn btn--text btn--subtle js-cancel align-left" href="#/"><%- @T(@buttonCancel) %></a>
</div> </div>
<% end %> <% end %>
<% for button in @centerButtons: %> <% for button in @centerButtons: %>
<div class="modal-centerFooter"> <div class="modal-centerFooter">
<div class="btn <%= button.className %> align-center"><%- @T( button.text ) %></div> <div class="btn <%= button.className %> align-center"><%- @T(button.text) %></div>
</div> </div>
<% end %> <% end %>
<% if @button: %> <% if @buttonSubmit: %>
<div class="modal-rightFooter"> <div class="modal-rightFooter">
<button type="submit" class="btn <%= @buttonClass %> js-submit align-right"><%- @T( @button ) %></button> <button type="submit" class="btn <%= @buttonClass %> js-submit align-right"><%- @T(@buttonSubmit) %></button>
</div> </div>
<% end %> <% end %>
</div> </div>

View file

@ -1,23 +1,23 @@
<div class="page-header"> <div class="page-header">
<div class="page-header-title"> <div class="page-header-title">
<h1><%= @T('Calendar') %></h1> <h1><%- @T('Calendar') %></h1>
</div> </div>
</div> </div>
<div class="page-content"> <div class="page-content">
<h2><%= @T('Ticket Subscriptions') %></h2> <h2><%- @T('Ticket Subscriptions') %></h2>
<p><%= @T('See your tickets from within your favorite calendar by adding the following url to your calendar app.') %></p> <p><%- @T('See your tickets from within your favorite calendar by adding the following url to your calendar app.') %></p>
<h3><%= @T('URL') %></h3> <h3><%- @T('URL') %></h3>
<input class="form-control js-select" readonly value="<%= @baseurl %>/ical/tickets"> <input class="form-control js-select" readonly value="<%= @baseurl %>/ical/tickets">
<h3><%= @T('Subscription Settings') %></h3> <h3><%- @T('Subscription Settings') %></h3>
<table class="settings-list"> <table class="settings-list">
<thead> <thead>
<tr> <tr>
<th style="white-space: nowrap;"><%= @T('Status Type') %> <th style="white-space: nowrap;"><%- @T('Status Type') %>
<th colspan="2"><%= @T('Options') %> <th colspan="2"><%- @T('Options') %>
<th width="100%"><%= @T('Direct URL') %> <th width="100%"><%- @T('Direct URL') %>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -30,18 +30,18 @@
<input type="checkbox" name="<%= stateType %>/own"<%= if options.own then ' checked' %>> <input type="checkbox" name="<%= stateType %>/own"<%= if options.own then ' checked' %>>
<%- @Icon('checkbox', 'icon-unchecked') %> <%- @Icon('checkbox', 'icon-unchecked') %>
<%- @Icon('checkbox-checked', 'icon-checked') %> <%- @Icon('checkbox-checked', 'icon-checked') %>
<span class="label-text"><%= @T('own tickets') %></span> <span class="label-text"><%- @T('own tickets') %></span>
</label> </label>
<td> <td>
<label class="inline-label checkbox-replacement"> <label class="inline-label checkbox-replacement">
<input type="checkbox" name="<%= stateType %>/not_assigned"<%= if options.not_assigned then ' checked' %>> <input type="checkbox" name="<%= stateType %>/not_assigned"<%= if options.not_assigned then ' checked' %>>
<%- @Icon('checkbox', 'icon-unchecked') %> <%- @Icon('checkbox', 'icon-unchecked') %>
<%- @Icon('checkbox-checked', 'icon-checked') %> <%- @Icon('checkbox-checked', 'icon-checked') %>
<span class="label-text"><%= @T('not assigned tickets') %></span> <span class="label-text"><%- @T('not assigned tickets') %></span>
</label> </label>
<td> <td>
<div class="btn btn--table btn--text js-showLink"><%= @T('Show') %></div> <div class="btn btn--table btn--text js-showLink"><%- @T('Show') %></div>
<input class="form-control form-control--borderless js-select is-hidden" readonly value="<%= @baseurl %>/ical/tickets/<%= stateType %>"> <input class="form-control form-control--borderless js-select is-hidden" readonly value="<%- @baseurl %>/ical/tickets/<%= stateType %>">
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>

View file

@ -4,7 +4,7 @@
<% for profile in @profiles: %> <% for profile in @profiles: %>
<% for backend in @metric.backend: %> <% for backend in @metric.backend: %>
<% if backend.dataDownload: %> <% if backend.dataDownload: %>
<li <% if backend.name is @downloadBackendSelected: %>class="is-active active"<% end %>><a href="#" class="js-dataDownloadBackendSelector" data-toggle="tab" data-profile-id="<%= profile.id %>" data-backend="<%= backend.name %>"><%= @T(backend.display) %></a></li> <li <% if backend.name is @downloadBackendSelected: %>class="is-active active"<% end %>><a href="#" class="js-dataDownloadBackendSelector" data-toggle="tab" data-profile-id="<%= profile.id %>" data-backend="<%= backend.name %>"><%- @T(backend.display) %></a></li>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>

View file

@ -40,6 +40,8 @@ dedicated:
{}, {},
{ {
json: true, json: true,
open_timeout: 6,
read_timeout: 16,
} }
) )
fail "Can't load translations from #{url}: #{result.error}" if !result.success? fail "Can't load translations from #{url}: #{result.error}" if !result.success?
@ -114,6 +116,8 @@ push translations to online
}, },
{ {
json: true, json: true,
open_timeout: 6,
read_timeout: 16,
} }
) )
fail "Can't push translations to #{url}: #{result.error}" if !result.success? fail "Can't push translations to #{url}: #{result.error}" if !result.success?

View file

@ -11,16 +11,16 @@ class UserAgent
get http/https calls get http/https calls
result = UserAgent.get( 'http://host/some_dir/some_file?param1=123' ) result = UserAgent.get('http://host/some_dir/some_file?param1=123')
result = UserAgent.get( result = UserAgent.get(
'http://host/some_dir/some_file?param1=123', 'http://host/some_dir/some_file?param1=123',
{ {
:param1 => 'some value', param1: 'some value',
}, },
{ {
:open_timeout => 2, open_timeout: 4,
:read_timeout => 4, read_timeout: 10,
}, },
) )
@ -34,7 +34,7 @@ get json object
'http://host/some_dir/some_file?param1=123', 'http://host/some_dir/some_file?param1=123',
{}, {},
{ {
:json => true, json: true,
} }
) )
@ -49,7 +49,7 @@ returns
http = get_http(uri, options) http = get_http(uri, options)
# prepare request # prepare request
request = Net::HTTP::Get.new( uri, { 'User-Agent' => 'Zammad User Agent' } ) request = Net::HTTP::Get.new(uri, { 'User-Agent' => 'Zammad User Agent' })
# http basic auth (if needed) # http basic auth (if needed)
request = set_basic_auth(request, options) request = set_basic_auth(request, options)
@ -77,12 +77,12 @@ post http/https calls
result = UserAgent.post( result = UserAgent.post(
'http://host/some_dir/some_file', 'http://host/some_dir/some_file',
{ {
:param1 => 1, param1: 1,
:param2 => 2, param2: 2,
}, },
{ {
:open_timeout => 2, open_timeout: 4,
:read_timeout => 4, read_timeout: 10,
}, },
) )
@ -97,7 +97,7 @@ returns
http = get_http(uri, options) http = get_http(uri, options)
# prepare request # prepare request
request = Net::HTTP::Post.new( uri, { 'User-Agent' => 'Zammad User Agent' } ) request = Net::HTTP::Post.new(uri, { 'User-Agent' => 'Zammad User Agent' })
# set params # set params
request = set_params(request, params, options) request = set_params(request, params, options)
@ -125,12 +125,12 @@ put http/https calls
result = UserAgent.put( result = UserAgent.put(
'http://host/some_dir/some_file', 'http://host/some_dir/some_file',
{ {
:param1 => 1, param1: 1,
:param2 => 2, param2: 2,
}, },
{ {
:open_timeout => 2, open_timeout: 4,
:read_timeout => 4, read_timeout: 10,
}, },
) )
@ -145,7 +145,7 @@ returns
http = get_http(uri, options) http = get_http(uri, options)
# prepare request # prepare request
request = Net::HTTP::Put.new( uri, { 'User-Agent' => 'Zammad User Agent' } ) request = Net::HTTP::Put.new(uri, { 'User-Agent' => 'Zammad User Agent' })
# set params # set params
request = set_params(request, params, options) request = set_params(request, params, options)
@ -173,8 +173,8 @@ delete http/https calls
result = UserAgent.delete( result = UserAgent.delete(
'http://host/some_dir/some_file', 'http://host/some_dir/some_file',
{ {
:open_timeout => 2, open_timeout: 4,
:read_timeout => 4, read_timeout: 10,
}, },
) )
@ -189,7 +189,7 @@ returns
http = get_http(uri, options) http = get_http(uri, options)
# prepare request # prepare request
request = Net::HTTP::Delete.new( uri, { 'User-Agent' => 'Zammad User Agent' } ) request = Net::HTTP::Delete.new(uri, { 'User-Agent' => 'Zammad User Agent' })
# http basic auth (if needed) # http basic auth (if needed)
request = set_basic_auth(request, options) request = set_basic_auth(request, options)
@ -211,18 +211,18 @@ returns
perform get http/https/ftp calls perform get http/https/ftp calls
result = UserAgent.request( 'ftp://host/some_dir/some_file.bin' ) result = UserAgent.request('ftp://host/some_dir/some_file.bin')
result = UserAgent.request( 'http://host/some_dir/some_file.bin' ) result = UserAgent.request('http://host/some_dir/some_file.bin')
result = UserAgent.request( 'https://host/some_dir/some_file.bin' ) result = UserAgent.request('https://host/some_dir/some_file.bin')
# get request # get request
result = UserAgent.request( result = UserAgent.request(
'http://host/some_dir/some_file?param1=123', 'http://host/some_dir/some_file?param1=123',
{ {
:open_timeout => 2, open_timeout: 4,
:read_timeout => 4, read_timeout: 10,
}, },
) )
@ -239,7 +239,7 @@ returns
when /ftp/ when /ftp/
ftp(uri, options) ftp(uri, options)
when /http|https/ when /http|https/
get( url, {}, options ) get(url, {}, options)
end end
end end
@ -276,7 +276,7 @@ returns
end end
else else
if !params.empty? if !params.empty?
request.set_form_data( params ) request.set_form_data(params)
end end
end end
request request
@ -317,7 +317,7 @@ returns
when Net::HTTPOK when Net::HTTPOK
data = nil data = nil
if options[:json] && !options[:jsonParseDisable] && response.body if options[:json] && !options[:jsonParseDisable] && response.body
data = JSON.parse( response.body ) data = JSON.parse(response.body)
end end
return Result.new( return Result.new(
data: data, data: data,
@ -329,7 +329,7 @@ returns
when Net::HTTPCreated when Net::HTTPCreated
data = nil data = nil
if options[:json] && !options[:jsonParseDisable] && response.body if options[:json] && !options[:jsonParseDisable] && response.body
data = JSON.parse( response.body ) data = JSON.parse(response.body)
end end
return Result.new( return Result.new(
data: data, data: data,
@ -355,14 +355,14 @@ returns
Net::FTP.open(host) do |ftp| Net::FTP.open(host) do |ftp|
ftp.passive = true ftp.passive = true
if options[:user] && options[:password] if options[:user] && options[:password]
ftp.login( options[:user], options[:password] ) ftp.login(options[:user], options[:password])
else else
ftp.login ftp.login
end end
ftp.chdir(remote_dir) unless remote_dir == '.' ftp.chdir(remote_dir) unless remote_dir == '.'
begin begin
ftp.getbinaryfile( filename, temp_file ) ftp.getbinaryfile(filename, temp_file)
rescue => e rescue => e
return Result.new( return Result.new(
error: e.inspect, error: e.inspect,

View file

@ -4,5 +4,5 @@
<span class="zammad-chat-loading-circle"></span> <span class="zammad-chat-loading-circle"></span>
<span class="zammad-chat-loading-circle"></span> <span class="zammad-chat-loading-circle"></span>
</span> </span>
<span class="zammad-chat-modal-text"><%= @T('Connecting') %></span> <span class="zammad-chat-modal-text"><%- @T('Connecting') %></span>
</div> </div>

View file

@ -1,6 +1,6 @@
<div class="zammad-chat-modal"> <div class="zammad-chat-modal">
<div class="zammad-chat-modal-text"> <div class="zammad-chat-modal-text">
<%- @T('Since you didn\'t respond in the last %s your conversation with <strong>%s</strong> got closed.', "#{ @delay } #{ @unit }", @agent) %><br> <%- @T('Since you didn\'t respond in the last %s your conversation with <strong>%s</strong> got closed.', "#{ @delay } #{ @unit }", @agent) %><br>
<div class="zammad-chat-button"<%= " style='background: #{ @background }'" if @background %>><%= @T('Start new conversation') %></div> <div class="zammad-chat-button"<%= " style='background: #{ @background }'" if @background %>><%- @T('Start new conversation') %></div>
</div> </div>
</div> </div>