- Timestamp:
- 07/24/12 16:39:41 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/ui/QuestionEditorToolkit.js
r372 r374 6 6 'dijit/_Container', 7 7 'dojo/dom-construct', 8 'rft/store', 8 9 'rft/ui/QuestionEditorPreviewItem', 10 'rft/ui/CategoryListView', 9 11 'dijit/_TemplatedMixin', 10 12 'dijit/_WidgetsInTemplateMixin', 13 'dijit/form/ComboBox', 11 14 '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) { 13 16 return declare("rft.ui.QuestionEditorToolkit", [_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, _Container], { 14 17 15 18 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 // }, 17 27 18 28 postCreate: function(){ … … 42 52 this.inputsSource.insertNodes(false, inputsItems); 43 53 }, 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 }, 44 64 _creator: function(item, hint) { 45 65 var node; … … 47 67 node = document.createElement("span"); 48 68 node.innerHTML = item.widgetType; 49 // debugger;50 69 return {node: node, data: item, type: "ToolkitItem"}; 51 70 } else { … … 60 79 } 61 80 }, 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 }, 62 123 _contentItems: function() { 63 124 // Returns an array of objects, from which to generate buttons to populate the ToolkitContentSource list.
Note: See TracChangeset
for help on using the changeset viewer.