Ignore:
Timestamp:
03/04/12 15:48:42 (13 years ago)
Author:
hendrikvanantwerpen
Message:

[Server] Refactored model classes with some meta-programming. Specific classes only define their fields and inherit from class RdfObject?. Changes to handle the new model objects correctly.
[Client] Added rft/store module for uniform resource access. Removed dependencies on 'uid' field name. Added support for references without loading full object nor exposing uri.
[Client] Added reset() to QuestionWidget?.
[RDFAPI] Fixed PHP warning.

Location:
Dev/branches/rest-dojo-ui/client/rft
Files:
1 added
7 edited

Legend:

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

    r288 r303  
    11define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/array','dojo/_base/event',
    2     'dojo/_base/Deferred','dojo/dom-construct','dojo/store/JsonRest','dijit/layout/ContentPane','dijit/TitlePane',
     2    'dojo/_base/Deferred','dojo/dom-construct','rft/store','dijit/TitlePane',
    33    'rft/ui/_Page','rft/ui/LineWithActionsWidget'],
    4     function(declare,lang,array,event,Deferred,domConstruct,JsonRest,ContentPane,TitlePane,_Page,LineWithActionsWidget) {
     4    function(declare,lang,array,event,Deferred,domConstruct,store,TitlePane,_Page,LineWithActionsWidget) {
    55        return declare('rft.pages.questions',[_Page],{
    66            constructor: function() {
     
    99            },
    1010            onVisit: function() {
    11                 this._store = new JsonRest({
    12                     target:"../server/api.php/data/Question/",
    13                     idProperty: 'uid'
    14                 });
     11                this._store = store.getStore('Question');               
    1512                this._refresh(true);
    1613            },
    1714            _refresh: function(initial) {
    18                 Deferred.when( this._store.query() ).then(lang.hitch(this,function(results){
     15                Deferred.when( this._store.query() )
     16                .then(lang.hitch(this,function(results){
    1917                    array.forEach(results,lang.hitch(this,'_addQuestion'));
    2018                    initial && this.accordion.selectChild(true);
     
    2220            },
    2321            _addQuestion: function(q) {
    24                 var uid = q.uid;
     22                var uid = q.getUid();
    2523                var question = this.questions[uid];
    2624                if ( !question ) {
     
    5452                var placeNode = this.accordion.domNode;
    5553                var placePos = 'last';
    56                 array.some(widgets,lang.hitch(this,function(widget,idx) {
     54                array.some(widgets,lang.hitch(this,function(widget) {
    5755                    if ( widget.title == category ) {
    5856                        containerWidget = widget;
  • Dev/branches/rest-dojo-ui/client/rft/pages/sessions.html

    r274 r303  
    2424            var submitHandler = lang.hitch(that,function(evt){
    2525                var newObj = this.form.get('value');
    26                 debugger;
    2726                // mixin newObj in obj.
    2827                // store.put(newObj);
  • Dev/branches/rest-dojo-ui/client/rft/pages/survey.html

    r292 r303  
    11<div data-dojo-type="rft.pages.survey">
    22    <h1 data-rft-attach-point="header">(default)</h1>
     3    <div>Created by <span data-rft-attach-point="creator"></span><div>
    34    <form data-dojo-type="dijit.form.Form" data-rft-attach-point="form" data-rft-attach-event="onSubmit:onSave">
    45        <div style="display: block; clear: both;">
  • Dev/branches/rest-dojo-ui/client/rft/pages/survey.js

    r292 r303  
    1 define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/event','dojo/_base/Deferred','dojo/store/JsonRest','rft/ui/_Page'],
    2     function(declare,lang,event,Deferred,JsonRest,_Page){
     1define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/event','dojo/_base/Deferred','rft/store','rft/ui/_Page'],
     2    function(declare,lang,event,Deferred,store,_Page){
    33        return declare('rft.pages.survey',[_Page],{
    44            object: null,
    55            postCreate: function() {
    66                this.inherited(arguments);
    7                 this._store = new JsonRest({
    8                     target:"../server/api.php/data/Survey/",
    9                     idProperty: 'uid'
    10                 });
     7                this._store = store.getStore('Survey');
    118            },
    129            onVisit: function() {
     
    1613                        this.object = obj;
    1714                        this.setFields(obj);
     15                        return Deferred.when( obj.creator && store.dereference(obj.creator) );
     16                    }))
     17                    .then(lang.hitch(this,function(obj){
     18                        this.creator.innerHTML = (obj && obj.email) || 'unknown';
    1819                    }));
    1920                } else {
  • Dev/branches/rest-dojo-ui/client/rft/pages/surveys.js

    r292 r303  
    1 define(['dojo/_base/declare','dojo/_base/lang','dojo/store/JsonRest','dojo/data/ObjectStore','rft/content','rft/ui/_Page'],
    2     function(declare,lang,JsonRest,ObjectStore,content,_Page){
     1define(['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){
    33        return declare('rft.pages.surveys',[_Page],{
    44            selectedObject: null,
    55            postCreate: function() {
    6                 this._store = new JsonRest({
    7                     target:"../server/api.php/data/Survey/",
    8                     idProperty: 'uid'
    9                 });
     6                this._store = store.getStore('Survey');
    107            },
    118            onVisit: function() {
     
    1411                this.grid.on('rowclick',lang.hitch(this,function(evt){
    1512                    this.selectedObject = evt.grid.getItem(evt.rowIndex);
    16                     this.btnEdit.set('disabled',!!this.selectedObject);
     13                    this.btnEdit.set('disabled',!this.selectedObject);
    1714                }));
    1815
    1916                this.grid.on('rowdblclick',lang.hitch(this,function(evt){
    2017                    var obj = evt.grid.getItem(evt.rowIndex);
    21                     content.goTo('/survey',{uid:obj.uid});
     18                    content.goTo('/survey',{uid:obj.getUid()});
    2219                }));
    23                
     20                               
    2421                this.btnNew.on('click',lang.hitch(this,function(){
    25                     this._store.add({},function(obj) {
    26                         content.goTo('/survey',{uid:this.selectedObject.uid});
     22                    Deferred.when( this._store.add({'creator':auth.getUser()}) )
     23                    .then(function(obj) {
     24                        content.goTo('/survey',{uid:obj.getUid()});
    2725                    });
    2826                }));
     
    3028                this.btnEdit.on('click',lang.hitch(this,function(){
    3129                    if ( this.selectedObject ) {
    32                         content.goTo('/survey',{uid:this.selectedObject.uid});
     30                        content.goTo('/survey',{uid:this.selectedObject.getUid()});
    3331                    }
    3432                   
  • Dev/branches/rest-dojo-ui/client/rft/ui/QuestionWidget.js

    r288 r303  
    1 define(['dojo/_base/declare','dojo/dom-construct','dijit/_WidgetBase',
     1define(['dojo/_base/declare','dojo/_base/lang','dojo/dom-construct','dijit/_WidgetBase',
    22    'dijit/_TemplatedMixin','dijit/_WidgetsInTemplateMixin',
    33    'dojo/text!./templates/QuestionWidget.html','dijit/form/TextBox',
    44    'dijit/form/Textarea','./MultipleChoiceWidget'],
    5     function(declare,domConstruct,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString,TextBox,Textarea,MultipleChoiceWidget){
     5    function(declare,lang,domConstruct,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString,TextBox,Textarea,MultipleChoiceWidget){
    66        return declare('rft.ui.QuestionWidget',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{
    77            templateString: templateString,
    88            mode: 'view', // view || edit
    99            name: '',
     10            value: null,
    1011            _type: null,
    1112            _widgetCache: null,
    1213            constructor: function() {
    1314                this.inherited(arguments);
     15                this.value = {};
    1416                this._widgetCache = {};
    1517            },
    1618            postCreate: function() {
     19                this._resetValue = this.value;
    1720                this.typeSelector.set('disabled', this.mode == 'edit');
    1821            },
    1922            _setValueAttr: function(value) {
    20                 value.type && this._onTypeChange(value.type);
     23                this.value = value;
     24                this._onTypeChange(value.type || 'string');
    2125                this.ourForm.set('value',value);
    2226            },
    2327            _getValueAttr: function() {
    24                 return this.ourForm.get('value');
     28                var value = this.ourForm.get('value');
     29                lang.mixin(this.value,value);
     30                return this._question;
    2531            },
    2632            _onTypeChange: function(type) {
     
    6066                }
    6167                return widget;
     68            },
     69            reset: function() {
     70                this.ourForm.reset();
     71                this._setValueAttr(this._resetValue);
    6272            }
    6373        });
  • Dev/branches/rest-dojo-ui/client/rft/ui/templates/QuestionWidget.html

    r288 r303  
    22    <form data-dojo-type="dijit.form.Form" data-dojo-attach-point="ourForm">
    33        <fieldset>
    4             <input data-dojo-type="dijit.form.TextBox" name="uid" type="text" class="dijitHidden" />
    54            <label for="code" class="loginLabel">Code</label>
    65            <input data-dojo-type="dijit.form.TextBox" name="code" type="text" class="loginInput" />
Note: See TracChangeset for help on using the changeset viewer.