Commit 55382fe3 authored by Bas Lijnse's avatar Bas Lijnse

More UI optimizations

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@2369 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 859b0922
......@@ -18,5 +18,11 @@ Ext.define('itwc.component.action.ActionButton',{
} else {
this.disable();
}
},
setTaskId: function(taskId) {
this.taskId = taskId;
},
setActionId: function(actionId) {
this.actionId = actionId;
}
});
......@@ -12,5 +12,11 @@ Ext.define('itwc.component.action.ActionMenuItem',{
this.viewport = this.findViewport();
this.viewport.fireEvent('action',this.taskId, this.actionId);
return this.callParent(arguments);
},
setTaskId: function(taskId) {
this.taskId = taskId;
},
setActionId: function(actionId) {
this.actionId = actionId;
}
});
......@@ -31,5 +31,21 @@ Ext.define('itwc.component.misc.Tab',{
} else {
me.viewport.fireEvent('focus',this.focusTaskId);
}
},
//Update operations
setFocusTaskId: function (focusTaskId) {
this.focusTaskId = focusTaskId;
},
setCloseTaskId: function (closeTaskId) {
this.closeTaskId = closeTaskId;
this.setClosable(Ext.isString(closeTaskId));
},
setActive: function (active) {
if(active) {
this.activate();
} else {
this.deactivate();
}
this.callParent(arguments);
}
});
......@@ -215,8 +215,6 @@ defToControl :: UIDef -> UIControl
defToControl def
| isJust (get TITLE_ATTRIBUTE (uiDefAttributes def))//If a title attribute is set, always make a panel
= defToPanel def
| not (isEmpty (uiDefWindows def)) //If there are windows, always make a panel
= defToPanel def
| otherwise
= case uiDefControls def of
[c=:(UIContainer _ _ _)] = c //Already a container, no need to double wrap
......
......@@ -9,7 +9,10 @@ from Task import :: Event
= UISetValue !JSONNode // Set the value of a component
| UISetOptions !JSONNode // Change the options in a choice component
| UISetTaskId !String // Set taskId a component belongs to
| UISetEditorId !String // Set taskId a component belongs to
| UISetCloseTaskId !(Maybe String)
| UISetFocusTaskId !(Maybe String)
| UISetEditorId !String // Set editorId a component belongs to
| UISetActionId !String // Set actionId a component belongs to
| UISetName !String // Set name of a component
| UISetEnabled !Bool // Enable/disable form elements
| UISetActive !Bool // Make a tab active/inactive
......
......@@ -83,7 +83,7 @@ diffControls path event c1 c2
(UIIcon sOpts1 opts1, UIIcon sOpts2 opts2)
= [diffSizeOpts path sOpts1 sOpts2,diffIconOpts path opts1 opts2]
(UITab sOpts1 opts1, UITab sOpts2 opts2)
= [diffSizeOpts path sOpts1 sOpts2,diffOpts opts1 opts2]
= [diffSizeOpts path sOpts1 sOpts2,diffTabOpts path opts1 opts2]
// Tasklet on the right hand side:
// check their instance id. Different: replace, Equals: update (mostly taskId)
(UITasklet sOpts1 opts1, UITasklet sOpts2 opts2)
......@@ -162,7 +162,10 @@ where
optionDiff = if (opts1.UIChoiceOpts.options === opts2.UIChoiceOpts.options) [] [UIUpdate path (UISetOptions (toJSON opts2.UIChoiceOpts.options))]
diffActionOpts :: UIPath UIActionOpts UIActionOpts -> DiffResult
diffActionOpts path opts1 opts2 = diffOpts opts1 opts2
diffActionOpts path opts1 opts2 = DiffPossible (flatten [taskIdUpd,actionIdUpd])
where
taskIdUpd = if (opts1.UIActionOpts.taskId == opts2.UIActionOpts.taskId) [] [UIUpdate path (UISetTaskId opts2.UIActionOpts.taskId)]
actionIdUpd = if (opts1.UIActionOpts.actionId == opts2.UIActionOpts.actionId) [] [UIUpdate path (UISetActionId opts2.UIActionOpts.actionId)]
diffItemsOpts :: UIPath !Event UIItemsOpts UIItemsOpts -> DiffResult
diffItemsOpts path event opts1 opts2
......@@ -214,6 +217,15 @@ where
iconUpd = if (i1.UIIconOpts.iconCls === i2.UIIconOpts.iconCls) [] [UIUpdate path (UISetIconCls (Just i2.UIIconOpts.iconCls))]
tooltipUpd = if (i1.UIIconOpts.tooltip === i2.UIIconOpts.tooltip) [] [UIUpdate path (UISetTooltip i2.UIIconOpts.tooltip)]
diffTabOpts :: UIPath UITabOpts UITabOpts -> DiffResult
diffTabOpts path t1 t2 = DiffPossible (flatten [textUpd,activeUpd,focusUpd,closeUpd,iconUpd])
where
textUpd = if (t1.UITabOpts.text === t2.UITabOpts.text) [] [UIUpdate path (UISetText (Just t2.UITabOpts.text))]
activeUpd = if (t1.UITabOpts.active == t2.UITabOpts.active) [] [UIUpdate path (UISetActive t2.UITabOpts.active)]
focusUpd = if (t1.UITabOpts.focusTaskId === t2.UITabOpts.focusTaskId) [] [UIUpdate path (UISetFocusTaskId t2.UITabOpts.focusTaskId)]
closeUpd = if (t1.UITabOpts.closeTaskId === t2.UITabOpts.closeTaskId) [] [UIUpdate path (UISetCloseTaskId t2.UITabOpts.closeTaskId)]
iconUpd = if (t1.UITabOpts.iconCls === t2.UITabOpts.iconCls) [] [UIUpdate path (UISetIconCls t2.UITabOpts.iconCls)]
diffItems :: UIPath Event [UIControl] [UIControl] -> [UIUpdate]
diffItems path event items1 items2 = diff path event 0 items1 items2
where
......@@ -277,7 +289,11 @@ where
encodeUIUpdateOperation :: UIUpdateOperation -> (!String,![JSONNode])
encodeUIUpdateOperation (UISetValue value) = ("setValue", [value])
encodeUIUpdateOperation (UISetOptions value) = ("setOptions", [value])
encodeUIUpdateOperation (UISetTaskId taskId) = ("setTaskId", [JSONString taskId])
encodeUIUpdateOperation (UISetTaskId id) = ("setTaskId", [JSONString id])
encodeUIUpdateOperation (UISetCloseTaskId id) = ("setCloseTaskId",[toJSON id])
encodeUIUpdateOperation (UISetFocusTaskId id) = ("setFocusTaskId",[toJSON id])
encodeUIUpdateOperation (UISetEditorId id) = ("setEditorId", [JSONString id])
encodeUIUpdateOperation (UISetActionId id) = ("setActionId", [JSONString id])
encodeUIUpdateOperation (UISetName name) = ("setName", [JSONString name])
encodeUIUpdateOperation (UISetEnabled enabled) = ("setDisabled", [JSONBool (not enabled)])
encodeUIUpdateOperation (UISetActive active) = ("setActive", [JSONBool active])
......
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