Changeset 353


Ignore:
Timestamp:
07/05/12 12:49:21 (13 years ago)
Author:
hendrikvanantwerpen
Message:

Added DB code to sessions page.
Removed old static mockups.
Removed dup widgets.

Location:
Dev/branches/rest-dojo-ui/client
Files:
5 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • Dev/branches/rest-dojo-ui/client/rft/pages/sessions.html

    r350 r353  
    11<div data-dojo-type="rft.pages.sessions">
    2     <script>
    3         function createNew(){
    4             var newBox = new rft.ui.ObjectBox({
    5                 title: 'TeamUp Basic Template',
    6                 subTitle: '',
    7                 lowerTitle: '',
    8                 objectType: 'SessionTemplate',
    9                 actions: {
    10                     "edit": function() {},
    11                     "delete": function() {}
    12                 }
    13             });
    14             newBox.startup();
    15             newBox.placeAt("containerTemplates", "last");
    16         }
    17        
    18         function createInstance(args) {
    19             // Create a template instance in the "Sessions" tab
    20             var args;
    21             args.objectType = "Session";
    22             var d = new Date();
    23             var dateString = d.getDate()+"-"+d.getMonth()+"-"+d.getFullYear();
    24             var creator = "Igor Mayer"; // Use currently logged in profile instead!
    25             args.subTitle = "Created on "+dateString+" by "+creator;
    26        
    27             args.actions = {
    28                 "edit": function() {},
    29                 "delete": function() {}
    30             }
    31             var newBox = new rft.ui.ObjectBox(args);
    32             newBox.startup();
    33             newBox.placeAt("containerSessions", "last");
    34 
    35             // TODO: Then switch tabs to the Sessions tab!
    36             var sess = dijit.byId("dijit_layout_ContentPane_5");
    37             dijit.byId("tabs").selectChild(sess);
    38         }
    39     </script>
    402    <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="region:'center'" style="height: 500px;">
    413        <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'top'">
     
    4810            <div data-dojo-type="dijit.layout.TabContainer" class="green" data-dojo-props="tabPosition:'left-h',region:'center'" id="tabs">
    4911                <div data-dojo-type="dijit.layout.BorderContainer" title="Templates">
    50                     <div id="containerTemplates" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'center'">
    51                         <!--TODO: These don't allow for custom icon settings yet! -->
    52                         <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>
     12                    <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'center'" data-rft-attach-point="containerTemplates">
    5313                    </div>
    5414                    <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'bottom'" style="height: 40px;">
    55                         <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>
     15                        <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>
    5616                    </div>
    5717                </div>
    5818                <div data-dojo-type="dijit.layout.ContentPane" title="Sessions">
    59                     <div id="containerSessions" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'center'">
    60 
     19                    <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'center'" data-rft-attach-point="containerSessions">
    6120                    </div>
    6221                    <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region: 'bottom'" style="height: 40px;">
  • Dev/branches/rest-dojo-ui/client/rft/pages/sessions.js

    r350 r353  
    1 define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/Deferred','dojo/data/ObjectStore','rft/auth','rft/store','rft/content','rft/ui/_Page'],
    2     function(declare,lang,Deferred,ObjectStore,auth,store,content,_Page){
     1define(['dojo/_base/declare','dojo/_base/lang','rft/store','rft/content','rft/ui/_Page','rft/ui/ObjectBox'],
     2    function(declare,lang,store,content,_Page,ObjectBox){
    33        return declare('rft.pages.sessions',[_Page],{
    44            selectedObject: null,
    55            onVisit: function() {
    6                 this.grid.setStore(
    7                     ObjectStore({objectStore: store}),
    8                     "_design/default/_view/by_type",{key:'Survey'});
    9                
    10                 this.grid.on('rowclick',lang.hitch(this,function(evt){
    11                     this.selectedObject = evt.grid.getItem(evt.rowIndex);
    12                     this.btnEdit.set('disabled',!this.selectedObject);
     6                this._refresh();
     7            },
     8            _refresh: function() {
     9                this.containerTemplates.set('content','');
     10                this.containerSessions.set('content','');
     11                this._refreshByType('SessionTemplate',this.containerTemplates.domNode);
     12                this._refreshByType('SessionInstance',this.containerSessions.domNode);
     13            },
     14            _refreshByType: function(type,container) {
     15                store.query("_design/default/_view/by_type",{key:type})
     16                .forEach(lang.hitch(this,function(obj){
     17                    var widget = new ObjectBox({
     18                        title: obj.title || "Untitled",
     19                        actions: {
     20                            "Edit": function(){alert('Custom edit code');},
     21                            "Delete": lang.hitch(this,function(){
     22                                store.remove(store.getIdentity(obj),store.getRevision(obj))
     23                                .then(lang.hitch(this,function(){
     24                                    this._refresh();
     25                                }));
     26                            }),
     27                            "Custom function": function(){alert('newCommand');},
     28                            "Publish": lang.hitch(this,this._publishSession,obj)
     29                        }
     30                    });
     31                    widget.startup();
     32                    widget.placeAt(container, "last");
    1333                }));
    14 
    15                 this.grid.on('rowdblclick',lang.hitch(this,function(evt){
    16                     var obj = evt.grid.getItem(evt.rowIndex);
    17                     content.goTo('/survey',{uid:store.getIdentity(obj)});
     34            },
     35            onAddSessionTemplate: function(){
     36                store.put({
     37                    type: 'SessionTemplate',
     38                    title: 'TeamUp Basic Template'
     39                })
     40                .then(lang.hitch(this,function(){
     41                    this._refresh();
    1842                }));
    19                                
    20                 this.btnNew.on('click',lang.hitch(this,function(){
    21                     Deferred.when( store.add({type:'Survey',creator:auth.getUser()}) )
    22                     .then(function(obj) {
    23                         content.goTo('/survey',{uid:store.getIdentity(obj)});
    24                     });
    25                 }));
    26 
    27                 this.btnEdit.on('click',lang.hitch(this,function(){
    28                     if ( this.selectedObject ) {
    29                         content.goTo('/survey',{uid:store.getIdentity(this.selectedObject)});
    30                     }
    31                    
     43            },
     44            _publishSession: function(sessionTemplate) {
     45                var publishDate = new Date();
     46                var session = {
     47                    type: "SessionInstance",
     48                    title: sessionTemplate.title,
     49                    date: publishDate.getDate()+"-"+publishDate.getMonth()+"-"+publishDate.getFullYear(),
     50                    creator: "Igor Mayer"
     51                };
     52                store.add(session)
     53                .then(lang.hitch(this,function(){
     54                    this._refresh();
    3255                }));
    3356            }
Note: See TracChangeset for help on using the changeset viewer.