add admin flash messaging and styles
This commit is contained in:
		| @@ -25,6 +25,16 @@ | |||||||
|   background-color: #f39c12; |   background-color: #f39c12; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | .success { | ||||||
|  |   @extend .error; | ||||||
|  |   background-color: $brand-success; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | .notice { | ||||||
|  |   @extend .error; | ||||||
|  |   background-color: $brand-info; | ||||||
|  | } | ||||||
|  |  | ||||||
| [data-id="live-coder-finish-later"] { | [data-id="live-coder-finish-later"] { | ||||||
|   .warning { |   .warning { | ||||||
|     margin-top: 0; |     margin-top: 0; | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ module Admin | |||||||
|       @question = Question.create(process_question_params) |       @question = Question.create(process_question_params) | ||||||
|  |  | ||||||
|       if @question.persisted? |       if @question.persisted? | ||||||
|         redirect_to admin_questions_path, flash: { notice: "Sucessfully created question" } |         redirect_to admin_questions_path, flash: { success: "Sucessfully created question" } | ||||||
|       else |       else | ||||||
|         flash[:error] = "Failed to save question." |         flash[:error] = "Failed to save question." | ||||||
|         render :new |         render :new | ||||||
| @@ -36,7 +36,7 @@ module Admin | |||||||
|  |  | ||||||
|       if @question.update_attributes(process_question_params) |       if @question.update_attributes(process_question_params) | ||||||
|         redirect_to admin_question_path(@question.to_i), |         redirect_to admin_question_path(@question.to_i), | ||||||
|                     flash: { notice: "Sucessfully updated question" } |                     flash: { success: "Sucessfully updated question" } | ||||||
|       else |       else | ||||||
|         flash[:error] = "Failed to update question." |         flash[:error] = "Failed to update question." | ||||||
|         render :edit |         render :edit | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ module Admin | |||||||
|  |  | ||||||
|       if @user.persisted? |       if @user.persisted? | ||||||
|         # TODO: UserMailer.welcome(@user, default_passwd).deliver_now |         # TODO: UserMailer.welcome(@user, default_passwd).deliver_now | ||||||
|         redirect_to admin_users_path, flash: { notice: "Sucessfully created user #{@user.name}" } |         redirect_to admin_users_path, flash: { success: "Sucessfully created user #{@user.name}" } | ||||||
|       else |       else | ||||||
|         flash[:error] = "Failed to save user." |         flash[:error] = "Failed to save user." | ||||||
|         render :new |         render :new | ||||||
| @@ -34,7 +34,7 @@ module Admin | |||||||
|  |  | ||||||
|       if @user.update_attributes(user_params) |       if @user.update_attributes(user_params) | ||||||
|         redirect_to admin_user_path(@user.to_i), |         redirect_to admin_user_path(@user.to_i), | ||||||
|                     flash: { notice: "Sucessfully updated #{@user.name}" } |                     flash: { success: "Sucessfully updated #{@user.name}" } | ||||||
|       else |       else | ||||||
|         flash[:error] = "Failed to update user." |         flash[:error] = "Failed to update user." | ||||||
|         render :edit |         render :edit | ||||||
|   | |||||||
| @@ -1,6 +1,8 @@ | |||||||
| class ApplicationController < ActionController::Base | class ApplicationController < ActionController::Base | ||||||
|   protect_from_forgery with: :exception |   protect_from_forgery with: :exception | ||||||
|  |  | ||||||
|  |   add_flash_types :warning, :success | ||||||
|  |  | ||||||
|   def current_recruiter |   def current_recruiter | ||||||
|     user_parms = { id: session[:user], role: %w(admin recruiter) } |     user_parms = { id: session[:user], role: %w(admin recruiter) } | ||||||
|     @current_recruiter ||= User.find_by(user_parms) if session[:user] |     @current_recruiter ||= User.find_by(user_parms) if session[:user] | ||||||
|   | |||||||
| @@ -16,7 +16,7 @@ class RecruiterController < ApplicationController | |||||||
|     if @candidate.persisted? |     if @candidate.persisted? | ||||||
|       CandidateMailer.welcome(@candidate).deliver_now |       CandidateMailer.welcome(@candidate).deliver_now | ||||||
|       RecruiterMailer.candidate_created(@candidate).deliver_now |       RecruiterMailer.candidate_created(@candidate).deliver_now | ||||||
|       redirect_to recruiter_path, flash: { notice: "Sucessfully created candidate #{@candidate.name}" } |       redirect_to recruiter_path, flash: { success: "Sucessfully created candidate #{@candidate.name}" } | ||||||
|     else |     else | ||||||
|       flash[:error] = "Failed to save candidate." |       flash[:error] = "Failed to save candidate." | ||||||
|       render :form |       render :form | ||||||
|   | |||||||
							
								
								
									
										15
									
								
								app/views/shared/_generic_flash.html.erb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								app/views/shared/_generic_flash.html.erb
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | |||||||
|  | <% if flash[:error].present? %> | ||||||
|  |   <div class="error"><%= flash[:error] %></div> | ||||||
|  | <% end %> | ||||||
|  |  | ||||||
|  | <% if flash[:success].present? %> | ||||||
|  |   <div class="success"><%= flash[:success] %></div> | ||||||
|  | <% end %> | ||||||
|  |  | ||||||
|  | <% if flash[:warning].present? %> | ||||||
|  |   <div class="warning"><%= flash[:warning] %></div> | ||||||
|  | <% end %> | ||||||
|  |  | ||||||
|  | <% if flash[:notice].present? %> | ||||||
|  |   <div class="notice"><%= flash[:notice] %></div> | ||||||
|  | <% end %> | ||||||
| @@ -150,7 +150,9 @@ | |||||||
|       </div> |       </div> | ||||||
|  |  | ||||||
|       <div class="error">This is a sample error message.</div> |       <div class="error">This is a sample error message.</div> | ||||||
|  |       <div class="success">This is a sample success message.</div> | ||||||
|  |       <div class="warning">This is a sample warning message.</div> | ||||||
|  |       <div class="notice">This is a sample notice message.</div> | ||||||
|  |  | ||||||
|   <hr> |   <hr> | ||||||
|  |  | ||||||
|   | |||||||
| @@ -74,7 +74,7 @@ class RecruiterControllerTest < ActionDispatch::IntegrationTest | |||||||
|       end |       end | ||||||
|     end |     end | ||||||
|     assert_redirected_to recruiter_path |     assert_redirected_to recruiter_path | ||||||
|     assert flash[:notice] |     assert flash[:success] | ||||||
|   end |   end | ||||||
|  |  | ||||||
|   test "should fail creation with message" do |   test "should fail creation with message" do | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user