member roles edit

This commit is contained in:
unknown 2013-01-08 16:58:01 +08:00
parent 5002916352
commit 9584d67b23
22 changed files with 975 additions and 139 deletions

View File

@ -72,10 +72,10 @@ end
group :test, :development do group :test, :development do
gem 'pry' #gem 'pry'
gem 'pry-remote' #gem 'pry-remote'
gem 'pry-stack_explorer' #gem 'pry-stack_explorer'
gem 'pry-debugger' #gem 'pry-debugger'
gem 'faker' gem 'faker'
gem "sunspot-rails-tester" gem "sunspot-rails-tester"

View File

@ -3,7 +3,7 @@ class Admin::RolesController < ApplicationController
layout "new_admin" layout "new_admin"
before_filter :authenticate_user! before_filter :authenticate_user!
before_filter :is_admin? before_filter :is_admin?
before_filter :set_attribute, :only => [:index, :show, :new, :edit] before_filter :set_attribute, :only => [:index, :show, :new, :edit, :role_field, :sub_role, :add_sub_role, :edit_sub_role, :sub_role_field]
helper Admin::AttributeValuesViewHelper helper Admin::AttributeValuesViewHelper
def index def index
@ -13,13 +13,100 @@ class Admin::RolesController < ApplicationController
def show def show
end
def role_field
@field_name = 'role'
@attribute = Role.find(params[:role_id])
end
def sub_role
@attribute = Role.find(params[:role_id])
@attribute_fields_upper_object = @attribute.sub_roles
end
def add_sub_role
@attribute = Role.find(params[:role_id])
# @sub_attribute = Role.find(params[:role_id])
@sub_attribute = SubRole.new
@sub_attribute.role_id = params[:role_id]
end
def edit_sub_role
@sub_attribute = SubRole.find(params[:role_id])
@attribute = Role.find(@sub_attribute.role_id)
@sub_attribute.role_id = @sub_attribute.role_id
end
def sub_role_field
@field_name = 'sub_role'
@sub_attribute = SubRole.find(params[:role_id])
@attribute = Role.find(@sub_attribute.role_id)
end
def add_attribute_field
if params[:sub_role]
@field_name = 'sub_role'
attribute = SubRole.find(params[:sub_role][:id]) rescue nil
@attribute_field_counter = attribute.attribute_fields.count
@attribute_field = attribute.attribute_fields.build
@attribute_field.save
@attribute_field[:af_count] = @attribute_field_counter
@attribute = SubRole.find(params[:sub_role][:id])
else
@field_name = 'role'
attribute = Role.find(params[:role_id]) rescue nil
@attribute_field_counter = attribute.attribute_fields.count
@attribute_field = attribute.attribute_fields.build
@attribute_field.save
@attribute_field[:af_count] = @attribute_field_counter
@attribute = Role.find(params[:role_id])
end
respond_to do |format|
format.js { render 'add_attribute_field' }
end
end end
def new def new
@attribute = Role.new @attribute = Role.new
if !params[:parent_id]
render :template => 'admin/attributes/new' render :template => 'admin/attributes/new'
end end
end
def edit def edit
@attribute = Role.find(params[:id]) @attribute = Role.find(params[:id])
@attribute_fields_upper_object = @attribute.sub_roles @attribute_fields_upper_object = @attribute.sub_roles
@ -27,24 +114,75 @@ class Admin::RolesController < ApplicationController
end end
def create def create
if params[:sub_role]
@sub_role = SubRole.new(params[:sub_role])
# @sub_role.role_id = params[:id]
respond_to do |format|
if @sub_role.save
format.html { redirect_to(admin_role_sub_role_url(params[:sub_role][:role_id])) }
end
end
else
@attribute = Role.new(params[:role]) @attribute = Role.new(params[:role])
@attribute.save @attribute.save
redirect_to :action => :index redirect_to :action => :index
end
end end
def update def update
if params[:sub_role]
@sub_role = SubRole.find(params[:sub_role][:id])
@sub_role.update_attributes(params[:sub_role])
@sub_role.attribute_fields.each{|t| t.destroy if t["to_delete"] == true}
respond_to do |format|
format.html { redirect_to(admin_role_sub_role_url(@sub_role.role_id)) }
format.js { render 'toggle_enable' }
end
else
@attribute = Role.find(params[:id]) @attribute = Role.find(params[:id])
@attribute.update_attributes(params[:role]) @attribute.update_attributes(params[:role])
@attribute.attribute_fields.each{|t| t.destroy if t["to_delete"] == true}
respond_to do |format| respond_to do |format|
format.html { redirect_to :action => :index } format.html { redirect_to :action => :index }
format.js { render 'admin/attributes/toggle_enable' } format.js { render 'admin/attributes/toggle_enable' }
end end
end
end end
def destroy def destroy
if params[:sub_role]
@sub_role = SubRole.find(params[:sub_role][:id])
respond_to do |format|
if @sub_role.destroy
format.html { redirect_to(admin_role_sub_role_url(@sub_role.role_id)) }
end
end
else
@attribute = Role.find(params[:id]) @attribute = Role.find(params[:id])
@attribute.destroy @attribute.destroy
redirect_to :action => :index redirect_to :action => :index
end
end end
protected protected

View File

@ -0,0 +1,4 @@
class Admin::SubRolesController < RolesController
end

View File

@ -11,6 +11,9 @@ class AttributeField
field :built_in, :type => Boolean, :default => false field :built_in, :type => Boolean, :default => false
field :disabled, :type => Boolean, :default => false field :disabled, :type => Boolean, :default => false
field :to_delete,:type=> Boolean,:default => false field :to_delete,:type=> Boolean,:default => false
field :to_search,:type=> Boolean,:default => false
field :typeA,:type=> Hash,:default=>{:cross_lang=>false} field :typeA,:type=> Hash,:default=>{:cross_lang=>false}
field :typeB,:type=> Hash,:default=>{} field :typeB,:type=> Hash,:default=>{}
field :typeC,:type=> Hash,:default=>{:calendar=>"west_calendar",:format=>"format3"} field :typeC,:type=> Hash,:default=>{:calendar=>"west_calendar",:format=>"format3"}

View File

@ -1,4 +1,4 @@
class Role class Role < Attribute
include Mongoid::Document include Mongoid::Document
include Mongoid::Timestamps include Mongoid::Timestamps
@ -6,12 +6,15 @@ class Role
field :key field :key
field :built_in, :type => Boolean, :default => false field :built_in, :type => Boolean, :default => false
field :disabled, :type => Boolean, :default => false field :disabled, :type => Boolean, :default => false
field :to_search, :type => Boolean, :default => false
field :title, localize: true field :title, localize: true
has_many :sub_roles, :autosave => true, :dependent => :destroy has_many :sub_roles, :autosave => true, :dependent => :destroy
has_many :users has_many :users
has_many :statuses, :autosave => true, :dependent => :destroy has_many :statuses, :autosave => true, :dependent => :destroy
has_many :attribute_fields, :autosave => true, :dependent => :destroy # has_many :attribute_fields, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :sub_roles, :allow_destroy => true accepts_nested_attributes_for :sub_roles, :allow_destroy => true
def is_built_in? def is_built_in?

View File

@ -0,0 +1,4 @@
<div class="map-block back attributes">
<h4><span><%= attribute_field_list.title+ t("admin.attributes")%></span></h4>
<%= render :partial=>"shared/attribute_field/attribute_field",:collection=>attribute_field_list.attribute_fields%>
</div>

View File

@ -1,9 +1,29 @@
<%= form_for @attribute,:url => admin_info_path(@attribute) ,:class=> "form-horizontal" do |f| %> <% content_for :side_bar do %>
<%= render :partial => 'layouts/side_bar', :locals => {:link_name => t(:member), :link_url => admin_site_site_info_path(@site), :icon => 'icons-group', :side_bar_content => 'admin/users_new_interface/side_bar'} %>
<% end %>
<%= form_for @attribute,:url => eval("admin_#{@attribute_type}_path(@attribute)") ,:class=> "form-horizontal" do |f| %>
<div class="site-map role-block"> <div class="site-map role-block">
<div class="map-block back"> <div class="map-block back">
<h4><span><%= t(:info)%></span></h4> <h4><span><%= t(eval(":#{@attribute_type}"))%></span></h4>
<div class="form-horizontal"> <div class="form-horizontal">
<div class="clear"> <div class="clear">
<% if @attribute._type == "Role" %>
<div class="control-group pull-left">
<label class="control-label" for="key"><%= t(:to_search) %></label>
<div class="controls">
<label class="radio inline">
<%= f.radio_button :to_search, true %>
Yes
</label>
<label class="radio inline">
<%= f.radio_button :to_search, false %>
No
</label>
</div>
</div>
<% end %>
<div class="control-group pull-left"> <div class="control-group pull-left">
<label class="control-label" for="key"><%= t(:key) %></label> <label class="control-label" for="key"><%= t(:key) %></label>
<div class="controls"> <div class="controls">
@ -14,10 +34,11 @@
<% end %> <% end %>
</div> </div>
</div> </div>
<%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>@attribute.title_translations,:class_ext=>"pull-left",:label_ext=>t(:item_name),:field_name=>"info[title_translations]"}%> <%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>@attribute.title_translations,:class_ext=>"pull-left",:label_ext=>t(:item_name),:field_name=>"#{@attribute_type}[title_translations]"}%>
</div> </div>
</div> </div>
</div> </div>
<% if @attribute._type == "Info" %>
<div class="map-block back attributes"> <div class="map-block back attributes">
<h4><span><%= @attribute.title+ t(:attributes)%></span></h4> <h4><span><%= @attribute.title+ t(:attributes)%></span></h4>
@ -26,11 +47,13 @@
</div> </div>
</div> </div>
<% end %>
</div> </div>
<div class="form-actions form-fixed pagination-right"> <div class="form-actions form-fixed pagination-right">
<%= link_to content_tag(:i,t(:add_attribute_field),:class=>"icon-plus icon-white"),admin_info_add_attribute_field_path(@attribute),:class=>"btn btn-primary",:remote => true%> <%= ( link_to content_tag(:i,t(:add_attribute_field),:class=>"icon-plus icon-white"),admin_info_add_attribute_field_path(@attribute),:class=>"btn btn-primary",:remote => true ) if @attribute._type == "Info"%>
<%= f.submit t(:save),:class=>"btn btn-primary"%> <%= f.submit t(:save),:class=>"btn btn-primary"%>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div> </div>
<% end %> <% end %>
<% content_for :page_specific_css do -%> <% content_for :page_specific_css do -%>
@ -40,11 +63,15 @@
<% content_for :page_specific_javascript do -%> <% content_for :page_specific_javascript do -%>
<script> <script>
var CloneTarget ;
var NewNode;
$(document).ready(function(){ $(document).ready(function(){
// function mas(){
// $('.site-map').masonry({
// itemSelector: '.map-block',
// columnWidth: 450,
// isAnimated: true
// });
// }
function checkSwitch() { function checkSwitch() {
$(".groups").addClass('disabled').has('.groups > .form-horizontal > div:not(.hide)').removeClass('disabled'); $(".groups").addClass('disabled').has('.groups > .form-horizontal > div:not(.hide)').removeClass('disabled');
} }
@ -54,40 +81,109 @@
}); });
} }
function removeInput() { function removeInput() {
$(".removeInput").live('click',function (){ $(".removeInput").click(function (){
$(this).parents(".controls").remove(); $(this).parents(".controls").remove();
checkMultipleInput(); checkMultipleInput();
return false; return false;
}); });
} }
checkSwitch(); function DataType() {
checkMultipleInput(); $(".dataType").each(function (i) {
removeInput(); $(this).change(function () {
$(".remove_attribute").live('click',function(){ $("option:selected").eq(i).each(function () {
$(this).siblings(".attribute_field_to_delete").val("true"); if($(this).attr("ref")=="typeA") {
$(this).parents(".form-horizontal").fadeOut("slow", function () { $(this).hide(); }); $(this).parents("legend").next("div").find("div[class^='type']").addClass("hide");
$(this).parents("legend").next("div").find(".typeA").removeClass("hide");
$(this).parents("legend").next("div").addClass("bottomLine");
}
if($(this).attr("ref")=="typeB") {
$(this).parents("legend").next("div").find("div[class^='type']").addClass("hide");
$(this).parents("legend").next("div").find(".typeB").removeClass("hide");
$(this).parents("legend").next("div").addClass("bottomLine");
}
if($(this).attr("ref")=="typeC") {
$(this).parents("legend").next("div").find("div[class^='type']").addClass("hide");
$(this).parents("legend").next("div").find(".typeC").removeClass("hide");
$(this).parents("legend").next("div").addClass("bottomLine");
}
if($(this).attr("ref")=="typeD") {
$(this).parents("legend").next("div").find("div[class^='type']").addClass("hide");
$(this).parents("legend").next("div").find(".typeD").removeClass("hide");
$(this).parents("legend").next("div").addClass("bottomLine");
}
if($(this).attr("ref")=="typeE") {
$(this).parents("legend").next("div").find("div[class^='type']").addClass("hide");
$(this).parents("legend").next("div").find(".typeE").removeClass("hide");
$(this).parents("legend").next("div").addClass("bottomLine");
}
if($(this).attr("ref")=="nothing"||$(this).attr("ref")=="typeF") {
$(this).parents("legend").next("div").find("div[class^='type']").addClass("hide");
$(this).parents("legend").next("div").removeClass("bottomLine");
}
}); });
$(".help-block a").live('click',function (){
CloneTarget = $(this).parents(".controls").prev(".multipleInput").find('.controls:last');
NewNode = CloneTarget.clone();
var index;
NewNode.find("input").each(function(k,v){
index = CloneTarget.parents("div.control-group").find(".list_count").val()
field_name = CloneTarget.parents("div.control-group").find(".field_name").val()
ori_str = $(v).attr("name").replace(field_name,"");
lang = ori_str.match(/\[\D*\]/);
new_field_name = (field_name+"[" + (parseInt(index)+1) + "]" + lang);
$(v).attr("name",new_field_name);
}) })
});
$(this).parents("div.control-group").find(".list_count").val(parseInt(index)+1) }
$(this).parents(".controls").prev(".multipleInput").append(NewNode); function onOff() {
$(".form-horizontal:last").delegate(".onoff","click",function(){
$(this).parent("legend").parent(".form-horizontal").toggleClass("disabled");
$(this).toggleClass("disabled");
$(this).parents("legend").next("div").toggleClass("disabled");
$(this).parents("legend").next("div").find(".help-block").toggleClass("hide");
if($(this).parents("legend").next("div").hasClass("disabled")){
$(this).text("OFF");
$(this).parents("legend").find("input, select, textarea").attr({disabled:''});
$(this).parents("legend").next("div").find("input, select, textarea").attr({disabled:''});
}else{
$(this).text("ON");
$(this).parents("legend").find("input, select, textarea").removeAttr("disabled");
$(this).parents("legend").next("div").find("input, select, textarea").removeAttr("disabled");
}
checkSwitch();
return!1
});
// $('.onoff').click(function () {
// // if($(this).parents("h4").length==1) {
// // $(this).parents(".map-block").toggleClass("disabled");
// // $(this).parents(".map-block").find(".form-horizontal").toggleClass("hide");
// // if($(this).parents(".map-block").hasClass("disabled")){
// // $(this).text("OFF");
// // }else{
// // $(this).text("ON");
// // }
// // }
// // if($(this).parents("legend").length==1) {
// $(this).toggleClass("disabled");
// $(this).parents("legend").next("div").toggleClass("disabled");
// if($(this).parents("legend").next("div").hasClass("disabled")){
// $(this).text("OFF");
// $(this).parents("legend").find("input, select, textarea").attr({disabled:''});
// $(this).parents("legend").next("div").find("input, select, textarea").attr({disabled:''});
// }else{
// $(this).text("ON");
// $(this).parents("legend").find("input, select, textarea").removeAttr("disabled");
// $(this).parents("legend").next("div").find("input, select, textarea").removeAttr("disabled");
// }
// checkSwitch();
// // }
// return false;
// });
}
function CloneDataType() {
$(".help-block a").click(function (){
var $CloneTarget = $(this).parents(".controls").prev(".multipleInput").find('.controls:last');
$(this).parents(".controls").prev(".multipleInput").append($CloneTarget.clone());
$(this).parents(".controls").prev(".multipleInput").find('.controls:last input').val(""); $(this).parents(".controls").prev(".multipleInput").find('.controls:last input').val("");
removeInput(); removeInput();
checkMultipleInput(); checkMultipleInput();
return false; return false;
}) })
}
checkSwitch();
checkMultipleInput();
removeInput();
DataType();
CloneDataType();
$(".status select").each(function (i) { $(".status select").each(function (i) {
$(this).change(function () { $(this).change(function () {
$(".status option:selected").eq(i).each(function () { $(".status option:selected").eq(i).each(function () {
@ -100,34 +196,39 @@
} }
}); });
}) })
}) });
$('.onoff').live('click',function () { $(".form-horizontal").delegate(".onoff","click",function(){
if($(this).parents("h4").length==1) {
$(this).parents(".map-block").toggleClass("disabled");
$(this).parents(".map-block").find(".form-horizontal").toggleClass("hide");
if($(this).parents(".map-block").hasClass("disabled")){
$(this).text("OFF");
}else{
$(this).text("ON");
}
}
if($(this).parents("legend").length==1) {
$(this).toggleClass("disabled"); $(this).toggleClass("disabled");
$(this).parents("legend").next("div").toggleClass("hide"); $(this).parent("legend").parent(".form-horizontal").toggleClass("disabled");
if($(this).parents("legend").next("div").hasClass("hide")){ $(this).parents("legend").next("div").toggleClass("disabled");
$(this).parents("legend").next("div").find(".help-block").toggleClass("hide");
if($(this).parents("legend").next("div").hasClass("disabled")){
$(this).text("OFF"); $(this).text("OFF");
$(this).siblings(".attribute_field_disabled").val("true"); $(this).parents("legend").find("input, select, textarea").attr({disabled:''});
$(this).parents("legend").next("div").find("input, select, textarea").attr({disabled:''});
}else{ }else{
$(this).text("ON"); $(this).text("ON");
$(this).siblings(".attribute_field_disabled").val("false"); $(this).parents("legend").find("input, select, textarea").removeAttr("disabled");
$(this).parents("legend").next("div").find("input, select, textarea").removeAttr("disabled");
} }
checkSwitch(); checkSwitch();
} return!1
return false;
}); });
$(".dataType").change(function () { $(".add-attributes a").click(function (){
$(this).parents("legend").next("div").find("div[class^='type']").addClass("hide"); var $CloneTarget = $(this).parents(".attributes").find('.form-horizontal:last');
$(this).parents("legend").next("div").find("."+$(this).find("option:selected").attr("ref")).removeClass("hide"); $(".cistern").append($CloneTarget.clone());
$('.form-horizontal:last input, .form-horizontal:last select, .form-horizontal:last textarea').val("");
$('.form-horizontal:last input, .form-horizontal:last select, .form-horizontal:last textarea').removeAttr("disabled");
$('.form-horizontal:last').find("legend").next("div").find("div[class^='type']").addClass("hide");
if($('.form-horizontal:last').find("legend").next("div").hasClass("disabled")) {
$('.form-horizontal:last').find("legend>button").removeClass("disabled");
$('.form-horizontal:last').find("legend>button").text("ON");
$('.form-horizontal:last').find("legend").next("div").removeClass("disabled");
}
DataType();
onOff();
CloneDataType();
return false;
}) })
}); });
</script> </script>

View File

@ -1,39 +1,72 @@
<% content_for :secondary do %> <% # encoding: utf-8 %>
<%= render 'admin/users_new_interface/side_bar' %>
<% content_for :side_bar do %>
<%= render :partial => 'layouts/side_bar', :locals => {:link_name => t(:member), :link_url => admin_site_site_info_path(@site), :icon => 'icons-group', :side_bar_content => 'admin/users_new_interface/side_bar'} %>
<% end %> <% end %>
<div class="main_list">
<div class="button_bar up">
<%= link_to t("new.#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path"), :class => 'new' %> <div class="subnav">
<div id="accordion">
<div class="accordion-group filters">
<div class="table-label">
<table class="table main-list">
<thead>
<tr class="sort-header">
<th id="sort-name" class="sort span1-2 select active"><span><a href="#"><%= t("#{@attribute_type}") %><b class="web-symbol"></b></a></span></th>
</tr>
</thead>
</table>
</div> </div>
<table> </div>
</div>
</div>
<table class="table main-list member-list">
<thead> <thead>
<tr> <tr>
<td class="<%= @attribute_type %>s"><%= t("#{@attribute_type}") %></td> <th class="span1-2"></th>
<td class="action"><%= t(:action) %></td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% @attributes.each do |attribute| %>
<tr id="attribute_<%= attribute.id %>" class="have <%= "#{attribute.is_disabled? ? 'disable' : ''}" %>">
<td class="<%= @attribute_type %>s <%= attribute.key.downcase %>"><%= attribute.title %></span>
<td class="action">
<%= link_to t(:edit), eval("edit_admin_#{@attribute_type}_path(attribute)"), :class => 'edit' %> <% @attributes.each do |attribute| %>
<%= link_to t(:enable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{@attribute_type} => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? 'none' : ''}", :class => 'switch' %> <tr class="with_action">
<%= link_to t(:disable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{@attribute_type} => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? '' : 'none'}", :class => 'switch' %> <td class="span1-2">
<% if !attribute.is_built_in? %> <%= attribute.title %>
<%= link_to t(:delete_), eval("admin_#{@attribute_type}_path(attribute)"), :class => 'delete', :confirm => t('sure?'), :method => :delete %> <div class="quick-edit">
<ul class="nav nav-pills hide">
<li><%= link_to t(:edit), eval("edit_admin_#{@attribute_type}_path(attribute)") %></li>
<% if @attribute_type == 'role' %>
<li><%= link_to t(:role_field), eval("admin_#{@attribute_type}_role_field_path(attribute)") %></li>
<li><%= link_to t(:sub_role), eval("admin_#{@attribute_type}_sub_role_path(attribute)") %></li>
<% end %> <% end %>
<li><%= link_to t(:enable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{@attribute_type} => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? 'none' : ''}", :class => 'switch' %></li>
<li><%= link_to t(:disable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{@attribute_type} => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? '' : 'none'}", :class => 'switch' %></li>
<% if !attribute.is_built_in? %>
<li><%= link_to t(:delete_), eval("admin_#{@attribute_type}_path(attribute)"), :class => 'delete', :confirm => t('sure?'), :method => :delete %></li>
<% end %>
</ul>
</div>
</td> </td>
</tr> </tr>
<tr>
<td colspan="5"></td>
</tr>
<% end %> <% end %>
</tbody> </tbody>
</table> </table>
<div class="button_bar"> <div class="form-actions form-fixed pagination-right">
<%= link_to t("new.#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path"), :class => 'new' %> <%= link_to content_tag(:i,t("new.#{@attribute_type}"),:class=>"icon-plus icon-white"),eval("new_admin_#{@attribute_type}_path"),:class=>"btn btn-primary pull-right"%>
<div class="paginationFixed">
<div class="pagination">
<ul>
<li><a href="#">Prev</a></li>
<li class="active"><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">Next</a></li>
</ul>
</div> </div>
</div> </div>
</div>

View File

@ -1,14 +1,51 @@
<% content_for :secondary do %> <%= form_for @attribute,:url => eval("admin_#{@attribute_type}s_path") ,:class=> "form-horizontal" do |f| %>
<%= render 'admin/users_new_interface/side_bar' %> <div class="site-map role-block">
<div class="map-block back">
<h4><span><%= t(eval(":#{@attribute_type}"))%></span></h4>
<div class="form-horizontal">
<div class="clear">
<% if @attribute._type == "Role" %>
<div class="control-group pull-left">
<label class="control-label" for="key"><%= t(:to_search) %></label>
<div class="controls">
<label class="radio inline">
<%= f.radio_button :to_search, true %>
Yes
</label>
<label class="radio inline">
<%= f.radio_button :to_search, false %>
No
</label>
</div>
</div>
<% end %> <% end %>
<div id="profile"> <div class="control-group pull-left">
<%= form_for @attribute, :url => eval("admin_#{@attribute_type}s_path") do |f| %> <label class="control-label" for="key"><%= t(:key) %></label>
<%= f.error_messages %> <div class="controls">
<%= render :partial => "admin/#{@attribute_type}s/form", :locals => { :f => f, :is_new => true } %> <% if @attribute.new_record? %>
<div class="button_bar"> <%= f.text_field :key, :placeholder => t(:key) %>
<%= link_back %> <% else %>
<%= link_to t('create'), "#", :onclick=>"$('#new_#{@attribute_type}').submit()" %> <div><%= @attribute.key%></div>
<% end %>
</div> </div>
<% end -%>
</div> </div>
<%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>@attribute.title_translations,:class_ext=>"pull-left",:label_ext=>t(:item_name),:field_name=>"#{@attribute_type}[title_translations]"}%>
</div>
</div>
</div>
</div>
<div class="form-actions form-fixed pagination-right">
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
<% end %>
<% content_for :page_specific_css do -%>
<%= stylesheet_link_tag "member" %>
<%= stylesheet_link_tag "site-map" %>
<% end %>

View File

@ -0,0 +1,121 @@
<div class="form-horizontal <%= attribute_field.disabled ? 'disabled' : ''%>">
<%
attribute_field.af_count ? @af_counter = attribute_field_counter + attribute_field.af_count : @af_counter = attribute_field_counter
%>
<%= @af_counter %>
<%#= attribute_field_counter %>
<legend>
<button class="onoff pull-right <%= attribute_field.disabled ? 'disabled' : ''%>"><%= attribute_field.disabled ? 'OFF' : 'ON'%></button>
<%= hidden_field "#{@field_name}[attribute_fields][#{@af_counter}]","disabled",:value=>attribute_field.disabled,:class=>"attribute_field_disabled"%>
<%= hidden_field "#{@field_name}[attribute_fields][#{@af_counter}]","to_delete",:value=>false,:class=>"attribute_field_to_delete"%>
<a class="btn btn-small pull-right btn-danger remove_attribute" href="#"><i class="icon-trash icon-large"></i> <%= t(:delete_)%></a>
<div class="clear">
<div class="control-group">
<label class="control-label" for="key"><%= t(:to_search) %></label>
<div class="controls">
<label class="radio inline">
<%= radio_button("#{@field_name}[attribute_fields][#{@af_counter}]", "to_search", "true",:checked => (attribute_field.to_search == true ? true : false)) %><%= t(:yes_)%>
</label>
<label class="radio inline">
<%= radio_button("#{@field_name}[attribute_fields][#{@af_counter}]", "to_search", "false",:checked => (attribute_field.to_search == false ? true : false)) %><%= t(:no_)%>
</label>
</div>
</div>
<div class="control-group pull-left">
<label class="control-label" for="key"><%= t(:key) %></label>
<div class="multipleInput">
<div class="controls">
<%= text_field "#{@field_name}[attribute_fields][#{@af_counter}]","key",:value=>attribute_field.key%>
</div>
</div>
</div>
<%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>attribute_field.title_translations,:class_ext=>"pull-left",:label_ext=>t(:name),:field_name=>"#{@field_name}[attribute_fields][#{@af_counter}][title_translations]"}%>
<div class="control-group pull-left">
<label class="control-label" for=""><%= t(:type)%></label>
<div class="controls">
<%#= select_tag "#{@field_name}[attribute_fields][#{@af_counter}][markup]" do %>
<select class="dataType" name=<%= "#{@field_name}[attribute_fields][#{@af_counter}][markup]"%>>
<%LIST[:markups].each do |key,val|%>
<option value="<%= key %>" <%= attribute_field.markup == key ? 'selected="selected"' : '' %> ref="<%=val["panel"]%>"><%=t("lists.markups."+key)%></option >
<% end %>
</select>
</div>
</div>
</div>
</legend>
<div class="<%= attribute_field.disabled ? 'hide' : ''%>">
<%= content_tag :div,:class=>show_type_panel(attribute_field,"typeA") do%>
<div class="control-group">
<label class="control-label"><%= t(:options)%></label>
<div class="controls">
<label class="checkbox inline">
<%= check_box_tag("#{@field_name}[attribute_fields][#{@af_counter}][typeA][cross_lang]","true",attribute_field["typeA"]["cross_lang"]) %>
<%= t(:cross_lang)%>
</label>
<label class="checkbox inline">
<%= check_box_tag("#{@field_name}[attribute_fields][#{@af_counter}][typeA][add_more]","true",attribute_field["typeA"]["add_more"]) %>
<%= t(:add_more)%>
</label>
</div>
</div>
<%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>attribute_field["typeA"]["placeholder"],:field_name=>"#{@field_name}[attribute_fields][#{@af_counter}][typeA][placeholder]"}%>
<% end %>
<%= content_tag :div,:class=>show_type_panel(attribute_field,"typeB") do %>
<%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:label_ext=>t(:initial),:values=>attribute_field["typeB"]["initial"],:field_name=>"#{@field_name}[attribute_fields][#{@af_counter}][typeB][initial]"}%>
<% if attribute_field.self_defined_markup_options?%>
<%= render :partial=>"shared/attribute_field/list_block",:locals=>{:values=>attribute_field["option_list"],:field_name=> "#{@field_name}[attribute_fields][#{@af_counter}][attribute][role][statuses]"} %>
<%else #normal list%>
<%= render :partial=>"shared/attribute_field/list_block",:locals=>{:values=>attribute_field["option_list"],:field_name=> "#{@field_name}[attribute_fields][#{@af_counter}][typeB][option_list]"} %>
<% end #of self_defined_markup_options?%>
<% end %>
<%= content_tag :div,:class=>show_type_panel(attribute_field,"typeC") do %>
<div class="control-group">
<label class="control-label"><%= t("date.format")%></label>
<div class="controls">
<%= select "#{@field_name}[attribute_fields][#{@af_counter}][typeC]","format",Admin::AttributeValuesViewHelper::OPT,:class=>"dataType",:selected=>attribute_field["typeC"]["format"] %>
</div>
</div>
<div class="control-group">
<label class="control-label"><%= t("date.range")%></label>
<div class="controls">
<label class="radio inline">
<%= radio_button("#{@field_name}[attribute_fields][#{@af_counter}][typeC]", "is_range", "false",:checked => (!attribute_field.date_is_range? ? true : false)) %><%= t(:yes_)%>
</label>
<label class="radio inline">
<%= radio_button("#{@field_name}[attribute_fields][#{@af_counter}][typeC]", "is_range", "true",:checked => (attribute_field.date_is_range? ? true : false)) %><%= t(:no_)%>
</label>
</div>
</div>
<div class="control-group">
<label class="control-label"><%= t("date.calendar")%></label>
<div class="controls">
<label class="radio inline">
<%= radio_button("#{@field_name}[attribute_fields][#{@af_counter}][typeC]", "calendar", "west_calendar",:checked =>(attribute_field["typeC"]["calendar"]== "west_calendar" ? true : false)) %><%= t("date.west_calendar")%>
</label>
<label class="radio inline">
<%= radio_button("#{@field_name}[attribute_fields][#{@af_counter}][typeC]", "calendar", "tw_calendar",:checked =>(attribute_field["typeC"]["calendar"]== "tw_calendar" ? true : false)) %><%= t("date.tw_calendar")%>
</label>
</div>
</div>
<% end %>
<%= content_tag :div,:class=>show_type_panel(attribute_field,"typeD") do%>
<div class="control-group">
<label class="control-label"><%= t(:options)%></label>
<div class="controls">
<label class="checkbox inline">
<%= check_box_tag("#{@field_name}[attribute_fields][#{@af_counter}][typeD][cross_lang]","true",attribute_field["typeD"]["cross_lang"]) %>
<%= t(:cross_lang)%>
</label>
</div>
</div>
<%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:field_name=>"#{@field_name}[attribute_fields][#{@af_counter}][typeD][placeholder]",:values=>attribute_field["typeD"]["placeholder"]} %>
<% end %>
<%= content_tag :div,:class=>show_type_panel(attribute_field,"typeE") do%>
<%= render :partial=>"shared/attribute_field/list_block",:locals=>{:field_name=>"#{@field_name}[attribute_fields][#{@af_counter}][typeE][option_list]",:values=>attribute_field["option_list"]}%>
<% end %>
</div>
<%= hidden_field "#{@field_name}[attribute_fields][#{@af_counter}]","id",:value=>attribute_field.id%>
</div>

View File

@ -0,0 +1 @@
$('<%= j render :partial => 'attribute_field', :collection => [@attribute_field] %>').appendTo('#attribute_field_list').hide().fadeIn();

View File

@ -0,0 +1,36 @@
<%= form_for @sub_attribute,:url => eval("admin_#{@attribute_type}s_path") ,:class=> "form-horizontal" do |f| %>
<div class="site-map role-block">
<div class="map-block back">
<h4><span><%= t(eval(":#{@attribute_type}"))%>:<%= @attribute.title %></span></h4>
<div class="form-horizontal">
<div class="clear">
<div class="control-group pull-left">
<label class="control-label" for="key"><%= t(:key) %></label>
<div class="controls">
<% if @sub_attribute.new_record? %>
<%= f.text_field :key, :placeholder => t(:key) %>
<% else %>
<div><%= @sub_attribute.key%></div>
<% end %>
</div>
</div>
<%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>@sub_attribute.title_translations,:class_ext=>"pull-left",:label_ext=>t(:item_name),:field_name=>"sub_role[title_translations]"}%>
</div>
</div>
</div>
</div>
<div class="form-actions form-fixed pagination-right">
<%#= hidden_field_tag 'id', params[:role_id] if !params[:role_id].blank? %>
<%= f.hidden_field :role_id, :value => params[:role_id] if !params[:role_id].blank? %>
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
<% end %>
<% content_for :page_specific_css do -%>
<%= stylesheet_link_tag "member" %>
<%= stylesheet_link_tag "site-map" %>
<% end %>

View File

@ -0,0 +1,37 @@
<%= form_for @sub_attribute,:url => eval("admin_#{@attribute_type}_path(@attribute)") ,:class=> "form-horizontal" do |f| %>
<div class="site-map role-block">
<div class="map-block back">
<h4><span><%= t(eval(":#{@attribute_type}"))%>:<%= @attribute.title %></span></h4>
<div class="form-horizontal">
<div class="clear">
<div class="control-group pull-left">
<label class="control-label" for="key"><%= t(:key) %></label>
<div class="controls">
<% if @sub_attribute.new_record? %>
<%= f.text_field :key, :placeholder => t(:key) %>
<% else %>
<div><%= @sub_attribute.key%></div>
<% end %>
</div>
</div>
<%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>@sub_attribute.title_translations,:class_ext=>"pull-left",:label_ext=>t(:item_name),:field_name=>"sub_role[title_translations]"}%>
</div>
</div>
</div>
</div>
<div class="form-actions form-fixed pagination-right">
<%#= hidden_field_tag 'id', params[:role_id] if !params[:role_id].blank? %>
<%= f.hidden_field :id %>
<%#= f.hidden_field :role_id, :value => @attribute.id if !params[:role_id].blank? %>
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
<% end %>
<% content_for :page_specific_css do -%>
<%= stylesheet_link_tag "member" %>
<%= stylesheet_link_tag "site-map" %>
<% end %>

View File

@ -0,0 +1 @@
111

View File

@ -0,0 +1,128 @@
<% content_for :side_bar do %>
<%= render :partial => 'layouts/side_bar', :locals => {:link_name => t(:member), :link_url => admin_site_site_info_path(@site), :icon => 'icons-group', :side_bar_content => 'admin/users_new_interface/side_bar'} %>
<% end %>
<%= form_for @attribute,:url => eval("admin_#{@attribute_type}_path(@attribute)") ,:class=> "form-horizontal" do |f| %>
<div class="site-map role-block">
<div class="map-block back attributes">
<h4><span><%= @attribute.title+ t(:attributes)%></span></h4>
<div id="attribute_field_list">
<%= render :partial=>"attribute_field",:collection=>@attribute.attribute_fields%>
</div>
</div>
<div class="add-attributes form-actions pagination-right">
<%= link_to content_tag(:i,t(:add_attribute_field),:class=>"icon-plus icon-white"),admin_role_add_attribute_field_path(@attribute),:class=>"btn btn-primary",:remote => true%>
</div>
</div>
<div class="form-actions form-fixed pagination-right">
<%#= f.hidden_field :id, :value => params[:role_id] if !params[:role_id].blank? %>
<%= hidden_field_tag 'id', params[:role_id] if !params[:role_id].blank? %>
<%= f.submit t(:save),:class=>"btn btn-primary"%>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
<% end %>
<% content_for :page_specific_css do -%>
<%= stylesheet_link_tag "member" %>
<%= stylesheet_link_tag "site-map" %>
<% end %>
<% content_for :page_specific_javascript do -%>
<script>
var CloneTarget ;
var NewNode;
$(document).ready(function(){
function checkSwitch() {
$(".groups").addClass('disabled').has('.groups > .form-horizontal > div:not(.hide)').removeClass('disabled');
}
function checkMultipleInput() {
$(".multipleInput").each(function() {
$(this).find('.controls').length==1 ? $(this).addClass("plural") : $(this).removeClass("plural")
});
}
function removeInput(){
$(".removeInput").live('click',function (){
$(this).parents(".controls").remove();
checkMultipleInput();
return false;
});
}
checkSwitch();
checkMultipleInput();
removeInput();
$(".remove_attribute").live('click',function(){
$(this).siblings(".attribute_field_to_delete").val("true");
$(this).parents(".form-horizontal").fadeOut("slow", function () { $(this).hide(); });
});
$(".help-block a").live('click',function (){
CloneTarget = $(this).parents(".controls").prev(".multipleInput").find('.controls:last');
NewNode = CloneTarget.clone();
var index;
NewNode.find("input").each(function(k,v){
index = CloneTarget.parents("div.control-group").find(".list_count").val()
field_name = CloneTarget.parents("div.control-group").find(".field_name").val()
ori_str = $(v).attr("name").replace(field_name,"");
lang = ori_str.match(/\[\D*\]/);
new_field_name = (field_name+"[" + (parseInt(index)+1) + "]" + lang);
$(v).attr("name",new_field_name);
})
$(this).parents("div.control-group").find(".list_count").val(parseInt(index)+1)
$(this).parents(".controls").prev(".multipleInput").append(NewNode);
$(this).parents(".controls").prev(".multipleInput").find('.controls:last input').val("");
removeInput();
checkMultipleInput();
return false;
})
$(".status select").each(function (i) {
$(this).change(function () {
$(".status option:selected").eq(i).each(function () {
if($(this).attr("value")=="alumna") {
$(this).parents(".status").nextAll(".graduated").removeClass("hide");
$(this).parents(".status").nextAll(".graduated").find("select").removeAttr("disabled");
}else{
$(this).parents(".status").nextAll(".graduated").addClass("hide");
$(this).parents(".status").nextAll(".graduated").find("select").attr({disabled:''});
}
});
})
})
$('.onoff').live('click',function () {
if($(this).parents("h4").length==1) {
$(this).parents(".map-block").toggleClass("disabled");
$(this).parents(".map-block").find(".form-horizontal").toggleClass("hide");
if($(this).parents(".map-block").hasClass("disabled")){
$(this).text("OFF");
}else{
$(this).text("ON");
}
}
if($(this).parents("legend").length==1) {
$(this).toggleClass("disabled");
$(this).parents("legend").next("div").toggleClass("hide");
if($(this).parents("legend").next("div").hasClass("hide")){
$(this).text("OFF");
$(this).siblings(".attribute_field_disabled").val("true");
}else{
$(this).text("ON");
$(this).siblings(".attribute_field_disabled").val("false");
}
checkSwitch();
}
return false;
});
$(".dataType").change(function () {
$(this).parents("legend").next("div").find("div[class^='type']").addClass("hide");
$(this).parents("legend").next("div").find("."+$(this).find("option:selected").attr("ref")).removeClass("hide");
})
});
</script>
<% end -%>

View File

@ -0,0 +1,41 @@
<% content_for :side_bar do %>
<%= render :partial => 'layouts/side_bar', :locals => {:link_name => t(:member), :link_url => admin_site_site_info_path(@site), :icon => 'icons-group', :side_bar_content => 'admin/users_new_interface/side_bar'} %>
<% end %>
<div class="main_list">
<div class="button_bar up">
<%= link_to t(:new_sub_role), eval("admin_#{@attribute_type}_add_sub_role_path(@attribute)"), :class => 'new' %>
</div>
<table>
<thead>
<tr>
<td class="<%= @attribute_type %>s"><%= t("#{@attribute_type}") %>:<%= @attribute.title %></td>
<td class="action"><%= t(:action) %></td>
</tr>
</thead>
<tbody>
<% @attribute_fields_upper_object.each do |attribute| %>
<tr id="attribute_<%= attribute.id %>" class="have <%= "#{attribute.is_disabled? ? 'disable' : ''}" %>">
<td class="<%= @attribute_type %>s <%= attribute.key.downcase %>"><%= attribute.title %></span>
<td class="action">
<%= link_to t(:edit), eval("admin_#{@attribute_type}_edit_sub_role_path(attribute)"), :class => 'edit' %>
<%= link_to t(:sub_role_field), eval("admin_#{@attribute_type}_sub_role_field_path(attribute)"), :class => 'edit' %>
<%= link_to t(:enable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :sub_role => {:disabled => true, :id => attribute })"), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? 'none' : ''}", :class => 'switch' %>
<%= link_to t(:disable), eval("admin_#{@attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :sub_role => {:disabled => false, :id => attribute })"), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? '' : 'none'}", :class => 'switch' %>
<% if !attribute.is_built_in? %>
<%= link_to t(:delete_), eval("admin_#{@attribute_type}_path(attribute, :sub_role => {:id => attribute })"), :class => 'delete', :confirm => t('sure?'), :method => :delete %>
<% end %>
</td>
</tr>
<tr>
<td colspan="5"></td>
</tr>
<% end %>
</tbody>
</table>
<div class="button_bar">
<%= link_to t(:new_sub_role), eval("admin_#{@attribute_type}_add_sub_role_path(@attribute)"), :class => 'new' %>
</div>
</div>

View File

@ -0,0 +1,125 @@
<% content_for :side_bar do %>
<%= render :partial => 'layouts/side_bar', :locals => {:link_name => t(:member), :link_url => admin_site_site_info_path(@site), :icon => 'icons-group', :side_bar_content => 'admin/users_new_interface/side_bar'} %>
<% end %>
<%= form_for @attribute,:url => eval("admin_#{@attribute_type}_path(@attribute)") ,:class=> "form-horizontal" do |f| %>
<div class="site-map role-block">
<div class="map-block back attributes">
<h4><span><%= @attribute.title+ t(:attributes)%> - <%= @sub_attribute.title %></span></h4>
<div id="attribute_field_list">
<%= render :partial=>"attribute_field",:collection=>@sub_attribute.attribute_fields%>
</div>
</div>
</div>
<div class="form-actions form-fixed pagination-right">
<%= link_to content_tag(:i,t(:add_attribute_field),:class=>"icon-plus icon-white"),admin_role_add_attribute_field_path(@sub_attribute, :sub_role => {:id => @sub_attribute }),:class=>"btn btn-primary",:remote => true%>
<%#= f.hidden_field :id, :value => params[:role_id] if !params[:role_id].blank? %>
<%= hidden_field_tag 'sub_role[id]', params[:role_id] if !params[:role_id].blank? %>
<%= f.submit t(:save),:class=>"btn btn-primary"%>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
<% end %>
<% content_for :page_specific_css do -%>
<%= stylesheet_link_tag "member" %>
<%= stylesheet_link_tag "site-map" %>
<% end %>
<% content_for :page_specific_javascript do -%>
<script>
var CloneTarget ;
var NewNode;
$(document).ready(function(){
function checkSwitch() {
$(".groups").addClass('disabled').has('.groups > .form-horizontal > div:not(.hide)').removeClass('disabled');
}
function checkMultipleInput() {
$(".multipleInput").each(function() {
$(this).find('.controls').length==1 ? $(this).addClass("plural") : $(this).removeClass("plural")
});
}
function removeInput(){
$(".removeInput").live('click',function (){
$(this).parents(".controls").remove();
checkMultipleInput();
return false;
});
}
checkSwitch();
checkMultipleInput();
removeInput();
$(".remove_attribute").live('click',function(){
$(this).siblings(".attribute_field_to_delete").val("true");
$(this).parents(".form-horizontal").fadeOut("slow", function () { $(this).hide(); });
});
$(".help-block a").live('click',function (){
CloneTarget = $(this).parents(".controls").prev(".multipleInput").find('.controls:last');
NewNode = CloneTarget.clone();
var index;
NewNode.find("input").each(function(k,v){
index = CloneTarget.parents("div.control-group").find(".list_count").val()
field_name = CloneTarget.parents("div.control-group").find(".field_name").val()
ori_str = $(v).attr("name").replace(field_name,"");
lang = ori_str.match(/\[\D*\]/);
new_field_name = (field_name+"[" + (parseInt(index)+1) + "]" + lang);
$(v).attr("name",new_field_name);
})
$(this).parents("div.control-group").find(".list_count").val(parseInt(index)+1)
$(this).parents(".controls").prev(".multipleInput").append(NewNode);
$(this).parents(".controls").prev(".multipleInput").find('.controls:last input').val("");
removeInput();
checkMultipleInput();
return false;
})
$(".status select").each(function (i) {
$(this).change(function () {
$(".status option:selected").eq(i).each(function () {
if($(this).attr("value")=="alumna") {
$(this).parents(".status").nextAll(".graduated").removeClass("hide");
$(this).parents(".status").nextAll(".graduated").find("select").removeAttr("disabled");
}else{
$(this).parents(".status").nextAll(".graduated").addClass("hide");
$(this).parents(".status").nextAll(".graduated").find("select").attr({disabled:''});
}
});
})
})
$('.onoff').live('click',function () {
if($(this).parents("h4").length==1) {
$(this).parents(".map-block").toggleClass("disabled");
$(this).parents(".map-block").find(".form-horizontal").toggleClass("hide");
if($(this).parents(".map-block").hasClass("disabled")){
$(this).text("OFF");
}else{
$(this).text("ON");
}
}
if($(this).parents("legend").length==1) {
$(this).toggleClass("disabled");
$(this).parents("legend").next("div").toggleClass("hide");
if($(this).parents("legend").next("div").hasClass("hide")){
$(this).text("OFF");
$(this).siblings(".attribute_field_disabled").val("true");
}else{
$(this).text("ON");
$(this).siblings(".attribute_field_disabled").val("false");
}
checkSwitch();
}
return false;
});
$(".dataType").change(function () {
$(this).parents("legend").next("div").find("div[class^='type']").addClass("hide");
$(this).parents("legend").next("div").find("."+$(this).find("option:selected").attr("ref")).removeClass("hide");
})
});
</script>
<% end -%>

View File

@ -0,0 +1,3 @@
$("#enable_<%= @sub_role.id %>").toggle();
$("#disable_<%= @sub_role.id %>").toggle();
$("#attribute_<%= @sub_role.id %>").toggleClass('disable');

View File

@ -3,9 +3,16 @@
<div class="form-horizontal"> <div class="form-horizontal">
<% role.attribute_fields.each do |rf|%>
<% role.sub_roles.each do |sub_role| %> <%= rf.block_helper(@user,@form_index)%>
<% @form_index = @form_index +1 %>
<% end %>
<% role.sub_roles.where(:disabled=>false).each do |sub_role| %>
<% sub_role_disable = @user.sub_roles.include?(sub_role) ? false : true %> <% sub_role_disable = @user.sub_roles.include?(sub_role) ? false : true %>
<%# sub_role_disable = !sub_role.disabled ? false : true %>
<%#= hidden_field_tag("[user][new_attribute_values][sub_role][disable][#{sub_role.id}]",sub_role_disable)%> <%#= hidden_field_tag("[user][new_attribute_values][sub_role][disable][#{sub_role.id}]",sub_role_disable)%>
<legend> <legend>
<button for=<%=@form_index%> class="onoff pull-right <%= sub_role_disable ? 'disabled' : '' %> "><%= t(:on_upcase) %></button><%= sub_role.title %> <button for=<%=@form_index%> class="onoff pull-right <%= sub_role_disable ? 'disabled' : '' %> "><%= t(:on_upcase) %></button><%= sub_role.title %>

View File

@ -1,9 +1,16 @@
<div class="roles <%= show_roles.key %>"> <div class="roles <%= show_roles.key %>">
<%= show_roles.title %>
<div class="label-line"> <div class="label-line">
<hr /> <hr />
</div> </div>
<table class="table"> <table class="table">
<tbody> <tbody>
<% show_roles.attribute_fields.where(:disabled=>false).each do |rf| %>
<tr>
<td class="span1"><%= rf.title %></td>
<td><%= show_attribute_value(@user.get_attribute_value(rf).get_value_by_locale(I18n.locale)) rescue '' %></td>
</tr>
<% end -%>
<%= render :partial => 'show_sub_role',:collection=> @user.get_sub_roles_by_role(show_roles)%> <%= render :partial => 'show_sub_role',:collection=> @user.get_sub_roles_by_role(show_roles)%>
</tbody> </tbody>
</table> </table>

View File

@ -2,14 +2,16 @@
<%= link_to content_tag(:i, nil, :class => 'icons-member')+ content_tag(:span, t(:member)), admin_users_new_interface_index_path %> <%= link_to content_tag(:i, nil, :class => 'icons-member')+ content_tag(:span, t(:member)), admin_users_new_interface_index_path %>
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('users_new_interface')) do -%> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('users_new_interface')) do -%>
<%= content_tag :li, link_to((t(:all_member) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, admin_users_new_interface_index_path), :class => active_for_action('users_new_interface', 'index') %> <%= content_tag :li, link_to((t(:all_member) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, admin_users_new_interface_index_path), :class => active_for_action('users_new_interface', 'index') %>
<%= content_tag :li, link_to((t(:add_member) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, new_admin_users_new_interface_path), :class => active_for_action('users_new_interface', 'new') %> <%= content_tag :li, link_to((t(:add_member) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, new_admin_users_new_interface_path), :class => active_for_action('users_new_interface', 'new') if (is_admin? rescue nil) %>
<%= content_tag :li, link_to((t(:roles) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe,admin_infos_path ), :class => active_for_action('users_new_interfacexx', 'index') %> <%= content_tag :li, link_to((t(:roles) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe,admin_roles_path ), :class => active_for_action('users_new_interfacexx', 'index') if (is_admin? rescue nil) %>
<%= content_tag :li, link_to((t(:info) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, admin_roles_path), :class => active_for_action('users_new_interfacexx', 'index') %> <%= content_tag :li, link_to((t(:info) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, edit_admin_info_path('4f45f3b9e9d02c5db900002c')), :class => active_for_action('users_new_interfacexx', 'index') if (is_admin? rescue nil) %>
<%= content_tag :li, link_to((t(:authorigation) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, '#'), :class => active_for_action('users_new_interfacexx', 'index') if (is_admin? rescue nil) %>
<%= content_tag :li, link_to((t(:registrant) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, '#'), :class => active_for_action('users_new_interfacexx', 'index') if (is_admin? rescue nil) %>
<% end -%> <% end -%>
<% end -%> <% end -%>
<%= content_tag :li, :class => active_for_controllers('plugins') do -%> <%= content_tag :li, :class => active_for_controllers('plugins') do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-pie')+ content_tag(:span, t(:plugins)), admin_plugins_path %> <%= link_to content_tag(:i, nil, :class => 'icons-pie')+ content_tag(:span, t(:analysis)), admin_plugins_path %>
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('plugins')) do -%> <%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('plugins')) do -%>
<%= content_tag :li, link_to((t(:all_plugins) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, admin_plugins_path), :class => active_for_action('users_new_interface', 'index') %> <%= content_tag :li, link_to((t(:all_plugins) + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, admin_plugins_path), :class => active_for_action('users_new_interface', 'index') %>
<% end -%> <% end -%>

View File

@ -117,7 +117,11 @@ Orbit::Application.routes.draw do
end end
end end
resources :roles do resources :roles do
get 'role_field'
get 'sub_role_field'
get 'sub_role'
get 'add_sub_role' get 'add_sub_role'
get 'edit_sub_role'
get 'add_attribute_field' get 'add_attribute_field'
end end
resources :sites do resources :sites do