Added nicer table formatting for “assets checked out to this user” table

This commit is contained in:
snipe 2017-10-24 19:21:53 -07:00
parent d678a0ebff
commit c605984db0

View file

@ -176,20 +176,45 @@ $(function() {
success: function (data) { success: function (data) {
$('#current_assets_box').fadeIn(); $('#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>'; 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(''); $('#current_assets_content').append('');
for (var i in data) { if (data.rows.length > 0) {
var asset = data[i];
table_html += '<tr><td class="col-md-8"><a href="{{ url('/') }}/hardware/' + asset.id + '">' + asset.name; for (var i in data.rows) {
if (asset.model.name!='') { 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 += " (" + asset.model.name + ")";
}
table_html += "</a></td><td class=\"col-md-4\">" + asset.asset_tag + "</td></tr>";
} }
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>'); $('#current_assets_content').html(table_html + '</tbody></table></div></div>');
}, },