diff --git a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee index f05dbe36b..3e4078eb2 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee @@ -284,6 +284,20 @@ class App.ControllerForm extends App.Controller # textarea else if attribute.tag is 'textarea' item = $( App.view('generic/textarea')( attribute: attribute ) ) + if attribute.upload + fileUploaderId = 'file-uploader-' + new Date().getTime() + '-' + Math.floor( Math.random() * 99999 ) + item.after('
') + + # add file uploader + u = => + uploader = new qq.FileUploader( + element: document.getElementById(fileUploaderId) + action: '/api/ticket_attachment_new' + debug: false + params: + form_id: @form_id + ) + @delay( u, 200 ) # tag else if attribute.tag is 'tag' @@ -643,6 +657,9 @@ class App.ControllerForm extends App.Controller App.Log.log 'ControllerForm', 'notice', 'formParam', form, param return param + @formId: -> + formId = new Date().getTime() + Math.floor( Math.random() * 99999 ) + formId.toString().substr formId.toString().length-9, 9 @disable: (form) -> App.Log.log 'ControllerForm', 'notice', 'disable...', $(form.target).parent() diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee index d4fd34e2c..7c3818822 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee @@ -15,6 +15,7 @@ class Index extends App.Controller # set title @title 'New Ticket' + @form_id = App.ControllerForm.formId() @fetch(params) @navupdate '#ticket_create' @@ -105,20 +106,20 @@ class Index extends App.Controller { name: 'owner_id', display: 'Owner', tag: 'select', multiple: false, null: true, filter: @edit_form, nulloption: true, relation: 'User', default: defaults['owner_id'], class: 'span7', }, { name: 'tags', display: 'Tags', tag: 'tag', type: 'text', null: true, default: defaults['tags'], class: 'span7', }, { name: 'subject', display: 'Subject', tag: 'input', type: 'text', limit: 200, null: false, default: defaults['subject'], class: 'span7', }, - { name: 'body', display: 'Text', tag: 'textarea', rows: 6, null: false, default: defaults['body'], class: 'span7', }, + { name: 'body', display: 'Text', tag: 'textarea', rows: 8, null: false, default: defaults['body'], class: 'span7', upload: true }, { name: 'ticket_state_id', display: 'State', tag: 'select', multiple: false, null: false, filter: @edit_form, relation: 'TicketState', default: defaults['ticket_state_id'], translate: true, class: 'medium' }, { name: 'ticket_priority_id', display: 'Priority', tag: 'select', multiple: false, null: false, filter: @edit_form, relation: 'TicketPriority', default: defaults['ticket_priority_id'], translate: true, class: 'medium' }, ] @html App.view('agent_ticket_create')( head: 'New Ticket' ) new App.ControllerForm( - el: @el.find('#form_create'), - model: { - configure_attributes: configure_attributes, - className: 'create', - }, - autofocus: true, - form_data: @edit_form, + el: @el.find('#form_create') + form_id: @form_id + model: + configure_attributes: configure_attributes + className: 'create' + autofocus: true + form_data: @edit_form ) # add elastic to textarea @@ -176,15 +177,14 @@ class Index extends App.Controller # create article params['article'] = { - from: params.customer_id_autocompletion, - to: (group && group.name) || '', - subject: params.subject, - body: params.body, - ticket_article_type_id: type.id, - ticket_article_sender_id: sender.id, - created_by_id: params.customer_id, + from: params.customer_id_autocompletion + to: (group && group.name) || '' + subject: params.subject + body: params.body + ticket_article_type_id: type.id + ticket_article_sender_id: sender.id + form_id: @form_id } -# console.log('params', params) object.load(params) diff --git a/app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee index 3df6397cf..ce8d20886 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee @@ -20,6 +20,7 @@ class Index extends App.Controller @navupdate '#' + @form_id = App.ControllerForm.formId() @edit_form = undefined @ticket_id = params.ticket_id @article_id = params.article_id @@ -105,7 +106,7 @@ class Index extends App.Controller { name: 'cc', display: 'Cc', tag: 'input', type: 'text', limit: 100, null: true, class: 'span7', item_class: 'hide' }, { name: 'subject', display: 'Subject', tag: 'input', type: 'text', limit: 100, null: true, class: 'span7', item_class: 'hide' }, { name: 'in_reply_to', display: 'In Reply to', tag: 'input', type: 'text', limit: 100, null: true, class: 'span7', item_class: 'hide' }, - { name: 'body', display: 'Text', tag: 'textarea', rows: 5, limit: 100, null: true, class: 'span7', item_class: '' }, + { name: 'body', display: 'Text', tag: 'textarea', rows: 6, limit: 100, null: true, class: 'span7', item_class: '', upload: true }, { name: 'internal', display: 'Visability', tag: 'select', default: false, null: true, options: { true: 'internal', false: 'public' }, class: 'medium', item_class: '' }, ] if @isRole('Customer') @@ -114,7 +115,7 @@ class Index extends App.Controller { name: 'cc', display: 'Cc', tag: 'input', type: 'text', limit: 100, null: true, class: 'span7', item_class: 'hide' }, { name: 'subject', display: 'Subject', tag: 'input', type: 'text', limit: 100, null: true, class: 'span7', item_class: 'hide' }, { name: 'in_reply_to', display: 'In Reply to', tag: 'input', type: 'text', limit: 100, null: true, class: 'span7', item_class: 'hide' }, - { name: 'body', display: 'Text', tag: 'textarea', rows: 5, limit: 100, null: true, class: 'span7', item_class: '' }, + { name: 'body', display: 'Text', tag: 'textarea', rows: 6, limit: 100, null: true, class: 'span7', item_class: '', upload: true }, ] @html App.view('agent_ticket_zoom')( @@ -125,6 +126,7 @@ class Index extends App.Controller new App.ControllerForm( el: @el.find('#form-ticket-update') + form_id: @form_id model: configure_attributes: @configure_attributes_ticket className: 'create' @@ -134,6 +136,7 @@ class Index extends App.Controller new App.ControllerForm( el: @el.find('#form-article-update') + form_id: @form_id model: configure_attributes: @configure_attributes_article form_data: @edit_form @@ -158,18 +161,6 @@ class Index extends App.Controller @scrollTo( 0, offset ) @delay( scrollTo, 100 ) - @delay(@u, 200) - - u: => - uploader = new qq.FileUploader( - element: document.getElementById('file-uploader') - action: '/api/ticket_attachment_new' - params: - form: 'TicketZoom' - form_id: @ticket.id - debug: false - ) - ticket_action_row: => # start customer info controller @@ -410,8 +401,10 @@ class Index extends App.Controller # create article if params['body'] article = new App.TicketArticle - params.from = @Session.get( 'firstname' ) + ' ' + @Session.get( 'lastname' ) + params.from = @Session.get( 'firstname' ) + ' ' + @Session.get( 'lastname' ) params.ticket_id = @ticket.id + params.form_id = @form_id + if !params['internal'] params['internal'] = false diff --git a/app/assets/javascripts/app/controllers/customer_ticket_new.js.coffee b/app/assets/javascripts/app/controllers/customer_ticket_new.js.coffee index 9f8f95164..9dc1149aa 100644 --- a/app/assets/javascripts/app/controllers/customer_ticket_new.js.coffee +++ b/app/assets/javascripts/app/controllers/customer_ticket_new.js.coffee @@ -11,9 +11,10 @@ class Index extends App.Controller # check authentication return if !@authenticate() - + # set title @title 'New Ticket' + @form_id = App.ControllerForm.formId() @fetch(params) @navupdate '#customer_ticket_new' @@ -98,20 +99,20 @@ class Index extends App.Controller { name: 'group_id', display: 'Group', tag: 'select', multiple: false, null: false, filter: groupFilter, nulloption: true, relation: 'Group', default: defaults['group_id'], class: 'span7', }, # { name: 'owner_id', display: 'Owner', tag: 'select', multiple: false, null: true, filter: @edit_form, nulloption: true, relation: 'User', default: defaults['owner_id'], class: 'span7', }, { name: 'subject', display: 'Subject', tag: 'input', type: 'text', limit: 100, null: false, default: defaults['subject'], class: 'span7', }, - { name: 'body', display: 'Text', tag: 'textarea', rows: 10, null: false, default: defaults['body'], class: 'span7', }, + { name: 'body', display: 'Text', tag: 'textarea', rows: 10, null: false, default: defaults['body'], class: 'span7', upload: true }, # { name: 'ticket_state_id', display: 'State', tag: 'select', multiple: false, null: false, filter: @edit_form, relation: 'TicketState', default: defaults['ticket_state_id'], translate: true, class: 'medium' }, # { name: 'ticket_priority_id', display: 'Priority', tag: 'select', multiple: false, null: false, filter: @edit_form, relation: 'TicketPriority', default: defaults['ticket_priority_id'], translate: true, class: 'medium' }, ] @html App.view('agent_ticket_create')( head: 'New Ticket' ) new App.ControllerForm( - el: @el.find('#form_create'), - model: { - configure_attributes: configure_attributes, - className: 'create', - }, - autofocus: true, - form_data: @edit_form, + el: @el.find('#form_create') + form_id: @form_id + model: + configure_attributes: configure_attributes + className: 'create' + autofocus: true + form_data: @edit_form ) # add elastic to textarea @@ -157,13 +158,13 @@ class Index extends App.Controller # create article params['article'] = { - from: "#{ @Session.get('firstname') } #{ @Session.get('lastname') }", - to: (group && group.name) || '', - subject: params.subject, - body: params.body, - ticket_article_type_id: type.id, - ticket_article_sender_id: sender.id, - created_by_id: @Session.get('id'), + from: "#{ @Session.get('firstname') } #{ @Session.get('lastname') }" + to: (group && group.name) || '' + subject: params.subject + body: params.body + ticket_article_type_id: type.id + ticket_article_sender_id: sender.id + form_id: @form_id } # console.log('params', params) diff --git a/app/assets/javascripts/app/lib/base/fileuploader.js b/app/assets/javascripts/app/lib/base/fileuploader.js index 6da5d90b3..42786f462 100644 --- a/app/assets/javascripts/app/lib/base/fileuploader.js +++ b/app/assets/javascripts/app/lib/base/fileuploader.js @@ -485,8 +485,8 @@ qq.FileUploader = function(o){ listElement: null, template: '