add admin flash messaging and styles
This commit is contained in:
parent
35f33e8215
commit
0058168c3e
@ -25,6 +25,16 @@
|
||||
background-color: #f39c12;
|
||||
}
|
||||
|
||||
.success {
|
||||
@extend .error;
|
||||
background-color: $brand-success;
|
||||
}
|
||||
|
||||
.notice {
|
||||
@extend .error;
|
||||
background-color: $brand-info;
|
||||
}
|
||||
|
||||
[data-id="live-coder-finish-later"] {
|
||||
.warning {
|
||||
margin-top: 0;
|
||||
|
@ -14,7 +14,7 @@ module Admin
|
||||
@question = Question.create(process_question_params)
|
||||
|
||||
if @question.persisted?
|
||||
redirect_to admin_questions_path, flash: { notice: "Sucessfully created question" }
|
||||
redirect_to admin_questions_path, flash: { success: "Sucessfully created question" }
|
||||
else
|
||||
flash[:error] = "Failed to save question."
|
||||
render :new
|
||||
@ -36,7 +36,7 @@ module Admin
|
||||
|
||||
if @question.update_attributes(process_question_params)
|
||||
redirect_to admin_question_path(@question.to_i),
|
||||
flash: { notice: "Sucessfully updated question" }
|
||||
flash: { success: "Sucessfully updated question" }
|
||||
else
|
||||
flash[:error] = "Failed to update question."
|
||||
render :edit
|
||||
|
@ -14,7 +14,7 @@ module Admin
|
||||
|
||||
if @user.persisted?
|
||||
# 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
|
||||
flash[:error] = "Failed to save user."
|
||||
render :new
|
||||
@ -34,7 +34,7 @@ module Admin
|
||||
|
||||
if @user.update_attributes(user_params)
|
||||
redirect_to admin_user_path(@user.to_i),
|
||||
flash: { notice: "Sucessfully updated #{@user.name}" }
|
||||
flash: { success: "Sucessfully updated #{@user.name}" }
|
||||
else
|
||||
flash[:error] = "Failed to update user."
|
||||
render :edit
|
||||
|
@ -1,6 +1,8 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
add_flash_types :warning, :success
|
||||
|
||||
def current_recruiter
|
||||
user_parms = { id: session[:user], role: %w(admin recruiter) }
|
||||
@current_recruiter ||= User.find_by(user_parms) if session[:user]
|
||||
|
@ -16,7 +16,7 @@ class RecruiterController < ApplicationController
|
||||
if @candidate.persisted?
|
||||
CandidateMailer.welcome(@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
|
||||
flash[:error] = "Failed to save candidate."
|
||||
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 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>
|
||||
|
||||
|
@ -74,7 +74,7 @@ class RecruiterControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
assert_redirected_to recruiter_path
|
||||
assert flash[:notice]
|
||||
assert flash[:success]
|
||||
end
|
||||
|
||||
test "should fail creation with message" do
|
||||
|
Loading…
Reference in New Issue
Block a user