Commit 7a10433f authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Call checkValidity before request the instance

This will require to the user input title, else the form will indicate that information is missing.
parent 99834304
...@@ -17,8 +17,6 @@ ...@@ -17,8 +17,6 @@
.declareAcquiredMethod("notifySubmitting", "notifySubmitting") .declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted') .declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// declared methods // declared methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -33,14 +31,22 @@ ...@@ -33,14 +31,22 @@
return gadget.getDeclaredGadget('form_view'); return gadget.getDeclaredGadget('form_view');
}) })
.push(function (form_gadget) { .push(function (form_gadget) {
return form_gadget.checkValidity()
.push(function (is_valid) {
if (!is_valid) {
return null;
}
return form_gadget.getContent(); return form_gadget.getContent();
});
}) })
.push(function (doc) { .push(function (doc) {
if (doc === null) {
return gadget.notifySubmitted({message: 'Please review the form.', status: 'error'});
}
return gadget.getSetting("hateoas_url") return gadget.getSetting("hateoas_url")
.push(function (url) { .push(function (url) {
return gadget.jio_putAttachment(doc.relative_url, return gadget.jio_putAttachment(doc.relative_url,
url + doc.relative_url + "/SoftwareRelease_requestHostingSubscription", doc); url + doc.relative_url + "/SoftwareRelease_requestHostingSubscription", doc);
});
}) })
.push(function (key) { .push(function (key) {
return gadget.notifySubmitted({message: 'New service created.', status: 'success'}) return gadget.notifySubmitted({message: 'New service created.', status: 'success'})
...@@ -50,6 +56,7 @@ ...@@ -50,6 +56,7 @@
"options": {"jio_key": "/", "page": "slap_service_list"}}); "options": {"jio_key": "/", "page": "slap_service_list"}});
}); });
}); });
});
}) })
.declareMethod("triggerSubmit", function () { .declareMethod("triggerSubmit", function () {
...@@ -83,7 +90,7 @@ ...@@ -83,7 +90,7 @@
"title": "Software Release URL", "title": "Software Release URL",
"default": doc.url_string, "default": doc.url_string,
"css_class": "", "css_class": "",
"required": 0, "required": 1,
"editable": 0, "editable": 0,
"key": "url_string", "key": "url_string",
"hidden": 0, "hidden": 0,
...@@ -94,7 +101,7 @@ ...@@ -94,7 +101,7 @@
"title": "Title", "title": "Title",
"default": "", "default": "",
"css_class": "", "css_class": "",
"required": 0, "required": 1,
"editable": 1, "editable": 1,
"key": "title", "key": "title",
"hidden": 0, "hidden": 0,
...@@ -119,7 +126,7 @@ ...@@ -119,7 +126,7 @@
"default": "", "default": "",
"items": doc.computer_guid, "items": doc.computer_guid,
"css_class": "", "css_class": "",
"required": 1, "required": 0,
"editable": 1, "editable": 1,
"key": "computer_guid", "key": "computer_guid",
"hidden": 0, "hidden": 0,
......
...@@ -273,7 +273,7 @@ ...@@ -273,7 +273,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>972.39869.45647.37461</string> </value> <value> <string>975.59432.24638.52206</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -291,7 +291,7 @@ ...@@ -291,7 +291,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1545997392.99</float> <float>1558622071.93</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment