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/app
Files:
1 added
1 moved

Legend:

Unmodified
Added
Removed
  • Dev/branches/rest-dojo-ui/client/rft/app/Router.js

    r407 r410  
    44    'dojo/io-query',
    55    'dojo/topic',
    6     './Page',
    7     'dijit/registry'
    8 ],function(declare,hash,ioQuery,topic,Page,registry){
     6    './Content',
     7    './Page'
     8],function(declare,hash,ioQuery,topic,Content,Page){
    99
    10 
    11     var Controller = declare(null,{
     10    var Router = declare(null,{
    1211        _started: false,
    1312        _routes: null,
    14         _container: null,
    1513        _previousHash: null,
    16         _previousContent: null,
    1714
    1815        _paramMatch: /:(\w[\w\d]*)/g,
    19         _paramReplace: "([^\\/]+)",
     16        _paramReplace: "([^\\/!]+)",
    2017
    2118        constructor: function() {
     
    2421        startup: function() {
    2522            if ( this._started ) { return; }
     23            if ( !Content._started ) {
     24                Content.startup();
     25            }
     26            this._started = true;
    2627
    2728            var self = this;
    28 
    29             this._container = registry.byId('content');
    30             if ( !this._container || !this._container.addChild ) {
    31                 throw new Error("Cannot find container widget with id 'content'.");
    32             }
    33             this._started = true;
    3429
    3530            if ( hash() === "" ) {
     
    4237        },
    4338        register: function(route) {
     39            if ( this._started ) {
     40                console.warn('Registering routes after startup() is called is discouraged.');
     41            }
    4442            var self = this;
    4543            var callback;
    4644            if ( route.callback ) {
    4745                callback = function(params){
    48                     self._setContent(route.callback(params));
     46                    Content.set(route.callback(params));
    4947                };
    5048            } else if ( route.redirect ) {
     
    5452            } else if ( route.constructor ) {
    5553                callback = function(params){
    56                     self._setContent( new route.constructor(params) );
     54                    Content.set( new route.constructor(params) );
    5755                };
    5856            }
     
    7573                        }
    7674            path = path.replace(this._paramMatch, this._paramReplace);
    77             route.regexp = new RegExp('^!'+path+'(!.*)?$');
     75            route.regexp = new RegExp('^!'+path+'(!(.*))?$');
    7876            return route;
    7977        },
     
    9492                    }
    9593
    96                     if ( result.length > numParams+1 ) {
    97                         params.options = ioQuery.queryToObject(result[numParams]);
     94                    if ( result.length > numParams+1 && result[numParams+2] ) {
     95                        params.options = ioQuery.queryToObject(result[numParams+2]);
    9896                    }
    9997
     
    126124            return hash;
    127125        },
    128         _setContent: function(widget) {
    129             if ( this._previousContent ) {
    130                 this._previousContent.destroyRecursive();
    131                 this._previousContent = null;
    132             }
    133             widget.region = 'center';
    134             this._container.addChild(widget);
    135             this._previousContent = widget;
    136         },
    137126        _defaultCallback: function() {
    138             this._setContent(new Page({
     127            Content.set(new Page({
    139128                templateString: "<div>Requested page not found. Go <a href=\"#!/\">home</a>.</div>"
    140129            }));
     
    142131    });
    143132
    144     return new Controller();
     133    return new Router();
    145134});
Note: See TracChangeset for help on using the changeset viewer.