Commit 4983a101 by François

Modifications to consider unreliable order of returned JSON objects keys order

parent 6f811203
Pipeline #1396 failed with stage
in 1 minute 25 seconds
......@@ -76,6 +76,7 @@ def get_settings(request):
msettings[k] = v
result['settings'] = dict(sorted(msettings.items(), key=lambda k_v: k_v[1]['sort_order']))
# on preprod server, dict order (through JsonResponse ??) is not respected !!
except Exception as e:
result['error'] = str(e)
else:
......
......@@ -67,6 +67,10 @@ function quillify(params) {
quill.root.innerHTML = params.content;
}
function get_sorted_keys(obj) {
var keys = Object.keys(obj);
return keys.sort(function(a,b){return obj[a].sort_order-obj[b].sort_order});
}
function get_module_settings() {
$.ajax('settings')
.done(function(rData) {
......@@ -76,11 +80,11 @@ function get_module_settings() {
var added_elts = [],
quill_containers = [];
for (let key in msettings) {
get_sorted_keys(msettings).forEach(function(key){
var param = $(param_template.clone().html());
// param html include textarea and input : one of them will be removed
var input = null;
let data = rData.res.settings[key];
let data = msettings[key];
// Fill the label content
param.find('label').text(data.title)
......@@ -126,7 +130,7 @@ function get_module_settings() {
added_elts.push(key);
}
})
if (added_elts.length > 0) {
submit_btn.prependTo(main_content);
submit_btn.clone().appendTo(main_content);
......
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