/**\r
- * @author Charles\r
+ * Basic IView implementation for displaying the test results list, by collection.\r
+ * \r
+ * This component creates a Table object and feed it with the results. It adds a collection chooser to its viewPane header.\r
+ * \r
+ * It creates the following commands : "loadtestlist", "polllistloading", "opentest", "download", "copytocollection", "deletetest".\r
*/\r
qx.Class.define("org.argeo.slc.web.TestList",\r
{\r
\r
properties : \r
{\r
+ /**\r
+ * The viewPane containing this applet.\r
+ */\r
view : {\r
init : null\r
},\r
+ viewSelection : {\r
+ nullable:false, \r
+ check:"org.argeo.ria.components.ViewSelection"\r
+ }, \r
+ instanceId : {init:""},\r
+ instanceLabel : {init:""},\r
+ /**\r
+ * The load list of available collection (Map of ids => labels)\r
+ */\r
collectionList : {\r
init : {},\r
check : "Map"\r
},\r
+ /**\r
+ * The current collection id selected.\r
+ */\r
collectionId:{\r
init : 'My Collection',\r
check : "String"\r
},\r
+ /**\r
+ * The applet commands.\r
+ */\r
commands : {\r
init : {\r
"loadtestlist" : {\r
callback : function(e){\r
var viewsManager = org.argeo.ria.components.ViewsManager.getInstance();\r
var classObj = org.argeo.slc.ria.Applet;\r
- var iView = viewsManager.initIViewClass(classObj, "applet");\r
var xmlNodes = viewsManager.getViewPaneSelection("list").getNodes();\r
+ var iView = viewsManager.initIViewClass(classObj, "applet", xmlNodes[0]);\r
iView.load(xmlNodes[0]);\r
},\r
selectionChange : function(viewId, xmlNodes){\r
menu : "Selection",\r
toolbar : "selection",\r
callback : function(e){\r
- \r
- var request = org.argeo.slc.ria.SlcApi.getRemoveResultService(this.getCollectionId(), this.extractTestUuid());\r
- request.addListener("completed", function(response){\r
- this.loadCollections();\r
- this.loadList();\r
- this.info("Test was successfully deleted");\r
- }, this);\r
- request.send();\r
+ var modal = new org.argeo.ria.components.Modal("Confirm", null);\r
+ modal.addConfirm("Are you sure you want to delete<br> test " + this.extractTestUuid() + "?");\r
+ modal.addListener("ok", function(){\r
+ var request = org.argeo.slc.ria.SlcApi.getRemoveResultService(this.getCollectionId(), this.extractTestUuid());\r
+ request.addListener("completed", function(response){\r
+ this.loadCollections();\r
+ this.loadList();\r
+ this.info("Test was successfully deleted");\r
+ }, this);\r
+ request.send(); \r
+ }, this);\r
+ modal.attachAndShow();\r
},\r
selectionChange : function(viewId, xmlNodes){\r
if(viewId != "list") return;\r
},\r
\r
members : {\r
- init : function(viewPane){\r
- this.setView(viewPane);\r
+ init : function(viewPane, data){\r
+ this.setView(viewPane);\r
+ this.setViewSelection(new org.argeo.ria.components.ViewSelection(viewPane.getViewId())); \r
},\r
- load : function(data){\r
+ load : function(){\r
this.table.set({ \r
statusBarVisible: false,\r
showCellFocusIndicator:false,\r
columnModel.setDataCellRenderer(1, renderer);\r
\r
this.table.getSelectionManager().getSelectionModel().addListener("changeSelection", function(e){\r
- var viewSelection = viewPane.getViewSelection();\r
+ var viewSelection = this.getViewSelection();\r
viewSelection.clear();\r
var selectionModel = this.table.getSelectionManager().getSelectionModel();\r
if(!selectionModel.getSelectedCount()){\r
var ranges = this.table.getSelectionManager().getSelectionModel().getSelectedRanges();\r
var xmlNode = this.table.getTableModel().getRowData(ranges[0].minIndex);\r
viewSelection.addNode(xmlNode);\r
- viewPane.setViewSelection(viewSelection);\r
+ //viewPane.setViewSelection(viewSelection);\r
}, this); \r
\r
var select = new qx.ui.form.SelectBox();\r
\r
},\r
\r
+ /**\r
+ * Use SlcApi to load the available collections.\r
+ */\r
loadCollections : function(){\r
var request = org.argeo.slc.ria.SlcApi.getListCollectionsService();\r
var NSMap = {slc:"http://argeo.org/projects/slc/schemas"};\r
request.send();\r
},\r
\r
+ /**\r
+ * Load the results of the currently selected collection.\r
+ */\r
loadList : function(){\r
var model = this.table.getTableModel();\r
model.removeRows(0, model.getRowCount());\r
request.send(); \r
},\r
\r
+ /**\r
+ * Enable/disable the automatic reloading of the list.\r
+ * @param state {Boolean} Whether the automatic reloading must be started or stopped.\r
+ */\r
pollListLoading : function(state){\r
if(!this.timer){\r
this.timer = new qx.event.Timer(5000);\r
}\r
},\r
\r
+ /**\r
+ * Creates a menu gui component from the currently loaded collectionList.\r
+ * @param command {qx.event.Command} The command on which to attach the created menu. \r
+ * @param checkSelection {Boolean} Whether at the end, we must check the current viewSelection to enable/disable the command accordingly. \r
+ */\r
collectionListToMenu : function(command, checkSelection){\r
command.setEnabled(false);\r
command.clearMenus();\r
command.setEnabled(true);\r
}\r
},\r
- \r
+ /**\r
+ * Use SlcApi "addResult" service to add selected results to a given collection.\r
+ * If collectionId is "slc.client.create", first triggers a modal dialog to enter a new collection name, then retrigger itself with the new id.\r
+ * @param collectionId {String} The id of the destination collection, or "slc.client.create".\r
+ * @param selectionType {String} "current_collection"|"current_selection". The first adds the whole collection content to the destination, the second only selected results.\r
+ */\r
copySelectionToCollection:function(collectionId, selectionType){\r
if(collectionId == "slc.client.create"){\r
var modal = new org.argeo.ria.components.Modal("Create collection", "resource/slc/folder-new.png");\r
}\r
},\r
\r
+ /**\r
+ * Utilitary function to extract test unique id from the currently selected node.\r
+ * @return {String} The test unique id.\r
+ */\r
extractTestUuid: function(){\r
var NSMap = {slc:"http://argeo.org/projects/slc/schemas"};\r
var xmlNodes = this.getView().getViewSelection().getNodes();\r
return uuid;\r
},\r
\r
- collectionSelectorListener : function(event){\r
+ /**\r
+ * Listener of the collection selector (select box added to the viewpane header). \r
+ * @param event {qx.event.type.Event} The event.\r
+ */\r
+ collectionSelectorListener : function(event){\r
this.setCollectionId(event.getData());\r
this.loadList(); \r
},\r
\r
addScroll : function(){\r
return false;\r
- } \r
+ },\r
+ \r
+ close : function(){\r
+ if(this.timer){\r
+ this.pollListLoading(false);\r
+ }\r
+ }\r
+ \r
}\r
});
\ No newline at end of file