Commit 6855620c authored by ecrombag's avatar ecrombag

- Removed Static type

- Reimplemented Hidden type
- Added DisplayHtml type to replace Static
- Added Editable type to allow for interactive components within DisplayHtml types

First version, still a bit buggy probably.

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@968 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 16f4a123
......@@ -22,6 +22,7 @@
,{"text":"StringControl.js","path":"src/js/tui/"}
,{"text":"TimeControl.js","path":"src/js/tui/"}
,{"text":"UsernameControl.js","path":"src/js/tui/"}
,{"text":"DisplayControl.js","path":"src/js/tui/"}
,{"text":"ListContainer.js","path":"src/js/tui/"}
,{"text":"RecordContainer.js","path":"src/js/tui/"}
,{"text":"TupleContainer.js","path":"src/js/tui/"}
......
......@@ -6,6 +6,7 @@ itasks.ttc.FormContainer = Ext.extend(Ext.Panel, {
this.buildComponents(this);
this.tbar = this.content.tbar;
this.replaceItems = [];
delete this.content;
......@@ -82,7 +83,7 @@ itasks.ttc.FormContainer = Ext.extend(Ext.Panel, {
else
return find(cmt,cnt,ind + 1);
}
var index = find(ct, ct.ownerCt, 0) + 1;
var newct = ct.ownerCt.insert(index, update[2]);
......@@ -130,6 +131,7 @@ itasks.ttc.FormContainer = Ext.extend(Ext.Panel, {
//this.attachTaskHandlers(newct);
itasks.ttc.common.attachTaskHandlers(newct);
}
break;
case "TUISetEnabled":
var ct = Ext.getCmp(update[1]);
......@@ -208,7 +210,8 @@ itasks.ttc.FormContainer = Ext.extend(Ext.Panel, {
tb.removeClass(cls);
tb.addClass(cls);
}
}
},
});
Ext.ns('itasks.ttc.form');
......@@ -227,6 +230,7 @@ itasks.ttc.form.FormDescription = Ext.extend(Ext.Panel,{
itasks.ttc.form.FormPanel = Ext.extend(Ext.Panel, {
initComponent : function(){
Ext.apply(this,
{ layout: 'fit'
, unstyled: true
......@@ -235,7 +239,6 @@ itasks.ttc.form.FormPanel = Ext.extend(Ext.Panel, {
itasks.ttc.form.FormPanel.superclass.initComponent.apply(this,arguments);
}
});
Ext.reg('itasks.ttc.form',itasks.ttc.FormContainer);
......
Ext.ns('itasks.tui');
itasks.tui.DisplayControl = Ext.extend(Ext.Panel,{
width: '100%',
fieldClass: 'x-form-field',
autoScroll: true,
initComponent: function(){
this.hideLabel = this.fieldLabel == null;
this.fieldLabel = itasks.util.fieldLabel(this.optional,this.fieldLabel);
this.unstyled = true;
this.layout = 'form';
this.panel = {
xtype: 'panel',
html: this.html,
unstyled: true
}
delete this.html;
Ext.apply(this,
{ items: [this.panel]
});
for(var i=0; i< this.formItems.length; i++){
this.formItems[i][1][0].hidden = true;
this.items[this.items.length] = this.formItems[i][1][0];
}
itasks.tui.DisplayControl.superclass.initComponent.apply(this,arguments);
},
afterRender: function(){
itasks.tui.DisplayControl.superclass.afterRender.call(this,arguments);
(this.moveActiveItems).defer(50,this);
},
moveActiveItems: function(){
for(var i=0; i< this.formItems.length; i++){
var fitem = this.formItems[i];
var phid = fitem[0];
var elid = fitem[1][0].id;
var ph = Ext.get(phid);
var cmp = Ext.getCmp(elid);
var el = cmp.getEl();
el.replace(ph);
cmp.show();
this.doLayout();
}
this.doLayout();
this.findParentByType(itasks.ttc.FormContainer).doLayout();
}
});
Ext.reg('itasks.tui.Display',itasks.tui.DisplayControl);
/*
placeDelayedItems : function(){
for(var i=0; i < this.replaceItems.length; i++){
var phid = this.replaceItems[i].applyToPHid;
delete this.replaceItems[i].applyToPHid;
var el = Ext.get(this.replaceItems[i].id);
var phEl = Ext.get(phid);
el.replace(phEl);
el.removeClass('x-hidden');
}
},
splitItems: function(data,ct){
this.replaceItems = [];
if(data instanceof Array){
for(var i=0; i<data.length;i++){
if(data[i].applyToPHid != null){
data[i].cls = (data[i].cls || '')+' x-hidden';
ct.replaceItems[ct.replaceItems.length] = data[i];
}else if(data[i].items){
ct.splitItems(data[i].items,ct);
}
}
}else {
if(data.applyToPHid != null){
data.cls = (data.cls || '')+' x-hidden';
ct.replaceItems[ct.replaceItems.length] = data;
}
if(data.items != null){
ct.splitItems(data.items,ct);
}
}
}
*/
\ No newline at end of file
......@@ -60,6 +60,7 @@
<script type="text/javascript" src="../js/tui/StringControl.js"></script>
<script type="text/javascript" src="../js/tui/TimeControl.js"></script>
<script type="text/javascript" src="../js/tui/UsernameControl.js"></script>
<script type="text/javascript" src="../js/tui/DisplayControl.js"></script>
<script type="text/javascript" src="../js/tui/ListContainer.js"></script>
<script type="text/javascript" src="../js/tui/RecordContainer.js"></script>
......
......@@ -70,7 +70,7 @@ where
convert (Labeled (s, b)) = convert b >>= \nb -> returnLabel s nb
where
returnLabel s (DV0 v :: DV0 a)
= return (dynamic DV0 (Static s,v) :: DV0 (Static String,a))
= return (dynamic DV0 (HtmlDisplay s,v) :: DV0 (HtmlDisplay String,a))
convert Notes = getDefaultValue >>= \v -> return (dynamic DV0 v :: DV0 Note)
convert Date = getDefaultValue >>= \v -> return (dynamic DV0 v :: DV0 Date)
convert Time = getDefaultValue >>= \v -> return (dynamic DV0 v :: DV0 Time)
......
......@@ -99,12 +99,12 @@ where
appointEditor idx = editor {editorFrom = editorFrom idx, editorTo = editorTo idx}
editorFrom :: Int MeetingDB -> (Static (Meeting,[(Maybe Attending,UserName)]),(Static String,(Maybe Attending)))
editorFrom :: Int MeetingDB -> (HtmlDisplay (Meeting,[(Maybe Attending,UserName)]),(HtmlDisplay String,(Maybe Attending)))
editorFrom idx (goal, dates)
# (date,attlist) = dates !! idx
= let (att,user) = attlist !! uid in (Static (date,attlist),(Static(user +++> " can you attend?"),att))
= let (att,user) = attlist !! uid in (HtmlDisplay (date,attlist),(HtmlDisplay(user +++> " can you attend?"),att))
editorTo :: Int (Static (Meeting,[(Maybe Attending,UserName)]),(Static String,(Maybe Attending))) MeetingDB -> MeetingDB
editorTo :: Int (HtmlDisplay (Meeting,[(Maybe Attending,UserName)]),(HtmlDisplay String,(Maybe Attending))) MeetingDB -> MeetingDB
editorTo idx (info,(question,att)) (goal, dates)
= let (meeting,attlist) = dates !! idx
in (goal,updateAt idx (meeting, let (_,user) = attlist !! uid
......
......@@ -35,8 +35,6 @@ where
getCurrentProcessId` tst=:{staticInfo}
= (TaskFinished staticInfo.currentProcessId,tst)
import StdDebug
getContextWorker :: Task UserName
getContextWorker = mkInstantTask "getContextWorker" getContextWorker`
where
......
......@@ -92,7 +92,7 @@ gVisualize{|Currency|} old new vst=:{vizType,label,idPrefix,currentPath,useLabel
VEditorUpdate
| oldV <> newV = ([TUIUpdate (TUISetValue id newV)]
, 1
, {VSt|vst & currentPath = stepDataPath currentPath, valid= stillValid currentPath new optional valid})
, {VSt|vst & currentPath = stepDataPath currentPath, valid = stillValid currentPath new optional valid})
_ = ([TextFragment (toString old)], 1, {VSt|vst & currentPath = stepDataPath currentPath, valid = stillValid currentPath new optional valid})
where
curLabel (VValue (EUR _) _) = "&euro;"
......
......@@ -2,7 +2,7 @@ implementation module UserDB
import StdEnv, StdMaybe
import StdGeneric
import TSt, Util, StdDebug
import TSt, Util
from Types import :: Password(..)
......
......@@ -8,7 +8,7 @@ generic gMakeLocalCopy a :: !a !*TSt -> (a,!*TSt)
derive gMakeSharedCopy OBJECT, CONS, PAIR, FIELD, EITHER, UNIT
derive gMakeSharedCopy Int, Real, Char, Bool, String, Dynamic
derive gMakeSharedCopy [], Maybe, Either, (,), (,,), (,,,), Void, Static, Hidden, Document
derive gMakeSharedCopy [], Maybe, Either, (,), (,,), (,,,), Void, HtmlDisplay, Editable, Hidden, Document
derive gMakeLocalCopy OBJECT, CONS, PAIR, FIELD, EITHER, UNIT
derive gMakeLocalCopy Int, Real, Char, Bool, String, Dynamic
derive gMakeLocalCopy [], Maybe, Either, (,), (,,), (,,,), Void, Static, Hidden, Document
\ No newline at end of file
derive gMakeLocalCopy [], Maybe, Either, (,), (,,), (,,,), Void, HtmlDisplay, Editable, Hidden, Document
\ No newline at end of file
......@@ -19,7 +19,7 @@ gMakeSharedCopy{|UNIT|} UNIT _ = UNIT
gMakeSharedCopy{|Dynamic|} dyn _ = dyn
gMakeSharedCopy{|Document|} doc sid = {Document|doc & type = Shared sid}
derive gMakeSharedCopy [], Maybe, Either, (,), (,,), (,,,), Void, Static, Hidden
derive gMakeSharedCopy [], Maybe, Either, (,), (,,), (,,,), Void, HtmlDisplay, Editable, Hidden
generic gMakeLocalCopy a :: !a !*TSt -> (a,!*TSt)
gMakeLocalCopy{|Int|} x tst = (x,tst)
......@@ -47,4 +47,4 @@ gMakeLocalCopy{|Document|} doc=:{content} tst=:{taskNr}
LocalLocation _ = ({Document|doc & type = Local},tst)
EmptyDocument = ({Document|doc & type = Local},tst)
derive gMakeLocalCopy [], Maybe, Either, (,), (,,), (,,,), Void, Static, Hidden
\ No newline at end of file
derive gMakeLocalCopy [], Maybe, Either, (,), (,,), (,,,), Void, HtmlDisplay, Editable, Hidden
\ No newline at end of file
......@@ -10,5 +10,5 @@ generic gMerge a :: MergeMode a a a -> MergeResult a
derive gMerge OBJECT, CONS, PAIR, FIELD, EITHER, UNIT
derive gMerge Int, Real, Char, Bool, String
derive gMerge Document, [], Maybe, Either, (,), (,,), (,,,), Void, Static, Hidden
derive gMerge Document, [], Maybe, Either, (,), (,,), (,,,), Void, HtmlDisplay, Editable, Hidden
derive bimap MergeResult
\ No newline at end of file
......@@ -7,7 +7,7 @@ mergeValues old cur new = getValue (gMerge{|*|} Merge old cur new)
:: MergeMode = Merge | Compare
:: MergeResult a = IsEqual Bool | Value a
derive gMerge [], Maybe, Either, (,), (,,), (,,,), Void, Static, Hidden
derive gMerge [], Maybe, Either, (,), (,,), (,,,), Void, HtmlDisplay, Editable, Hidden
derive gEq Document, DocumentContent, DocumentType, DocumentInfo, DocumentDataLocation
derive bimap MergeResult
......
......@@ -30,7 +30,7 @@ generic gUpdate a :: a *USt -> (a, *USt)
derive gUpdate UNIT, PAIR, EITHER, CONS, OBJECT, FIELD
derive gUpdate Int, Real, Char, Bool, String, Document, UserName
derive gUpdate Dynamic, [], Maybe, Either, (,), (,,), (,,,), Void, Static, Hidden
derive gUpdate Dynamic, [], Maybe, Either, (,), (,,), (,,,), Void, HtmlDisplay, Editable, Hidden
//Wrapper functions for updating
defaultValue :: !*World -> (!a,!*World) | gUpdate{|*|} a
......
......@@ -355,7 +355,7 @@ gUpdate {|Document|} s ust =: {USt | mode=UDSearch, searchPath, currentPath, upd
gUpdate {|Document|} s ust = (s,ust)
derive gUpdate Either, (,), (,,), (,,,), Void, Static, Hidden
derive gUpdate Either, (,), (,,), (,,,), Void, HtmlDisplay, Editable, Hidden
//Utility functions
dp2s :: DataPath -> String
......
......@@ -10,7 +10,7 @@ generic gVisualize a :: (VisualizationValue a) (VisualizationValue a) *VSt -> ([
//Default available instances
derive gVisualize UNIT, PAIR, EITHER, CONS, OBJECT, FIELD
derive gVisualize Int, Real, Char, Bool, String, Document, UserName
derive gVisualize Dynamic, [], Maybe, Either, (,), (,,), (,,,), Void, Static, Hidden
derive gVisualize Dynamic, [], Maybe, Either, (,), (,,), (,,,), Void, HtmlDisplay, Editable, Hidden
//Wrapper functions for visualization
visualizeAsEditor :: String (Maybe SubEditorIndex) DataMask a -> ([TUIDef],Bool) | gVisualize{|*|} a
......@@ -35,16 +35,19 @@ determineEditorUpdates :: String (Maybe SubEditorIndex) DataMask DataMask ListMa
derive bimap VisualizationValue
:: *VSt =
{ vizType :: !VisualizationType // Type of preferred visualization
, idPrefix :: !String // Prefix for all identity strings of editor fields
, label :: !Maybe String // Optional label to attach to editor fields
{ vizType :: !VisualizationType // Type of preferred visualization
, origVizType :: !VisualizationType // Type of the preferred visualization at initialization, this should not be edited.
, idPrefix :: !String // Prefix for all identity strings of editor fields
, label :: !Maybe String // Optional label to attach to editor fields
// Additional information for form generation
, currentPath :: !DataPath // Accumulated path through the data structure, used to identify sub-structures
, useLabels :: !Bool // Indent for labels, whether there is a label or not
, onlyBody :: !Bool // Only generate a constructor body for editors
, optional :: !Bool // Create optional form fields
, valid :: !Bool // Is the form valid
, listMask :: ListMask // Indicating which parts of a list have changed
, currentPath :: !DataPath // Accumulated path through the data structure, used to identify sub-structures
, useLabels :: !Bool // Indent for labels, whether there is a label or not
, onlyBody :: !Bool // Only generate a constructor body for editors
, optional :: !Bool // Create optional form fields
, valid :: !Bool // Is the form valid
, listMask :: !ListMask // Indicating which parts of a list have changed
, defAcc :: ![(!String,[TUIDef])] // An accumulator for definitions which cannot be directly placed in their HTML context
, phId :: Int // Counter for placeholder id's
}
:: VisualizationType
......
This diff is collapsed.
......@@ -27,7 +27,6 @@ derive JSONEncode WorkList, WorkListItem, TaskPriority, TaskProgress
//JSON specialization for Timestamp: Ignore the constructor
JSONEncode{|Timestamp|} (Timestamp x) c = JSONEncode{|*|} x c
import StdDebug
handleWorkListRequest :: !HTTPRequest !*TSt -> (!HTTPResponse, !*TSt)
handleWorkListRequest request tst=:{staticInfo}
# username = toUserName staticInfo.currentSession.user
......
......@@ -10,6 +10,7 @@ import JSON
derive JSONEncode TUIDef, TUIUpdate
:: TUIId :== String
:: PlaceholderId :== String
:: TUIUpdate
= TUIAdd TUIId TUIDef // Add the additional component *after* the component with indicated id
......@@ -32,6 +33,7 @@ derive JSONEncode TUIDef, TUIUpdate
| TUIPasswordControl TUIBasicControl
| TUICurrencyControl TUICurrencyControl
| TUIUsernameControl TUIBasicControl
| TUIDisplayControl TUIDisplayControl
| TUIButton TUIButton
| TUINumberField TUINumberField
| TUITextArea TUITextArea
......@@ -72,6 +74,14 @@ derive JSONEncode TUIDef, TUIUpdate
, currencyLabel :: !String
, optional :: !Bool
}
:: TUIDisplayControl =
{ id :: !String
, fieldLabel :: !Maybe String
, optional :: !Bool
, html :: !String
, formItems :: ![(PlaceholderId,[TUIDef])]
}
:: TUIButton =
{ name :: !String
, id :: !String
......
......@@ -4,7 +4,7 @@ import JSON,StdList
//JSON Encoding of TUI definitions is directly encoded as JSON data.
derive JSONEncode TUIButton, TUITextArea, TUIUserField, TUINumberField, TUIComboBox, TUICheckBox, TUICheckBoxGroup, TUIRadio, TUIRadioGroup, TUIDateField, TUITimeField, TUIFieldSet, TUIPanel, TUIHtmlPanel, TUIList, TUIMenuButton, TUIMenu, TUIMenuItem
derive JSONEncode TUIUpdate, TUIBox, TUIListItem, TUIDocument, TUITuple
derive JSONEncode TUIBasicControl, TUICurrencyControl
derive JSONEncode TUIBasicControl, TUICurrencyControl, TUIDisplayControl
JSONEncode{|TUIDef|} (TUIButton r) c = addXType "button" (JSONEncode{|*|} r c)
JSONEncode{|TUIDef|} (TUITextArea r) c = addXType "textarea" (JSONEncode{|*|} r c)
......@@ -41,6 +41,7 @@ JSONEncode{|TUIDef|} (TUITimeControl r) c = addXType "itasks.tui.Time" (JSONEnco
JSONEncode{|TUIDef|} (TUICurrencyControl r) c = addXType "itasks.tui.Currency" (JSONEncode{|*|} r c)
JSONEncode{|TUIDef|} (TUIUsernameControl r) c = addXType "itasks.tui.Username" (JSONEncode{|*|} r c)
JSONEncode{|TUIDef|} (TUIPasswordControl r) c = addXType "itasks.tui.Password" (JSONEncode{|*|} r c)
JSONEncode{|TUIDef|} (TUIDisplayControl r) c = addXType "itasks.tui.Display" (JSONEncode{|*|} r c)
addXType :: String [String] -> [String]
addXType xtype [x:xs] = [x,"\"xtype\" : \"",xtype,"\", ":xs]
\ No newline at end of file
......@@ -13,8 +13,8 @@ from iTasks import class iTask
import GenPrint, GenParse, GenVisualize, GenUpdate, JSON, StoreTasks
derive gPrint Session, Document, Hidden, Static, UserName
derive gParse Session, Document, Hidden, Static, UserName
derive gPrint Session, Document, Hidden, HtmlDisplay, Editable, UserName
derive gParse Session, Document, Hidden, HtmlDisplay, Editable, UserName
derive gVisualize Session
derive gUpdate Session
derive gMerge Session, UserName, User
......@@ -114,11 +114,21 @@ instance == Password
// Field behaviour extensions
:: Static a = Static a // Variable is always rendered as a HTML-fragment
:: VisualizationHint a = VHEditable a
| VHHtmlDisplay a
| VHHidden a
:: Editable a = Editable a // Variable is always rendered within a form as editor field
:: HtmlDisplay a = HtmlDisplay a // Variable is always rendered within a form as a HTML-fragment
:: Hidden a = Hidden a // Variable is never rendered
fromStatic :: !(Static .a) -> .a
toStatic :: !.a -> (Static .a)
fromVisualizationHint :: !(VisualizationHint .a) -> .a
toVisualizationHint :: !.a -> (VisualizationHint .a)
fromEditable :: !(Editable .a) -> .a
toEditable :: !.a -> (Editable .a)
fromHtmlDisplay :: !(HtmlDisplay .a) -> .a
toHtmlDisplay :: !.a -> (HtmlDisplay .a)
fromHidden :: !(Hidden .a) -> .a
toHidden :: !.a -> (Hidden .a)
......
......@@ -6,8 +6,8 @@ import Html
import Text, Util
import CommonDomain
derive gPrint Session, Document, DocumentType, DocumentInfo, DocumentContent, DocumentDataLocation, Hidden, Static, UserName
derive gParse Session, Document, DocumentType, DocumentInfo, DocumentContent, DocumentDataLocation,Hidden, Static, UserName
derive gPrint Session, Document, DocumentType, DocumentInfo, DocumentContent, DocumentDataLocation, Hidden, HtmlDisplay, Editable, UserName
derive gParse Session, Document, DocumentType, DocumentInfo, DocumentContent, DocumentDataLocation, Hidden, HtmlDisplay, Editable, UserName
derive gVisualize Session
derive gUpdate Session
derive gMerge Session, UserName, User
......@@ -86,13 +86,27 @@ emptyDoc = {type = Local, content = EmptyDocument}
isEmptyDoc :: !Document -> Bool
isEmptyDoc {type,content=EmptyDocument} = True
isEmptyDoc _ = False
// Hidden en Static
fromStatic :: !(Static .a) -> .a
fromStatic (Static x) = x
toStatic :: !.a -> (Static .a)
toStatic x = (Static x)
// VisualizationHints etc..
fromVisualizationHint :: !(VisualizationHint .a) -> .a
fromVisualizationHint (VHEditable a) = a
fromVisualizationHint (VHHtmlDisplay a) = a
fromVisualizationHint (VHHidden a) = a
toVisualizationHint :: !.a -> (VisualizationHint .a)
toVisualizationHint a = (VHEditable a)
fromEditable :: !(Editable .a) -> .a
fromEditable (Editable a) = a
toEditable :: !.a -> (Editable .a)
toEditable a = (Editable a)
fromHtmlDisplay :: !(HtmlDisplay .a) -> .a
fromHtmlDisplay (HtmlDisplay a) = a
toHtmlDisplay :: !.a -> (HtmlDisplay .a)
toHtmlDisplay a = (HtmlDisplay a)
fromHidden :: !(Hidden .a) -> .a
fromHidden (Hidden x) = x
......
......@@ -2,16 +2,34 @@ module MessageTest
import iTasks
derive bimap Maybe
derive bimap Maybe,(,)
derive gPrint Rec
derive gVisualize Rec
derive gParse Rec
derive gUpdate Rec
enter :: Task Int
enter = enterInformation "Enter a number"
instructionAbout :: Task Void
instructionAbout = enter >>= \v -> displayInstructionAbout "Test Instruction 2" "Please speak this number out loud" v
instructionAbout = enter >>= \v -> showInstructionAbout "Test Instruction 2" "Please speak this number out loud" v
:: Rec =
{ hidden :: Hidden Int
, html :: HtmlDisplay Int
, editable :: Editable Document
, normal :: Int
, list :: Editable [HtmlDisplay Rec]
, tuple :: (Editable Int, String)
}
typestest :: Task (HtmlDisplay Rec)
typestest = updateInformation "Update" (HtmlDisplay {Rec | normal = 4, hidden = Hidden 1, html = HtmlDisplay 2, editable = Editable emptyDoc,list= Editable [], tuple = (Editable 1, "Test")})
Start :: *World -> *World
Start world = startEngine [
workflow "Display Instruction" (displayInstruction "Test Instruction" "Please perform the following.."),
workflow "Display Instruction About" instructionAbout
workflow "Display Instruction" (showInstruction "Test Instruction" "Please perform the following.."),
workflow "Display Instruction About" instructionAbout,
workflow "Types Test" typestest
] world
\ No newline at end of file
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