Changeset 415 for Dev/branches/rest-dojo-ui/client
- Timestamp:
- 12/04/12 16:29:49 (12 years ago)
- Location:
- Dev/branches/rest-dojo-ui/client/rft
- Files:
-
- 11 added
- 1 deleted
- 11 edited
- 1 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/client/rft/pages/question.html
r407 r415 3 3 <h2> 4 4 <span class="rftIcon rftIconSurvey"></span> 5 <span class="headerText"> Question 123[Editing]</span>5 <span class="headerText"><span data-dojo-attach-point="titleNode">Question title</span> [Editing]</span> 6 6 </h2> 7 7 </div> -
Dev/branches/rest-dojo-ui/client/rft/pages/question.js
r410 r415 21 21 if ( this._started ) { return; } 22 22 this.inherited(arguments); 23 if (this.questionId) { 23 if ( !this.questionId ) { 24 throw new Error("Error: no reference to object set!"); 25 } 26 this._setupEditor(); 27 if (this.questionId === "new") { 28 this.question = { type: 'Question' }; 29 this._refresh(); 30 } else { 24 31 Deferred.when(store.get(this.questionId)) 25 32 .then(lang.hitch(this, function(obj) { … … 27 34 this._refresh(); 28 35 })); 29 } else {30 throw new Error("Error: no reference to object set!");31 36 } 32 this._setupEditor();33 37 }, 34 38 onLeave: function() { … … 36 40 }, 37 41 _refresh: function () { 42 this.titleNode.innerHTML = this.question.title || ""; 38 43 this._toolkit.set('value',this.question); 39 44 this._preview.appendItems(this.question.content || []); … … 46 51 Router.go('/questions'); 47 52 },function(err){ 48 Content.notify(err .reason,'error');53 Content.notify(err,'error'); 49 54 }); 50 55 evt && event.stop( evt ); -
Dev/branches/rest-dojo-ui/client/rft/pages/questions.js
r414 r415 40 40 }, 41 41 onNewQuestion: function() { 42 Deferred.when(store.add({type:'Question'})) 43 .then(lang.hitch(this,function(question){ 44 this.onEditQuestion(question); 45 })); 42 Router.go("/question/new"); 46 43 }, 47 44 onDeleteQuestion: function(question) { … … 50 47 Content.notify("Question deleted."); 51 48 },function(err){ 52 Content.notify(err .reason,'error');49 Content.notify(err,'error'); 53 50 }); 54 51 }, … … 62 59 Content.notify("Question published."); 63 60 },function(err){ 64 Content.notify(err .reason,'error');61 Content.notify(err,'error'); 65 62 }); 66 63 } -
Dev/branches/rest-dojo-ui/client/rft/pages/survey.html
r407 r415 40 40 data-dojo-attach-event="onSubmit:_onPropertiesOk"> 41 41 42 <form data-dojo-type="dijit/form/Form" 43 data-dojo-attach-point="propertiesForm"> 44 <label for="title">Title</label> 45 <input data-dojo-type="dijit/form/TextBox" name="title"/><br/> 46 <label for="description">Description</label> 47 <input data-dojo-type="dijit/form/Textarea" name="description"/><br/> 48 </form> 42 <div data-dojo-type="rft/ui/model/SurveyForm" 43 data-dojo-attach-point="propertiesForm"></div> 49 44 50 45 <div> -
Dev/branches/rest-dojo-ui/client/rft/pages/surveys.html
r414 r415 36 36 </div> 37 37 38 <div data-dojo-type="dijit/Dialog" 39 title="SurveyRun properties" 40 data-dojo-attach-point="surveyRunDialog"> 41 <form data-dojo-type="rft/ui/model/SurveyRunForm" data-dojo-attach-point="surveyRunForm"> 42 <button data-dojo-type="dijit/form/Button">OK</button> 43 <button data-dojo-type="dijit/form/Button">Cancel</button> 44 </form> 45 </div> 46 38 47 </div> -
Dev/branches/rest-dojo-ui/client/rft/pages/surveys.js
r414 r415 23 23 Router.go('/survey/'+store.getIdentity(survey)); 24 24 },function(err){ 25 Content.notify(err .reason,'error');25 Content.notify(err,'error'); 26 26 }); 27 27 }, … … 33 33 self.refreshPublished(); 34 34 },function(err){ 35 Content.notify(err .reason,'error');35 Content.notify(err,'error'); 36 36 }); 37 37 }, … … 42 42 self.refreshDrafts(); 43 43 },function(err){ 44 Content.notify(err .reason,'error');44 Content.notify(err,'error'); 45 45 }); 46 46 }, … … 52 52 }, 53 53 _onRunSurvey:function(survey){ 54 54 this.surveyRunDialog.show(); 55 55 }, 56 56 refresh: function() { -
Dev/branches/rest-dojo-ui/client/rft/pages/viewSurvey.js
r410 r415 7 7 '../store', 8 8 '../app/Page', 9 '../ui/ content/ContentWidgetFactory',9 '../ui/model/QuestionWidgetFactory', 10 10 'dojo/text!./viewSurvey.html' 11 ],function(array,declare,Deferred,event,lang,store,Page, ContentWidgetFactory,template){11 ],function(array,declare,Deferred,event,lang,store,Page,QuestionWidgetFactory,template){ 12 12 return declare([Page],{ 13 13 templateString: template, … … 35 35 this.titleNode.innerHTML = survey.title + 36 36 (this.options.preview?' [preview]':''); 37 var f = new ContentWidgetFactory();37 var f = new QuestionWidgetFactory(); 38 38 this.survey = survey; 39 39 store.query(null,{keys:this.survey.questions,include_docs:true}) -
Dev/branches/rest-dojo-ui/client/rft/stddeps.js
r407 r415 21 21 'dijit/form/Textarea', 22 22 'dijit/form/TextBox', 23 'dijit/form/TimeTextBox', 23 24 24 25 'dojox/grid/DataGrid', … … 33 34 'rft/ui/Selector', 34 35 'rft/ui/TitleGroup', 36 'rft/ui/generic/DateTimeTextBox', 37 'rft/ui/model/SurveyForm', 38 'rft/ui/model/SurveyRunForm', 35 39 'rft/ui/lists/AccountListView', 36 40 'rft/ui/lists/List', -
Dev/branches/rest-dojo-ui/client/rft/store.js
r410 r415 1 1 define([ 2 2 'dojo/date/stamp', 3 'dojox/json/schema', 4 './schema', 3 5 './store/CouchStore' 4 ],function(stamp, CouchStore){6 ],function(stamp,jsonSchema,schema,CouchStore){ 5 7 6 var store = new CouchStore({target: 'data/couch/'}); 8 var store = new CouchStore({ 9 target: 'data/couch/', 10 validate: function(object) { 11 var result = jsonSchema.validate(object,schema); 12 if ( result.valid ) { 13 return true; 14 } else { 15 console.log("Found error ",result," for invalid object ",object); 16 return false; 17 } 18 } 19 }); 7 20 store.formatDate = function(date){ 8 21 return stamp.toISOString(date,{zulu:true}); -
Dev/branches/rest-dojo-ui/client/rft/store/CouchStore.js
r414 r415 10 10 11 11 function getCouchError(err){ 12 return (err.response && err.response.data) 13 ? json.fromJson(err.response.data) 14 : "Unknown error."; 12 var reason = err.response && 13 err.response.data && 14 json.fromJson(err.response.data).reason; 15 return reason || "Unknown error."; 15 16 } 16 17 … … 74 75 return dfd.promise; 75 76 }, 77 validate: function(object) { 78 return true; 79 }, 76 80 put: function(object, options){ 77 81 // summary: … … 83 87 // id: String 84 88 // 89 90 if ( !this.validate(object) ) { 91 var dfd = new Deferred(); 92 dfd.reject("Invalid document."); 93 return dfd.promise; 94 } 95 return this._putValid(object, options); 96 97 }, 98 _putValid: function(object,options) { 99 var dfd = new Deferred(); 85 100 options = options || {}; 86 87 var dfd = new Deferred();88 101 var id = options.id ? options.id : this.getIdentity(object); 89 var hasId = typeof id != "undefined";102 var hasId = typeof id !== "undefined"; 90 103 xhr(hasId ? "PUT" : "POST", { 91 104 url: hasId ? this.target + id : this.target, -
Dev/branches/rest-dojo-ui/client/rft/ui/QuestionEditorPreviewItem.js
r414 r415 10 10 'dijit/_WidgetBase', 11 11 'dijit/_WidgetsInTemplateMixin', 12 './ content/ContentWidgetFactory',12 './model/QuestionWidgetFactory', 13 13 'dojo/text!./templates/QuestionEditorPreviewItem.html' 14 14 ], function( … … 23 23 _WidgetBase, 24 24 _WidgetsInTemplateMixin, 25 ContentWidgetFactory,25 QuestionWidgetFactory, 26 26 template 27 27 ){ … … 55 55 }, 56 56 _showViewWidget: function() { 57 var factory = new ContentWidgetFactory();57 var factory = new QuestionWidgetFactory(); 58 58 this.innerWidget = factory.createViewWidget( this.item ); 59 59 if ( this.innerWidget !== null ) { … … 65 65 }, 66 66 _showEditWidget: function() { 67 var factory = new ContentWidgetFactory();67 var factory = new QuestionWidgetFactory(); 68 68 this.innerWidget = factory.createEditWidget( this.item ); 69 69 if ( this.innerWidget !== null ) {
Note: See TracChangeset
for help on using the changeset viewer.