Commit 755a962a authored by Sven Franck's avatar Sven Franck

app: fix handling of sample data into storage.write

parent ca3b5d5a
...@@ -4011,18 +4011,18 @@ ...@@ -4011,18 +4011,18 @@
action = (obj.state.url_pointer || storage.obj)[pointer]; action = (obj.state.url_pointer || storage.obj)[pointer];
config = {}; config = {};
prefix = obj.id + "_"; prefix = obj.id + "_";
valid = storage.validate(form); valid = obj.sample_store || storage.validate(form);
if (valid) { if (valid) {
data = storage.parseForm(valid, prefix, true); data = obj.sample_data || storage.parseForm(valid, prefix, true);
// TODO: remove, used for update scope, which does not honor form definition // TODO: remove, used for update scope, which does not honor form definition
if (obj.force_data) { if (obj.force_data) {
config._force_data = true; config._force_data = true;
} }
if (form.identifier) { if (obj.sample_data._id || form.identifier) {
// PUT > set id, method and view // PUT > set id, method and view
data._id = form.identifier.value; data._id = obj.sample_data._id || form.identifier.value;
method = "put"; method = "put";
config._view = obj.state.view; config._view = obj.state.view;
} }
...@@ -5879,7 +5879,7 @@ ...@@ -5879,7 +5879,7 @@
if (reply.response) { if (reply.response) {
if (util.parse(reply.response).data.total_rows === 0) { if (util.parse(reply.response).data.total_rows === 0) {
return util.ajax( return util.ajax(
{"url": "data/" + pass.config.portal_type_title + "_sample.json"} {"url": "data/" + pass.config_dict.portal_type_title + "_sample.json"}
) )
// STORE SAMPLE DATA HERE! // STORE SAMPLE DATA HERE!
.then(function (e) { .then(function (e) {
...@@ -5895,16 +5895,21 @@ ...@@ -5895,16 +5895,21 @@
// NOTE: do we still validate against field_dict? // NOTE: do we still validate against field_dict?
for (i = 0; i < len; i += 1) { for (i = 0; i < len; i += 1) {
record = response[i]; record = response[i];
record.portal_type = pass.config_dict.initial_query; record.portal_type = pass.config_dict.portal_type_source;
promise_list[i] = storage.write(record);
promise_list[i] = storage.write({
"sample_data": record,
"sample_store": true,
"state": {}
});
} }
return RSVP.all(promise_list) return RSVP.all(promise_list)
.then(function(response_list) { .then(function(response_list) {
if (!response_list[0]) { if (!response_list[0]) {
util.loader("", "status_dict.internal_error", "ban-circle"); app.util.loader("", "status_dict.internal_error", "ban-circle");
} else { } else {
util.loader("", "status_dict.success", "check"); app.util.loader("", "status_dict.success", "check");
} }
// just return pass and continue // just return pass and continue
return { return {
......
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