Commit 2ecc71beb12189129a5aa0547f8344f391103fd0
1 parent
12664f27
Exists in
institution_modal_on_rating
Display modal to create a new institution
Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com> Signed-off-by: Pedro de Lyra <pedrodelyra@gmail.com>
Showing
5 changed files
with
58 additions
and
22 deletions
Show diff stats
src/noosfero-spb/gov_user/public/style.css
| @@ -24,3 +24,12 @@ | @@ -24,3 +24,12 @@ | ||
| 24 | border-color: #FF0000; | 24 | border-color: #FF0000; |
| 25 | box-shadow: 0 0 10px #FF0000; | 25 | box-shadow: 0 0 10px #FF0000; |
| 26 | } | 26 | } |
| 27 | + | ||
| 28 | +#institution_empty_ajax_message { | ||
| 29 | + margin-top: 10px; | ||
| 30 | + margin-left: 0px !important; | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +#create_institution_link { | ||
| 34 | + margin-left: 8px; | ||
| 35 | +} |
src/noosfero-spb/gov_user/public/views/create-institution.js
| @@ -34,6 +34,7 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | @@ -34,6 +34,7 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | ||
| 34 | close: function() { | 34 | close: function() { |
| 35 | $("#institution_dialog").html(""); | 35 | $("#institution_dialog").html(""); |
| 36 | $('#institution_empty_ajax_message').switchClass("show-field", "hide-field"); | 36 | $('#institution_empty_ajax_message').switchClass("show-field", "hide-field"); |
| 37 | + toggle_extra_fields_style_status(false); | ||
| 37 | } | 38 | } |
| 38 | }); | 39 | }); |
| 39 | }); | 40 | }); |
| @@ -196,6 +197,16 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | @@ -196,6 +197,16 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | ||
| 196 | return user_institutions; | 197 | return user_institutions; |
| 197 | } | 198 | } |
| 198 | 199 | ||
| 200 | + function toggle_extra_fields_style_status(status) { | ||
| 201 | + if(status) { | ||
| 202 | + $('.extra-fields-container').css({ marginTop: "55px" }); | ||
| 203 | + $('.button-bar').css({ marginTop: "55px" }); | ||
| 204 | + } else { | ||
| 205 | + $('.extra-fields-container').css({ marginTop: "0px" }); | ||
| 206 | + $('.button-bar').css({ marginTop: "20px" }); | ||
| 207 | + } | ||
| 208 | + } | ||
| 209 | + | ||
| 199 | 210 | ||
| 200 | function institution_autocomplete() { | 211 | function institution_autocomplete() { |
| 201 | $("#input_institution").autocomplete({ | 212 | $("#input_institution").autocomplete({ |
| @@ -209,8 +220,17 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | @@ -209,8 +220,17 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | ||
| 209 | 220 | ||
| 210 | if( result.length === 0 ) { | 221 | if( result.length === 0 ) { |
| 211 | $('#institution_empty_ajax_message').switchClass("hide-field", "show-field"); | 222 | $('#institution_empty_ajax_message').switchClass("hide-field", "show-field"); |
| 223 | + | ||
| 224 | + if(!$('#institution_empty_ajax_message').has('a').length) { | ||
| 225 | + $('#institution_empty_ajax_message').append("<a id='create_institution_link' class='button with-text icon-save submit' href='#'>Adicionar</a>"); | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + toggle_extra_fields_style_status(true); | ||
| 229 | + $("#create_institution_link").click(open_create_institution_modal); | ||
| 212 | } else { | 230 | } else { |
| 213 | $('#institution_empty_ajax_message').switchClass("show-field", "hide-field"); | 231 | $('#institution_empty_ajax_message').switchClass("show-field", "hide-field"); |
| 232 | + $("#create_institution_link").remove(); | ||
| 233 | + toggle_extra_fields_style_status(false); | ||
| 214 | } | 234 | } |
| 215 | }, | 235 | }, |
| 216 | error: function(ajax, stat, errorThrown) { | 236 | error: function(ajax, stat, errorThrown) { |
| @@ -223,11 +243,6 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | @@ -223,11 +243,6 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | ||
| 223 | 243 | ||
| 224 | select : function (event, selected) { | 244 | select : function (event, selected) { |
| 225 | $("#institution_selected").val(selected.item.id).attr("data-name", selected.item.label); | 245 | $("#institution_selected").val(selected.item.id).attr("data-name", selected.item.label); |
| 226 | - | ||
| 227 | - // +("") -> 0; +("1") -> 1... | ||
| 228 | - if (+($("#institution_selected").val()) !== 0) { | ||
| 229 | - add_new_institution(); | ||
| 230 | - } | ||
| 231 | } | 246 | } |
| 232 | }); | 247 | }); |
| 233 | } | 248 | } |
| @@ -241,27 +256,27 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | @@ -241,27 +256,27 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | ||
| 241 | } | 256 | } |
| 242 | 257 | ||
| 243 | 258 | ||
| 244 | - function add_new_institution() { | 259 | + function add_new_institution(evt) { |
| 260 | + evt.preventDefault(); | ||
| 245 | var selected = $("#institution_selected"); | 261 | var selected = $("#institution_selected"); |
| 246 | - var already_added_to_list = is_institution_already_added_to_list(selected.val()); | 262 | + var institution_already_added = $(".institutions_added li[data-institution='"+selected.val()+"']").length; |
| 247 | 263 | ||
| 248 | - if(selected.val().length > 0 && !already_added_to_list) { | 264 | + if(selected.val().length > 0 && institution_already_added === 0) { |
| 249 | //field that send the institutions to the server | 265 | //field that send the institutions to the server |
| 250 | $(".institution_container").append(get_clone_institution_data(selected.val())); | 266 | $(".institution_container").append(get_clone_institution_data(selected.val())); |
| 251 | 267 | ||
| 252 | // Visualy add the selected institution to the list | 268 | // Visualy add the selected institution to the list |
| 253 | add_selected_institution_to_list(selected.val(), selected.attr("data-name")); | 269 | add_selected_institution_to_list(selected.val(), selected.attr("data-name")); |
| 254 | 270 | ||
| 271 | + // clean the institution flag | ||
| 272 | + selected.val("").attr("data-name", ""); | ||
| 273 | + $("#input_institution").val(""); | ||
| 274 | + | ||
| 255 | $(".remove-institution").click(remove_institution); | 275 | $(".remove-institution").click(remove_institution); |
| 256 | } | 276 | } |
| 257 | } | 277 | } |
| 258 | 278 | ||
| 259 | 279 | ||
| 260 | - function is_institution_already_added_to_list(institution_id) { | ||
| 261 | - return $(".institutions_added li[data-institution='"+institution_id+"']").length !== 0; | ||
| 262 | - } | ||
| 263 | - | ||
| 264 | - | ||
| 265 | function remove_institution(evt) { | 280 | function remove_institution(evt) { |
| 266 | evt.preventDefault(); | 281 | evt.preventDefault(); |
| 267 | var code = $(this).parent().attr("data-institution"); | 282 | var code = $(this).parent().attr("data-institution"); |
| @@ -365,6 +380,7 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | @@ -365,6 +380,7 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | ||
| 365 | } | 380 | } |
| 366 | 381 | ||
| 367 | function set_events() { | 382 | function set_events() { |
| 383 | + | ||
| 368 | $("#create_institution_link").click(open_create_institution_modal); | 384 | $("#create_institution_link").click(open_create_institution_modal); |
| 369 | 385 | ||
| 370 | $("input[name='institutions[type]']").click(function(){ | 386 | $("input[name='institutions[type]']").click(function(){ |
| @@ -376,6 +392,8 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | @@ -376,6 +392,8 @@ modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'] | ||
| 376 | 392 | ||
| 377 | $("#community_name").keyup(institution_already_exists); | 393 | $("#community_name").keyup(institution_already_exists); |
| 378 | 394 | ||
| 395 | + $("#add_new_institution").click(add_new_institution); | ||
| 396 | + | ||
| 379 | $(".remove-institution").click(remove_institution); | 397 | $(".remove-institution").click(remove_institution); |
| 380 | 398 | ||
| 381 | $("#community_country").change(function(){ | 399 | $("#community_country").change(function(){ |
src/noosfero-spb/gov_user/views/ratings_extra_field.html.erb
| @@ -8,3 +8,5 @@ | @@ -8,3 +8,5 @@ | ||
| 8 | :class=>"errorExplanation hide-field") %> | 8 | :class=>"errorExplanation hide-field") %> |
| 9 | <%= hidden_field_tag "organization_rating[institution_id]", "", id: "institution_selected" %> | 9 | <%= hidden_field_tag "organization_rating[institution_id]", "", id: "institution_selected" %> |
| 10 | </div> | 10 | </div> |
| 11 | + | ||
| 12 | +<%= content_tag(:div, "", :id=>"institution_dialog") %> | ||
| 11 | \ No newline at end of file | 13 | \ No newline at end of file |
src/noosfero-spb/software_communities/public/style.css
src/noosfero-spb/software_communities/views/comments_extra_fields.html.erb
| @@ -7,15 +7,18 @@ | @@ -7,15 +7,18 @@ | ||
| 7 | </div> | 7 | </div> |
| 8 | 8 | ||
| 9 | <div class="comments-software-extra-fields"> | 9 | <div class="comments-software-extra-fields"> |
| 10 | - <div class="comments-software-people-benefited"> | ||
| 11 | - <%= label_tag "comments_people_benefited", _("Number of Beneficiaries")%> | ||
| 12 | - <span class="star-tooltip" title="Quantidade de pessoas beneficiadas com a utilização do software"></span> | ||
| 13 | - <%= text_field_tag "organization_rating[people_benefited]", "" %> | ||
| 14 | - </div> | ||
| 15 | 10 | ||
| 16 | - <div class="comments-software-saved-values"> | ||
| 17 | - <%= label_tag "comments_saved_value", _("Saved resources")%> | ||
| 18 | - <span class="star-tooltip" title="Valores em “Real” economizados com a utilização do software"></span> | ||
| 19 | - <%= text_field_tag "organization_rating[saved_value]", "", :placeholder=>"R$"%> | 11 | + <div class="extra-fields-container"> |
| 12 | + <div class="comments-software-people-benefited"> | ||
| 13 | + <%= label_tag "comments_people_benefited", _("Number of Beneficiaries")%> | ||
| 14 | + <span class="star-tooltip" title="Estimativa do número de pessoas beneficiadas com a utilização do software"></span> | ||
| 15 | + <%= text_field_tag "organization_rating[people_benefited]", "" %> | ||
| 16 | + </div> | ||
| 17 | + | ||
| 18 | + <div class="comments-software-saved-values"> | ||
| 19 | + <%= label_tag "comments_saved_value", _("Saved resources")%> | ||
| 20 | + <span class="star-tooltip" title='Estimativa dos valores em "Real" economizados com a utilização do software'></span> | ||
| 21 | + <%= text_field_tag "organization_rating[saved_value]", "", :placeholder=>"R$"%> | ||
| 22 | + </div> | ||
| 20 | </div> | 23 | </div> |
| 21 | </div> | 24 | </div> |