Ignore:
Timestamp:
02/21/12 13:03:21 (13 years ago)
Author:
hendrikvanantwerpen
Message:
  • [Server] Added PUT support to API.
  • [Client] Extended questions page with Accordion and list with actions on each row.
File:
1 edited

Legend:

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

    r274 r275  
    11define(['dojo/_base/declare','dojo/_base/lang','dojo/_base/array','dojo/_base/event',
    22    'dojo/_base/Deferred','dojo/store/JsonRest','dijit/layout/ContentPane',
    3     'rft/ui/_Page','rft/ui/QuestionWidget'],
    4     function(declare,lang,array,event,Deferred,JsonRest,ContentPane,_Page,QuestionWidget) {
     3    'rft/ui/_Page','rft/ui/LineWithActionsWidget'],
     4    function(declare,lang,array,event,Deferred,JsonRest,ContentPane,_Page,LineWithActionsWidget) {
    55        return declare('rft.pages.questions',[_Page],{
    66            constructor: function() {
     
    2626                if ( !categoryContainer ) {
    2727                    var ac = new ContentPane({
    28                         title:category
     28                        title:category,
     29                        doLayout: false
    2930                    });
    3031                    categoryContainer = this.containers[category] = {
     
    4041                var question = this.questions[uid];
    4142                if ( !question ) {
    42                     var qw = new QuestionWidget({
    43                         question: q
     43                    var qw = new LineWithActionsWidget({
     44                        title: q.title,
     45                        userObject: q,
     46                        actions: {
     47                            'Edit': lang.hitch(this,'_editQuestion')
     48                        }
    4449                    });
    4550                    qw.startup();
     
    4853                        widget: qw
    4954                    }
     55                } else {
     56                    // update info
     57                    question.question = q;
     58                    question.widget.title = q.title;
     59                    question.widget.userObject = q;
     60                    question.widget.refresh();
    5061                }
    5162                var container = this._getContainerForQuestion(q);
    5263                question.widget.placeAt(container.containerNode);
    53                 container.resize();
    5464            },
    5565            onNewQuestion: function() {
    5666                Deferred.when( this._store.add({}) )
    5767                .then(lang.hitch(this,function(question){
    58                     this.questionForm.reset();
    59                     this.questionForm.set('value',question);
    60                     this.questionDialog.show();
     68                    this._editQuestion(question);
    6169                }));
     70            },
     71            _editQuestion: function(question) {
     72                this.questionForm.reset();
     73                this.questionForm.set('value',question);
     74                this.questionDialog.show();
    6275            },
    6376            onSaveQuestion: function(evt) {
Note: See TracChangeset for help on using the changeset viewer.