diff --git a/src/noosfero-spb/gov_user/public/style.css b/src/noosfero-spb/gov_user/public/style.css index c1fdab2..e903755 100644 --- a/src/noosfero-spb/gov_user/public/style.css +++ b/src/noosfero-spb/gov_user/public/style.css @@ -24,3 +24,12 @@ border-color: #FF0000; box-shadow: 0 0 10px #FF0000; } + +#institution_empty_ajax_message { + margin-top: 10px; + margin-left: 0px !important; +} + +#create_institution_link { + margin-left: 8px; +} diff --git a/src/noosfero-spb/gov_user/public/views/create-institution.js b/src/noosfero-spb/gov_user/public/views/create-institution.js index 2da1926..3d92329 100644 --- a/src/noosfero-spb/gov_user/public/views/create-institution.js +++ b/src/noosfero-spb/gov_user/public/views/create-institution.js @@ -34,6 +34,7 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] close: function() { $("#institution_dialog").html(""); $('#institution_empty_ajax_message').switchClass("show-field", "hide-field"); + toggle_extra_fields_style_status(false); } }); }); @@ -196,6 +197,16 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] return user_institutions; } + function toggle_extra_fields_style_status(status) { + if(status) { + $('.extra-fields-container').css({ marginTop: "55px" }); + $('.button-bar').css({ marginTop: "55px" }); + } else { + $('.extra-fields-container').css({ marginTop: "0px" }); + $('.button-bar').css({ marginTop: "20px" }); + } + } + function institution_autocomplete() { $("#input_institution").autocomplete({ @@ -209,8 +220,17 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] if( result.length === 0 ) { $('#institution_empty_ajax_message').switchClass("hide-field", "show-field"); + + if(!$('#institution_empty_ajax_message').has('a').length) { + $('#institution_empty_ajax_message').append("Adicionar"); + } + + toggle_extra_fields_style_status(true); + $("#create_institution_link").click(open_create_institution_modal); } else { $('#institution_empty_ajax_message').switchClass("show-field", "hide-field"); + $("#create_institution_link").remove(); + toggle_extra_fields_style_status(false); } }, error: function(ajax, stat, errorThrown) { @@ -223,11 +243,6 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] select : function (event, selected) { $("#institution_selected").val(selected.item.id).attr("data-name", selected.item.label); - - // +("") -> 0; +("1") -> 1... - if (+($("#institution_selected").val()) !== 0) { - add_new_institution(); - } } }); } @@ -241,27 +256,27 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] } - function add_new_institution() { + function add_new_institution(evt) { + evt.preventDefault(); var selected = $("#institution_selected"); - var already_added_to_list = is_institution_already_added_to_list(selected.val()); + var institution_already_added = $(".institutions_added li[data-institution='"+selected.val()+"']").length; - if(selected.val().length > 0 && !already_added_to_list) { + if(selected.val().length > 0 && institution_already_added === 0) { //field that send the institutions to the server $(".institution_container").append(get_clone_institution_data(selected.val())); // Visualy add the selected institution to the list add_selected_institution_to_list(selected.val(), selected.attr("data-name")); + // clean the institution flag + selected.val("").attr("data-name", ""); + $("#input_institution").val(""); + $(".remove-institution").click(remove_institution); } } - function is_institution_already_added_to_list(institution_id) { - return $(".institutions_added li[data-institution='"+institution_id+"']").length !== 0; - } - - function remove_institution(evt) { evt.preventDefault(); var code = $(this).parent().attr("data-institution"); @@ -365,6 +380,7 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] } function set_events() { + $("#create_institution_link").click(open_create_institution_modal); $("input[name='institutions[type]']").click(function(){ @@ -376,6 +392,8 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] $("#community_name").keyup(institution_already_exists); + $("#add_new_institution").click(add_new_institution); + $(".remove-institution").click(remove_institution); $("#community_country").change(function(){ diff --git a/src/noosfero-spb/gov_user/views/ratings_extra_field.html.erb b/src/noosfero-spb/gov_user/views/ratings_extra_field.html.erb index 6f835d1..562fa53 100644 --- a/src/noosfero-spb/gov_user/views/ratings_extra_field.html.erb +++ b/src/noosfero-spb/gov_user/views/ratings_extra_field.html.erb @@ -8,3 +8,5 @@ :class=>"errorExplanation hide-field") %> <%= hidden_field_tag "organization_rating[institution_id]", "", id: "institution_selected" %> + +<%= content_tag(:div, "", :id=>"institution_dialog") %> \ No newline at end of file diff --git a/src/noosfero-spb/software_communities/public/style.css b/src/noosfero-spb/software_communities/public/style.css index 5d4c536..2711d26 100644 --- a/src/noosfero-spb/software_communities/public/style.css +++ b/src/noosfero-spb/software_communities/public/style.css @@ -110,3 +110,7 @@ cursor: pointer; } +.extra-fields-container { + overflow: auto; +} + diff --git a/src/noosfero-spb/software_communities/views/comments_extra_fields.html.erb b/src/noosfero-spb/software_communities/views/comments_extra_fields.html.erb index f50992a..bad694c 100644 --- a/src/noosfero-spb/software_communities/views/comments_extra_fields.html.erb +++ b/src/noosfero-spb/software_communities/views/comments_extra_fields.html.erb @@ -7,15 +7,18 @@
-
- <%= label_tag "comments_people_benefited", _("Number of Beneficiaries")%> - - <%= text_field_tag "organization_rating[people_benefited]", "" %> -
-
- <%= label_tag "comments_saved_value", _("Saved resources")%> - - <%= text_field_tag "organization_rating[saved_value]", "", :placeholder=>"R$"%> +
+
+ <%= label_tag "comments_people_benefited", _("Number of Beneficiaries")%> + + <%= text_field_tag "organization_rating[people_benefited]", "" %> +
+ +
+ <%= label_tag "comments_saved_value", _("Saved resources")%> + + <%= text_field_tag "organization_rating[saved_value]", "", :placeholder=>"R$"%> +
-- libgit2 0.21.2