mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Pull common formatters into partial
This commit is contained in:
parent
5d14acaac4
commit
bebb653a70
|
@ -38,7 +38,7 @@
|
|||
<tbody>
|
||||
@foreach ($assets as $asset)
|
||||
<tr>
|
||||
<td><input type="checkbox" name="bulk_edit[]" value="{{ $asset->id }}" checked="checked"></td>
|
||||
<td><input type="checkbox" name="ids[]" value="{{ $asset->id }}" checked="checked"></td>
|
||||
<td>{{ $asset->id }}</td>
|
||||
<td>{{ $asset->present()->name() }}</td>
|
||||
<td>
|
||||
|
|
|
@ -149,7 +149,7 @@
|
|||
</div>
|
||||
|
||||
@foreach ($assets as $key => $value)
|
||||
<input type="hidden" name="bulk_edit[{{ $key }}]" value="1">
|
||||
<input type="hidden" name="ids[{{ $key }}]" value="1">
|
||||
@endforeach
|
||||
</div> <!--/.box-body-->
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
'method' => 'POST',
|
||||
'route' => ['hardware/bulkedit'],
|
||||
'class' => 'form-inline',
|
||||
'id' => 'bulkEditForm']) }}
|
||||
'id' => 'bulkForm']) }}
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
@if (Input::get('status')!='Deleted')
|
||||
|
@ -77,13 +77,13 @@
|
|||
<th data-field="companyName" data-searchable="true" data-sortable="true" data-switchable="true" data-visible="false">{{ trans('general.company') }}</th>
|
||||
<th data-sortable="true" data-field="image" data-visible="false">{{ trans('admin/hardware/table.image') }}</th>
|
||||
<th data-sortable="true" data-field="name" data-visible="false">{{ trans('admin/hardware/form.name') }}</th>
|
||||
<th data-sortable="true" data-field="asset_tag">{{ trans('admin/hardware/table.asset_tag') }}</th>
|
||||
<th data-sortable="true" data-field="asset_tag" data-formatter="">{{ trans('admin/hardware/table.asset_tag') }}</th>
|
||||
<th data-sortable="true" data-field="serial">{{ trans('admin/hardware/table.serial') }}</th>
|
||||
<th data-sortable="true" data-field="model">{{ trans('admin/hardware/form.model') }}</th>
|
||||
<th data-sortable="true" data-field="model_number" data-visible="false">{{ trans('admin/models/table.modelnumber') }}</th>
|
||||
<th data-sortable="true" data-field="status_label">{{ trans('admin/hardware/table.status') }}</th>
|
||||
<th data-sortable="true" data-field="assigned_to">{{ trans('admin/hardware/form.checkedout_to') }}</th>
|
||||
<th data-sortable="true" data-field="location" data-searchable="true">{{ trans('admin/hardware/table.location') }}</th>
|
||||
<th data-sortable="true" data-formatter="locationFormatter" data-field="location" data-searchable="true">{{ trans('admin/hardware/table.location') }}</th>
|
||||
<th data-sortable="true" data-field="category" data-searchable="true">{{ trans('general.category') }}</th>
|
||||
<th data-sortable="true" data-field="manufacturer" data-searchable="true" data-visible="false">{{ trans('general.manufacturer') }}</th>
|
||||
<th data-sortable="true" data-field="purchase_cost" data-searchable="true" data-visible="false">{{ trans('admin/hardware/form.cost') }}</th>
|
||||
|
@ -130,31 +130,6 @@
|
|||
|
||||
<script>
|
||||
|
||||
var checkedRows = 0;
|
||||
|
||||
$('.snipe-table').on('check.bs.table', function (e, row) {
|
||||
$(this).val(row.id);
|
||||
checkedRows++;
|
||||
$('#bulkEdit').removeAttr('disabled');
|
||||
atLeastOneChecked(checkedRows);
|
||||
});
|
||||
|
||||
$('.snipe-table').on('uncheck.bs.table', function (e, row) {
|
||||
checkedRows--;
|
||||
atLeastOneChecked(checkedRows);
|
||||
|
||||
});
|
||||
|
||||
|
||||
function atLeastOneChecked(checkedRows) {
|
||||
if (checkedRows > 0) {
|
||||
$('#bulkEdit').removeAttr('disabled');
|
||||
}
|
||||
else {
|
||||
$('#bulkEdit').attr('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
|
||||
function actionsFormatter(value, row) {
|
||||
return '<nobr><a href="{{ url('/') }}/hardware/' + row.id + '/edit" class="btn btn-sm btn-warning"><i class="fa fa-pencil"></i></a> '
|
||||
+ '<a data-html="false" class="btn delete-asset btn-danger btn-sm" ' +
|
||||
|
@ -164,25 +139,7 @@
|
|||
|
||||
}
|
||||
|
||||
function createdAtFormatter(value, row) {
|
||||
if ((value) && (value.date)) {
|
||||
return value.date;
|
||||
}
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$('#bulkEdit').click(function () {
|
||||
var selectedIds = $('.snipe-table').bootstrapTable('getSelections');
|
||||
|
||||
$.each(selectedIds, function(key,value) {
|
||||
$( "#bulkEditForm" ).append($('<input type="hidden" name="edit_asset[' + value.id + ']" value="' + value.id + '">' ));
|
||||
//alert(value.id);
|
||||
});
|
||||
|
||||
//event.preventDefault();
|
||||
//return false;
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
@stop
|
||||
|
|
|
@ -53,4 +53,77 @@ $('.snipe-table').bootstrapTable({
|
|||
},
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
// Handle whether or not the edit button should be disabled
|
||||
$('.snipe-table').on('check.bs.table', function () {
|
||||
$('#bulkEdit').removeAttr('disabled');
|
||||
});
|
||||
|
||||
$('.snipe-table').on('check-all.bs.table', function () {
|
||||
$('#bulkEdit').removeAttr('disabled');
|
||||
});
|
||||
|
||||
$('.snipe-table').on('uncheck.bs.table', function () {
|
||||
console.log($('.snipe-table').bootstrapTable('getSelections').length);
|
||||
if ($('.snipe-table').bootstrapTable('getSelections').length == 0) {
|
||||
$('#bulkEdit').attr('disabled', 'disabled');
|
||||
}
|
||||
});
|
||||
|
||||
$('.snipe-table').on('uncheck-all.bs.table', function (e, row) {
|
||||
$('#bulkEdit').attr('disabled', 'disabled');
|
||||
});
|
||||
|
||||
|
||||
function createdAtFormatter(value, row) {
|
||||
if ((value) && (value.date)) {
|
||||
return value.date;
|
||||
}
|
||||
}
|
||||
|
||||
function trueFalseFormatter(value, row) {
|
||||
if ((value) && ((value == 'true') || (value == '1'))) {
|
||||
return '<i class="fa fa-check"></i>';
|
||||
} else {
|
||||
return '<i class="fa fa-times"></i>';
|
||||
}
|
||||
}
|
||||
|
||||
function userFormatter(value, row) {
|
||||
if (value.name) {
|
||||
return '<a href="{{ url('/') }}/users/' + value.id + '"> ' + value.name + '</a>';
|
||||
} else if (value) {
|
||||
return '<a href="{{ url('/') }}/users/' + row.id + '"> ' + value + '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
function companyFormatter(value, row) {
|
||||
if ((value) && (value[0].name)) {
|
||||
return '<a href="{{ url('/') }}/companies/' + value[0].id + '"> ' + value[0].name + '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
function locationFormatter(value, row) {
|
||||
if ((value) && (value[0].name)) {
|
||||
return '<a href="{{ url('/') }}/locations/' + value[0].id + '"> ' + value[0].name + '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
function emailFormatter(value, row) {
|
||||
if (value) {
|
||||
return '<a href="mailto:' + value + '"> ' + value + '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$('#bulkEdit').click(function () {
|
||||
var selectedIds = $('.snipe-table').bootstrapTable('getSelections');
|
||||
$.each(selectedIds, function(key,value) {
|
||||
$( "#bulkForm" ).append($('<input type="hidden" name="ids[' + value.id + ']" value="' + value.id + '">' ));
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -50,9 +50,9 @@ Bulk Checkin & Delete
|
|||
<tr {!! ($user->isSuperUser() ? ' class="danger"':'') !!}>
|
||||
<td>
|
||||
@if (Auth::id()!=$user->id)
|
||||
<input type="checkbox" name="edit_user[]" value="{{ $user->id }}" checked="checked">
|
||||
<input type="checkbox" name="ids[]" value="{{ $user->id }}" checked="checked">
|
||||
@else
|
||||
<input type="checkbox" name="edit_user[]" value="{{ $user->id }}" disabled>
|
||||
<input type="checkbox" name="ids[]" value="{{ $user->id }}" disabled>
|
||||
@endif
|
||||
</td>
|
||||
|
||||
|
@ -90,7 +90,7 @@ Bulk Checkin & Delete
|
|||
</tr>
|
||||
<tr>
|
||||
<td colspan="6" class="warning">
|
||||
<label><input type="checkbox" name="edit_user['.e($user->id).']" checked> Check in all properties associated with these users</label>
|
||||
<label><input type="checkbox" name="ids['.e($user->id).']" checked> Check in all properties associated with these users</label>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
'method' => 'POST',
|
||||
'route' => ['users/bulkedit'],
|
||||
'class' => 'form-inline',
|
||||
'id' => 'bulkEditForm']) }}
|
||||
'id' => 'bulkForm']) }}
|
||||
|
||||
@if (Input::get('status')!='deleted')
|
||||
@can('delete', \App\Models\User::class)
|
||||
|
@ -82,7 +82,7 @@
|
|||
<span class="hidden-xs"><i class="fa fa-envelope fa-lg"></i></span>
|
||||
</th>
|
||||
<th data-sortable="true" data-field="username">{{ trans('admin/users/table.username') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="manager">{{ trans('admin/users/table.manager') }}</th>
|
||||
<th data-searchable="true" data-sortable="true" data-field="manager" data-formatter="userFormatter">{{ trans('admin/users/table.manager') }}</th>
|
||||
<th data-sortable="true" data-field="location" data-formatter="locationFormatter">{{ trans('admin/users/table.location') }}</th>
|
||||
<th data-sortable="false" data-field="assets">
|
||||
<span class="hidden-md hidden-lg">Assets</span>
|
||||
|
@ -100,7 +100,9 @@
|
|||
<span class="hidden-md hidden-lg">Consumables</span>
|
||||
<span class="hidden-xs"><i class="fa fa-tint fa-lg"></i></span>
|
||||
</th>
|
||||
<th data-sortable="false" data-field="groups">{{ trans('general.groups') }}</th>
|
||||
<th data-sortable="false" data-field="groups" data-formatter="groupsFormatter">
|
||||
{{ trans('general.groups') }}
|
||||
</th>
|
||||
<th data-sortable="true" data-field="notes">{{ trans('general.notes') }}</th>
|
||||
<th data-sortable="true" data-field="two_factor_enrolled" data-visible="false" data-formatter="trueFalseFormatter" >{{ trans('admin/users/general.two_factor_enrolled') }}</th>
|
||||
<th data-sortable="true" data-field="two_factor_optin" data-formatter="trueFalseFormatter" data-visible="false">{{ trans('admin/users/general.two_factor_active') }}</th>
|
||||
|
@ -125,70 +127,15 @@
|
|||
|
||||
<script>
|
||||
|
||||
var checkedRows = 0;
|
||||
|
||||
$('.snipe-table').on('check.bs.table', function (e, row) {
|
||||
$(this).val(row.id);
|
||||
checkedRows++;
|
||||
$('#bulkEdit').removeAttr('disabled');
|
||||
atLeastOneChecked(checkedRows);
|
||||
});
|
||||
|
||||
$('.snipe-table').on('uncheck.bs.table', function (e, row) {
|
||||
checkedRows--;
|
||||
atLeastOneChecked(checkedRows);
|
||||
|
||||
});
|
||||
|
||||
function atLeastOneChecked(checkedRows) {
|
||||
if (checkedRows > 0) {
|
||||
$('#bulkEdit').removeAttr('disabled');
|
||||
}
|
||||
else {
|
||||
$('#bulkEdit').attr('disabled', 'disabled');
|
||||
function groupsFormatter(value) {
|
||||
var groups = '';
|
||||
for (var index = 0; index < value.length; index++) {
|
||||
groups += '<a href="#" class="label label-default"> ' + value[index].name + '</a> ';
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function locationFormatter(value, row) {
|
||||
if ((value) && (value[0].name)) {
|
||||
return '<a href="{{ url('/') }}/locations/' + value[0].id + '"> ' + value[0].name + '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
function emailFormatter(value, row) {
|
||||
if (value) {
|
||||
return '<a href="mailto:' + value + '"> ' + value + '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
function userFormatter(value, row) {
|
||||
if (value) {
|
||||
return '<a href="{{ url('/') }}/users/' + row.id + '"> ' + value + '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
function companyFormatter(value, row) {
|
||||
if ((value) && (value[0].name)) {
|
||||
return '<a href="{{ url('/') }}/companies/' + value[0].id + '"> ' + value[0].name + '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
function createdAtFormatter(value, row) {
|
||||
if ((value) && (value.date)) {
|
||||
return value.date;
|
||||
}
|
||||
}
|
||||
|
||||
function trueFalseFormatter(value, row) {
|
||||
if ((value) && ((value == 'true') || (value == '1'))) {
|
||||
return '<i class="fa fa-check"></i>';
|
||||
} else {
|
||||
return '<i class="fa fa-times"></i>';
|
||||
}
|
||||
}
|
||||
|
||||
function actionsFormatter(value, row) {
|
||||
return '<nobr><a href="{{ url('/') }}/users/' + row.id + '/edit" class="btn btn-sm btn-warning"><i class="fa fa-pencil"></i></a> '
|
||||
+ '<a data-html="false" class="btn delete-asset btn-danger btn-sm" ' +
|
||||
|
@ -198,21 +145,6 @@
|
|||
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$('#bulkEdit').click(function () {
|
||||
var selectedIds = $('.snipe-table').bootstrapTable('getSelections');
|
||||
|
||||
$.each(selectedIds, function(key,value) {
|
||||
$( "#bulkEditForm" ).append($('<input type="hidden" name="edit_user[' + value.id + ']" value="' + value.id + '">' ));
|
||||
//alert(value.id);
|
||||
});
|
||||
|
||||
//event.preventDefault();
|
||||
//return false;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
@stop
|
||||
|
|
Loading…
Reference in a new issue