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.
Location:
Dev/branches/rest-dojo-ui/client/rft/ui
Files:
8 added
3 edited

Legend:

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

    r350 r355  
    1 define(['dojo/_base/declare','dojo/_base/lang','dojo/on','dojo/dom', 'dojo/dom-class', 'dijit/form/Button',
    2     'dijit/_WidgetBase','dijit/_TemplatedMixin','dijit/_WidgetsInTemplateMixin',
    3     'dojo/text!./templates/LineWithActionsWidget.html'
    4     ],
    5     function(declare,lang,on,dom,domClass,Button,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString){
    6         return declare('rft.ui.LineWithActionsWidget',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{
    7             templateString: templateString,
    8             baseClass: 'rftLineWithButtons',
    9             title: '',
    10             modifiers: "blue",
    11             userObject: null,
    12             actions: {},
    13             postCreate: function() {
    14                 dom.setSelectable(this.domNode, false);
    15                 on(this.titleNode,'click',lang.hitch(this,'_onClick'));
    16             },
    17             startup: function() {
    18                 this.inherited(arguments);
    19                 this._setupActions();
    20                 domClass.add(this.domNode, this.modifiers);
    21                 this.refresh();
    22             },
    23             _setupActions: function() {
    24                 for (var action in this.actions) {
    25                     var properties;
    26                     if (this.actions[action].properties.blockButton == true) {  // BlockButton
    27                         properties = lang.mixin({
    28                             baseClass: 'rftBlockButton',
    29                             modifiers: this.modifiers,
    30                             label: "Default",
    31                             iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon,
    32                             title: action,
    33                             onClick: lang.hitch(this, this.actions[action].callback)
    34                         }, this.actions[action].properties);
    35                         properties["class"] = properties.modifiers;
    36                         new Button(properties).placeAt(this.buttonsNode);
    37                     } else {    //InlineButton
    38                         properties = lang.mixin({
    39                             baseClass: 'rftInlineButton',
    40                             modifiers: 'black',
    41                             label: "Default",
    42                             showLabel: false,
    43                             iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon,
    44                             title: action,
    45                             onClick: lang.hitch(this, this.actions[action].callback)
    46                         }, this.actions[action].properties);
    47                         properties["class"] = properties.modifiers;
    48                         new Button(properties).placeAt(this.buttonsNode);
    49                     }
    50                 }
    51             },
    52             refresh: function() {
    53                 this.titleNode.innerHTML = this.title;
    54             },
    55             _onClick: function(e){
    56                 var preventDefault = this.onClick(e) === false;
    57                 if(preventDefault){
    58                     e.preventDefault();
    59                 }
    60                 return !preventDefault;
    61             },
    62             onClick: function(e) {},
    63             _setTitleAttr: function(value){
    64                 this.title = value;
    65                 this.refresh();
    66             }
    67         });
    68     });
     1define(['dojo/_base/declare',
     2        'dojo/_base/lang',
     3        'dojo/on',
     4        'dojo/dom',
     5        'dojo/_base/event',
     6        'dojo/dom-class',
     7        'dijit/form/Button',
     8        'dijit/_WidgetBase',
     9        'dijit/_TemplatedMixin',
     10        'dijit/_WidgetsInTemplateMixin',
     11        'dojo/text!./templates/LineWithActionsWidget.html'
     12        ],
     13        function(declare,lang,on,dom,event,domClass,Button,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,templateString){
     14                return declare('rft.ui.LineWithActionsWidget',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin],{
     15                        templateString: templateString,
     16                        baseClass: 'rftLineWithButtons',
     17                        title: '',
     18                        modifiers: "blue",
     19                        selectable: false,
     20                        userObject: null,
     21
     22                        actions: {},
     23                        postCreate: function() {
     24                                dom.setSelectable(this.domNode, false); // Text selection, has nothing to do with object selection!
     25                                on(this.domNode,'click',lang.hitch(this,'_onClick'));
     26                        },
     27                        startup: function() {
     28                                this.inherited(arguments);
     29                                this._setupActions();
     30                                domClass.add(this.domNode, this.modifiers);
     31                                this.refresh();
     32                        },
     33                        _setupActions: function() {
     34                                for (var action in this.actions) {
     35                                        var properties;
     36                                        if (this.actions[action].properties.blockButton == true) {
     37                                                properties = lang.mixin({
     38                                                        baseClass: 'rftBlockButton',
     39                                                        modifiers: this.modifiers,
     40                                                        label: "Default",
     41                                                        iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon,
     42                                                        title: action,
     43                                                        onClick: lang.hitch(this, function(e){
     44                                                                lang.hitch(this, this.actions[action].callback )(e);
     45                                                                event.stop(e);
     46                                                                return false;
     47                                                        })
     48                                                }, this.actions[action].properties);
     49                                                properties["class"] = properties.modifiers;
     50                                                new Button(properties).placeAt(this.buttonsNode);
     51                                        } else {
     52                                                properties = lang.mixin({
     53                                                        baseClass: 'rftInlineButton',
     54                                                        modifiers: 'black',
     55                                                        label: "Default",
     56                                                        showLabel: false,
     57                                                        iconClass: 'rftIcon rftIcon'+this.actions[action].properties.icon,
     58                                                        title: action,
     59                                                        onClick: lang.hitch(this, function(e){
     60                                                                lang.hitch(this, this.actions[action].callback)(e);
     61                                                                event.stop(e);
     62                                                                return false;
     63                                                        })
     64                                                }, this.actions[action].properties);
     65                                                properties["class"] = properties.modifiers;
     66                                                new Button(properties).placeAt(this.buttonsNode);
     67                                        }
     68                                }
     69                        },
     70                        refresh: function() {
     71                                this.titleNode.innerHTML = this.title;
     72                        },
     73                        _onClick: function(e){
     74                                var preventDefault = this.onClick(e) === false;
     75                                if (preventDefault) {
     76                                        event.stop(e);
     77                                }
     78                                return !preventDefault;
     79                        },
     80                        onClick: function(e) {
     81                        },
     82                        _setTitleAttr: function(value){
     83                                this.title = value;
     84                                this.refresh();
     85                        }
     86                });
     87});
  • 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        });
  • Dev/branches/rest-dojo-ui/client/rft/ui/templates/LineWithActionsWidget.html

    r316 r355  
    1 <div class="${baseClass}">
     1<div class="${baseClass} inheritBgColor">
    22    <span class="${baseClass}Title" data-dojo-attach-point="titleNode"></span>
    33    <span class="${baseClass}Buttons" data-dojo-attach-point="buttonsNode"></span>
Note: See TracChangeset for help on using the changeset viewer.