From 8800b6b61a03a6251643fb2200558d47555f59db Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 20 Nov 2015 02:59:35 +0100 Subject: [PATCH] Replaced App.ControllerModal by App.ControllerModalNice to support also translation inline feature (ctrl+alt+t) for modal dialog screens. --- .../_application_controller.coffee | 147 +++++++++++------- .../_application_controller_generic.coffee | 137 ++++++++-------- .../app/controllers/_channel/email.coffee | 73 ++++----- .../app/controllers/_channel/form.coffee | 19 ++- .../app/controllers/_profile/avatar.coffee | 71 +++++---- .../app/controllers/agent_ticket_merge.coffee | 56 +++---- .../app/controllers/layout_ref.coffee | 62 +++----- .../app/controllers/object_manager.coffee | 67 ++++---- .../controllers/organization_history.coffee | 19 +-- .../controllers/organization_profile.coffee | 5 +- .../app/controllers/profile.coffee | 2 +- .../app/controllers/taskbar_widget.coffee | 22 ++- .../app/controllers/ticket_customer.coffee | 24 +-- .../app/controllers/ticket_history.coffee | 23 +-- .../app/controllers/ticket_overview.coffee | 23 ++- .../app/controllers/user_history.coffee | 21 +-- .../app/controllers/user_profile.coffee | 7 +- .../app/controllers/widget/link.coffee | 132 +++++++--------- .../app/controllers/widget/maintenance.coffee | 16 +- .../widget/session_taken_over.coffee | 14 +- .../widget/translation_inline.coffee | 14 +- .../widget/translation_support.coffee | 47 ++++-- .../javascripts/app/lib/app_post/ajax.coffee | 8 +- .../app/lib/app_post/browser.coffee.coffee | 26 ++-- .../user_organization_autocompletion.coffee | 40 +++-- .../app/lib/app_post/websocket.coffee | 20 ++- .../javascripts/app/models/calendar.coffee | 2 +- .../javascripts/app/models/translation.coffee | 2 +- .../app/views/calendar/index.jst.eco | 6 +- .../app/views/channel/form.jst.eco | 6 +- .../app/views/generic/admin/empty.jst.eco | 2 +- .../views/layout_ref/customer_chat.jst.eco | 2 +- .../layout_ref/customer_chat_window.jst.eco | 2 +- .../javascripts/app/views/modal.jst.eco | 24 +-- .../profile/calendar_subscriptions.jst.eco | 24 +-- .../app/views/report/download_header.jst.eco | 2 +- app/models/translation.rb | 4 + lib/user_agent.rb | 60 +++---- public/assets/chat/views/loader.eco | 2 +- public/assets/chat/views/timeout.eco | 2 +- 40 files changed, 589 insertions(+), 646 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller.coffee b/app/assets/javascripts/app/controllers/_application_controller.coffee index baf264dee..804efc241 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.coffee @@ -152,7 +152,7 @@ class App.Controller extends Spine.Controller shakeMe( element, position, 20 ) isRole: (name) -> - roles = @Session.get( 'roles' ) + roles = @Session.get('roles') return false if !roles for role in roles return true if role.name is name @@ -568,55 +568,79 @@ class App.ControllerContent extends App.Controller $('#content').removeClass('hide') @navShow() -class App.ControllerModal extends App.Controller - elements: - '.modal-body': 'body' +class App.ControllerModalNice extends App.Controller + backdrop: true + keyboard: true + large: false + head: '?' + container: null + buttonClass: 'btn--success' + centerButtons: [] + buttonClose: true + buttonCancel: false + buttonSubmit: true + headPrefix: '' + shown: true events: - 'submit form': 'onSubmit' - 'click .js-submit:not(.is-disabled)': 'onSubmit' - 'click .js-cancel': 'hide' - 'click .js-close': 'hide' + 'submit form': 'submit' + 'click .js-submit:not(.is-disabled)': 'submit' + 'click .js-cancel': 'cancel' + 'click .js-close': 'close' className: 'modal fade' - constructor: (options = {}) -> - defaults = - backdrop: true - 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) + constructor: -> + @className += ' modal--large' if @large + super + # rerender view, e. g. on langauge change + @bind('ui:rerender', => + @update() + 'modal' + ) if @shown - @show() + @render() - show: (content) -> - if @button is true - @button = 'Submit' + content: -> + 'You need to implement a one @content()!' - @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 + headPrefix: @headPrefix message: @message detail: @detail - close: @close - cancel: @cancel - button: @button + buttonClose: @buttonClose + buttonCancel: @buttonCancel + buttonSubmit: @buttonSubmit buttonClass: @buttonClass centerButtons: @centerButtons - content: content + ) + modal.find('.modal-body').html content + if !@initRenderingDone + @initRenderingDone = true + @html modal + else + @$('.modal-dialog').replaceWith(modal) + @post() - if @content - @body.html @content + post: => + # nothing + + render: => + if @buttonSubmit is true + @buttonSubmit = 'Submit' + if @buttonCancel is true + @buttonCancel = 'Cancel & Go Back' + + @update() if @container @el.addClass('modal--local') @@ -629,52 +653,57 @@ class App.ControllerModal extends App.Controller .on 'show.bs.modal': @onShow 'shown.bs.modal': @onShown + 'hide.bs.modal': @onClose 'hidden.bs.modal': => - @onHide() + @onClosed() # remove modal from dom $('.modal').remove() - hide: (e) => + close: (e) => if e e.preventDefault() @el.modal('hide') - onShown: -> - console.log('modal shown: do nothing') - # do nothing - onShow: -> - console.log('modal rendered: do nothing') # do nothing - onHide: -> - console.log('modal removed: do nothing') + onShown: -> # 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() - if @onSubmitCallback - @onSubmitCallback() - @log 'error', 'You need to implement your own "onSubmit" method!' + @onSubmit(e) -class App.ErrorModal extends App.ControllerModal - constructor: -> - super - @show() +class App.SessionMessage extends App.ControllerModalNice + onCancel: (e) => + if @forceReload + @reload(e) -class App.SessionMessage extends App.ControllerModal - constructor: -> - super - @show(@content) - - # reload page on modal hidden - onHide: (e) => + onClose: (e) => if @forceReload @reload(e) onSubmit: (e) => if @forceReload @reload(e) + else + @close() reload: (e) -> if e diff --git a/app/assets/javascripts/app/controllers/_application_controller_generic.coffee b/app/assets/javascripts/app/controllers/_application_controller_generic.coffee index 26f371286..fb2394aab 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_generic.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_generic.coffee @@ -1,25 +1,21 @@ -class App.ControllerGenericNew extends App.ControllerModal - constructor: (params) -> - super - - @head = App.i18n.translateContent( 'New' ) + ': ' + App.i18n.translateContent( @pageData.object ) - @cancel = true - @button = true +class App.ControllerGenericNew extends App.ControllerModalNice + buttonClose: true + buttonCancel: true + buttonSubmit: true + headPrefix: 'New' + content: => + @head = @pageData.object controller = new App.ControllerForm( model: App[ @genericObject ] params: @item screen: @screen || 'edit' autofocus: true ) - - @content = controller.form - - @show() + controller.form onSubmit: (e) -> - e.preventDefault() - params = @formParam( e.target ) + params = @formParam(e.target) object = new App[ @genericObject ] object.load(params) @@ -40,22 +36,23 @@ class App.ControllerGenericNew extends App.ControllerModal done: -> if ui.callback item = App[ ui.genericObject ].fullLocal(@id) - ui.callback( item ) - ui.hide() + ui.callback(item) + ui.close() fail: -> ui.log 'errors' - ui.hide() + ui.close() ) -class App.ControllerGenericEdit extends App.ControllerModal - constructor: (params) -> - super - @item = App[ @genericObject ].find( params.id ) +class App.ControllerGenericEdit extends App.ControllerModalNice + buttonClose: true + buttonCancel: true + buttonSubmit: true + headPrefix: 'Edit' - @head = App.i18n.translateContent( 'Edit' ) + ': ' + App.i18n.translateContent( @pageData.object ) - @cancel = true - @button = true + content: => + @item = App[ @genericObject ].find( @id ) + @head = @pageData.object controller = new App.ControllerForm( model: App[ @genericObject ] @@ -63,12 +60,9 @@ class App.ControllerGenericEdit extends App.ControllerModal screen: @screen || 'edit' autofocus: true ) - @content = controller.form - - @show() + controller.form onSubmit: (e) -> - e.preventDefault() params = @formParam(e.target) @item.load(params) @@ -88,12 +82,12 @@ class App.ControllerGenericEdit extends App.ControllerModal done: -> if ui.callback item = App[ ui.genericObject ].fullLocal(@id) - ui.callback( item ) - ui.hide() + ui.callback(item) + ui.close() fail: -> ui.log 'errors' - ui.hide() + ui.close() ) class App.ControllerGenericIndex extends App.Controller @@ -214,19 +208,17 @@ class App.ControllerGenericIndex extends App.Controller container: @container ) -class App.ControllerGenericDescription extends App.ControllerModal - constructor: -> - super - @head = 'Description' - @cancel = false - @button = 'Close' - description = marked(@description) +class App.ControllerGenericDescription extends App.ControllerModalNice + buttonClose: true + buttonCancel: false + buttonSubmit: 'Close' + head: 'Description' - @show(description) + content: => + marked(@description) - onSubmit: (e) -> - e.preventDefault() - @hide() + onSubmit: => + @close() class App.ControllerModalLoading extends App.Controller className: 'modal fade' @@ -270,25 +262,25 @@ class App.ControllerModalLoading extends App.Controller return App.Delay.set(remove, delay * 1000) -class App.ControllerGenericDestroyConfirm extends App.ControllerModal - constructor: -> - super - @head = 'Confirm' - @cancel = true - @button = 'Yes' - @message = 'Sure to delete this object?' - @show() +class App.ControllerGenericDestroyConfirm extends App.ControllerModalNice + buttonClose: true + buttonCancel: true + buttonSubmit: 'yes' + buttonClass: 'btn--danger' + head: 'Confirm' - onSubmit: (e) -> - e.preventDefault() + content: => + App.i18n.translateContent('Sure to delete this object?') + + onSubmit: => @item.destroy( done: => if @callback @callback() - @hide() + @close() fail: => @log 'errors' - @hide() + @close() ) class App.ControllerDrox extends App.Controller @@ -439,40 +431,35 @@ class App.ControllerNavSidbar extends App.ControllerContent 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: -> super - @head = 'History' - @close = true + @fetch() - render: -> + content: => + localItem = @reworkItems(@items) - localItem = @reworkItems( @items ) - - @content = $ App.view('generic/history')( + content = $ App.view('generic/history')( items: localItem ) - - @onShow() - - @content.find('a[data-type="sortorder"]').bind( - 'click', - (e) => - e.preventDefault() - @sortorder() + content.find('a[data-type="sortorder"]').bind('click', (e) => + e.preventDefault() + @sortorder() ) - if !@isShown - @isShown = true - @show() + content - onShow: => - # enable user popups + onShown: => @userPopups() sortorder: => @items = @items.reverse() - - @render() + @update() T: (name) -> App.i18n.translateInline(name) diff --git a/app/assets/javascripts/app/controllers/_channel/email.coffee b/app/assets/javascripts/app/controllers/_channel/email.coffee index e23878755..d41e41aa2 100644 --- a/app/assets/javascripts/app/controllers/_channel/email.coffee +++ b/app/assets/javascripts/app/controllers/_channel/email.coffee @@ -73,15 +73,13 @@ With Filters you can e. g. dispatch new Tickets into certain groups or set a cer container: @el.closest('.content') ) -class App.ChannelEmailFilterEdit extends App.ControllerModal - constructor: -> - super - - @head = 'Postmaster Filter' - @button = true - @close = true - @cancel = true +class App.ChannelEmailFilterEdit extends App.ControllerModalNice + buttonClose: true + buttonCancel: true + buttonSubmit: true + head: 'Postmaster Filter' + content: => if @object @form = new App.ControllerForm( model: App.PostmasterFilter, @@ -94,8 +92,7 @@ class App.ChannelEmailFilterEdit extends App.ControllerModal autofocus: true, ) - @content = @form.form - @show() + @form.form onSubmit: (e) => e.preventDefault() @@ -108,7 +105,7 @@ class App.ChannelEmailFilterEdit extends App.ControllerModal object.load(params) # validate form - errors = @form.validate( params ) + errors = @form.validate(params) # show errors in form if errors @@ -122,9 +119,9 @@ class App.ChannelEmailFilterEdit extends App.ControllerModal # save object object.save( done: => - @hide() + @close() fail: => - @hide() + @close() ) 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') ) -class App.ChannelEmailSignatureEdit extends App.ControllerModal - constructor: -> - super - - @head = 'Signature' - @button = true - @close = true - @cancel = true +class App.ChannelEmailSignatureEdit extends App.ControllerModalNice + buttonClose: true + buttonCancel: true + buttonSubmit: true + head: 'Signature' + content: => if @object @form = new App.ControllerForm( model: App.Signature @@ -193,12 +188,9 @@ class App.ChannelEmailSignatureEdit extends App.ControllerModal autofocus: true ) - @content = @form.form - - @show() + @form.form onSubmit: (e) => - e.preventDefault() # get params params = @formParam(e.target) @@ -207,7 +199,7 @@ class App.ChannelEmailSignatureEdit extends App.ControllerModal object.load(params) # validate form - errors = @form.validate( params ) + errors = @form.validate(params) # show errors in form if errors @@ -221,9 +213,9 @@ class App.ChannelEmailSignatureEdit extends App.ControllerModal # save object object.save( done: => - @hide() + @close() fail: => - @hide() + @formEnable(e) ) class App.ChannelEmailAccountOverview extends App.Controller @@ -399,15 +391,13 @@ class App.ChannelEmailAccountOverview extends App.Controller channelDriver: @channelDriver ) -class App.ChannelEmailEdit extends App.ControllerModal - constructor: -> - super - - @head = 'Channel' - @button = true - @close = true - @cancel = true +class App.ChannelEmailEdit extends App.ControllerModalNice + buttonClose: true + buttonCancel: true + buttonSubmit: true + head: 'Channel' + content: => configureAttributesBase = [ { 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: '' params: @item ) - - @content = @form.form - @show() + @form.form onSubmit: (e) => - e.preventDefault() # get params params = @formParam(e.target) # validate form - errors = @form.validate( params ) + errors = @form.validate(params) # show errors in form if errors @@ -448,9 +435,9 @@ class App.ChannelEmailEdit extends App.ControllerModal processData: true success: (data, status, xhr) => @callback() - @hide() + @close() fail: => - @enable(e) + @formEnable(e) ) class App.ChannelEmailAccountWizard extends App.Wizard diff --git a/app/assets/javascripts/app/controllers/_channel/form.coffee b/app/assets/javascripts/app/controllers/_channel/form.coffee index 5c539db61..381220be3 100644 --- a/app/assets/javascripts/app/controllers/_channel/form.coffee +++ b/app/assets/javascripts/app/controllers/_channel/form.coffee @@ -10,7 +10,7 @@ class App.ChannelForm extends App.Controller @render() @updateParams() new App.SettingsArea( - el: @el.find('.js-settings') + el: @$('.js-settings') area: 'Form::Base' ) @@ -21,16 +21,19 @@ class App.ChannelForm extends App.Controller updateParams: -> quote = (string) -> - string.replace('\'', '\\\'') + string = string.replace('\'', '\\\'') + .replace(/\/g, '>') params = @formParam(@$('.js-params')) paramString = '' for key, value of params - if paramString != '' - paramString += ",\n" - if value == 'true' || value == 'false' - paramString += " #{key}: #{value}" - else - paramString += " #{key}: '#{quote(value)}'" + if value != '' + if paramString != '' + paramString += ",\n" + if value == 'true' || value == 'false' + paramString += " #{key}: #{value}" + else + paramString += " #{key}: '#{quote(value)}'" @$('.js-modal-params').html(paramString) App.Config.set( 'Form', { prio: 2000, name: 'Form', parent: '#channels', target: '#channels/form', controller: App.ChannelForm, role: ['Admin'] }, 'NavBarAdmin' ) diff --git a/app/assets/javascripts/app/controllers/_profile/avatar.coffee b/app/assets/javascripts/app/controllers/_profile/avatar.coffee index 57c6635b1..9707d3a71 100644 --- a/app/assets/javascripts/app/controllers/_profile/avatar.coffee +++ b/app/assets/javascripts/app/controllers/_profile/avatar.coffee @@ -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' ) -class ImageCropper extends App.ControllerModal +class ImageCropper extends App.ControllerModalNice + buttonClose: true + buttonCancel: true + buttonSubmit: 'Save' + head: 'Crop Image' + elements: '.imageCropper-image': 'image' '.imageCropper-holder': 'holder' - constructor: (options) -> - super - @head = 'Crop Image' - @cancel = true - @button = 'Save' - @buttonClass = 'btn--success' - - @show( App.view('profile/imageCropper')() ) + content: => + App.view('profile/imageCropper')() + post: => @size = 256 orientationTransform = @@ -168,7 +168,7 @@ class ImageCropper extends App.ControllerModal 6: 90 8: -90 - @angle = orientationTransform[ @options.orientation ] + @angle = orientationTransform[ @orientation ] if @angle == undefined @angle = 0 @@ -177,9 +177,9 @@ class ImageCropper extends App.ControllerModal @isOrientating = true image = new Image() image.addEventListener 'load', @orientateImage - image.src = @options.imageSource + image.src = @imageSource else - @image.attr src: @options.imageSource + @image.attr src: @imageSource orientateImage: (e) => image = e.currentTarget @@ -215,14 +215,23 @@ class ImageCropper extends App.ControllerModal minContainerHeight: 300 preview: '.imageCropper-preview' - onSubmit: (e) => - e.preventDefault() - @options.callback( @image.cropper('getCroppedCanvas').toDataURL() ) + onSubmit: => + @callback( @image.cropper('getCroppedCanvas').toDataURL() ) @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: '.js-shoot': 'shootButton' '.js-submit': 'submitButton' @@ -233,23 +242,14 @@ class Camera extends App.ControllerModal events: 'click .js-shoot:not(.is-disabled)': 'onShootClick' - constructor: (options) -> - super + content: => + App.view('profile/camera')() + + post: => @size = 256 @photoTaken = false @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') requestWebcam = Modernizr.prefixed('getUserMedia', navigator) @@ -312,7 +312,7 @@ class Camera extends App.ControllerModal 'ConstraintNotSatisfiedError': App.i18n.translateInline('No camera found.') alert convertToHumanReadable[error.name] - @hide() + @close() setupPreview: => @video.attr 'height', @size @@ -400,14 +400,13 @@ class Camera extends App.ControllerModal # reset video height @video.attr height: @size - onHide: => + onClose: => @stream.stop() if @stream @hidden = true - onSubmit: (e) => - e.preventDefault() + onSubmit: => # send picture to the callback console.log @cache.get(0).toDataURL() window.file = @cache.get(0).toDataURL() - @options.callback @cache.get(0).toDataURL() - @hide() + @callback @cache.get(0).toDataURL() + @close() diff --git a/app/assets/javascripts/app/controllers/agent_ticket_merge.coffee b/app/assets/javascripts/app/controllers/agent_ticket_merge.coffee index 0d1229905..d93339929 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_merge.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_merge.coffee @@ -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: -> super - @head = 'Merge' - @button = true - @cancel = true @fetch() fetch: -> - - # merge tickets @ajax( id: 'ticket_related' type: 'GET' - url: @apiPath + '/ticket_related/' + @ticket.id - processData: true, + url: "#{@apiPath}/ticket_related/#{@ticket.id}" + processData: true 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_recent_viewed = data.ticket_ids_recent_viewed @render() ) - render: -> - - @content = $( App.view('agent_ticket_merge')() ) + content: => + content = $( App.view('agent_ticket_merge')() ) new App.TicketList( - el: @content.find('#ticket-merge-customer-tickets') + el: content.find('#ticket-merge-customer-tickets') ticket_ids: @ticket_ids_by_customer radio: true ) new App.TicketList( - el: @content.find('#ticket-merge-recent-tickets'), + el: content.find('#ticket-merge-recent-tickets') ticket_ids: @ticket_ids_recent_viewed 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) ) - @content.delegate('[name="radio"]', 'click', (e) -> + content.delegate('[name="radio"]', 'click', (e) -> if $(e.target).prop('checked') ticket_id = $(e.target).val() - ticket = App.Ticket.fullLocal( ticket_id ) - $(e.target).parents().find('[name="master_ticket_number"]').val( ticket.number ) + ticket = App.Ticket.fullLocal(ticket_id) + $(e.target).parents().find('[name="master_ticket_number"]').val(ticket.number) ) - @show() + content onSubmit: (e) => - e.preventDefault() - - # disable form @formDisable(e) - params = @formParam(e.target) # merge tickets @ajax( - id: 'ticket_merge', - type: 'GET', - url: @apiPath + '/ticket_merge/' + @ticket.id + '/' + params['master_ticket_number'], - data: { -# view: @view - } + id: 'ticket_merge' + type: 'GET' + url: "#{@apiPath}/ticket_merge/#{@ticket.id}/#{params['master_ticket_number']}" processData: true, success: (data, status, xhr) => @@ -78,7 +69,7 @@ class App.TicketMerge extends App.ControllerModal App.Collection.load( type: 'Ticket', data: [data.slave_ticket] ) # hide dialog - @hide() + @close() # view ticket @log 'notice', 'nav...', App.Ticket.find( data.master_ticket['id'] ) @@ -105,4 +96,3 @@ class App.TicketMerge extends App.ControllerModal error: => @formEnable(e) ) - diff --git a/app/assets/javascripts/app/controllers/layout_ref.coffee b/app/assets/javascripts/app/controllers/layout_ref.coffee index 79c9a15c0..61650b992 100644 --- a/app/assets/javascripts/app/controllers/layout_ref.coffee +++ b/app/assets/javascripts/app/controllers/layout_ref.coffee @@ -413,23 +413,15 @@ class ContentSidebarRightSidebarOptional extends App.ControllerContent App.Config.set( 'layout_ref/content_sidebar_right_sidebar_optional', ContentSidebarRightSidebarOptional, 'Routes' ) -class ModalForm extends App.ControllerModal - constructor: -> - super - @head = '123 some title' - @cancel = true - @button = true +class ModalForm extends App.ControllerModalNice + head: '123 some title' - @render() - - render: -> + content: -> controller = new App.ControllerForm( model: App.User autofocus: true ) - @content = controller.form - - @show() + controller.form onHide: -> window.history.back() @@ -442,15 +434,10 @@ class ModalForm extends App.ControllerModal App.Config.set( 'layout_ref/modal_form', ModalForm, 'Routes' ) -class ModalText extends App.ControllerModal - constructor: -> - super - @head = '123 some title' +class ModalText extends App.ControllerModalNice - @render() - - render: -> - @show( App.view('layout_ref/content')() ) + content: -> + App.view('layout_ref/content')() onHide: -> window.history.back() @@ -458,7 +445,6 @@ class ModalText extends App.ControllerModal App.Config.set( 'layout_ref/modal_text', ModalText, 'Routes' ) - class ContentSidebarTabsRight extends App.ControllerContent elements: '.tabsSidebar' : 'sidebar' @@ -1380,12 +1366,13 @@ class SlaRef extends App.ControllerContent checkbox.closest('tr').toggleClass('is-active', checkbox.prop('checked')) createNew: => - @newItemModal = new App.ControllerModal - head: 'New Service Level Agreement (SLA)' - content: App.view('layout_ref/sla_modal')() - button: 'Create SLA' + @newItemModal = new App.ControllerModalNice + head: 'Service Level Agreement (SLA)' + headPrefox: 'New' + contentInline: App.view('layout_ref/sla_modal')() + buttonSubmit: 'Create SLA' shown: true - cancel: true + buttonCancel: true container: @el onShown: => @$('.js-responseTime').timepicker @@ -1419,12 +1406,13 @@ class SchedulersRef extends App.ControllerContent .text(if isInactive then 'Enable' else 'Disable') createNew: => - new App.ControllerModal - head: 'New Scheduler' - content: App.view('layout_ref/scheduler_modal')() - button: 'Create Schedule' + new App.ControllerModalNice + head: 'Scheduler' + headPrefix: 'New' + buttonSubmit: 'Create' + buttonCancel: true + contentInline: App.view('layout_ref/scheduler_modal')() shown: true - cancel: true container: @el select: (event) => @@ -1655,13 +1643,13 @@ class MergeCustomerRef extends App.ControllerContent render: -> @html App.view('layout_ref/merge_customer_view') - new App.ControllerModal + new App.ControllerModalNice large: true - head: "Merge #{@mergeSource.firstname} #{@mergeSource.lastname}" - content: App.view('layout_ref/merge_customer')() - button: 'Merge' - shown: true - cancel: true + head: "#{@mergeSource.firstname} #{@mergeSource.lastname}" + headPrefix: 'Merge' + contentInline: App.view('layout_ref/merge_customer')() + buttonSubmit: 'Merge' + buttonCancel: true container: @el onChange: -> diff --git a/app/assets/javascripts/app/controllers/object_manager.coffee b/app/assets/javascripts/app/controllers/object_manager.coffee index e35c950d5..02a66d007 100644 --- a/app/assets/javascripts/app/controllers/object_manager.coffee +++ b/app/assets/javascripts/app/controllers/object_manager.coffee @@ -152,15 +152,14 @@ class Items extends App.ControllerContent @load() ) -class Edit extends App.ControllerModal - constructor: (params) -> - super +class Edit extends App.ControllerModalNice + buttonClose: true + buttonCancel: true + buttonSubmit: true + head: 'Edit' - @head = App.i18n.translateContent( 'Edit' ) - @cancel = true - @button = true - - @content = $( App.view('object_manager/edit')( + content: => + content = $( App.view('object_manager/edit')( head: @object 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 }, ] controller = new App.ControllerForm( - model: { configure_attributes: configureAttributesTop, className: '' }, - params: item - #screen: @screen || 'edit' - el: @content.find('.js-top') - autofocus: true + model: { configure_attributes: configureAttributesTop, className: '' }, + params: item + #screen: @screen || 'edit' + el: content.find('.js-top') + autofocus: true ) # input @@ -201,10 +200,10 @@ class Edit extends App.ControllerModal { name: 'data_option::note', display: 'Note', tag: 'input', type: 'text', limit: 100, null: true }, ] controller = new App.ControllerForm( - model: { configure_attributes: configureAttributesInput, className: '' }, - params: item - el: @content.find('.js-input') - autofocus: true + model: { configure_attributes: configureAttributesInput, className: '' }, + params: item + el: content.find('.js-input') + autofocus: true ) # textarea @@ -215,10 +214,10 @@ class Edit extends App.ControllerModal { name: 'data_option::note', display: 'autocomplete', tag: 'input', type: 'text', limit: 100, null: true }, ] controller = new App.ControllerForm( - model: { configure_attributes: configureAttributesTextarea, className: '' }, - params: item - el: @content.find('.js-textarea') - autofocus: true + model: { configure_attributes: configureAttributesTextarea, className: '' }, + params: item + el: content.find('.js-textarea') + autofocus: true ) # select @@ -233,7 +232,7 @@ class Edit extends App.ControllerModal controller = new App.ControllerForm( model: { configure_attributes: configureAttributesSelect, className: '' }, params: item - el: @content.find('.js-select') + el: content.find('.js-select') autofocus: true ) @@ -245,32 +244,26 @@ class Edit extends App.ControllerModal }, ### - @content.find('[name=data_type]').on( + content.find('[name=data_type]').on( 'change', (e) => dataType = $( e.target ).val() - @content.find('.js-middle > div').addClass('hide') - @content.find(".js-#{dataType}").removeClass('hide') + content.find('.js-middle > div').addClass('hide') + content.find(".js-#{dataType}").removeClass('hide') ) - @content.find('[name=data_type]').trigger('change') + content.find('[name=data_type]').trigger('change') configureAttributesBottom = [ { name: 'active', display: 'Active', tag: 'active', default: true }, ] controller = new App.ControllerForm( - model: { configure_attributes: configureAttributesBottom, className: '' }, - params: item - #screen: @screen || 'edit' - el: @content.find('.js-bottom') + model: { configure_attributes: configureAttributesBottom, className: '' }, + params: item + #screen: @screen || 'edit' + el: content.find('.js-bottom') ) - #@content = controller.form - - - #@show(content) - @show() - - + controller.form App.Config.set( 'SystemObject', { prio: 1700, parent: '#system', name: 'Objects', target: '#system/object_manager', controller: Index, role: ['Admin'] }, 'NavBarAdmin' ) diff --git a/app/assets/javascripts/app/controllers/organization_history.coffee b/app/assets/javascripts/app/controllers/organization_history.coffee index 96770b540..6dfb54e4a 100644 --- a/app/assets/javascripts/app/controllers/organization_history.coffee +++ b/app/assets/javascripts/app/controllers/organization_history.coffee @@ -1,22 +1,11 @@ class App.OrganizationHistory extends App.GenericHistory - constructor: -> - super - @fetch() - - fetch: -> - - # get data + fetch: => @ajax( id: 'organization_history' type: 'GET' - url: @apiPath + '/organizations/history/' + @organization_id + url: "#{@apiPath}/organizations/history/#{@organization_id}" success: (data, status, xhr) => - - # load assets - App.Collection.loadAssets( data.assets ) - + App.Collection.loadAssets(data.assets) @items = data.history - - # render page @render() - ) \ No newline at end of file + ) diff --git a/app/assets/javascripts/app/controllers/organization_profile.coffee b/app/assets/javascripts/app/controllers/organization_profile.coffee index 71acd346c..3ccd2d5f0 100644 --- a/app/assets/javascripts/app/controllers/organization_profile.coffee +++ b/app/assets/javascripts/app/controllers/organization_profile.coffee @@ -108,7 +108,10 @@ class Object extends App.Controller # start action controller showHistory = -> - new App.OrganizationHistory( organization_id: organization.id ) + new App.OrganizationHistory( + organization_id: organization.id + container: @el.closest('.content') + ) editOrganization = => new App.ControllerGenericEdit( id: organization.id diff --git a/app/assets/javascripts/app/controllers/profile.coffee b/app/assets/javascripts/app/controllers/profile.coffee index 1de3787ce..e1d8503fa 100644 --- a/app/assets/javascripts/app/controllers/profile.coffee +++ b/app/assets/javascripts/app/controllers/profile.coffee @@ -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: 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' ) diff --git a/app/assets/javascripts/app/controllers/taskbar_widget.coffee b/app/assets/javascripts/app/controllers/taskbar_widget.coffee index d9e92226e..04f4dc15b 100644 --- a/app/assets/javascripts/app/controllers/taskbar_widget.coffee +++ b/app/assets/javascripts/app/controllers/taskbar_widget.coffee @@ -112,18 +112,16 @@ class App.TaskbarWidget extends App.Controller @navigate '#' -class Remove extends App.ControllerModal - constructor: -> - super - @head = 'Confirm' - @message = 'Tab has changed, you really want to close it?' - @cancel = true - @close = true - @button = 'Discared changes' - @buttonClass = 'btn--danger' - @show() +class Remove extends App.ControllerModalNice + buttonClose: true + buttonCancel: true + buttonSubmit: 'Discared changes' + buttonClass: 'btn--danger' + head: 'Confirm' + + content: => + App.i18n.translateContent('Tab has changed, you really want to close it?') onSubmit: (e) => - e.preventDefault() - @hide() + @close() @ui.remove(e, @key, true) diff --git a/app/assets/javascripts/app/controllers/ticket_customer.coffee b/app/assets/javascripts/app/controllers/ticket_customer.coffee index 1856adb2b..88b784275 100644 --- a/app/assets/javascripts/app/controllers/ticket_customer.coffee +++ b/app/assets/javascripts/app/controllers/ticket_customer.coffee @@ -1,29 +1,21 @@ -class App.TicketCustomer extends App.ControllerModal - constructor: -> - super - - @head = 'Change Customer' - @close = true - @cancel = true - @button = true +class App.TicketCustomer extends App.ControllerModalNice + buttonClose: true + buttonCancel: true + buttonSubmit: true + head: 'Change Customer' + content: => configure_attributes = [ { name: 'customer_id', display: 'Customer', tag: 'user_autocompletion', null: false, placeholder: 'Enter Person or Organization/Company', minLengt: 2, disableCreateUser: true }, ] - controller = new App.ControllerForm( model: configure_attributes: configure_attributes, autofocus: true ) - - @content = controller.form - - @show() + controller.form onSubmit: (e) => - e.preventDefault() - params = @formParam(e.target) @customer_id = params['customer_id'] @@ -31,7 +23,7 @@ class App.TicketCustomer extends App.ControllerModal callback = => # close modal - @hide() + @close() # update ticket @ticket.updateAttributes( diff --git a/app/assets/javascripts/app/controllers/ticket_history.coffee b/app/assets/javascripts/app/controllers/ticket_history.coffee index 2cd33cc60..0979a9d1f 100644 --- a/app/assets/javascripts/app/controllers/ticket_history.coffee +++ b/app/assets/javascripts/app/controllers/ticket_history.coffee @@ -1,22 +1,11 @@ class App.TicketHistory extends App.GenericHistory - constructor: -> - super - @fetch() - - fetch: -> - - # get data + fetch: => @ajax( - id: 'ticket_history', - type: 'GET', - url: @apiPath + '/ticket_history/' + @ticket_id, + id: 'ticket_history' + type: 'GET' + url: "#{@apiPath}/ticket_history/#{@ticket_id}" success: (data, status, xhr) => - - # load assets - App.Collection.loadAssets( data.assets ) - + App.Collection.loadAssets(data.assets) @items = data.history - - # render page @render() - ) \ No newline at end of file + ) diff --git a/app/assets/javascripts/app/controllers/ticket_overview.coffee b/app/assets/javascripts/app/controllers/ticket_overview.coffee index 46606fda4..0444575e2 100644 --- a/app/assets/javascripts/app/controllers/ticket_overview.coffee +++ b/app/assets/javascripts/app/controllers/ticket_overview.coffee @@ -620,10 +620,15 @@ class BulkForm extends App.Controller msg: App.i18n.translateContent('Bulk-Action executed!') } -class App.OverviewSettings extends App.ControllerModal - constructor: -> - super +class App.OverviewSettings extends App.ControllerModalNice + buttonClose: true + buttonCancel: true + buttonSubmit: true + headPrefix: 'Edit' + + content: => @overview = App.Overview.find(@overview_id) + @head = @overview.name @configure_attributes_article = [] if @view_mode is 'd' @@ -715,19 +720,13 @@ class App.OverviewSettings extends App.ControllerModal owner: 'Owner' }) - @head = App.i18n.translateContent( 'Edit' ) + ': ' + App.i18n.translateContent( @overview.name ) - @close = true - @cancel = true - @button = true controller = new App.ControllerForm( model: { configure_attributes: @configure_attributes_article } autofocus: false ) - @content = controller.form - @show() + controller.form onSubmit: (e) => - e.preventDefault() params = @formParam(e.target) # check if re-fetch is needed @@ -756,8 +755,8 @@ class App.OverviewSettings extends App.ControllerModal App.OverviewIndexCollection.trigger() App.OverviewCollection.trigger(@overview.link) - # hide modal - @hide() + # close modal + @close() ) class TicketOverviewRouter extends App.ControllerPermanent diff --git a/app/assets/javascripts/app/controllers/user_history.coffee b/app/assets/javascripts/app/controllers/user_history.coffee index 5890082ce..b7640c70a 100644 --- a/app/assets/javascripts/app/controllers/user_history.coffee +++ b/app/assets/javascripts/app/controllers/user_history.coffee @@ -1,22 +1,11 @@ class App.UserHistory extends App.GenericHistory - constructor: -> - super - @fetch() - - fetch: -> - - # get data + fetch: => @ajax( - id: 'user_history', - type: 'GET', - url: @apiPath + '/users/history/' + @user_id, + id: 'user_history' + type: 'GET' + url: "#{@apiPath}/users/history/#{@user_id}" success: (data, status, xhr) => - - # load assets - App.Collection.loadAssets( data.assets ) - + App.Collection.loadAssets(data.assets) @items = data.history - - # render page @render() ) diff --git a/app/assets/javascripts/app/controllers/user_profile.coffee b/app/assets/javascripts/app/controllers/user_profile.coffee index 775cce35d..815c54823 100644 --- a/app/assets/javascripts/app/controllers/user_profile.coffee +++ b/app/assets/javascripts/app/controllers/user_profile.coffee @@ -110,8 +110,11 @@ class Object extends App.Controller }) # start action controller - showHistory = -> - new App.UserHistory( user_id: user.id ) + showHistory = => + new App.UserHistory( + user_id: user.id + container: @el.closest('.content') + ) editUser = => new App.ControllerGenericEdit( diff --git a/app/assets/javascripts/app/controllers/widget/link.coffee b/app/assets/javascripts/app/controllers/widget/link.coffee index c66495de9..57778f59c 100644 --- a/app/assets/javascripts/app/controllers/widget/link.coffee +++ b/app/assets/javascripts/app/controllers/widget/link.coffee @@ -1,7 +1,7 @@ class App.WidgetLink extends App.Controller events: - 'click .js-add': 'add', - 'click .js-remove': 'remove', + 'click .js-add': 'add' + 'click .js-delete': 'delete' constructor: -> super @@ -16,25 +16,20 @@ class App.WidgetLink extends App.Controller # fetch item on demand # get data @ajax( - id: 'links_' + @object.id + '_' + @object_type, - type: 'GET', - url: @apiPath + '/links', - data: { - link_object: @object_type, - link_object_value: @object.id, - } - processData: true, + id: "links_#{@object.id}_#{@object_type}" + type: 'GET' + url: "#{@apiPath}/links" + data: + link_object: @object_type + link_object_value: @object.id + processData: true success: (data, status, xhr) => @links = data.links - - # load assets - App.Collection.loadAssets( data.assets ) - + App.Collection.loadAssets(data.assets) @render() ) render: => - list = {} for item in @links if !list[ item['link_type'] ] @@ -51,7 +46,7 @@ class App.WidgetLink extends App.Controller links: list ) - remove: (e) => + delete: (e) => e.preventDefault() link_type = $(e.target).data('link-type') link_object_source = $(e.target).data('object') @@ -61,17 +56,16 @@ class App.WidgetLink extends App.Controller # get data @ajax( - id: 'links_remove_' + @object.id + '_' + @object_type, - type: 'GET', - url: @apiPath + '/links/remove', - data: { - link_type: link_type, - link_object_source: link_object_source, - link_object_source_value: link_object_source_value, - link_object_target: link_object_target, - link_object_target_value: link_object_target_value, - } - processData: true, + id: "links_remove_#{@object.id}_#{@object_type}" + type: 'GET' + url: "#{@apiPath}/links/remove" + data: + link_type: link_type + link_object_source: link_object_source + link_object_source_value: link_object_source_value + link_object_target: link_object_target + link_object_target_value: link_object_target_value + processData: true success: (data, status, xhr) => @fetch() ) @@ -86,42 +80,37 @@ class App.WidgetLink extends App.Controller 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: -> super - @head = 'Links' - @button = true - @cancel = true - @ticket = @object - @fetch() fetch: -> - - # merge tickets @ajax( id: 'ticket_related' type: 'GET' - url: @apiPath + '/ticket_related/' + @ticket.id - processData: true, + url: "#{@apiPath}/ticket_related/#{@ticket.id}" + processData: true success: (data, status, xhr) => - - # load assets - App.Collection.loadAssets( data.assets ) - + App.Collection.loadAssets(data.assets) @ticket_ids_by_customer = data.ticket_ids_by_customer @ticket_ids_recent_viewed = data.ticket_ids_recent_viewed @render() ) - - render: -> - @content = $ App.view('link/add')( - link_object: @link_object, - link_object_id: @link_object_id, - object: @object, - ) + content: => + content = $( App.view('link/add')( + link_object: @link_object + link_object_id: @link_object_id + object: @object + )) list = [] for ticket_id in @ticket_ids_by_customer @@ -129,11 +118,11 @@ class App.LinkAdd extends App.ControllerModal ticketItem = App.Ticket.fullLocal( ticket_id ) list.push ticketItem new App.ControllerTable( - el: @content.find('#ticket-merge-customer-tickets'), + el: content.find('#ticket-merge-customer-tickets') overview: [ 'number', 'title', 'state', 'group', 'created_at' ] - model: App.Ticket, - objects: list, - radio: true, + model: App.Ticket + objects: list + radio: true ) list = [] @@ -142,28 +131,26 @@ class App.LinkAdd extends App.ControllerModal ticketItem = App.Ticket.fullLocal( ticket_id ) list.push ticketItem new App.ControllerTable( - el: @content.find('#ticket-merge-recent-tickets'), + el: content.find('#ticket-merge-recent-tickets') overview: [ 'number', 'title', 'state', 'group', 'created_at' ] - model: App.Ticket, - objects: list, - radio: true, + model: App.Ticket + objects: list + 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 ) ) - @content.delegate('[name="radio"]', 'click', (e) -> + content.delegate('[name="radio"]', 'click', (e) -> if $(e.target).prop('checked') ticket_id = $(e.target).val() ticket = App.Ticket.fullLocal( ticket_id ) $(e.target).parents().find('[name="ticket_number"]').val( ticket.number ) ) - - @show() + content onSubmit: (e) => - e.preventDefault() params = @formParam(e.target) if !params['ticket_number'] @@ -175,18 +162,17 @@ class App.LinkAdd extends App.ControllerModal # get data @ajax( - id: 'links_add_' + @object.id + '_' + @object_type, - type: 'GET', - url: @apiPath + '/links/add', - data: { - link_type: params['link_type'], - link_object_target: 'Ticket', - link_object_target_value: @object.id, - link_object_source: 'Ticket', - link_object_source_number: params['ticket_number'], - } - processData: true, + id: "links_add_#{@object.id}_#{@object_type}" + type: 'GET' + url: "#{@apiPath}/links/add" + data: + link_type: params['link_type'] + link_object_target: 'Ticket' + link_object_target_value: @object.id + link_object_source: 'Ticket' + link_object_source_number: params['ticket_number'] + processData: true success: (data, status, xhr) => - @hide() + @close() @parent.fetch() ) diff --git a/app/assets/javascripts/app/controllers/widget/maintenance.coffee b/app/assets/javascripts/app/controllers/widget/maintenance.coffee index c35af8237..87a4396f5 100644 --- a/app/assets/javascripts/app/controllers/widget/maintenance.coffee +++ b/app/assets/javascripts/app/controllers/widget/maintenance.coffee @@ -15,19 +15,21 @@ class Widget extends App.Controller if message.reload @disconnectClient() button = 'Continue session' + else + button = 'Close' # convert to html and linkify message.message = App.Utils.textCleanup( message.message ) message.message = App.Utils.text2html( message.message ) new App.SessionMessage( - head: message.head - content: message.message - keyboard: true - backdrop: true - close: true - button: button - forceReload: message.reload + head: message.head + contentInline: message.message + keyboard: true + backdrop: true + buttonClose: true + buttonSubmit: button + forceReload: message.reload ) App.Config.set( 'maintenance', Widget, 'Widgets' ) \ No newline at end of file diff --git a/app/assets/javascripts/app/controllers/widget/session_taken_over.coffee b/app/assets/javascripts/app/controllers/widget/session_taken_over.coffee index 90a048857..3f02396c1 100644 --- a/app/assets/javascripts/app/controllers/widget/session_taken_over.coffee +++ b/app/assets/javascripts/app/controllers/widget/session_taken_over.coffee @@ -39,13 +39,13 @@ class Widget extends App.Controller # only if new client id isnt own client id if data.taskbar_id isnt App.TaskManager.TaskbarId() @error = new App.SessionMessage( - head: 'Session' - message: App.i18n.translateInline('A new session with your account was created. This session will be stopped to prevent a conflict.') - keyboard: false - backdrop: true - close: false - button: 'Continue session' - forceReload: true + head: 'Session' + message: 'A new session with your account was created. This session will be stopped to prevent a conflict.' + keyboard: false + backdrop: true + buttonClose: false + buttonSubmit: 'Continue session' + forceReload: true ) @disconnectClient() 'maintenance' diff --git a/app/assets/javascripts/app/controllers/widget/translation_inline.coffee b/app/assets/javascripts/app/controllers/widget/translation_inline.coffee index 95354acb8..3ddb65a8e 100644 --- a/app/assets/javascripts/app/controllers/widget/translation_inline.coffee +++ b/app/assets/javascripts/app/controllers/widget/translation_inline.coffee @@ -32,11 +32,12 @@ class Widget extends App.Controller # observe if text has been translated $('body') - .on '.translation', 'focus', (e) -> + .on 'focus.translation', '.translation', (e) -> element = $(e.target) element.data 'before', element.html() element - .on '.translation', 'blur', (e) => + .on 'blur.translation', '.translation', (e) => + console.log('blur') element = $(e.target) source = element.attr('title') @@ -66,16 +67,17 @@ class Widget extends App.Controller else translation = new App.Translation translation.load( - locale: @locale - source: source - target: translation_new + locale: App.i18n.get() + source: source + target: translation_new + initial_target: '' ) translation.save() element disable: -> - $('body').off('.translation') + $('body').off('focus.translation blur.translation') # disable translation inline App.Config.set('translation_inline', false) diff --git a/app/assets/javascripts/app/controllers/widget/translation_support.coffee b/app/assets/javascripts/app/controllers/widget/translation_support.coffee index 94ecac00e..ac9c7efa6 100644 --- a/app/assets/javascripts/app/controllers/widget/translation_support.coffee +++ b/app/assets/javascripts/app/controllers/widget/translation_support.coffee @@ -20,23 +20,9 @@ class TranslationSupport extends App.Controller meta = App.i18n.meta() percent = parseInt( meta.translated / (meta.total / 100) ) 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 - modal = new App.ControllerModal( - 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() - ) + new Modal(percent: percent) @bind 'i18n:language:change', => @delay(check, 2500, 'translation_support') @@ -44,4 +30,33 @@ class TranslationSupport extends App.Controller @bind 'auth:login', => @delay(check, 2500, 'translation_support') -App.Config.set( 'translaton_support', TranslationSupport, 'Widgets' ) \ No newline at end of file +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() diff --git a/app/assets/javascripts/app/lib/app_post/ajax.coffee b/app/assets/javascripts/app/lib/app_post/ajax.coffee index 095bda739..956b9e40f 100644 --- a/app/assets/javascripts/app/lib/app_post/ajax.coffee +++ b/app/assets/javascripts/app/lib/app_post/ajax.coffee @@ -73,10 +73,10 @@ class _ajaxSingleton return if status is 502 # show error message - new App.ErrorModal( - message: 'StatusCode: ' + status - detail: detail - close: true + new App.ControllerModalNice( + head: 'StatusCode: ' + status + contentInline: '
' + App.Utils.htmlEscape(detail) + '
' + buttonClose: true ) ) diff --git a/app/assets/javascripts/app/lib/app_post/browser.coffee.coffee b/app/assets/javascripts/app/lib/app_post/browser.coffee.coffee index 8d3013879..f5a1077ab 100644 --- a/app/assets/javascripts/app/lib/app_post/browser.coffee.coffee +++ b/app/assets/javascripts/app/lib/app_post/browser.coffee.coffee @@ -40,8 +40,11 @@ class App.Browser # disable id older if data.browser if map[data.browser.name] && data.browser.major < map[data.browser.name] - @message(data, map[data.browser.name]) - console.log('Browser not supported') + new Modal( + data: data + version: map[data.browser.name] + ) + App.Log.error('Browser', 'Browser not supported') return false # allow browser @@ -73,12 +76,13 @@ class App.Browser localStorage.setItem('fingerprint', fingerprint) fingerprint - @message: (data, version) -> - new App.ControllerModal( - head: 'Browser too old!' - 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)." - close: false - backdrop: false - keyboard: false - shown: true - ) +class Modal extends App.ControllerModalNice + buttonClose: false + buttonCancel: false + buttonSubmit: false + backdrop: false + keyboard: false + head: 'Browser too old!' + + 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)." diff --git a/app/assets/javascripts/app/lib/app_post/user_organization_autocompletion.coffee b/app/assets/javascripts/app/lib/app_post/user_organization_autocompletion.coffee index 7c6a6f77f..490f5a18c 100644 --- a/app/assets/javascripts/app/lib/app_post/user_organization_autocompletion.coffee +++ b/app/assets/javascripts/app/lib/app_post/user_organization_autocompletion.coffee @@ -294,26 +294,22 @@ class App.UserOrganizationAutocompletion extends App.Controller container: @el.closest('.content') ) -class UserNew extends App.ControllerModal - constructor: -> - super - @head = 'New User' - @cancel = true - @button = true +class UserNew extends App.ControllerModalNice + buttonClose: true + buttonCancel: true + buttonSubmit: true + head: 'User' + headPrefix: 'New' + content: -> controller = new App.ControllerForm( - model: App.User - screen: 'edit' - autofocus: true + model: App.User + screen: 'edit' + autofocus: true ) + controller.form - @content = controller.form - - @show() - - onSubmit: (e) -> - - e.preventDefault() + onSubmit: (e) => params = @formParam(e.target) # if no login is given, use emails as fallback @@ -321,8 +317,8 @@ class UserNew extends App.ControllerModal params.login = params.email # find role_id - if !params.role_ids || _.isEmpty( params.role_ids ) - role = App.Role.findByAttribute( 'name', 'Customer' ) + if !params.role_ids || _.isEmpty(params.role_ids) + role = App.Role.findByAttribute('name', 'Customer') params.role_ids = role.id @log 'notice', 'updateAttributes', params @@ -346,9 +342,9 @@ class UserNew extends App.ControllerModal ui.parent.close() # start customer info controller - ui.hide() - App.User.full( @id, callbackReload , true ) + ui.close() + App.User.full(@id, callbackReload , true) fail: -> - ui.hide() - ) \ No newline at end of file + ui.close() + ) diff --git a/app/assets/javascripts/app/lib/app_post/websocket.coffee b/app/assets/javascripts/app/lib/app_post/websocket.coffee index 9ac2e9f1a..c86193070 100644 --- a/app/assets/javascripts/app/lib/app_post/websocket.coffee +++ b/app/assets/javascripts/app/lib/app_post/websocket.coffee @@ -256,14 +256,7 @@ class _webSocketSingleton extends App.Controller message = => # show reconnect message - @error = new App.ControllerModal( - head: 'Lost network connection!' - message: 'Trying to reconnect...' - backdrop: false - keyboard: false - close: false - shown: true - ) + @error = new Modal() if !@tryToConnect App.Delay.set message, 7000, 'websocket-no-connection-try-reconnect-message', 'ws' @tryToConnect = true @@ -380,3 +373,14 @@ class _webSocketSingleton extends App.Controller @_ajaxInit( force: true ) @_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...' diff --git a/app/assets/javascripts/app/models/calendar.coffee b/app/assets/javascripts/app/models/calendar.coffee index a50aa51a4..add3b4131 100644 --- a/app/assets/javascripts/app/models/calendar.coffee +++ b/app/assets/javascripts/app/models/calendar.coffee @@ -5,7 +5,7 @@ class App.Calendar extends App.Model @configure_attributes = [ { 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: '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 } diff --git a/app/assets/javascripts/app/models/translation.coffee b/app/assets/javascripts/app/models/translation.coffee index 2ecec3ff4..349de326f 100644 --- a/app/assets/javascripts/app/models/translation.coffee +++ b/app/assets/javascripts/app/models/translation.coffee @@ -1,4 +1,4 @@ class App.Translation extends App.Model - @configure 'Translation', 'source', 'target', 'locale' + @configure 'Translation', 'source', 'target', 'target_initial', 'locale' @extend Spine.Model.Ajax @url: @apiPath + '/translations' \ No newline at end of file diff --git a/app/assets/javascripts/app/views/calendar/index.jst.eco b/app/assets/javascripts/app/views/calendar/index.jst.eco index 53045e8c6..9b7fbf7d9 100644 --- a/app/assets/javascripts/app/views/calendar/index.jst.eco +++ b/app/assets/javascripts/app/views/calendar/index.jst.eco @@ -22,20 +22,20 @@
-

<% if !_.isEmpty(calendar.ical_url): %> +

<% if !_.isEmpty(calendar.ical_url): %> <% if calendar.last_log: %> <%- @Icon('status', 'error inline') %> <% else: %> <%- @Icon('status', 'ok inline') %> <% end %><% end %> <%= calendar.name %>

<% if calendar.default: %> -
Default
+
<%- @T('Default') %>
<% end %>

<% if calendar.last_log: %>
<%= calendar.last_log %>
<% end %>
-
<%- @T('Time zone') %>
<%= calendar.timezone %> +
<%- @T('Timezone') %>
<%= calendar.timezone %>
<%- @T('Business Hours') %>
diff --git a/app/assets/javascripts/app/views/channel/form.jst.eco b/app/assets/javascripts/app/views/channel/form.jst.eco index 989d9806a..67c113585 100644 --- a/app/assets/javascripts/app/views/channel/form.jst.eco +++ b/app/assets/javascripts/app/views/channel/form.jst.eco @@ -19,7 +19,7 @@
- +
@@ -27,7 +27,7 @@
- +
@@ -35,7 +35,7 @@
- +
diff --git a/app/assets/javascripts/app/views/generic/admin/empty.jst.eco b/app/assets/javascripts/app/views/generic/admin/empty.jst.eco index ec7286af6..473231b3b 100644 --- a/app/assets/javascripts/app/views/generic/admin/empty.jst.eco +++ b/app/assets/javascripts/app/views/generic/admin/empty.jst.eco @@ -1,4 +1,4 @@ -

<%= @T(@explanation) %>

+

<%- @T(@explanation) %>

<%- @T('No Entries') %> diff --git a/app/assets/javascripts/app/views/layout_ref/customer_chat.jst.eco b/app/assets/javascripts/app/views/layout_ref/customer_chat.jst.eco index 57dfdbab8..ab5160e0b 100644 --- a/app/assets/javascripts/app/views/layout_ref/customer_chat.jst.eco +++ b/app/assets/javascripts/app/views/layout_ref/customer_chat.jst.eco @@ -17,7 +17,7 @@
-
<%= @T('Settings') %>
+
<%- @T('Settings') %>
diff --git a/app/assets/javascripts/app/views/layout_ref/customer_chat_window.jst.eco b/app/assets/javascripts/app/views/layout_ref/customer_chat_window.jst.eco index 183d31f4d..211c34fbf 100644 --- a/app/assets/javascripts/app/views/layout_ref/customer_chat_window.jst.eco +++ b/app/assets/javascripts/app/views/layout_ref/customer_chat_window.jst.eco @@ -16,5 +16,5 @@
-
<%= @T('Send') %>
+
<%- @T('Send') %>
\ No newline at end of file diff --git a/app/assets/javascripts/app/views/modal.jst.eco b/app/assets/javascripts/app/views/modal.jst.eco index c673a8b4a..f7def8931 100644 --- a/app/assets/javascripts/app/views/modal.jst.eco +++ b/app/assets/javascripts/app/views/modal.jst.eco @@ -2,38 +2,30 @@