Ray's back-end modifications for sub-roles

This commit is contained in:
Christophe Vilayphiou 2011-12-28 20:57:18 +08:00
parent 62aaf79491
commit 75c9851dbc
10 changed files with 83 additions and 35 deletions

View File

@ -344,6 +344,7 @@ body{
#person label { #person label {
display: block; display: block;
margin: 15px 0 0; margin: 15px 0 0;
width: auto;
} }
#person label input { #person label input {
} }
@ -362,10 +363,10 @@ body{
padding: 0; padding: 0;
width: 140px; width: 140px;
} }
#porfile .users{ #profile .users{
margin-left: 180px; margin-left: 180px;
} }
.roles_block { .roles_block, .attributes_block {
background: url(<%= asset_path "75.png" %>) repeat left top; background: url(<%= asset_path "75.png" %>) repeat left top;
min-width:710px; min-width:710px;
margin-bottom:50px; margin-bottom:50px;
@ -378,7 +379,7 @@ body{
-webkit-box-shadow: 0px 0px 4px #180902;/* Safari 和 Chrome */ -webkit-box-shadow: 0px 0px 4px #180902;/* Safari 和 Chrome */
box-shadow: 0px 0px 4px #180902; /* Opera 10.5 + */ box-shadow: 0px 0px 4px #180902; /* Opera 10.5 + */
} }
.roles_block h2 { .roles_block>h2, .attributes_block>h2 {
color: #FFFFFF; color: #FFFFFF;
font-weight: normal; font-weight: normal;
margin: 0; margin: 0;
@ -387,7 +388,18 @@ body{
text-shadow: 0 3px 2px #000000; text-shadow: 0 3px 2px #000000;
top: -30px; top: -30px;
} }
.group>h2 {
color: #FFFFFF;
margin: 0 20px;
padding: 10px 0;
}
.group>.info_input {
border: 1px solid #686868;
margin: 0 20px;
padding: 10px;
}
.main hr { .main hr {
background-color: #222222;
height:8px; height:8px;
border:none; border:none;
margin:0; margin:0;
@ -399,11 +411,11 @@ body{
#basic_block hr { #basic_block hr {
background-color: #666666; background-color: #666666;
} }
#teacher_block hr { hr.teacher_block {
background-color: #0071A9; background-color: #0071A9 !important;
} }
#student_block hr { hr.student_block {
background-color: #AF0045; background-color: #AF0045 !important;
} }
.info_input { .info_input {
padding:10px 20px; padding:10px 20px;
@ -425,15 +437,41 @@ body{
.info_input .list_item { .info_input .list_item {
color:#AEAEAE; color:#AEAEAE;
} }
.info_input .add { #add_attribute {
}
.add {
-moz-box-shadow:inset 0px 1px 0px 0px #8c8c8c;
-webkit-box-shadow:inset 0px 1px 0px 0px #8c8c8c;
box-shadow:inset 0px 1px 0px 0px #8c8c8c;
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #303030), color-stop(1, #1a1a1a) );
background:-moz-linear-gradient( center top, #303030 5%, #1a1a1a 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#303030', endColorstr='#1a1a1a');
background-color:#303030;
-moz-border-radius:3px;
-webkit-border-radius:3px;
border-radius:3px;
border:1px solid #000;
display:block; display:block;
padding-left:22px; color:#999;
font-family:arial;
font-size:12px; font-size:12px;
line-height:21px; font-weight:bold;
height:19px; padding:0px;
background:url(<%= asset_path "icon.png" %>) no-repeat -59px 0; text-decoration:none;
margin-top: 10px; text-shadow:0px -1px 0px #000000;
color: #DDDDDD; text-align: center;
line-height: 26px;
}
.add:hover {
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #1a1a1a), color-stop(1, #303030) );
background:-moz-linear-gradient( center top, #1a1a1a 5%, #303030 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#1a1a1a', endColorstr='#303030');
background-color:#1a1a1a;
}
.add:active {
position:relative;
top:1px;
} }
.main table { .main table {
@ -466,7 +504,6 @@ body{
-webkit-border-radius: 0 5px 5px 0; -webkit-border-radius: 0 5px 5px 0;
} }
.main thead td { .main thead td {
line-height:40px;
font-size:16px; font-size:16px;
text-shadow: 0px 1px 1px #3e2914; text-shadow: 0px 1px 1px #3e2914;
} }

View File

@ -15,9 +15,8 @@
<%= f.select "select_list_options", attribute_field.select_list_options, :style => "width:130px" %> <%= f.select "select_list_options", attribute_field.select_list_options, :style => "width:130px" %>
</div> </div>
</td> </td>
<td> <td class="action">
<span class="action"> <% if attribute_field.new_record? %>
<% if attribute_field.new_record? %>
<a href="#" class="delete"><%= t(:delete) %></a> <a href="#" class="delete"><%= t(:delete) %></a>
<% else %> <% else %>
<%= f.hidden_field :id %> <%= f.hidden_field :id %>
@ -25,10 +24,9 @@
<a href="#" class="switch" id="<%= attribute_field.id %>"></a> <a href="#" class="switch" id="<%= attribute_field.id %>"></a>
<%= f.hidden_field :disabled, :value => attribute_field.is_disabled? , :class => 'built_in_state' %> <%= f.hidden_field :disabled, :value => attribute_field.is_disabled? , :class => 'built_in_state' %>
<% else %> <% else %>
<a href="#" class="remove_existing_record"><%= t(:delete) %></a> <a href="#" class="remove_existing_record delete"><%= t(:delete) %></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %> <%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
<% end %> <% end %>
<% end %> <% end %>
</span>
</td> </td>
</tr> </tr>

View File

@ -42,7 +42,7 @@
</thead> </thead>
<tfoot> <tfoot>
<tr> <tr>
<td colspan="5"> <td colspan="6">
<%= hidden_field_tag 'attribute_field_count', @attribute.attribute_fields.count %> <%= hidden_field_tag 'attribute_field_count', @attribute.attribute_fields.count %>
<a href="#" class="add"><%= t(:add) %></a> <a href="#" class="add"><%= t(:add) %></a>
</td> </td>

View File

@ -1,5 +1,6 @@
<div class="attributes_block <%= @class %>"> <div class="attributes_block <%= @class %>">
<h2><%= t("admin.#{@attribute_type}") %></h2> <h2><%= t("admin.#{@attribute_type}") %></h2>
<hr>
<div class="info_input"> <div class="info_input">
<table border="0" cellspacing="0" cellpadding="0"> <table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head"> <thead class="list_head">
@ -26,13 +27,14 @@
<div id='sub_roles' class="attributes_block <%= @class %>"> <div id='sub_roles' class="attributes_block <%= @class %>">
<h2>Sub roles</h2> <h2>Sub roles</h2>
<hr>
<% @attribute.sub_roles.each_with_index do |sub_role, i| %> <% @attribute.sub_roles.each_with_index do |sub_role, i| %>
<%= render :partial => 'form_sub', :object => sub_role, :locals => {:f => f, :i => i} %> <%= render :partial => 'form_sub', :object => sub_role, :locals => {:f => f, :i => i} %>
<% end %> <% end %>
</div> </div>
</div> </div>
<div id='add_sub_role' class="info_input attributes_block"> <div id='add_sub_role'>
<%= hidden_field_tag 'attribute_field_count', @attribute.sub_roles.count %> <%= hidden_field_tag 'attribute_field_count', @attribute.sub_roles.count %>
<a href="#" class="add"><%= t(:add) %></a> <a href="#" class="add"><%= t(:add) %></a>
</div> </div>

View File

@ -1,4 +1,3 @@
<div class="info_input"> <div class="info_input">
<table border="0" cellspacing="0" cellpadding="0"> <table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head"> <thead class="list_head">
@ -20,7 +19,7 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<div class="attributes_block <%= @class %>"> <div class="group">
<h2>Attributes</h2> <h2>Attributes</h2>
<div class="info_input"> <div class="info_input">
<table class="sub_role_attributes" border="0" cellspacing="0" cellpadding="0"> <table class="sub_role_attributes" border="0" cellspacing="0" cellpadding="0">
@ -37,10 +36,12 @@
</thead> </thead>
<tfoot> <tfoot>
<tr> <tr>
<td id='add_attribute' colspan="5"> <td colspan="6">
<%= hidden_field_tag 'attribute_field_count', sub_role.attribute_fields.count %> <div id='add_attribute'>
<a href="#" class="add"><%= t(:add) %></a> <%= hidden_field_tag 'attribute_field_count', sub_role.attribute_fields.count %>
<%= hidden_field_tag 'sub_role_temp_id', (i rescue 'new_sub_roles') %> <a href="#" class="add"><%= t(:add) %></a>
<%= hidden_field_tag 'sub_role_temp_id', (i rescue 'new_sub_roles') %>
</div>
</td> </td>
</tr> </tr>
</tfoot> </tfoot>

View File

@ -28,7 +28,7 @@
<% @roles.each do |role| %> <% @roles.each do |role| %>
<div id="<%= role.id %>_block" class="attributes_block <%= @class %>" <%= raw(' style="display: none;"') unless ((@user.role.id.eql?(role.id) rescue nil) || (role.key.eql?('student') && @user.new_record?)) %>> <div id="<%= role.id %>_block" class="attributes_block <%= @class %>" <%= raw(' style="display: none;"') unless ((@user.role.id.eql?(role.id) rescue nil) || (role.key.eql?('student') && @user.new_record?)) %>>
<h2><%= role.i18n_variable[I18n.locale] %></h2> <h2><%= role.i18n_variable[I18n.locale] %></h2>
<hr> <hr class="<#%= @user.role.key %>_block">
<%= render :partial => 'sub_role_selector', :locals => {:f => f, :role => role} %> <%= render :partial => 'sub_role_selector', :locals => {:f => f, :role => role} %>
<%= render :partial => 'sub_role', :collection => role.sub_roles, :locals => {:f => f, :role => role} %> <%= render :partial => 'sub_role', :collection => role.sub_roles, :locals => {:f => f, :role => role} %>
</div> </div>

View File

@ -1,4 +1,4 @@
<div id="sub_role_<%= show_sub_role.id %>" class="info_input"> <div id="sub_role_<%= show_sub_role.id %>" class="group">
<h2><%= show_sub_role.i18n_variable[I18n.locale] %></h2> <h2><%= show_sub_role.i18n_variable[I18n.locale] %></h2>
<%= render :partial => 'show_attribute', :object => show_sub_role %> <%= render :partial => 'show_attribute', :object => show_sub_role %>
</div> </div>

View File

@ -1,5 +1,6 @@
<div id="sub_role_<%= sub_role.id %>" class="info_input" <%= raw(' style="display: none;"') unless @user.sub_role_ids.include?(sub_role.id) %>> <div id="sub_role_<%= sub_role.id %>" class="group" <%= raw(' style="display: none;"') unless @user.sub_role_ids.include?(sub_role.id) %>>
<h2><%= sub_role.i18n_variable[I18n.locale] %></h2> <h2><%= sub_role.i18n_variable[I18n.locale] %></h2>
<div class="info_input">
<table border="0" cellspacing="0" cellpadding="0"> <table border="0" cellspacing="0" cellpadding="0">
<thead class="list_head"> <thead class="list_head">
<tr> <tr>
@ -34,4 +35,5 @@
<% end %> <% end %>
</tbody> </tbody>
</table> </table>
</div> </div>
</div>

View File

@ -20,9 +20,9 @@
</div> </div>
<% end -%> <% end -%>
<div id="<%= @user.role.key %>_block" class="roles_block <%= @class %>"> <div id="basic_block" class="roles_block <%= @class %>">
<h2><%= @user.role.i18n_variable[I18n.locale] %></h2> <h2><%= @user.role.i18n_variable[I18n.locale] %></h2>
<hr> <hr class="<%= @user.role.key %>_block">
<%= render :partial => 'show_sub_role', :collection => @user.sub_roles %> <%= render :partial => 'show_sub_role', :collection => @user.sub_roles %>
</div> </div>
<div class="button_bar"> <div class="button_bar">

View File

@ -33,4 +33,12 @@ module ParserLayout
end end
end end
def parse_html_image(html)
html.scan(/(?<=\<img)(.*?)(?=\/\>)/){
$1.gsub(' ','').scan(/(?<=src=\")(.*?)(?=\")/){
return File.basename($1).gsub(/[\\\"]/, '')
}
}
end
end end