summaryrefslogtreecommitdiffstats
path: root/web/transaction.js
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2014-04-05 16:18:24 +0300
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2014-04-05 22:33:08 +0300
commit979594ba229c4380fbafac35b78c1c2af8b85f97 (patch)
treea66cb143525c0f187dcfcf68d4f31db5e5b17fab /web/transaction.js
parentfae383faa521c58f93a473c9ecdca894ee607c5a (diff)
downloadaconf-979594ba229c4380fbafac35b78c1c2af8b85f97.tar.bz2
aconf-979594ba229c4380fbafac35b78c1c2af8b85f97.tar.xz
web client: remember new but invalid primitive members on reload
Diffstat (limited to 'web/transaction.js')
-rw-r--r--web/transaction.js25
1 files changed, 18 insertions, 7 deletions
diff --git a/web/transaction.js b/web/transaction.js
index bbfcf8c..7f56a88 100644
--- a/web/transaction.js
+++ b/web/transaction.js
@@ -73,6 +73,22 @@ define(
return _.isArray(data.data) ? name - 1 : name;
}
+ function findSubordinateKeys(objmap, path) {
+ return _.filter(_.keys(objmap), function(p) {
+ return pth.isSubordinate(p, path);
+ });
+ }
+
+ var set = data.meta.type == "set";
+
+ if (type.isCollection(data.meta) && !set) {
+ var level = pth.split(path).length;
+ _.each(findSubordinateKeys(invalid, path), function(p) {
+ var key = index(pth.split(p)[level]);
+ if (!(key in data.data) data.data[key] = null;
+ });
+ }
+
data.get = function(name, valid) {
var p = pth.join(path, name);
if (!valid && p in invalid) return invalid[p][0];
@@ -96,12 +112,8 @@ define(
data.status = function(name) {
var p = name ? pth.join(path, name) : path;
- function scan(objs) {
- return _.size(_.filter(
- _.keys(objs), function(obj) {
- return pth.isSubordinate(obj, p);
- }
- ));
+ function scan(objmap) {
+ return _.size(findSubordinateKeys(objmap, p));
}
if (scan(invalid)) return "invalid";
@@ -153,7 +165,6 @@ define(
function validate() {
var del = newValue == null;
- var set = data.meta.type == "set";
var options;
if (!del)