Commit da171fd4 authored by Sven Franck's avatar Sven Franck

fixed display of status loader, added generic JIO POST

parent 19c141a9
...@@ -3595,6 +3595,8 @@ ...@@ -3595,6 +3595,8 @@
var property, var property,
replace, replace,
i, i,
obj,
value,
form_elements, form_elements,
form_element, form_element,
pass = false, pass = false,
...@@ -3644,20 +3646,39 @@ ...@@ -3644,20 +3646,39 @@
// valid form and no spam // valid form and no spam
if (pass) { if (pass) {
replace = form_to_submit.id.split("_")[0] + "_"; replace = form_to_submit.id.split("_")[0] + "_";
obj = {};
for (property in valid) { for (property in valid) {
if (valid.hasOwnProperty(property)) { if (valid.hasOwnProperty(property)) {
formData.append(property.replace(replace, ""), valid[property]); value = valid[property];
// prepare for storage
// TODO: check for portal-type in field name and skip if missing
if (property !== "undefined") {
obj[property] = value;
}
// prepare for form submit
formData.append(property.replace(replace, ""), value);
} }
} }
// report to ERP5 // create ERP5 event
// TODO: remove once normal access is possible
util.updateStatus("show", "", "global.status_dict.uploading");
util.ajax({ util.ajax({
"url": "https://nexedi.erp5.net/" + "url": "https://nexedi.erp5.net/" +
"ERP5Site_addApplicationSubmissionRequest", "ERP5Site_addApplicationSubmissionRequest",
"type": "POST", "type": "POST",
"data": formData "data": formData
}) })
// .then(function () {
// // TODO: a post should always include all required fields
// // TODO: find a way to set default fields, like timestamp etc
// return app.postDataToStorage({
// "response": [obj],
// "baggage": {"type": config.portal_type_source}
// })
// })
.then(function() { .then(function() {
$.mobile.changePage("#thanks"); $.mobile.changePage("#thanks");
}) })
...@@ -4129,8 +4150,8 @@ ...@@ -4129,8 +4150,8 @@
// ===== SAMPLE DATA ======== // ===== SAMPLE DATA ========
.then(app.testStorageForData) .then(app.testStorageForData)
.then(app.retrieveSampleData) .then(app.retrieveSampleData)
.then(app.storeSampleDataInStorage)
// ===== SAMPLE DATA ======== // ===== SAMPLE DATA ========
.then(app.postDataToStorage)
.then(app.fetchDataTotal) .then(app.fetchDataTotal)
.then(app.fetchDataQuery) .then(app.fetchDataQuery)
.then(app.generateGadgetContent) .then(app.generateGadgetContent)
...@@ -4355,7 +4376,7 @@ ...@@ -4355,7 +4376,7 @@
* @param {object} parcel object containing storage, type and baggage * @param {object} parcel object containing storage, type and baggage
* @return {object} promise object/baggage * @return {object} promise object/baggage
*/ */
app.storeSampleDataInStorage = function (reply) { app.postDataToStorage = function (reply) {
var i, var i,
obj, obj,
key, key,
...@@ -4977,20 +4998,21 @@ ...@@ -4977,20 +4998,21 @@
* @param {string} icon Which icon to display when overriding the loader * @param {string} icon Which icon to display when overriding the loader
*/ */
util.updateStatus = function (show, message, msg_i18n, icon) { util.updateStatus = function (show, message, msg_i18n, icon) {
var text_to_display = i18n ? var text_to_display = i18n && msg_i18n ?
factory.map_actions.translateLookup(msg_i18n) : message; factory.map_actions.translateLookup(msg_i18n) : message;
// hm... jQuery... hm string building
// hm... jQuery... // TODO: better way?
if (app.default_dict.loader) { if (app.default_dict.loader) {
$.mobile.loading( $.mobile.loading(
show ? "show" : "hide", "show",
{ {
"text": "",
"textVisible": true,
"theme": app.default_dict.loader_theme, "theme": app.default_dict.loader_theme,
"text": icon === undefined ? message : "", "html": "<span class='ui-icon-" +
"html": icon === undefined ? "" : (icon ? (icon + " loading_icon") : "loading") + "'> </span>" +
'<span class="ui-icon-' + icon + ' loader_icon> </span>'+ "<h1 class='loader_message'>" + text_to_display + "</h1>"
'<h1 class="loader_message">' + text_to_display + '</h1>'
} }
); );
......
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
"back": "Back", "back": "Back",
"clear": "Delete" "clear": "Delete"
}, },
"status_dict": {
"uploading": "Uploading",
"sync": "Sychronizing"
},
"form_helpers": { "form_helpers": {
"secure_blank": "Please do not fill out this field", "secure_blank": "Please do not fill out this field",
"secure_filled": "Please leave this value unchanged" "secure_filled": "Please leave this value unchanged"
......
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
"back": "后退", "back": "后退",
"clear": "删除" "clear": "删除"
}, },
"status_dict": {
"uploading": "Uploading",
"sync": "Sychronizing"
},
"form_helpers": { "form_helpers": {
"secure_blank": "Please do not fill out this field", "secure_blank": "Please do not fill out this field",
"secure_filled": "Please leave this value unchanged" "secure_filled": "Please leave this value unchanged"
......
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