Changeset 374


Ignore:
Timestamp:
07/24/12 16:39:41 (13 years ago)
Author:
jkraaijeveld
Message:

Can now edit basic question properties and store them.

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

Legend:

Unmodified
Added
Removed
  • Dev/branches/rest-dojo-ui/client/rft/css/layout.css

    r366 r374  
    288288}
    289289.claro .dijitAccordionContainer {
     290    height: 600;
    290291    /* No styling for now, use this for margins and other layout-related business. This class does not affect the look of the AccordionContainer currently! */
    291292}
     
    480481}
    481482
     483/* AccountListView */
     484.claro .rftAccountListView .rftLineWithButtons .rftLineWithButtonsTitle {
     485    max-width: 400px;
     486    overflow: auto;
     487}
    482488/* Generic list with lines */
    483489.claro .rftLineListView {
    484     width: 400px;
     490    max-width: 200px;
    485491    max-height: 500px;
    486492}
    487493.claro .rftLineListView .rftLineListViewContent {
    488     max-width: 400px;
     494    max-width: 200px;
    489495    overflow: auto;
    490496}
  • Dev/branches/rest-dojo-ui/client/rft/pages/question.js

    r372 r374  
    11define(['dojo/_base/declare',
    22    'dojo/_base/lang',
     3    'dojo/_base/event',
    34    'dojo/_base/Deferred',
    45    'rft/ui/LineWithActionsWidget',
     
    1415    'rft/ui/QuestionEditorToolkit',
    1516    'dijit/form/FilteringSelect'],
    16     function(declare, lang, Deferred, LineWithActionsWidget, store, _Page, api, content, registry, on, behavior, query){
     17    function(declare, lang, event, Deferred, LineWithActionsWidget, store, _Page, api, content, registry, on, behavior, query){
    1718        return declare('rft.pages.question', [_Page], {
    1819            question: null,
     
    3738            },
    3839            _refresh: function () {
    39                 this._toolkit.propertiesForm.set('value', this.question);
     40                this._toolkit.loadQuestion(this.question);
     41            },
     42            _onSave: function() {
     43                lang.mixin(this.question, this._toolkit.propertiesForm.get('value'));
     44                this.question.categories = this._toolkit._categories;
     45                store.put(this.question)
     46                .then(function() {
     47                    content.goTo('questions');
     48                });
     49                return false;
     50            },
     51            _onDiscard: function() {
     52                this._toolkit.propertiesForm.reset();
     53                content.goTo('questions');
     54                return false;
    4055            },
    4156            _setupButtons: function() {
     
    4358                    "#btnSave": {
    4459                        onclick: lang.hitch(this, function(){
    45                             this._saveSurvey();
     60                            this._onSave();
    4661                        })
    4762                    },
    4863                    "#btnDiscard": {
    4964                        onclick: lang.hitch(this, function(){
    50                             this._restartEditor();
     65                            this._onDiscard();
    5166                        })
    5267                    }
  • Dev/branches/rest-dojo-ui/client/rft/pages/session.html

    r369 r374  
    3131                            <br/><br/>
    3232                           
    33                             <div data-rft-attach-point="listViewNode" class="rftLineListView">
     33                            <div data-rft-attach-point="listViewNode" class="rftAccountListView">
    3434                            </div>
    3535                        </fieldset>
  • Dev/branches/rest-dojo-ui/client/rft/pages/session.js

    r371 r374  
    5555            },
    5656            _addAccount: function(item) {
     57                if (!this.session.accounts)
     58                    this.session.accounts = [];
    5759                this.session.accounts.push(item);
    5860                this._listView.insertItem(item);
  • Dev/branches/rest-dojo-ui/client/rft/run.js

    r366 r374  
    3030    'dojox/data/QueryReadStore',
    3131    'rft/elastic/ElasticReadStore',
    32     'rft/ui/ListView',
     32    'rft/ui/List',
     33    'rft/ui/OrderedList',
    3334    'rft/ui/AccountListView',
    3435    'rft/ui/MainMenu',
  • Dev/branches/rest-dojo-ui/client/rft/ui/AccountListView.js

    r373 r374  
    77    'dijit/_Container',
    88    'rft/ui/LineWithActionsWidget',
    9     'rft/ui/ListView',
     9    'rft/ui/OrderedList',
    1010    'dojo/text!./templates/AccountListView.html'
    1111        ],function(
     
    2222        return declare('rft.ui.AccountListView',[OrderedList,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{
    2323            templateString: templateString,
    24             baseClass: 'rftLineListView',
     24            baseClass: 'rftAccountListView',
    2525            region: 'center',
    2626
     
    5858                };
    5959                return fullItem;
    60                 },
     60                }
    6161
    6262           
  • Dev/branches/rest-dojo-ui/client/rft/ui/List.js

    r364 r374  
    11define([
    22    'dojo/_base/declare',
     3    'dojo/_base/lang',
    34    'dijit/_WidgetBase',
    45    'dijit/_TemplatedMixin',
    56    'dijit/_WidgetsInTemplateMixin',
    67    'dijit/_Container',
     8    'rft/ui/LineWithActionsWidget',
    79    'dojo/text!./templates/List.html'
    810    ],function(
    911        declare,
     12        lang,
    1013        _WidgetBase,
    1114        _TemplatedMixin,
    1215        _WidgetsInTemplateMixin,
    1316        _Container,
     17        LineWithActionsWidget,
    1418        templateString
    1519        ){
    1620        return declare('rft.ui.List',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{
    1721            templateString: templateString,
    18             baseClass: 'rftList'
     22            baseClass: 'rftList',
     23            removeCallback: null,
     24            creator: null,
     25
     26            constructor: function() {
     27                lang.mixin(this, arguments);
     28            },
     29
     30            postCreate: function() {
     31                if (this.title) {
     32                    this.titleNode.innerHTML = this.title;
     33                } else {
     34                    this.domNode.removeChild(this.titleNode);
     35                }
     36
     37                this.source = new dojo.dnd.Source(this.sourceNode, {
     38                    isSource: false,
     39                    accept: ["LineListViewItem"],
     40                    horizontal: false,
     41                    withHandles: false,
     42                    selfCopy: false,
     43                    selfAccept: true,
     44                    delay: 0,
     45                    singular: true,
     46                    creator: lang.hitch(this, this.creatorMethod)
     47                })
     48            },
     49
     50            removeItem: function(item, widget) {
     51                widget.destroy();
     52                if(this.removeCallback)
     53                    this.removeCallback(item);
     54            },
     55
     56            insertItem: function(item) {
     57                this.source.insertNodes(false, [item]);
     58            }
     59
    1960        });
    2061    });
  • Dev/branches/rest-dojo-ui/client/rft/ui/OrderedList.js

    r373 r374  
    66    'dijit/_WidgetsInTemplateMixin',
    77    'dijit/_Container',
    8     'dojo/text!./templates/List.html'
     8    'rft/ui/List',
     9    'dojo/text!./templates/OrderedList.html'
    910    ],function(
    1011        declare,
     
    1415        _WidgetsInTemplateMixin,
    1516        _Container,
     17        List,
    1618        templateString
    1719        ){
    18         return declare('rft.ui.List',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{
     20        return declare('rft.ui.OrderedList',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container,List],{
    1921            templateString: templateString,
    20             baseClass: 'rftList',
    21 
    22             removeCallback: null,
    23 
    24             constructor: function() {
    25                 lang.mixin(this, arguments);
    26             },
     22            baseClass: 'rftLineListView',
    2723
    2824            postCreate: function() {
     
    10096                    this.source.insertNodes(false, [item]);
    10197                }
    102             },
    103             removeItem: function(item, widget) {
    104                 widget.destroy();
    105                 if(this.removeCallback)
    106                     this.removeCallback(item);
    10798            }
     99
    108100        });
    109101    });
  • Dev/branches/rest-dojo-ui/client/rft/ui/QuestionEditorToolkit.js

    r372 r374  
    66        'dijit/_Container',
    77        'dojo/dom-construct',
     8        'rft/store',
    89        'rft/ui/QuestionEditorPreviewItem',
     10        'rft/ui/CategoryListView',
    911        'dijit/_TemplatedMixin',
    1012        'dijit/_WidgetsInTemplateMixin',
     13        'dijit/form/ComboBox',
    1114        'dojo/text!./templates/QuestionEditorToolkit.html'
    12         ], function(declare, lang, baseArray, _WidgetBase, _Container, domConstruct, QuestionEditorPreviewItem, _TemplatedMixin, _WidgetsInTemplateMixin, template) {
     15        ], function(declare, lang, baseArray, _WidgetBase, _Container, domConstruct, store, QuestionEditorPreviewItem, CategoryListView, _TemplatedMixin, _WidgetsInTemplateMixin, ComboBox, template) {
    1316                return declare("rft.ui.QuestionEditorToolkit", [_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, _Container], {
    1417
    1518                        templateString: template,
    16                         question: null,
     19                        _list: null,
     20                        _categorySelect: null,
     21                        _categoryStore: null,
     22                        _categories : null,
     23
     24//                      constructor: function() {
     25//                              lang.mixin(this, arguments);
     26//                      },
    1727
    1828                        postCreate: function(){
     
    4252                                this.inputsSource.insertNodes(false, inputsItems);
    4353                        },
     54                        loadQuestion: function(question) {
     55                                this.propertiesForm.set('value', question);
     56                                this._categories = question.categories;
     57                                this._setupListView();
     58                                this._setupAutoComplete();
     59                        },
     60                        onCategoryAdd: function() {
     61                                this._addCategory(this._categorySelect.get('displayedValue'));
     62                                this._categorySelect.reset();
     63                        },
    4464                        _creator: function(item, hint) {
    4565                                var node;
     
    4767                                        node = document.createElement("span");
    4868                                        node.innerHTML = item.widgetType;
    49                                         // debugger;
    5069                                        return {node: node, data: item, type: "ToolkitItem"};
    5170                                } else {
     
    6079                                }
    6180                        },
     81                        _setupListView: function() {
     82                                this._list = new CategoryListView( {
     83                                        controller: this,
     84                                        removeCallback: lang.hitch(this, this._removeCategory),
     85                                }).placeAt(this.listNode);
     86                                for (category in this._categories) {
     87                                        this._list.insertItem(this._categories[category]);
     88                                }       
     89                                this._list.startup();
     90                        },
     91                        _setupAutoComplete: function() {
     92                                this._categoryStore = new dojo.store.Memory({data: [] });
     93                                store.query("_design/default/_view/questions", {reduce:true, group:false, group_level:1})
     94                                        .forPairs(lang.hitch(this, function(value, key) {
     95                                                this._categoryStore.put({ category: key[0] });
     96                                        }));
     97                                this._categorySelect = new ComboBox( {
     98                                        id: "categoriesBox",
     99                                        name: "categories",
     100                                        store: this._categoryStore,
     101                                        searchAttr: "category"
     102                                }, "categoriesBox");
     103
     104                                this._topicStore = new dojo.store.Memory( {data: [] });
     105                                store.query("_design/default/_view/questions", {reduce:true, group:true, group_level:2})
     106                                        .forPairs(lang.hitch(this, function(value, key) {
     107                                                this._topicStore.put({ topic: key[1]});
     108                                        }));
     109                                this._topicSelect = new ComboBox( {
     110                                        id: "topicBox",
     111                                        name: "topic",
     112                                        store: this._topicStore,
     113                                        searchAttr: "topic"
     114                                }, "topicBox");
     115            },
     116                        _addCategory: function(item) {
     117                                this._categories.push(item);
     118                                this._list.insertItem(item);
     119                        },
     120                        _removeCategory: function(item) {
     121                                this._categories.splice(this._categories.indexOf(item), 1);
     122                        },
    62123                        _contentItems: function() {
    63124                                // Returns an array of objects, from which to generate buttons to populate the ToolkitContentSource list.
  • Dev/branches/rest-dojo-ui/client/rft/ui/templates/List.html

    r364 r374  
    11<div>
    2     <div data-dojo-attach-point="containerNode"></div>
    3     <div style="float: right;">
    4         <span>Move selected: </span>
    5         <button data-dojo-type="dijit.form.Button" data-dojo-props="baseClass: 'rftBlockButton', iconClass:'rftIcon rftIconFullArrowUp'" class="trans"></button>
    6         <button data-dojo-type="dijit.form.Button" data-dojo-props="baseClass: 'rftBlockButton', iconClass:'rftIcon rftIconFullArrowDown'" class="trans"></button>
    7     </div>
     2        <h3 data-dojo-attach-point="titleNode"></h3>
     3    <div data-dojo-attach-point="sourceNode" id="source" class="${baseClass}Content"></div>
    84</div>
  • Dev/branches/rest-dojo-ui/client/rft/ui/templates/QuestionEditorToolkit.html

    r372 r374  
    55                                <fieldset class="align">
    66                                        <label for="propertiesTitle">Title:</label><input data-dojo-type="dijit.form.TextBox" id="propertiesTitle" name="title"/>
    7                                         <label for="propertiesCode">Code:</label><input data-dojo-type="dijit.form.TextBox" id="propertiesCode" name= "code"/>
    8                                         <label for="propertiesCategories">Categories:</label><input data-dojo-type="dijit.form.FilteringSelect" id="propertiesCategories" name="categories"/>
    9                                         <label for="propertiesTopic">Topic:</label><input data-dojo-type="dijit.form.FilteringSelect" id="propertiesTopic" name="topic"/>
    10                                         <label for="propertiesDescription">Description:</label><textarea data-dojo-type="dijit.form.Textarea" id="propertiesDescription" name="description"></textarea>
     7                                        <label for="propertiesCode">Code:</label><input data-dojo-type="dijit.form.TextBox" id="propertiesCode" name= "_id"/>
     8                                        <label for="propertiesCategories">Categories:</label>
     9                                        <div data-dojo-attach-point="listNode" class="rftLineListView"></div>
     10                                        <select id="categoriesBox"></select>
     11                                        <button data-rft-attach-point="btnCategory" data-dojo-type="dijit.form.Button" data-dojo-attach-event="onClick:onCategoryAdd" data-dojo-props="baseClass:'rftBlockButton', class:'orange', iconClass: 'rftIcon rftIconPlus'">Add</button><br>
     12                                        <label for="propertiesTopic">Topic:</label>
     13                                        <select id="topicBox"></select>
     14                                        <label for="propertiesDescription">Description:</label><textarea data-dojo-type="dijit.form.TextBox" id="propertiesDescription" name="description"></textarea>
    1115                                </fieldset>
    1216                        </div>
Note: See TracChangeset for help on using the changeset viewer.