aboutsummaryrefslogtreecommitdiffstats
path: root/www/js/views/save_offline.js
blob: d00170c8f93f94a22620978f91933055d6d9852f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
(function (FMS, Backbone, _, $) {
    _.extend( FMS, {
        SaveOfflineView: FMS.FMSView.extend({
            template: 'save_offline',
            id: 'save_offline',

            events: {
                'pagehide': 'destroy',
                'pagebeforeshow': 'beforeDisplay',
                'pageshow': 'afterDisplay',
                'vclick #save_report': 'saveReport',
                'vclick #discard': 'discardReport'
            },

            saveReport: function() {
                FMS.clearCurrentDraft();
                this.navigate('reports');
            },

            discardReport: function() {
                var reset = FMS.removeDraft(FMS.currentDraft.id, true);
                var that = this;
                reset.done( function() { that.onDraftRemove(); } );
                reset.fail( function() { that.onDraftRemove(); } );
            },

            onDraftRemove: function() {
                this.navigate( 'around', 'left' );
            }
        })
    });
})(FMS, Backbone, _, $);