- Timestamp:
- 05/02/13 13:13:13 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/client/qed/model/widgets/QuestionEditorToolkit.js
r441 r442 20 20 21 21 templateString: template, 22 _ list: null,22 _categoryList: null, 23 23 _categorySelect: null, 24 24 _categoryStore: null, … … 65 65 }, 66 66 67 postCreate: function(){67 buildRendering: function() { 68 68 this.inherited(arguments); 69 70 this._categoryList = new CategoryListView({ 71 name: "categories" 72 }).placeAt(this.categoryListNode); 73 74 this._categoryStore = new Memory({data: [] }); 75 this._categorySelect = new ComboBox( { 76 store: this._categoryStore, 77 searchAttr: "id" 78 }, this.categoryBoxNode); 79 80 this._topicStore = new Memory( {data: [] }); 81 this._topicSelect = new ComboBox({ 82 name: "topic", 83 store: this._topicStore, 84 searchAttr: "id" 85 }, this.topicBoxNode); 86 69 87 var creator = lang.hitch(this,"_creator"); 70 88 this.contentSource = new Source(this.ToolkitContentSourceNode, { … … 85 103 this.inputsSource.insertNodes(false, this._inputsItems); 86 104 }, 87 _setValueAttr: function(question) { 88 this._setupListView(); 89 this._setupCategories(); 90 this._setupTopic(question.topic); 91 this.propertiesForm.set('value', question); 92 this._list.set('value', question.categories); 105 startup: function() { 106 if ( this._started ) { return; } 107 this.inherited(arguments); 108 109 store.query("_design/questions/_view/all", {reduce:true, group:false, group_level:1}) 110 .forPairs(lang.hitch(this, function(value, key) { 111 this._categoryStore.put({ id: key[0] }); 112 })); 113 114 store.query("_design/questions/_view/all_topics", {reduce:true, group:true}) 115 .forPairs(lang.hitch(this, function(value, key) { 116 this._topicStore.put({ id: key }); 117 })); 93 118 }, 94 _getValueAttr: function() { 95 var value = this.propertiesForm.get('value'); 96 value.categories = this._list.get('value'); 97 return value; 98 }, 99 onCategoryAdd: function() { 100 this._addCategory(this._categorySelect.get('displayedValue')); 119 _onCategoryAdd: function() { 120 this._categoryList.appendItem(this._categorySelect.get('displayedValue')); 101 121 this._categorySelect.reset(); 102 122 }, … … 122 142 type: ["questionContent"] 123 143 }; 124 },125 _setupListView: function() {126 this._list = new CategoryListView({127 }).placeAt(this.listNode);128 this._list.startup();129 },130 _setupCategories: function() {131 this._categoryStore = new Memory({data: [] });132 store.query("_design/questions/_view/all", {reduce:true, group:false, group_level:1})133 .forPairs(lang.hitch(this, function(value, key) {134 this._categoryStore.put({ id: key[0] });135 }));136 this._categorySelect = new ComboBox( {137 name: "categories",138 store: this._categoryStore,139 searchAttr: "id"140 }, this.categoriesBoxNode);141 },142 _setupTopic: function(topic) {143 this._topicStore = new Memory( {data: [] });144 store.query("_design/questions/_view/all_topics", {reduce:true, group:true})145 .forPairs(lang.hitch(this, function(value, key) {146 this._topicStore.put({ id: key });147 }));148 this._topicSelect = new ComboBox( {149 name: "topic",150 store: this._topicStore,151 searchAttr: "id",152 value: topic153 }, this.topicBoxNode);154 },155 _addCategory: function(item) {156 this._list.appendItem(item);157 144 } 158 145
Note: See TracChangeset
for help on using the changeset viewer.