]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/BatchView.js
MonitorPerspective implementation
[gpl/argeo-slc.git] / server / org.argeo.slc.ria / src / argeo-ria-lib / slc / class / org / argeo / slc / ria / BatchView.js
index 0574296710dd1943a28b6835353d59ea005593ae..78715de0403652f23aad1095fc6ccf67ba59daa7 100644 (file)
@@ -12,6 +12,11 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
                                label : "Confirm on batch deletion",\r
                                type  : "boolean",\r
                                defaultValue  : true\r
+                       },\r
+                       "slc.batch.autoclear" : {\r
+                               label : "Autoclear batch on execution",\r
+                               type : "boolean",\r
+                               defaultValue : false\r
                        }\r
                }\r
        },\r
@@ -31,9 +36,25 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
                                        menu : "Launcher",\r
                                        toolbar : "batch",\r
                                        callback : function(e) {\r
-                                               if (this.getBatchAgentId()) {\r
-                                                       this.executeBatchOnAgent(this.getBatchAgentId());\r
+                                               var batchAgentId = this.getBatchAgentId();\r
+                                               if (!batchAgentId) {\r
+                                                       return;                                                 \r
                                                }\r
+                                               var prefName = "slc.batch.autoclear";\r
+                                               var prefValue = this.getRiaPreferenceValue(prefName);\r
+                                               if(prefValue !== null){\r
+                                                       this.executeBatchOnAgent(batchAgentId, prefValue);\r
+                                                       return;\r
+                                               }\r
+                                               var modal = new org.argeo.ria.components.Modal("Clear?", null);\r
+                                               modal.addYesNoReminder("Do you want to clear the batch automatically after execution?", prefName);\r
+                                               modal.addListener("cancel", function(e){\r
+                                                       this.executeBatchOnAgent(batchAgentId, false);\r
+                                               }, this);\r
+                                               modal.addListener("ok", function(e){\r
+                                                       this.executeBatchOnAgent(batchAgentId, true);\r
+                                               }, this);\r
+                                               modal.attachAndShow();                                          \r
                                        },\r
                                        command : null\r
                                },\r
@@ -396,7 +417,7 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
                 * @param agentUuid\r
                 *            {String} The id of the target agent\r
                 */\r
-               executeBatchOnAgent : function(agentUuid) {\r
+               executeBatchOnAgent : function(agentUuid, clearBatch) {\r
                        var selection = this.list.getChildren();\r
                        if (!selection.length)\r
                                return;\r
@@ -418,6 +439,11 @@ qx.Class.define("org.argeo.slc.ria.BatchView",
                                                                command.execute();\r
                                                        }\r
                                                }, this, 2000);\r
+                               if(clearBatch){\r
+                                       req.addListener("completed", function(e){\r
+                                               this.list.removeAll();\r
+                                       }, this);\r
+                               }                                               \r
                        }catch(e){\r
                                this.error(e);                          \r
                        }\r