source: Dev/trunk/src/client/qed-client/response.js @ 529

Last change on this file since 529 was 506, checked in by hendrikvanantwerpen, 11 years ago
  • Added subcodes to schema and config widgets.
  • Disallow empty strings in schema and strip objects before sending them to the server.
  • Finally managed proper change events in lists and complexvalues.
File size: 1.5 KB
RevLine 
[443]1define([
[477]2    "./app/Content",
3    "./app/Page",
4    "./app/Path",
[487]5    "./model/classes/responses",
6    "./model/classes/surveyRuns",
[477]7    "./pages/response",
8    "dojo/_base/json",
9    "dojo/date",
10    "dojo/date/locale",
11    "dojo/hash",
12    "dojo/parser",
13    "dojo/request",
14    "./stddeps",
15    "dojo/domReady!"
[506]16], function(Content, Page, Path, responses, surveyRuns, ResponsePage, json, date, locale, hash, parser, request) {
[443]17    parser.parse();
18    Content.startup();
19
20    function error(msg) {
21        Content.set(new Page({
22            templateString: "<div>"+msg+"</div>"
23        }));
24    }
25
[487]26    var path = new Path('/:type/:id');
[443]27    var params = path.match(hash());
28    params.options = params.options || {};
[487]29   
30    if ( params && params.type === 'surveyRuns' ) {
31        var response = responses.create();
32        response.surveyRunId = params.id;
33        responses.postWithSecret(response,params.options.secret)
34        .then(setContent,function(err){ error(err.error); });
35    } else if ( params && params.type === 'responses' ) {
36        responses.getWithSecret(params.id,params.options.secret)
37        .then(setContent,function(err){ error(err.error); });
38    } else {
[443]39        error("Something is wrong with the URL, don't know what survey to show you. Sorry.");
40    }
41
[487]42    function setContent(response) {
[490]43        hash(Path.format(responses.getObjectPath(response),
[487]44                         {secret:response.secret}));
[443]45        Content.set(new ResponsePage({
[487]46            response: response
[443]47        }));
[487]48    }
49
[443]50});
Note: See TracBrowser for help on using the repository browser.