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): ...@@ -76,6 +76,7 @@ def get_settings(request):
msettings[k] = v msettings[k] = v
result['settings'] = dict(sorted(msettings.items(), key=lambda k_v: k_v[1]['sort_order'])) 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: except Exception as e:
result['error'] = str(e) result['error'] = str(e)
else: else:
......
...@@ -67,6 +67,10 @@ function quillify(params) { ...@@ -67,6 +67,10 @@ function quillify(params) {
quill.root.innerHTML = params.content; 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() { function get_module_settings() {
$.ajax('settings') $.ajax('settings')
.done(function(rData) { .done(function(rData) {
...@@ -76,11 +80,11 @@ function get_module_settings() { ...@@ -76,11 +80,11 @@ function get_module_settings() {
var added_elts = [], var added_elts = [],
quill_containers = []; quill_containers = [];
for (let key in msettings) { get_sorted_keys(msettings).forEach(function(key){
var param = $(param_template.clone().html()); var param = $(param_template.clone().html());
// param html include textarea and input : one of them will be removed // param html include textarea and input : one of them will be removed
var input = null; var input = null;
let data = rData.res.settings[key]; let data = msettings[key];
// Fill the label content // Fill the label content
param.find('label').text(data.title) param.find('label').text(data.title)
...@@ -126,7 +130,7 @@ function get_module_settings() { ...@@ -126,7 +130,7 @@ function get_module_settings() {
added_elts.push(key); added_elts.push(key);
} })
if (added_elts.length > 0) { if (added_elts.length > 0) {
submit_btn.prependTo(main_content); submit_btn.prependTo(main_content);
submit_btn.clone().appendTo(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