mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Fix for deleting documents
This commit is contained in:
parent
7599edbc8c
commit
b32a9110c7
@ -14,6 +14,7 @@ use App\Ninja\Repositories\DocumentRepository;
|
|||||||
|
|
||||||
use App\Http\Requests\DocumentRequest;
|
use App\Http\Requests\DocumentRequest;
|
||||||
use App\Http\Requests\CreateDocumentRequest;
|
use App\Http\Requests\CreateDocumentRequest;
|
||||||
|
use App\Http\Requests\UpdateDocumentRequest;
|
||||||
|
|
||||||
class DocumentController extends BaseController
|
class DocumentController extends BaseController
|
||||||
{
|
{
|
||||||
@ -120,4 +121,11 @@ class DocumentController extends BaseController
|
|||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete(UpdateDocumentRequest $request)
|
||||||
|
{
|
||||||
|
$request->entity()->delete();
|
||||||
|
|
||||||
|
return RESULT_SUCCESS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
26
app/Http/Requests/UpdateDocumentRequest.php
Normal file
26
app/Http/Requests/UpdateDocumentRequest.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php namespace App\Http\Requests;
|
||||||
|
|
||||||
|
class UpdateDocumentRequest extends DocumentRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize()
|
||||||
|
{
|
||||||
|
return $this->user()->can('edit', $this->entity());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -145,6 +145,7 @@ Route::group(['middleware' => 'auth:user'], function() {
|
|||||||
Route::get('documents/js/{documents}/{filename}', 'DocumentController@getVFSJS');
|
Route::get('documents/js/{documents}/{filename}', 'DocumentController@getVFSJS');
|
||||||
Route::get('documents/preview/{documents}/{filename?}', 'DocumentController@getPreview');
|
Route::get('documents/preview/{documents}/{filename?}', 'DocumentController@getPreview');
|
||||||
Route::post('document', 'DocumentController@postUpload');
|
Route::post('document', 'DocumentController@postUpload');
|
||||||
|
Route::delete('documents/{documents}', 'DocumentController@delete');
|
||||||
|
|
||||||
Route::get('quotes/create/{client_id?}', 'QuoteController@create');
|
Route::get('quotes/create/{client_id?}', 'QuoteController@create');
|
||||||
Route::get('quotes/{invoices}/clone', 'InvoiceController@cloneInvoice');
|
Route::get('quotes/{invoices}/clone', 'InvoiceController@cloneInvoice');
|
||||||
|
@ -243,6 +243,7 @@
|
|||||||
},
|
},
|
||||||
acceptedFiles:{!! json_encode(implode(',',\App\Models\Document::$allowedMimes)) !!},
|
acceptedFiles:{!! json_encode(implode(',',\App\Models\Document::$allowedMimes)) !!},
|
||||||
addRemoveLinks:true,
|
addRemoveLinks:true,
|
||||||
|
dictRemoveFileConfirmation:"{{trans('texts.are_you_sure')}}",
|
||||||
@foreach(trans('texts.dropzone') as $key=>$text)
|
@foreach(trans('texts.dropzone') as $key=>$text)
|
||||||
"dict{{strval($key)}}":"{{strval($text)}}",
|
"dict{{strval($key)}}":"{{strval($text)}}",
|
||||||
@endforeach
|
@endforeach
|
||||||
@ -392,6 +393,13 @@
|
|||||||
|
|
||||||
function handleDocumentRemoved(file){
|
function handleDocumentRemoved(file){
|
||||||
model.removeDocument(file.public_id);
|
model.removeDocument(file.public_id);
|
||||||
|
$.ajax({
|
||||||
|
url: '{{ '/documents/' }}' + file.public_id,
|
||||||
|
type: 'DELETE',
|
||||||
|
success: function(result) {
|
||||||
|
// Do something with the result
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDocumentUploaded(file, response){
|
function handleDocumentUploaded(file, response){
|
||||||
|
@ -992,6 +992,7 @@
|
|||||||
},
|
},
|
||||||
acceptedFiles:{!! json_encode(implode(',',\App\Models\Document::$allowedMimes)) !!},
|
acceptedFiles:{!! json_encode(implode(',',\App\Models\Document::$allowedMimes)) !!},
|
||||||
addRemoveLinks:true,
|
addRemoveLinks:true,
|
||||||
|
dictRemoveFileConfirmation:"{{trans('texts.are_you_sure')}}",
|
||||||
@foreach(trans('texts.dropzone') as $key=>$text)
|
@foreach(trans('texts.dropzone') as $key=>$text)
|
||||||
"dict{{strval($key)}}":"{{strval($text)}}",
|
"dict{{strval($key)}}":"{{strval($text)}}",
|
||||||
@endforeach
|
@endforeach
|
||||||
@ -1415,6 +1416,13 @@
|
|||||||
function handleDocumentRemoved(file){
|
function handleDocumentRemoved(file){
|
||||||
model.invoice().removeDocument(file.public_id);
|
model.invoice().removeDocument(file.public_id);
|
||||||
refreshPDF(true);
|
refreshPDF(true);
|
||||||
|
$.ajax({
|
||||||
|
url: '{{ '/documents/' }}' + file.public_id,
|
||||||
|
type: 'DELETE',
|
||||||
|
success: function(result) {
|
||||||
|
// Do something with the result
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDocumentUploaded(file, response){
|
function handleDocumentUploaded(file, response){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user