From 18665da354593d06daa67930c3f2dfc0174dd3d3 Mon Sep 17 00:00:00 2001 From: ParleyMartins Date: Wed, 3 Sep 2014 09:47:09 -0300 Subject: [PATCH] deactive_and_active_profile: Add javascript and html to reason for deactivate profile --- app/controllers/my_profile/profile_editor_controller.rb | 2 +- app/models/profile.rb | 3 +++ app/views/profile_editor/edit.html.erb | 15 +++++++++++++-- public/javascripts/deactivate_profile.js | 9 +++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 public/javascripts/deactivate_profile.js diff --git a/app/controllers/my_profile/profile_editor_controller.rb b/app/controllers/my_profile/profile_editor_controller.rb index 9798ab5..9a5f5f6 100644 --- a/app/controllers/my_profile/profile_editor_controller.rb +++ b/app/controllers/my_profile/profile_editor_controller.rb @@ -115,4 +115,4 @@ class ProfileEditorController < MyProfileController redirect_to back end -end \ No newline at end of file +end diff --git a/app/models/profile.rb b/app/models/profile.rb index 90b462a..2766aab 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -5,6 +5,7 @@ class Profile < ActiveRecord::Base 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 + # use for internationalizable human type names in search facets # reimplement on subclasses def self.type_name @@ -154,6 +155,8 @@ class Profile < ActiveRecord::Base settings_items :public_content, :type => :boolean, :default => true settings_items :description settings_items :fields_privacy, :type => :hash, :default => {} + settings_items :reason_to_deactivate, :type => :text, :default=>"" + validates_length_of :description, :maximum => 550, :allow_nil => true diff --git a/app/views/profile_editor/edit.html.erb b/app/views/profile_editor/edit.html.erb index 0d8ffaa..056f36c 100644 --- a/app/views/profile_editor/edit.html.erb +++ b/app/views/profile_editor/edit.html.erb @@ -1,5 +1,5 @@

<%= _('Profile settings for %s') % profile.name %>

- +<%= javascript_include_tag 'deactivate_profile' %> <%= error_messages_for :profile_data %> <%= labelled_form_for :profile_data, :html => { :id => 'profile-data', :multipart => true } do |f| %> @@ -71,11 +71,22 @@ <% if environment.admins.include?(current_person) %> <% if profile.visible? %> - <%= button(:remove, _('Deactivate profile'), {:action => :deactivate_profile, :id=>profile.id}, :data => {:confirm=>_("Are you sure ?")}) %> + <%= button(:remove, _('Deactivate profile'), nil, :id=>'deactivate_profile_button') %> <% else %> <%= button(:add, _('Activate profile'), {:action => :activate_profile, :id=>profile.id}, :data => {:confirm=>_("Are you sure ?")}) %> <% end %> <% end %> <% end %> <% end %> + + <% end %> + + diff --git a/public/javascripts/deactivate_profile.js b/public/javascripts/deactivate_profile.js new file mode 100644 index 0000000..347136f --- /dev/null +++ b/public/javascripts/deactivate_profile.js @@ -0,0 +1,9 @@ +function show_reason_fields(event){ + event.preventDefault(); + jQuery(".deactivate-profile").show(); + jQuery(".deactivate-profile").switchClass("hidden", "show"); +} + +jQuery(document).ready(function(){ + jQuery("#deactivate_profile_button").click(show_reason_fields); +}); \ No newline at end of file -- libgit2 0.21.2