Commit 8aa3aed6 authored by Sven Franck's avatar Sven Franck

app: add setKey to dynamically set properties in map.listItem

parent 525c2cc1
......@@ -1844,6 +1844,7 @@
// TODO: add collapsible support if needed
// TODO: dividers? will not be in spec, so can only be listview option!
// TODO: find better way to set mapper/widget
// TODO: make setParam/setValue/setKey generic over all widgets!
factory.widget.listview = function (spec) {
var fragment, has_filter, generator, filter_id;
......@@ -2544,7 +2545,6 @@
"type": is_type ? "checkbox" : "radio",
"data-i18n": "[value]",
"data-enhanced": true,
"value": "Select item",
"data-iconpos": "notext"
};
if (spec.action) {
......@@ -3553,14 +3553,14 @@
// TODO: move radio/check into property_dict and item? or do same on tableItem
// TODO: not nice & find better handling for text elements and i18n tags
// TODO: subordinated fields should have links, not id only!!!
// NOTE: make sure there is no "id" flying through here!!! only _id
// TODO: make sure there is no "id" flying through here!!! only _id
map.listItem = function (spec) {
var quirk_dict, section, label, j, k, field, setter, record, new_item,
id, key, translation_fields, item, relation, promise_list, pass, count,
class_string;
promise_list = [];
translation_fields = "titletextlabel";
translation_fields = " titletextlabel ";
quirk_dict = spec.wrapper.property_dict;
item = spec.item;
record = item.doc;
......@@ -3614,6 +3614,7 @@
"record": record,
"position": section.position,
"key": key,
"setKey": field.setKey,
"field": field,
"text_element": translation_fields.indexOf(key) > -1
};
......@@ -3634,10 +3635,11 @@
return RSVP.all(promise_list)
.then(function(response_list) {
var l, len, response, obj, setter, pos;
var l, len, response, obj, setter, pos, setter_key;
for (l = 0, len = response_list.length; l < len; l += 1) {
response = response_list[l];
setter_key = response.key;
pos = response.position;
obj = {};
new_item[pos] = new_item[pos] || [];
......@@ -3645,15 +3647,16 @@
// text/label/... all stuff translateable
if (response.text_element) {
obj[response.key + "_18n"] = record[response.key + "_i18n"];
setter = key;
obj[setter_key + "_18n"] = record[setter_key + "_i18n"];
setter = setter_key;
} else {
setter = "value";
setter = response.setKey || "value";
}
obj[setter] = response.value;
new_item[pos].push(util.mergeObject(response.field, obj));
}
return new_item;
})
.fail(app.util.error);
......@@ -7113,6 +7116,7 @@
break;
}
}
return initial_query;
};
......
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