for user new interface, member role is working.

This commit is contained in:
Matthew K. Fu JuYuan authored and chris committed 2012-10-26 11:27:37 +08:00
1 parent b301f6522a
commit bd0d975014
15 files changed
+312 -90

No files matched your search

@@ -16,39 +16,92 @@
</div>
<%= render :partial=>"infos"%>
<%#= render :partial=>"roles"%>
<%= render :partial=>"roles"%>
<% content_for :page_specific_javascript do -%>
<script type="text/javascript">
$(document).ready(function(){
// $("a.submit_btn").click(function(){
// value = $("a.submit_btn").parents("form").find("input[disabled='disabled']")
// jQuery.each(value, function() {
// index = $(this).attr("for");
// console.log(index);
// $("input[for='"+ index +"']").remove();
// });
// value.remove();
// $(this).parents("form")[0].submit();
<script>
// $('.site-map').masonry({
// itemSelector: '.map-block',
// columnWidth: 450,
// isAnimated: true
// });
$(document).ready(function(){
function subrole_disable_field( triggled_object, switch_value_str){
var switch_field = triggled_object.attr("for");
$("input.subrole_disable_field[for="+switch_field+"]").val(switch_value_str)
}
$(".onoff").click(function(){
var dom = $(this).attr("for");
if($(this).hasClass("disabled")){
$(".controls-block[for="+dom+"] input").removeAttr("disabled");
$(".controls-block[for="+dom+"]").slideDown();
$(this).removeClass("disabled");
$(this).text("OFF");
}else{
$(this).addClass("disabled");
$(".controls-block[for="+dom+"]").slideUp();
$(".controls-block[for="+dom+"] input").attr("disabled","disabled");
$(this).text("ON");
}
return false;
function checkSwitch() {
$(".groups").each(function() {
$(this).find('.form-horizontal > .hide').length < $(this).find('.form-horizontal > div').length ? $(this).removeClass("disabled") : $(this).addClass("disabled")
});
}
function checkMultipleInput() {
$(".multipleInput").each(function() {
$(this).find('.controls').length==1 ? $(this).addClass("plural") : $(this).removeClass("plural")
});
}
function removeInput(){
$(".removeInput").click(function (){
$(this).parents(".controls").remove();
checkMultipleInput();
return false;
});
}
checkSwitch();
checkMultipleInput();
removeInput();
$(".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;
})
$(".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').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");
// console.log("LV1");
// console.log($(this));
}else{
$(this).text("ON");
// console.log("LV1");
// console.log($(this));
}
}
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");
console.log("LV2");
subrole_disable_field($(this),"true");
}else{
$(this).text("ON");
console.log("LV2");
subrole_disable_field($(this),"false");
}
checkSwitch();
}
return false;
});
})
</script>
<% end -%>
@@ -1,16 +1,19 @@
<div class="map-block back">
<div class="groups map-block back">
<h4><span><%= role.title %></span></h4>
<div class="form-horizontal">
<% role.sub_roles.each do |sub_role| %>
<% sub_role_disable = @disable_all_field ? true : !check_user_role_enable(sub_role.attribute_fields) %>
<% sub_role_disable = @user.sub_roles.include?(sub_role) ? false : true %>
<%= hidden_field_tag("user[disable_sub_role][id][#{sub_role.id}]",sub_role_disable,:for=>@form_index,:class=>"subrole_disable_field",:value=>sub_role_disable)%>
<%#= hidden_field_tag("[user][new_attribute_values][sub_role][disable][#{sub_role.id}]",sub_role_disable)%>
<legend><button for=<%=@form_index%> class="onoff pull-right <%= sub_role_disable ? 'disabled' : '' %> "><%= sub_role_disable ? 'ON' : 'OFF' %></button><%= sub_role.title %></legend>
<div class="controls-block <%= sub_role_disable ? 'hide' : '' %>" for=<%=@form_index%> >
<legend>
<button for=<%=@form_index%> class="onoff pull-right <%= sub_role_disable ? 'disabled' : '' %> ">ON</button><%= sub_role.title %>
</legend>
<div class="controls-block <%= sub_role_disable ? 'hide' : '' %>" >
<% sub_role.attribute_fields.each do |af|%>
<%= af.block_helper(@user,@form_index,sub_role_disable)%>
<%= af.block_helper(@user,@form_index)%>
<% @form_index = @form_index +1 %>
<% end %>
</div>
@@ -0,0 +1,10 @@
<div class="roles <%= show_roles.key %>">
<div class="label-line">
<hr />
</div>
<table class="table">
<tbody>
<%= render :partial => 'show_sub_role',:collection=> @user.get_sub_roles_by_role(show_roles)%>
</tbody>
</table>
</div>
@@ -0,0 +1,7 @@
<tr><td class="span1"><%= show_sub_role.title %></td></tr>
<% show_sub_role.attribute_fields.each do |item|%>
<tr>
<td class="span1"><%= item.title %></td>
<td><%= show_attribute_value(@user.get_attribute_value(item).get_value_by_locale(I18n.locale)) %></td>
</tr>
<% end %>
@@ -51,6 +51,9 @@
<div class="viewport">
<div class="overview">
<%= render :partial=> "user_role",:locals=>{:role_class=>"basic",:i18n=>"admin.new_admin.users.profile",:items=>@profile_data} %>
<%= render :partial=> "show_roles",:collection=>@user.roles %>
<%# @user.sub_roles.each{|sr| render :partial=> "user_role",:locals=>{:role_class=>sr.key.to_s,:i18n=>"admin.new_admin.users.roles.#{sr.key.to_s}",:items=>sr} }%>
<%#= render :partial=> "user_role",:locals=>{:role_class=>"teacher",:i18n=>"admin.new_admin.users.roles.teacher",:items=>@teacher_data} %>
<%#= render :partial=> "user_role",:locals=>{:role_class=>"student",:i18n=>"admin.new_admin.users.roles.student",:items=>@student_data}%>
<%#= render :partial=> "user_role",:locals=>{:role_class=>"staff",:i18n=>"admin.new_admin.users.roles.staff",:items=>@staff_data} %>