mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Pull assigned asets preview into its own blade for re-use
This commit is contained in:
parent
7f1b7be416
commit
4bb546a882
|
@ -28,18 +28,7 @@
|
|||
{{ csrf_field() }}
|
||||
|
||||
<!-- User -->
|
||||
<div id="assigned_user" class="form-group{{ $errors->has('assigned_to') ? ' has-error' : '' }}">
|
||||
|
||||
{{ Form::label('assigned_to', trans('admin/hardware/form.checkout_to'), array('class' => 'col-md-3 control-label')) }}
|
||||
<div class="col-md-7 required">
|
||||
{{ Form::select('assigned_to', $users_list , Input::old('assigned_to'), array('class'=>'select2', 'id'=>'assigned_to', 'style'=>'width:100%')) }}
|
||||
|
||||
{!! $errors->first('assigned_to', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
|
||||
</div>
|
||||
<div class="col-md-1 col-sm-1 text-left">
|
||||
<a href='{{ route('modal.user') }}' data-toggle="modal" data-target="#createModal" data-dependency="user" data-select='assigned_to' class="btn btn-sm btn-default">New</a>
|
||||
</div>
|
||||
</div>
|
||||
@include ('partials.forms.edit.user-select', ['translated_name' => trans('admin/hardware/form.checkout_to'), 'fieldname' => 'assigned_user'])
|
||||
|
||||
<!-- Checkout/Checkin Date -->
|
||||
<div class="form-group {{ $errors->has('checkout_at') ? 'error' : '' }}">
|
||||
|
@ -75,13 +64,8 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group{{ $errors->has('selected_asset') ? ' has-error' : '' }}">
|
||||
{{ Form::label('selected_asset', trans('general.assets'), array('class' => 'col-md-3 control-label')) }}
|
||||
<div class="col-md-8 required">
|
||||
{{ Form::select('selected_assets[]', $assets_list , Input::old('selected_asset'), array('class'=>'select2', 'id'=>'selected_asset', 'style'=>'width:100%', 'multiple'=>'multiple')) }}
|
||||
{!! $errors->first('selected_asset', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
|
||||
</div>
|
||||
</div>
|
||||
@include ('partials.forms.edit.asset-select', ['translated_name' => trans('general.assets'), 'fieldname' => 'selected_assets[]', 'multiple' => true])
|
||||
|
||||
|
||||
</div> <!--./box-body-->
|
||||
<div class="box-footer">
|
||||
|
@ -108,38 +92,6 @@
|
|||
@stop
|
||||
|
||||
@section('moar_scripts')
|
||||
<script nonce="{{ csrf_token() }}">
|
||||
$(function() {
|
||||
$('#assigned_to').on("change",function () {
|
||||
// console.warn("Model Id has changed!");
|
||||
var userid=$('#assigned_to').val();
|
||||
if(userid=='') {
|
||||
console.warn('no user selected');
|
||||
$('#current_assets_box').fadeOut();
|
||||
$('#current_assets_content').html("");
|
||||
} else {
|
||||
$.get("{{url('/') }}/api/users/"+userid+"/assets",{_token: "{{ csrf_token() }}"},function (data) {
|
||||
// console.warn("Ajax call came back okay for user " + userid + "! " + data.length + " Data is: "+data);
|
||||
if (data.length > 0) {
|
||||
$('#current_assets_box').fadeIn();
|
||||
var table_html = '<div class="row"><div class="col-md-12"><table class="table table-striped"><thead><tr><td>{{ trans('admin/hardware/form.name') }}</td><td>{{ trans('admin/hardware/form.tag') }}</td></tr></thead><tbody>';
|
||||
$('#current_assets_content').append('');
|
||||
for (var i in data) {
|
||||
var asset = data[i];
|
||||
table_html += "<tr><td class=\"col-md-8\"><a href=\"{{ url('/') }}/hardware/" + asset.id + "/view\">" + asset.name;
|
||||
if (asset.model.name!='') {
|
||||
table_html += " (" + asset.model.name + ")";
|
||||
}
|
||||
table_html += "</a></td><td class=\"col-md-4\">" + asset.asset_tag + "</td></tr>";
|
||||
}
|
||||
$('#current_assets_content').html(table_html + '</tbody></table></div></div>');
|
||||
} else {
|
||||
$('#current_assets_box').fadeOut();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@include('partials/assets-assigned')
|
||||
|
||||
@stop
|
||||
|
|
|
@ -143,79 +143,5 @@
|
|||
@stop
|
||||
|
||||
@section('moar_scripts')
|
||||
<script nonce="{{ csrf_token() }}">
|
||||
|
||||
// create the assigned assets listing box for the right side of the screen
|
||||
$(function() {
|
||||
$('#assigned_user').on("change",function () {
|
||||
var userid = $('#assigned_user option:selected').val();
|
||||
|
||||
if(userid=='') {
|
||||
console.warn('no user selected');
|
||||
$('#current_assets_box').fadeOut();
|
||||
$('#current_assets_content').html("");
|
||||
} else {
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '{{ url('/') }}/api/v1/users/' + userid + '/assets',
|
||||
headers: {
|
||||
"X-Requested-With": 'XMLHttpRequest',
|
||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content')
|
||||
},
|
||||
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
$('#current_assets_box').fadeIn();
|
||||
|
||||
var table_html = '<div class="row">';
|
||||
table_html += '<div class="col-md-12">';
|
||||
table_html += '<table class="table table-striped">';
|
||||
table_html += '<thead><tr>';
|
||||
table_html += '<th></th>';
|
||||
table_html += '<th>{{ trans('admin/hardware/form.name') }}</th>';
|
||||
table_html += '<th>{{ trans('admin/hardware/form.tag') }}</th>';
|
||||
table_html += '<th>{{ trans('admin/hardware/form.serial') }}</th>';
|
||||
table_html += '</tr></thead><tbody>';
|
||||
|
||||
$('#current_assets_content').append('');
|
||||
|
||||
if (data.rows.length > 0) {
|
||||
|
||||
for (var i in data.rows) {
|
||||
var asset = data.rows[i];
|
||||
table_html += '<tr>';
|
||||
if (asset.image != null) {
|
||||
table_html += '<td class="col-md-1"><a href="' + asset.image + '" data-toggle="lightbox" data-type="image"><img src="' + asset.image + '" style="max-height: {{ $snipeSettings->thumbnail_max_h }}px; width: auto;"></a></td>';
|
||||
} else {
|
||||
table_html += "<td></td> ";
|
||||
}
|
||||
table_html += '<td><a href="{{ url('/') }}/hardware/' + asset.id + '">';
|
||||
|
||||
if ((asset.name == '') && (asset.name != null)) {
|
||||
table_html += " " + asset.model.name;
|
||||
} else {
|
||||
table_html += asset.name;
|
||||
table_html += " (" + asset.model.name + ")";
|
||||
}
|
||||
|
||||
table_html += '</a></td>';
|
||||
table_html += '<td class="col-md-4">' + asset.asset_tag + '</td>';
|
||||
table_html += '<td class="col-md-4">' + asset.serial + '</td>';
|
||||
table_html += "</tr>";
|
||||
}
|
||||
} else {
|
||||
table_html += '<tr><td colspan="4">No assets checked out to '+ $('.js-data-user-ajax').find('option:selected').text() + ' yet!</td></tr>';
|
||||
}
|
||||
$('#current_assets_content').html(table_html + '</tbody></table></div></div>');
|
||||
|
||||
},
|
||||
error: function (data) {
|
||||
$('#current_assets_box').fadeOut();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@include('partials/assets-assigned')
|
||||
@stop
|
||||
|
|
75
resources/views/partials/assets-assigned.blade.php
Normal file
75
resources/views/partials/assets-assigned.blade.php
Normal file
|
@ -0,0 +1,75 @@
|
|||
<script nonce="{{ csrf_token() }}">
|
||||
|
||||
// create the assigned assets listing box for the right side of the screen
|
||||
$(function() {
|
||||
$('#assigned_user').on("change",function () {
|
||||
var userid = $('#assigned_user option:selected').val();
|
||||
|
||||
if(userid=='') {
|
||||
console.warn('no user selected');
|
||||
$('#current_assets_box').fadeOut();
|
||||
$('#current_assets_content').html("");
|
||||
} else {
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '{{ url('/') }}/api/v1/users/' + userid + '/assets',
|
||||
headers: {
|
||||
"X-Requested-With": 'XMLHttpRequest',
|
||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content')
|
||||
},
|
||||
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
$('#current_assets_box').fadeIn();
|
||||
|
||||
var table_html = '<div class="row">';
|
||||
table_html += '<div class="col-md-12">';
|
||||
table_html += '<table class="table table-striped">';
|
||||
table_html += '<thead><tr>';
|
||||
table_html += '<th></th>';
|
||||
table_html += '<th>{{ trans('admin/hardware/form.name') }}</th>';
|
||||
table_html += '<th>{{ trans('admin/hardware/form.tag') }}</th>';
|
||||
table_html += '<th>{{ trans('admin/hardware/form.serial') }}</th>';
|
||||
table_html += '</tr></thead><tbody>';
|
||||
|
||||
$('#current_assets_content').append('');
|
||||
|
||||
if (data.rows.length > 0) {
|
||||
|
||||
for (var i in data.rows) {
|
||||
var asset = data.rows[i];
|
||||
table_html += '<tr>';
|
||||
if (asset.image != null) {
|
||||
table_html += '<td class="col-md-1"><a href="' + asset.image + '" data-toggle="lightbox" data-type="image"><img src="' + asset.image + '" style="max-height: {{ $snipeSettings->thumbnail_max_h }}px; width: auto;"></a></td>';
|
||||
} else {
|
||||
table_html += "<td></td> ";
|
||||
}
|
||||
table_html += '<td><a href="{{ url('/') }}/hardware/' + asset.id + '">';
|
||||
|
||||
if ((asset.name == '') && (asset.name != null)) {
|
||||
table_html += " " + asset.model.name;
|
||||
} else {
|
||||
table_html += asset.name;
|
||||
table_html += " (" + asset.model.name + ")";
|
||||
}
|
||||
|
||||
table_html += '</a></td>';
|
||||
table_html += '<td class="col-md-4">' + asset.asset_tag + '</td>';
|
||||
table_html += '<td class="col-md-4">' + asset.serial + '</td>';
|
||||
table_html += "</tr>";
|
||||
}
|
||||
} else {
|
||||
table_html += '<tr><td colspan="4">No assets checked out to '+ $('.js-data-user-ajax').find('option:selected').text() + ' yet!</td></tr>';
|
||||
}
|
||||
$('#current_assets_content').html(table_html + '</tbody></table></div></div>');
|
||||
|
||||
},
|
||||
error: function (data) {
|
||||
$('#current_assets_box').fadeOut();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
Loading…
Reference in a new issue