Role Status - UI work in progress

This commit is contained in:
Saurabh Bhatia 2014-05-26 18:52:15 +08:00
parent 5773a826e4
commit 471cc0510a
19 changed files with 80 additions and 10 deletions

View File

@ -18,7 +18,7 @@ class Admin::AuthorizationsController < OrbitAdminController
end
unless @objects.blank?
@object ||= @objects.first
@authorizations = Authorization.category_sub_managers(@object)
@authorizations = Authorization.category_sub_managers(@object) rescue nil
else
@error = t(:no_data)
end

View File

@ -2,7 +2,7 @@ class Admin::MembersController < OrbitMemberController
before_action :set_member_profile, only: [:show, :edit, :update]
def index
@roles = Role.all
@roles = Role.where(disabled: false).asc("_id")
page_num = params[:page] || 1
@filter = params[:filter]
@ -76,9 +76,11 @@ class Admin::MembersController < OrbitMemberController
@member = MemberProfile.new
get_info_and_roles
@user = User.new
@form_index = 0
end
def edit
@form_index = 0
if @member.user.present?
@user = @member.user
else

View File

@ -2,8 +2,8 @@ class Admin::RoleStatusesController < OrbitMemberController
before_action :set_role_status, only: [:show, :edit , :update, :destroy]
def index
@role = Role.find(params[:role_id])
@role_statuses = RoleStatus.where(role_id: @role.id)
@role = Role.find(params[:role_id]) rescue nil
@role_statuses = RoleStatus.where(role_id: @role.id) if @role
respond_to do |format|
format.html # index.html.erb
@ -33,9 +33,18 @@ class Admin::RoleStatusesController < OrbitMemberController
end
def update
if @role_status.update_attributes(role_status_params)
redirect_to action: :index
else
flash.now[:error] = t('update.error.category')
render action: :edit
end
end
def toggle
@role_status.disable = @role_status.disable ? false : true
@role_status.save!
render action: :index
end
def destroy

View File

@ -27,4 +27,14 @@ class MemberProfile
"#{self.first_name} #{self.last_name}"
end
end
def disable_role=(var)
var[:id].each do |id,val|
if (val=="true")
self.role_ids.reject!{|t| t.to_s == id}
elsif(val=="false")
self.role_ids += Array(id)
end
end
end
end

View File

@ -0,0 +1,3 @@
<div id="roles-area" class="input-area">
<%= render partial: "roles", collection: @roles %>
</div>

View File

@ -0,0 +1,22 @@
<% role_disable = @member.roles.include?(role) ? false : true %>
<div class="attributes <%= role_disable ? 'disabled' : '' %>">
<div class="attributes-header clearfix">
<h4><%= role.title %><%= t(:role_info)%></h4>
</div>
<div class="attributes-body">
<% @form_index = @form_index +1 %>
<div class="control-group">
<%= label_tag t(:status), nil, {:func=>"field_label", :for=>"1", :class=>"control-label muted"} %>
<div class="controls">
<% role.role_statuses.where(disable: false).each_with_index do |rrs, i|%>
<% end %>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1 @@
<%= render partial: "role", collection: @roles %>

View File

@ -28,6 +28,7 @@
<%= render :partial => 'user_basic_passwd'%>
<%= render :partial => 'member_basic', :locals => {:f => f}%>
<%= render :partial => 'form', :locals => { :f => f } %>
</div>

View File

@ -26,6 +26,7 @@
<div id="basic-area" class="input-area">
<%= render :partial => 'user_basic_passwd'%>
<%= render :partial => 'member_basic', :locals => {:f => f}%>
<%= render :partial => 'form', :locals => { :f => f } %>
</div>

View File

@ -0,0 +1,10 @@
<%= form_for @role_status, url: admin_role_status_path(id: @role_status.id), remote: true, :html => { :id => 'form_role_filter' } do |f| %>
<fieldset>
<legend>Edit</legend>
<%= render :partial => 'form', :locals => {:f => f} %>
</fieldset>
<div class="form-actions">
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
<%= f.submit t(:update_), class: 'btn btn-primary btn-small' %>
</div>
<% end %>

View File

@ -4,7 +4,7 @@
<%= f.fields_for :title_translations do |f| %>
<% @site_in_use_locales.each do |locale| %>
<%= label_tag "name-#{locale}", "#{t(:name)} (#{I18nVariable.from_locale(locale)})" %>
<%= f.text_field locale, :class => 'input-large', :value => (@role_filter.title_translations[locale] rescue ''), placeholder: t(:name) %>
<%= f.text_field locale, :class => 'input-large', :value => (@role_status.title_translations[locale] rescue ''), placeholder: t(:name) %>
<% end %>
<% end %>
<%= f.hidden_field :role_id, :value => params[:role_id] if !params[:role_id].blank? %>

View File

@ -9,7 +9,7 @@
</tr>
</thead>
<tbody>
<%= render :partial => 'role_status', :collection => @role_status %>
<%= render :partial => 'role_status', :collection => @role_statuses %>
</tbody>
</table>

View File

@ -1,7 +1,7 @@
<%= form_for @role_status, url: admin_role_status_path(id: @role_status.id), remote: true, :html => { :id => 'form_role_filter' } do |f| %>
<%= form_for @role_status, url: admin_role_statuses_path(id: @role_status.id), remote: true, :html => { :id => 'form_role_filter' } do |f| %>
<fieldset>
<legend>Add</legend>
<%= render :partial => 'form', :locals => {:f => f} %>
<%= render partial: 'form', locals: {f: f} %>
</fieldset>
<div class="form-actions">
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>

View File

@ -14,6 +14,6 @@
<% end %>
<td class="action dsrgsdgsdg">
<%= check_box_tag 'accept', role_status.disable ? 'fasle' : 'true', false ,{ :class => 'toggle-check role_status_checked', :data=>{:deploy=>"right"}, :data=>{:path=> eval("admin_role_status_toggle_path(role_status)")}, :checked=> role_status.disable} %>
<%= check_box_tag 'accept', role_status.disable ? 'false' : 'true', false ,{ :class => 'toggle-check role_status_checked', :data=>{:deploy=>"right"}, :data=>{:path=> eval("admin_role_status_toggle_path(role_status)")}, :checked=> role_status.disable} %>
</td>
</tr>

View File

@ -0,0 +1,2 @@
$('<%= j render :partial => 'role_status', :collection => [@role_statuses] %>').appendTo('#role_filters').hide().fadeIn();
$("#form_role_filter")[0].reset();

View File

@ -0,0 +1 @@
<%= render 'edit' %>

View File

@ -0,0 +1 @@
$("#form > form").replaceWith("<%= j render "form" %>");

View File

@ -0,0 +1,4 @@
// $("#role_filters_index").html("<%= j render 'index' %>")
location.reload();
$.pageslide.close();
openSlide();

View File

@ -0,0 +1,3 @@
$("#<%= dom_id @role_status %>").replaceWith("<%= j render :partial => 'role_status', :collection => [@role_statuses] %>");
$("#form_role_filter").replaceWith("<%= j render "form" %>")
$("#form_role_filter")[0].reset();