member roles edit

This commit is contained in:
unknown authored and chris committed 2013-01-14 17:02:51 +08:00
1 parent 4e2cbac027
commit 84e4a558be
22 files changed
+975 -139

No files matched your search

@@ -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>
+166 -65
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="map-block back">
<h4><span><%= t(:info)%></span></h4>
<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 %>
<div class="control-group pull-left">
<label class="control-label" for="key"><%= t(:key) %></label>
<div class="controls">
@@ -14,10 +34,11 @@
<% 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=>"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>
<% if @attribute._type == "Info" %>
<div class="map-block back attributes">
<h4><span><%= @attribute.title+ t(:attributes)%></span></h4>
@@ -26,11 +47,13 @@
</div>
</div>
<% end %>
</div>
<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"%>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
<% end %>
<% content_for :page_specific_css do -%>
@@ -39,12 +62,16 @@
<% end %>
<% content_for :page_specific_javascript do -%>
<script>
var CloneTarget ;
<script>
var NewNode;
$(document).ready(function(){
$(document).ready(function(){
// function mas(){
// $('.site-map').masonry({
// itemSelector: '.map-block',
// columnWidth: 450,
// isAnimated: true
// });
// }
function checkSwitch() {
$(".groups").addClass('disabled').has('.groups > .form-horizontal > div:not(.hide)').removeClass('disabled');
}
@@ -53,41 +80,110 @@
$(this).find('.controls').length==1 ? $(this).addClass("plural") : $(this).removeClass("plural")
});
}
function removeInput(){
$(".removeInput").live('click',function (){
function removeInput() {
$(".removeInput").click(function (){
$(this).parents(".controls").remove();
checkMultipleInput();
return false;
});
}
function DataType() {
$(".dataType").each(function (i) {
$(this).change(function () {
$("option:selected").eq(i).each(function () {
if($(this).attr("ref")=="typeA") {
$(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");
}
});
})
});
}
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("");
removeInput();
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;
})
DataType();
CloneDataType();
$(".status select").each(function (i) {
$(this).change(function () {
$(".status option:selected").eq(i).each(function () {
@@ -100,35 +196,40 @@
}
});
})
})
$('.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");
})
$(".form-horizontal").delegate(".onoff","click",function(){
$(this).toggleClass("disabled");
$(this).parent("legend").parent(".form-horizontal").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
});
$(".add-attributes a").click(function (){
var $CloneTarget = $(this).parents(".attributes").find('.form-horizontal:last');
$(".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>
<% end -%>
+68 -35
View File
@@ -1,39 +1,72 @@
<% content_for :secondary do %>
<%= render 'admin/users_new_interface/side_bar' %>
<% # encoding: utf-8 %>
<% 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.#{@attribute_type}"), eval("new_admin_#{@attribute_type}_path"), :class => 'new' %>
</div>
<table>
<thead>
<tr>
<td class="<%= @attribute_type %>s"><%= t("#{@attribute_type}") %></td>
<td class="action"><%= t(:action) %></td>
</tr>
</thead>
<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' %>
<%= 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' %>
<%= 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' %>
<% if !attribute.is_built_in? %>
<%= link_to t(:delete_), eval("admin_#{@attribute_type}_path(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.#{@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>
</div>
</div>
<table class="table main-list member-list">
<thead>
<tr>
<th class="span1-2"></th>
</tr>
</thead>
<tbody>
<% @attributes.each do |attribute| %>
<tr class="with_action">
<td class="span1-2">
<%= attribute.title %>
<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 %>
<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>
</tr>
<% end %>
</tbody>
</table>
<div class="form-actions form-fixed pagination-right">
<%= 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>
+50 -13
View File
@@ -1,14 +1,51 @@
<% content_for :secondary do %>
<%= render 'admin/users_new_interface/side_bar' %>
<% end %>
<%= form_for @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}"))%></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 %>
<div class="control-group pull-left">
<label class="control-label" for="key"><%= t(:key) %></label>
<div class="controls">
<% if @attribute.new_record? %>
<%= f.text_field :key, :placeholder => t(:key) %>
<% else %>
<div><%= @attribute.key%></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 %>
<div id="profile">
<%= form_for @attribute, :url => eval("admin_#{@attribute_type}s_path") do |f| %>
<%= f.error_messages %>
<%= render :partial => "admin/#{@attribute_type}s/form", :locals => { :f => f, :is_new => true } %>
<div class="button_bar">
<%= link_back %>
<%= link_to t('create'), "#", :onclick=>"$('#new_#{@attribute_type}').submit()" %>
</div>
<% end -%>
</div>
<% content_for :page_specific_css do -%>
<%= stylesheet_link_tag "member" %>
<%= stylesheet_link_tag "site-map" %>
<% end %>