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 =
ticket: @formParam( @el.find('.edit') )
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)
# remove not needed attributes
delete currentParams.article.form_id
@ -650,6 +658,14 @@ class App.TicketZoom extends App.Controller
# reset task
@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
App.Event.trigger('ui::ticket::taskReset', { ticket_id: @ticket.id })

View file

@ -371,7 +371,7 @@ class App.TicketZoomArticleNew extends App.Controller
openTextarea: (event, withoutAnimation) =>
if @articleNewEdit.hasClass('is-open')
return
duration = 300
if withoutAnimation
@ -517,7 +517,7 @@ class App.TicketZoomArticleNew extends App.Controller
App.Ajax.request(
type: 'DELETE'
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
)

View file

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