feature #3748: Add templates datatable

This commit is contained in:
Daniel Molina committed 2015-05-26 12:29:59 +02:00
1 parent 53cb7c6320
commit d674b599ec
2 files changed
+88 -2

No files matched your search

@@ -2,7 +2,7 @@ define(function(require) {
var Locale = require('utils/locale');
var Buttons = require('./templates-tab/buttons');
//var Actions = require('./templates-tab/actions');
//var Table = require('./templates-tab/datatable');
var Table = require('./templates-tab/datatable');
var TAB_ID = require('./templates-tab/tabId');
var DATATABLE_ID = "dataTableTemplates";
@@ -33,7 +33,7 @@ define(function(require) {
resource: 'Template',
buttons: Buttons,
//actions: Actions,
//dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
dataTable: new Table(DATATABLE_ID, {actions: true, info: true}),
//panels: _panels,
//formPanels: _formPanels,
//dialogs: _dialogs
@@ -0,0 +1,86 @@
define(function(require) {
/*
DEPENDENCIES
*/
var TabDataTable = require('utils/tab-datatable');
var SunstoneConfig = require('sunstone-config');
var Locale = require('utils/locale');
var Humanize = require('utils/humanize');
/*
CONSTANTS
*/
var RESOURCE = "Template";
var XML_ROOT = "VMTEMPLATE";
var TAB_NAME = require('./tabId');
/*
CONSTRUCTOR
*/
function Table(dataTableId, conf) {
this.conf = conf || {};
this.tabId = TAB_NAME;
this.dataTableId = dataTableId;
this.resource = RESOURCE;
this.xmlRoot = XML_ROOT;
this.dataTableOptions = {
"bAutoWidth": false,
"bSortClasses" : false,
"bDeferRender": true,
"aoColumnDefs": [
{"bSortable": false, "aTargets": ["check"]},
{"sWidth": "35px", "aTargets": [0]},
{"bVisible": true, "aTargets": SunstoneConfig.tabTableColumns(TAB_NAME)},
{"bVisible": false, "aTargets": ['_all']}
]
}
this.columns = [
Locale.tr("ID") ,
Locale.tr("Owner") ,
Locale.tr("Group"),
Locale.tr("Name"),
Locale.tr("Registration time")
];
this.selectOptions = {
"id_index": 1,
"name_index": 4,
"select_resource": Locale.tr("Please select a Template from the list"),
"you_selected": Locale.tr("You selected the following Template:"),
"select_resource_multiple": Locale.tr("Please select one or more Templates from the list"),
"you_selected_multiple": Locale.tr("You selected the following Templates:")
};
TabDataTable.call(this);
};
Table.prototype = Object.create(TabDataTable.prototype);
Table.prototype.constructor = Table;
Table.prototype.elementArray = _elementArray;
return Table;
/*
FUNCTION DEFINITIONS
*/
function _elementArray(element_json) {
var element = element_json[XML_ROOT];
return [
'<input class="check_item" type="checkbox" id="' + RESOURCE.toLowerCase() + '_' +
element.ID + '" name="selected_items" value="' +
element.ID + '"/>',
element.ID,
element.NAME,
element.GNAME,
element.NAME,
Humanize.prettyTime(element.REGTIME)
];
}
});