forked from saurabh/orbit4-5
Role Status - UI work in progress
This commit is contained in:
parent
5773a826e4
commit
471cc0510a
|
@ -18,11 +18,11 @@ class Admin::AuthorizationsController < OrbitAdminController
|
||||||
end
|
end
|
||||||
unless @objects.blank?
|
unless @objects.blank?
|
||||||
@object ||= @objects.first
|
@object ||= @objects.first
|
||||||
@authorizations = Authorization.category_sub_managers(@object)
|
@authorizations = Authorization.category_sub_managers(@object) rescue nil
|
||||||
else
|
else
|
||||||
@error = t(:no_data)
|
@error = t(:no_data)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@authorizations = @module_app.module_managers rescue nil
|
@authorizations = @module_app.module_managers rescue nil
|
||||||
end
|
end
|
||||||
elsif @module_apps
|
elsif @module_apps
|
||||||
|
|
|
@ -2,7 +2,7 @@ class Admin::MembersController < OrbitMemberController
|
||||||
before_action :set_member_profile, only: [:show, :edit, :update]
|
before_action :set_member_profile, only: [:show, :edit, :update]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@roles = Role.all
|
@roles = Role.where(disabled: false).asc("_id")
|
||||||
page_num = params[:page] || 1
|
page_num = params[:page] || 1
|
||||||
|
|
||||||
@filter = params[:filter]
|
@filter = params[:filter]
|
||||||
|
@ -76,9 +76,11 @@ class Admin::MembersController < OrbitMemberController
|
||||||
@member = MemberProfile.new
|
@member = MemberProfile.new
|
||||||
get_info_and_roles
|
get_info_and_roles
|
||||||
@user = User.new
|
@user = User.new
|
||||||
|
@form_index = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
@form_index = 0
|
||||||
if @member.user.present?
|
if @member.user.present?
|
||||||
@user = @member.user
|
@user = @member.user
|
||||||
else
|
else
|
||||||
|
|
|
@ -2,8 +2,8 @@ class Admin::RoleStatusesController < OrbitMemberController
|
||||||
before_action :set_role_status, only: [:show, :edit , :update, :destroy]
|
before_action :set_role_status, only: [:show, :edit , :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@role = Role.find(params[:role_id])
|
@role = Role.find(params[:role_id]) rescue nil
|
||||||
@role_statuses = RoleStatus.where(role_id: @role.id)
|
@role_statuses = RoleStatus.where(role_id: @role.id) if @role
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html # index.html.erb
|
format.html # index.html.erb
|
||||||
|
@ -33,9 +33,18 @@ class Admin::RoleStatusesController < OrbitMemberController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
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
|
end
|
||||||
|
|
||||||
def toggle
|
def toggle
|
||||||
|
@role_status.disable = @role_status.disable ? false : true
|
||||||
|
@role_status.save!
|
||||||
|
render action: :index
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
|
|
@ -27,4 +27,14 @@ class MemberProfile
|
||||||
"#{self.first_name} #{self.last_name}"
|
"#{self.first_name} #{self.last_name}"
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
<div id="roles-area" class="input-area">
|
||||||
|
<%= render partial: "roles", collection: @roles %>
|
||||||
|
</div>
|
|
@ -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>
|
|
@ -0,0 +1 @@
|
||||||
|
<%= render partial: "role", collection: @roles %>
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
<%= render :partial => 'user_basic_passwd'%>
|
<%= render :partial => 'user_basic_passwd'%>
|
||||||
<%= render :partial => 'member_basic', :locals => {:f => f}%>
|
<%= render :partial => 'member_basic', :locals => {:f => f}%>
|
||||||
|
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
<div id="basic-area" class="input-area">
|
<div id="basic-area" class="input-area">
|
||||||
<%= render :partial => 'user_basic_passwd'%>
|
<%= render :partial => 'user_basic_passwd'%>
|
||||||
<%= render :partial => 'member_basic', :locals => {:f => f}%>
|
<%= render :partial => 'member_basic', :locals => {:f => f}%>
|
||||||
|
<%= render :partial => 'form', :locals => { :f => f } %>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -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 %>
|
|
@ -4,7 +4,7 @@
|
||||||
<%= f.fields_for :title_translations do |f| %>
|
<%= f.fields_for :title_translations do |f| %>
|
||||||
<% @site_in_use_locales.each do |locale| %>
|
<% @site_in_use_locales.each do |locale| %>
|
||||||
<%= label_tag "name-#{locale}", "#{t(:name)} (#{I18nVariable.from_locale(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 %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= f.hidden_field :role_id, :value => params[:role_id] if !params[:role_id].blank? %>
|
<%= f.hidden_field :role_id, :value => params[:role_id] if !params[:role_id].blank? %>
|
|
@ -9,7 +9,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<%= render :partial => 'role_status', :collection => @role_status %>
|
<%= render :partial => 'role_status', :collection => @role_statuses %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
|
@ -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>
|
<fieldset>
|
||||||
<legend>Add</legend>
|
<legend>Add</legend>
|
||||||
<%= render :partial => 'form', :locals => {:f => f} %>
|
<%= render partial: 'form', locals: {f: f} %>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
|
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
|
||||||
|
|
|
@ -14,6 +14,6 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<td class="action dsrgsdgsdg">
|
<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>
|
</td>
|
||||||
</tr>
|
</tr>
|
|
@ -0,0 +1,2 @@
|
||||||
|
$('<%= j render :partial => 'role_status', :collection => [@role_statuses] %>').appendTo('#role_filters').hide().fadeIn();
|
||||||
|
$("#form_role_filter")[0].reset();
|
|
@ -0,0 +1 @@
|
||||||
|
<%= render 'edit' %>
|
|
@ -0,0 +1 @@
|
||||||
|
$("#form > form").replaceWith("<%= j render "form" %>");
|
|
@ -0,0 +1,4 @@
|
||||||
|
// $("#role_filters_index").html("<%= j render 'index' %>")
|
||||||
|
location.reload();
|
||||||
|
$.pageslide.close();
|
||||||
|
openSlide();
|
|
@ -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();
|
Loading…
Reference in New Issue