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