Commit 18665da354593d06daa67930c3f2dfc0174dd3d3

Authored by Parley
Committed by Luciano Prestes
1 parent f0c1c11a

deactive_and_active_profile: Add javascript and html to reason for deactivate profile

(ActionItem3287)

Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
Signed-off-by: Parley Martins <parley@outlook.com>
app/controllers/my_profile/profile_editor_controller.rb
@@ -115,4 +115,4 @@ class ProfileEditorController &lt; MyProfileController @@ -115,4 +115,4 @@ class ProfileEditorController &lt; MyProfileController
115 115
116 redirect_to back 116 redirect_to back
117 end 117 end
118 -end  
119 \ No newline at end of file 118 \ No newline at end of file
  119 +end
app/models/profile.rb
@@ -5,6 +5,7 @@ class Profile &lt; ActiveRecord::Base @@ -5,6 +5,7 @@ class Profile &lt; ActiveRecord::Base
5 5
6 attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed, :template_id, :environment, :lat, :lng, :is_template, :fields_privacy, :preferred_domain_id, :category_ids, :country, :city, :state, :national_region_code, :email, :contact_email, :redirect_l10n, :notification_time, :redirection_after_login 6 attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed, :template_id, :environment, :lat, :lng, :is_template, :fields_privacy, :preferred_domain_id, :category_ids, :country, :city, :state, :national_region_code, :email, :contact_email, :redirect_l10n, :notification_time, :redirection_after_login
7 7
  8 +
8 # use for internationalizable human type names in search facets 9 # use for internationalizable human type names in search facets
9 # reimplement on subclasses 10 # reimplement on subclasses
10 def self.type_name 11 def self.type_name
@@ -154,6 +155,8 @@ class Profile &lt; ActiveRecord::Base @@ -154,6 +155,8 @@ class Profile &lt; ActiveRecord::Base
154 settings_items :public_content, :type => :boolean, :default => true 155 settings_items :public_content, :type => :boolean, :default => true
155 settings_items :description 156 settings_items :description
156 settings_items :fields_privacy, :type => :hash, :default => {} 157 settings_items :fields_privacy, :type => :hash, :default => {}
  158 + settings_items :reason_to_deactivate, :type => :text, :default=>""
  159 +
157 160
158 validates_length_of :description, :maximum => 550, :allow_nil => true 161 validates_length_of :description, :maximum => 550, :allow_nil => true
159 162
app/views/profile_editor/edit.html.erb
1 <h1><%= _('Profile settings for %s') % profile.name %></h1> 1 <h1><%= _('Profile settings for %s') % profile.name %></h1>
2 - 2 +<%= javascript_include_tag 'deactivate_profile' %>
3 <%= error_messages_for :profile_data %> 3 <%= error_messages_for :profile_data %>
4 4
5 <%= labelled_form_for :profile_data, :html => { :id => 'profile-data', :multipart => true } do |f| %> 5 <%= labelled_form_for :profile_data, :html => { :id => 'profile-data', :multipart => true } do |f| %>
@@ -71,11 +71,22 @@ @@ -71,11 +71,22 @@
71 <% if environment.admins.include?(current_person) %> 71 <% if environment.admins.include?(current_person) %>
72 72
73 <% if profile.visible? %> 73 <% if profile.visible? %>
74 - <%= button(:remove, _('Deactivate profile'), {:action => :deactivate_profile, :id=>profile.id}, :data => {:confirm=>_("Are you sure ?")}) %> 74 + <%= button(:remove, _('Deactivate profile'), nil, :id=>'deactivate_profile_button') %>
75 <% else %> 75 <% else %>
76 <%= button(:add, _('Activate profile'), {:action => :activate_profile, :id=>profile.id}, :data => {:confirm=>_("Are you sure ?")}) %> 76 <%= button(:add, _('Activate profile'), {:action => :activate_profile, :id=>profile.id}, :data => {:confirm=>_("Are you sure ?")}) %>
77 <% end %> 77 <% end %>
78 <% end %> 78 <% end %>
79 <% end %> 79 <% end %>
80 <% end %> 80 <% end %>
  81 +
  82 +
81 <% end %> 83 <% end %>
  84 +
  85 +<div class='deactivate-profile hidden'>
  86 + <%= label_tag 'reason', _("Reason to deactivate profile:")%><br />
  87 + <%= text_area_tag('profile_data[reason_to_deactivate]', nil, :class=>"expand-field") %>
  88 + <% button_bar(:id => 'deactivate-profile') do %>
  89 + <%= button(:remove, _('Confirm Deactivation'), {:action => :deactivate_profile, :id=>profile.id, :reason=>@profile.reason_to_deactivate}, :id=>'confirm_deactivation_button') %>
  90 + <%= button(:cancel, _('Cancel'), nil, :id=>'cancel_deactivation_button') %>
  91 + <% end %>
  92 + </div>
public/javascripts/deactivate_profile.js 0 → 100644
@@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
  1 +function show_reason_fields(event){
  2 + event.preventDefault();
  3 + jQuery(".deactivate-profile").show();
  4 + jQuery(".deactivate-profile").switchClass("hidden", "show");
  5 +}
  6 +
  7 +jQuery(document).ready(function(){
  8 + jQuery("#deactivate_profile_button").click(show_reason_fields);
  9 +});
0 \ No newline at end of file 10 \ No newline at end of file