Commit e8435beb authored by Mart Lubbers's avatar Mart Lubbers

Fix #163, allow disabled on all the input forms

parent b79c27bb
...@@ -5,6 +5,11 @@ import StdFunc, StdBool, GenEq ...@@ -5,6 +5,11 @@ import StdFunc, StdBool, GenEq
import Data.Error, Text.JSON, Text.HTML import Data.Error, Text.JSON, Text.HTML
import qualified Data.Map as DM import qualified Data.Map as DM
import iTasks.UI.Definition
import iTasks.UI.Editor.Modifiers
disableOnView e = selectByMode (withAttributes (enabledAttr False) e) e e
textField :: Editor String textField :: Editor String
textField = fieldComponent toJSON UITextField textField = fieldComponent toJSON UITextField
...@@ -85,7 +90,7 @@ where ...@@ -85,7 +90,7 @@ where
| otherwise = or (map (checkNode idx) children) | otherwise = or (map (checkNode idx) children)
//Field like components for which simply knowing the UI type is sufficient //Field like components for which simply knowing the UI type is sufficient
fieldComponent toValue type = {Editor|genUI=genUI,onEdit=onEdit,onRefresh=onRefresh} fieldComponent toValue type = disableOnView {Editor|genUI=genUI,onEdit=onEdit,onRefresh=onRefresh}
where where
genUI dp val vst=:{VSt|taskId,mode,optional} genUI dp val vst=:{VSt|taskId,mode,optional}
# val = if (mode =: Enter) JSONNull (toValue val) # val = if (mode =: Enter) JSONNull (toValue val)
......
...@@ -5,10 +5,14 @@ itasks.TextField = { ...@@ -5,10 +5,14 @@ itasks.TextField = {
el = this.domEl; el = this.domEl;
el.type = 'text'; el.type = 'text';
el.value = me.attributes.value ? me.attributes.value : ''; el.value = me.attributes.value ? me.attributes.value : '';
if('enabled' in me.attributes && me.attributes['enabled'] === false) {
el.disabled = true;
} else {
el.addEventListener('keyup',function(e) { el.addEventListener('keyup',function(e) {
var value = e.target.value === "" ? null : e.target.value var value = e.target.value === "" ? null : e.target.value
me.doEditEvent(me.attributes.taskId,me.attributes.editorId,value); me.doEditEvent(me.attributes.taskId,me.attributes.editorId,value);
}); });
}
}, },
onAttributeChange: function(name,value) { onAttributeChange: function(name,value) {
var me = this; var me = this;
...@@ -25,16 +29,20 @@ itasks.TextArea = { ...@@ -25,16 +29,20 @@ itasks.TextArea = {
height: 'flex', height: 'flex',
width: 'flex', width: 'flex',
minHeight: 150, minHeight: 150,
minWidth: 400 minWidth: 400,
}, },
initDOMEl: function() { initDOMEl: function() {
var me = this, var me = this,
el = this.domEl; el = this.domEl;
el.innerHTML = me.attributes.value ? me.attributes.value : ''; el.innerHTML = me.attributes.value ? me.attributes.value : '';
if('enabled' in me.attributes && me.attributes['enabled'] === false) {
el.disabled = true;
} else {
el.addEventListener('keyup',function(e) { el.addEventListener('keyup',function(e) {
var value = e.target.value === "" ? null : e.target.value var value = e.target.value === "" ? null : e.target.value
me.doEditEvent(me.attributes.taskId,me.attributes.editorId,value); me.doEditEvent(me.attributes.taskId,me.attributes.editorId,value);
}); });
}
}, },
onAttributeChange: function(name,value) { onAttributeChange: function(name,value) {
var me = this; var me = this;
...@@ -52,11 +60,15 @@ itasks.PasswordField = { ...@@ -52,11 +60,15 @@ itasks.PasswordField = {
el = this.domEl; el = this.domEl;
el.type = 'password'; el.type = 'password';
el.value = me.attributes.value ? me.attributes.value : ''; el.value = me.attributes.value ? me.attributes.value : '';
if('enabled' in me.attributes && me.attributes['enabled'] === false) {
el.disabled = true;
} else {
el.addEventListener('keyup',function(e) { el.addEventListener('keyup',function(e) {
var value = e.target.value === "" ? null : e.target.value var value = e.target.value === "" ? null : e.target.value
me.doEditEvent(me.attributes.taskId,me.attributes.editorId,value); me.doEditEvent(me.attributes.taskId,me.attributes.editorId,value);
}); });
} }
}
,onAttributeChange: function(name,value) { ,onAttributeChange: function(name,value) {
var me = this; var me = this;
if(name == 'value') { if(name == 'value') {
...@@ -271,9 +283,13 @@ itasks.Slider = { ...@@ -271,9 +283,13 @@ itasks.Slider = {
el.max = me.attributes.max; el.max = me.attributes.max;
el.value = me.attributes.value; el.value = me.attributes.value;
if('enabled' in me.attributes && me.attributes['enabled'] === false) {
el.disabled = true;
} else {
el.addEventListener('change',function(e) { el.addEventListener('change',function(e) {
me.doEditEvent(me.attributes.taskId,me.attributes.editorId, (e.target.value | 0),true); me.doEditEvent(me.attributes.taskId,me.attributes.editorId, (e.target.value | 0),true);
}); });
}
}, },
onAttributeChange: function(name,value) { onAttributeChange: function(name,value) {
var me = this; var me = this;
......
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