Commit eeb26a2f authored by Sven Franck's avatar Sven Franck

added portal_type to query for total number of records

parent f428d904
...@@ -2023,15 +2023,20 @@ ...@@ -2023,15 +2023,20 @@
if (config.columns && config.columns.length > 0) { if (config.columns && config.columns.length > 0) {
obj.select_list = config.columns; obj.select_list = config.columns;
} }
if (config.limit) {
obj.start = config.limit[0];
obj.items = config.limit[1];
}
if (item) { if (item) {
obj.query += 'AND (id:"%' + item + '")'; obj.query += 'AND (id:"%' + item + '")';
obj.start = 0; obj.start = 0;
obj.items = 1; obj.items = 1;
}
if (obj.start !== undefined) {
obj.limit = [obj.start, obj.items];
} else { } else {
obj.start = config.limit[0]; obj.limit = [];
obj.items = config.limit[1];
} }
obj.limit = [obj.start, obj.items];
if (config.wildcard) { if (config.wildcard) {
obj.wildcard_character = config.wildcard obj.wildcard_character = config.wildcard
} else { } else {
...@@ -2571,6 +2576,7 @@ ...@@ -2571,6 +2576,7 @@
// generate content // generate content
// NOTE: this may include local header/footer/panel/popups // NOTE: this may include local header/footer/panel/popups
// TODO: beware of target when adding the above! should not be content // TODO: beware of target when adding the above! should not be content
// TODO: bundle into a single DOM operation!
for (i = 0; i < gadgets.length; i += 1) { for (i = 0; i < gadgets.length; i += 1) {
gadget = gadgets[i]; gadget = gadgets[i];
gadget_id = gadget.gadget || gadget.getAttribute("data-gadget-id"); gadget_id = gadget.gadget || gadget.getAttribute("data-gadget-id");
...@@ -2612,8 +2618,12 @@ ...@@ -2612,8 +2618,12 @@
return undefined; return undefined;
}) })
.then(function(sample_data) { .then(function(sample_data) {
if (sample_data && typeof sample_data.target.response === "string") { if (sample_data) {
response = JSON.parse(sample_data.target.response); if (typeof sample_data.target.response === "string") {
response = JSON.parse(sample_data.target.response);
} else {
response = sample_data.target.response;
}
return init.storeSampleData(response, portal_type, "items"); return init.storeSampleData(response, portal_type, "items");
} }
return undefined; return undefined;
...@@ -2634,7 +2644,7 @@ ...@@ -2634,7 +2644,7 @@
gadget_type = gadget.type || gadget_type = gadget.type ||
gadget.getAttribute("data-gadget-type"); gadget.getAttribute("data-gadget-type");
constructor = gadget_type; constructor = gadget_type;
query = {}; query = init.buildQuery({}, portal_type);
} }
return util.fetchData("items", query); return util.fetchData("items", 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