Mark ticket as changed if only one attachment is uploaded. Delete uploaded attachments on form rest.

This commit is contained in:
Martin Edenhofer 2015-11-04 12:42:57 +01:00
parent 58b90fd489
commit 7115103b5e
3 changed files with 35 additions and 7 deletions

View file

@ -415,6 +415,14 @@ class App.TicketZoom extends App.Controller
currentParams = currentParams =
ticket: @formParam( @el.find('.edit') ) ticket: @formParam( @el.find('.edit') )
article: @formParam( @el.find('.article-add') ) article: @formParam( @el.find('.article-add') )
# add attachments if exist
attachmentCount = @$('.article-add .textBubble .attachments .attachment').length
if attachmentCount > 0
currentParams.article.attachments = true
else
delete currentParams.article.attachments
#console.log('lll', currentStore) #console.log('lll', currentStore)
# remove not needed attributes # remove not needed attributes
delete currentParams.article.form_id delete currentParams.article.form_id
@ -650,6 +658,14 @@ class App.TicketZoom extends App.Controller
# reset task # reset task
@taskReset() @taskReset()
# reset/delete uploaded attachments
App.Ajax.request(
type: 'DELETE'
url: App.Config.get('api_path') + '/ticket_attachment_upload'
data: JSON.stringify( { form_id: @form_id } )
processData: false
)
# reset edit ticket / reset new article # reset edit ticket / reset new article
App.Event.trigger('ui::ticket::taskReset', { ticket_id: @ticket.id }) App.Event.trigger('ui::ticket::taskReset', { ticket_id: @ticket.id })

View file

@ -517,7 +517,7 @@ class App.TicketZoomArticleNew extends App.Controller
App.Ajax.request( App.Ajax.request(
type: 'DELETE' type: 'DELETE'
url: App.Config.get('api_path') + '/ticket_attachment_upload' url: App.Config.get('api_path') + '/ticket_attachment_upload'
data: JSON.stringify( { store_id: store_id } ), data: JSON.stringify( { store_id: store_id } )
processData: false processData: false
) )

View file

@ -66,12 +66,24 @@ class TicketArticlesController < ApplicationController
# DELETE /ticket_attachment_upload # DELETE /ticket_attachment_upload
def ticket_attachment_upload_delete def ticket_attachment_upload_delete
Store.remove_item( params[:store_id] ) if params[:store_id]
Store.remove_item(params[:store_id])
# return result
render json: { render json: {
success: true, success: true,
} }
return
elsif params[:form_id]
Store.remove(
object: 'UploadCache',
o_id: params[:form_id],
)
render json: {
success: true,
}
return
end
render json: { message: 'No such store_id or form_id!' }, status: :unprocessable_entity
end end
# POST /ticket_attachment_upload # POST /ticket_attachment_upload