Skip to content
Browse files

Fix most issues in #357. There is a CSS issue

which occurs on error after calling render
that we should fix seperately
  • Loading branch information...
1 parent 007962c commit 81c31395453ee144bb124cfb36ec1f18924eb58a @khanh khanh committed Mar 24, 2013
View
5 app/assets/stylesheets/application/components/forms.scss.erb
@@ -324,6 +324,11 @@ textarea[readonly] {
}
}
+// Actions on Sub-Forms like in manager/users/id
+.sub_actions {
+ padding-top: 5px;
+}
+
// Help Text
.help-inline,
.help-block {
View
1 app/models/user.rb
@@ -20,7 +20,6 @@ class User < ActiveRecord::Base
has_many :leading_groups, :through => :memberships, :source => :group, :conditions => {"memberships.level" => Membership::LEVELS[:leader]}
# Validations
- validates :email, :presence => true, :uniqueness => true
validates :first_name, :presence => true
scope :admin, where(:is_admin => true)
View
19 app/views/devise/registrations/edit.html.erb
@@ -8,31 +8,28 @@
<fieldset>
<div class="field">
- <%= f.label :password, "New password" %>
+ <%= f.label :current_password %>
<div class="inputs">
- <i>(leave blank if you don't want to change your password)</i>
- <%= f.password_field :password %>
+ <%= f.password_field :current_password %>
</div>
</div>
<div class="field">
- <%= f.label :password_confirmation, "Confirm new password" %>
+ <%= f.label :password, "New password" %>
<div class="inputs">
- <%= f.password_field :password_confirmation %>
+ <%= f.password_field :password %>
</div>
</div>
<div class="field">
- <%= f.label :current_password %>
+ <%= f.label :password_confirmation, "Confirm new password" %>
<div class="inputs">
- <i>(we need your current password to confirm your changes)</i>
- <%= f.password_field :current_password %>
+ <%= f.password_field :password_confirmation %>
</div>
</div>
</fieldset>
<div class="submit_bar actions">
- <%= f.submit "Submit", :class => "btn primary" "Update Account" %>
- &nbsp; &nbsp; &nbsp;
- <%= link_to "Cancel Account", registration_path(resource_name), :data => { :confirm => "Are you sure?"}, :method => :delete %>
+ <%= f.submit :class => "btn primary" %>
+ <%= link_to_function t(:cancel), "history.back()", :class => "btn" %>
</div>
<% end %>
View
1 app/views/elements/_topmenu_contents.html.erb
@@ -56,6 +56,7 @@
<section>
<div class="top-menu-sectop">
<%= link_to t(:dashboard), main_app.dashboard_path, :class => "btn #{ controller.controller_name == 'dashboard' ? 'selected' : '' }" %>
+ <%= link_to t(:manage_users), main_app.users_path, :class => "btn #{ controller.controller_name == 'users' ? 'selected' : '' }" %>
</div>
<div class="top-menu-secbot">
<h1><%= t(:admin) %></h1>
View
56 app/views/users/_form.html.erb
@@ -0,0 +1,56 @@
+<%= form_for(@user) do |f| %>
+<% if @user.errors.any? %>
+ <div id="error_explanation">
+ <h2><%= pluralize(@user.errors.count, t(:error)) + t(:prohibited_save, :model => 'user') %></h2>
+
+ <ul>
+ <% @user.errors.full_messages.each do |msg| %>
+ <li><%= msg %></li>
+ <% end %>
+ </ul>
+ </div>
+<% end %>
+
+<fieldset>
+ <div class="clearfix">
+ <%= f.label :first_name %>
+ <div class="input">
+ <div class="inline-inputs">
+ <%= f.text_field :first_name, :class => "span3" %> <%= f.text_field :last_name, :class => "span3" %>
+ </div>
+ </div>
+ </div>
+
+ <div class="clearfix">
+ <%= f.label :email %>
+ <div class="input">
+ <%= f.text_field :email, :class => "span4" %>
+ </div>
+ </div>
+
+ <div class="clearfix">
+ <%= f.label :locale %>
+ <div class="input">
+ <%= f.select :locale, options_for_select(I18n.available_locales, I18n.locale.to_sym) %>
+ </div>
+ </div>
+
+ <div class="clearfix">
+ <div class="input">
+ <%= f.check_box :receive_moderation_notifications %> <%= f.label :receive_moderation_notifications %>
+ </div>
+ </div>
+
+ <% if can? :manage, @user %>
+ <div class="clearfix">
+ <div class="input">
+ <%= f.check_box :is_admin %> <%= f.label :is_admin %>
+ </div>
+ </div>
+ <% end %>
+</fieldset>
+<div class="submit_bar actions">
+ <%= f.submit :class => "btn primary" %>
+ <%= link_to_function t(:cancel), "history.back()", :class => "btn" %>
+</div>
+<% end %>
View
7 app/views/users/_show_body.html.erb
@@ -18,6 +18,9 @@
<% if user_signed_in? and current_user == @user %>
<p style="margin-bottom: 0px;"><b><%= t(:you) %></b></p>
+ <p><%= link_to t(:edit_settings), edit_user_path, :class => "btn primary" %></p>
+ <p><%= link_to t(:change_password), edit_user_registration_path, :class => "btn primary" %></p>
+ <p><%= link_to t(:delete_account), registration_path(@user), :data => { :confirm => "Are you sure?"}, :method => :delete, :class => "btn danger" %></p>
<% end %>
</div>
</div>
@@ -50,7 +53,9 @@
<%= membership.level_name.humanize %>
<% end %>
<%= f.select :receive_emails, {"Receive Emails" => true, "Don't Receive Emails" => false}%>
- <%= f.submit t(:submit), :class => "btn" %>
+ <div class="submit_bar sub_actions">
+ <%= f.submit :class => "btn primary" %>
+ </div>
<% end %>
</td>
<% end %>
View
63 app/views/users/edit.html.erb
@@ -3,67 +3,6 @@
<h1 class="default-padding">Edit User</h1>
</header>
<div class="viewblock-cont">
- <%= form_for(@user) do |f| %>
- <% if @user.errors.any? %>
- <div id="error_explanation">
- <h2><%= pluralize(@user.errors.count, t(:error)) + t(:prohibited_save, :model => 'user') %></h2>
-
- <ul>
- <% @user.errors.full_messages.each do |msg| %>
- <li><%= msg %></li>
- <% end %>
- </ul>
- </div>
- <% end %>
-
- <fieldset>
- <div class="clearfix">
- <%= f.label :first_name %>
- <div class="input">
- <div class="inline-inputs">
- <%= f.text_field :first_name, :class => "span3" %> <%= f.text_field :last_name, :class => "span3" %>
- </div>
- </div>
- </div>
-
- <div class="clearfix">
- <%= f.label :email %>
- <div class="input">
- <%= f.text_field :email, :class => "span4" %>
- </div>
- </div>
-
- <div class="clearfix">
- <%= f.label :locale %>
- <div class="input">
- <%= f.select :locale, options_for_select(I18n.available_locales, I18n.locale.to_sym) %>
- </div>
- </div>
-
- <div class="clearfix">
- <div class="input">
- <%= f.check_box :receive_moderation_notifications %> <%= f.label :receive_moderation_notifications %>
- </div>
- </div>
-
- <% if can? :manage, @user %>
- <div class="clearfix">
- <div class="input">
- <%= f.check_box :is_admin %> <%= f.label :is_admin %>
- </div>
- </div>
- <% end %>
- </fieldset>
-
- <div class="submit_bar actions">
- <%= f.submit t(:submit), :class => "btn primary" %>
- <% if @user.id == current_user.id %>
- &nbsp; &nbsp; &nbsp; &nbsp;
- <%= link_to t(:change_password), edit_user_registration_path %>
- <% end %>
- </div>
- <% end %>
-
-
+ <%= render :partial => 'users/form' %>
</div>
</section>
View
54 app/views/users/new.html.erb
@@ -3,56 +3,6 @@
<h1 class="default-padding"><%= t(:new_user) %></h1>
</header>
<div class="viewblock-cont">
- <%= form_for(@user) do |f| %>
- <% if @user.errors.any? %>
- <div id="error_explanation">
- <h2><%= pluralize(@user.errors.count, t(:error)) + t(:prohibited_save, :model => 'user') %></h2>
-
- <ul>
- <% @user.errors.full_messages.each do |msg| %>
- <li><%= msg %></li>
- <% end %>
- </ul>
- </div>
- <% end %>
-
- <fieldset>
- <div class="clearfix">
- <%= f.label :first_name %>
- <div class="input">
- <div class="inline-inputs">
- <%= f.text_field :first_name, :class => "span3" %> <%= f.text_field :last_name, :class => "span3" %>
- </div>
- </div>
- </div>
-
- <div class="clearfix">
- <%= f.label :email %>
- <div class="input">
- <%= f.text_field :email, :class => "span4" %>
- </div>
- </div>
-
- <div class="clearfix">
- <%= f.label :password %>
- <div class="input">
- <%= f.password_field :password %>
- </div>
- </div>
-
- <% if can? :manage, @user %>
- <div class="clearfix">
- <div class="input">
- <%= f.check_box :is_admin %> <%= f.label :is_admin %>
- </div>
- </div>
- <% end %>
- </fieldset>
-
- <div class="submit_bar actions">
- <%= f.submit t(:submit), :class => "btn primary" %>
- </div>
- <% end %>
-
- </div>
+ <%= render :partial => 'users/form' %>
+ </div>
</section>
View
1 config/locales/views/elements/en.yml
@@ -22,3 +22,4 @@ en:
system_admin: "You are a system-wide admin"
leader: "You are a leader of one or more groups"
dashboard: "Dashboard"
+ manage_users: "Manage Users"
View
12 config/locales/views/users/en.yml
@@ -1,6 +1,7 @@
en:
#_show_header
all_users: 'All Users'
+ create: 'Create'
#_show_body
system_wide_admin: 'This user is a system-wide admin'
@@ -12,8 +13,9 @@ en:
contents: 'Contents'
#edit
- change_password: 'Change your password'
-
+ change_password: 'Change Password'
+ delete_account: 'Delete Account'
+ edit_settings: 'Edit Settings'
#index
new_user: 'New User'
first_name: 'First Name'
@@ -33,6 +35,6 @@ en:
password: 'Password'
new_password: 'New Password'
password_confirmation: 'Confirm New Password'
- submit:
- create: 'Create'
- update: 'Update'
+ submit:
+ create: 'Create'
+ update: 'Update'

0 comments on commit 81c3139

Please sign in to comment.
Something went wrong with that request. Please try again.