From d674b599ecbc9d737358d7f09d9a40d32a2415cf Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Tue, 26 May 2015 12:29:59 +0200 Subject: [PATCH] feature #3748: Add templates datatable --- src/sunstone/public/app/tabs/templates-tab.js | 4 +- .../app/tabs/templates-tab/datatable.js | 86 +++++++++++++++++++ 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 src/sunstone/public/app/tabs/templates-tab/datatable.js diff --git a/src/sunstone/public/app/tabs/templates-tab.js b/src/sunstone/public/app/tabs/templates-tab.js index e3d1820721..2ddd1c070d 100644 --- a/src/sunstone/public/app/tabs/templates-tab.js +++ b/src/sunstone/public/app/tabs/templates-tab.js @@ -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 diff --git a/src/sunstone/public/app/tabs/templates-tab/datatable.js b/src/sunstone/public/app/tabs/templates-tab/datatable.js new file mode 100644 index 0000000000..640f8cd461 --- /dev/null +++ b/src/sunstone/public/app/tabs/templates-tab/datatable.js @@ -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 [ + '', + element.ID, + element.NAME, + element.GNAME, + element.NAME, + Humanize.prettyTime(element.REGTIME) + ]; + } +});