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

Last change on this file since 497 was 490, checked in by hendrikvanantwerpen, 11 years ago
  • Mark content as dirty to prevent moving away from unsaved data.
  • Better change propagation from lists and our own widgets.
  • Generate notifications for errors and show correct message.
  • Moved all path/url generation to the class stores, not everywhere we use it.
  • Give user always a choice between Save and Save & Close.
  • Better refresh behaviour on form changes and saves.
  • Don't generate duplicate code error when existing object is the one you're storing.
File size: 1.5 KB
Line 
1define([
2    "./app/Content",
3    "./app/Page",
4    "./app/Path",
5    "./lib/async",
6    "./model/classes/responses",
7    "./model/classes/surveyRuns",
8    "./pages/response",
9    "dojo/_base/json",
10    "dojo/date",
11    "dojo/date/locale",
12    "dojo/hash",
13    "dojo/parser",
14    "dojo/request",
15    "./stddeps",
16    "dojo/domReady!"
17], function(Content, Page, Path, async, responses, surveyRuns, ResponsePage, json, date, locale, hash, parser, request) {
18    parser.parse();
19    Content.startup();
20
21    function error(msg) {
22        Content.set(new Page({
23            templateString: "<div>"+msg+"</div>"
24        }));
25    }
26
27    var path = new Path('/:type/:id');
28    var params = path.match(hash());
29    params.options = params.options || {};
30   
31    if ( params && params.type === 'surveyRuns' ) {
32        var response = responses.create();
33        response.surveyRunId = params.id;
34        responses.postWithSecret(response,params.options.secret)
35        .then(setContent,function(err){ error(err.error); });
36    } else if ( params && params.type === 'responses' ) {
37        responses.getWithSecret(params.id,params.options.secret)
38        .then(setContent,function(err){ error(err.error); });
39    } else {
40        error("Something is wrong with the URL, don't know what survey to show you. Sorry.");
41    }
42
43    function setContent(response) {
44        hash(Path.format(responses.getObjectPath(response),
45                         {secret:response.secret}));
46        Content.set(new ResponsePage({
47            response: response
48        }));
49    }
50
51});
Note: See TracBrowser for help on using the repository browser.