From 7ac070dd338c67f649520ef04ff873efbad222ae Mon Sep 17 00:00:00 2001
From: Rafael Monnerat <rafael@nexedi.com>
Date: Mon, 28 Nov 2022 19:47:09 +0000
Subject: [PATCH] slapos_jio: Extend test parameter sample to filter software
 type

---
 ...t_erp5_page_slap_test_parameter_form_js.js | 37 ++++++++++++-------
 ..._erp5_page_slap_test_parameter_form_js.xml |  4 +-
 2 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_test_parameter_form_js.js b/master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_test_parameter_form_js.js
index 23fb110ff..5343a943c 100644
--- a/master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_test_parameter_form_js.js
+++ b/master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_test_parameter_form_js.js
@@ -51,6 +51,7 @@
                 .push(function () {
                   return gadget.redirect({"command": "change",
                                     "options": {"url_string": doc.url_string,
+                                                "software_type": doc.software_type,
                                                 "parameter_output": doc.text_content}});
                 });
             }, function (error) {
@@ -73,16 +74,10 @@
       if (options.url_string === undefined) {
         options.url_string = "";
       }
-      if (options.editable === undefined) {
-        options.editable = true;
-      }
-      if (options.restricted_softwaretype === undefined) {
-        options.restricted_softwaretype = false;
-      }
       return this.changeState({
         "url_string": options.url_string,
         "parameter_output": options.parameter_output,
-        "restricted_softwaretype": options.restricted_softwaretype
+        "software_type_list": options.software_type
       });
     })
 
@@ -113,14 +108,16 @@
           parameter_dict = {
             'parameter' : {
               'json_url':  gadget.state.url_string.split('?')[0] + ".json",
-              'parameter_hash': parameter_hash,
-              'restricted_softwaretype': false
+              'parameter_hash': parameter_hash
             }
           };
+          if (gadget.state.software_type_list) {
+            parameter_dict.parameter.software_type_list = gadget.state.software_type_list.split(',');
+          }
           return result[0].render({
             erp5_document: {
               "_embedded": {"_view": {
-                "my_url_string": {
+                "your_url_string": {
                   "description": "Software Release Url",
                   "title": "Software Release URL",
                   "default": default_url,
@@ -144,6 +141,18 @@
                   "hidden": gadget.state.url_string === "",
                   "type": "GadgetField"
                 },
+                "your_software_type": {
+                  "description": "",
+                  "title": "Software type",
+                  "default": gadget.state.software_type_list,
+                  "css_class": "",
+                  "required": 0,
+                  "editable": 1,
+                  "sandbox": "",
+                  "key": "software_type",
+                  "hidden": 1,
+                  "type": "StringField"
+                },
                 "your_parameter_output": {
                   "description": "",
                   "title": "Parameters Output",
@@ -167,8 +176,7 @@
                   "key": "parameter_hash",
                   "hidden": gadget.state.parameter_output === undefined,
                   "type": "StringField"
-                },
-                
+                }
               }},
               "_links": {
                 "type": {
@@ -180,14 +188,15 @@
             form_definition: {
               group_list: [[
                 "center",
-                [["my_url_string"], ["your_parameter_output"], ["your_parameter_hash"], ["your_text_content"]]
+                [["your_url_string"], ["your_parameter_output"], ["your_software_type"], ["your_parameter_hash"], ["your_text_content"]]
               ]]
             }
           })
             .push(function () {
               return gadget.getUrlFor({"command": "change",
                                        "options": {"url_string": undefined,
-                                                  "parameter_output": undefined}});
+                                                   "software_type": undefined,
+                                                   "parameter_output": undefined}});
             })
             .push(function (selection_url) {
               return gadget.updateHeader({
diff --git a/master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_test_parameter_form_js.xml b/master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_test_parameter_form_js.xml
index 862393009..eee442eb3 100644
--- a/master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_test_parameter_form_js.xml
+++ b/master/bt5/slapos_jio/PathTemplateItem/web_page_module/rjs_gadget_erp5_page_slap_test_parameter_form_js.xml
@@ -277,7 +277,7 @@
                   </item>
                   <item>
                       <key> <string>serial</string> </key>
-                      <value> <string>1004.31514.19921.44151</string> </value>
+                      <value> <string>1004.41258.43166.28757</string> </value>
                   </item>
                   <item>
                       <key> <string>state</string> </key>
@@ -295,7 +295,7 @@
                           </tuple>
                           <state>
                             <tuple>
-                              <float>1669083537.85</float>
+                              <float>1669664533.48</float>
                               <string>UTC</string>
                             </tuple>
                           </state>
-- 
2.30.9