Ignore:
Timestamp:
07/29/12 00:03:52 (13 years ago)
Author:
hendrikvanantwerpen
Message:
  • Cleanup of the differen ListViews?, List & OrderedList?. Based QuestionListView? on these base classes as well. Removed duplicate code.
  • Destroy busy indicator of TabbedQuestionBrowser? (because it's placed outside of the widgets DOM tree, this is not done automatically).
  • Use dojo/date/stamp module for uniform and parsable date formatting.
  • Added docs/ directory for database format documentation etc.
File:
1 edited

Legend:

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

    r374 r384  
    1 define(['dojo/_base/declare',
    2         'dojo/_base/lang',
    3         'dojo/_base/event',
    4         'dojo/_base/Deferred',
     1define([
     2    'dojo/_base/array',
     3    'dojo/_base/declare',
     4    'dojo/_base/lang',
     5    'dojo/_base/event',
     6    'dojo/_base/Deferred',
    57    'rft/elastic/ElasticSearchFilteringSelect',
    68    'rft/elastic/ElasticReadStore',
    7         'rft/store',
    8         'rft/ui/_Page',
    9         'rft/content',
     9    'rft/store',
     10    'rft/ui/_Page',
     11    'rft/content',
    1012    'rft/ui/AccountListView'
    1113    ],
    12         function(declare,lang,event,Deferred,ElasticSearchFilteringSelect,ElasticReadStore,store,_Page,content,AccountListView){
    13                 return declare('rft.pages.session',[_Page],{
    14                         session: null,
    15                         _listView: null,
     14    function(array,declare,lang,event,Deferred,ElasticSearchFilteringSelect,ElasticReadStore,store,_Page,content,AccountListView){
     15        return declare('rft.pages.session',[_Page],{
     16            session: null,
     17            _accountList: null,
    1618            _select: null,
    17                         onVisit: function() {
    18                                 if ( this.pageArgs.uid ) {
    19                                         Deferred.when(store.get(this.pageArgs.uid))
    20                                         .then(lang.hitch(this,function(obj){
    21                                                 this.session = obj;
    22                         this._setupListView();
     19            onVisit: function() {
     20                if ( this.pageArgs.uid ) {
     21                    Deferred.when(store.get(this.pageArgs.uid))
     22                    .then(lang.hitch(this,function(obj){
     23                        this.session = obj;
     24                        this._setupAccountList();
    2325                        this._refresh();
    24                                         }));
     26                    }));
    2527                    this._setupAutoComplete();
    26                                 } else {
    27                                         throw "No valid uid or session passed!";
    28                                 }
    29                         },
    30                         onLeave: function() {
    31                                 this.inherited(arguments);
    32                         },
     28                } else {
     29                    throw "No valid uid or session passed!";
     30                }
     31            },
    3332            _refresh: function() {
    3433                this.titleNode.innerHTML = this.session.title || '';
     
    4140            onSave: function(evt) {
    4241                lang.mixin(this.session,this.propertiesForm.get('value'));
     42                this.session.accounts = array.map(this._accountList.getItems(),function(item){
     43                    return store.getIdentity(item);
     44                });
    4345                store.put(this.session)
    4446                .then(function(){
     
    5557            },
    5658            _addAccount: function(item) {
    57                 if (!this.session.accounts)
    58                     this.session.accounts = [];
    59                 this.session.accounts.push(item);
    60                 this._listView.insertItem(item);
     59                this._accountList.insertItem(item);
    6160            },
    62             _removeAccount: function(item) {
    63                 this.session.accounts.splice(this.session.accounts.indexOf(item), 1);
    64             },
    65             _setupListView: function() {
    66                 this._listView = new AccountListView( {
    67                     controller: this,
    68                     removeCallback: lang.hitch(this, this._removeAccount)
    69                 }).placeAt(this.listViewNode);
    70                 for (account in this.session.accounts) {
    71                     this._listView.insertItem(this.session.accounts[account]);
     61            _setupAccountList: function() {
     62                this._accountList = new AccountListView().placeAt(this.accountListNode);
     63                this._accountList.startup();
     64                for (var account in this.session.accounts) {
     65                    this._accountList.insertItem(this.session.accounts[account]);
    7266                }
    73 
    74                 this._listView.startup();
    7567            },
    7668            _setupAutoComplete: function() {
    77 
    7869                var accountStore = new ElasticReadStore({
    7970                    url: "http://localhost:9200/rft/_search",
     
    8172                });
    8273                this._select = new ElasticSearchFilteringSelect({
    83                     name: "accountBox",
    8474                    store: accountStore,
    8575                    autoComplete: false,
     
    9080                    hasDownArrow: false,
    9181                    style: "width: 400",
    92                     searchAttr: "title",
    93                     id: "accountText"
    94                 }, "accountBox");
     82                    searchAttr: "title"
     83                }, this.accountSelector);
    9584                this._select.startup();
    9685            }
    9786
    9887
    99                 });
    100 });
     88        });
     89    });
    10190
Note: See TracChangeset for help on using the changeset viewer.