Ignore:
Timestamp:
07/11/12 18:45:51 (13 years ago)
Author:
tjcschipper
Message:
  • surveyEditor more or less works! Only needed change is addition of "topic" property in question objects (database-side), and the change from "category"(string) to "categories"(string[]).
  • surveyEditor still needs removal function and infofunction to be written properly!
  • Added all files belonging to SurveyAdvanced?. Most do not work properly yet, but at least there will not be a 404 page when you click btnPreview on survey.html.
File:
1 edited

Legend:

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

    r354 r355  
    11define([
    22    'dojo/_base/declare',
     3    'dojo/_base/array',
     4    'dijit/registry',
    35    'dojo/_base/lang',
    46    'dojo/fx',
     
    1214    ],function(
    1315        declare,
     16        baseArray,
     17        registry,
    1418        lang,
    1519        fx,
     
    2428        return declare('rft.ui.Selector',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{
    2529            templateString: templateString,
    26             title: "The professional as a participant",
     30            title: "ERROR: NULL_TOPIC",
    2731            baseClass: 'rftSelector',
    2832            modifiers: 'blue',
     33            currentlySelectedId: null,
     34            controller: null,   // Use events/pubsub instead of a controller variable? Decoupling!
     35
    2936            postCreate: function() {
    3037                domClass.add(this.domNode, this.modifiers);
    3138                domClass.add(this.selectedColorNode, "pending");
    32                
     39                this.domNode.dataset["topic"] = this.topic;
     40
    3341                new LineWithActionsWidget({
    34                     title: this.title,
     42                    title: this.topic,
    3543                    modifiers: this.modifiers,
    3644                    actions: {
    3745                        "AddToSurvey" : {
    38                             callback: function(arg){},
     46                            callback: lang.hitch(this, this.includeQuestion),
    3947                            properties: {
    4048                                blockButton: true,
     
    4654                    }
    4755                },this.titleNode);
    48                
     56
    4957                this.selectorLine = new LineWithActionsWidget({
    5058                    title: 'None',
     
    6371                },this.selectedItemNode);
    6472            },
    65             _toggleDropdown: function(selectorLine) {
     73            _toggleDropdown: function() {
     74
    6675                var node = this.optionsNode;
    6776                var show = fx.wipeIn({
     
    94103                };
    95104            },
    96             addQuestion: function(question) {
    97                 new LineWithActionsWidget({
    98                     title: question.title,
    99                     question: question,
    100                     actions: {
    101                         "InfoHover" : {
    102                             callback: this.infoFunction,
    103                             properties: {
    104                                 blockButton: false,
    105                                 showLabel: false,
    106                                 icon: "Inspect"
     105            addQuestion: function(questionId) {
     106                var question = this.controller.GetQuestion(questionId);
     107                if (question) {
     108                    var w = new LineWithActionsWidget({
     109                        title: question.title,
     110                        questionId: questionId,
     111                        actions: {
     112                            "InfoHover" : {
     113                                callback: dojo.partial(this.infoFunction, this),
     114                                properties: {
     115                                    blockButton: false,
     116                                    showLabel: false,
     117                                    icon: "Inspect"
     118                                }
    107119                            }
    108120                        }
    109                     }
    110                 }).placeAt(this.optionsNode);
     121                    });
     122                    w.placeAt(this.optionsNode);
     123                    w.on("Click", lang.hitch(this, function(){
     124                        this.selectQuestion(questionId);
     125                        this._toggleDropdown();
     126                    }, questionId));
     127
     128                }   
    111129            },
    112             infoFunction: function(){
    113                 alert("Some info here!");text
     130            infoFunction: function(selector) {
     131                var question = selector.controller.GetQuestion(this.questionId);
     132                console.log(question);
     133                alert("Some info here!");
     134            },
     135            includeQuestion: function() {
     136                if (this.currentlySelectedId) {
     137                    this.controller.IncludeQuestion(this.currentlySelectedId)
     138                } else {
     139                    return false;
     140                }
     141            },
     142            selectQuestion: function(questionId) {
     143                /* TODO: TEST THOROUGHLY! */
     144                var question = this.controller.GetQuestion(questionId);
     145                if (question) {
     146                    this.currentlySelectedId = questionId;
     147                    this.selectorLine.questionId = questionId;
     148                    this.selectorLine.set("title", question.title);
     149                    // Iterate through optionsNode, add "selected" class to currently selected node
     150                    baseArray.forEach(this.optionsNode.childNodes, function(node, index){
     151                        var line = registry.byNode(node);
     152                        if (line) {
     153                            if (line.questionId == this.currentlySelectedId) {
     154                                domClass.add(line.domNode, "inheritBgColor light");
     155                            } else {
     156                                domClass.remove(line.domNode, "inheritBgColor light");
     157                            }
     158                        }
     159                    }, this);
     160                }
    114161            }
    115162        });
Note: See TracChangeset for help on using the changeset viewer.