aboutsummaryrefslogtreecommitdiffstats
path: root/www/js/views
diff options
context:
space:
mode:
Diffstat (limited to 'www/js/views')
-rw-r--r--www/js/views/home.js3
-rw-r--r--www/js/views/login.js26
2 files changed, 22 insertions, 7 deletions
diff --git a/www/js/views/home.js b/www/js/views/home.js
index 998af1c..05ee2f7 100644
--- a/www/js/views/home.js
+++ b/www/js/views/home.js
@@ -24,8 +24,11 @@
afterDisplay: function() {
$('#load-screen').hide();
+
if ( FMS.isOffline ) {
this.navigate( 'offline' );
+ } else if ( !FMS.isLoggedIn && CONFIG.LOGIN_REQUIRED ) {
+ this.navigate( 'login' );
} else if ( FMS.currentDraft && (
FMS.currentDraft.get('title') || FMS.currentDraft.get('lat') ||
FMS.currentDraft.get('details') || FMS.currentDraft.get('file') )
diff --git a/www/js/views/login.js b/www/js/views/login.js
index c0f16ba..93a9a5b 100644
--- a/www/js/views/login.js
+++ b/www/js/views/login.js
@@ -40,8 +40,7 @@
that.model.set('name', data.name);
that.model.save();
FMS.isLoggedIn = 1;
- that.$('#password_row').hide();
- that.$('#success_row').show();
+ that.rerender();
} else {
that.validationError('signinForm', FMS.strings.login_details_error);
}
@@ -65,11 +64,7 @@
FMS.isLoggedIn = 0;
that.model.set('password', '');
that.model.save();
- that.$('#form_email').val('');
- that.$('#form_password').val('');
- that.$('#success_row').hide();
- that.$('#signed_in_row').hide();
- that.$('#password_row').show();
+ that.rerender();
},
error: function() {
that.validationError('err', FMS.strings.logout_error);
@@ -102,6 +97,23 @@
}
return isValid;
+ },
+
+ beforeDisplay: function() {
+ this.fixPageHeight();
+ if ( !FMS.isLoggedIn && CONFIG.LOGIN_REQUIRED ) {
+ this.$("#reports-next-btn").hide();
+ }
+ },
+
+ rerender: function() {
+ // Simply calling this.render() breaks the DOM in a weird and
+ // interesting way - somehow the main view element is duplicated
+ // instead of replaced and none of the event handlers are
+ // hooked up so you end up with a blank screen.
+ // This is a convenience wrapper around the correct router call
+ // which works around the problem.
+ FMS.router.login();
}
})
});