Commit 30e39dd95746ea2fb303e5730e3e975708b77b22
Committed by
David Silva
1 parent
d603d8ba
Exists in
master
and in
5 other branches
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>
Showing
4 changed files
with
7 additions
and
9 deletions
Show diff stats
controllers/mpog_software_plugin_myprofile_controller.rb
@@ -22,9 +22,7 @@ class MpogSoftwarePluginMyprofileController < MyProfileController | @@ -22,9 +22,7 @@ class MpogSoftwarePluginMyprofileController < MyProfileController | ||
22 | @license_info = if params[:license_info].nil? | 22 | @license_info = if params[:license_info].nil? |
23 | LicenseInfo.new | 23 | LicenseInfo.new |
24 | else | 24 | else |
25 | - LicenseInfo.find(:first, | ||
26 | - :conditions => ["version = ?", | ||
27 | - "#{params[:license_info][:version]}"]) | 25 | + LicenseInfo.find(params[:license_info][:version]) |
28 | end | 26 | end |
29 | 27 | ||
30 | control_software_creation | 28 | control_software_creation |
public/mpog-software-validations.js
@@ -89,9 +89,8 @@ | @@ -89,9 +89,8 @@ | ||
89 | Element.insert(element_id, {bottom: content}); | 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 | jQuery("#version_link") | 95 | jQuery("#version_link") |
97 | .attr("href", link) | 96 | .attr("href", link) |
@@ -208,5 +207,7 @@ | @@ -208,5 +207,7 @@ | ||
208 | jQuery("#software_public_software").click(hide_show_public_software_fields); | 207 | jQuery("#software_public_software").click(hide_show_public_software_fields); |
209 | 208 | ||
210 | replace_software_creations_step(); | 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,14 +12,13 @@ | ||
12 | 12 | ||
13 | <h3> <%= _("Licenses") %> </h3> | 13 | <h3> <%= _("Licenses") %> </h3> |
14 | <div id='licenses'> | 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 | <br /> | 16 | <br /> |
17 | 17 | ||
18 | <h4> <%= _("License link") %> </h4> | 18 | <h4> <%= _("License link") %> </h4> |
19 | <% LicenseHelper.getListLicenses.each do | license | %> | 19 | <% LicenseHelper.getListLicenses.each do | license | %> |
20 | <input type="hidden" id = "version_<%=license.id %>" value = "<%=license.link%>"> | 20 | <input type="hidden" id = "version_<%=license.id %>" value = "<%=license.link%>"> |
21 | <% end %> | 21 | <% end %> |
22 | - | ||
23 | <a id = "version_link" href="<%= @profile.software_info.license_info.link %>" target="BLANK"> <%= @profile.software_info.license_info.link %> </a> | 22 | <a id = "version_link" href="<%= @profile.software_info.license_info.link %>" target="BLANK"> <%= @profile.software_info.license_info.link %> </a> |
24 | </div> | 23 | </div> |
25 | 24 |
views/mpog_software_plugin_myprofile/new_software.html.erb
@@ -45,7 +45,7 @@ | @@ -45,7 +45,7 @@ | ||
45 | <%= fields_for @license_info do |lcv| %> | 45 | <%= fields_for @license_info do |lcv| %> |
46 | <div class="formfieldline"> | 46 | <div class="formfieldline"> |
47 | <h4> <%= lcv.label _("License Version: ") %> </h4> | 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 | <h4> <%= _("License link") %> </h4> | 50 | <h4> <%= _("License link") %> </h4> |
51 | <% LicenseHelper.getListLicenses.each do | license | %> | 51 | <% LicenseHelper.getListLicenses.each do | license | %> |