close #1521 Fixed: Can't edit revenue when there's an attachment
This commit is contained in:
parent
9c9970eafb
commit
a57751081c
@ -121,10 +121,21 @@ class Uploads extends Controller
|
|||||||
*/
|
*/
|
||||||
public function destroy($id, Request $request)
|
public function destroy($id, Request $request)
|
||||||
{
|
{
|
||||||
|
$return = back();
|
||||||
|
|
||||||
|
if ($request->has('ajax') && $request->get('ajax')) {
|
||||||
|
$return = [
|
||||||
|
'success' => true,
|
||||||
|
'errors' => false,
|
||||||
|
'message' => '',
|
||||||
|
'redirect' => $request->get('redirect')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$media = Media::find($id);
|
$media = Media::find($id);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return back();
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get file path
|
// Get file path
|
||||||
@ -133,7 +144,7 @@ class Uploads extends Controller
|
|||||||
|
|
||||||
flash($message)->warning();
|
flash($message)->warning();
|
||||||
|
|
||||||
return back();
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$media->delete(); //will not delete files
|
$media->delete(); //will not delete files
|
||||||
@ -150,7 +161,7 @@ class Uploads extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return back();
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
74
resources/assets/js/mixins/global.js
vendored
74
resources/assets/js/mixins/global.js
vendored
@ -313,6 +313,80 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Delete attachment file
|
||||||
|
onDeleteFile(file_id, url, title, message, button_cancel, button_delete) {
|
||||||
|
let file_data = {
|
||||||
|
page: null,
|
||||||
|
key: null,
|
||||||
|
value: null,
|
||||||
|
ajax: true,
|
||||||
|
redirect: window.location.href
|
||||||
|
};
|
||||||
|
|
||||||
|
if (this.form['page' + file_id]) {
|
||||||
|
file_data.page = this.form['page' + file_id];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.form['key' + file_id]) {
|
||||||
|
file_data.key = this.form['key' + file_id];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.form['value' + file_id]) {
|
||||||
|
file_data.value = this.form['value' + file_id];
|
||||||
|
}
|
||||||
|
|
||||||
|
let confirm = {
|
||||||
|
url: url,
|
||||||
|
title: title,
|
||||||
|
message: message,
|
||||||
|
button_cancel: button_cancel,
|
||||||
|
button_delete: button_delete,
|
||||||
|
file_data: file_data,
|
||||||
|
show: true
|
||||||
|
};
|
||||||
|
|
||||||
|
this.component = Vue.component('add-new-component', (resolve, reject) => {
|
||||||
|
resolve({
|
||||||
|
template : '<div id="dynamic-component"><akaunting-modal v-if="confirm.show" :show="confirm.show" :title="confirm.title" :message="confirm.message" :button_cancel="confirm.button_cancel" :button_delete="confirm.button_delete" @confirm="onDelete" @cancel="cancelDelete"></akaunting-modal></div>',
|
||||||
|
|
||||||
|
components: {
|
||||||
|
AkauntingModal,
|
||||||
|
},
|
||||||
|
|
||||||
|
data: function () {
|
||||||
|
return {
|
||||||
|
confirm: confirm,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
// Delete action post
|
||||||
|
async onDelete() {
|
||||||
|
let promise = Promise.resolve(axios({
|
||||||
|
method: 'DELETE',
|
||||||
|
url: this.confirm.url,
|
||||||
|
data: file_data
|
||||||
|
}));
|
||||||
|
|
||||||
|
promise.then(response => {
|
||||||
|
if (response.data.redirect) {
|
||||||
|
window.location.href = response.data.redirect;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
this.success = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// Close modal empty default value
|
||||||
|
cancelDelete() {
|
||||||
|
this.confirm.show = false;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
clickTab(id) {
|
clickTab(id) {
|
||||||
let event = new document.window.KeyboardEvent('keydown', { keyCode: 9 }); // Tab key
|
let event = new document.window.KeyboardEvent('keydown', { keyCode: 9 }); // Tab key
|
||||||
|
|
||||||
|
@ -26,23 +26,15 @@
|
|||||||
|
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
@permission('delete-common-uploads')
|
@permission('delete-common-uploads')
|
||||||
{!! Form::open([
|
<a href="javascript:void();" id="remove-{{ $column_name }}" @click="onDeleteFile('{{ $file->id }}', '{{ route('uploads.destroy', $file->id) }}', '{{ trans('general.title.delete', ['type' => $column_name]) }}', '{{ trans('general.delete_confirm', ['name' => $file->basename, 'type' => $column_name]) }} ', '{{ trans('general.cancel') }}', '{{ trans('general.delete') }}')" type="button" class="btn btn-sm btn-danger text-white header-button-top">
|
||||||
'id' => $column_name. '-' . $file->id,
|
<i class="fas fa-times"></i>
|
||||||
'method' => 'DELETE',
|
</a>
|
||||||
'url' => [url('uploads/' . $file->id)],
|
|
||||||
'class' => 'd-inline'
|
|
||||||
]) !!}
|
|
||||||
|
|
||||||
<a href="javascript:void();" id="remove-{{ $column_name }}" type="button" class="btn btn-sm btn-danger text-white header-button-top">
|
@if ($options)
|
||||||
<i class="fas fa-times"></i>
|
<input type="hidden" name="page_{{ $file->id}}" id="file-page-{{ $file->id}}" value="{{ $options['page'] }}" />
|
||||||
</a>
|
<input type="hidden" name="key_{{ $file->id}}" id="file-key-{{ $file->id}}" value="{{ $options['key'] }}" />
|
||||||
|
<input type="hidden" name="value_{{ $file->id}}" id="file-value-{{ $file->id}}" value="{{ $file->id }}" />
|
||||||
@if ($options)
|
@endif
|
||||||
<input type="hidden" name="page" value="{{ $options['page'] }}" />
|
|
||||||
<input type="hidden" name="key" value="{{ $options['key'] }}" />
|
|
||||||
<input type="hidden" name="value" value="{{ $file->id }}" />
|
|
||||||
@endif
|
|
||||||
{!! Form::close() !!}
|
|
||||||
@endpermission
|
@endpermission
|
||||||
|
|
||||||
<a href="{{ url('uploads/' . $file->id . '/download') }}" type="button" class="btn btn-sm btn-info text-white header-button-top">
|
<a href="{{ url('uploads/' . $file->id . '/download') }}" type="button" class="btn btn-sm btn-info text-white header-button-top">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user