in log4j-catalog/log4j-catalog-editor/src/main/resources/static/js/attributes.js [17:132]
$(document).ready(function () {
$('#AttributesTableContainer').jtable({
title: 'Table of Attributes',
paging: true, //Enable paging
pageSize: 25, //Set page size (default: 25)
sorting: true, //Enable sorting
defaultSorting: 'Name ASC', //Set default sorting
actions: {
listAction: 'api/attributes/list',
},
toolbar: {
items: [{
icon: 'js/jtable.2.4.0/themes/metro/add.png',
text: 'Add new record',
click: () => { addEditAttributeItem() }
}]
},
fields: {
id: {
key: true,
list: false
},
name: {
title: 'Name',
width: '15%'
},
displayName: {
title: 'Display Name',
width: '15%'
},
description: {
title: 'Description',
width: '25%'
},
dataType: {
title: 'Data Type',
width: '5%'
},
indexed: {
title: 'Indexed',
width: '5%',
display: function (attributeData) {
return attributeData.record.indexed ? 'true' : 'false';
}
},
sortable: {
title: 'Sortable',
width: '5%',
display: function (attributeData) {
return attributeData.record.sortable ? 'true' : 'false';
}
},
required: {
title: 'Required',
width: '5%',
display: function (attributeData) {
return attributeData.record.required ? 'true' : 'false';
}
},
requestContext: {
title: 'RequestContext',
width: '3%',
display: function (attributeData) {
return attributeData.record.requestContext ? 'true' : 'false';
}
},
constraints: {
title: 'Constraints',
width: '16%',
sorting: false,
edit: false,
create: false,
display: function (attributeData) {
var constraintList = '';
if (typeof(attributeData.record.constraints) != 'undefined' && attributeData.record.constraints != null) {
constraintList = attributeData.record.constraints.map(function (elem) {
return elem.constraintType.name + '("' + elem.value + '")'
}).join(' | ');
}
//Create a div that will be used to view associated attributes
var $divConstraints = $('<div class="constraints">' + constraintList + '</div>');
return $divConstraints;
}
},
edit: {
title: '',
width: '2%',
display: function (attributeData) {
// Store attribute item data in localStorage
var attributeDataItem = JSON.stringify(attributeData.record);
localStorage.setItem('attributeItem' + attributeData.record.id,attributeDataItem);
return '<img class="log4J-action-icon" src="js/jtable.2.4.0/themes/metro/edit.png" onClick="addEditAttributeItem(' + attributeData.record.id + ')" />';
}
},
delete: {
title: '',
width: '2%',
display: function (attributeData) {
return '<img class="log4J-action-icon" src="js/jtable.2.4.0/themes/metro/delete.png" onClick="deleteAttributeItem(' + attributeData.record.id + ')" />';
}
}
}
});
$.ajax({
type: 'GET',
url: 'api/constraints/types',
success:function(response){
localStorage.setItem('allConstraints', response);
},
error:function(jqXhr, textStatus, errorThrown){
console.error(textStatus + ' - ' + errorThrown);
}
});
//Load attributes list from server
$('#AttributesTableContainer').jtable('load');
});