Ignore:
Timestamp:
09/07/12 16:59:14 (13 years ago)
Author:
hendrikvanantwerpen
Message:

Next steps to actually make taking surveys possible.

Split Controller in Router and Content. Updated the view.html to work
with the new app/Content mechanism. Include view page in build profile.

Rearranged Couch design documents per type. Changed config tool so the
docs.js can be more readable, functions don't have to be on one line
anymore but are serialized later. Because the .htaccess proxy is limited
to the rft database for security reasons, the config tool has to be run
on Node.js, to be able to access the Couch port (which is limited by
cross domain security in the browser).

Added elastic search to .htaccess proxy as well. Seperated CouchStore?
from rft/store, which contains application specific data.

Removed some old API files that were hanging around still.

Introduced preview mode for viewSurvey page. Changed survey page to
only show published questions to be included. The surveys page has
three categories: drafts, published and runs. Creating survey runs is
not yet implemented.

Location:
Dev/branches/rest-dojo-ui/client/rft/pages
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • Dev/branches/rest-dojo-ui/client/rft/pages/index.js

    r407 r410  
    11define([
    22    'dojo/_base/declare',
    3     '../app/Controller',
     3    '../app/Router',
    44    '../app/Page',
    55    'dojo/text!./index.html'
    6 ],function(declare,Controller,Page,template){
     6],function(declare,Router,Page,template){
    77    return declare([Page],{
    88        templateString: template,
     
    1111            if ( this._started ) { return; }
    1212            this.inherited(arguments);
    13             this.btnContentCreate.on("click",function(){ Controller.go("/sessions"); });
    14             this.btnContentFacilitate.on("click",function(){ Controller.go("/run"); });
    15             this.btnSurveys.on("click",function(){ Controller.go("/surveys"); });
    16             this.btnQuestions.on("click",function(){ Controller.go("/questions"); });
    17             this.btnApplications.on("click",function(){ Controller.go("/applications"); });
    18             this.btnDashboards.on("click",function(){ Controller.go("/dashboards"); });
    19             this.btnResults.on("click",function(){ Controller.go("/results"); });
     13            this.btnContentCreate.on("click",function(){ Router.go("/sessions"); });
     14            this.btnContentFacilitate.on("click",function(){ Router.go("/run"); });
     15            this.btnSurveys.on("click",function(){ Router.go("/surveys"); });
     16            this.btnQuestions.on("click",function(){ Router.go("/questions"); });
     17            this.btnApplications.on("click",function(){ Router.go("/applications"); });
     18            this.btnDashboards.on("click",function(){ Router.go("/dashboards"); });
     19            this.btnResults.on("click",function(){ Router.go("/results"); });
    2020        }
    2121    });
  • Dev/branches/rest-dojo-ui/client/rft/pages/question.js

    r407 r410  
    55    'dojo/_base/lang',
    66    '../store',
    7     '../app/Controller',
     7    '../app/Content',
     8    '../app/Router',
    89    '../app/Page',
    910    '../ui/QuestionEditorPreview',
    1011    '../ui/QuestionEditorToolkit',
    1112    'dojo/text!./question.html'
    12 ],function(declare, Deferred, event, lang, store, Controller, Page, QuestionEditorPreview, QuestionEditorToolkit, template){
     13],function(declare, Deferred, event, lang, store, Content, Router, Page, QuestionEditorPreview, QuestionEditorToolkit, template){
    1314    return declare([Page], {
    1415        templateString: template,
     
    4344            store.put(this.question)
    4445            .then(function() {
    45                 Controller.go('/questions');
     46                Router.go('/questions');
     47            },function(err){
     48                Content.notify(err.reason,'error');
    4649            });
    4750            evt && event.stop( evt );
     
    4952        },
    5053        _onDiscard: function() {
    51             Controller.go('/questions');
     54            Router.go('/questions');
    5255            return true;
    5356        },
  • Dev/branches/rest-dojo-ui/client/rft/pages/questions.js

    r407 r410  
    44    'dojo/_base/event',
    55    'dojo/_base/lang',
    6     '../app/Controller',
    76    '../store',
     7    '../app/Content',
     8    '../app/Router',
    89    '../app/Page',
    910    '../ui/TabbedQuestionBrowser',
    1011    'dojo/text!./questions.html'
    11 ],function(declare,Deferred,event,lang,Controller,store,Page,TabbedQuestionBrowser,template) {
     12],function(declare,Deferred,event,lang,store,Content,Router,Page,TabbedQuestionBrowser,template) {
    1213    return declare([Page],{
    1314        templateString: template,
     
    1920                'class': 'blue',
    2021                itemActions: {
    21                     'Edit': {
     22                    Edit: {
    2223                        callback: lang.hitch(this,"onEditQuestion"),
    23                            icon: 'Edit',
    24                            description: 'Edit question'
     24                        icon: 'Edit',
     25                        description: 'Edit question'
     26                    },
     27                    Publish: {
     28                        callback: lang.hitch(this,"onPublishQuestion"),
     29                        icon: 'Publish',
     30                        description: 'Publish question'
    2531                    }
    2632                }
    2733            },this.questionBrowser);
    2834            this.questionBrowser.startup();
    29         },
    30         _refresh: function() {
    31             Deferred.when(store.query('_design/default/_view/by_type',{key: 'Question'}))
    32             .then(lang.hitch(this,function(items){
    33                 this._list.setItems(items);
    34             }));
    3535        },
    3636        onNewQuestion: function() {
     
    4141        },
    4242        onEditQuestion: function(question) {
    43             Controller.go("/question/"+question._id);
     43            Router.go("/question/"+question._id);
     44        },
     45        onPublishQuestion: function(question) {
     46            question.publicationDate = store.timestamp();
     47            store.put(question)
     48            .then(function(){
     49                Content.notify("Question puplished.");
     50            },function(err){
     51                Content.notify(err.reason,'error');
     52            });
    4453        }
    4554    });
  • Dev/branches/rest-dojo-ui/client/rft/pages/session.js

    r407 r410  
    22    'dojo/_base/array',
    33    'dojo/_base/declare',
     4    'dojo/_base/Deferred',
     5    'dojo/_base/event',
    46    'dojo/_base/lang',
    5     'dojo/_base/event',
    6     'dojo/_base/Deferred',
    7     '../app/Controller',
     7    '../search',
    88    '../store',
    9     '../elastic/ElasticSearchFilteringSelect',
    10     '../elastic/ElasticReadStore',
    119    '../app/Page',
     10    '../app/Router',
     11    '../ui/ThresholdFilteringSelect',
    1212    '../ui/lists/AccountListView',
    1313    'dojo/text!./session.html'
    14 ],function(array,declare,lang,event,Deferred,ElasticSearchFilteringSelect,ElasticReadStore,store,Page,Controller,AccountListView,template){
     14],function(array,declare,Deferred,event,lang,search,store,Page,Router,ThresholdFilteringSelect,AccountListView,template){
    1515    return declare([Page],{
    1616        templateString: template,
     
    4848            store.put(this.session)
    4949            .then(function(){
    50                 Controller.go('/sessions');
     50                Router.go('/sessions');
    5151            });
    5252            event.stop(evt);
     
    5656            this.propertiesForm.reset();
    5757            event.stop(evt);
    58             Controller.go('/sessions');
     58            Router.go('/sessions');
    5959            return false;
    6060        },
     
    7070        },
    7171        _setupAutoComplete: function() {
    72             var accountStore = new ElasticReadStore({
    73                 url: "http://localhost:9200/rft/_search",
    74                 requestMethod: "POST"
    75             });
    76             this._select = new ElasticSearchFilteringSelect({
    77                 store: accountStore,
     72            this._select = new ThresholdFilteringSelect({
     73                store: search,
    7874                autoComplete: false,
    7975                required: false,
  • Dev/branches/rest-dojo-ui/client/rft/pages/sessions.js

    r407 r410  
    44    'dojo/date/stamp',
    55    '../store',
    6     '../app/Controller',
     6    '../app/Router',
    77    '../app/Page',
    88    '../ui/ObjectBox',
    99    'dojo/text!./sessions.html'
    10 ],function(declare,lang,dateStamp,store,Controller,Page,ObjectBox,template){
     10],function(declare,lang,dateStamp,store,Router,Page,ObjectBox,template){
    1111    return declare([Page],{
    1212        templateString: template,
     
    1818            this.templateActions = {
    1919                "Edit": function(obj){
    20                     Controller.go('/session/'+store.getIdentity(obj));
     20                    Router.go('/session/'+store.getIdentity(obj));
    2121                },
    2222                "Delete": lang.hitch(this,function(obj){
     
    3030            this.sessionActions = {
    3131                "Facilitate": function(obj){
    32                     Controller.go('run',{uid:store.getIdentity(obj)});
     32                    Router.go('run',{uid:store.getIdentity(obj)});
    3333                },
    3434                "Delete": lang.hitch(this,function(obj){
     
    6262            })
    6363            .then(lang.hitch(this,function(obj){
    64                 Controller.go('/session/'+store.getIdentity(obj));
     64                Router.go('/session/'+store.getIdentity(obj));
    6565            }));
    6666        },
     
    7070            delete session[store.revProperty];
    7171            session.type = "SessionInstance";
    72             session.publishedDate = dateStamp.toISOString(new Date(),{zulu: true});
     72            session.publicationDate = store.timestamp();
    7373            session.creator = "Igor Mayer";
    7474            store.add(session)
  • Dev/branches/rest-dojo-ui/client/rft/pages/survey.js

    r407 r410  
    55    'dojo/_base/event',
    66    'dojo/_base/lang',
    7     '../app/Controller',
     7    '../app/Router',
    88    '../store',
    99    '../app/Page',
     
    1111    '../ui/TabbedQuestionBrowser',
    1212    'dojo/text!./survey.html'
    13 ],function(array,declare,Deferred,event,lang,Controller,store,Page,
     13],function(array,declare,Deferred,event,lang,Router,store,Page,
    1414         QuestionListView,TabbedQuestionBrowser,template){
    1515    return declare([Page],{
     
    2727                this._setupQuestionBrowser();
    2828                this._setupListView();
    29                 Deferred.when(store.get(this.surveyId))
    30                 .then(lang.hitch(this,function(obj){
    31                     this.survey = obj;
    32                     store.query(null,{keys:this.survey.questions,include_docs:true})
    33                     .forEach(lang.hitch(this.questionList,'appendItem'));
    34                     this.refresh();
    35                 }));
     29                this._setupSurvey();
    3630            } else {
    3731                throw "No valid uid or survey passed!";
     
    4236                region: 'center',
    4337                'class': 'blue',
     38                include: 'published',
    4439                selectedActions: {
    4540                    "Include": {
     
    5954            this.questionBrowser.startup();
    6055        },
    61         _includeQuestion: function(question) {
    62             this.questionList.insertItem(question);
    63         },
    6456        _setupListView: function() {
    6557            this.questionList = new QuestionListView({
     
    6759            },this.surveyListViewNode);
    6860            this.questionList.startup();
     61        },
     62        _setupSurvey: function() {
     63            Deferred.when(store.get(this.surveyId))
     64            .then(lang.hitch(this,function(survey){
     65                this.survey = survey;
     66                store.query(null,{keys:this.survey.questions || [], include_docs: true})
     67                .forEach(lang.hitch(this.questionList,'appendItem'));
     68                this.refresh();
     69            }));
     70        },
     71        _includeQuestion: function(question) {
     72            this.questionList.insertItem(question);
    6973        },
    7074        refresh: function() {
     
    9498            store.put(this.survey)
    9599            .then(function() {
    96                 Controller.go('/surveys');
     100                Router.go('/surveys');
    97101            });
    98102            event.stop(evt);
     
    100104        },
    101105        _onDiscard: function(evt) {
     106            Router.go('/surveys');
    102107        },
    103108        _onShowPreview: function() {
    104             Controller.go('/viewSurvey/'+store.getIdentity(this.survey));
     109            Router.go('/viewSurvey/'+store.getIdentity(this.survey),{
     110                preview: true
     111            });
    105112        }
    106113    });
  • Dev/branches/rest-dojo-ui/client/rft/pages/surveys.html

    r407 r410  
    11<div>
    2     <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region: 'center'">
    3         <button data-dojo-type="dijit/form/Button" class="blue" data-dojo-props="disabled: true, baseClass: 'rftBlockButton', iconClass: 'rftIcon rftIconEdit'" data-dojo-attach-point="btnEdit">Edit</button>
    4         <button data-dojo-type="dijit/form/Button" class="blue" data-dojo-props="baseClass: 'rftBlockButton', iconClass: 'rftIcon rftIconPlus'" data-dojo-attach-point="btnNew">New</button>
    5         <div data-dojo-type="dojox/grid/DataGrid" data-dojo-props="autoWidth:true,autoHeight:true,structure:[{name:'Title',field:'title'}]" data-dojo-attach-point="grid"></div>
     2
     3    <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'">
     4        <h2>
     5            <span class="rftIcon rftIconSurvey"></span>
     6            <span class="headerText">Surveys</span>
     7        </h2>
    68    </div>
     9
     10    <div data-dojo-attach-point="tabContainer" data-dojo-type="dijit/layout/TabContainer" class="blue" data-dojo-props="tabPosition:'left-h',region:'center'">
     11
     12        <div data-dojo-type="dijit/layout/BorderContainer" title="Drafts" data-dojo-attach-point="draftsTab">
     13            <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region: 'center'" data-dojo-attach-point="draftsContainer">
     14            </div>
     15            <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region: 'bottom'" style="height: 40px;">
     16                <button data-dojo-type="dijit/form/Button" class="blue" data-dojo-props="baseClass: 'rftBlockButton', iconClass: 'rftIcon rftIconNew'" data-dojo-attach-event="onClick:_onNewSurvey">New survey</button>
     17            </div>
     18        </div>
     19
     20        <div data-dojo-type="dijit/layout/BorderContainer" title="Published" data-dojo-attach-point="publishedTab">
     21            <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region: 'center'" data-dojo-attach-point="publishedContainer">
     22            </div>
     23            <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region: 'bottom'" style="height: 40px;">
     24            </div>
     25        </div>
     26
     27        <div data-dojo-type="dijit/layout/BorderContainer" title="Runs" data-dojo-attach-point="runsTab">
     28            <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region: 'center'" data-dojo-attach-point="runsContainer">
     29            </div>
     30            <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region: 'bottom'" style="height: 40px;">
     31            </div>
     32        </div>
     33    </div>
     34
    735</div>
  • Dev/branches/rest-dojo-ui/client/rft/pages/surveys.js

    r407 r410  
    11define([
     2    'dojo/_base/array',
    23    'dojo/_base/declare',
    34    'dojo/_base/lang',
    4     'dojo/_base/Deferred',
    5     'dojo/data/ObjectStore',
    6     '../auth',
     5    'dojo/when',
    76    '../store',
    8     '../app/Controller',
     7    '../app/Content',
    98    '../app/Page',
     9    '../app/Router',
     10    '../ui/LineWithActionsWidget',
    1011    'dojo/text!./surveys.html'
    11 ],function(declare,lang,Deferred,ObjectStore,auth,store,Controller,Page,template){
     12],function(array,declare,lang,when,store,Content,Page,Router,LineWithActionsWidget,template){
    1213    return declare([Page],{
    1314        templateString: template,
    14         selectedObject: null,
    1515        startup: function() {
    1616            if ( this._started ) { return; }
    1717            this.inherited(arguments);
    18             this.grid.setStore(
    19                 ObjectStore({objectStore: store}),
    20                 "_design/default/_view/by_type",{key:'Survey'});
    21            
    22             this.grid.on('rowclick',lang.hitch(this,function(evt){
    23                 this.selectedObject = evt.grid.getItem(evt.rowIndex);
    24                 this.btnEdit.set('disabled',!this.selectedObject);
     18            this.refresh();
     19        },
     20        _onNewSurvey: function(){
     21            when( store.add({type:'Survey'}) )
     22            .then(function(survey) {
     23                Router.go('/survey/'+store.getIdentity(survey));
     24            });
     25        },
     26        _onPublishSurvey:function(survey){
     27            var self = this;
     28            survey.publicationDate = store.timestamp();
     29            store.put(survey).then(function(){
     30                self.refreshDrafts();
     31                self.refreshPublished();
     32            },function(err){
     33                Content.notify(err.reason,'error');
     34            });
     35        },
     36        _onDeleteSurvey:function(survey){
     37            var self = this;
     38            store.remove(store.getIdentity(survey),store.getRevision(survey))
     39            .then(function(){
     40                self.refreshDrafts();
     41            },function(err){
     42                Content.notify(err.reason,'error');
     43            });
     44        },
     45        _onEditSurvey:function(survey){
     46            Router.go('/survey/'+store.getIdentity(survey));
     47        },
     48        _onPreviewSurvey:function(survey){
     49            Router.go('/viewSurvey/'+store.getIdentity(survey),{preview:true});
     50        },
     51        _onRunSurvey:function(survey){
     52
     53        },
     54        refresh: function() {
     55            this.refreshDrafts();
     56            this.refreshPublished();
     57            this.refreshRuns();
     58        },
     59        refreshDrafts: function() {
     60            this.draftsContainer.set('content','');
     61            when(store.query("_design/surveys/_view/drafts")
     62                    ,lang.hitch(this,function(surveys){
     63                this.draftsTab.set('title','Drafts ('+surveys.length+')');
     64                array.forEach(surveys,function(survey){
     65                    var w = new LineWithActionsWidget({
     66                        title: survey.title || '(unnamed)',
     67                        actions: [{
     68                            callback: lang.hitch(this,'_onPublishSurvey',survey),
     69                            properties: {
     70                                label: 'Publish',
     71                                tooltip: 'Publish survey',
     72                                icon: 'Publish'
     73                            }
     74                        },{
     75                            callback: lang.hitch(this,'_onPreviewSurvey',survey),
     76                            properties: {
     77                                label: 'Preview',
     78                                tooltip: 'Preview survey',
     79                                icon: 'Preview'
     80                            }
     81                        },{
     82                            callback: lang.hitch(this,'_onDeleteSurvey',survey),
     83                            properties: {
     84                                label: 'Delete',
     85                                tooltip: 'Delete survey',
     86                                icon: 'Delete'
     87                            }
     88                        },{
     89                            callback: lang.hitch(this,'_onEditSurvey',survey),
     90                            properties: {
     91                                label: 'Edit',
     92                                tooltip: 'Edit survey',
     93                                icon: 'Edit'
     94                            }
     95                        }]
     96                    });
     97                    this.draftsContainer.addChild(w);
     98                },this);
    2599            }));
    26 
    27             this.grid.on('rowdblclick',lang.hitch(this,function(evt){
    28                 var obj = evt.grid.getItem(evt.rowIndex);
    29                 Controller.go('/survey/'+store.getIdentity(obj));
     100        },
     101        refreshPublished: function() {
     102            this.publishedContainer.set('content','');
     103            when(store.query("_design/surveys/_view/published")
     104                    ,lang.hitch(this,function(surveys){
     105                this.publishedTab.set('title','Published ('+surveys.length+')');
     106                array.forEach(surveys,function(survey){
     107                    var w = new LineWithActionsWidget({
     108                        title: survey.title,
     109                        actions:[{
     110                            callback: lang.hitch(this,'_onPreviewSurvey',survey),
     111                            properties: {
     112                                label: 'Preview',
     113                                tooltip: 'Preview survey',
     114                                icon: 'Preview'
     115                            }
     116                        },{
     117                            callback: lang.hitch(this,'_onRunSurvey',survey),
     118                            properties: {
     119                                label: 'Run',
     120                                tooltip: 'Run survey',
     121                                icon: 'Run'
     122                            }
     123                        }]
     124                    });
     125                    this.publishedContainer.addChild(w);
     126                },this);
    30127            }));
    31            
    32             this.btnNew.on('click',lang.hitch(this,function(){
    33                 Deferred.when( store.add({type:'Survey',creator:auth.getUser()}) )
    34                 .then(function(obj) {
    35                     Controller.go('/survey/'+store.getIdentity(obj));
    36                 });
    37             }));
    38 
    39             this.btnEdit.on('click',lang.hitch(this,function(){
    40                 if ( this.selectedObject ) {
    41                     Controller.go('/survey/'+store.getIdentity(this.selectedObject));
    42                 }
    43                
     128        },
     129        refreshRuns: function() {
     130            this.runsContainer.set('content','');
     131            when(store.query("_design/default/_view/by_type",{key:'SurveyRun'})
     132                    ,lang.hitch(this,function(surveyRuns){
     133                this.runsTab.set('title','Runs ('+surveyRuns.length+')');
     134                array.forEach(surveyRuns,function(surveyRun){
     135                    var w = new LineWithActionsWidget({
     136                        title: survey.title,
     137                        actions:[{
     138                            callback: lang.hitch(this,'_onCloseRun',surveyRun),
     139                            properties: {
     140                                label: 'Close',
     141                                tooltip: 'Close survey',
     142                                icon: 'Close'
     143                            }
     144                        }]
     145                    });
     146                    this.runsContainer.addChild(w);
     147                },this);
    44148            }));
    45149        }
  • Dev/branches/rest-dojo-ui/client/rft/pages/viewSurvey.html

    r407 r410  
    1616    </div>
    1717   
    18     <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'bottom'">
     18    <div data-dojo-attach-point="buttonsPane" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'bottom'">
    1919        <button data-dojo-type="dijit/form/Button"
    2020                type="submit"
  • Dev/branches/rest-dojo-ui/client/rft/pages/viewSurvey.js

    r407 r410  
    1313        templateString: template,
    1414        survey: null,
     15        surveyId: "",
     16        options: null,
    1517        constructor: function(){
    1618            this._dataMap = {};
     19            this.options = this.options || {};
    1720        },
    1821        startup: function() {
    1922            if ( this._started ) { return; }
    2023            this.inherited(arguments);
     24
     25
    2126            if ( this.surveyId ) {
    2227                Deferred.when(store.get(this.surveyId))
    23                 .then(lang.hitch(this,function(obj){
     28                .then(lang.hitch(this,function(survey){
     29                    if ( !survey.published ) {
     30                        this.options.preview = true;
     31                    }
     32                    if ( this.options.preview ) {
     33                        this.buttonsPane.destroyRecursive();
     34                    }
     35                    this.titleNode.innerHTML = survey.title +
     36                            (this.options.preview?' [preview]':'');
    2437                    var f = new ContentWidgetFactory();
    25                     this.survey = obj;
     38                    this.survey = survey;
    2639                    store.query(null,{keys:this.survey.questions,include_docs:true})
    2740                    .forEach(function(question){
     
    3750                }));
    3851            } else {
    39                 throw "No valid uid or survey passed!";
     52                throw new Error("No valid uid or survey passed!");
    4053            }
    4154        },
    4255        _onSubmit: function(evt) {
     56            if ( this.options.preview ) { return; }
    4357            var value = this.questionsForm.get('value');
    4458            this.questionsPane.set('content','<pre>'+JSON.stringify(value)+'</pre>');
     
    4761        },
    4862        _onCancel: function(evt) {
     63            if ( this.options.preview ) { return; }
    4964            event.stop(evt);
    5065            return false;
Note: See TracChangeset for help on using the changeset viewer.