Commit 0247423b authored by Sven Franck's avatar Sven Franck

fixing loading of pages with/without auth, new items loading

parent 2efdfaab
...@@ -1211,8 +1211,18 @@ ...@@ -1211,8 +1211,18 @@
* @return {object} fragment * @return {object} fragment
**/ **/
"listbox": function (spec, answer, field_dict, update, url_pointer) { "listbox": function (spec, answer, field_dict, update, url_pointer) {
var element, i, empty, target, container, pack, slot, pop, active; var element, i, empty, target, container, pack, slot, pop, active,
placeholder;
// set placeholders
placeholder = spec.placeholder_dict || {};
// no auth
if (answer === null) {
target = factory.util.wrapInForm(spec);
target.appendChild(app.noItemsFound(placeholder.no_auth));
return target;
} else {
// determine target element, that will be returned // determine target element, that will be returned
if (update) { if (update) {
target = document.createDocumentFragment(); target = document.createDocumentFragment();
...@@ -1278,7 +1288,7 @@ ...@@ -1278,7 +1288,7 @@
} }
} }
} else { } else {
target.appendChild(app.noItemsFound()); target.appendChild(app.noItemsFound(placeholder.no_items));
} }
// assemble and/or return // assemble and/or return
...@@ -1287,6 +1297,7 @@ ...@@ -1287,6 +1297,7 @@
return container; return container;
} }
return target; return target;
}
}, },
/** /**
...@@ -1300,12 +1311,19 @@ ...@@ -1300,12 +1311,19 @@
* @return {object} fragment * @return {object} fragment
**/ **/
"fieldlist": function (spec, answer, field_dict, update, url_pointer) { "fieldlist": function (spec, answer, field_dict, update, url_pointer) {
var i, element, target; var i, element, target, placeholder;
// set placeholders
placeholder = spec.placeholder_dict || {};
// no auth // no auth
console.log("so what is answer")
console.log(answer)
console.log(answer === null)
if (answer === null) { if (answer === null) {
target = factory.util.wrapInForm(spec); target = factory.util.wrapInForm(spec);
target.appendChild(app.noItemsFound("auth")); target.appendChild(app.noItemsFound(placeholder.no_auth));
return target; return target;
} else { } else {
target = document.createDocumentFragment(); target = document.createDocumentFragment();
...@@ -2038,11 +2056,11 @@ ...@@ -2038,11 +2056,11 @@
position, doc, config, value, stamp, sauce, encode, secure, position, doc, config, value, stamp, sauce, encode, secure,
safety_box, noscript, fragment, wrap; safety_box, noscript, fragment, wrap;
fragment = factory.util.wrapInForm(spec);
secure = spec.property_dict.secure;
if (spec.property_dict.update) { if (spec.property_dict.update) {
spec.update = spec.property_dict.update; spec.update = spec.property_dict.update;
} }
fragment = factory.util.wrapInForm(spec);
secure = spec.property_dict.secure;
wrap = function (area, captcha) { wrap = function (area, captcha) {
var keys = {}; var keys = {};
...@@ -3750,8 +3768,14 @@ ...@@ -3750,8 +3768,14 @@
"pass": {"type": config.gadget.state.type, "reply": true} "pass": {"type": config.gadget.state.type, "reply": true}
}) })
.then(function(answer) { .then(function(answer) {
console.log("soo....")
console.log(answer)
// TODO: This is not the correct place to run all status updates! // TODO: This is not the correct place to run all status updates!
if (answer.response.result === "success") { if (answer.response.result === "success") {
console.log("swithing")
console.log(config)
console.log(config.gadget)
console.log("mh")
switch (config.gadget.getAttribute("data-set")) { switch (config.gadget.getAttribute("data-set")) {
case "login_state": case "login_state":
app.setLoginStatus(answer.response, config.portal_type_source); app.setLoginStatus(answer.response, config.portal_type_source);
...@@ -4170,49 +4194,23 @@ ...@@ -4170,49 +4194,23 @@
/** /**
* return a placeholder with button in case no items were found * return a placeholder with button in case no items were found
* @method noItemsFound * @method noItemsFound
* @param {string} type Type of placeholder to create * @param {object} content_dict Type of placeholder to create
* @return {object} HTML fragment * @return {object} HTML fragment
*/ */
// TODO: don't get global popup like this!!!!!! app.noItemsFound = function (content_dict) {
// TODO: make this element fit to whoever calls (tr, li, div...) var i, reply, content, message, message_i18n;
app.noItemsFound = function (type) {
var reply, content, message, message_i18n;
// TODO: find less content-heavy way! // provided in gadget config
switch (type) { if (content_dict) {
case "auth": message = content_dict.text;
message = "Requires authorization."; message_i18n = content_dict.text_i18n;
message_i18n = "validation_dict.requires_auth"; content = content_dict.children;
content = {
"generate": "widget", // fallback
"type": "controlgroup", } else {
"property_dict": {"direction": "horizontal"},
"children": [{
"type": "a",
"direct":{"className":"translate action", "href":"#global-popup"},
"attributes":{
"data-i18n":"global_dict.common_dict.login",
"data-action":"login",
"data-icon":"lock",
"data-rel": "popup"
},
"logic": {"text":"Login"}
}, {
"type": "a",
"direct": {"className":"translate", "href": "#person::new"},
"attributes": {
"data-i18n": "global_dict.common_dict.register",
"data-icon": "edit"
},
"logic": {"text":"Register"}
}
]
};
break;
default:
message = "No items found."; message = "No items found.";
message_i18n = "validation_dict.no_items_found"; message_i18n = "validation_dict.no_items_found";
content = { content = [{
"type": "a", "type": "a",
"direct": { "direct": {
"href":"#", "href":"#",
...@@ -4224,9 +4222,8 @@ ...@@ -4224,9 +4222,8 @@
"data-i18n":"global_dict.pagination_dict.back" "data-i18n":"global_dict.pagination_dict.back"
}, },
"logic": {"Text": "Back"} "logic": {"Text": "Back"}
}]
} }
break;
};
// <p> is not flexible... // <p> is not flexible...
reply = factory.element( reply = factory.element(
...@@ -4240,8 +4237,10 @@ ...@@ -4240,8 +4237,10 @@
{"data-i18n": message_i18n}, {"data-i18n": message_i18n},
{"text": message} {"text": message}
)); ));
reply.appendChild(app.setContent(content));
for (i = 0; i < content.length; i += 1) {
reply.appendChild(app.setContent(content[i]));
}
return reply; return reply;
}; };
...@@ -4268,7 +4267,8 @@ ...@@ -4268,7 +4267,8 @@
"issued": stamp, "issued": stamp,
"expires": auth ? auth.expires_in : 3600 "expires": auth ? auth.expires_in : 3600
} }
console.log("so...")
console.log(flux)
// need to update the .... button // need to update the .... button
// TODO: make a login gadget, store dependend buttons in state // TODO: make a login gadget, store dependend buttons in state
links = util.getHeader().getElementsByTagName("A"); links = util.getHeader().getElementsByTagName("A");
...@@ -4672,11 +4672,9 @@ ...@@ -4672,11 +4672,9 @@
* @param {string} url Url to go to * @param {string} url Url to go to
* @return {object} pointer object * @return {object} pointer object
*/ */
// TODO: renderJS should parse a link
app.generateLinkObject = function (url) { app.generateLinkObject = function (url) {
var i, query, parameter, path, clean_hash, config; var i, query, parameter, path, clean_hash, config;
parameter = 0;
path = $.mobile.path.parseUrl(url.replace($.mobile.dialogHashKey, "")), path = $.mobile.path.parseUrl(url.replace($.mobile.dialogHashKey, "")),
clean_hash = path.hash.replace("#", ""), clean_hash = path.hash.replace("#", ""),
config = { config = {
...@@ -4695,20 +4693,19 @@ ...@@ -4695,20 +4693,19 @@
for (i = 0; i < query.length; i += 1) { for (i = 0; i < query.length; i += 1) {
switch(query[i]) { switch(query[i]) {
case "new": case "new":
// person::new = create a new entry for person
// NOTE: this will allow loading of field definitions in auth!
config.mode = "new"; config.mode = "new";
parameter = 1;
break; break;
}; };
} }
config.fragment_list = clean_hash.split("::"); config.fragment_list = clean_hash.split("::");
config.id = clean_hash; config.id = clean_hash;
config.layout_level = config.fragment_list.length - 1 - parameter; config.layout_level = config.fragment_list.length - 1;
config.deeplink = true; config.deeplink = true;
config.layout_identifier = clean_hash.split("::")[0]; config.layout_identifier = clean_hash.split("::")[0];
} }
console.log("parsed link")
console.log(config)
return config; return config;
}; };
...@@ -4976,8 +4973,14 @@ ...@@ -4976,8 +4973,14 @@
pass = reply.pass; pass = reply.pass;
constructor = map.gadgets[pass.constructor]; constructor = map.gadgets[pass.constructor];
// TODO: this always sets "new" urls to an empty result. Good? // set answer depending on mode=new and auth
request_new = pass.mode === "new" ? {"request_new": true} : null; if (pass.mode === "new") {
if (pass.auth && pass.active_login === false) {
request_new = null;
} else {
request_new = {"request_new": true}
}
}
if (constructor === undefined) { if (constructor === undefined) {
util.error( util.error(
...@@ -5571,7 +5574,8 @@ ...@@ -5571,7 +5574,8 @@
} else { } else {
destination = config.layout_identifier; destination = config.layout_identifier;
} }
console.log("RUNNING WITH")
console.log(destination)
return app.fetchConfiguration({ return app.fetchConfiguration({
"storage": app.default_dict.storage_dict.settings, "storage": app.default_dict.storage_dict.settings,
"file": "pages", "file": "pages",
......
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