Changeset 384
- Timestamp:
- 07/29/12 00:03:52 (13 years ago)
- Location:
- Dev/branches/rest-dojo-ui
- Files:
-
- 2 added
- 2 deleted
- 12 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/elastic/ElasticReadStore.js
r382 r384 7 7 ],function(declare, json, lang, xhr, QueryReadStore) { 8 8 9 10 11 12 13 14 15 9 return declare("rft.elastic.ElasticReadStore", QueryReadStore, { 10 fetch:function(request){ 11 var attr = Object.keys(request.query)[0]; 12 if (request.query[attr].length == 0) { 13 return 0; 14 } 15 var q = request.query[attr]; 16 16 17 request.serverQuery = json.toJson({ 18 query: 19 { 20 query_string: 21 { 22 default_field: attr, 23 query: q 24 } 25 } 26 }); 27 // Call superclasses' fetch 28 return this.inherited("fetch", arguments); 29 }, 30 _fetchItems: function(request, fetchHandler, errorHandler){ 31 var serverQuery = request.serverQuery; 32 var xhrHandler = xhr.post({ 17 request.serverQuery = json.toJson({ 18 query: { 19 query_string: { 20 default_field: attr, 21 query: q 22 } 23 } 24 }); 25 return this.inherited(arguments); 26 }, 27 _fetchItems: function(request, fetchHandler, errorHandler){ 28 var serverQuery = request.serverQuery; 29 var xhrHandler = xhr.post({ 33 30 url: this.url, 34 31 handleAs: "json", 35 32 postData: serverQuery 33 }).then(lang.hitch(this, function(data){ 34 this._xhrFetchHandler(data, request, fetchHandler, errorHandler); 35 }),function(error){ 36 errorHandler(error, request); 36 37 }); 37 request.abort = function(){ 38 xhrHandler.cancel(); 39 }; 40 xhrHandler.addCallback(lang.hitch(this, function(data){ 41 this._xhrFetchHandler(data, request, fetchHandler, errorHandler); 42 })); 43 xhrHandler.addErrback(function(error){ 44 errorHandler(error, request); 45 }); 46 }, 47 _xhrFetchHandler: function(data, request, fetchHandler, errorHandler) { 48 data = this._filterResponse(data); 49 this._items = []; 50 var numHits = data.hits.total || -1; 51 if(numHits > 0) { 52 this._items.push({i:data.hits.hits[0]._source, r:this, n:0}); 53 } 54 fetchHandler(this._items, request, data.hits.total); 55 this._numRows = data.hits.total; 56 } 57 }); 38 request.abort = function(){ 39 xhrHandler.cancel(); 40 }; 41 }, 42 _xhrFetchHandler: function(data, request, fetchHandler, errorHandler) { 43 data = this._filterResponse(data); 44 this._items = []; 45 var numHits = data.hits.total || -1; 46 if(numHits > 0) { 47 this._items.push({i:data.hits.hits[0]._source, r:this, n:0}); 48 } 49 fetchHandler(this._items, request, data.hits.total); 50 this._numRows = data.hits.total; 51 } 52 }); 58 53 }) -
Dev/branches/rest-dojo-ui/client/rft/pages/session.html
r374 r384 14 14 <h3>Basic</h3> 15 15 <fieldset class="align"> 16 <label for="title Input">Title</label>16 <label for="title">Title</label> 17 17 <input type="text" name="title" data-dojo-type="dijit.form.TextBox" data-dojo-props="placeHolder: 'Enter title here'" /> 18 18 <br/> 19 <label for="description Input">Description</label>19 <label for="description">Description</label> 20 20 <textarea name="description" rows="3" cols="54" data-dojo-type="dijit.form.SimpleTextarea" data-dojo-props="selectOnClick: true, placeHolder: 'Description shown in tooltips'"></textarea> 21 21 <br/> 22 <label for=" dateInput">Planned date</label>22 <label for="plannedDate">Planned date</label> 23 23 <input type="text" name="plannedDate" data-dojo-type="dijit.form.DateTextBox" required="required" /> 24 24 </fieldset> … … 26 26 <h3>Accounts</h3> 27 27 <fieldset class="align"> 28 <label for="account sInput">Add new</label>29 <select id="accountBox"></select>28 <label for="accountSelector">Add new</label> 29 <select data-rft-attach-point="accountSelector"></select> 30 30 <button data-rft-attach-point="btnInvite" data-dojo-type="dijit.form.Button" data-rft-attach-event="onClick:onInvite" data-dojo-props="baseClass: 'rftBlockButton', class: 'green', iconClass: 'rftIcon rftIconPlus'">Invite</button> 31 31 <br/><br/> 32 32 33 <div data-rft-attach-point=" listViewNode" class="rftAccountListView">33 <div data-rft-attach-point="accountListNode" class="rftAccountListView"> 34 34 </div> 35 35 </fieldset> 36 36 37 <button data- rft-attach-point="btnPropertiesDiscard" data-dojo-type="dijit.form.Button" data-rft-attach-event="onClick:onDiscard" data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconCancel'">Discard changes</button>38 <button data- rft-attach-point="btnPropertiesSave" data-dojo-type="dijit.form.Button" data-rft-attach-event="onClick:onSave" data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconAccept'">Save changes</button>37 <button data-dojo-type="dijit.form.Button" data-rft-attach-event="onClick:onDiscard" data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconCancel'">Discard changes</button> 38 <button data-dojo-type="dijit.form.Button" data-rft-attach-event="onClick:onSave" data-dojo-props="baseClass: 'rftLargeButton', iconClass: 'rftIcon rftIconAccept'">Save changes</button> 39 39 40 40 </div> … … 42 42 </div> 43 43 <div data-dojo-type="dijit.layout.ContentPane" title="Design"> 44 <!--DESIGN-->45 46 44 <div class="rftSessionObject green"> 47 45 <div class="rftIcon rftIconSurvey"></div> -
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', 1 define([ 2 'dojo/_base/array', 3 'dojo/_base/declare', 4 'dojo/_base/lang', 5 'dojo/_base/event', 6 'dojo/_base/Deferred', 5 7 'rft/elastic/ElasticSearchFilteringSelect', 6 8 'rft/elastic/ElasticReadStore', 7 8 9 9 'rft/store', 10 'rft/ui/_Page', 11 'rft/content', 10 12 'rft/ui/AccountListView' 11 13 ], 12 function(declare,lang,event,Deferred,ElasticSearchFilteringSelect,ElasticReadStore,store,_Page,content,AccountListView){13 14 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, 16 18 _select: null, 17 18 19 20 21 22 this._setup ListView();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(); 23 25 this._refresh(); 24 26 })); 25 27 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 }, 33 32 _refresh: function() { 34 33 this.titleNode.innerHTML = this.session.title || ''; … … 41 40 onSave: function(evt) { 42 41 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 }); 43 45 store.put(this.session) 44 46 .then(function(){ … … 55 57 }, 56 58 _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); 61 60 }, 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]); 72 66 } 73 74 this._listView.startup();75 67 }, 76 68 _setupAutoComplete: function() { 77 78 69 var accountStore = new ElasticReadStore({ 79 70 url: "http://localhost:9200/rft/_search", … … 81 72 }); 82 73 this._select = new ElasticSearchFilteringSelect({ 83 name: "accountBox",84 74 store: accountStore, 85 75 autoComplete: false, … … 90 80 hasDownArrow: false, 91 81 style: "width: 400", 92 searchAttr: "title", 93 id: "accountText" 94 }, "accountBox"); 82 searchAttr: "title" 83 }, this.accountSelector); 95 84 this._select.startup(); 96 85 } 97 86 98 87 99 100 });88 }); 89 }); 101 90 -
Dev/branches/rest-dojo-ui/client/rft/pages/sessions.js
r359 r384 1 define(['dojo/_base/declare','dojo/_base/lang','rft/store','rft/content','rft/ui/_Page','rft/ui/ObjectBox'], 2 function(declare,lang,store,content,_Page,ObjectBox){ 1 define([ 2 'dojo/_base/declare', 3 'dojo/_base/lang', 4 'dojo/date/stamp', 5 'rft/store', 6 'rft/content', 7 'rft/ui/_Page', 8 'rft/ui/ObjectBox'], 9 function(declare,lang,dateStamp,store,content,_Page,ObjectBox){ 3 10 return declare('rft.pages.sessions',[_Page],{ 4 11 templateActions: null, … … 55 62 }, 56 63 _publishSession: function(sessionTemplate) { 57 var publishDate = new Date();58 64 var session = lang.clone(sessionTemplate); 59 65 delete session[store.idProperty]; 60 66 delete session[store.revProperty]; 61 67 session.type = "SessionInstance"; 62 session. date = publishDate.getDate()+"-"+publishDate.getMonth()+"-"+publishDate.getFullYear();68 session.publishedDate = dateStamp.toISOString(new Date(),{zulu: true}); 63 69 session.creator = "Igor Mayer"; 64 70 store.add(session) -
Dev/branches/rest-dojo-ui/client/rft/pages/survey.js
r379 r384 8 8 'rft/store', 9 9 'rft/ui/_Page', 10 'rft/ui/ OrderedDndList',10 'rft/ui/QuestionListView', 11 11 'rft/ui/TabbedQuestionBrowser' 12 12 ], 13 13 function(array,declare,Deferred,event,lang,content,store,_Page, 14 OrderedDndList,TabbedQuestionBrowser){14 QuestionListView,TabbedQuestionBrowser){ 15 15 return declare('rft.pages.survey',[_Page],{ 16 16 survey: null, … … 58 58 }, 59 59 _setupListView: function() { 60 this.questionList = new OrderedDndList({ 61 type: 'question', 60 this.questionList = new QuestionListView({ 62 61 region: 'center' 63 62 }).placeAt(this.surveyListViewNode); -
Dev/branches/rest-dojo-ui/client/rft/ui/AccountListView.js
r374 r384 2 2 'dojo/_base/declare', 3 3 'dojo/_base/lang', 4 'dijit/_WidgetBase', 5 'dijit/_TemplatedMixin', 6 'dijit/_WidgetsInTemplateMixin', 7 'dijit/_Container', 4 'dojo/dom-construct', 8 5 'rft/ui/LineWithActionsWidget', 9 'rft/ui/OrderedList', 10 'dojo/text!./templates/AccountListView.html' 6 'rft/ui/OrderedList' 11 7 ],function( 12 8 declare, 13 9 lang, 14 _WidgetBase, 15 _TemplatedMixin, 16 _WidgetsInTemplateMixin, 17 _Container, 10 domConstruct, 18 11 LineWithActionsWidget, 19 OrderedList, 20 templateString 12 OrderedList 21 13 ) { 22 return declare('rft.ui.AccountListView',[OrderedList,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 23 templateString: templateString, 14 return declare('rft.ui.AccountListView',[OrderedList],{ 24 15 baseClass: 'rftAccountListView', 25 region: 'center',16 type: 'account', 26 17 27 creatorMethod: function(item, hint) { 28 var node; 29 30 if (hint == "avatar") { 31 node = document.createElement("div"); 32 node.className = "dragAvatar"; 33 node.innerHTML = item.title; 34 } else { 35 var w = new LineWithActionsWidget({ 36 title: item.title, 37 'class': "green", 38 actions: { 39 "Remove" : { 40 callback: lang.hitch(this, function() { 41 this.removeItem(item, w); 42 }), 43 properties: { 44 blockButton: false, 45 icon: "Delete", 46 modifiers: "white" 47 } 48 } 49 } 50 }); 51 w.startup(); 52 node = w.domNode; 53 } 54 var fullItem = { 55 node: node, 56 data: item, 57 type: "ListViewItem" 58 }; 59 return fullItem; 18 _createAvatarNode: function(item){ 19 return domConstruct.create("div",{ 20 'class': 'dragAvatar', 21 innerHTML: item.title 22 }); 23 }, 24 _createListNode: function(item) { 25 var w = new LineWithActionsWidget({ 26 title: item.title, 27 'class': "green", 28 actions: { 29 "Remove" : { 30 callback: lang.hitch(this, 'removeItem', item), 31 properties: { 32 blockButton: false, 33 icon: "Delete", 34 modifiers: "white" 35 } 36 } 37 } 38 }); 39 w.startup(); 40 return w.domNode; 60 41 } 61 62 63 64 42 }); 65 });43 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/CategoryListView.js
r374 r384 2 2 'dojo/_base/declare', 3 3 'dojo/_base/lang', 4 'dijit/_WidgetBase',5 'dijit/_TemplatedMixin',6 'dijit/_WidgetsInTemplateMixin',7 'dijit/_Container',8 4 'rft/ui/LineWithActionsWidget', 9 5 'rft/ui/List', 10 'dojo/text!./templates/List.html'11 6 ],function( 12 7 declare, 13 8 lang, 14 _WidgetBase,15 _TemplatedMixin,16 _WidgetsInTemplateMixin,17 _Container,18 9 LineWithActionsWidget, 19 List, 20 templateString 10 List 21 11 ) { 22 return declare('rft.ui.CategoryListView',[List,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 23 templateString: templateString, 12 return declare('rft.ui.CategoryListView',[List],{ 24 13 baseClass: 'rftLineListView', 25 region: 'center',26 14 27 creatorMethod: function(item, hint) { 28 var node; 15 _createAvatarNode: function(item) { 16 var node = document.createElement("div"); 17 node.className = "dragAvatar"; 18 node.innerHTML = item.title; 19 return node; 20 }, 29 21 30 if (hint == "avatar") { 31 node = document.createElement("div"); 32 node.className = "dragAvatar"; 33 node.innerHTML = item.title; 34 } else { 35 var w = new LineWithActionsWidget({ 36 title: item, 37 'class': "orange", 38 actions: { 39 "Remove" : { 40 callback: lang.hitch(this, function() { 41 this.removeItem(item, w); 42 }), 43 properties: { 44 blockButton: false, 45 icon: "Delete", 46 modifiers: "white" 47 } 22 _createListNode: function(item) { 23 var w = new LineWithActionsWidget({ 24 title: item, 25 'class': "orange", 26 actions: { 27 "Remove" : { 28 callback: lang.hitch(this, function() { 29 this.removeItem(item, w); 30 }), 31 properties: { 32 blockButton: false, 33 icon: "Delete", 34 modifiers: "white" 48 35 } 49 36 } 50 }); 51 w.startup(); 52 node = w.domNode; 53 } 54 var fullItem = { 55 node: node, 56 data: item, 57 type: "ListViewItem" 58 }; 59 return fullItem; 37 } 38 }); 39 w.startup(); 40 return w.domNode; 60 41 } 42 61 43 }); 62 });44 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/List.js
r374 r384 2 2 'dojo/_base/declare', 3 3 'dojo/_base/lang', 4 'dojo/dnd/Source', 5 'dijit/_Container', 6 'dijit/_TemplatedMixin', 4 7 'dijit/_WidgetBase', 5 'dijit/_TemplatedMixin',6 8 'dijit/_WidgetsInTemplateMixin', 7 'dijit/_Container', 8 'rft/ui/LineWithActionsWidget', 9 'dijit/registry', 9 10 'dojo/text!./templates/List.html' 10 11 ],function( 11 12 declare, 12 13 lang, 14 Source, 15 _Container, 16 _TemplatedMixin, 13 17 _WidgetBase, 14 _TemplatedMixin,15 18 _WidgetsInTemplateMixin, 16 _Container, 17 LineWithActionsWidget, 19 registry, 18 20 templateString 19 21 ){ … … 22 24 baseClass: 'rftList', 23 25 removeCallback: null, 24 creator: null, 25 26 constructor: function() { 27 lang.mixin(this, arguments); 28 }, 26 type: 'text', 27 source: null, 29 28 30 29 postCreate: function() { … … 35 34 } 36 35 37 this.source = new dojo.dnd.Source(this.sourceNode, { 38 isSource: false, 39 accept: ["LineListViewItem"], 36 this.source = new Source(this.sourceNode, { 37 accept: [this.type], 40 38 horizontal: false, 41 withHandles: false,42 selfCopy: false,43 selfAccept: true,44 delay: 0,45 39 singular: true, 46 creator: lang.hitch(this, this. creatorMethod)47 }) 40 creator: lang.hitch(this, this._createNode) 41 }); 48 42 }, 49 43 50 removeItem: function(item, widget) { 51 widget.destroy(); 52 if(this.removeCallback) 53 this.removeCallback(item); 44 _createNode: function(item, hint) { 45 var node = hint === "avatar" ? 46 this._createAvatarNode(item) : this._createListNode(item); 47 return { 48 node: node, 49 data: item, 50 type: this.type 51 }; 52 }, 53 _createListNode: function(item) {}, 54 _createAvatarNode: function(item) {}, 55 56 appendItem: function(item) { 57 this.source.insertNodes(false,[item]); 54 58 }, 55 59 56 insertItem: function(item) { 57 this.source.insertNodes(false, [item]); 60 getItems: function() { 61 return this.source.getAllNodes() 62 .map(function(node){ 63 return this.source.getItem(node.id).data; 64 },this); 65 }, 66 67 deleteItems: function() { 68 this.source.getAllNodes() 69 .forEach(function(node){ 70 registry.byNode(node).destroy(); 71 }); 72 this.source.sync(); 73 }, 74 75 removeItem: function(item){ 76 this.source.getAllNodes() 77 .filter(lang.hitch(this,function(node){ 78 return this.source.getItem(node.id).data === item; 79 })) 80 .forEach(lang.hitch(this,function(node){ 81 registry.byNode(node).destroy(); 82 this.removeCallback && this.removeCallback(item); 83 })); 84 this.source.sync(); 58 85 } 59 86 -
Dev/branches/rest-dojo-ui/client/rft/ui/MultipleChoiceListView.js
r383 r384 2 2 'dojo/_base/declare', 3 3 'dojo/_base/lang', 4 'dijit/_WidgetBase', 5 'dijit/_TemplatedMixin', 6 'dijit/_WidgetsInTemplateMixin', 7 'dijit/_Container', 4 'dojo/dom-construct', 8 5 'rft/ui/LineWithActionsWidget', 9 'rft/ui/OrderedList', 10 'dojo/text!./templates/AccountListView.html' 6 'rft/ui/OrderedList' 11 7 ],function( 12 8 declare, 13 9 lang, 14 _WidgetBase, 15 _TemplatedMixin, 16 _WidgetsInTemplateMixin, 17 _Container, 10 domConstruct, 18 11 LineWithActionsWidget, 19 OrderedList, 20 templateString 12 OrderedList 21 13 ) { 22 return declare('rft.ui.MultipleChoiceListView',[OrderedList,_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 23 templateString: templateString, 14 return declare('rft.ui.MultipleChoiceListView',[OrderedList],{ 24 15 baseClass: 'rftMultipleChoiceListView', 25 region: 'center',16 type: 'multipleChoiceOption', 26 17 27 creatorMethod: function(item, hint) { 28 var node; 29 30 if (hint == "avatar") { 31 node = document.createElement("div"); 32 node.className = "dragAvatar"; 33 node.innerHTML = item.title; 34 } else { 35 var w = new LineWithActionsWidget({ 36 title: item.title, 37 'class': "orange", 38 actions: { 39 "Remove" : { 40 callback: lang.hitch(this, function() { 41 this.removeItem(item, w); 42 }), 43 properties: { 44 blockButton: false, 45 icon: "Delete", 46 modifiers: "white" 47 } 18 _createAvatarNode: function(item){ 19 return domConstruct.create("div",{ 20 'class': 'dragAvatar', 21 innerHTML: item.title 22 }); 23 }, 24 _createListNode: function(item) { 25 var w = new LineWithActionsWidget({ 26 title: item.title, 27 'class': "orange", 28 actions: { 29 "Remove" : { 30 callback: lang.hitch(this, 'removeItem', item), 31 properties: { 32 blockButton: false, 33 icon: "Delete", 34 modifiers: "white" 48 35 } 49 36 } 50 }); 51 w.startup(); 52 node = w.domNode; 53 } 54 var fullItem = { 55 node: node, 56 data: item, 57 type: "ListViewItem" 58 }; 59 return fullItem; 37 } 38 }); 39 w.startup(); 40 return w.domNode; 60 41 } 61 42 }); 62 });43 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/OrderedList.js
r383 r384 2 2 'dojo/_base/declare', 3 3 'dojo/_base/lang', 4 'dijit/_WidgetBase', 5 'dijit/_TemplatedMixin', 6 'dijit/_WidgetsInTemplateMixin', 7 'dijit/_Container', 4 'dijit/form/Button', 8 5 'rft/ui/List', 9 6 'dojo/text!./templates/OrderedList.html' … … 11 8 declare, 12 9 lang, 13 _WidgetBase, 14 _TemplatedMixin, 15 _WidgetsInTemplateMixin, 16 _Container, 10 Button, 17 11 List, 18 12 templateString 19 13 ){ 20 return declare('rft.ui.OrderedList',[ _WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container,List],{14 return declare('rft.ui.OrderedList',[List],{ 21 15 templateString: templateString, 22 16 baseClass: 'rftLineListView', 23 17 24 18 postCreate: function() { 25 if (this.title) { 26 this.titleNode.innerHTML = this.title; 27 } else { 28 this.domNode.removeChild(this.titleNode); 29 } 19 this.inherited(arguments); 30 20 31 this.source = new dojo.dnd.Source(this.sourceNode, { 32 isSource: true, 33 accept: ["LineListViewItem"], 34 horizontal: false, 35 withHandles: false, 36 copyOnly: false, 37 selfCopy: false, 38 selfAccept: true, 39 delay: 0, 40 singular: true, 41 creator: lang.hitch(this, this.creatorMethod) 42 }); 43 44 new dijit.form.Button({ 21 new Button({ 45 22 label: "Move up", 46 23 showLabel: false, … … 49 26 'class': "trans", 50 27 onClick: lang.hitch(this, function() { 51 this. moveItem("up");28 this._moveSelectedItem("up"); 52 29 }) 53 }, this.btnListMoveUp) ;30 }, this.btnListMoveUp).startup(); 54 31 55 new dijit.form.Button({32 new Button({ 56 33 label: "Move down", 57 34 showLabel: false, … … 60 37 'class': "trans", 61 38 onClick: lang.hitch(this, function() { 62 this. moveItem("down");39 this._moveSelectedItem("down"); 63 40 }) 64 }, this.btnListMoveDown) ;41 }, this.btnListMoveDown).startup(); 65 42 }, 66 43 67 moveItem: function(dir) {44 _moveSelectedItem: function(dir) { 68 45 var node = this.source.getSelectedNodes()[0]; 69 46 if (node) { … … 92 69 var anchor = this.source.getSelectedNodes()[0]; 93 70 if (anchor) { 94 this.source.insertNodes(false, 71 this.source.insertNodes(false,[item], false, anchor); 95 72 } else { 96 this. source.insertNodes(false, [item]);73 this.appendItem(item); 97 74 } 98 }, 99 getItems: function() { 100 return this.source.getAllNodes() 101 .map(function(node){ 102 return this.source.getItem(node.id).data; 103 },this); 104 }, 75 } 76 105 77 }); 106 78 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/QuestionEditorToolkit.js
r378 r384 84 84 _setupListView: function() { 85 85 this._list = new CategoryListView( { 86 controller: this, 87 removeCallback: lang.hitch(this, this._removeCategory), 86 removeCallback: lang.hitch(this, this._removeCategory) 88 87 }).placeAt(this.listNode); 89 for ( category in this._categories) {90 this._list. insertItem(this._categories[category]);88 for (var category in this._categories) { 89 this._list.appendItem(this._categories[category]); 91 90 } 92 91 this._list.startup(); … … 124 123 _addCategory: function(item) { 125 124 this._categories.push(item); 126 this._list. insertItem(item);125 this._list.appendItem(item); 127 126 }, 128 127 _removeCategory: function(item) { -
Dev/branches/rest-dojo-ui/client/rft/ui/QuestionListView.js
r383 r384 2 2 'dojo/_base/declare', 3 3 'dojo/_base/lang', 4 'dojo/dnd/Source',5 4 'dojo/dom-construct', 6 'dijit/_Container',7 'dijit/_TemplatedMixin',8 'dijit/_WidgetBase',9 'dijit/_WidgetsInTemplateMixin',10 'dijit/form/Button',11 5 'rft/ui/LineWithActionsWidget', 12 ' dojo/text!./templates/OrderedDndList.html'6 'rft/ui/OrderedList' 13 7 ],function( 14 8 declare, 15 9 lang, 16 Source,17 10 domConstruct, 18 _Container,19 _TemplatedMixin,20 _WidgetBase,21 _WidgetsInTemplateMixin,22 Button,23 11 LineWithActionsWidget, 24 templateString12 OrderedList 25 13 ){ 26 return declare('rft.ui.OrderedDndList',[_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{ 27 templateString: templateString, 14 return declare('rft.ui.QuestionListView',[OrderedList],{ 28 15 baseClass: 'rftSurveyListView', 29 type: 'text', 30 source: null, 16 type: 'question', 31 17 32 postCreate: function() { 33 if (this.title) { 34 this.titleNode.innerHTML = this.title; 35 } else { 36 this.domNode.removeChild(this.titleNode); 37 } 38 39 this.source = new Source(this.sourceNode, { 40 accept: [this.type], 41 horizontal: false, 42 singular: true, 43 creator: lang.hitch(this, this._createQuestionDndItem) 18 _createAvatarNode: function(item){ 19 return domConstruct.create("div",{ 20 'class': 'dragAvatar', 21 innerHTML: item.title 44 22 }); 45 46 new Button({47 label: "Move up",48 showLabel: false,49 iconClass: "rftIcon rftIconFullArrowUp",50 baseClass: "rftBlockButton",51 'class': "trans",52 onClick: lang.hitch(this, function() {53 this._moveSelectedItem("up");54 })55 }, this.btnListMoveUp);56 57 new Button({58 label: "Move down",59 showLabel: false,60 iconClass: "rftIcon rftIconFullArrowDown",61 baseClass: "rftBlockButton",62 'class': "trans",63 onClick: lang.hitch(this, function() {64 this._moveSelectedItem("down");65 })66 }, this.btnListMoveDown);67 23 }, 68 _createQuestionDndItem: function(item, hint) { 69 var node; 70 71 if (hint == "avatar") { 72 node = domConstruct.create("div",{ 73 'class': 'dragAvatar', 74 innerHTML: item.title 75 }); 76 } else { 77 var w = new LineWithActionsWidget({ 78 title: item.title, 79 'class': "inheritBgColor", 80 actions: { 81 "Remove" : { 82 // w not bound in hitch, because it's 83 // not initialized when hitch is called. 84 callback: lang.hitch(this, function(){ 85 this._removeItem(w); 86 }), 87 properties: { 88 blockButton: false, 89 icon: "Delete", 90 modifiers: "white", 91 label: "Remove" 92 } 93 }, 94 "Info" : { 95 callback: function(){ item.description && alert(item.description); }, 96 properties: { 97 blockButton: false, 98 icon: "Inspect", 99 modifiers: "white", 100 label: "Show info" 101 } 24 _createListNode: function(item) { 25 var w = new LineWithActionsWidget({ 26 title: item.title, 27 'class': "inheritBgColor", 28 actions: { 29 "Remove" : { 30 callback: lang.hitch(this, 'removeItem', item), 31 properties: { 32 blockButton: false, 33 icon: "Delete", 34 modifiers: "white", 35 label: "Remove" 36 } 37 }, 38 "Info" : { 39 callback: function(){ item.description && alert(item.description); }, 40 properties: { 41 blockButton: false, 42 icon: "Inspect", 43 modifiers: "white", 44 label: "Show info" 102 45 } 103 46 } 104 });105 w.startup();106 node = w.domNode;107 }108 return {109 node: node,110 data: item,111 type: "question"112 };113 },114 _moveSelectedItem: function(dir) {115 var node = this.source.getSelectedNodes()[0];116 if (node) {117 if (dir == "up") {118 if (node.previousSibling) {119 return node.parentNode.insertBefore(node, node.previousSibling);120 } else {121 return false;122 }123 124 } else if (dir == "down") {125 if (node.nextSibling) {126 return node.parentNode.insertBefore(node.nextSibling, node);127 } else {128 return false;129 }130 } else {131 throw "Invalid move direction passed!";132 47 } 133 } else {134 return false;135 }136 },137 insertItem: function(item) {138 var anchor = this.source.getSelectedNodes()[0];139 if (anchor) {140 this.source.insertNodes(false,[item], false, anchor);141 } else {142 this.appendItem(item);143 }144 },145 appendItem: function(item) {146 this.source.insertNodes(false,[item]);147 },148 getItems: function() {149 return this.source.getAllNodes()150 .map(function(node){151 return this.source.getItem(node.id).data;152 },this);153 },154 deleteItems: function() {155 this.source.getAllNodes()156 .forEach(function(node){157 node.destroy();158 48 }); 159 this.source.sync(); 160 }, 161 _removeItem: function(widget){ 162 widget.destroy(); 163 this.source.sync(); 49 w.startup(); 50 return w.domNode; 164 51 } 165 52 }); -
Dev/branches/rest-dojo-ui/client/rft/ui/TabbedQuestionBrowser.js
r382 r384 77 77 }; 78 78 this._fillTopicSelector(topic,category); 79 w.on('include',lang.hitch(this,this.onSelect));80 79 } 81 80 }, … … 107 106 } 108 107 } else { 109 console.warn(' Busycount <= 0 when _done is called.');108 console.warn('_done() was called more times than _busy().'); 110 109 } 111 110 }, 112 onSelect: function(question) {} 111 destroy: function() { 112 this._busyWidget.destroyRecursive(); 113 this.inherited(arguments); 114 } 113 115 }); 114 116 });
Note: See TracChangeset
for help on using the changeset viewer.