Commit 49c80882 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Fixup add related ticket

  It relies on Person_requestSupport now
parent 3ccd0906
Pipeline #20322 failed with stage
in 0 seconds
...@@ -10,7 +10,9 @@ ...@@ -10,7 +10,9 @@
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel") .declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment") .declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getSettingList", "getSettingList")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post") .declareAcquiredMethod("jio_post", "jio_post")
...@@ -33,28 +35,32 @@ ...@@ -33,28 +35,32 @@
return gadget.getDeclaredGadget('form_view'); return gadget.getDeclaredGadget('form_view');
}) })
.push(function (form_gadget) { .push(function (form_gadget) {
return form_gadget.getContent(); return RSVP.all([form_gadget.getContent(),
gadget.getSettingList(['me', 'hateoas_url'])]);
}) })
.push(function (content) { .push(function (result) {
var property, doc = {}; var doc = result[0],
for (property in content) { me = result[1][0],
if ((content.hasOwnProperty(property)) && url = result[1][1];
// Remove undefined keys added by Gadget fields return gadget.jio_putAttachment(me,
(property !== "undefined") && url + me + "/Person_requestSupport",
// Remove default_*:int keys added by ListField {title: doc.title,
!(property.endsWith(":int") && property.startsWith("default_"))) { description: doc.description,
doc[property] = content[property]; aggregate: gadget.state.jio_key,
} resource: doc.resource});
})
} .push(function (attachment) {
return gadget.jio_post(doc); return jIO.util.readBlobAsText(attachment.target.response);
})
.push(function (response) {
return JSON.parse(response.target.result);
}) })
.push(function (key) { .push(function (result) {
return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'}) return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'})
.push(function () { .push(function () {
// Workaround, find a way to open document without break gadget. // Workaround, find a way to open document without break gadget.
return gadget.redirect({"command": "change", return gadget.redirect({"command": "change",
"options": {"jio_key": key, "page": "slap_controller"}}); "options": {"jio_key": result.relative_url, "page": "slap_controller"}});
}); });
}); });
}) })
...@@ -133,63 +139,6 @@ ...@@ -133,63 +139,6 @@
"key": "resource", "key": "resource",
"hidden": 0, "hidden": 0,
"type": "ListField" "type": "ListField"
},
"my_destination_decision": {
"description": result[3][1],
"title": result[3][5],
"default": result[2],
"css_class": "",
"required": 1,
"editable": 1,
"key": "destination_decision",
"hidden": 1,
"type": "StringField"
},
"my_specialise": {
"description": "",
"title": result[3][6],
// Auto Set a hardcoded trade Condition
// Please replace it by a getSetting.
"default": "sale_trade_condition_module/slapos_ticket_trade_condition",
"css_class": "",
"required": 1,
"editable": 1,
"key": "specialise",
"hidden": 1,
"type": "StringField"
},
"my_aggregate": {
"description": "",
"title": result[3][7],
"default": gadget.state.jio_key,
"css_class": "",
"required": 1,
"editable": 1,
"key": "aggregate",
"hidden": 1,
"type": "StringField"
},
"my_portal_type": {
"description": result[3][1],
"title": result[3][8],
"default": "Support Request",
"css_class": "",
"required": 1,
"editable": 1,
"key": "portal_type",
"hidden": 1,
"type": "StringField"
},
"my_parent_relative_url": {
"description": "",
"title": result[3][10],
"default": "support_request_module",
"css_class": "",
"required": 1,
"editable": 1,
"key": "parent_relative_url",
"hidden": 1,
"type": "StringField"
} }
}}, }},
"_links": { "_links": {
...@@ -205,7 +154,7 @@ ...@@ -205,7 +154,7 @@
[["my_resource"]] [["my_resource"]]
], [ ], [
"center", "center",
[["my_title"], ["my_description"], ["my_specialise"], ["my_destination_decision"], ["my_aggregate"], ["my_portal_type"], ["my_parent_relative_url"]] [["my_title"], ["my_description"]]
]] ]]
} }
}) })
......
...@@ -279,7 +279,7 @@ ...@@ -279,7 +279,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>987.11836.53106.28979</string> </value> <value> <string>999.2879.31654.18568</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -297,7 +297,7 @@ ...@@ -297,7 +297,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1602260953.44</float> <float>1647959180.04</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