Commit 32a5a0fd authored by Sven Franck's avatar Sven Franck

added status messages indicating loading of records/config

parent e468c03e
......@@ -5034,6 +5034,7 @@
"_jump": pointer
};
}
return RSVP.resolve(
app.storage_dict.items[method || "allDocs"](query, config)
).then(function (response) {
......@@ -5055,6 +5056,8 @@
* @method write
* @param {object} obj Action object
*/
// TODO: storage.add included prefetch of field_items and validation
// TODO: storage.add deleted identifier if create_new was set
storage.write = function (obj) {
var form, data, valid, prefix, config, method, action, pointer, id;
......@@ -5359,105 +5362,6 @@
}
};
/**
* add a new item to a storage
* @method add
* @param {object} config Action Object
*/
// NOTE: we always validate! to skip validation test for class on form
// TODO: generate common promise handler for add/remove/clone/export/etc
// TODO: make form validation and captcha generic
storage.add = function (config) {
var property, replace, obj, value, form_to_submit,
valid, pass_id, validate_portal_type_fields, decode, data;
form_to_submit = document.getElementById(config.id);
valid = storage.validate(config);
if (valid === undefined) {
util.loader("", "validation_dict.general", "ban-circle");
// form is valid and not "spam"
} else {
replace = form_to_submit.id + "_";
obj = {};
// force portal_type
if (config.gadget.state.force_type) {
config.gadget.state.type = config.gadget.state.force_type;
validate_portal_type_fields = true;
}
// force formData
if (config.gadget.state.force_formdata) {
data = storage.parseForm(valid, replace);
} else {
for (property in valid) {
if (valid.hasOwnProperty(property)) {
value = valid[property];
// prepare to store
if (property !== "undefined") {
obj[property.replace(replace, "")] = value;
}
}
}
}
// force new
if (config.gadget.state.create_new) {
delete obj.identifier;
}
util.loader("", "status_dict.saving");
// TODO: a post should always include all required fields
// TODO: find a way to set default fields, like timestamp etc
app.store({
"response": [obj],
"pass": {
"type": config.gadget.state.type,
"reply": true,
"validate_type": validate_portal_type_fields,
// hacked view
"view": config.gadget.state.view,
"form_data": data || undefined,
"fetch": config.gadget.state.url_pointer
}
})
.then(function (answer) {
if (answer.response && answer.response.result === "success") {
pass_id = answer.response.id;
switch (config.gadget.getAttribute("data-reset")) {
case "login_state":
app.setLoginStatus(answer.response, config.portal_type_source);
break;
}
util.loader("", "status_dict.saved", "check");
return pass_id;
}
// install new instance
if (answer.response && answer.response.location) {
return jIO.util.ajax({
"url": answer.response.location,
"xhrFields": {
"withCredentials": true
}
})
.then(function (instance_location) {
return util.parse(instance_location.target.responseText)._relative_url;
}).fail(util.error);
}
})
.then(function (id) {
decode = /^[^\/]*%2[^\/]*$/.test(id);
if (id && config.state.callback) {
$.mobile.changePage(config.state.callback.replace("__id__", decode ? id : window.encodeURIComponent(id)));
}
})
.fail(util.error);
}
};
/* ====================================================================== */
/* FLUX */
/* ====================================================================== */
......@@ -6703,6 +6607,7 @@
// get an item?
if (pass.mode !== "new" || pass.config.initial_query !== undefined) {
util.loader("", "status_dict.loading_set");
return storage.fetch({
"storage": "items",
"query": pass.state.query,
......@@ -6786,6 +6691,7 @@
// store the complete initial query, not only the "query"
pass.state.initial_query = pass.config.initial_query;
util.loader("", "status_dict.loading_set");
return storage.fetch({
"pass": pass,
"storage": "items",
......@@ -7014,6 +6920,7 @@
// TODO: keep this until sample handling is removed
pass.needs_fields = true;
util.loader("", "status_dict.loading_config");
return app.fetchConfig({
"storage": app.storage_dict.settings,
"file": app.storage_dict.property_dict.name_dict.data_type,
......
......@@ -58,6 +58,8 @@
"find_out_more_details": "For additional information, please refer to the following sections:"
},
"status_dict": {
"loading_set": "Loading Records",
"loading_config": "Loading Configuration",
"requesting": "Requesting",
"timeout": "Request Timeout. Try again.",
"ssl_error": "Please revoke existing certificate first",
......
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