Commit 6b03fc9c46969a3a0fe06765ffceca7e0cb5074b
1 parent
cefdc01f
Exists in
master
and in
5 other branches
incomplete_registration: Using session to hide the percentage message
Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com> Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Showing
4 changed files
with
28 additions
and
38 deletions
Show diff stats
lib/mpog_software_plugin.rb
... | ... | @@ -136,7 +136,7 @@ class MpogSoftwarePlugin < Noosfero::Plugin |
136 | 136 | end |
137 | 137 | |
138 | 138 | def js_files |
139 | - ["mpog-software-validations.js", "mpog-user-validations.js", "mpog-institution-validations.js"] | |
139 | + ["mpog-software-validations.js", "mpog-user-validations.js", "mpog-institution-validations.js", "mpog-incomplete-registration.js"] | |
140 | 140 | end |
141 | 141 | |
142 | 142 | def add_new_organization_button |
... | ... | @@ -150,12 +150,6 @@ class MpogSoftwarePlugin < Noosfero::Plugin |
150 | 150 | person.has_permission_without_plugins?(permission, target) |
151 | 151 | end |
152 | 152 | |
153 | - def create_url_to_edit_profile person | |
154 | - new_url = person.public_profile_url | |
155 | - new_url[:controller] = 'profile_editor' | |
156 | - new_url[:action] = 'edit' | |
157 | - new_url | |
158 | - end | |
159 | 153 | |
160 | 154 | def incomplete_registration params |
161 | 155 | return if params.nil? or params[:user].nil? |
... | ... | @@ -170,11 +164,18 @@ class MpogSoftwarePlugin < Noosfero::Plugin |
170 | 164 | @profile_empty_fields = profile_required_empty_list person |
171 | 165 | @percentege = calc_percentage_registration(person) |
172 | 166 | |
173 | - if @percentege >= 0 and @percentege <= 100 | |
167 | + if @percentege >= 0 and @percentege <= 100 and context.session[:hide_incomplete_percentage] != true | |
174 | 168 | expanded_template('mpog_software_plugin_myprofile/_incomplete_registration.html.erb') |
175 | 169 | end |
176 | 170 | end |
177 | 171 | |
172 | + | |
173 | + def manage_software | |
174 | + [{:title => _('Manage Software'), :url => {:controller => 'mpog_software_plugin', :action => 'archive_software'}}] | |
175 | + end | |
176 | + | |
177 | + protected | |
178 | + | |
178 | 179 | def calc_percentage_registration person |
179 | 180 | required_list = profile_required_list |
180 | 181 | empty_fields = profile_required_empty_list person |
... | ... | @@ -185,25 +186,13 @@ class MpogSoftwarePlugin < Noosfero::Plugin |
185 | 186 | percentege |
186 | 187 | end |
187 | 188 | |
188 | - def add_link_to_complete_registration person | |
189 | - #find a better way to do it | |
190 | - if context.session[:hide_incomplete_percentage] != true | |
191 | - _new_url = create_url_to_edit_profile(person) | |
192 | - Proc::new do | |
193 | - content_tag(:div, | |
194 | - link_to( _("Percentage incomplete: #{person.percentage_incomplete.to_s} %" ), _new_url) + | |
195 | - link_to(image_tag("/images/icon_filter_exclude.png"), "#", :class => "hide-incomplete-percentage", :alt => "Hide Incomplete Percentage"), :class=>"mpog-incomplete-percentage" | |
196 | - ) | |
197 | - end | |
198 | - end | |
189 | + def create_url_to_edit_profile person | |
190 | + new_url = person.public_profile_url | |
191 | + new_url[:controller] = 'profile_editor' | |
192 | + new_url[:action] = 'edit' | |
193 | + new_url | |
199 | 194 | end |
200 | 195 | |
201 | - def manage_software | |
202 | - [{:title => _('Manage Software'), :url => {:controller => 'mpog_software_plugin', :action => 'archive_software'}}] | |
203 | - end | |
204 | - | |
205 | - protected | |
206 | - | |
207 | 196 | def profile_required_list |
208 | 197 | required_list = ["cell_phone","contact_phone","institution","comercial_phone","country","city","state","organization_website","role","area_interest","image"] |
209 | 198 | end | ... | ... |
... | ... | @@ -0,0 +1,13 @@ |
1 | +function hide_incomplete_percentage(evt) { | |
2 | + evt.preventDefault(); | |
3 | + | |
4 | + jQuery.get("/plugin/mpog_software/hide_registration_incomplete_percentage", {hide:true}, function(response){ | |
5 | + if( response == true ) | |
6 | + jQuery("#incomplete_registration").fadeOut(); | |
7 | + }); | |
8 | +} | |
9 | + | |
10 | + | |
11 | +jQuery(document).ready(function(){ | |
12 | + jQuery(".hide-incomplete-percentage").click(hide_incomplete_percentage); | |
13 | +}); | ... | ... |
public/mpog-user-validations.js
... | ... | @@ -73,16 +73,6 @@ function institution_autocomplete() { |
73 | 73 | } |
74 | 74 | |
75 | 75 | |
76 | -function hide_incomplete_percentage(evt) { | |
77 | - evt.preventDefault(); | |
78 | - var link_div = jQuery(this).parent(); | |
79 | - | |
80 | - jQuery.get("/plugin/mpog_software/hide_registration_incomplete_percentage", {hide:true}, function(response){ | |
81 | - if( response == true ) | |
82 | - link_div.hide(); | |
83 | - }); | |
84 | -} | |
85 | - | |
86 | 76 | jQuery(document).ready(function(){ |
87 | 77 | jQuery('#secondary_email_field').blur( |
88 | 78 | validate_email_format |
... | ... | @@ -92,8 +82,6 @@ jQuery(document).ready(function(){ |
92 | 82 | put_brazil_based_on_email |
93 | 83 | ); |
94 | 84 | |
95 | - jQuery(".hide-incomplete-percentage").click(hide_incomplete_percentage); | |
96 | - | |
97 | 85 | jQuery('#secondary_email_field').focus(function() { jQuery('#secondary-email-balloon').fadeIn('slow'); }); |
98 | 86 | jQuery('#secondary_email_field').blur(function() { jQuery('#secondary-email-balloon').fadeOut('slow'); }); |
99 | 87 | ... | ... |
views/mpog_software_plugin_myprofile/_incomplete_registration.html.erb