Commit 44e1fb21 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Allow to attach Computer Network to a Project

parent 55afac7d
......@@ -135,6 +135,17 @@
"hidden": 0,
"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": "",
"hidden": 0,
"type": "StringField"
},
"listbox": {
"column_list": column_list,
"show_anchor": 0,
......@@ -166,7 +177,10 @@
form_definition: {
group_list: [[
"left",
[["my_title"], ["my_reference"], ['my_monitoring_status']]
[["my_title"], ["my_reference"]]
], [
"right",
[['my_monitoring_status'], ["my_source_project"]]
], [
"bottom",
[["listbox"]]
......@@ -178,8 +192,8 @@
return RSVP.all([
gadget.getUrlFor({command: "change", options: {editable: true}}),
gadget.getUrlFor({command: 'history_previous'}),
gadget.getUrlFor({command: "change", options: {page: "slap_delete_network"}})
gadget.getUrlFor({command: "change", options: {page: "slap_delete_network"}}),
gadget.getUrlFor({command: "change", options: {page: "slap_transfer_computer_network"}})
]);
})
.push(function (url_list) {
......@@ -187,6 +201,7 @@
selection_url: url_list[1],
page_title: "Computer Network :" + gadget.state.doc.title,
delete_url: url_list[2],
transfer_url: url_list[3],
save_action: true
};
if (!gadget.state.editable) {
......
......@@ -216,7 +216,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>superrafael</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.51644.49478.39304</string> </value>
<value> <string>976.54433.31362.16861</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1554343320.18</float>
<float>1562167951.36</float>
<string>UTC</string>
</tuple>
</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_computer_network.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 + "/ComputerNetwork_createMovement", doc);
})
.push(function () {
return gadget.notifySubmitted({message: 'Computer Network 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 RSVP.Queue()
.push(function () {
return gadget.getSetting("me");
})
.push(function (setting) {
return gadget.jio_get(setting);
})
.push(function (me) {
var i, destination_project_list = '"NULL",';
for (i in me.assignment_destination_project_list) {
destination_project_list += '"' + me.assignment_destination_project_list[i] + '",';
}
return RSVP.all([
gadget.getDeclaredGadget('form_view'),
gadget.jio_get(options.jio_key),
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[2].data.total_rows;
for (i = 0; i < project_len; i += 1) {
project_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
]);
}
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 Network",
submit_action: true
});
});
});
}(window, rJS, RSVP));
\ No newline at end of file
......@@ -374,6 +374,8 @@ gadget_erp5_page_slap_transfer_computer.html\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_transfer_computer_network.html\n
gadget_erp5_page_slap_transfer_computer_network.js\n
gadget_erp5_page_slap_trial_request_message.html\n
gadget_erp5_page_slap_trial_request_message.js\n
gadget_erp5_page_slap_upgrade_decision_view.html\n
......@@ -575,7 +577,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>976.53195.17162.28177</string> </value>
<value> <string>976.53590.39649.887</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -593,7 +595,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1562117196.29</float>
<float>1562173473.25</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -96,6 +96,7 @@
<string>my_title</string>
<string>my_reference</string>
<string>my_news</string>
<string>my_source_project_title</string>
</list>
</value>
</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>
......@@ -128,6 +128,8 @@ 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_hosting_subscription_js
web_page_module/rjs_gadget_erp5_page_slap_transfer_hosting_subscription_html
web_page_module/rjs_gadget_erp5_page_slap_transfer_computer_network_html
web_page_module/rjs_gadget_erp5_page_slap_transfer_computer_network_js
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_upgrade_decision_view_html
......
......@@ -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_transfer_computer_html
web_page_module/rjs_gadget_erp5_page_slap_transfer_computer_js
web_page_module/rjs_gadget_erp5_page_slap_transfer_computer_network_html
web_page_module/rjs_gadget_erp5_page_slap_transfer_computer_network_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
......
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