From e102c1242bb74c3b92b717b302e600fd70aaa0ef Mon Sep 17 00:00:00 2001 From: Fabio Teixeira Date: Wed, 23 Jul 2014 16:03:11 -0300 Subject: [PATCH] incomplete_registration: New visualization to percentage of profile complete regeistration. --- lib/mpog_software_plugin.rb | 9 +++------ public/mpog-incomplete-registration.js | 16 +++++++++++++++- public/style.css | 25 +++++++++++++------------ views/incomplete_registration.html.erb | 37 +++++++++---------------------------- 4 files changed, 40 insertions(+), 47 deletions(-) diff --git a/lib/mpog_software_plugin.rb b/lib/mpog_software_plugin.rb index 3aae3f9..f45770a 100644 --- a/lib/mpog_software_plugin.rb +++ b/lib/mpog_software_plugin.rb @@ -150,17 +150,14 @@ class MpogSoftwarePlugin < Noosfero::Plugin person.has_permission_without_plugins?(permission, target) end - - def body_middle + def incomplete_registration return if context.session[:user].nil? or context.session[:hide_incomplete_percentage] == true person = Person.where(:user_id=>context.session[:user]).first unless person.nil? - @profile_edit_link = link_to _("Complete your registration"), "/myprofile/#{person.identifier}/profile_editor/edit" - @profile_empty_fields = profile_required_empty_list person + @profile_edit_link = link_to _("Complete your profile"), "/myprofile/#{person.identifier}/profile_editor/edit" @percentege = calc_percentage_registration(person) - if @percentege >= 0 and @percentege <= 100 expanded_template('incomplete_registration.html.erb') end @@ -178,7 +175,7 @@ class MpogSoftwarePlugin < Noosfero::Plugin required_list = profile_required_list empty_fields = profile_required_empty_list person - percentege = (empty_fields.count*100)/required_list.count + percentege = 100 - ((empty_fields.count*100)/required_list.count) person.percentage_incomplete = percentege person.save(validate: false) percentege diff --git a/public/mpog-incomplete-registration.js b/public/mpog-incomplete-registration.js index e490d90..6c74011 100644 --- a/public/mpog-incomplete-registration.js +++ b/public/mpog-incomplete-registration.js @@ -3,11 +3,25 @@ function hide_incomplete_percentage(evt) { jQuery.get("/plugin/mpog_software/hide_registration_incomplete_percentage", {hide:true}, function(response){ if( response == true ) - jQuery("#incomplete_registration").fadeOut(); + jQuery("#complete_registration").fadeOut(); }); } +function show_complete_progressbar() { + var percentage = jQuery("#complete_registration_message span").html(); + var canvas_tag = document.getElementById("complete_registration_percentage"); + var context = canvas_tag.getContext("2d"); + + percentage = canvas_tag.width*(percentage/100.0); + + context.beginPath(); + context.rect(0, 0, percentage, canvas_tag.height); + context.fillStyle = '#00FF00'; + context.fill(); +} jQuery(document).ready(function(){ jQuery(".hide-incomplete-percentage").click(hide_incomplete_percentage); + + show_complete_progressbar(); }); diff --git a/public/style.css b/public/style.css index 3ed408a..8981bc5 100644 --- a/public/style.css +++ b/public/style.css @@ -114,22 +114,23 @@ width: 180px; } -#incomplete_registration { - position: relative; - border: solid 2px #000; +#complete_registration { padding: 5px; + width: 100%; + background-color: #fff; } -#incomplete_percentage { - text-align: center; - margin-bottom: 15px; - font-size: 18px; +#complete_registration a { + text-decoration: none; } -#profile_empty_fields span { - margin-left: 15px; +#complete_registration a:hover { + font-weight: bold; } -#profile_links table tr td { - text-align: center; -} +#complete_registration_percentage { + width: 100%; + height: 20px; + background: #fff; + border: solid 1px #000; +} \ No newline at end of file diff --git a/views/incomplete_registration.html.erb b/views/incomplete_registration.html.erb index 1320475..d42c4d9 100644 --- a/views/incomplete_registration.html.erb +++ b/views/incomplete_registration.html.erb @@ -1,29 +1,10 @@ -
-
- <%= _("Incomplete registration percentage")+":#{@percentege}%" %> +
+
+
<%= _("Complete Profile")+": #{@percentege}%" %>
+ +
+ <%= @profile_edit_link %> | + <%= link_to _("Hide"), "#", :class=>"hide-incomplete-percentage" %> +
- -
- <%= _("List with fields to be filled")+":" %> -
    - <% @profile_empty_fields.each do |field|%> -
  • - <%= field %> -
  • - <% end %> -
-
- - -
+
\ No newline at end of file -- libgit2 0.21.2