Commit c0107515 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Improve transfer gadgets for Computer Network

   - Fixup current Organisation on Compute Node UI (missing field)
   - Extend the query to fetch as much project and organisations as possible
   - Sort alphabetically, since it is more user_friendly
   - Keep single field (not current/Future) for each project, and pre-select the default
parent 7546a9a9
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
.declareAcquiredMethod("jio_allDocs", "jio_allDocs") .declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting") .declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted') .declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("getTranslationList", "getTranslationList") .declareAcquiredMethod("getTranslationList", "getTranslationList")
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -39,7 +38,6 @@ ...@@ -39,7 +38,6 @@
.push(function (doc) { .push(function (doc) {
return gadget.getSetting("hateoas_url") return gadget.getSetting("hateoas_url")
.push(function (url) { .push(function (url) {
// This is horrible
return gadget.jio_putAttachment(doc.relative_url, return gadget.jio_putAttachment(doc.relative_url,
url + doc.relative_url + "/ComputerNetwork_createMovement", doc); url + doc.relative_url + "/ComputerNetwork_createMovement", doc);
}) })
...@@ -65,10 +63,8 @@ ...@@ -65,10 +63,8 @@
"The name of a document in ERP5", "The name of a document in ERP5",
"Title", "Title",
"Reference", "Reference",
"Current Project", "Project",
"Future Project", "Organisation",
"Current Organisation",
"Future Organisation",
"Parent Relative Url", "Parent Relative Url",
"Transfer Computer Network", "Transfer Computer Network",
"Computer Network is transferred." "Computer Network is transferred."
...@@ -93,21 +89,25 @@ ...@@ -93,21 +89,25 @@
gadget.jio_get(options.jio_key), gadget.jio_get(options.jio_key),
gadget.jio_allDocs({ gadget.jio_allDocs({
query: 'portal_type:"Project" AND validation_state:"validated"', query: 'portal_type:"Project" AND validation_state:"validated"',
sort_on: [['reference', 'ascending']], sort_on: [['title', 'ascending']],
select_list: ['reference', 'title'] select_list: ['reference', 'title'],
limit: 1000
}), }),
gadget.jio_allDocs({ gadget.jio_allDocs({
query: 'portal_type:"Organisation" AND role_title: "Client" AND relative_url:(' + destination_list + ')', query: 'portal_type:"Organisation" AND role_title: "Client" AND relative_url:(' + destination_list + ')',
sort_on: [['reference', 'ascending']], sort_on: [['title', 'ascending']],
select_list: ['reference', 'title'] select_list: ['reference', 'title'],
limit: 1000
}), }),
gadget.getTranslationList(translation_list) gadget.getTranslationList(translation_list)
]); ]);
}) })
.push(function (result) { .push(function (result) {
gadget.page_title_translation = result[4][8]; gadget.page_title_translation = result[4][6];
gadget.message_translation = result[4][9]; gadget.message_translation = result[4][7];
var doc = result[1], var doc = result[1],
default_project = "",
default_organisation = "",
organisation_list = [["", ""]], organisation_list = [["", ""]],
project_list = [["", ""]], project_list = [["", ""]],
i, i,
...@@ -115,6 +115,9 @@ ...@@ -115,6 +115,9 @@
organisation_len = result[3].data.total_rows; organisation_len = result[3].data.total_rows;
for (i = 0; i < project_len; i += 1) { for (i = 0; i < project_len; i += 1) {
if (result[2].data.rows[i].value.title === doc.source_project_title) {
default_project = result[2].data.rows[i].id;
}
project_list.push([ project_list.push([
result[2].data.rows[i].value.title || result[2].data.rows[i].value.reference, result[2].data.rows[i].value.title || result[2].data.rows[i].value.reference,
result[2].data.rows[i].id result[2].data.rows[i].id
...@@ -122,6 +125,9 @@ ...@@ -122,6 +125,9 @@
} }
for (i = 0; i < organisation_len; i += 1) { for (i = 0; i < organisation_len; i += 1) {
if (result[3].data.rows[i].value.title === doc.source_project_title) {
default_organisation = result[3].data.rows[i].id;
}
organisation_list.push([ organisation_list.push([
result[3].data.rows[i].value.title || result[3].data.rows[i].value.reference, result[3].data.rows[i].value.title || result[3].data.rows[i].value.reference,
result[3].data.rows[i].id result[3].data.rows[i].id
...@@ -153,47 +159,25 @@ ...@@ -153,47 +159,25 @@
"hidden": 0, "hidden": 0,
"type": "StringField" "type": "StringField"
}, },
"my_source_project": {
"description": result[4][0],
"title": result[4][3],
"default": doc.source_project_title,
"css_class": "",
"required": 1,
"editable": 0,
"key": "source_project_title",
"hidden": 0,
"type": "StringField"
},
"my_destination_project": { "my_destination_project": {
"description": result[4][0], "description": result[4][0],
"title": result[4][4], "title": result[4][3],
"default": "", "default": default_project,
"items": project_list, "items": project_list,
"css_class": "", "css_class": "",
"required": 1, "required": 0,
"editable": 1, "editable": 1,
"key": "destination_project", "key": "destination_project",
"hidden": 0, "hidden": 0,
"type": "ListField" "type": "ListField"
}, },
"my_source_section": {
"description": result[4][0],
"title": result[4][5],
"default": doc.source_section_title,
"css_class": "",
"required": 1,
"editable": 0,
"key": "source_section_title",
"hidden": 0,
"type": "StringField"
},
"my_destination_section": { "my_destination_section": {
"description": result[4][0], "description": result[4][0],
"title": result[4][6], "title": result[4][4],
"default": "", "default": default_organisation,
"items": organisation_list, "items": organisation_list,
"css_class": "", "css_class": "",
"required": 1, "required": 0,
"editable": 1, "editable": 1,
"key": "destination_section", "key": "destination_section",
"hidden": 0, "hidden": 0,
...@@ -201,10 +185,10 @@ ...@@ -201,10 +185,10 @@
}, },
"my_relative_url": { "my_relative_url": {
"description": "", "description": "",
"title": result[4][7], "title": result[4][5],
"default": options.jio_key, "default": options.jio_key,
"css_class": "", "css_class": "",
"required": 1, "required": 0,
"editable": 1, "editable": 1,
"key": "relative_url", "key": "relative_url",
"hidden": 1, "hidden": 1,
...@@ -221,7 +205,8 @@ ...@@ -221,7 +205,8 @@
form_definition: { form_definition: {
group_list: [[ group_list: [[
"left", "left",
[["my_title"], ["my_reference"], ["my_source_project"], ["my_source_section"], ["my_destination_project"], ["my_destination_section"], ["my_relative_url"]] [["my_title"], ["my_reference"], ["my_source_project"], ["my_source_section"],
["my_destination_project"], ["my_destination_section"], ["my_relative_url"]]
]] ]]
} }
}); });
......
...@@ -281,7 +281,7 @@ ...@@ -281,7 +281,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>993.49407.7079.26129</string> </value> <value> <string>1008.22397.35734.62054</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -301,7 +301,7 @@ ...@@ -301,7 +301,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1638836685.2</float> <float>1683828480.9</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