Changeset 414


Ignore:
Timestamp:
11/24/12 18:13:18 (12 years ago)
Author:
hendrikvanantwerpen
Message:

Small issues for db name, widgets, startup.

Don't start application when database is not configured correctly.
Refactored edit widgets to use DefaultEdit?.
Fixed bug in getItems of Lists.
Renamed database to 'qed'.

Location:
Dev/branches/rest-dojo-ui
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • Dev/branches/rest-dojo-ui/client/config/config.sh

    r410 r414  
    11#!/bin/sh
    2 node ../dojo/dojo.js load=config/db
     2nodejs ../dojo/dojo.js load=config/db
  • Dev/branches/rest-dojo-ui/client/config/db.js

    r410 r414  
    9191            });
    9292        },function(){
    93             console.log("Checking database 'rft'");
    94             return req('get','rft')
    95             .then(function(){
    96                 console.log("Database 'rft' found.");
    97             },function(){
    98                 console.log("Creating database 'rft'");
    99                 return req('put','/rft');
     93            console.log("Checking database 'qed'");
     94            return req('get','qed')
     95            .then(function(res){
     96                if (res.error) {
     97                    console.log("Creating database 'qed'");
     98                    return req('put','/qed');
     99                } else {
     100                    console.log("Database 'qed' found.");
     101                }
     102            },function(res){
     103                console.log("Creating database 'qed'");
     104                return req('put','/qed');
    100105            });
    101106        },function(){
  • Dev/branches/rest-dojo-ui/client/config/docs.js

    r410 r414  
    11define([],function(){
    22    return {
    3         "_users/rft_admin": {
     3        "_users/qed_admin": {
    44            __configAction: "ignore",
    5             _id: "org.couchdb.user:rft_admin",
    6             name: "rft_admin",
     5            _id: "org.couchdb.user:qed_admin",
     6            name: "qed_admin",
    77            password: "Welkom01",
    8             roles: [ "rft_admin" ],
     8            roles: [ "qed_admin" ],
    99            type: "user"
    1010        },
    11         "rft/_security": {
     11        "qed/_security": {
    1212            __configAction: "ignore",
    1313            admins: {
    1414                names: [],
    15                 roles: ["rft_admin"]
     15                roles: ["qed_admin"]
    1616            },
    1717            readers: {
    1818                names: [],
    19                 roles: ["rft_user"]
     19                roles: ["qed_user"]
    2020            }
    2121        },
    22         "rft/_design/default": {
     22        "qed/_design/default": {
    2323            __configAction: "replace",
    2424            _id: "_design/default",
     
    3636            }
    3737        },
    38         "rft/_design/questions": {
     38        "qed/_design/questions": {
    3939            __configAction: "replace",
    4040            _id: "_design/questions",
     
    7575                        if( doc.type !== 'Question' ){ return; }
    7676                        emit(doc.topic);
    77                     }
     77                    },
     78                    reduce: function(key, values, rereduce) { return null; }
    7879                },
    7980                published_topics: {
     
    8182                        if ( doc.type !== 'Question' || !doc.publicationDate ) { return; }
    8283                        emit(doc.topic);
    83                     }
     84                    },
     85                    reduce: function(key, values, rereduce) { return null; }
    8486                }
    8587            }
    8688        },
    87         "rft/_design/surveys": {
     89        "qed/_design/surveys": {
    8890            __configAction: "replace",
    8991            _id: "_design/surveys",
  • Dev/branches/rest-dojo-ui/client/data/.htaccess

    r410 r414  
    11RewriteEngine on
    2 RewriteRule couch/(.*) http://localhost:5984/rft/$1 [P,QSA]
    3 RewriteRule elastic http://localhost:9200/rft/_search [P,QSA]
     2RewriteRule couch/(.*) http://localhost:5984/qed/$1 [P,QSA]
     3RewriteRule elastic http://localhost:9200/qed/_search [P,QSA]
  • Dev/branches/rest-dojo-ui/client/index.html

    r411 r414  
    1212            <div class="topbar" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'">
    1313                <a href="#!/"><h1>QED</h1></a>
    14                 <div data-dojo-type="rft/ui/MainMenu"></div>
     14                <div id="menu"></div>
    1515            </div>
    1616        </div>
  • Dev/branches/rest-dojo-ui/client/rft/pages/questions.js

    r411 r414  
    2020                'class': 'orange',
    2121                itemActions: {
     22                    Delete: {
     23                        callback: lang.hitch(this,"onDeleteQuestion"),
     24                        icon: 'Delete',
     25                        description: 'Delete question'
     26                    },
    2227                    Edit: {
    2328                        callback: lang.hitch(this,"onEditQuestion"),
     
    4045            }));
    4146        },
     47        onDeleteQuestion: function(question) {
     48            store.remove(store.getIdentity(question),store.getRevision(question))
     49            .then(function(){
     50                Content.notify("Question deleted.");
     51            },function(err){
     52                Content.notify(err.reason,'error');
     53            });
     54        },
    4255        onEditQuestion: function(question) {
    4356            Router.go("/question/"+question._id);
     
    4760            store.put(question)
    4861            .then(function(){
    49                 Content.notify("Question puplished.");
     62                Content.notify("Question published.");
    5063            },function(err){
    5164                Content.notify(err.reason,'error');
  • Dev/branches/rest-dojo-ui/client/rft/pages/surveys.html

    r410 r414  
    1414            </div>
    1515            <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>
    1716            </div>
    1817        </div>
     
    3332    </div>
    3433
     34    <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region: 'bottom'" style="height: 40px;">
     35        <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>
     36    </div>
     37
    3538</div>
  • Dev/branches/rest-dojo-ui/client/rft/pages/surveys.js

    r410 r414  
    2222            .then(function(survey) {
    2323                Router.go('/survey/'+store.getIdentity(survey));
     24            },function(err){
     25                Content.notify(err.reason,'error');
    2426            });
    2527        },
  • Dev/branches/rest-dojo-ui/client/rft/run.js

    r410 r414  
    22    'dojo/_base/array',
    33    'dojo/parser',
     4    'rft/app/Content',
     5    'rft/app/Page',
    46    'rft/app/Router',
     7    'rft/ui/MainMenu',
    58    'rft/routes',
     9    'rft/store',
    610    'rft/stddeps',
    711    'dojo/domReady!'
    8 ],function(array,parser,router,routes) {
     12],function(array,parser,Content,Page,Router,MainMenu,routes,store) {
    913    parser.parse();
    10     array.forEach(routes,function(route){
    11         router.register(route);
     14
     15    store.info()
     16    .then(function(){
     17        new MainMenu({},"menu").startup();
     18        array.forEach(routes,function(route){
     19            Router.register(route);
     20        });
     21        Router.startup();
     22    },function(){
     23        Content.startup();
     24        Content.set(new Page({
     25            templateString: "<div>Application database is not properly configured. Contact your system administrator.</div>"
     26        }));
    1227    });
    13     router.startup();
    1428});
  • Dev/branches/rest-dojo-ui/client/rft/store/CouchStore.js

    r410 r414  
    3535        getRevision: function(object){
    3636            return object[this.revProperty];
     37        },
     38        info: function(){
     39            var dfd = new Deferred();
     40            xhr("GET", {
     41                url: this.target,
     42                handleAs: "json",
     43                headers: {
     44                    Accept: this.accepts
     45                }
     46            }).then(function(result){
     47                if ( result.error ) {
     48                    dfd.reject(result.reason);
     49                } else {
     50                    dfd.resolve(result);
     51                }
     52            }, function(err){
     53                dfd.reject(getCouchError(err));
     54            });
     55            return dfd.promise;
    3756        },
    3857        get: function(id){
  • Dev/branches/rest-dojo-ui/client/rft/ui/MainMenu.js

    r407 r414  
    1 define(['dojo/_base/declare','dijit/_WidgetBase',
    2     'dijit/_TemplatedMixin','dijit/_WidgetsInTemplateMixin','dojo/text!./templates/MainMenu.html'],
    3     function(declare,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,template){
    4         return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{
    5             templateString: template
    6         });
     1define([
     2    'dojo/_base/declare',
     3    'dijit/_WidgetBase',
     4    'dijit/_TemplatedMixin',
     5    'dijit/_WidgetsInTemplateMixin',
     6    'dojo/text!./templates/MainMenu.html'
     7],function(declare,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,template){
     8    return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{
     9        templateString: template
    710    });
     11});
  • Dev/branches/rest-dojo-ui/client/rft/ui/QuestionEditorPreview.js

    r407 r414  
    11define([
     2    'dojo/_base/array',
    23    'dojo/_base/declare',
    34    'dojo/_base/lang',
     
    67    './QuestionEditorPreviewItem',
    78    './lists/OrderedList'
    8 ], function(declare, lang, domConstruct, registry, QuestionEditorPreviewItem, OrderedList) {
     9], function(array, declare, lang, domConstruct, registry, QuestionEditorPreviewItem, OrderedList) {
    910    return declare([OrderedList], {
    1011        baseClass: 'surveyEditorPreview',
     
    2627        },
    2728        getItems: function() {
    28             return this.source.getAllNodes()
    29             .map(function(node){
    30                 return registry.byNode(node).get('value');
    31             },this);
     29            return array.map(
     30                this.source.getAllNodes(),
     31                function(node){
     32                    return registry.byNode(node).get('value');
     33                },this);
    3234        }
    3335    });
  • Dev/branches/rest-dojo-ui/client/rft/ui/QuestionEditorPreviewItem.js

    r407 r414  
    6262                this.innerWidget.set('readOnly',true);
    6363            }
    64             this.titleNode.innerHTML = (this.item.code||"(no code)")+" : "+this.item.type+" [preview]";
     64            this.titleNode.innerHTML = this.item.type+" [preview]";
    6565        },
    6666        _showEditWidget: function() {
     
    7171                this.innerWidget.startup();
    7272            }
    73             this.titleNode.innerHTML = (this.item.code||"(no code)")+" : "+this.item.type+" [editing]";
     73            this.titleNode.innerHTML = this.item.type+" [editing]";
    7474        },
    7575        onClose: function() {},
  • Dev/branches/rest-dojo-ui/client/rft/ui/content/ContentWidgetFactory.js

    r407 r414  
    99    'dijit/form/Button',
    1010    'dijit/form/CheckBox',
     11    'dijit/form/Form',
    1112    'dijit/form/NumberSpinner',
    1213    'dijit/form/RadioButton',
     
    1617    './../lists/_EditableListMixin',
    1718    './../lists/OrderedList'
    18 ],function(array, declare, lang, domConstruct, _TemplatedMixin, _WidgetBase, _Container, Button, CheckBox, NumberSpinner, RadioButton, Textarea, TextBox, TableContainer, _EditableListMixin, OrderedList) {
     19],function(array, declare, lang, domConstruct, _TemplatedMixin, _WidgetBase, _Container, Button, CheckBox, Form, NumberSpinner, RadioButton, Textarea, TextBox, TableContainer, _EditableListMixin, OrderedList) {
    1920    var factory = declare(null, {
    2021        createViewWidget: function(/*Object*/options) {
     
    9596    });
    9697
     98    var DefaultEdit = declare([Form,_Container],{
     99        type: null,
     100        addChild: function(widget) {
     101            domConstruct.create("label",{
     102                innerHTML: widget.title || ''
     103            },this.containerNode,'last');
     104            this.inherited(arguments,[widget]);
     105        },
     106        _getValueAttr: function() {
     107            var val = this.inherited(arguments);
     108            val.type = this.type;
     109            return val;
     110        }
     111    });
     112
    97113    var HeaderView = declare([_WidgetBase], {
    98114        postCreate: function() {
     
    101117    });
    102118
    103     var HeaderEdit = declare([_WidgetBase, _Container], {
     119    var HeaderEdit = declare([DefaultEdit], {
     120        type: 'Header',
     121        postCreate: function() {
     122            this.inherited(arguments);
     123            this.addChild(new TextBox({
     124                title: 'Content',
     125                name: 'content'
     126            }));
     127        }
     128    });
     129
     130    var TextView = declare([_WidgetBase], {
     131        postCreate: function() {
     132            this.domNode.innerHTML = "<p>"+this.options.content+"</p>";
     133        }
     134    });
     135
     136    var TextEdit = declare([DefaultEdit], {
     137        type: 'Text',
     138        postCreate: function() {
     139            this.inherited(arguments);
     140            this.addChild(new Textarea({
     141                title: 'Content',
     142                name: 'content'
     143            }));
     144        }
     145    });
     146
     147    var DividerView = declare([_WidgetBase], {
     148        postCreate: function() {
     149            this.domNode.innerHTML = "<hr>";
     150        }
     151    });
     152
     153    var DefaultInputEdit = declare([DefaultEdit],{
     154        postCreate: function() {
     155            this.inherited(arguments);
     156            this.addChild(new TextBox({
     157                title: 'Text',
     158                name: 'text'
     159            }));
     160        }
     161    });
     162
     163    var StringInputView = declare([_WidgetBase, _Container],{
    104164        _textBox: null,
    105165        postCreate: function() {
    106             this._textBox = new TextBox();
     166            this._textBox = new TextBox({
     167                name: this.options.code || ''
     168            });
    107169            this.addChild(this._textBox);
    108170            this._textBox.startup();
    109171        },
    110         _setValueAttr: function(value) {
    111             this._textBox.set('value', value.content || "");
    112         },
    113         _getValueAttr: function() {
    114             return { type: 'Header',
    115                  content: this._textBox.get('displayedValue')
    116             };
    117         }
    118     });
    119 
    120     var TextView = declare([_WidgetBase], {
    121         postCreate: function() {
    122             this.domNode.innerHTML = "<p>"+this.options.content+"</p>";
    123         }
    124     });
    125 
    126     var TextEdit = declare([_WidgetBase, _Container], {
    127         _textArea: null,
    128         postCreate: function() {
    129             this._textArea = new Textarea();
    130             this.addChild(this._textArea);
    131             this._textArea.startup();
    132         },
    133         _setValueAttr: function(value) {
    134             this._textArea.set('value', value.content || "");
    135         },
    136         _getValueAttr: function() {
    137             return { type: 'Text',
    138                  content: this._textArea.get('displayedValue')
    139             };
    140         }
    141     })
    142 
    143     var DividerView = declare([_WidgetBase], {
    144         postCreate: function() {
    145             this.domNode.innerHTML = "<hr>";
    146         }
    147     });
    148 
    149     var StringInputView = declare([_WidgetBase, _Container],{
    150         _textBox: null,
    151         postCreate: function() {
    152             this._textBox = new TextBox({
    153                 name: this.options.code || ''
    154             });
    155             this.addChild(this._textBox);
    156             this._textBox.startup();
    157         },
    158172        _setReadOnlyAttr: function(value) {
    159173            this._textBox.set('readOnly', value);
     
    170184    });
    171185
    172     var StringInputEdit = declare([_WidgetBase, _Container],{
    173         _codeInput: null,
    174         postCreate: function() {
    175             var table = new TableContainer({ cols: 1, customClass: "labelsAndValues"} );
    176 
    177             this._codeInput = new TextBox({
    178                 title: "Code"
    179             });
    180             table.addChild(this._codeInput);
    181             this._codeInput.startup();
    182 
    183             this.addChild(table);
    184             table.startup();
    185         },
    186         _getValueAttr: function() {
    187             return {
    188                 type: "StringInput",
    189                 code: this._codeInput.get('value') || ""
    190             };
    191         },
    192         _setValueAttr: function(value) {
    193             this._codeInput.set('value', value.code || "");
    194         }
     186    var StringInputEdit = declare([DefaultInputEdit],{
     187        type: 'StringInput'
    195188    });
    196189
     
    217210    });
    218211
    219     var TextInputEdit = declare([_WidgetBase, _Container], {
    220         _codeInput: null,
    221         _maxLengthInput: null,
    222         postCreate: function() {
    223             var table = new TableContainer({ cols: 1, customClass: "labelsAndValues"} );
    224 
    225             this._codeInput = new TextBox({
    226                 title: "Code"
    227             });
    228             table.addChild(this._codeInput);
    229             this._codeInput.startup();
    230 
    231             this._maxLengthInput = new NumberSpinner({
     212    var TextInputEdit = declare([DefaultInputEdit], {
     213        type: 'TextInput',
     214        postCreate: function() {
     215            this.inherited(arguments);
     216            this.addChild(new NumberSpinner({
     217                name: 'maxLength',
    232218                title: "Maximum length",
    233219                constraints: {
    234220                    min: 0
    235221                }
    236             });
    237             table.addChild(this._maxLengthInput);
    238             this._maxLengthInput.startup();
    239 
    240             this.addChild(table);
    241             table.startup();
    242         },
    243 
    244         _setValueAttr: function(value) {
    245             this._codeInput.set('value', value.code || "");
    246             this._maxLengthInput.set('value', value.maxLength);
    247         },
    248         _getValueAttr: function() {
    249             return {
    250                 type: "TextInput",
    251                 code: this._codeInput.get('value') || "",
    252                 maxLength: this._maxLengthInput.get('value')
    253             };
     222            }));
    254223        }
    255224    });
     
    280249    });
    281250
    282     var IntegerInputEdit = declare([_WidgetBase, _Container], {
    283         _codeInput: null,
    284         _minInput: null,
    285         _maxInput: null,
    286         postCreate: function() {
    287             var table = new TableContainer({ cols: 1, customClass: "labelsAndValues"} );
    288 
    289             this._codeInput = new TextBox({
    290                 title: "Code"
    291             });
    292             table.addChild(this._codeInput);
    293             this._codeInput.startup();
    294 
    295             this._minInput = new NumberSpinner({
    296                 title: "Minimum"
    297             });
    298             table.addChild(this._minInput);
    299             this._minInput.startup();
    300 
    301             this._maxInput = new NumberSpinner({
    302                 title: "Maximum"
    303             });
    304             table.addChild(this._maxInput);
    305             this._maxInput.startup();
    306 
    307             this._stepInput = new NumberSpinner({
    308                 title: "Step"
    309             });
    310             table.addChild(this._stepInput);
    311             this._stepInput.startup();
    312 
    313             this.addChild(table);
    314             table.startup();
    315         },
    316 
    317         _setValueAttr: function(value) {
    318             this._codeInput.set('value', value.code || "");
    319             this._minInput.set('value', value.min);
    320             this._maxInput.set('value', value.max);
    321             this._stepInput.set('value', value.step);
    322         },
    323         _getValueAttr: function() {
    324             return {
    325                 type: "IntegerInput",
    326                 code: this._codeInput.get('value') || "",
    327                 min: this._minInput.get('value'),
    328                 max: this._maxInput.get('value'),
    329                 step: this._stepInput.get('value')
    330             };
     251    var IntegerInputEdit = declare([DefaultInputEdit], {
     252        type: 'IntegerInput',
     253        postCreate: function() {
     254            this.inherited(arguments);
     255            this.addChild(new NumberSpinner({
     256                title: "Minimum",
     257                name: 'min'
     258            }));
     259            this.addChild(new NumberSpinner({
     260                title: "Maximum",
     261                name: 'max'
     262            }));
     263            this.addChild(new NumberSpinner({
     264                title: "Step",
     265                name: 'step'
     266            }));
    331267        }
    332268    });
  • Dev/branches/rest-dojo-ui/client/rft/ui/templates/MainMenu.html

    r407 r414  
    1212        </div>
    1313        <div class="rftMainMenuButton" data-dojo-type="rft/ui/MenuBarLink" data-dojo-props="path:'/results'">Results</div>
    14         <div class="rftMainMenuButton" data-dojo-type="rft/ui/MenuBarLink" id="loginMenu">Logout</div>
     14        <div class="rftMainMenuButton" data-dojo-type="rft/ui/MenuBarLink">Logout</div>
    1515    </div>
    1616</div>
  • Dev/branches/rest-dojo-ui/docs/jsonformat.txt

    r410 r414  
     1Document types
     2==============
     3
     4
     5Question types
     6==============
     7
     8
     9
    110sessions
    211========
     
    4352    topic: ''
    4453    categories: []
    45     content: [{ type:'contentTypeId', /* custom content element fields */ } /* and more ... */]
     54    content: [{ type:'contentTypeId', text: '' || ['' ...], /* custom content element fields */ } /*, and more ... */]
    4655}
Note: See TracChangeset for help on using the changeset viewer.