Commit 1efd7e68 authored by Sven Franck's avatar Sven Franck

harmonized fieldlist API, switch to setting select_list based on gadget

parent 9402c085
......@@ -11,6 +11,21 @@
"wrap_gadget": 2,
"submit_to": "#servers::__id__"
},
"scheme": [
{
"position": "left",
"fieldlist": [
{"field": "title"},
{"field": "reference_network"}
]
}, {
"position": "center",
"fieldlist": [
{"field": "description"},
{"field": "reference", "overrides": {"widget":{"hidden": true}}}
]
}
],
"children": [{
"generate": "widget",
"type": "form",
......@@ -32,22 +47,7 @@
{"type": "input", "direct": {"value": "Reset", "className": "translate"}, "attributes": {"type": "reset", "data-i18n":"[value]portal_type_dict.computer_dict.text_dict.cancel"}},
{"type": "input", "direct": {"value": "Submit", "className": "action translate"}, "attributes": {"type": "submit", "data-action":"add", "data-icon":"save", "data-i18n":"[value]portal_type_dict.computer_dict.text_dict.submit", "data-theme": "slapos-black"}}
]
}],
"layout": [
{
"position": "left",
"fieldlist": [
{"title": "title"},
{"title": "reference_network"}
]
}, {
"position": "center",
"fieldlist": [
{"title": "description"},
{"title": "reference", "overrides": {"widget":{"hidden": true}}}
]
}
]
}]
}
]
}
......@@ -13,6 +13,15 @@
"wrap_gadget": 2,
"submit_to": "#servers"
},
"scheme": [
{
"position": "left",
"fieldlist": [
{"field": "title", "overrides": {"properties":{"editable":false, "required": false}}},
{"field": "reference", "overrides": {"properties":{"editable":false, "required": false}}}
]
}
],
"children": [{
"generate": "widget",
"type": "form",
......@@ -35,16 +44,7 @@
{"type": "a", "direct": {"href": "#servers::__id__::ssl_off", "className": "ui-btn-slapos-black"}, "attributes": {"data-i18n":"portal_type_dict.computer_dict.text_dict.ssl_off", "data-icon":"unlock"}, "logic": {"text":"Revoke SSL"}},
{"type": "a", "direct": {"href": "#", "className": "action translate error status ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-trash" }, "attributes": {"data-i18n":"portal_type_dict.computer_dict.text_dict.delete", "data-action": "destroy"}, "logic": {"text":"Delete"}}
]
}],
"layout": [
{
"position": "left",
"fieldlist": [
{"title": "title", "overrides": {"properties":{"editable":false, "required": false}}},
{"title": "reference", "overrides": {"properties":{"editable":false, "required": false}}}
]
}
]
}]
}
]
}
......@@ -11,6 +11,49 @@
"requires_authentication": true,
"depends_on": "login_state"
},
"scheme": [
{
"position": "left",
"fieldlist": [
{"field": "title"},
{"field": "reference"},
{"field": "region"},
{"field": "group"},
{"field": "translated_validation_state_title"}
]
},{
"position": "right",
"fieldlist": [
{"field": "cpu_core"},
{"field": "cpu_frequency"},
{"field": "cpu_type"},
{"field": "memory_size"},
{"field": "memory_type"}
]
}, {
"position": "left",
"fieldlist": [
{"field": "storage_capacity"},
{"field": "storage_interface"},
{"field": "storage_redundancy"},
{"field": "storage_technology"}
]
},{
"position": "right",
"fieldlist": [
{"field": "wide_area_network_type"},
{"field": "local_area_network_type"},
{"field": "default_network_address_netmask"},
{"field": "default_network_address_ip_address"},
{"field": "default_network_address_host_name"}
]
}, {
"position": "center",
"fieldlist": [
{"field": "description"}
]
}
],
"children": [{
"generate": "widget",
"type": "form",
......@@ -32,50 +75,7 @@
{"type": "input", "direct": {"value": "Reset", "className": "translate"}, "attributes": {"type": "reset", "data-i18n":"[value]portal_type_dict.computer_dict.text_dict.cancel"}},
{"type": "input", "direct": {"value": "Submit", "className": "action translate"}, "attributes": {"type": "submit", "data-action":"add", "data-i18n":"[value]portal_type_dict.computer_dict.text_dict.submit", "data-theme": "slapos-black"}}
]
}],
"layout": [
{
"position": "left",
"fieldlist": [
{"title": "title"},
{"title": "reference"},
{"title": "region"},
{"title": "group"},
{"title": "translated_validation_state_title"}
]
},{
"position": "right",
"fieldlist": [
{"title": "cpu_core"},
{"title": "cpu_frequency"},
{"title": "cpu_type"},
{"title": "memory_size"},
{"title": "memory_type"}
]
}, {
"position": "left",
"fieldlist": [
{"title": "storage_capacity"},
{"title": "storage_interface"},
{"title": "storage_redundancy"},
{"title": "storage_technology"}
]
},{
"position": "right",
"fieldlist": [
{"title": "wide_area_network_type"},
{"title": "local_area_network_type"},
{"title": "default_network_address_netmask"},
{"title": "default_network_address_ip_address"},
{"title": "default_network_address_host_name"}
]
}, {
"position": "center",
"fieldlist": [
{"title": "description"}
]
}
]
}]
}
]
}
......@@ -11,6 +11,18 @@
"wrap_gadget": 2,
"submit_to": "#networks::__id__"
},
"scheme": [
{
"position": "left",
"fieldlist": [
{"field": "title"}
]
},
{
"position": "right",
"fieldlist": []
}
],
"children": [{
"generate": "widget",
"type": "form",
......@@ -32,19 +44,7 @@
{"type": "input", "direct": {"value": "Reset", "className": "translate"}, "attributes": {"type": "reset", "data-i18n":"[value]portal_type_dict.network_dict.text_dict.cancel"}},
{"type": "input", "direct": {"value": "Submit", "className": "action translate"}, "attributes": {"type": "submit", "data-action":"add", "data-icon":"save", "data-i18n":"[value]portal_type_dict.network_dict.text_dict.submit", "data-theme": "slapos-black"}}
]
}],
"layout": [
{
"position": "left",
"fieldlist": [
{"title": "title"}
]
},
{
"position": "right",
"fieldlist": []
}
]
}]
}
]
}
......@@ -13,6 +13,15 @@
"wrap_gadget": 2,
"submit_to": "#networks"
},
"scheme": [
{
"position": "left",
"fieldlist": [
{"field": "title", "overrides": {"properties":{"editable":false, "required": false}}},
{"field": "reference", "overrides": {"properties":{"editable":false, "required": false}}}
]
}
],
"children": [{
"generate": "widget",
"type": "form",
......@@ -30,15 +39,6 @@
"attributes": {"data-i18n":"portal_type_dict.network_dict.text_dict.delete", "data-action": "destroy"},
"logic": {"text":"Delete"}
}
],
"layout": [
{
"position": "left",
"fieldlist": [
{"title": "title", "overrides": {"properties":{"editable":false, "required": false}}},
{"title": "reference", "overrides": {"properties":{"editable":false, "required": false}}}
]
}
]
}
]
......
......@@ -25,6 +25,46 @@
"reset": "login_state",
"allow_new": true
},
"scheme": [
{
"position": "left",
"fieldlist": [
{"field": "gender"},
{"field": "first_name"},
{"field": "last_name"},
{"field": "default_email_text"},
{"field": "default_telephone_text"},
{"field": "default_mobile_telephone_text"},
{"field": "default_fax_text"},
{"field": "default_address_street"},
{"field": "default_address_city"},
{"field": "default_address_zip_code"},
{"field": "default_address_region"},
{"field": "nationality"}
]
},{
"position": "right",
"fieldlist": [
{"field": "password"},
{"field": "password_confirm"},
{"field": "default_credential_question_question"},
{"field": "default_credential_question_question_free_text"},
{"field": "default_credential_question_answer"},
{"field": "date_of_birth"},
{"field": "corporate_name"},
{"field": "role_list"},
{"field": "activity_list"},
{"field": "work_function"},
{"field": "site"},
{"field": "skill_list"}
]
},{
"position": "center",
"fieldlist": [
{"field": "description"}
]
}
],
"children": [{
"generate": "widget",
"type": "form",
......@@ -46,47 +86,7 @@
{"type": "input", "direct": {"value": "Reset", "className": "translate"}, "attributes": {"type": "reset", "data-i18n":"[value]portal_type_dict.person_dict.text_dict.cancel"}},
{"type": "input", "direct": {"value": "Submit", "className": "action translate"}, "attributes": {"type": "submit", "data-action":"add", "data-i18n":"[value]portal_type_dict.person_dict.text_dict.submit", "data-theme": "slapos-black"}}
]
}],
"layout": [
{
"position": "left",
"fieldlist": [
{"title": "gender"},
{"title": "first_name"},
{"title": "last_name"},
{"title": "default_email_text"},
{"title": "default_telephone_text"},
{"title": "default_mobile_telephone_text"},
{"title": "default_fax_text"},
{"title": "default_address_street"},
{"title": "default_address_city"},
{"title": "default_address_zip_code"},
{"title": "default_address_region"},
{"title": "nationality"}
]
},{
"position": "right",
"fieldlist": [
{"title": "password"},
{"title": "password_confirm"},
{"title": "default_credential_question_question"},
{"title": "default_credential_question_question_free_text"},
{"title": "default_credential_question_answer"},
{"title": "date_of_birth"},
{"title": "corporate_name"},
{"title": "role_list"},
{"title": "activity_list"},
{"title": "work_function"},
{"title": "site"},
{"title": "skill_list"}
]
},{
"position": "center",
"fieldlist": [
{"title": "description"}
]
}
]
}]
}
]
}
......@@ -12,6 +12,38 @@
"depends_on": "login_state",
"submit_to": "#services::__id__"
},
"scheme": [
{
"position": "center",
"fieldlist": [
{"type": "input", "direct": {"disabled": true, "className":"progress_notifier", "name": "status", "id": "status", "value": "Preparing instance..."}, "attributes": {"data-i18n":"[value]portal_type_dict.release_dict.text_dict.prepare_instance"}}
]
},
{
"position": "left",
"fieldlist": [
{"field": "title", "overrides": {"properties": {"required": true, "editable":false}}},
{"field": "version", "overrides": {"properties": {"required": true, "editable":false}}},
{"type": "input", "direct": {"name": "install_release_id", "id": "install_release_id", "className": "required"}, "attributes": {"data-enhanced":"true", "type":"text", "readonly": "readonly"}, "logic":{"setValue": "instance_", "label":"Instance ID", "label_i18n":"portal_type_dict.release_dict.text_dict.instance_id"}},
{"type":"select", "direct":{"name": "install_release_reference_computer", "id": "install_release_reference_computer","className": "required"},"attributes": {"data-enhanced": "true"},"logic": {"label":"Request for Computer", "label_i18n":"portal_type_dict.release_dict.text_dict.instance_server", "options":[{"value":"", "text": "", "selected": "true"}, {"value": "Cortana", "text": "Cortana"},{"value": "Prof. Simon Wright", "text": "Prof. Simon Wright"},{"value": "HAL", "text": "HAL"},{"value": "Computer", "text": "Computer"},{"value": "Lawnmower", "text": "Lawnmower"}]}}
]
},
{
"position": "right",
"fieldlist": [
{"field": "image_url"},
{"field": "image_type", "overrides": {"widget": {"hidden":true}}},
{"field": "image_url", "overrides": {"type": "StringField", "widget": {"hidden": true}}},
{"field": "detail_description", "overrides": {"properties": {"required": true, "editable":false}}}
]
},
{
"position": "center",
"fieldlist": [
{"type": "textarea", "direct": {"name": "install_release_xml_recipe", "id": "install_release_xml_recipe", "className": "required", "value": "<?xml version='1.0' encoding='utf-8'?>\n<instance>\n</instance>"}, "attributes": {"data-enhanced":"true"}, "logic": {"label":"Instance Configuration", "label_i18n":"portal_type_dict.release_dict.text_dict.instance_recipe"}}
]
}
],
"children": [
{
"generate": "widget",
......@@ -34,39 +66,7 @@
{"type": "input", "direct": {"value": "Reset", "className": "translate"}, "attributes": {"type": "reset", "data-i18n":"[value]portal_type_dict.release_dict.text_dict.cancel"}},
{"type": "input", "direct": {"value": "Request", "className": "action translate"}, "attributes": {"type": "submit", "data-action":"install", "data-i18n":"[value]portal_type_dict.release_dict.text_dict.request", "data-theme": "slapos-black"}}
]
}],
"layout": [
{
"position": "center",
"fieldlist": [
{"type": "input", "direct": {"disabled": true, "className":"progress_notifier", "name": "status", "id": "status", "value": "Preparing instance..."}, "attributes": {"data-i18n":"[value]portal_type_dict.release_dict.text_dict.prepare_instance"}}
]
},
{
"position": "left",
"fieldlist": [
{"title": "title", "overrides": {"properties": {"required": true, "editable":false}}},
{"title": "version", "overrides": {"properties": {"required": true, "editable":false}}},
{"type": "input", "direct": {"name": "install_release_id", "id": "install_release_id", "className": "required"}, "attributes": {"data-enhanced":"true", "type":"text", "readonly": "readonly"}, "logic":{"setValue": "instance_", "label":"Instance ID", "label_i18n":"portal_type_dict.release_dict.text_dict.instance_id"}},
{"type":"select", "direct":{"name": "install_release_reference_computer", "id": "install_release_reference_computer","className": "required"},"attributes": {"data-enhanced": "true"},"logic": {"label":"Request for Computer", "label_i18n":"portal_type_dict.release_dict.text_dict.instance_server", "options":[{"value":"", "text": "", "selected": "true"}, {"value": "Cortana", "text": "Cortana"},{"value": "Prof. Simon Wright", "text": "Prof. Simon Wright"},{"value": "HAL", "text": "HAL"},{"value": "Computer", "text": "Computer"},{"value": "Lawnmower", "text": "Lawnmower"}]}}
]
},
{
"position": "right",
"fieldlist": [
{"title": "image_url"},
{"title": "image_type", "overrides": {"widget": {"hidden":true}}},
{"title": "image_url", "overrides": {"type": "StringField", "widget": {"hidden": true}}},
{"title": "detail_description", "overrides": {"properties": {"required": true, "editable":false}}}
]
},
{
"position": "center",
"fieldlist": [
{"type": "textarea", "direct": {"name": "install_release_xml_recipe", "id": "install_release_xml_recipe", "className": "required", "value": "<?xml version='1.0' encoding='utf-8'?>\n<instance>\n</instance>"}, "attributes": {"data-enhanced":"true"}, "logic": {"label":"Instance Configuration", "label_i18n":"portal_type_dict.release_dict.text_dict.instance_recipe"}}
]
}
]
}]
}
]
}
......@@ -10,6 +10,36 @@
"requires_authentication": true,
"depends_on": "login_state"
},
"scheme": [
{
"position": "left",
"fieldlist": [
{"field": "id", "overrides": {"properties": {"editable": false, "required": false}}},
{"field": "title", "overrides": {"widget": {"title": "Software Type", "title_i18n": "portal_type_dict.service_dict.text_dict.software_type"}, "properties": {"editable":false}}},
{"field": "status", "overrides": {"properties": {"editable": false, "required": false}}},
{"field": "reference_computer", "overrides": {"type": "StringField", "properties": {"editable": false, "required": false}}}
]
},
{
"position": "right",
"fieldlist": [
{"field": "detail_description", "overrides": {"properties": {"editable": false}, "required": false}},
{"field": "version", "overrides": {"widget": {"hidden": true}, "properties": {"required": false}}},
{"field": "image_type", "overrides": {"widget": {"hidden": true}, "properties": {"required": false}}},
{"field": "image_url", "overrides": {"type":"StringField", "widget": {"hidden": true}, "properties": {"required": false}}},
{"field": "status", "overrides": {"widget": {"hidden": true}, "properties": {"required": false}}},
{"field": "usage", "overrides": {"widget": {"hidden": true}, "properties": {"required": false}}},
{"field": "timestamp", "overrides": {"widget": {"hidden": true}, "properties": {"required": false}}},
{"field": "reference_release", "overrides": {"widget": {"hidden": true}, "properties": {"required": false}}}
]
},
{
"position": "center",
"fieldlist": [
{"field": "xml_recipe", "overrides": {"widget": {"title": "Instance XML Recipe", "title_i18n": "portal_type_dict.service_dict.text_dict.recipe"}}}
]
}
],
"children": [
{
"generate": "widget",
......@@ -32,37 +62,7 @@
{"type": "input", "direct": {"value": "Stop", "className": "action error status translate"}, "attributes": {"type": "button", "data-i18n":"[value]portal_type_dict.service_dict.text_dict.stop", "data-icon": "ban-circle"}},
{"type": "input", "direct": {"value": "Update", "className": "action translate"}, "attributes": {"type": "submit", "data-action":"add", "data-i18n":"[value]portal_type_dict.service_dict.text_dict.update", "data-icon": "ok", "data-theme": "slapos-black"}}
]
}],
"layout": [
{
"position": "left",
"fieldlist": [
{"title": "id", "overrides": {"properties": {"editable": false, "required": false}}},
{"title": "title", "overrides": {"widget": {"title": "Software Type", "title_i18n": "portal_type_dict.service_dict.text_dict.software_type"}, "properties": {"editable":false}}},
{"title": "status", "overrides": {"properties": {"editable": false, "required": false}}},
{"title": "reference_computer", "overrides": {"type": "StringField", "properties": {"editable": false, "required": false}}}
]
},
{
"position": "right",
"fieldlist": [
{"title": "detail_description", "overrides": {"properties": {"editable": false}, "required": false}},
{"title": "version", "overrides": {"widget": {"hidden": true}, "properties": {"required": false}}},
{"title": "image_type", "overrides": {"widget": {"hidden": true}, "properties": {"required": false}}},
{"title": "image_url", "overrides": {"type":"StringField", "widget": {"hidden": true}, "properties": {"required": false}}},
{"title": "status", "overrides": {"widget": {"hidden": true}, "properties": {"required": false}}},
{"title": "usage", "overrides": {"widget": {"hidden": true}, "properties": {"required": false}}},
{"title": "timestamp", "overrides": {"widget": {"hidden": true}, "properties": {"required": false}}},
{"title": "reference_release", "overrides": {"widget": {"hidden": true}, "properties": {"required": false}}}
]
},
{
"position": "center",
"fieldlist": [
{"title": "xml_recipe", "overrides": {"widget": {"title": "Instance XML Recipe", "title_i18n": "portal_type_dict.service_dict.text_dict.recipe"}}}
]
}
]
}]
}
]
}
......@@ -11,6 +11,22 @@
"link_to_view": "install",
"dynamic_children": [1]
},
"scheme": [
{
"position": "left",
"fieldlist": [
{"field": "image_url", "type": "image"},
{"field": "title", "type": "alt"}
]
},
{
"position": "center",
"fieldlist": [
{"field": "title", "type": "h1"},
{"field": "description", "type": "p"}
]
}
],
"children": [{
"generate": "widget",
"type": "controlbar",
......
......@@ -1530,6 +1530,7 @@
element.form = spec.form;
element.fields = field_dict;
element.reference = spec.id;
element.scheme = spec.scheme;
}
target.appendChild(app.setContent(element));
}
......@@ -2224,7 +2225,7 @@
// TODO: crap to use both layout and children!
// NOTE: securing ? http://nedbatchelder.com/text/stopbots.html
factory.form = function (spec) {
var i, j, k, layout, element, container, area, field, overrides,
var i, j, k, segment, element, container, area, field, overrides,
position, doc, config, value, stamp, sauce, encode, secure,
safety_box, fragment, wrap, item_id, input_config, form_id;
......@@ -2251,9 +2252,9 @@
};
// loop over form layout sections
for (i = 0; i < spec.layout.length; i += 1) {
layout = spec.layout[i];
area = layout.position === "center" ? 2 : 1;
for (i = 0; i < spec.scheme.length; i += 1) {
segment = spec.scheme[i];
area = segment.position === "center" ? 2 : 1;
container = wrap(area);
if (i === 0) {
......@@ -2263,7 +2264,7 @@
stamp = new Date().getTime();
encode = window.btoa || window.shim.Base64.encode;
// TODO: include client IP in hash to block submission serverside
// TODO: include client IP in hash
sauce = encode(stamp.toString() + spec.property_dict.secret_hash);
container.appendChild(factory.formElement(
......@@ -2333,8 +2334,8 @@
}
// loop fieldlist of layout section
for (j = 0; j < layout.fieldlist.length; j += 1) {
field = layout.fieldlist[j];
for (j = 0; j < segment.fieldlist.length; j += 1) {
field = segment.fieldlist[j];
// allow non-fieldlist form elements to be generated
// TODO: can we also generate a field from another portal_type here?
......@@ -2347,10 +2348,10 @@
util.generateUuid();
}
} else {
config = spec.fields[field.title];
config = spec.fields[field.field];
overrides = field.overrides;
doc = spec.data || undefined;
value = doc ? (doc[field.title]) : undefined;
value = doc ? (doc[field.field]) : undefined;
// map config to what we need
input_config = map.utils.mapFormField(
......@@ -2366,10 +2367,10 @@
case 0:
position = true;
break;
case (layout.fieldlist.length - 1):
case (segment.fieldlist.length - 1):
position = false;
break;
case (j === 1 && layout.fieldlist.length === 1):
case (j === 1 && segment.fieldlist.length === 1):
position = null;
break;
default:
......@@ -3983,16 +3984,19 @@
/**
* Generate an array of fields from a dict
* @method makeSelectList
* @param {object} field_dict Dictionary of fields
* @param {object} scheme of gadget to retrieve fields from
* @return {array} select_list
**/
storage.makeSelectList = function (field_dict) {
var field, select_list = [];
storage.makeSelectList = function (scheme) {
var i, j, field, select_list = [];
for (field in field_dict) {
if (field_dict.hasOwnProperty(field)) {
select_list.push(field);
}
for (i = 0; i < scheme.length; i += 1) {
for (j = 0; j < scheme[i].fieldlist.length; j += 1) {
field = scheme[i].fieldlist[j];
if (field.field && select_list.indexOf(field.field) === -1) {
select_list.push(field.field);
}
}
}
return select_list;
};
......@@ -4289,45 +4293,23 @@
*/
app.search = function (config) {
// TODO: why do I need the first 2 calls here, without I cannot search.
// gadget config
app.fetchConfiguration({
"storage": app.default_dict.storage_dict.settings,
"file": app.default_dict.storage_dict.gadgets,
"attachment": config.id,
"pass": undefined
})
.then(function (gadget_config) {
// portal_type fieldlist
return app.fetchConfiguration({
"storage": app.default_dict.storage_dict.settings,
"file": app.default_dict.storage_dict.data_type,
"attachment": gadget_config.portal_type_fields,
"pass": {
"portal_type": gadget_config.portal_type_source
}
});
})
.then(function (reply) {
// update gadget state
config.state.query = app.generateQueryObject(
config.state.initial_query,
reply.pass.portal_type,
null,
config.element.value,
reply.response
);
// update gadget state
config.state.query = app.generateQueryObject(
config.state.initial_query,
config.state.type,
null,
config.element.value,
config.state.query.select_list
);
// update gadget
app.setContent(
{"generate": "gadget", "id": config.id, "href": config.id},
{"fragment_list": config.state.fragment_list, "layout_level": config.state.layout_level},
false
)
.then(function (reply) {
factory.util.updatePageSection(config.id, reply);
})
.fail(util.error);
// update gadget
app.setContent(
{"generate": "gadget", "id": config.id, "href": config.id},
{"fragment_list": config.state.fragment_list, "layout_level": config.state.layout_level},
false
)
.then(function (reply) {
factory.util.updatePageSection(config.id, reply);
})
.fail(util.error);
};
......@@ -4363,9 +4345,12 @@
.then(function(answer) {
if (answer.response) {
answer.query.select_list = storage.makeSelectList(
util.parse(answer.response)
);
util.error("FIX THIS IN LOGIN!")
// we need to make a fieldlist here based on the fields
// requested be the gadget!!!
// answer.query.select_list = storage.makeSelectList(
// util.parse(answer.response)
// );
}
return app.fetchData({
......@@ -5042,7 +5027,7 @@
// WARNING: complex_queries dependency!
app.generateQueryObject = function (query, type, key, value, field_list) {
var property, wrap, query_object, query_clean, default_query, obj,
is_value;
is_value, i;
is_value = value && value !== "";
......@@ -5050,7 +5035,7 @@
if (is_value && key && key === "_id") {
obj = {"_id": value};
// allDocs
// ALLDOCS
} else {
default_query = query || {};
obj = {"query": ''};
......@@ -5089,17 +5074,11 @@
// searching. These fields should not be set in the search
if (field_list && query) {
wrap = "";
for (property in field_list) {
if (field_list.hasOwnProperty(property)) {
if (!util.findKey(
(query_object || {}),
"query_list",
"key",
property
)
) {
wrap += property + ': "%' + value + '%" OR ';
}
for (i = 0; i < field_list.length; i += 1) {
if (!util.findKey(
(query_object || {}), "query_list", "key", field_list[i])
) {
wrap += field_list[i] + ': "%' + value + '%" OR ';
}
}
obj.query += ' AND (' + wrap.slice(0, -4) + ')';
......@@ -5117,9 +5096,9 @@
obj.include_docs = true;
}
if (field_list && storage.force_fields) {
if (field_list && field_list.length > 0 && storage.force_fields) {
delete obj.include_docs;
obj.select_list = storage.makeSelectList(field_list);
obj.select_list = field_list;
}
if (default_query.select_list && default_query.select_list.length > 0) {
......@@ -5489,17 +5468,18 @@
}
pass.state.query.limit = pass.store_limit;
} else {
// generate a new query object, if force_fields is set
// generate an array of columns to select here
// get the columns required based on the gadget config!
if (pass.fields && storage && storage.force_fields) {
if (pass.config.scheme) {
pass.field_list = storage.makeSelectList(pass.config.scheme);
}
}
pass.state.query = app.generateQueryObject(
pass.config.initial_query,
pass.type,
pass.config.property_dict.initial_query_url_identifier,
pass.value,
pass.fields
pass.field_list
);
}
......@@ -5562,8 +5542,7 @@
}
}
// generate new query object
// TODO: we don't pass fields here!
// generate new query object with initial query!
if (pass.config.initial_query) {
pass.state.query = app.generateQueryObject(
{"query": pass.config.initial_query.query},
......@@ -5581,14 +5560,13 @@
(pass.no_auth || ((pass.auth && pass.active_login) ||
(pass.mode === "new" || pass.purge)))) {
// skip total for single item layouts!
// get ALL RECORDS matching query
if (pass.config.initial_query) {
// make sure limit is reset from any sample loading [0,1]
pass.state.query.limit = [];
// store the complete initial query, not only the "query"
pass.state.initial_query = pass.config.initial_query;
return app.fetchData({
"pass": pass,
"storage": "items",
......@@ -5776,7 +5754,7 @@
pass.fields = util.parse(reply.response);
}
// try to get 1 record
// try to get 1 record for this portal type
if ((pass.create !== false || pass.purge) && pass.config.initial_query &&
(pass.no_auth || (pass.auth && pass.active_login))) {
return app.fetchData({
......@@ -5840,9 +5818,11 @@
if (pass.skip === undefined) {
parsed = util.parse(reply.response);
// TODO: WE DON'T NEED ALL OF THIS!
pass.config = parsed;
pass.type = parsed.portal_type_source;
// if app uses login and gadget requires auth
if (app.default_dict.state_dict.login &&
parsed.property_dict.requires_authentication) {
......@@ -5881,6 +5861,10 @@
spec = url_dict || {};
if (content_dict === undefined) {
util.error("setContent: Page not found");
util.loader("", "status_dict.not_found", "ban-circle");
};
switch (content_dict.generate) {
case "widget":
......@@ -5904,7 +5888,6 @@
"create": create,
"layout_level": spec.layout_level || null,
"fragment_list": spec.fragment_list,
"layout": content_dict,
"id": content_dict.id
};
}
......
......@@ -45,6 +45,7 @@
"find_out_more": "To find out more, please refer to:"
},
"status_dict": {
"not_found": "Page not found",
"uploading": "Uploading",
"fetching": "Fetching Data",
"storing": "Storing Data",
......
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