Ignore:
Timestamp:
08/06/13 01:48:17 (12 years ago)
Author:
hendrikvanantwerpen
Message:

Quick hack to allow responding despite not being authenticated. Something like tokes need to be added.

Location:
Dev/trunk/src/client/qed-client
Files:
1 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/src/client/qed-client/css/fonts.less

    r447 r477  
    33    font-size: @font_size;
    44    color: @text;
     5    &.light {
     6        color: black; // FIXME : hack for readability
     7    }
    58
    69    a {
  • Dev/trunk/src/client/qed-client/css/layout.less

    r443 r477  
    77    height: 100%;
    88    background-color: @base;
     9    .light {
     10        background-color: white; // FIXME : hack for readability
     11    }
    912}
  • Dev/trunk/src/client/qed-client/model/widgets/TabbedQuestionBrowser.js

    r443 r477  
    7878                    title: (topic || '[No topic]')+" ("+count+")",
    7979                    selectedActions: this.selectedActions,
    80                     itemActions: this.itemActions
     80                    itemActions: this.itemActions,
     81                    itemTitle: this._itemTitle
    8182                }).placeAt(categoryMap._widget.containerNode);
    8283                w.startup();
     
    8788            }
    8889        },
     90        _itemTitle: function(item) {
     91            var title = '['+item.code+']'+item.title;
     92            if ( this.include === 'all' ) {
     93                title += (item.publicationDate?' (published on '+item.publicationDate+')':' (unpublished)');
     94            }
     95            return title;
     96        },
    8997        _fillTopicSelector: function(topic,category) {
    9098            var categoryMap = this._dataMap[category];
     
    93101                topicMap._filled = true;
    94102                this._busy();
    95                 store.query(this._query, {reduce:false,include_docs:true,key:[category,topic]})
    96                 .forEach(lang.hitch(this,function(value){
    97                     var title;
    98                     if ( this.include === 'all' ) {
    99                         title = value.title+(value.publicationDate?' (published on '+value.publicationDate+')':' (unpublished)');
    100                     }
    101                     topicMap._widget.addItem(value,title);
     103                store.query(this._query, {
     104                    reduce:false,
     105                    include_docs:true,
     106                    key:[category,topic]
     107                }).forEach(lang.hitch(this,function(value){
     108                    topicMap._widget.addItem(value);
    102109                })).then(lang.hitch(this,function(){
    103110                    this._done();
  • Dev/trunk/src/client/qed-client/pages/response.js

    r461 r477  
    99    "dojo/_base/declare",
    1010    "dojo/_base/event",
     11    "dojo/_base/json",
    1112    "dojo/_base/lang",
    1213    "dojo/promise/all",
     14    "dojo/request",
    1315    "dojo/when",
    1416    "require",
    1517    "dojo/text!./templates/response.html"
    16 ], function(Content, Page, async, Response, Survey, SurveyRun, store, declare, event, lang, all, when, require, template) {
     18], function(Content, Page, async, Response, Survey, SurveyRun, store, declare, event, json, lang, all, request, when, require, template) {
    1719    return declare([Page],{
    1820        contextRequire: require,
     
    3739                        this._enableSubmit();
    3840                    }
    39                 }), function() {
     41                }), lang.hitch(this,function() {
    4042                    this._showInfo("<div>The url seems to be incorrect, no survey found.</div>");
    41                 });
     43                }));
    4244            } else {
    4345                throw new Error("No valid uid or survey passed!");
     
    4547        },
    4648        _loadSurveyAndResponse: function(surveyRunId,responseId){
    47             return all([store.get(surveyRunId),store.get(responseId)])
     49            return all([request.get('/api/surveyRuns/'+surveyRunId,{handleAs:'json'}),
     50                        request.get('/api/responses/'+responseId,{handleAs:'json'})])
    4851            .then(lang.hitch(this,function(surveyAndResponse){
    4952                var surveyRun = surveyAndResponse[0];
     
    7376            var answers = this.surveyWidget.get('value');
    7477            this.response.answers = answers;
    75             return store.put(this.response).then(function(){
     78            return request.put('/api/responses/'+store.getIdentity(this.response),{
     79                handleAs:'json',
     80                data:json.toJson(this.response),
     81                headers:{"Content-Type": "application/json"}
     82            }).then(function(){
    7683                Content.notify("Your response is saved.");
    7784            }, function(err){
     
    8289            this.response.publicationDate = store.timestamp();
    8390            this._getAnswersAndSaveResponse()
    84             .then(function(){
     91            .then(lang.hitch(this,function(){
    8592                this._showInfo("<div>Thanks for filling in the survey. You cannot edit your answers anymore.</div>");
    8693                this._disableSubmit();
    87             });
     94            }));
    8895            if ( e ) { event.stop(e); }
    8996            return false;
  • Dev/trunk/src/client/qed-client/response.js

    r443 r477  
    11define([
    2     'dojo/date',
    3     'dojo/date/locale',
    4     'dojo/hash',
    5     'dojo/parser',
    6     './store',
    7     './app/Content',
    8     './app/Page',
    9     './app/Path',
    10     './lib/async',
    11     './model/classes/Response',
    12     './model/classes/SurveyRun',
    13     './pages/response',
    14     'dojo/domReady!',
    15     './stddeps'
    16 ],function(date,locale,hash,parser,store,Content,Page,Path,async,Response,SurveyRun,ResponsePage) {
     2    "./app/Content",
     3    "./app/Page",
     4    "./app/Path",
     5    "./lib/async",
     6    "./model/classes/Response",
     7    "./model/classes/SurveyRun",
     8    "./pages/response",
     9    "./store",
     10    "dojo/_base/json",
     11    "dojo/date",
     12    "dojo/date/locale",
     13    "dojo/hash",
     14    "dojo/parser",
     15    "dojo/request",
     16    "./stddeps",
     17    "dojo/domReady!"
     18], function(Content, Page, Path, async, Response, SurveyRun, ResponsePage, store, json, date, locale, hash, parser, request) {
    1719    parser.parse();
    1820    Content.startup();
     
    4951    }
    5052
    51     store.get(surveyRunId)
     53    request.get('/api/surveyRuns/'+surveyRunId,{handleAs:'json'})
    5254    .then(function(surveyRun){
    5355        checkDates(surveyRun);
     
    5860                var response = Response.create();
    5961                response.surveyRunId = surveyRunId;
    60                 return store.put(response).then(function(res){
    61                     return store.getIdentity(res);
     62                return request.post('/api/responses',{
     63                    handleAs:'json',
     64                    data:json.toJson(response),
     65                    headers:{"Content-Type": "application/json"}
     66                }).then(function(res){
     67                    return res.id;
    6268                });
    6369            } else {
  • Dev/trunk/src/client/qed-client/widgets/Selector.js

    r472 r477  
    1818], function(LineWithActionsWidget, _Container, _TemplatedMixin, _WidgetBase, _WidgetsInTemplateMixin, registry, baseArray, declare, event, lang, Source, domClass, domConstruct, fx, query, templateString) {
    1919
     20    function get(selector, item) {
     21        if ( lang.isFunction(selector) ) {
     22            return selector(item);
     23        } else {
     24            return item[selector || 'title'];
     25        }
     26    }
     27   
    2028    return declare([_WidgetBase,_TemplatedMixin,_WidgetsInTemplateMixin,_Container],{
    2129        templateString: templateString,
     
    2533        selectedActions: null,
    2634        itemActions: null,
     35        itemTitle: 'title',
    2736        // main selector action: Object
    2837        //    title:
     
    111120            this._selectedItem = item;
    112121            this.onToggle();
    113             this._selectorLine.set("title", item.title);
     122            this._selectorLine.set("title", get(this.itemTitle,item));
    114123            baseArray.forEach(this.optionsNode.childNodes, function(node){
    115124                var line = registry.byNode(node);
     
    174183            return domConstruct.create("div",{
    175184                'class': 'dragAvatar',
    176                 innerHTML: item.title
     185                innerHTML: get(this.itemTitle,item)
    177186            });
    178187        },
     
    197206            }
    198207            var w = new LineWithActionsWidget({
    199                 title: item.title,
     208                title: get(this.itemTitle,item),
    200209                actions: actions
    201210            });
Note: See TracChangeset for help on using the changeset viewer.