mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
Starting off
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
aef45a90b2
commit
db73f80058
|
@ -148,6 +148,7 @@ class AssetsTransformer
|
||||||
'restore' => ($asset->deleted_at!='' && Gate::allows('create', Asset::class)) ? true : false,
|
'restore' => ($asset->deleted_at!='' && Gate::allows('create', Asset::class)) ? true : false,
|
||||||
'update' => ($asset->deleted_at=='' && Gate::allows('update', Asset::class)) ? true : false,
|
'update' => ($asset->deleted_at=='' && Gate::allows('update', Asset::class)) ? true : false,
|
||||||
'delete' => ($asset->deleted_at=='' && $asset->assigned_to =='' && Gate::allows('delete', Asset::class) && ($asset->deleted_at == '')) ? true : false,
|
'delete' => ($asset->deleted_at=='' && $asset->assigned_to =='' && Gate::allows('delete', Asset::class) && ($asset->deleted_at == '')) ? true : false,
|
||||||
|
'selectable' => ($asset->deleted_at=='' && $asset->assigned_to =='' && Gate::allows('delete', Asset::class) && ($asset->deleted_at == '')) ? true : false,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,9 @@ class LocationsTransformer
|
||||||
$permissions_array['available_actions'] = [
|
$permissions_array['available_actions'] = [
|
||||||
'update' => Gate::allows('update', Location::class) ? true : false,
|
'update' => Gate::allows('update', Location::class) ? true : false,
|
||||||
'delete' => $location->isDeletable(),
|
'delete' => $location->isDeletable(),
|
||||||
|
'bulk_selectable' => [
|
||||||
|
'delete' => $location->isDeletable()]
|
||||||
|
,
|
||||||
'clone' => (Gate::allows('create', Location::class) && ($location->deleted_at == '')),
|
'clone' => (Gate::allows('create', Location::class) && ($location->deleted_at == '')),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ class UsersTransformer
|
||||||
'delete' => $user->isDeletable(),
|
'delete' => $user->isDeletable(),
|
||||||
'clone' => (Gate::allows('create', User::class) && ($user->deleted_at == '')),
|
'clone' => (Gate::allows('create', User::class) && ($user->deleted_at == '')),
|
||||||
'restore' => (Gate::allows('create', User::class) && ($user->deleted_at != '')),
|
'restore' => (Gate::allows('create', User::class) && ($user->deleted_at != '')),
|
||||||
|
'selectable' => $user->isDeletable(),
|
||||||
];
|
];
|
||||||
|
|
||||||
$array += $permissions_array;
|
$array += $permissions_array;
|
||||||
|
|
|
@ -19,8 +19,9 @@ class AssetPresenter extends Presenter
|
||||||
{
|
{
|
||||||
$layout = [
|
$layout = [
|
||||||
[
|
[
|
||||||
'field' => 'checkbox',
|
'field' => 'bulk_selectable',
|
||||||
'checkbox' => true,
|
'checkbox' => true,
|
||||||
|
'formatter' => 'checkboxEnabledFormatter',
|
||||||
], [
|
], [
|
||||||
'field' => 'id',
|
'field' => 'id',
|
||||||
'searchable' => false,
|
'searchable' => false,
|
||||||
|
|
|
@ -14,7 +14,11 @@ class LocationPresenter extends Presenter
|
||||||
public static function dataTableLayout()
|
public static function dataTableLayout()
|
||||||
{
|
{
|
||||||
$layout = [
|
$layout = [
|
||||||
|
[
|
||||||
|
'field' => 'bulk_selectable',
|
||||||
|
'checkbox' => true,
|
||||||
|
'formatter' => 'checkboxEnabledFormatter',
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'field' => 'id',
|
'field' => 'id',
|
||||||
'searchable' => false,
|
'searchable' => false,
|
||||||
|
|
|
@ -22,8 +22,9 @@ class UserPresenter extends Presenter
|
||||||
{
|
{
|
||||||
$layout = [
|
$layout = [
|
||||||
[
|
[
|
||||||
'field' => 'checkbox',
|
'field' => 'bulk_selectable',
|
||||||
'checkbox' => true,
|
'checkbox' => true,
|
||||||
|
'formatter' => 'checkboxEnabledFormatter',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'field' => 'id',
|
'field' => 'id',
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
<table
|
<table
|
||||||
data-columns="{{ \App\Presenters\LocationPresenter::dataTableLayout() }}"
|
data-columns="{{ \App\Presenters\LocationPresenter::dataTableLayout() }}"
|
||||||
data-cookie-id-table="locationTable"
|
data-cookie-id-table="locationTable"
|
||||||
|
data-click-to-select="true"
|
||||||
data-pagination="true"
|
data-pagination="true"
|
||||||
data-id-table="locationTable"
|
data-id-table="locationTable"
|
||||||
data-search="true"
|
data-search="true"
|
||||||
|
|
|
@ -398,17 +398,35 @@
|
||||||
// Convert line breaks to <br>
|
// Convert line breaks to <br>
|
||||||
function notesFormatter(value) {
|
function notesFormatter(value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
return value.replace(/(?:\r\n|\r|\n)/g, '<br />');;
|
return value.replace(/(?:\r\n|\r|\n)/g, '<br />');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if checkbox should be selectable
|
||||||
|
// Selectability is determined by the API field "selectable" which is set at the Presenter/API Transformer
|
||||||
|
// However since different bulk actions have different requirements, we have to walk through the available_actions object
|
||||||
|
// to determine whether to disable it
|
||||||
|
function checkboxEnabledFormatter (value, row) {
|
||||||
|
|
||||||
|
// add some stuff to get the value of the select2 option here?
|
||||||
|
|
||||||
|
if ((row.available_actions) && (row.available_actions.bulk_selectable) && (row.available_actions.bulk_selectable.delete !== true)) {
|
||||||
|
console.log('value for ID ' + row.id + ' is NOT true:' + row.available_actions.bulk_selectable.delete);
|
||||||
|
return {
|
||||||
|
disabled:true,
|
||||||
|
//checked: false, <-- not sure this will work the way we want?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('value for ID ' + row.id + ' IS true:' + row.available_actions.bulk_selectable.delete);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// We need a special formatter for license seats, since they don't work exactly the same
|
// We need a special formatter for license seats, since they don't work exactly the same
|
||||||
// Checkouts need the license ID, checkins need the specific seat ID
|
// Checkouts need the license ID, checkins need the specific seat ID
|
||||||
|
|
||||||
function licenseSeatInOutFormatter(value, row) {
|
function licenseSeatInOutFormatter(value, row) {
|
||||||
// The user is allowed to check the license seat out and it's available
|
// The user is allowed to check the license seat out and it's available
|
||||||
if ((row.available_actions.checkout == true) && (row.user_can_checkout == true) && ((!row.asset_id) && (!row.assigned_to))) {
|
if ((row.available_actions.checkout === true) && (row.user_can_checkout === true) && ((!row.asset_id) && (!row.assigned_to))) {
|
||||||
return '<a href="{{ config('app.url') }}/licenses/' + row.license_id + '/checkout/'+row.id+'" class="btn btn-sm bg-maroon" data-tooltip="true" title="{{ trans('general.checkout_tooltip') }}">{{ trans('general.checkout') }}</a>';
|
return '<a href="{{ config('app.url') }}/licenses/' + row.license_id + '/checkout/'+row.id+'" class="btn btn-sm bg-maroon" data-tooltip="true" title="{{ trans('general.checkout_tooltip') }}">{{ trans('general.checkout') }}</a>';
|
||||||
} else {
|
} else {
|
||||||
return '<a href="{{ config('app.url') }}/licenses/' + row.id + '/checkin" class="btn btn-sm bg-purple" data-tooltip="true" title="Check in this license seat.">{{ trans('general.checkin') }}</a>';
|
return '<a href="{{ config('app.url') }}/licenses/' + row.id + '/checkin" class="btn btn-sm bg-purple" data-tooltip="true" title="Check in this license seat.">{{ trans('general.checkin') }}</a>';
|
||||||
|
|
Loading…
Reference in a new issue