Commit bd55b755 authored by Bas Lijnse's avatar Bas Lijnse

saving progress...

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/branches/itwc-experiments@2158 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 11013493
......@@ -26,7 +26,7 @@ Ext.define('itwc.component.edit.Document',{
},
getTriggerMarkup: function() {
var me = this,
hasValue = !(this.value == null),
hasValue = isObject(this.value),
inputElCfg = {
id: me.id + '-fileInputEl',
cls: Ext.baseCSSPrefix + 'form-file-input',
......@@ -41,7 +41,7 @@ Ext.define('itwc.component.edit.Document',{
id: me.id + '-triggerEl',
ui: me.ui,
tag: 'div',
cls: ['x-form-trigger ',this.value ? 'x-form-clear-trigger':'x-form-search-trigger',Ext.baseCSSPrefix + 'trigger-index-0'].join(' ')
cls: ['x-form-trigger ',hasValue ? 'x-form-clear-trigger':'x-form-search-trigger',Ext.baseCSSPrefix + 'trigger-index-0'].join(' ')
},
formCfg = {
id: me.id + '-formEl',
......@@ -49,7 +49,6 @@ Ext.define('itwc.component.edit.Document',{
tag: 'form',
cls: 'x-form'
};
triggerCfg.cn = inputElCfg;
formCfg.cn = triggerCfg
return '<td class="x-trigger-cell">' + Ext.DomHelper.markup(formCfg) + '</td>';
......@@ -59,7 +58,6 @@ Ext.define('itwc.component.edit.Document',{
formEl = me.formEl,
fileInputEl = me.getEl().child('file'),
opts;
//When a file is selected, we immediately start uploading it to get its info
//only when the upload is completed we change the value of the field
//console.log("Starting upload of ",this.fileInputEl.dom.value);
......@@ -114,7 +112,6 @@ Ext.define('itwc.component.edit.Document',{
enableUpload: function() {
var me = this,
fileInputEl = me.fileInputEl;
fileInputEl.show();
},
disableUpload: function() {
......@@ -132,7 +129,6 @@ Ext.define('itwc.component.edit.Document',{
var me = this;
if(!(me.value == null)) {
me.setValue(null);
}
}
......
......@@ -4,7 +4,7 @@ Ext.define('itwc.component.edit.String',{
mixins: ['itwc.component.edit.Editable'],
width: 'flex',
minWidth: 400,
minWidth: 200,
initComponent: function() {
this.callParent(arguments);
......
......@@ -21,8 +21,10 @@ where
* The basic data layout groups the controls of a part of a compound datastructure in a fieldset
*/
autoDataLayout :: UIDef -> UIDef
autoDataLayout def
= {UIDef|def & attributes = put TYPE_ATTRIBUTE "partial" def.UIDef.attributes}
autoDataLayout def=:{UIDef|attributes}
# def = autoReduce (decorateControls {UIDef|def & attributes = put TYPE_ATTRIBUTE "partial" def.UIDef.attributes})
//Attributes are discarded so merge with the reduced control
= {UIDef|def & controls = [(c,mergeAttributes a attributes) \\ (c,a) <- def.UIDef.controls]}
/**
* The basic interaction layout simply decorates the prompt and merges it with the editor.
*/
......@@ -73,10 +75,13 @@ autoReduce def=:{UIDef|attributes,controls,actions}
# (buttons,actions) = actionsToButtons actions
# controls = addButtons buttons controls
# (controls,actions) = case controls of
[(UIPanel _ _ _ _,_)] = (controls,actions) //Do nothing if the controls already consist of a single panel
[(c=:(UIContainer _ _ _ _),a)] = case titleAttr of
Nothing = (controls,actions) //If we don't have a title, just leave the container be the single control
(Just title) = ([(setTitle title (toPanel c),a)],actions) //Promote container to panel and set title
[_] | isNothing titleAttr
= (controls,actions)
_
# (menus,actions) = actionsToMenus actions
= (wrapControls attributes menus controls,actions)
......@@ -94,7 +99,7 @@ where
tbar = case menus of [] = Nothing; _ = Just menus
sizeOpts = {defaultSizeOpts & width = Just FlexSize, minWidth = Just WrapMin, height = Just WrapSize}
layoutOpts = {defaultLayoutOpts & padding = Just {top = 5, right = 5, bottom = 0, left = 5}}
layoutOpts = {defaultLayoutOpts & padding = Just {top = 5, right = 5, bottom = 5, left = 5}}
panelOpts = {UIPanelOpts|title = titleAttr,frame = False, tbar
,iconCls = iconClsAttr, baseCls = Nothing, bodyCls = Nothing}
......@@ -105,23 +110,29 @@ fillReduce def = autoReduce (fillOutControls def)
//Add labels and icons to a set of controls if they have any of those attributes set
decorateControls :: UIDef -> UIDef
decorateControls def=:{UIDef|controls} = {UIDef|def & controls = map decorateControl controls}
decorateControl :: (!UIControl,!UIAttributes) -> (!UIControl,!UIAttributes)
decorateControl (control,attributes)
decorateControls def=:{UIDef|controls} = {UIDef|def & controls = mapLst decorateControl controls}
where
mapLst f [] = []
mapLst f [x] = [f True x]
mapLst f [x:xs] = [f False x: mapLst f xs]
decorateControl :: Bool (!UIControl,!UIAttributes) -> (!UIControl,!UIAttributes)
decorateControl last (control,attributes)
# mbLabel = get LABEL_ATTRIBUTE attributes
# mbHint = get HINT_ATTRIBUTE attributes
# mbValid = get VALID_ATTRIBUTE attributes
# mbError = get ERROR_ATTRIBUTE attributes
= case (mbLabel,mbHint,mbValid,mbError) of
(Nothing,Nothing,Nothing,Nothing) //Nothing to do
# control = if last control (setBottomMargin 5 control)
= (control,attributes)
_ //Add decoration
# control = row (labelCtrl mbLabel ++ [control] ++ iconCtrl mbHint mbValid mbError)
# control = if last control (setBottomMargin 5 control)
# attributes = foldr del attributes [LABEL_ATTRIBUTE,HINT_ATTRIBUTE,VALID_ATTRIBUTE,ERROR_ATTRIBUTE]
= (control,attributes)
where
row ctrls = (setBottomMargin 5 o setSize FlexSize WrapSize o setDirection Horizontal) (defaultContainer ctrls)
row ctrls = (setSize FlexSize WrapSize o setDirection Horizontal) (defaultContainer ctrls)
labelCtrl (Just label) = [setWidth (ExactSize 100) (stringDisplay label)]
labelCtrl Nothing = []
......
......@@ -111,7 +111,6 @@ gVisualizeText{|HtmlTag|} _ html = [toString html]
derive gVisualizeText DateTime, Either, (,), (,,), (,,,), Timestamp, Map, EmailAddress, Username, Action, TreeNode, UserConstraint, ManagementMeta, TaskPriority, Tree, ButtonState
mkVSt :: !TaskId *IWorld -> *VSt
mkVSt taskId iworld
= {VSt| currentPath = startDataPath, selectedConsIndex = -1, optional = False, disabled = False, verifyMask = []
......@@ -122,7 +121,7 @@ kmVSt {VSt|iworld} = iworld
//Generic visualizer
generic gVisualizeEditor a | gVisualizeText a, gHeaders a, gGridRows a :: !(Maybe a)!*VSt -> (!VisualizationResult,!*VSt)
import StdDebug
gVisualizeEditor{|UNIT|} _ vst
= (NormalEditor [],vst)
......@@ -141,12 +140,16 @@ where
checkbox c = UIEditCheckbox defaultSizeOpts {UIEditOpts|taskId = toString taskId, editorId = name, value = Just c}
gVisualizeEditor{|FIELD of {gfd_name}|} fx _ _ _ val vst=:{VSt|disabled}
gVisualizeEditor{|FIELD of {gfd_name}|} fx _ _ _ val vst=:{VSt|disabled,layout}
# (vizBody,vst) = fx (fmap fromFIELD val) vst
= case vizBody of
HiddenEditor = (HiddenEditor,vst)
NormalEditor controls = (NormalEditor [(c,addLabel False gfd_name a) \\ (c,a) <- controls], vst)
OptionalEditor controls = (OptionalEditor [(c,addLabel True gfd_name a) \\ (c,a) <- controls], vst)
NormalEditor controls
# def = layout (DataLayout {UIDef|attributes = addLabel False gfd_name newMap, controls = controls, actions = []})
= (NormalEditor def.UIDef.controls,vst)
OptionalEditor controls
# def = layout (DataLayout {UIDef|attributes = addLabel False gfd_name newMap, controls = controls, actions = []})
= (OptionalEditor def.UIDef.controls, vst)
gVisualizeEditor{|OBJECT of {gtd_num_conses,gtd_conses}|} fx _ _ _ val vst=:{currentPath,selectedConsIndex = oldSelectedConsIndex,disabled,verifyMask,taskId}
//For objects we only peek at the verify mask, but don't take it out of the state yet.
......@@ -225,78 +228,91 @@ gVisualizeEditor{|(,)|} fx _ _ _ fy _ _ _ val vst=:{VSt|currentPath,verifyMask}
gVisualizeEditor{|Int|} val vst = visualizeCustom viz vst
where
viz name touched verRes vst=:{VSt|taskId,disabled}
# val = checkMask touched val
| disabled = ([(UIViewString defaultSizeOpts {UIViewOpts|value = fmap toString val},newMap)],vst)
| otherwise = ([(UIEditInt defaultSizeOpts {UIEditOpts|taskId=toString taskId,editorId=name,value=val},addVerAttributes verRes newMap)],vst)
gVisualizeEditor{|Real|} val vst = visualizeCustom viz vst
where
viz name touched verRes vst=:{VSt|taskId,disabled}
# val = checkMask touched val
| disabled = ([(UIViewString defaultSizeOpts {UIViewOpts|value = fmap toString val},newMap)],vst)
| otherwise = ([(UIEditDecimal defaultSizeOpts {UIEditOpts|taskId=toString taskId,editorId=name,value=val},addVerAttributes verRes newMap)],vst)
gVisualizeEditor{|Char|} val vst = visualizeCustom viz vst
where
viz name touched verRes vst=:{VSt|taskId,disabled}
# val = checkMask touched val
| disabled = ([(UIViewString defaultSizeOpts {UIViewOpts|value = fmap toString val},newMap)],vst)
| otherwise = ([(UIEditString defaultSizeOpts {UIEditOpts|taskId=toString taskId,editorId=name,value=fmap toString val},addVerAttributes verRes newMap)],vst)
gVisualizeEditor{|String|} val vst = visualizeCustom viz vst
where
viz name touched verRes vst=:{VSt|taskId,disabled}
# val = checkMask touched val
| disabled = ([(UIViewString defaultSizeOpts {UIViewOpts|value = fmap toString val},newMap)],vst)
| otherwise = ([(UIEditString defaultSizeOpts {UIEditOpts|taskId=toString taskId,editorId=name,value=val},addVerAttributes verRes newMap)],vst)
gVisualizeEditor{|Bool|} val vst = visualizeCustom viz vst
where
viz name touched verRes vst=:{VSt|taskId,disabled}
# val = checkMask touched val
| disabled = ([(UIViewCheckbox defaultSizeOpts {UIViewOpts|value = val},addVerAttributes verRes newMap)],vst)
| otherwise = ([(UIEditCheckbox defaultSizeOpts {UIEditOpts|taskId=toString taskId,editorId=name,value=val},addVerAttributes verRes newMap)],vst)
gVisualizeEditor{|Username|} val vst = visualizeCustom viz vst
where
viz name touched verRes vst=:{VSt|taskId,disabled}
# val = checkMask touched val
| disabled = ([(UIViewString defaultSizeOpts {UIViewOpts|value = fmap (\(Username v) -> v) val},newMap)],vst)
| otherwise = ([(UIEditString defaultSizeOpts {UIEditOpts|taskId=toString taskId,editorId=name,value=fmap (\(Username v) -> v) val},addVerAttributes verRes newMap)],vst)
gVisualizeEditor{|Password|} val vst = visualizeCustom viz vst
where
viz name touched verRes vst=:{VSt|taskId,disabled}
# val = checkMask touched val
| disabled = ([(UIViewString defaultSizeOpts {UIViewOpts|value = Just "********"},newMap)],vst)
| otherwise = ([(UIEditPassword defaultSizeOpts {UIEditOpts|taskId=toString taskId,editorId=name,value= fmap (\(Password v) -> v) val},addVerAttributes verRes newMap)],vst)
gVisualizeEditor{|Note|} val vst = visualizeCustom viz vst
where
viz name touched verRes vst=:{VSt|taskId,disabled}
# val = checkMask touched val
| disabled = ([(UIViewHtml defaultSizeOpts {UIViewOpts|value = fmap (\(Note v) -> Text v) val},newMap)],vst)
| otherwise = ([(UIEditNote defaultSizeOpts {UIEditOpts|taskId=toString taskId,editorId=name,value=fmap (\(Note v) -> v) val},addVerAttributes verRes newMap)],vst)
gVisualizeEditor{|Date|} val vst = visualizeCustom viz vst
where
viz name touched verRes vst=:{VSt|taskId,disabled}
# val = checkMask touched val
| disabled = ([(UIViewString defaultSizeOpts {UIViewOpts|value = fmap toString val},newMap)],vst)
| otherwise = ([(UIEditDate defaultSizeOpts {UIEditOpts|taskId=toString taskId,editorId=name,value=val},addVerAttributes verRes newMap)],vst)
gVisualizeEditor{|Time|} val vst = visualizeCustom viz vst
where
viz name touched verRes vst=:{VSt|taskId,disabled}
# val = checkMask touched val
| disabled = ([(UIViewString defaultSizeOpts {UIViewOpts|value = fmap toString val},newMap)],vst)
| otherwise = ([(UIEditTime defaultSizeOpts {UIEditOpts|taskId=toString taskId,editorId=name,value=val},addVerAttributes verRes newMap)],vst)
gVisualizeEditor{|EUR|} val vst = visualizeCustom viz vst
where
viz name touched verRes vst=:{VSt|taskId,disabled}
# val = checkMask touched val
| disabled = ([(UIViewString defaultSizeOpts {UIViewOpts|value = fmap (\(EUR v) -> toString v) val},newMap)],vst)
| otherwise = ([(UIEditDecimal defaultSizeOpts {UIEditOpts|taskId=toString taskId,editorId=name,value=fmap (\(EUR v) -> toReal v / 100.0) val},addVerAttributes verRes newMap)],vst)
gVisualizeEditor{|USD|} val vst = visualizeCustom viz vst
where
viz name touched verRes vst=:{VSt|taskId,disabled}
# val = checkMask touched val
| disabled = ([(UIViewString defaultSizeOpts {UIViewOpts|value = fmap toString val},newMap)],vst)
| otherwise = ([(UIEditDecimal defaultSizeOpts {UIEditOpts|taskId=toString taskId,editorId=name,value=fmap (\(USD v) -> toReal v / 100.0) val},addVerAttributes verRes newMap)],vst)
gVisualizeEditor{|BoundedInt|} val vst = visualizeCustom viz vst
where
viz name touched verRes vst=:{VSt|taskId,disabled}
# val = checkMask touched val
# sliderOpts = {UISliderOpts|minValue=maybe 1 (\{BoundedInt|min} -> min) val,maxValue=maybe 5 (\{BoundedInt|max} -> max) val}
| disabled
# viewOpts = {UIViewOpts|value = fmap curVal val}
......@@ -328,6 +344,7 @@ where
gVisualizeEditor {|Document|} val vst = visualizeCustom viz vst
where
viz name touched verRes vst=:{VSt|taskId,disabled}
# val = checkMask touched val
| disabled = ([(UIViewDocument defaultSizeOpts {UIViewOpts|value = val},newMap)],vst)
| otherwise = ([(UIEditDocument defaultSizeOpts {UIEditOpts|taskId=toString taskId,editorId=name,value=val},addVerAttributes verRes newMap)],vst)
......
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