Commit c9f69fe6 authored by Sven Franck's avatar Sven Franck

app: update mapper for listitem and carousel to new format

parent 050b7fcc
......@@ -3595,7 +3595,7 @@
/* Mapper list item */
/* ********************************************************************** */
/**
* Map records to factory widget listview
* Map records to factory widget listview and carousel
* @method listItem
* @param {object} item Item to be mapped
* @param {object} wrapper Configuration object containing parent info
......@@ -3607,78 +3607,71 @@
// TODO: core?
map.listItem = function (item, wrapper, i) {
var quirk_dict, level, core, new_item, section, pos, label, j, k, field,
record;
record, property, source;
quirk_dict = wrapper.property_dict;
record = item.doc;
new_item = {
"type": "item"
};
// link base
if (quirk_dict.link && !quirk_dict.link_source) {
level = quirk_dict.layout_level || 0;
core = quirk_dict.link_core || (quirk_dict.fragment_list ?
if (quirk_dict.link) {
label = true;
source = quirk_dict.link_source;
if (source) {
new_item.href = source;
} else {
level = quirk_dict.layout_level || 0;
core = quirk_dict.link_core || (quirk_dict.fragment_list ?
quirk_dict.fragment_list.slice(0, level + 1).join("/") : "");
}
// set
new_item.href = ("#" + core + "/" + window.encodeURIComponent(
record[quirk_dict.link_identifier || "_id"])
);
}
new_item = {
"type": "item",
"center": {
"text": []
if (quirk_dict.link_external) {
new_item.external = true;
}
};
}
// radio
if (quirk_dict.radio) {
label = true;
new_item.right = {"radio": true, "action": "check"};
new_item.right = [{"type":"radio", "action": "check"}];
}
// checkbox
if (quirk_dict.check) {
label = true;
new_item.right = {"check": true, "action": "check"};
}
// link
if (quirk_dict.link) {
label = true;
new_item.href = record[quirk_dict.link_source] ||
("#" + core + "/" + window.encodeURIComponent(record[quirk_dict.link_identifier || "id"]));
if (quirk_dict.link_external) {
new_item.external = true;
}
new_item.right = [{"type": "check", "action": "check"}];
}
// add record id for radio/check/linking
// TODO: develop a clean way to use _id and id. this is bad!
if (label) {
new_item.id = record["id"] || record["_id"] || items[i]["id"] || null;
new_item.id = record["id"] || record["_id"] || null;
}
// loop scheme sections
for (j = 0; j < item.scheme.length; j += 1) {
section = item.scheme[j];
pos = section.position;
new_item[pos] = new_item[pos] || {};
new_item[pos] = new_item[pos] || [];
// loop scheme fields
for (k = 0; k < section.field_list.length; k += 1) {
field = section.field_list[k];
// add object to text-array
if (new_item[pos].text) {
// TODO: so much nulllll, also how to convert to input field?
new_item[pos].text.push({
"type": field.type || "span",
"text": util.generateText(record[field.field], field, record),
"aside": field.aside || null,
"count": field.count || null,
"text_i18n": record.text_i18n || null,
"class_list": field.class_list || ""
});
} else {
// set type to record field or field value (custom fields!)
new_item[pos][field.type] = record[field.field || field.value];
}
new_item[pos].push(util.mergeObject(
field,
{
"value": util.generateText(
record[field.value || field.field], field, record
)
}
));
}
}
......
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