Index: v/branches/rest-dojo-ui/client/mSurvey2.html
===================================================================
--- /Dev/branches/rest-dojo-ui/client/mSurvey2.html	(revision 352)
+++ 	(revision )
@@ -1,128 +1,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-    <title>Research Facilitator Tool</title>
-    <link rel="stylesheet" type="text/css" href="dojotoolkit/dijit/themes/claro/claro.css" />
-    <link rel="stylesheet" type="text/css" href="dojotoolkit/dojox/grid/resources/Grid.css" />
-    <link rel="stylesheet" type="text/css" href="dojotoolkit/dojox/grid/resources/claroGrid.css" />
-    <link rel="stylesheet" type="text/css" href="dojotoolkit/dojox/widget/Toaster/Toaster.css" />
-    <link rel="stylesheet" type="text/css" href="rft/css/main.css" />
-    <script type="text/javascript" src="dojotoolkit/dojo/dojo.js" data-dojo-config="async: true, parseOnLoad: false, tlmSiblingOfDojo: false, isDebug: true, baseUrl: '', packagePaths: {'dojotoolkit':['dojo','dijit', 'dojox'], '.':['rft']}"></script>
-    <script type="text/javascript">
-    require([
-        'dojo/parser',
-        'dijit/DropDownMenu',
-        'dijit/layout/AccordionContainer',
-        'dijit/layout/BorderContainer',
-        'dijit/layout/ContentPane',
-        'dijit/layout/TabContainer',
-        'dijit/layout/SplitContainer',
-        'dijit/MenuBar',
-        'dijit/MenuBarItem',
-        'dijit/form/Button',
-        'dijit/form/ComboBox',
-        'dijit/form/Form',
-        'dijit/form/Select',
-        'dijit/form/SimpleTextarea',
-        'dijit/form/TextBox',
-        'dijit/form/Textarea',
-        'dijit/PopupMenuBarItem',
-        'dijit/TitlePane',
-        'dojox/grid/DataGrid',
-        'dojox/widget/TitleGroup',
-        'rft/ui/List',
-        'rft/ui/MainMenu',
-        'rft/ui/MenuBarLink',
-        'rft/ui/MenuLink',
-        'rft/ui/Notifications',
-        'rft/ui/LineWithActionsWidget',
-        'rft/ui/QuestionWidget',
-        'rft/ui/Selector',
-        'rft/ui/SelectorThijs',
-        'rft/ui/LineWithActionsWidgetThijs',
-        'rft/ui/TitleGroup',
-        'dojo/domReady!'
-        ],function(parser){
-            parser.parse();
-        });
-</script>
-<script>
-function goToPage(name) {
-    window.location = "http://localhost/RESEARCHTOOL/Dev/branches/rest-dojo-ui/client/"+name+".html";
-}
-</script>
-</head>
-<body class="dijitReset claro">
-    <div class="page" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'">
-        <!-- Top menu bar -->
-        <div class="topbar" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'top'">
-            <h1>ResearchTool</h1>
-            <div data-dojo-type="rft.ui.MainMenu"></div>
-            <div class="breadcrumbs">
-                <span class="breadcrumb">User > </span>
-                <span class="breadcrumb">Session > </span>
-                <span class="breadcrumbCurrent">Survey A [editing]</span>
-            </div>
-        </div>
-        <!-- Main content window -->
-        <div class="content" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'">
-            <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="region:'center'" style="height: 500px;">
-                <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'top'">
-                    <h2>
-                        <span class="rftIcon rftIconSurvey"></span>
-                        <span class="headerText">Survey A [editing]</span>
-                    </h2>
-                </div>
-                <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="region:'center'">
-                    <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'top'">
-                        Presets
-                    </div>
-                    <div data-dojo-type="dijit.layout.TabContainer" class="blue" data-dojo-props="tabPosition:'left-h',region:'center'">
-                        <div data-dojo-type="dijit.layout.ContentPane" title="Category One, this is a very long title to see how overflow works. This part is cut off because it passes two lines at 200px wide.">
-                            <div data-dojo-type="rft.ui.SelectorThijs" data-dojo-props="Title:'Subcat one'"></div>
-                            <div data-dojo-type="rft.ui.SelectorThijs" data-dojo-props="Title:'Subcat two'"></div>
-                        </div>
-                        <div data-dojo-type="dijit.layout.ContentPane" title="Category Two">
-                            <div data-dojo-type="rft.ui.SelectorThijs" data-dojo-props="Title:'Subcat one'"></div>
-                            <div data-dojo-type="rft.ui.SelectorThijs" data-dojo-props="Title:'Subcat two'"></div>
-                        </div>
-                        <div data-dojo-type="dijit.layout.ContentPane" title="Category Three">
-                            <div data-dojo-type="rft.ui.SelectorThijs" data-dojo-props="Title:'Subcat one'"></div>
-                        </div>
-                        <div data-dojo-type="dijit.layout.ContentPane" title="Category Four">
-                            <div data-dojo-type="rft.ui.SelectorThijs" data-dojo-props="Title:'Green Question Subcat one'"></div>
-                            <div data-dojo-type="rft.ui.SelectorThijs" data-dojo-props="Title:'Subcat two'"></div>
-                            <div data-dojo-type="rft.ui.SelectorThijs" data-dojo-props="Title:'Subcat three'"></div>
-                        </div>
-                        <div data-dojo-type="dijit.layout.ContentPane" title="Category Five">
-                            <div data-dojo-type="rft.ui.SelectorThijs" data-dojo-props="Title:'Subcat one'"></div>
-                            <div data-dojo-type="rft.ui.SelectorThijs" data-dojo-props="Title:'Subcat two'"></div>
-                            <div data-dojo-type="rft.ui.SelectorThijs" data-dojo-props="Title:'Subcat three'"></div>
-                            <div data-dojo-type="rft.ui.SelectorThijs" data-dojo-props="Title:'Subcat four'"></div>
-                        </div>
-                    </div>
-                </div>
-                <!-- "Shopping cart" -->
-                <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="region:'right'" style="width: 300px">
-                    <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="region:'top'">
-                        <h3>Included questions</h3>
-                    </div>
-                    <div data-dojo-type="rft.ui.List" data-dojo-props="region:'center'">
-                        <!-- These would have to be dynamically generated instead of declared here! -->
-                        <div data-dojo-type="rft.ui.LineWithActionsWidgetThijs" data-dojo-props="title:'Question one', actions: {'Cancel':{callback: function(){}, properties: {blockButton: false, icon: 'Delete', modifiers:'white'}}}"></div>
-                        <div data-dojo-type="rft.ui.LineWithActionsWidgetThijs" data-dojo-props="title:'Question two', actions: {'Cancel':{callback: function(){}, properties: {blockButton: false, icon: 'Delete', modifiers:'white'}}}"></div>
-                    </div>
-                    <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'bottom'">
-                        <button data-dojo-type="dijit.form.Button" data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconSettings'">Properties</button>
-                        <button data-dojo-type="dijit.form.Button" data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconAccept'">Save Changes</button>
-                        <button data-dojo-type="dijit.form.Button" data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconCancel'">Discard changes</button>
-                        <button data-dojo-type="dijit.form.Button" data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconPreview'">Design</button>
-
-                    </div>
-                </div>
-            </div>
-        </div>
-    </div>
-</body>
-</html>
Index: /Dev/branches/rest-dojo-ui/client/rft/pages/sessions.html
===================================================================
--- /Dev/branches/rest-dojo-ui/client/rft/pages/sessions.html	(revision 352)
+++ /Dev/branches/rest-dojo-ui/client/rft/pages/sessions.html	(revision 353)
@@ -1,41 +1,3 @@
 <div data-dojo-type="rft.pages.sessions">
-    <script>
-        function createNew(){
-            var newBox = new rft.ui.ObjectBox({
-                title: 'TeamUp Basic Template',
-                subTitle: '',
-                lowerTitle: '',
-                objectType: 'SessionTemplate',
-                actions: {
-                    "edit": function() {},
-                    "delete": function() {}
-                }
-            });
-            newBox.startup();
-            newBox.placeAt("containerTemplates", "last");
-        }
-        
-        function createInstance(args) {
-            // Create a template instance in the "Sessions" tab
-            var args;
-            args.objectType = "Session";
-            var d = new Date();
-            var dateString = d.getDate()+"-"+d.getMonth()+"-"+d.getFullYear();
-            var creator = "Igor Mayer"; // Use currently logged in profile instead!
-            args.subTitle = "Created on "+dateString+" by "+creator;
-        
-            args.actions = {
-                "edit": function() {},
-                "delete": function() {}
-            }
-            var newBox = new rft.ui.ObjectBox(args);
-            newBox.startup();
-            newBox.placeAt("containerSessions", "last");
-
-            // TODO: Then switch tabs to the Sessions tab!
-            var sess = dijit.byId("dijit_layout_ContentPane_5");
-            dijit.byId("tabs").selectChild(sess);
-        }
-    </script>
     <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="region:'center'" style="height: 500px;">
         <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'top'">
@@ -48,15 +10,12 @@
             <div data-dojo-type="dijit.layout.TabContainer" class="green" data-dojo-props="tabPosition:'left-h',region:'center'" id="tabs">
                 <div data-dojo-type="dijit.layout.BorderContainer" title="Templates">
-                    <div id="containerTemplates" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'center'">
-                        <!--TODO: These don't allow for custom icon settings yet! -->
-                        <div data-dojo-type="rft.ui.ObjectBox" data-dojo-props="actions: {'edit': function(){alert('Custom edit code');}, 'delete':function(){}, 'Custom function': function(){alert('newCommand');}, 'publish': function(){alert('createInstance');}}"></div>
+                    <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'center'" data-rft-attach-point="containerTemplates">
                     </div>
                     <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'bottom'" style="height: 40px;">
-                        <div data-dojo-type="dijit.form.Button" data-dojo-props="region: 'bottom', baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconSessionTemplate', onClick: function(){alert('createNew');}">Create new template</div>
+                        <div data-dojo-type="dijit.form.Button" data-dojo-props="region: 'bottom', baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconSessionTemplate'" data-rft-attach-event="onClick:onAddSessionTemplate">Create new template</div>
                     </div>
                 </div>
                 <div data-dojo-type="dijit.layout.ContentPane" title="Sessions">
-                    <div id="containerSessions" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'center'">
-
+                    <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'center'" data-rft-attach-point="containerSessions">
                     </div>
                     <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'bottom'" style="height: 40px;">
Index: /Dev/branches/rest-dojo-ui/client/rft/pages/sessions.js
===================================================================
--- /Dev/branches/rest-dojo-ui/client/rft/pages/sessions.js	(revision 352)
+++ /Dev/branches/rest-dojo-ui/client/rft/pages/sessions.js	(revision 353)
@@ -1,33 +1,56 @@
-define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/Deferred','dojo/data/ObjectStore','rft/auth','rft/store','rft/content','rft/ui/_Page'],
-    function(declare,lang,Deferred,ObjectStore,auth,store,content,_Page){
+define(['dojo/_base/declare','dojo/_base/lang','rft/store','rft/content','rft/ui/_Page','rft/ui/ObjectBox'],
+    function(declare,lang,store,content,_Page,ObjectBox){
         return declare('rft.pages.sessions',[_Page],{
             selectedObject: null,
             onVisit: function() {
-                this.grid.setStore(
-                    ObjectStore({objectStore: store}),
-                    "_design/default/_view/by_type",{key:'Survey'});
-                
-                this.grid.on('rowclick',lang.hitch(this,function(evt){
-                    this.selectedObject = evt.grid.getItem(evt.rowIndex);
-                    this.btnEdit.set('disabled',!this.selectedObject);
+                this._refresh();
+            },
+            _refresh: function() {
+                this.containerTemplates.set('content','');
+                this.containerSessions.set('content','');
+                this._refreshByType('SessionTemplate',this.containerTemplates.domNode);
+                this._refreshByType('SessionInstance',this.containerSessions.domNode);
+            },
+            _refreshByType: function(type,container) {
+                store.query("_design/default/_view/by_type",{key:type})
+                .forEach(lang.hitch(this,function(obj){
+                    var widget = new ObjectBox({
+                        title: obj.title || "Untitled",
+                        actions: {
+                            "Edit": function(){alert('Custom edit code');},
+                            "Delete": lang.hitch(this,function(){
+                                store.remove(store.getIdentity(obj),store.getRevision(obj))
+                                .then(lang.hitch(this,function(){
+                                    this._refresh();
+                                }));
+                            }),
+                            "Custom function": function(){alert('newCommand');},
+                            "Publish": lang.hitch(this,this._publishSession,obj)
+                        }
+                    });
+                    widget.startup();
+                    widget.placeAt(container, "last");
                 }));
-
-                this.grid.on('rowdblclick',lang.hitch(this,function(evt){
-                    var obj = evt.grid.getItem(evt.rowIndex);
-                    content.goTo('/survey',{uid:store.getIdentity(obj)});
+            },
+            onAddSessionTemplate: function(){
+                store.put({
+                    type: 'SessionTemplate',
+                    title: 'TeamUp Basic Template'
+                })
+                .then(lang.hitch(this,function(){
+                    this._refresh();
                 }));
-                                
-                this.btnNew.on('click',lang.hitch(this,function(){
-                    Deferred.when( store.add({type:'Survey',creator:auth.getUser()}) )
-                    .then(function(obj) {
-                        content.goTo('/survey',{uid:store.getIdentity(obj)});
-                    });
-                }));
-
-                this.btnEdit.on('click',lang.hitch(this,function(){
-                    if ( this.selectedObject ) {
-                        content.goTo('/survey',{uid:store.getIdentity(this.selectedObject)});
-                    }
-                    
+            },
+            _publishSession: function(sessionTemplate) {
+                var publishDate = new Date();
+                var session = {
+                    type: "SessionInstance",
+                    title: sessionTemplate.title,
+                    date: publishDate.getDate()+"-"+publishDate.getMonth()+"-"+publishDate.getFullYear(),
+                    creator: "Igor Mayer"
+                };
+                store.add(session)
+                .then(lang.hitch(this,function(){
+                    this._refresh();
                 }));
             }
Index: v/branches/rest-dojo-ui/client/rft/ui/LineWithActionsWidgetThijs.js
===================================================================
--- /Dev/branches/rest-dojo-ui/client/rft/ui/LineWithActionsWidgetThijs.js	(revision 352)
+++ 	(revision )
@@ -1,89 +1,0 @@
-define([
-    'dojo/_base/declare',
-    'dojo/_base/lang',
-    'dojo/on',
-    'dojo/dom', 
-    'dojo/dom-class', 
-    'dijit/form/Button',
-    'dijit/_WidgetBase',
-    'dijit/_TemplatedMixin',
-    'dijit/_WidgetsInTemplateMixin',
-    'dojo/text!./templates/LineWithActionsWidget.html'
-    ],
-    function(
-        declare,
-        lang,
-        on,
-        dom,
-        domClass,
-        Button,
-        _WidgetBase,
-        _TemplatedMixin,
-        _WidgetsInTemplateMixin,
-        templateString) {
-        return declare('rft.ui.LineWithActionsWidgetThijs',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{
-
-            templateString: templateString,
-            baseClass: 'rftLineWithButtons',
-            title: '',
-            modifiers: "",
-            userObject: null,
-            actions: {},
-            
-            postCreate: function() {
-                dom.setSelectable(this.domNode, false);
-                on(this.titleNode,'click',lang.hitch(this,'_onClick'));
-            },
-            startup: function() {
-                this.inherited(arguments);
-                this._setupActions();
-                domClass.add(this.domNode, this.modifiers);
-                this.refresh();
-            },
-            _setupActions: function() {
-                for (var action in this.actions) {
-
-                    if (this.actions[action].properties.blockButton == true) {  // BlockButton
-                        var properties = lang.mixin({
-                            baseClass: 'rftBlockButton',
-                            modifiers: this.modifiers,
-                            label: "Default",
-                            iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon,
-                            title: action,
-                            onClick: lang.hitch(this, this.actions[action].callback)
-                        }, this.actions[action].properties);
-                        properties["class"] = properties.modifiers;
-                        new Button(properties).placeAt(this.buttonsNode);
-                    } else {    //InlineButton
-                        var properties = lang.mixin({
-                            baseClass: 'rftInlineButton',
-                            modifiers: 'black',
-                            label: "Default",
-                            showLabel: false,
-                            iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon,
-                            title: action,
-                            onClick: lang.hitch(this, this.actions[action].callback)
-                        }, this.actions[action].properties);
-                        properties["class"] = properties.modifiers;
-                        new Button(properties).placeAt(this.buttonsNode);
-                    }
-                }
-            },
-            refresh: function() {
-
-                this.titleNode.innerHTML = this.title;
-            },
-            _onClick: function(e){
-                var preventDefault = this.onClick(e) === false;
-                if(preventDefault){
-                    e.preventDefault();
-                }
-                return !preventDefault;
-            },
-            onClick: function(e) {},
-            _setTitleAttr: function(value){
-                this.title = value;
-                this.refresh();
-            }
-        });
-});
Index: v/branches/rest-dojo-ui/client/rft/ui/SelectorThijs.js
===================================================================
--- /Dev/branches/rest-dojo-ui/client/rft/ui/SelectorThijs.js	(revision 352)
+++ 	(revision )
@@ -1,112 +1,0 @@
-define([
-    'dojo/_base/declare',
-    'dojo/_base/lang',
-    'dojo/fx',
-    'dijit/_WidgetBase',
-    'dijit/_TemplatedMixin',
-    'dijit/_WidgetsInTemplateMixin',
-    'dijit/_Container',
-    './LineWithActionsWidgetThijs',
-    'dojo/text!./templates/SelectorThijs.html',
-    'dojo/dom-class'
-    ],function(
-        declare,
-        lang,
-        fx,
-        _WidgetBase,
-        _TemplatedMixin,
-        _WidgetsInTemplateMixin,
-        _Container,
-        LineWithActionsWidget,
-        templateString,
-        domClass
-        ){
-        return declare('rft.ui.SelectorThijs',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{
-            templateString: templateString,
-            title: "The professional as a participant",
-            baseClass: 'rftSelector',
-            modifiers: 'blue',    // Extra CSS classes
-            postCreate: function() {
-                domClass.add(this.domNode, this.modifiers);
-                domClass.add(this.selectedColorNode, "pending");
-                var infoFunction = function() {
-                    alert("Show info here");
-                }
-                new LineWithActionsWidget({
-                    title: this.title,
-                    modifiers: this.modifiers,
-                    actions: {
-                        "AddToSurvey" : {
-                            callback: function(arg){},
-                            properties: {
-                                blockButton: true,
-                                modifiers: this.modifiers,
-                                icon: "Accept",
-                                label: "Include"
-                            }
-                        }
-                    }
-                },this.titleNode);
-                var selectorLine = new LineWithActionsWidget({
-                    title: 'None',
-                    modifiers: this.modifiers,
-                    actions: {
-                        "ToggleDropdown" : {
-                            callback: lang.hitch(this,function(){
-                                var node = this.optionsNode;
-                                var show = fx.wipeIn({
-                                    node: node
-                                });
-                                var hide = fx.wipeOut({
-                                    node: node
-                                });
-                                hide.play();
-                                var folded = true;
-                                return function(e) {
-                                    if ( folded ) {
-                                        // Bit of an ugly solution, really. Limit workload by limiting search to child elements of selecorLine.buttonsNode
-                                        var downArrowIcon = dojo.query(".rftBlockButton .rftIconHalfArrowDown", selectorLine.buttonsNode)[0];  // Query the down arrow rftIcon span
-                                        if (downArrowIcon){
-                                            domClass.replace(downArrowIcon, "rftIconHalfArrowUp", "rftIconHalfArrowDown");
-                                        }
-                                        show.play();
-                                        folded = false;
-                                    } else {
-                                        // Bit of an ugly solution, really. Limit workload by limiting search to child elements of selecorLine.buttonsNode
-                                        var upArrowIcon = dojo.query(".rftBlockButton .rftIconHalfArrowUp", selectorLine.buttonsNode)[0];  // Query the up arrow rftIcon span
-                                        if (upArrowIcon){
-                                            domClass.replace(upArrowIcon, "rftIconHalfArrowDown", "rftIconHalfArrowUp");
-                                        }
-                                        hide.play();
-                                        folded = true;
-                            
-                                    }
-                                    e.preventDefault();
-                                    e.stopPropagation();
-                                };
-                            })(),
-                            properties: {
-                                blockButton: true,
-                                modifiers: this.modifiers,
-                                showLabel: false,
-                                icon: "HalfArrowDown"
-                            }
-                        }
-                    }
-                },this.selectedItemNode);
-                new LineWithActionsWidget({
-                    title: 'Are there direct colleagues among the other participants?',
-                    actions: {
-                        "InfoHover" : {
-                            callback: infoFunction,
-                            properties: {
-                                blockButton: false,
-                                showLabel: false,
-                                icon: "Inspect"
-                            }
-                        }
-                    }
-                }).placeAt(this.optionsNode);
-            }
-        });
-    });
Index: v/branches/rest-dojo-ui/client/rft/ui/templates/LineWithActionsWidgetThijs.html
===================================================================
--- /Dev/branches/rest-dojo-ui/client/rft/ui/templates/LineWithActionsWidgetThijs.html	(revision 352)
+++ 	(revision )
@@ -1,4 +1,0 @@
-<div class="${baseClass}">
-    <span class="${baseClass}Title" data-dojo-attach-point="titleNode"></span>
-    <span class="${baseClass}Buttons" data-dojo-attach-point="buttonsNode"></span>
-</div>
Index: v/branches/rest-dojo-ui/client/rft/ui/templates/SelectorThijs.html
===================================================================
--- /Dev/branches/rest-dojo-ui/client/rft/ui/templates/SelectorThijs.html	(revision 352)
+++ 	(revision )
@@ -1,10 +1,0 @@
-<div>
-    <div class="${baseClass}Category">
-        <div class="${baseClass}Title" data-dojo-attach-point="titleNode"></div>
-    </div>
-    <div class="${baseClass}Selected">
-        <div class="${baseClass}Color" data-dojo-attach-point="selectedColorNode"></div>
-        <div class="${baseClass}Item" data-dojo-attach-point="selectedItemNode"></div>
-    </div>
-    <div class="${baseClass}Options" data-dojo-attach-point="optionsNode"></div>
-</div>
