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 @@ ...@@ -11,6 +11,21 @@
"wrap_gadget": 2, "wrap_gadget": 2,
"submit_to": "#servers::__id__" "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": [{ "children": [{
"generate": "widget", "generate": "widget",
"type": "form", "type": "form",
...@@ -32,22 +47,7 @@ ...@@ -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": "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"}} {"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 @@ ...@@ -13,6 +13,15 @@
"wrap_gadget": 2, "wrap_gadget": 2,
"submit_to": "#servers" "submit_to": "#servers"
}, },
"scheme": [
{
"position": "left",
"fieldlist": [
{"field": "title", "overrides": {"properties":{"editable":false, "required": false}}},
{"field": "reference", "overrides": {"properties":{"editable":false, "required": false}}}
]
}
],
"children": [{ "children": [{
"generate": "widget", "generate": "widget",
"type": "form", "type": "form",
...@@ -35,16 +44,7 @@ ...@@ -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": "#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"}} {"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 @@ ...@@ -11,6 +11,49 @@
"requires_authentication": true, "requires_authentication": true,
"depends_on": "login_state" "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": [{ "children": [{
"generate": "widget", "generate": "widget",
"type": "form", "type": "form",
...@@ -32,50 +75,7 @@ ...@@ -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": "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"}} {"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 @@ ...@@ -11,6 +11,18 @@
"wrap_gadget": 2, "wrap_gadget": 2,
"submit_to": "#networks::__id__" "submit_to": "#networks::__id__"
}, },
"scheme": [
{
"position": "left",
"fieldlist": [
{"field": "title"}
]
},
{
"position": "right",
"fieldlist": []
}
],
"children": [{ "children": [{
"generate": "widget", "generate": "widget",
"type": "form", "type": "form",
...@@ -32,19 +44,7 @@ ...@@ -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": "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"}} {"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 @@ ...@@ -13,6 +13,15 @@
"wrap_gadget": 2, "wrap_gadget": 2,
"submit_to": "#networks" "submit_to": "#networks"
}, },
"scheme": [
{
"position": "left",
"fieldlist": [
{"field": "title", "overrides": {"properties":{"editable":false, "required": false}}},
{"field": "reference", "overrides": {"properties":{"editable":false, "required": false}}}
]
}
],
"children": [{ "children": [{
"generate": "widget", "generate": "widget",
"type": "form", "type": "form",
...@@ -30,15 +39,6 @@ ...@@ -30,15 +39,6 @@
"attributes": {"data-i18n":"portal_type_dict.network_dict.text_dict.delete", "data-action": "destroy"}, "attributes": {"data-i18n":"portal_type_dict.network_dict.text_dict.delete", "data-action": "destroy"},
"logic": {"text":"Delete"} "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 @@ ...@@ -25,6 +25,46 @@
"reset": "login_state", "reset": "login_state",
"allow_new": true "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": [{ "children": [{
"generate": "widget", "generate": "widget",
"type": "form", "type": "form",
...@@ -46,47 +86,7 @@ ...@@ -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": "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"}} {"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 @@ ...@@ -12,6 +12,38 @@
"depends_on": "login_state", "depends_on": "login_state",
"submit_to": "#services::__id__" "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": [ "children": [
{ {
"generate": "widget", "generate": "widget",
...@@ -34,39 +66,7 @@ ...@@ -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": "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"}} {"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 @@ ...@@ -10,6 +10,36 @@
"requires_authentication": true, "requires_authentication": true,
"depends_on": "login_state" "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": [ "children": [
{ {
"generate": "widget", "generate": "widget",
...@@ -32,37 +62,7 @@ ...@@ -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": "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"}} {"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 @@ ...@@ -11,6 +11,22 @@
"link_to_view": "install", "link_to_view": "install",
"dynamic_children": [1] "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": [{ "children": [{
"generate": "widget", "generate": "widget",
"type": "controlbar", "type": "controlbar",
......
...@@ -1530,6 +1530,7 @@ ...@@ -1530,6 +1530,7 @@
element.form = spec.form; element.form = spec.form;
element.fields = field_dict; element.fields = field_dict;
element.reference = spec.id; element.reference = spec.id;
element.scheme = spec.scheme;
} }
target.appendChild(app.setContent(element)); target.appendChild(app.setContent(element));
} }
...@@ -2224,7 +2225,7 @@ ...@@ -2224,7 +2225,7 @@
// TODO: crap to use both layout and children! // TODO: crap to use both layout and children!
// NOTE: securing ? http://nedbatchelder.com/text/stopbots.html // NOTE: securing ? http://nedbatchelder.com/text/stopbots.html
factory.form = function (spec) { 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, position, doc, config, value, stamp, sauce, encode, secure,
safety_box, fragment, wrap, item_id, input_config, form_id; safety_box, fragment, wrap, item_id, input_config, form_id;
...@@ -2251,9 +2252,9 @@ ...@@ -2251,9 +2252,9 @@
}; };
// loop over form layout sections // loop over form layout sections
for (i = 0; i < spec.layout.length; i += 1) { for (i = 0; i < spec.scheme.length; i += 1) {
layout = spec.layout[i]; segment = spec.scheme[i];
area = layout.position === "center" ? 2 : 1; area = segment.position === "center" ? 2 : 1;
container = wrap(area); container = wrap(area);
if (i === 0) { if (i === 0) {
...@@ -2263,7 +2264,7 @@ ...@@ -2263,7 +2264,7 @@
stamp = new Date().getTime(); stamp = new Date().getTime();
encode = window.btoa || window.shim.Base64.encode; 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); sauce = encode(stamp.toString() + spec.property_dict.secret_hash);
container.appendChild(factory.formElement( container.appendChild(factory.formElement(
...@@ -2333,8 +2334,8 @@ ...@@ -2333,8 +2334,8 @@
} }
// loop fieldlist of layout section // loop fieldlist of layout section
for (j = 0; j < layout.fieldlist.length; j += 1) { for (j = 0; j < segment.fieldlist.length; j += 1) {
field = layout.fieldlist[j]; field = segment.fieldlist[j];
// allow non-fieldlist form elements to be generated // allow non-fieldlist form elements to be generated
// TODO: can we also generate a field from another portal_type here? // TODO: can we also generate a field from another portal_type here?
...@@ -2347,10 +2348,10 @@ ...@@ -2347,10 +2348,10 @@
util.generateUuid(); util.generateUuid();
} }
} else { } else {
config = spec.fields[field.title]; config = spec.fields[field.field];
overrides = field.overrides; overrides = field.overrides;
doc = spec.data || undefined; doc = spec.data || undefined;
value = doc ? (doc[field.title]) : undefined; value = doc ? (doc[field.field]) : undefined;
// map config to what we need // map config to what we need
input_config = map.utils.mapFormField( input_config = map.utils.mapFormField(
...@@ -2366,10 +2367,10 @@ ...@@ -2366,10 +2367,10 @@
case 0: case 0:
position = true; position = true;
break; break;
case (layout.fieldlist.length - 1): case (segment.fieldlist.length - 1):
position = false; position = false;
break; break;
case (j === 1 && layout.fieldlist.length === 1): case (j === 1 && segment.fieldlist.length === 1):
position = null; position = null;
break; break;
default: default:
...@@ -3983,16 +3984,19 @@ ...@@ -3983,16 +3984,19 @@
/** /**
* Generate an array of fields from a dict * Generate an array of fields from a dict
* @method makeSelectList * @method makeSelectList
* @param {object} field_dict Dictionary of fields * @param {object} scheme of gadget to retrieve fields from
* @return {array} select_list * @return {array} select_list
**/ **/
storage.makeSelectList = function (field_dict) { storage.makeSelectList = function (scheme) {
var field, select_list = []; var i, j, field, select_list = [];
for (field in field_dict) { for (i = 0; i < scheme.length; i += 1) {
if (field_dict.hasOwnProperty(field)) { for (j = 0; j < scheme[i].fieldlist.length; j += 1) {
select_list.push(field); field = scheme[i].fieldlist[j];
} if (field.field && select_list.indexOf(field.field) === -1) {
select_list.push(field.field);
}
}
} }
return select_list; return select_list;
}; };
...@@ -4289,45 +4293,23 @@ ...@@ -4289,45 +4293,23 @@
*/ */
app.search = function (config) { app.search = function (config) {
// TODO: why do I need the first 2 calls here, without I cannot search. // update gadget state
// gadget config config.state.query = app.generateQueryObject(
app.fetchConfiguration({ config.state.initial_query,
"storage": app.default_dict.storage_dict.settings, config.state.type,
"file": app.default_dict.storage_dict.gadgets, null,
"attachment": config.id, config.element.value,
"pass": undefined config.state.query.select_list
}) );
.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 // update gadget
app.setContent( app.setContent(
{"generate": "gadget", "id": config.id, "href": config.id}, {"generate": "gadget", "id": config.id, "href": config.id},
{"fragment_list": config.state.fragment_list, "layout_level": config.state.layout_level}, {"fragment_list": config.state.fragment_list, "layout_level": config.state.layout_level},
false false
) )
.then(function (reply) { .then(function (reply) {
factory.util.updatePageSection(config.id, reply); factory.util.updatePageSection(config.id, reply);
})
.fail(util.error);
}) })
.fail(util.error); .fail(util.error);
}; };
...@@ -4363,9 +4345,12 @@ ...@@ -4363,9 +4345,12 @@
.then(function(answer) { .then(function(answer) {
if (answer.response) { if (answer.response) {
answer.query.select_list = storage.makeSelectList( util.error("FIX THIS IN LOGIN!")
util.parse(answer.response) // 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({ return app.fetchData({
...@@ -5042,7 +5027,7 @@ ...@@ -5042,7 +5027,7 @@
// WARNING: complex_queries dependency! // WARNING: complex_queries dependency!
app.generateQueryObject = function (query, type, key, value, field_list) { app.generateQueryObject = function (query, type, key, value, field_list) {
var property, wrap, query_object, query_clean, default_query, obj, var property, wrap, query_object, query_clean, default_query, obj,
is_value; is_value, i;
is_value = value && value !== ""; is_value = value && value !== "";
...@@ -5050,7 +5035,7 @@ ...@@ -5050,7 +5035,7 @@
if (is_value && key && key === "_id") { if (is_value && key && key === "_id") {
obj = {"_id": value}; obj = {"_id": value};
// allDocs // ALLDOCS
} else { } else {
default_query = query || {}; default_query = query || {};
obj = {"query": ''}; obj = {"query": ''};
...@@ -5089,17 +5074,11 @@ ...@@ -5089,17 +5074,11 @@
// searching. These fields should not be set in the search // searching. These fields should not be set in the search
if (field_list && query) { if (field_list && query) {
wrap = ""; wrap = "";
for (property in field_list) { for (i = 0; i < field_list.length; i += 1) {
if (field_list.hasOwnProperty(property)) { if (!util.findKey(
if (!util.findKey( (query_object || {}), "query_list", "key", field_list[i])
(query_object || {}), ) {
"query_list", wrap += field_list[i] + ': "%' + value + '%" OR ';
"key",
property
)
) {
wrap += property + ': "%' + value + '%" OR ';
}
} }
} }
obj.query += ' AND (' + wrap.slice(0, -4) + ')'; obj.query += ' AND (' + wrap.slice(0, -4) + ')';
...@@ -5117,9 +5096,9 @@ ...@@ -5117,9 +5096,9 @@
obj.include_docs = true; obj.include_docs = true;
} }
if (field_list && storage.force_fields) { if (field_list && field_list.length > 0 && storage.force_fields) {
delete obj.include_docs; 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) { if (default_query.select_list && default_query.select_list.length > 0) {
...@@ -5489,17 +5468,18 @@ ...@@ -5489,17 +5468,18 @@
} }
pass.state.query.limit = pass.store_limit; pass.state.query.limit = pass.store_limit;
} else { } else {
// generate a new query object, if force_fields is set // get the columns required based on the gadget config!
// generate an array of columns to select here
if (pass.fields && storage && storage.force_fields) { 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.state.query = app.generateQueryObject(
pass.config.initial_query, pass.config.initial_query,
pass.type, pass.type,
pass.config.property_dict.initial_query_url_identifier, pass.config.property_dict.initial_query_url_identifier,
pass.value, pass.value,
pass.fields pass.field_list
); );
} }
...@@ -5562,8 +5542,7 @@ ...@@ -5562,8 +5542,7 @@
} }
} }
// generate new query object // generate new query object with initial query!
// TODO: we don't pass fields here!
if (pass.config.initial_query) { if (pass.config.initial_query) {
pass.state.query = app.generateQueryObject( pass.state.query = app.generateQueryObject(
{"query": pass.config.initial_query.query}, {"query": pass.config.initial_query.query},
...@@ -5581,14 +5560,13 @@ ...@@ -5581,14 +5560,13 @@
(pass.no_auth || ((pass.auth && pass.active_login) || (pass.no_auth || ((pass.auth && pass.active_login) ||
(pass.mode === "new" || pass.purge)))) { (pass.mode === "new" || pass.purge)))) {
// skip total for single item layouts! // get ALL RECORDS matching query
if (pass.config.initial_query) { if (pass.config.initial_query) {
// make sure limit is reset from any sample loading [0,1] // make sure limit is reset from any sample loading [0,1]
pass.state.query.limit = []; pass.state.query.limit = [];
// store the complete initial query, not only the "query" // store the complete initial query, not only the "query"
pass.state.initial_query = pass.config.initial_query; pass.state.initial_query = pass.config.initial_query;
return app.fetchData({ return app.fetchData({
"pass": pass, "pass": pass,
"storage": "items", "storage": "items",
...@@ -5776,7 +5754,7 @@ ...@@ -5776,7 +5754,7 @@
pass.fields = util.parse(reply.response); 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 && if ((pass.create !== false || pass.purge) && pass.config.initial_query &&
(pass.no_auth || (pass.auth && pass.active_login))) { (pass.no_auth || (pass.auth && pass.active_login))) {
return app.fetchData({ return app.fetchData({
...@@ -5840,9 +5818,11 @@ ...@@ -5840,9 +5818,11 @@
if (pass.skip === undefined) { if (pass.skip === undefined) {
parsed = util.parse(reply.response); parsed = util.parse(reply.response);
// TODO: WE DON'T NEED ALL OF THIS! // TODO: WE DON'T NEED ALL OF THIS!
pass.config = parsed; pass.config = parsed;
pass.type = parsed.portal_type_source; pass.type = parsed.portal_type_source;
// if app uses login and gadget requires auth // if app uses login and gadget requires auth
if (app.default_dict.state_dict.login && if (app.default_dict.state_dict.login &&
parsed.property_dict.requires_authentication) { parsed.property_dict.requires_authentication) {
...@@ -5881,6 +5861,10 @@ ...@@ -5881,6 +5861,10 @@
spec = url_dict || {}; 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) { switch (content_dict.generate) {
case "widget": case "widget":
...@@ -5904,7 +5888,6 @@ ...@@ -5904,7 +5888,6 @@
"create": create, "create": create,
"layout_level": spec.layout_level || null, "layout_level": spec.layout_level || null,
"fragment_list": spec.fragment_list, "fragment_list": spec.fragment_list,
"layout": content_dict,
"id": content_dict.id "id": content_dict.id
}; };
} }
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
"find_out_more": "To find out more, please refer to:" "find_out_more": "To find out more, please refer to:"
}, },
"status_dict": { "status_dict": {
"not_found": "Page not found",
"uploading": "Uploading", "uploading": "Uploading",
"fetching": "Fetching Data", "fetching": "Fetching Data",
"storing": "Storing 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