diff --git a/app/controllers/admin/infos_controller.rb b/app/controllers/admin/infos_controller.rb index e79fba7b..d6325ef0 100644 --- a/app/controllers/admin/infos_controller.rb +++ b/app/controllers/admin/infos_controller.rb @@ -40,9 +40,10 @@ class Admin::InfosController < ApplicationController @attribute.update_attributes(params[:info]) @attribute.attribute_fields.each{|t| t.destroy if t["to_delete"] == true} respond_to do |format| - format.html { redirect_to :action => :index } + format.html { redirect_to(edit_admin_info_path(params[:id])) } format.js { render 'admin/attributes/toggle_enable' } end + end def destroy diff --git a/app/models/user/attribute.rb b/app/models/user/attribute.rb index c0970863..a1367c9f 100644 --- a/app/models/user/attribute.rb +++ b/app/models/user/attribute.rb @@ -6,7 +6,9 @@ class Attribute field :key field :built_in, :type => Boolean, :default => false field :disabled, :type => Boolean, :default => false - field :title, localize: true + field :title, localize: true + + field :to_search, :type => Boolean, :default => false has_many :attribute_fields, :autosave => true, :dependent => :destroy accepts_nested_attributes_for :attribute_fields, :allow_destroy => true diff --git a/app/models/user/role.rb b/app/models/user/role.rb index e5d8039d..7291c88c 100644 --- a/app/models/user/role.rb +++ b/app/models/user/role.rb @@ -7,8 +7,6 @@ class Role < Attribute field :built_in, :type => Boolean, :default => false field :disabled, :type => Boolean, :default => false - field :to_search, :type => Boolean, :default => false - field :title, localize: true has_many :sub_roles, :autosave => true, :dependent => :destroy diff --git a/app/models/user/user.rb b/app/models/user/user.rb index c9dffd70..99e086ef 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -72,14 +72,32 @@ class User sub_roles.where(role_id: role.id) end - def disable_sub_role=(var) + def disable_role=(var) var[:id].each do |id,val| # binding.pry if id == '5052c5b22b5c49ab02000004' if (val=="true") + self.roles = self.roles.reject{|t| t.id.to_s==id} + elsif(val=="false") + self.roles << Role.find(id) + end + end + end + + def disable_sub_role=(var) + var[:id].each do |id,val| + + @sr = SubRole.find(id) + + @roid = Role.find(@sr.role_id.to_s) + + # binding.pry if id == '5052c5b22b5c49ab02000004' + + if ( self.roles.include?(@roid) == false or val=="true") self.sub_roles = self.sub_roles.reject{|t| t.id.to_s==id} elsif(val=="false") self.sub_roles << SubRole.find(id) end + end end @@ -189,7 +207,8 @@ class User protected def save_roles - self.roles = self.sub_roles.collect{|t| t.role}.uniq + # self.roles = self.sub_roles.collect{|t| t.role}.uniq + self.roles = self.roles.uniq end diff --git a/app/views/admin/attributes/edit.html.erb b/app/views/admin/attributes/edit.html.erb index a98b4cad..b3cc2bb8 100644 --- a/app/views/admin/attributes/edit.html.erb +++ b/app/views/admin/attributes/edit.html.erb @@ -8,7 +8,7 @@

<%= t(eval(":#{@attribute_type}"))%>

- <% if @attribute._type == "Role" %> +
@@ -22,7 +22,6 @@
- <% end %>
@@ -47,11 +46,14 @@
+
+ <%= ( 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 )%> +
+ <% end %>
- <%= ( 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" %>
@@ -63,15 +65,11 @@ <% content_for :page_specific_javascript do -%> <% end -%> diff --git a/app/views/admin/attributes/index.html.erb b/app/views/admin/attributes/index.html.erb index eafdde02..eb8695a6 100644 --- a/app/views/admin/attributes/index.html.erb +++ b/app/views/admin/attributes/index.html.erb @@ -1,5 +1,3 @@ -<% # 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 %> @@ -56,17 +54,5 @@
<%= 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"%> -
- -
\ No newline at end of file diff --git a/app/views/admin/attributes/new.html.erb b/app/views/admin/attributes/new.html.erb index 99b526ff..bffc3758 100644 --- a/app/views/admin/attributes/new.html.erb +++ b/app/views/admin/attributes/new.html.erb @@ -5,7 +5,6 @@
- <% if @attribute._type == "Role" %>
@@ -19,7 +18,6 @@
- <% end %>
diff --git a/app/views/admin/roles/_attribute_field.html.erb b/app/views/admin/roles/_attribute_field.html.erb index 240a8c18..8ec2675d 100644 --- a/app/views/admin/roles/_attribute_field.html.erb +++ b/app/views/admin/roles/_attribute_field.html.erb @@ -2,13 +2,13 @@ <% attribute_field.af_count ? @af_counter = attribute_field_counter + attribute_field.af_count : @af_counter = attribute_field_counter %> - <%= @af_counter %> + <%= @af_counter + 1 %> <%#= attribute_field_counter %> <%= 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"%> - <%= t(:delete_)%> + <%= t(:delete_)%>
diff --git a/app/views/admin/roles/add_sub_role.html.erb b/app/views/admin/roles/add_sub_role.html.erb index bf4bf1e9..fd4f4bb2 100644 --- a/app/views/admin/roles/add_sub_role.html.erb +++ b/app/views/admin/roles/add_sub_role.html.erb @@ -4,6 +4,21 @@

<%= t(eval(":#{@attribute_type}"))%>:<%= @attribute.title %>

+ +
+ +
+ + +
+
+
diff --git a/app/views/admin/roles/edit_sub_role.html.erb b/app/views/admin/roles/edit_sub_role.html.erb index b4848fd4..54036ff7 100644 --- a/app/views/admin/roles/edit_sub_role.html.erb +++ b/app/views/admin/roles/edit_sub_role.html.erb @@ -4,6 +4,21 @@

<%= t(eval(":#{@attribute_type}"))%>:<%= @attribute.title %>

+ +
+ +
+ + +
+
+
diff --git a/app/views/admin/roles/sub_role.html.erb b/app/views/admin/roles/sub_role.html.erb index 9dc8892e..cacfee41 100644 --- a/app/views/admin/roles/sub_role.html.erb +++ b/app/views/admin/roles/sub_role.html.erb @@ -1,41 +1,60 @@ +<% # 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 %> -
-
- <%= link_to t(:new_sub_role), eval("admin_#{@attribute_type}_add_sub_role_path(@attribute)"), :class => 'new' %> -
- - - - - - - - - <% @attribute_fields_upper_object.each do |attribute| %> - "> - - - - - - <% end %> - -
<%= t("#{@attribute_type}") %>:<%= @attribute.title %><%= t(:action) %>
<%= attribute.title %> - - - <%= 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 %> -
-
- <%= link_to t(:new_sub_role), eval("admin_#{@attribute_type}_add_sub_role_path(@attribute)"), :class => 'new' %> + + + + + + + + + + + <% @attribute_fields_upper_object.each do |attribute| %> + + + + <% end %> + + +
+ <%= attribute.title %> +
+ +
+
+ +
+ <%= link_to content_tag(:i,t(:new_sub_role),:class=>"icon-plus icon-white"),eval("admin_#{@attribute_type}_add_sub_role_path(@attribute)"),:class=>"btn btn-primary pull-right"%> +
\ No newline at end of file diff --git a/app/views/admin/roles/sub_role_field.html.erb b/app/views/admin/roles/sub_role_field.html.erb index ed71f8b7..de741270 100644 --- a/app/views/admin/roles/sub_role_field.html.erb +++ b/app/views/admin/roles/sub_role_field.html.erb @@ -11,11 +11,14 @@ <%= render :partial=>"attribute_field",:collection=>@sub_attribute.attribute_fields%>
+ +
+ <%= 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%> +
- <%= 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"%> diff --git a/app/views/admin/users_new_interface/_role.html.erb b/app/views/admin/users_new_interface/_role.html.erb index ac04809f..c3adeacc 100644 --- a/app/views/admin/users_new_interface/_role.html.erb +++ b/app/views/admin/users_new_interface/_role.html.erb @@ -1,14 +1,23 @@ -
-

<%= role.title %>

-
- +<% role_disable = @user.roles.include?(role) ? false : true %> + + +
+

+ <%= role.title %> + <%= hidden_field_tag("user[disable_role][id][#{role.id}]",role_disable,:for=>@form_index,:class=>"subrole_disable_field",:value=>role_disable)%> +

+ +
+ <% role.attribute_fields.each do |rf|%> <%= rf.block_helper(@user,@form_index)%> <% @form_index = @form_index +1 %> <% end %> + +<% @form_index = @form_index +1 %> <% role.sub_roles.where(:disabled=>false).each do |sub_role| %> <% sub_role_disable = @user.sub_roles.include?(sub_role) ? false : true %> diff --git a/app/views/admin/users_new_interface/_side_bar.html.erb b/app/views/admin/users_new_interface/_side_bar.html.erb index 651f0794..0fb52b28 100644 --- a/app/views/admin/users_new_interface/_side_bar.html.erb +++ b/app/views/admin/users_new_interface/_side_bar.html.erb @@ -4,7 +4,7 @@ <%= 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') if (is_admin? rescue nil) %> <%= 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, edit_admin_info_path('4f45f3b9e9d02c5db900002c')), :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, edit_admin_info_path(Info.first.id.to_s)), :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 -%> diff --git a/app/views/shared/attribute_field/_attribute_field.html.erb b/app/views/shared/attribute_field/_attribute_field.html.erb index 30623fbe..328d4cb5 100644 --- a/app/views/shared/attribute_field/_attribute_field.html.erb +++ b/app/views/shared/attribute_field/_attribute_field.html.erb @@ -2,14 +2,25 @@ <% attribute_field.af_count ? @af_counter = attribute_field_counter + attribute_field.af_count : @af_counter = attribute_field_counter %> - <%= @af_counter %> + <%= @af_counter + 1 %> <%#= attribute_field_counter %> <%= hidden_field "info[attribute_fields][#{@af_counter}]","disabled",:value=>attribute_field.disabled,:class=>"attribute_field_disabled"%> <%= hidden_field "info[attribute_fields][#{@af_counter}]","to_delete",:value=>false,:class=>"attribute_field_to_delete"%> - <%= t(:delete_)%> + <%= t(:delete_)%>
+
+ +
+ + +
+
diff --git a/vendor/built_in_modules/announcement/init.rb b/vendor/built_in_modules/announcement/init.rb index 79aba936..4ae40c3f 100644 --- a/vendor/built_in_modules/announcement/init.rb +++ b/vendor/built_in_modules/announcement/init.rb @@ -1,13 +1,13 @@ -module Announcement - OrbitApp.registration "Announcement",:type=> 'ModuleApp' do +# module Announcement + # OrbitApp.registration "Announcement",:type=> 'ModuleApp' do - base_url File.expand_path File.dirname(__FILE__) - personal_plugin :enable => true,:path=>"panel/announcement/plugin/profile" + # base_url File.expand_path File.dirname(__FILE__) + # personal_plugin :enable => true,:path=>"panel/announcement/plugin/profile" - end + # end -end +# end # OrbitApp.backend_side_bar 'News' do