Commit 30e39dd95746ea2fb303e5730e3e975708b77b22

Authored by Luciano Prestes
Committed by David Silva
1 parent d603d8ba
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

Change dynamically link of license in create and edit software

Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
controllers/mpog_software_plugin_myprofile_controller.rb
... ... @@ -22,9 +22,7 @@ class MpogSoftwarePluginMyprofileController &lt; MyProfileController
22 22 @license_info = if params[:license_info].nil?
23 23 LicenseInfo.new
24 24 else
25   - LicenseInfo.find(:first,
26   - :conditions => ["version = ?",
27   - "#{params[:license_info][:version]}"])
  25 + LicenseInfo.find(params[:license_info][:version])
28 26 end
29 27  
30 28 control_software_creation
... ...
public/mpog-software-validations.js
... ... @@ -89,9 +89,8 @@
89 89 Element.insert(element_id, {bottom: content});
90 90 }
91 91  
92   - function get_license_link(select_id){
93   - var selected = jQuery('#'+select_id).selected().val();
94   - var link = jQuery("#version_" + selected).val();
  92 + function get_license_link(){
  93 + var link = jQuery("#version_" + this.value).val();
95 94  
96 95 jQuery("#version_link")
97 96 .attr("href", link)
... ... @@ -208,5 +207,7 @@
208 207 jQuery("#software_public_software").click(hide_show_public_software_fields);
209 208  
210 209 replace_software_creations_step();
  210 +
  211 + jQuery("#license_info_version").change(get_license_link);
211 212 });
212 213 })();
... ...
views/mpog_software_plugin_myprofile/_main_software_editor_extras.html.erb
... ... @@ -12,14 +12,13 @@
12 12  
13 13 <h3> <%= _("Licenses") %> </h3>
14 14 <div id='licenses'>
15   - <%= select_tag("license[license_infos_id]", options_for_select(LicenseHelper.getListLicenses.collect{|l| [l.version, l.id]}, :selected => @profile.software_info.license_info.id), :onchange => "get_license_link('version')") %>
  15 + <%= select_tag("license[license_infos_id]", options_for_select(LicenseHelper.getListLicenses.collect{|l| [l.version, l.id]}, :selected => @profile.software_info.license_info.id), :id => "license_info_version") %>
16 16 <br />
17 17  
18 18 <h4> <%= _("License link") %> </h4>
19 19 <% LicenseHelper.getListLicenses.each do | license | %>
20 20 <input type="hidden" id = "version_<%=license.id %>" value = "<%=license.link%>">
21 21 <% end %>
22   -
23 22 <a id = "version_link" href="<%= @profile.software_info.license_info.link %>" target="BLANK"> <%= @profile.software_info.license_info.link %> </a>
24 23 </div>
25 24  
... ...
views/mpog_software_plugin_myprofile/new_software.html.erb
... ... @@ -45,7 +45,7 @@
45 45 <%= fields_for @license_info do |lcv| %>
46 46 <div class="formfieldline">
47 47 <h4> <%= lcv.label _("License Version: ") %> </h4>
48   - <%= lcv.select(:version, LicenseInfo.all.map {|l| [l.version, l.version]}, {:selected=>1}, :onchange => "get_license_link('license_info_version')") %>
  48 + <%= lcv.select(:version, LicenseInfo.all.map {|l| [l.version, l.id]}, {:selected => 1}) %>
49 49  
50 50 <h4> <%= _("License link") %> </h4>
51 51 <% LicenseHelper.getListLicenses.each do | license | %>
... ...