Commit c5b384c0 authored by Romain Courteaud's avatar Romain Courteaud Committed by Kazuhiko Shiozaki

erp5_officejs_support_request_ui: control the initial rendering

parent d333026b
...@@ -3,6 +3,29 @@ ...@@ -3,6 +3,29 @@
(function (window, rJS) { (function (window, rJS) {
"use strict"; "use strict";
function updateResourceListField(gadget) {
var selectedProject = gadget.element.querySelector('#field_your_project').value;
return gadget.jio_getAttachment(
'support_request_module',
gadget.hateoas_url + 'support_request_module'
+ "/SupportRequest_getSupportTypeList"
+ "?project_id=" + selectedProject + "&json_flag=True"
).push(function (sp_list) {
var i, j,
sp_select = gadget.element.querySelector('#field_your_resource');
for (i = sp_select.options.length - 1; i >= 0; i -= 1) {
sp_select.remove(i);
}
for (j = 0; j < sp_list.length; j += 1) {
sp_select.options[j] = new Option(sp_list[j][0], sp_list[j][1]);
}
if (sp_select.options.length === 2) {
sp_select.selectedIndex = 1;
}
});
}
rJS(window) rJS(window)
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Acquired methods // Acquired methods
...@@ -41,40 +64,22 @@ ...@@ -41,40 +64,22 @@
}) })
.push(function (hateoas_url) { .push(function (hateoas_url) {
gadget.hateoas_url = hateoas_url; gadget.hateoas_url = hateoas_url;
}).push(function () { // Do it synchronously, to ensure the full form
gadget.updateResourceListField(); // will be displayed only when the select field has the expected
// values
return updateResourceListField(gadget);
}); });
}) })
.declareMethod('triggerSubmit', function () { .declareMethod('triggerSubmit', function () {
return this.form.triggerSubmit(); return this.form.triggerSubmit();
}) })
.declareJob('updateResourceListField', function () { .declareJob('deferUpdateResourceListField', function () {
var gadget = this, return updateResourceListField(this);
selectedProject = document.getElementById('field_your_project').value;
return gadget.jio_getAttachment(
'support_request_module',
gadget.hateoas_url + 'support_request_module'
+ "/SupportRequest_getSupportTypeList"
+ "?project_id=" + selectedProject + "&json_flag=True"
).push(function (sp_list) {
var i, j,
sp_select = document.getElementById('field_your_resource');
for (i = sp_select.options.length - 1; i >= 0; i -= 1) {
sp_select.remove(i);
}
for (j = 0; j < sp_list.length; j += 1) {
sp_select.options[j] = new Option(sp_list[j][0], sp_list[j][1]);
}
if (sp_select.options.length === 2) {
sp_select.selectedIndex = 1;
}
});
}) })
.onEvent('change', function (evt) { .onEvent('change', function (evt) {
var gadget = this; var gadget = this;
if (evt.target.id === "field_your_project") { if (evt.target.id === "field_your_project") {
gadget.updateResourceListField(); gadget.deferUpdateResourceListField();
} }
}, false, false); }, false, false);
}(window, rJS)); }(window, rJS));
\ No newline at end of file
...@@ -69,7 +69,9 @@ ...@@ -69,7 +69,9 @@
</item> </item>
<item> <item>
<key> <string>content_type</string> </key> <key> <string>content_type</string> </key>
<value> <string>application/javascript</string> </value> <value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
...@@ -244,7 +246,7 @@ ...@@ -244,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>962.26853.29747.36369</string> </value> <value> <string>1017.45366.38938.62225</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -264,8 +266,8 @@ ...@@ -264,8 +266,8 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1607511772.32</float> <float>1719991591.9</float>
<string>GMT+1</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
</object> </object>
......
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