Commit daf30b1f authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Allow user attach a Hosting Subscription to a Project

parent 925a2770
...@@ -269,6 +269,17 @@ ...@@ -269,6 +269,17 @@
"hidden": 0, "hidden": 0,
"type": "GadgetField" "type": "GadgetField"
}, },
"my_source_project": {
"description": "The name of a document in ERP5",
"title": "Current Project",
"default": gadget.state.doc.source_project_title,
"css_class": "",
"required": 1,
"editable": 0,
"key": "source_project_title",
"hidden": 0,
"type": "StringField"
},
"my_monitoring_status": { "my_monitoring_status": {
"description": "", "description": "",
"title": "Monitoring Status", "title": "Monitoring Status",
...@@ -387,10 +398,9 @@ ...@@ -387,10 +398,9 @@
group_list: [[ group_list: [[
"left", "left",
[["my_title"], ["my_reference"], ["my_short_title"], ["my_description"]] [["my_title"], ["my_reference"], ["my_short_title"], ["my_description"]]
], [ ], [
"right", "right",
[["my_slap_state_title"], ['my_monitoring_status'], ['my_monitor_scope'], ['my_upgrade_scope']] [["my_slap_state_title"], ['my_monitoring_status'], ['my_monitor_scope'], ['my_upgrade_scope'], ['my_source_project']]
], ["center", ], ["center",
[["my_source_reference"], ["my_url_string"]] [["my_source_reference"], ["my_url_string"]]
...@@ -410,7 +420,8 @@ ...@@ -410,7 +420,8 @@
gadget.getUrlFor({command: "change", options: {"page": "slap_stop_hosting_subscription"}}), gadget.getUrlFor({command: "change", options: {"page": "slap_stop_hosting_subscription"}}),
gadget.getUrlFor({command: "change", options: {"page": "slap_destroy_hosting_subscription"}}), gadget.getUrlFor({command: "change", options: {"page": "slap_destroy_hosting_subscription"}}),
gadget.getUrlFor({command: "change", options: {page: "slap_rss_ticket"}}), gadget.getUrlFor({command: "change", options: {page: "slap_rss_ticket"}}),
gadget.getUrlFor({command: 'history_previous'}) gadget.getUrlFor({command: 'history_previous'}),
gadget.getUrlFor({command: "change", options: {page: "slap_transfer_hosting_subscription"}})
]); ]);
}) })
.push(function (url_list) { .push(function (url_list) {
...@@ -420,6 +431,7 @@ ...@@ -420,6 +431,7 @@
destroy_url: url_list[4], destroy_url: url_list[4],
rss_url: url_list[5], rss_url: url_list[5],
selection_url: url_list[6], selection_url: url_list[6],
transfer_url: url_list[7],
save_action: true save_action: true
}; };
if (gadget.state.doc.slap_state === "start_requested") { if (gadget.state.doc.slap_state === "start_requested") {
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>975.56864.40160.43520</string> </value> <value> <string>976.53553.17660.802</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1558622604.12</float> <float>1562115464.51</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Add Text Document</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_erp5_page_slap_transfer_hosting_subscription.js"></script>
</head>
<body>
<form class="save_form ui-body-c" novalidate>
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-edit ui-btn-icon-right ui-screen-hidden"></button>
<div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="form_view"
data-gadget-sandbox="public">
</div>
</form>
</body>
</html>
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.allowPublicAcquisition('notifySubmit', function () {
return this.triggerSubmit();
})
.onEvent('submit', function () {
var gadget = this;
return gadget.notifySubmitting()
.push(function () {
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
return form_gadget.getContent();
})
.push(function (doc) {
return gadget.getSetting("hateoas_url")
.push(function (url) {
// This is horrible
return gadget.jio_putAttachment(doc.relative_url,
url + doc.relative_url + "/HostingSubscription_createMovement", doc);
})
.push(function () {
return gadget.notifySubmitted({message: 'Computer is transferred.', status: 'success'})
.push(function () {
// Workaround, find a way to open document without break gadget.
return gadget.redirect({"command": "change",
"options": {"jio_key": doc.relative_url, "page": "slap_controller"}});
});
});
});
})
.declareMethod("triggerSubmit", function () {
return this.element.querySelector('button[type="submit"]').click();
})
.declareMethod("render", function (options) {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return gadget.getSetting("me");
})
.push(function (setting) {
return gadget.jio_get(setting);
})
.push(function (me) {
var i, destination_list = '"NULL",', destination_project_list = '"NULL",';
for (i in me.assignment_destination_project_list) {
destination_project_list += '"' + me.assignment_destination_project_list[i] + '",';
}
for (i in me.assignment_destination_list) {
destination_list += '"' + me.assignment_destination_list[i] + '",';
}
return RSVP.all([
gadget.getDeclaredGadget('form_view'),
gadget.jio_get(options.jio_key),
gadget.jio_allDocs({
query: 'portal_type:"Organisation" AND relative_url:(' + destination_list + ')',
sort_on: [['reference', 'ascending']],
select_list: ['reference', 'title']
}),
gadget.jio_allDocs({
query: 'portal_type:"Project" AND validation_state:"validated" AND relative_url:(' + destination_project_list + ')',
sort_on: [['reference', 'ascending']],
select_list: ['reference', 'title']
})
]);
})
.push(function (result) {
var doc = result[1],
site_list = [["", ""]],
project_list = [["", ""]],
i,
value,
project_len = result[3].data.total_rows,
site_len = result[2].data.total_rows;
for (i = 0; i < site_len; i += 1) {
site_list.push([
result[2].data.rows[i].value.title ? result[2].data.rows[i].value.title : result[2].data.rows[i].value.reference,
result[2].data.rows[i].id
]);
}
for (i = 0; i < project_len; i += 1) {
project_list.push([
result[3].data.rows[i].value.title ? result[3].data.rows[i].value.title : result[3].data.rows[i].value.reference,
result[3].data.rows[i].id
]);
}
return result[0].render({
erp5_document: {
"_embedded": {"_view": {
"my_title": {
"description": "The name of a document in ERP5",
"title": "Title",
"default": doc.title,
"css_class": "",
"required": 1,
"editable": 0,
"key": "title",
"hidden": 0,
"type": "StringField"
},
"my_reference": {
"description": "The name of a document in ERP5",
"title": "Reference",
"default": doc.reference,
"css_class": "",
"required": 1,
"editable": 0,
"key": "reference",
"hidden": 0,
"type": "StringField"
},
"my_source_project": {
"description": "The name of a document in ERP5",
"title": "Current Project",
"default": doc.source_project_title,
"css_class": "",
"required": 1,
"editable": 0,
"key": "source_project_title",
"hidden": 0,
"type": "StringField"
},
"my_destination_project": {
"description": "The name of a document in ERP5",
"title": "Future Project",
"default": "",
"items": project_list,
"css_class": "",
"required": 1,
"editable": 1,
"key": "destination_project",
"hidden": 0,
"type": "ListField"
},
"my_relative_url": {
"description": "",
"title": "Parent Relative Url",
"default": options.jio_key,
"css_class": "",
"required": 1,
"editable": 1,
"key": "relative_url",
"hidden": 1,
"type": "StringField"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"left",
[["my_title"], ["my_reference"], ["my_source_project"], ["my_destination_project"], ["my_relative_url"]]
]]
}
});
})
.push(function () {
return gadget.getSetting('document_title');
})
.push(function (document_title) {
return gadget.updateHeader({
page_title: "Transfer Computer",
submit_action: true
});
});
});
}(window, rJS, RSVP));
\ No newline at end of file
...@@ -372,6 +372,8 @@ gadget_erp5_page_slap_ticket_list.js\n ...@@ -372,6 +372,8 @@ gadget_erp5_page_slap_ticket_list.js\n
gadget_erp5_page_slap_ticket_view.js\n gadget_erp5_page_slap_ticket_view.js\n
gadget_erp5_page_slap_transfer_computer.html\n gadget_erp5_page_slap_transfer_computer.html\n
gadget_erp5_page_slap_transfer_computer.js\n gadget_erp5_page_slap_transfer_computer.js\n
gadget_erp5_page_slap_transfer_hosting_subscription.html\n
gadget_erp5_page_slap_transfer_hosting_subscription.js\n
gadget_erp5_page_slap_trial_request_message.html\n gadget_erp5_page_slap_trial_request_message.html\n
gadget_erp5_page_slap_trial_request_message.js\n gadget_erp5_page_slap_trial_request_message.js\n
gadget_erp5_page_slap_upgrade_decision_view.html\n gadget_erp5_page_slap_upgrade_decision_view.html\n
...@@ -573,7 +575,7 @@ NETWORK:\n ...@@ -573,7 +575,7 @@ NETWORK:\n
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>976.53162.22511.22903</string> </value> <value> <string>976.53195.17162.28177</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -591,7 +593,7 @@ NETWORK:\n ...@@ -591,7 +593,7 @@ NETWORK:\n
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1562093475.71</float> <float>1562117196.29</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -107,6 +107,7 @@ ...@@ -107,6 +107,7 @@
<string>my_monitor_scope</string> <string>my_monitor_scope</string>
<string>my_connection_parameter_list</string> <string>my_connection_parameter_list</string>
<string>my_upgrade_scope</string> <string>my_upgrade_scope</string>
<string>my_source_project_title</string>
</list> </list>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_source_project_title</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_string_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>items</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Current Project</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.Item_getCurrentProjectValue().title</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -126,6 +126,8 @@ web_page_module/rjs_gadget_erp5_page_slap_ticket_list_js ...@@ -126,6 +126,8 @@ web_page_module/rjs_gadget_erp5_page_slap_ticket_list_js
web_page_module/rjs_gadget_erp5_page_slap_ticket_view_js web_page_module/rjs_gadget_erp5_page_slap_ticket_view_js
web_page_module/rjs_gadget_erp5_page_slap_transfer_computer_html web_page_module/rjs_gadget_erp5_page_slap_transfer_computer_html
web_page_module/rjs_gadget_erp5_page_slap_transfer_computer_js web_page_module/rjs_gadget_erp5_page_slap_transfer_computer_js
web_page_module/rjs_gadget_erp5_page_slap_transfer_hosting_subscription_js
web_page_module/rjs_gadget_erp5_page_slap_transfer_hosting_subscription_html
web_page_module/rjs_gadget_erp5_page_slap_trial_request_message_html web_page_module/rjs_gadget_erp5_page_slap_trial_request_message_html
web_page_module/rjs_gadget_erp5_page_slap_trial_request_message_js web_page_module/rjs_gadget_erp5_page_slap_trial_request_message_js
web_page_module/rjs_gadget_erp5_page_slap_upgrade_decision_view_html web_page_module/rjs_gadget_erp5_page_slap_upgrade_decision_view_html
......
...@@ -132,6 +132,8 @@ web_page_module/rjs_gadget_erp5_page_slap_ticket_list_js ...@@ -132,6 +132,8 @@ web_page_module/rjs_gadget_erp5_page_slap_ticket_list_js
web_page_module/rjs_gadget_erp5_page_slap_ticket_view_js web_page_module/rjs_gadget_erp5_page_slap_ticket_view_js
web_page_module/rjs_gadget_erp5_page_slap_transfer_computer_html web_page_module/rjs_gadget_erp5_page_slap_transfer_computer_html
web_page_module/rjs_gadget_erp5_page_slap_transfer_computer_js web_page_module/rjs_gadget_erp5_page_slap_transfer_computer_js
web_page_module/rjs_gadget_erp5_page_slap_transfer_hosting_subscription_html
web_page_module/rjs_gadget_erp5_page_slap_transfer_hosting_subscription_js
web_page_module/rjs_gadget_erp5_page_slap_trial_request_message_html web_page_module/rjs_gadget_erp5_page_slap_trial_request_message_html
web_page_module/rjs_gadget_erp5_page_slap_trial_request_message_js web_page_module/rjs_gadget_erp5_page_slap_trial_request_message_js
web_page_module/rjs_gadget_erp5_page_slap_upgrade_decision_view_html web_page_module/rjs_gadget_erp5_page_slap_upgrade_decision_view_html
......
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