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

app: add update_bip method to allow sticky put

parent 0359eb06
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
}, { }, {
"type": "input", "type": "input",
"direct": {"className": "action translate"}, "direct": {"className": "action translate"},
"attributes": {"type": "submit", "data-action":"update", "data-icon":"carat-r", "data-theme": "active", "data-i18n":"[value]portal_type_dict.sales_order_dict.text_dict.proceed"}, "attributes": {"type": "submit", "data-action":"update_bip", "data-icon":"carat-r", "data-theme": "active", "data-i18n":"[value]portal_type_dict.sales_order_dict.text_dict.proceed"},
"logic": {"wrapper_class_list": " ui-last-child "} "logic": {"wrapper_class_list": " ui-last-child "}
}] }]
} }
......
...@@ -1632,7 +1632,8 @@ ...@@ -1632,7 +1632,8 @@
"placeholder": captcha, "placeholder": captcha,
"target": wrap, "target": wrap,
"target_selector": "first", "target_selector": "first",
"reverse": spec.reverse || null "reverse": spec.reverse || null,
"reference": spec.reference
}; };
}; };
...@@ -2588,7 +2589,7 @@ ...@@ -2588,7 +2589,7 @@
"direct": { "direct": {
"id": "select_" + (spec.id || id), "id": "select_" + (spec.id || id),
"name": "select_" + "name": "select_" +
(is_type ? (spec.id || id) : config.id), (is_type ? (spec.id || id) : (spec.id || id || config.id).slice(0, -2)),
"className": spec.action ? "action" : "" "className": spec.action ? "action" : ""
}, },
"attributes": input_dict, "attributes": input_dict,
...@@ -3045,6 +3046,62 @@ ...@@ -3045,6 +3046,62 @@
storage.fetch(obj); storage.fetch(obj);
}, },
/**
* PUT an object
* @method update
* @param {object} obj Action Object
**/
"update_bip": function (obj) {
var identifier, element_list, i, len, value = undefined;
if (obj.form) {
element_list = obj.form.getElementsByTagName("input");
for (i = 0, len = element_list.length; i < len; i += 1) {
if (element_list[i].name === "identifier") {
value = element_list[i].value;
}
}
}
if (value) {
return storage.fetch({
"query": {"_id": value},
"pass": obj.pass || {}
})
.then(function (reply) {
obj.backpack = reply.response.data.rows[0].doc;
})
.then(function () {
return storage.write(obj)
.then(function (response) {
app.util.loader("", "status_dict.saved", "check");
app.navigate(obj, response);
})
.fail(function (error) {
switch (error.status) {
case 408: app.util.loader("", "status_dict.timeout", "clock-o"); break;
case 400: app.util.loader("", "validation_dict.general", "ban"); break;
default: app.util.loader("", "status_dict.error", "ban"); break;
}
});
})
.fail(app.util.error);
} else {
return storage.write(obj)
.then(function (response) {
app.util.loader("", "status_dict.saved", "check");
app.navigate(obj, response);
})
.fail(function (error) {
switch (error.status) {
case 408: app.util.loader("", "status_dict.timeout", "clock-o"); break;
case 400: app.util.loader("", "validation_dict.general", "ban"); break;
default: app.util.loader("", "status_dict.error", "ban"); break;
}
});
}
},
/** /**
* PUT an object * PUT an object
* @method update * @method update
...@@ -4092,6 +4149,8 @@ ...@@ -4092,6 +4149,8 @@
for (m = 0; m < section_response_list.length; m += 1) { for (m = 0; m < section_response_list.length; m += 1) {
helper.children.push(section_response_list[m]); helper.children.push(section_response_list[m]);
} }
// HACK for Thierry
helper.reference = helper.property_dict.reference = spec.wrapper.reference;
return RSVP.resolve(helper); return RSVP.resolve(helper);
}) })
...@@ -4248,6 +4307,11 @@ ...@@ -4248,6 +4307,11 @@
if (valid) { if (valid) {
data = obj.sample_data || storage.parseForm(valid, prefix, true); data = obj.sample_data || storage.parseForm(valid, prefix, true);
// HACK: Thierry
if (obj.backpack) {
data = util.mergeObject(obj.backpack, data);
}
// TODO: remove, used for update scope, doesn't honor form definition // TODO: remove, used for update scope, doesn't honor form definition
if (obj.force_data) { if (obj.force_data) {
config._force_data = true; config._force_data = true;
...@@ -4545,7 +4609,7 @@ ...@@ -4545,7 +4609,7 @@
break; break;
default: default:
if (plain) { if (plain) {
container[property.replace(clean, "")] = value; container[property.replace(clean, "").replace("select_", "")] = value;
} else { } else {
container.append(property.replace(clean, ""), value); container.append(property.replace(clean, ""), value);
} }
...@@ -6735,6 +6799,11 @@ ...@@ -6735,6 +6799,11 @@
} }
} }
// HACK for Thierry to pass reference into custom fields
if (wrapper.reference) {
kid.reference = wrapper.reference;
}
// set classes // set classes
if (is_html) { if (is_html) {
kid.direct.className = (kid.direct.className || "") + kid.direct.className = (kid.direct.className || "") +
......
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