summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2013-11-14 10:26:36 +0200
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2013-11-14 14:58:29 +0200
commit0f85950e95f983981a4b706b400a719c1e5af9e8 (patch)
tree70977d364c5d69ab4aecad770083885fefb90613 /web
parentc30abf88ad4c816236f65ca1da26d7a2ae10482b (diff)
downloadaconf-0f85950e95f983981a4b706b400a719c1e5af9e8.tar.bz2
aconf-0f85950e95f983981a4b706b400a719c1e5af9e8.tar.xz
web client: handle conditional read-only fields correctly
Diffstat (limited to 'web')
-rw-r--r--web/client.js16
1 files changed, 11 insertions, 5 deletions
diff --git a/web/client.js b/web/client.js
index 2ae17ec..f12c2e8 100644
--- a/web/client.js
+++ b/web/client.js
@@ -489,9 +489,11 @@ $(function() {
data, name, meta, level, editable, removable
);
- if (editable && meta.editable) {
- this.data = data;
- this.name = name;
+ this.data = data;
+ this.name = name;
+ this.editable = editable && meta.editable;
+
+ if (this.editable) {
this.onChange(this.validate);
if (data.status(name) == "invalid") this.validate();
}
@@ -523,7 +525,7 @@ $(function() {
};
Field.onChange = function(cb) {
- this.field.change(_.bind(cb, this));
+ if (this.editable) this.field.change(_.bind(cb, this));
}
Field.validate = function() {
@@ -555,7 +557,11 @@ $(function() {
});
};
- Field.get = function() { return this.field.val() || null; };
+ Field.get = function() {
+ return this.editable ? (
+ this.field.val() || null
+ ) : this.data.get(this.name);
+ };
var ComboBox = Object.create(Field);