diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.coffee index d523501f2..067618d68 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.coffee @@ -404,7 +404,7 @@ class App.TicketZoom extends App.Controller ) new App.TicketZoomOverviewNavigator( - el: elLocal.find('.overview-navigator') + el: elLocal.find('.js-overviewNavigatorContainer') ticket_id: @ticket_id overview_id: @overview_id ) @@ -412,13 +412,13 @@ class App.TicketZoom extends App.Controller new App.TicketZoomTitle( object_id: @ticket_id overview_id: @overview_id - el: elLocal.find('.ticket-title') + el: elLocal.find('.js-ticketTitleContainer') task_key: @task_key ) new App.TicketZoomMeta( object_id: @ticket_id - el: elLocal.find('.ticket-meta') + el: elLocal.find('.js-ticketMetaContainer') ) @attributeBar = new App.TicketZoomAttributeBar( @@ -445,7 +445,12 @@ class App.TicketZoom extends App.Controller ) @highligher = new App.TicketZoomHighlighter( - el: elLocal.find('.highlighter') + el: elLocal.find('.js-highlighterContainer') + ticket_id: @ticket_id + ) + + new App.TicketZoomSetting( + el: elLocal.find('.js-settingContainer') ticket_id: @ticket_id ) @@ -557,14 +562,16 @@ class App.TicketZoom extends App.Controller return if !@ticket currentStoreTicket = @ticket.attributes() delete currentStoreTicket.article + internal = @Config.get('ui_ticket_zoom_article_note_new_internal') currentStore = ticket: currentStoreTicket article: to: '' cc: '' + subject: '' type: 'note' body: '' - internal: 'true' + internal: internal in_reply_to: '' if @permissionCheck('ticket.customer') @@ -575,7 +582,7 @@ class App.TicketZoom extends App.Controller formCurrent: => currentParams = ticket: @formParam(@el.find('.edit')) - article: @formParam(@el.find('.article-add')) + article: @articleNew.params() # add attachments if exist attachmentCount = @$('.article-add .textBubble .attachments .attachment').length diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee index c42c5ba7a..60fd1b1bf 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee @@ -28,107 +28,9 @@ class App.TicketZoomArticleNew extends App.Controller constructor: -> super - # set possble article types - possibleArticleType = - note: true - phone: true - if @ticket && @ticket.create_article_type_id - articleTypeCreate = App.TicketArticleType.find(@ticket.create_article_type_id).name - if articleTypeCreate is 'twitter status' - possibleArticleType['twitter status'] = true - else if articleTypeCreate is 'twitter direct-message' - possibleArticleType['twitter direct-message'] = true - else if articleTypeCreate is 'email' - possibleArticleType['email'] = true - else if articleTypeCreate is 'facebook feed post' - possibleArticleType['facebook feed comment'] = true - else if articleTypeCreate is 'telegram personal-message' - possibleArticleType['telegram personal-message'] = true - if @ticket && @ticket.customer_id - customer = App.User.find(@ticket.customer_id) - if customer.email - possibleArticleType['email'] = true - - # gets referenced in @setArticleType @internalSelector = true @type = @defaults['type'] || 'note' - @articleTypes = [] - if possibleArticleType.note - internal = @Config.get('ui_ticket_zoom_article_new_internal') - - @articleTypes.push { - name: 'note' - icon: 'note' - attributes: [] - internal: internal, - features: ['attachment'] - } - if possibleArticleType.email - @articleTypes.push { - name: 'email' - icon: 'email' - attributes: ['to', 'cc'] - internal: false, - features: ['attachment'] - } - if possibleArticleType['facebook feed comment'] - @articleTypes.push { - name: 'facebook feed comment' - icon: 'facebook' - attributes: [] - internal: false, - features: [] - } - if possibleArticleType['twitter status'] - @articleTypes.push { - name: 'twitter status' - icon: 'twitter' - attributes: [] - internal: false, - features: ['body:limit', 'body:initials'] - maxTextLength: 140 - warningTextLength: 30 - } - if possibleArticleType['twitter direct-message'] - @articleTypes.push { - name: 'twitter direct-message' - icon: 'twitter' - attributes: ['to'] - internal: false, - features: ['body:limit', 'body:initials'] - maxTextLength: 10000 - warningTextLength: 500 - } - if possibleArticleType.phone - @articleTypes.push { - name: 'phone' - icon: 'phone' - attributes: [] - internal: false, - features: ['attachment'] - } - if possibleArticleType['telegram personal-message'] - @articleTypes.push { - name: 'telegram personal-message' - icon: 'telegram' - attributes: [] - internal: false, - features: ['attachment'] - maxTextLength: 10000 - warningTextLength: 5000 - } - - if @permissionCheck('ticket.customer') - @type = 'note' - @articleTypes = [ - { - name: 'note' - icon: 'note' - attributes: [] - internal: false, - features: ['attachment'] - }, - ] + @setPossibleArticleTypes() if @permissionCheck('ticket.customer') @internalSelector = false @@ -181,6 +83,114 @@ class App.TicketZoomArticleNew extends App.Controller @render() ) + setPossibleArticleTypes: => + possibleArticleType = + note: true + phone: true + if @ticket && @ticket.create_article_type_id + articleTypeCreate = App.TicketArticleType.find(@ticket.create_article_type_id).name + if articleTypeCreate is 'twitter status' + possibleArticleType['twitter status'] = true + else if articleTypeCreate is 'twitter direct-message' + possibleArticleType['twitter direct-message'] = true + else if articleTypeCreate is 'email' + possibleArticleType['email'] = true + else if articleTypeCreate is 'facebook feed post' + possibleArticleType['facebook feed comment'] = true + else if articleTypeCreate is 'telegram personal-message' + possibleArticleType['telegram personal-message'] = true + if @ticket && @ticket.customer_id + customer = App.User.find(@ticket.customer_id) + if customer.email + possibleArticleType['email'] = true + + # gets referenced in @setArticleType + @articleTypes = [] + if possibleArticleType.note + internal = @Config.get('ui_ticket_zoom_article_note_new_internal') + @articleTypes.push { + name: 'note' + icon: 'note' + attributes: [] + internal: internal, + features: ['attachment'] + } + if possibleArticleType.email + attributes = ['to', 'cc', 'subject'] + if !@Config.get('ui_ticket_zoom_article_email_subject') + attributes = ['to', 'cc'] + @articleTypes.push { + name: 'email' + icon: 'email' + attributes: attributes + internal: false, + features: ['attachment'] + } + if possibleArticleType['facebook feed comment'] + @articleTypes.push { + name: 'facebook feed comment' + icon: 'facebook' + attributes: [] + internal: false, + features: [] + } + if possibleArticleType['twitter status'] + attributes = ['body:limit', 'body:initials'] + if !@Config.get('ui_ticket_zoom_article_twitter_initials') + attributes = ['body:limit'] + @articleTypes.push { + name: 'twitter status' + icon: 'twitter' + attributes: [] + internal: false, + features: ['body:limit', 'body:initials'] + maxTextLength: 140 + warningTextLength: 30 + } + if possibleArticleType['twitter direct-message'] + attributes = ['body:limit', 'body:initials'] + if !@Config.get('ui_ticket_zoom_article_twitter_initials') + attributes = ['body:limit'] + @articleTypes.push { + name: 'twitter direct-message' + icon: 'twitter' + attributes: ['to'] + internal: false, + features: ['body:limit', 'body:initials'] + maxTextLength: 10000 + warningTextLength: 500 + } + if possibleArticleType.phone + @articleTypes.push { + name: 'phone' + icon: 'phone' + attributes: [] + internal: false, + features: ['attachment'] + } + if possibleArticleType['telegram personal-message'] + @articleTypes.push { + name: 'telegram personal-message' + icon: 'telegram' + attributes: [] + internal: false, + features: ['attachment'] + maxTextLength: 10000 + warningTextLength: 5000 + } + + if @permissionCheck('ticket.customer') + @type = 'note' + @articleTypes = [ + { + name: 'note' + icon: 'note' + attributes: [] + internal: false, + features: ['attachment'] + }, + ] + placeCaretAtEnd: (el) -> el.focus() if typeof window.getSelection isnt 'undefined' && typeof document.createRange isnt 'undefined' @@ -318,9 +328,6 @@ class App.TicketZoomArticleNew extends App.Controller params.form_id = @form_id params.content_type = 'text/html' - if !params['internal'] - params['internal'] = false - if @permissionCheck('ticket.customer') sender = App.TicketArticleSender.findByAttribute('name', 'Customer') type = App.TicketArticleType.findByAttribute('name', 'web') @@ -332,6 +339,11 @@ class App.TicketZoomArticleNew extends App.Controller params.sender_id = sender.id params.type_id = type.id + if params.internal + params.internal = true + else + params.internal = false + if params.type is 'twitter status' App.Utils.htmlRemoveRichtext(@$('[data-name=body]'), false) params.content_type = 'text/plain' @@ -478,6 +490,8 @@ class App.TicketZoomArticleNew extends App.Controller @articleNewEdit.attr('data-type', type) @$('.js-selectableTypes').addClass('hide').filter("[data-type='#{type}']").removeClass('hide') + @setPossibleArticleTypes() + # get config config = {} for articleTypeConfig in @articleTypes diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/higlighter.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/highlighter.coffee similarity index 100% rename from app/assets/javascripts/app/controllers/ticket_zoom/higlighter.coffee rename to app/assets/javascripts/app/controllers/ticket_zoom/highlighter.coffee diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/setting.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/setting.coffee new file mode 100644 index 000000000..1103f9e3c --- /dev/null +++ b/app/assets/javascripts/app/controllers/ticket_zoom/setting.coffee @@ -0,0 +1,35 @@ +class App.TicketZoomSetting extends App.Controller + events: + 'click .js-setting': 'show' + + constructor: -> + super + return if !@permissionCheck('admin') + @render() + + render: -> + @html(App.view('ticket_zoom/setting')()) + + show: -> + new Modal() + +class Modal extends App.ControllerModal + buttonClose: true + buttonCancel: true + buttonSubmit: false + head: 'Settings' + + constructor: -> + super + + render: => + super + + post: => + new App.SettingsArea( + area: 'UI::TicketZoom' + el: @el.find('.modal-body') + ) + + content: -> + App.view('generic/page_loading')() diff --git a/app/assets/javascripts/app/views/ticket_zoom.jst.eco b/app/assets/javascripts/app/views/ticket_zoom.jst.eco index 36ef86765..89d8733a8 100644 --- a/app/assets/javascripts/app/views/ticket_zoom.jst.eco +++ b/app/assets/javascripts/app/views/ticket_zoom.jst.eco @@ -1,21 +1,22 @@