From 54491e0de2ab18d6acf66f8a7b7464b48ccbb242 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Thu, 27 Mar 2014 16:17:51 +1100 Subject: [PATCH 1/3] Syncing up the email addresses between the SpreeUser tabs --- .../controllers/forgot_sidebar_controller.js.coffee | 6 ++---- .../controllers/login_sidebar_controller.js.coffee | 6 ++---- .../controllers/signup_sidebar_controller.js.coffee | 4 ++-- .../javascripts/darkswarm/services/spree_user.js.coffee | 6 ++++++ app/views/shared/_forgot_sidebar.html.haml | 1 - 5 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 app/assets/javascripts/darkswarm/services/spree_user.js.coffee diff --git a/app/assets/javascripts/darkswarm/controllers/forgot_sidebar_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/forgot_sidebar_controller.js.coffee index f740e5aaf8..0ebe1d72e9 100644 --- a/app/assets/javascripts/darkswarm/controllers/forgot_sidebar_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/forgot_sidebar_controller.js.coffee @@ -1,7 +1,5 @@ -window.ForgotSidebarCtrl = Darkswarm.controller "ForgotSidebarCtrl", ($scope, $http, $location) -> - $scope.spree_user = { - email: null - } +window.ForgotSidebarCtrl = Darkswarm.controller "ForgotSidebarCtrl", ($scope, $http, $location, SpreeUser) -> + $scope.spree_user = SpreeUser.spree_user $scope.active = -> $location.path() == '/forgot' diff --git a/app/assets/javascripts/darkswarm/controllers/login_sidebar_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/login_sidebar_controller.js.coffee index a514348aba..e3d0d20d25 100644 --- a/app/assets/javascripts/darkswarm/controllers/login_sidebar_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/login_sidebar_controller.js.coffee @@ -1,7 +1,5 @@ -window.LoginSidebarCtrl = Darkswarm.controller "LoginSidebarCtrl", ($scope, $http, $location) -> - $scope.spree_user = { - remember_me: 0 - } +window.LoginSidebarCtrl = Darkswarm.controller "LoginSidebarCtrl", ($scope, $http, $location, SpreeUser) -> + $scope.spree_user = SpreeUser.spree_user $scope.active = -> $location.path() == '/login' diff --git a/app/assets/javascripts/darkswarm/controllers/signup_sidebar_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/signup_sidebar_controller.js.coffee index 5e4c3327e1..5c1c80ce23 100644 --- a/app/assets/javascripts/darkswarm/controllers/signup_sidebar_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/signup_sidebar_controller.js.coffee @@ -1,5 +1,5 @@ -window.SignupSidebarCtrl = Darkswarm.controller "SignupSidebarCtrl", ($scope, $http, $location) -> - $scope.spree_user = {} +window.SignupSidebarCtrl = Darkswarm.controller "SignupSidebarCtrl", ($scope, $http, $location, SpreeUser) -> + $scope.spree_user = SpreeUser.spree_user $scope.errors = email: null password: null diff --git a/app/assets/javascripts/darkswarm/services/spree_user.js.coffee b/app/assets/javascripts/darkswarm/services/spree_user.js.coffee new file mode 100644 index 0000000000..f57a6e183b --- /dev/null +++ b/app/assets/javascripts/darkswarm/services/spree_user.js.coffee @@ -0,0 +1,6 @@ +Darkswarm.factory 'SpreeUser', ($resource) -> + new class SpreeUser + spree_user: { + remember_me: 0 + email: null + } diff --git a/app/views/shared/_forgot_sidebar.html.haml b/app/views/shared/_forgot_sidebar.html.haml index 84b0540f1a..e2e018ff23 100644 --- a/app/views/shared/_forgot_sidebar.html.haml +++ b/app/views/shared/_forgot_sidebar.html.haml @@ -3,7 +3,6 @@ active: "active()", select: "select()"} - {{ spree_user.email }} %form{"ng-submit" => "submit()"} .alert-box.alert{"ng-show" => "errors != null"} {{ errors }} From 08c25b16048be7b62991b8d5bac03b9131a1fd99 Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Thu, 27 Mar 2014 16:26:22 +1100 Subject: [PATCH 2/3] Getting a success message in place --- .../forgot_sidebar_controller.js.coffee | 5 ++- app/views/shared/_forgot_sidebar.html.haml | 34 ++++++++++++------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/darkswarm/controllers/forgot_sidebar_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/forgot_sidebar_controller.js.coffee index 0ebe1d72e9..f0e708f2f7 100644 --- a/app/assets/javascripts/darkswarm/controllers/forgot_sidebar_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/forgot_sidebar_controller.js.coffee @@ -1,5 +1,6 @@ window.ForgotSidebarCtrl = Darkswarm.controller "ForgotSidebarCtrl", ($scope, $http, $location, SpreeUser) -> $scope.spree_user = SpreeUser.spree_user + $scope.sent = false $scope.active = -> $location.path() == '/forgot' @@ -10,9 +11,7 @@ window.ForgotSidebarCtrl = Darkswarm.controller "ForgotSidebarCtrl", ($scope, $h $scope.submit = -> if $scope.spree_user.email != null $http.post("/user/spree_user/password", {spree_user: $scope.spree_user}).success (data)-> - - $location.path("/reset") - + $scope.sent = true .error (data) -> $scope.errors = "Email address not found" else diff --git a/app/views/shared/_forgot_sidebar.html.haml b/app/views/shared/_forgot_sidebar.html.haml index e2e018ff23..0edaee5bbb 100644 --- a/app/views/shared/_forgot_sidebar.html.haml +++ b/app/views/shared/_forgot_sidebar.html.haml @@ -4,18 +4,26 @@ select: "select()"} %form{"ng-submit" => "submit()"} - .alert-box.alert{"ng-show" => "errors != null"} - {{ errors }} + .row .large-12.columns - %label{for: "email"} Email - %input.title.input-text{name: "email", - type: "email", - tabindex: 1, - "ng-model" => "spree_user.email"} - .row - .large-12.columns - %input.button.primary{name: "commit", - tabindex: "3", - type: "submit", - value: "Reset password"} + .alert-box.success.radius{"ng-show" => "sent"} + An email with instructions on resetting your password has been sent! + + %div{"ng-show" => "!sent"} + .alert-box.alert{"ng-show" => "errors != null"} + {{ errors }} + + .row + .large-12.columns + %label{for: "email"} Email + %input.title.input-text{name: "email", + type: "email", + tabindex: 1, + "ng-model" => "spree_user.email"} + .row + .large-12.columns + %input.button.primary{name: "commit", + tabindex: "3", + type: "submit", + value: "Reset password"} From 89fcf50762ecc3ffe62bf6860588ccbec792563d Mon Sep 17 00:00:00 2001 From: Will Marshall Date: Thu, 27 Mar 2014 16:36:12 +1100 Subject: [PATCH 3/3] Tidying up tabs --- .../darkswarm/controllers/tabs_controller.js.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/darkswarm/controllers/tabs_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/tabs_controller.js.coffee index f6e6d15f89..eb501bcb4a 100644 --- a/app/assets/javascripts/darkswarm/controllers/tabs_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/tabs_controller.js.coffee @@ -1,6 +1,6 @@ Darkswarm.controller "TabsCtrl", ($scope, $rootScope, $location, OrderCycle) -> $scope.active = (path)-> - if !OrderCycle.selected() and $location.hash() == "" and path == "/about" + if !OrderCycle.selected() and $location.hash() == "" and path == "about" true else $location.hash() == path @@ -9,10 +9,10 @@ Darkswarm.controller "TabsCtrl", ($scope, $rootScope, $location, OrderCycle) -> $scope.tabs = ["contact", "about", "groups", "producers"] for tab in $scope.tabs $scope[tab] = - path: "/" + tab + path: tab $scope.select = (tab)-> if $scope.active(tab.path) - $location.hash "/" + $location.hash "" else $location.hash tab.path