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 @@
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getSettingList", "getSettingList")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post")
......@@ -33,28 +35,32 @@
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
return form_gadget.getContent();
return RSVP.all([form_gadget.getContent(),
gadget.getSettingList(['me', 'hateoas_url'])]);
})
.push(function (content) {
var property, doc = {};
for (property in content) {
if ((content.hasOwnProperty(property)) &&
// Remove undefined keys added by Gadget fields
(property !== "undefined") &&
// Remove default_*:int keys added by ListField
!(property.endsWith(":int") && property.startsWith("default_"))) {
doc[property] = content[property];
}
}
return gadget.jio_post(doc);
.push(function (result) {
var doc = result[0],
me = result[1][0],
url = result[1][1];
return gadget.jio_putAttachment(me,
url + me + "/Person_requestSupport",
{title: doc.title,
description: doc.description,
aggregate: gadget.state.jio_key,
resource: doc.resource});
})
.push(function (attachment) {
return jIO.util.readBlobAsText(attachment.target.response);
})
.push(function (key) {
.push(function (response) {
return JSON.parse(response.target.result);
})
.push(function (result) {
return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'})
.push(function () {
// Workaround, find a way to open document without break gadget.
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 @@
"key": "resource",
"hidden": 0,
"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": {
......@@ -205,7 +154,7 @@
[["my_resource"]]
], [
"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 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>987.11836.53106.28979</string> </value>
<value> <string>999.2879.31654.18568</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -297,7 +297,7 @@
</tuple>
<state>
<tuple>
<float>1602260953.44</float>
<float>1647959180.04</float>
<string>UTC</string>
</tuple>
</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