Bulk action permission check fixed.
This commit is contained in:
parent
d9e9271858
commit
2000de7b7b
@ -29,6 +29,18 @@ BulkActions extends Controller
|
|||||||
$bulk_actions = app('App\BulkActions\\' . ucfirst($group) . '\\' . ucfirst($type));
|
$bulk_actions = app('App\BulkActions\\' . ucfirst($group) . '\\' . ucfirst($type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($bulk_actions->actions[$request->get('handle')]['permission']) && !user()->can($bulk_actions->actions[$request->get('handle')]['permission'])) {
|
||||||
|
flash(trans('errors.message.403'))->error();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => false,
|
||||||
|
'redirect' => true,
|
||||||
|
'error' => true,
|
||||||
|
'data' => [],
|
||||||
|
'message' => trans('errors.message.403')
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
$result = $bulk_actions->{$request->get('handle')}($request);
|
$result = $bulk_actions->{$request->get('handle')}($request);
|
||||||
|
|
||||||
if (!empty($result) && ($result instanceof \Symfony\Component\HttpFoundation\BinaryFileResponse)) {
|
if (!empty($result) && ($result instanceof \Symfony\Component\HttpFoundation\BinaryFileResponse)) {
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
@stack('bulk_action_row_input_start')
|
@stack('bulk_action_row_input_start')
|
||||||
@php
|
@php
|
||||||
if (is_array($path)) {
|
if (is_array($path)) {
|
||||||
$path = route('bulk-actions.action', $path);
|
$path = route('bulk-actions.action', $path);
|
||||||
} else {
|
} else {
|
||||||
$path = url('common/bulk-actions/' . $path);
|
$path = url('common/bulk-actions/' . $path);
|
||||||
}
|
}
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
<div class="align-items-center d-none"
|
<div class="align-items-center d-none"
|
||||||
v-if="bulk_action.show"
|
v-if="bulk_action.show"
|
||||||
:class="[{'show': bulk_action.show}]">
|
:class="[{'show': bulk_action.show}]">
|
||||||
<div class="mr-6">
|
<div class="mr-6">
|
||||||
<span class="text-white d-none d-sm-block">
|
<span class="text-white d-none d-sm-block">
|
||||||
<b v-text="bulk_action.count"></b>
|
<b v-text="bulk_action.count"></b>
|
||||||
<span v-if="bulk_action.count === 1">
|
<span v-if="bulk_action.count === 1">
|
||||||
@ -21,68 +21,70 @@
|
|||||||
</span>
|
</span>
|
||||||
{{ trans('bulk_actions.selected') }}
|
{{ trans('bulk_actions.selected') }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="w-25 mr-4" v-if="bulk_action.count">
|
<div class="w-25 mr-4" v-if="bulk_action.count">
|
||||||
<div class="form-group mb-0">
|
<div class="form-group mb-0">
|
||||||
<select
|
<select
|
||||||
class="form-control form-control-sm"
|
class="form-control form-control-sm"
|
||||||
v-model="{{ !empty($attributes['v-model']) ? $attributes['v-model'] : 'bulk_action.value' }}"
|
v-model="{{ !empty($attributes['v-model']) ? $attributes['v-model'] : 'bulk_action.value' }}"
|
||||||
@change="onChange">
|
@change="onChange">
|
||||||
<option value="*">{{ trans_choice('bulk_actions.bulk_actions', 2) }}</option>
|
<option value="*">{{ trans_choice('bulk_actions.bulk_actions', 2) }}</option>
|
||||||
@foreach($actions as $key => $action)
|
@foreach($actions as $key => $action)
|
||||||
<option
|
@if((!isset($action['permission'])) || (isset($action['permission']) && user()->can($action['permission'])))
|
||||||
value="{{ $key }}"
|
<option
|
||||||
@if(!empty($action['message']))
|
value="{{ $key }}"
|
||||||
data-message="{{ trans_choice($action['message'], 2, ['type' => $text]) }}"
|
@if(!empty($action['message']))
|
||||||
@endif
|
data-message="{{ trans_choice($action['message'], 2, ['type' => $text]) }}"
|
||||||
>{{ trans($action['name']) }}</option>
|
@endif
|
||||||
@endforeach
|
>{{ trans($action['name']) }}</option>
|
||||||
</select>
|
@endif
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
|
||||||
<input type="hidden" name="bulk_action_path" value="{{ $path }}" />
|
<input type="hidden" name="bulk_action_path" value="{{ $path }}" />
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mr-4" v-if="bulk_action.count">
|
|
||||||
<button type="button" class="btn btn-sm btn-outline-confirm"
|
|
||||||
v-if="bulk_action.message.length"
|
|
||||||
@click="bulk_action.modal=true">
|
|
||||||
<span>{{ trans('general.confirm') }}</span>
|
|
||||||
</button>
|
|
||||||
<button type="button" class="btn btn-sm btn-outline-confirm"
|
|
||||||
v-if="!bulk_action.message.length"
|
|
||||||
@click="onAction">
|
|
||||||
<span>{{ trans('general.confirm') }}</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mr-4" v-if="bulk_action.count">
|
|
||||||
<button type="button" class="btn btn-outline-clear btn-sm"
|
|
||||||
@click="onClear">
|
|
||||||
<span>{{ trans('general.clear') }}</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<akaunting-modal
|
<div class="mr-4" v-if="bulk_action.count">
|
||||||
:show="bulk_action.modal"
|
<button type="button" class="btn btn-sm btn-outline-confirm"
|
||||||
:title="'{{ trans_choice('general.items', 2) }}'"
|
v-if="bulk_action.message.length"
|
||||||
:message="bulk_action.message"
|
@click="bulk_action.modal=true">
|
||||||
@cancel="onCancel"
|
<span>{{ trans('general.confirm') }}</span>
|
||||||
v-if='bulk_action.message && bulk_action.modal'>
|
</button>
|
||||||
<template #card-footer>
|
<button type="button" class="btn btn-sm btn-outline-confirm"
|
||||||
<div class="float-right">
|
v-if="!bulk_action.message.length"
|
||||||
<button type="button" class="btn btn-outline-secondary" @click="onCancel">
|
@click="onAction">
|
||||||
<span>{{ trans('general.cancel') }}</span>
|
<span>{{ trans('general.confirm') }}</span>
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<button :disabled="bulk_action.loading" type="button" class="btn btn-success button-submit" @click="onAction">
|
<div class="mr-4" v-if="bulk_action.count">
|
||||||
<div class="aka-loader d-none"></div>
|
<button type="button" class="btn btn-outline-clear btn-sm"
|
||||||
<span>{{ trans('general.confirm') }}</span>
|
@click="onClear">
|
||||||
</button>
|
<span>{{ trans('general.clear') }}</span>
|
||||||
</div>
|
</button>
|
||||||
</template>
|
</div>
|
||||||
</akaunting-modal>
|
</div>
|
||||||
|
|
||||||
|
<akaunting-modal
|
||||||
|
:show="bulk_action.modal"
|
||||||
|
:title="'{{ trans_choice('general.items', 2) }}'"
|
||||||
|
:message="bulk_action.message"
|
||||||
|
@cancel="onCancel"
|
||||||
|
v-if='bulk_action.message && bulk_action.modal'>
|
||||||
|
<template #card-footer>
|
||||||
|
<div class="float-right">
|
||||||
|
<button type="button" class="btn btn-outline-secondary" @click="onCancel">
|
||||||
|
<span>{{ trans('general.cancel') }}</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button :disabled="bulk_action.loading" type="button" class="btn btn-success button-submit" @click="onAction">
|
||||||
|
<div class="aka-loader d-none"></div>
|
||||||
|
<span>{{ trans('general.confirm') }}</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</akaunting-modal>
|
||||||
|
|
||||||
@stack('bulk_action_row_input_end')
|
@stack('bulk_action_row_input_end')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user