Commit a8b2d25b722302f2f6844bdde2f16cb245930ca9
Exists in
master
and in
5 other branches
Merge branch 'general_plugin_fix'
Showing
14 changed files
with
184 additions
and
114 deletions
Show diff stats
controllers/software_communities_plugin_myprofile_controller.rb
... | ... | @@ -27,6 +27,7 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController |
27 | 27 | end |
28 | 28 | |
29 | 29 | control_software_creation |
30 | + update_new_software_errors | |
30 | 31 | end |
31 | 32 | |
32 | 33 | def search_offerers |
... | ... | @@ -60,6 +61,7 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController |
60 | 61 | session[:notice] = _('Software updated successfully') |
61 | 62 | end |
62 | 63 | rescue ActiveRecord::RecordInvalid => invalid |
64 | + update_new_software_errors | |
63 | 65 | session[:notice] = _('Could not update software') |
64 | 66 | end |
65 | 67 | end |
... | ... | @@ -75,9 +77,9 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController |
75 | 77 | |
76 | 78 | def add_software_erros |
77 | 79 | @errors = [] |
78 | - @errors |= @community.errors.full_messages | |
79 | - @errors |= @software_info.errors.full_messages | |
80 | - @errors |= @license_info.errors.full_messages | |
80 | + @errors |= @community.errors.full_messages if @community | |
81 | + @errors |= @software_info.errors.full_messages if @software_info | |
82 | + @errors |= @license_info.errors.full_messages if @license_info | |
81 | 83 | end |
82 | 84 | |
83 | 85 | def control_software_creation |
... | ... | @@ -217,4 +219,20 @@ class SoftwareCommunitiesPluginMyprofileController < MyProfileController |
217 | 219 | end |
218 | 220 | end |
219 | 221 | end |
222 | + | |
223 | + def update_new_software_errors | |
224 | + if request.post? | |
225 | + @community.valid? if @community | |
226 | + @software_info.valid? if @software_info | |
227 | + @license_info.valid? if @license_info | |
228 | + add_software_erros | |
229 | + end | |
230 | + | |
231 | + | |
232 | + @error_community_name = @community.errors.include?(:name) ? "highlight-error" : "" if @community | |
233 | + @error_software_acronym = @software_info.errors.include?(:acronym) ? "highlight-error" : "" if @software_info | |
234 | + @error_software_domain = @community.errors.include?(:identifier) ? "highlight-error" : "" if @community | |
235 | + @error_software_finality = @software_info.errors.include?(:finality) ? "highlight-error" : "" if @software_info | |
236 | + @error_software_license = @license_info.errors.include?(:version) ? "highlight-error" : "" if @license_info | |
237 | + end | |
220 | 238 | end | ... | ... |
lib/software_communities_plugin.rb
... | ... | @@ -128,6 +128,7 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin |
128 | 128 | views/complete-registration.js |
129 | 129 | views/search-software-catalog.js |
130 | 130 | views/profile-tabs-software.js |
131 | + views/new-community.js | |
131 | 132 | blocks/software-download.js |
132 | 133 | initializer.js |
133 | 134 | app.js | ... | ... |
public/initializer.js
public/style.css
... | ... | @@ -0,0 +1,28 @@ |
1 | +modulejs.define("NewCommunity", ['jquery'], function($) { | |
2 | + | |
3 | + function replace_mandatory_message() { | |
4 | + $(".required-field").first() | |
5 | + .replaceWith("<span class='required-field'> Os campos em destaque<label class='pseudoformlabel'> (*)</label> são obrigatórios. </span>"); | |
6 | + } | |
7 | + | |
8 | + function remove_image_builder_text() { | |
9 | + $("label:contains('Image builder')").hide(); | |
10 | + } | |
11 | + | |
12 | + function hide_organization_template_fields(){ | |
13 | + $('#template-options').hide(); | |
14 | + } | |
15 | + | |
16 | + return { | |
17 | + | |
18 | + isCurrentPage: function() { | |
19 | + return true; | |
20 | + }, | |
21 | + | |
22 | + init: function() { | |
23 | + replace_mandatory_message(); | |
24 | + remove_image_builder_text(); | |
25 | + hide_organization_template_fields(); | |
26 | + } | |
27 | + } | |
28 | +}) | ... | ... |
public/views/new-software.js
1 | -modulejs.define('NewSoftware', ['jquery', 'NoosferoRoot', 'AutoComplete'], function($, NoosferoRoot, AutoComplete) { | |
1 | +modulejs.define('NewSoftware', ['jquery', 'NoosferoRoot', 'AutoComplete', 'NewCommunity'], function($, NoosferoRoot, AutoComplete, Community) { | |
2 | 2 | 'use strict'; |
3 | 3 | |
4 | 4 | var AJAX_URL = { |
... | ... | @@ -61,6 +61,7 @@ modulejs.define('NewSoftware', ['jquery', 'NoosferoRoot', 'AutoComplete'], funct |
61 | 61 | |
62 | 62 | init: function() { |
63 | 63 | license_info_autocomplete(); |
64 | + Community.init(); | |
64 | 65 | |
65 | 66 | $("#community_name_id").blur(replace_domain_and_repository_link); |
66 | 67 | } | ... | ... |
views/blocks/download.html.erb
... | ... | @@ -7,8 +7,10 @@ |
7 | 7 | <% block.downloads.each_with_index do |download, index| %> |
8 | 8 | <div id="download-info-<%=(index+1)%>"> |
9 | 9 | <div id="version01"> |
10 | - <%= link_to _(""), download[:link], {:id => "image-download", :title => "Baixar o software"} %> | |
11 | - <%= link_to _(download[:size]), download[:link], {:id => "size-download", :title => "Baixar o software"} %> | |
10 | + <%= link_to download[:link], title: _("Download the software"), download: block.owner.name do %> | |
11 | + <span id="image-download"></span> | |
12 | + <span id="size-download"><%= download[:size] %></span> | |
13 | + <% end %> | |
12 | 14 | </div> |
13 | 15 | <div id="info-software-download"> |
14 | 16 | <span class="download-name"><%= _("#{download[:name]}") %></span> | ... | ... |
views/blocks/repository.html.erb
views/profile/_software_tab.html.erb
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | <%= content_tag('tr', content_tag('td', _("Internacionalizable:")) + content_tag('td', profile.software_info.intern ? _("Yes") : _("No"))) %> |
12 | 12 | <%= display_mpog_field(_('Operating Platform:'), profile.software_info, :operating_platform, true) %> |
13 | 13 | <%= display_mpog_field(_('Demonstration URL:'), profile.software_info, :demonstration_url, true) %> |
14 | - <%= display_mpog_field(_('Acronym:'), profile.software_info, :acronym, true) %> | |
14 | + <%= display_mpog_field(_('Short Name:'), profile.software_info, :acronym, true) %> | |
15 | 15 | <%= display_mpog_field(_('Objectives:'), profile.software_info, :objectives, true) %> |
16 | 16 | <%= display_mpog_field(_('Features:'), profile.software_info, :features, true) %> |
17 | 17 | ... | ... |
views/profile_editor/edit_software_community.html.erb
1 | + | |
1 | 2 | <%= render :partial => 'first_edit_software_community_extras', :locals => {:class_step_one => "another-step", :class_step_two => "current-step"} if @first_edit %> |
2 | 3 | |
3 | 4 | <h1><%= _('Configure Software Community') %></h1> |
... | ... | @@ -13,7 +14,7 @@ |
13 | 14 | |
14 | 15 | <%= labelled_form_for :profile_data, :html => { :id => 'profile-data', :multipart => true } do |f| %> |
15 | 16 | |
16 | - <% if user.has_permission?('manage_environment_templates', profile.environment) %> | |
17 | + <% if environment.admins.include?(user) %> | |
17 | 18 | <div id="profile-is-template"> |
18 | 19 | <%= labelled_check_box(_('This profile is a template'), 'profile_data[is_template]', true, @profile.is_template) %> |
19 | 20 | </div> |
... | ... | @@ -62,23 +63,24 @@ |
62 | 63 | end.join("\n") |
63 | 64 | %> |
64 | 65 | |
65 | - <%= select_categories(:profile_data, _('Select the categories of your interest'), 2) %> | |
66 | + <%= select_categories(:profile_data, _('Software Categories'), 2) %> | |
66 | 67 | |
67 | 68 | <% button_bar do %> |
68 | 69 | <%= submit_button('save', _('Save'), :cancel => {:action => 'index'}) %> |
69 | - <%= button(:back, _('Back to control panel'), :controller => 'profile_editor') %> | |
70 | + | |
71 | + <% unless @first_edit %> | |
72 | + <%= button(:back, _('Back to control panel'), :controller => 'profile_editor') %> | |
73 | + <% end %> | |
70 | 74 | <% end %> |
71 | 75 | |
72 | - <% if user && user.has_permission?('destroy_profile', profile) %> | |
76 | + <% if user && user.has_permission?('destroy_profile', profile) && !@first_edit %> | |
73 | 77 | <% button_bar(:id => 'delete-profile') do %> |
74 | - <%= button(:remove, _('Delete profile'), {:action => :destroy_profile}) %> | |
75 | - | |
78 | + <%= button(:remove, _('Delete software and community'), {:action => :destroy_profile}) %> | |
76 | 79 | <% if environment.admins.include?(current_person) %> |
77 | - | |
78 | 80 | <% if profile.visible? %> |
79 | - <%= button(:remove, _('Deactivate profile'), {:action => :deactivate_profile, :id=>profile.id}, :id=>'deactivate_profile_button', :data => {:confirm=>_("Are you sure you want to deactivate this profile?")}) %> | |
81 | + <%= button(:remove, _('Deactivate software and community'), {:action => :deactivate_profile, :id=>profile.id}, :id=>'deactivate_profile_button', :data => {:confirm=>_("Are you sure you want to deactivate this profile?")}) %> | |
80 | 82 | <% else %> |
81 | - <%= button(:add, _('Activate profile'), {:action => :activate_profile, :id=>profile.id}, :data => {:confirm=>_("Are you sure you want to deactivate this profile?")}) %> | |
83 | + <%= button(:add, _('Activate software and community'), {:action => :activate_profile, :id=>profile.id}, :data => {:confirm=>_("Are you sure you want to deactivate this profile?")}) %> | |
82 | 84 | <% end %> |
83 | 85 | <% end %> |
84 | 86 | <% end %> | ... | ... |
views/software_communities_plugin_myprofile/_main_software_editor_extras.html.erb
1 | -<h1><%= @profile.software_info.name + _(' Information') %></h1> | |
2 | 1 | |
3 | -<h3> <%= _("Name") %> </h3> | |
4 | -<div id="name"> | |
5 | - <%= text_field_tag("community[name]", @profile.name) %> | |
2 | +<div class= <%= @error_community_name %> > | |
3 | + <%= label_tag("community[name]", _('Name'), {:class => 'formlabel mandatory'}) %> | |
4 | + <%= text_field_tag("community[name]", @profile.name, :id => 'community_name_id') %> | |
6 | 5 | </div> |
7 | 6 | |
8 | -<h3> <%= _("Acronym") %> </h3> | |
9 | -<div id="acronym"> | |
10 | - <%= text_field_tag("software[acronym]", @profile.software_info.acronym, :maxlength=>"10") %> | |
7 | +<div class= <%= @error_software_acronym %> > | |
8 | + <%= label_tag("software[acronym]", _('Short Name'), {:class => 'formlabel mandatory'}) %> | |
9 | + <%= text_field_tag("software[acronym]", @profile.software_info.acronym, :id => 'software_acronym_id', :maxlength=>"10") %> | |
11 | 10 | </div> |
12 | 11 | |
13 | -<h3> <%= _("Finality") %> </h3> | |
14 | -<div id="finality"> | |
15 | - <%= text_area_tag "software[finality]", @profile.software_info.finality, :placeholder => _("What is the software for?"), :maxlength => 120 %> | |
12 | +<div class= <%= @error_software_finality %> > | |
13 | + <div id="finality" class="formfield type-text"> | |
14 | + <%= label_tag("software[finality]", _('Finality'), {:class => 'formlabel mandatory'}) %> | |
15 | + <%= text_area_tag "software[finality]", @profile.software_info.finality, :placeholder => _("What is the software for?"), :maxlength => 120 %> | |
16 | + </div> | |
16 | 17 | </div> |
17 | 18 | |
18 | -<div id="profile_change_picture_title"> | |
19 | - <h3><%= _('Software Logo') %></h3> | |
19 | +<div id="profile_change_picture_title" class="formlabel"> | |
20 | + <label> | |
21 | + <%= _('Software Logo') %> | |
22 | + </label> | |
20 | 23 | </div> |
21 | 24 | <div id="profile_change_picture"> |
22 | 25 | <%= f.fields_for :image_builder, @profile.image do |i| %> |
... | ... | @@ -24,20 +27,21 @@ |
24 | 27 | <% end %> |
25 | 28 | </div> |
26 | 29 | |
27 | -<h3><%= _("License Version: ") %></h3> | |
28 | -<div id='licenses'> | |
29 | - <%= render :partial => "license_info_fields", :locals => { | |
30 | - :license_version => @license_version, | |
31 | - :license_id => @license_id, | |
32 | - :another_version => @another_license_version, | |
33 | - :another_link => @another_license_link | |
34 | - } | |
35 | - %> | |
30 | +<div class= <%= @error_software_license %> > | |
31 | + <div id="profile_change_picture_title" class="formlabel formfieldline"> | |
32 | + <label class="formlabel mandatory"> | |
33 | + <%= _("License Version: ") %> | |
34 | + </label> | |
35 | + <%= render :partial => "license_info_fields", :locals => { | |
36 | + :license_version => @license_version, | |
37 | + :license_id => @license_id, | |
38 | + :another_version => @another_license_version, | |
39 | + :another_link => @another_license_link | |
40 | + } %> | |
41 | + </div> | |
36 | 42 | </div> |
37 | 43 | |
38 | -<h3> <%= _("Link to Repository") %> </h3> | |
39 | -<div id='repository_link'> | |
40 | - <%= text_field_tag("software[repository_link]", @profile.software_info.repository_link, :class => "improve_input_size") %> | |
44 | +<div class="formfieldline formfield type-text"> | |
45 | + <%= label_tag("software[repository_link]", _('Link to Repository: '), {:class => 'formlabel'}) %> | |
46 | + <%= text_field_tag("software[repository_link]", @profile.software_info.repository_link, :class => "improve_input_size", :id => "software-info-repository-link") %> | |
41 | 47 | </div> |
42 | - | |
43 | - | ... | ... |
views/software_communities_plugin_myprofile/_public_software_info.html.erb
1 | -<h1><%= _('Edit software') %></h1> | |
2 | - | |
3 | -<div class="formfieldline"> | |
4 | - <h4> <%= _("Operating Platform") %> </h4> | |
5 | - <%= text_area_tag "software[operating_platform]", @software_info.operating_platform, :cols => 40, :rows => 5%> | |
6 | -</div> | |
7 | - | |
8 | -<div class="formfieldline"> | |
9 | - <h4> <%= _("Features") %> </h4> | |
10 | - <%= text_area_tag "software[features]", @software_info.features, :maxlength=>"4000", :cols => 40, :rows => 5%> | |
11 | -</div> | |
12 | - | |
13 | -<div id='libraries_fields'> | |
14 | - <h4> <%= _("Libraries") %> </h4> | |
15 | - | |
16 | - <%= render :partial => 'library_fields', :locals => {:object_name => 'community', :profile => @community, :libraries => @list_libraries } %> | |
17 | -</div> | |
18 | -<br /> | |
19 | - | |
20 | -<div id='operating_system_fields'> | |
21 | - <h4> <%= _("Operating Systems") %> </h4> | |
22 | - | |
23 | - <%= render :partial => 'operating_system_fields', :locals => {:object_name => 'community', :profile => @community, :operating_systems_fields => @list_operating_systems} %> | |
24 | -</div> | |
25 | -<br /> | |
26 | - | |
27 | -<br /> | |
28 | -<div id='programming_languages_fields'> | |
29 | - <h4> <%= _("Programming languages") %> </h4> | |
30 | - | |
31 | - <%= render :partial => 'language_fields', :locals => { :object_name => 'community', :profile => @community, :languages => @list_languages } %> | |
32 | -</div> | |
33 | - | |
34 | -<br /> | |
35 | -<div id='database_fields'> | |
36 | - <h4> <%= _("Databases") %> </h4> | |
37 | - | |
38 | - <%= render :partial => 'database_fields', :locals => {:object_name => 'community', :profile => @community, :database => @list_databases } %> | |
39 | -</div> | |
40 | - | |
41 | -<div id = "demonstration_url"> | |
42 | - <h4> <%= _("Demonstration url") %> </h4> | |
43 | - <%= text_field_tag("software[demonstration_url]", @software_info.demonstration_url) %> | |
44 | -</div> | |
45 | - | |
46 | -<br> | |
47 | - | |
48 | 1 | <div id = "public_software"> |
49 | 2 | <% if @disabled_public_software_field == true %> |
50 | 3 | <%= check_box_tag("software[public_software]", "true", @software_info.public_software?, :disabled => "disabled") %> |
... | ... | @@ -101,3 +54,49 @@ |
101 | 54 | </div> |
102 | 55 | </div> |
103 | 56 | </div> |
57 | + | |
58 | +<div class="formfieldline"> | |
59 | + <h4> <%= _("Operating Platform") %> </h4> | |
60 | + <%= text_area_tag "software[operating_platform]", @software_info.operating_platform, :cols => 40, :rows => 5%> | |
61 | +</div> | |
62 | + | |
63 | +<div class="formfieldline"> | |
64 | + <h4> <%= _("Features") %> </h4> | |
65 | + <%= text_area_tag "software[features]", @software_info.features, :maxlength=>"4000", :cols => 40, :rows => 5%> | |
66 | +</div> | |
67 | + | |
68 | +<div id = "demonstration_url"> | |
69 | + <h4> <%= _("Demonstration url") %> </h4> | |
70 | + <%= text_field_tag("software[demonstration_url]", @software_info.demonstration_url) %> | |
71 | +</div> | |
72 | + | |
73 | +<div id='libraries_fields'> | |
74 | + <h4> <%= _("Libraries") %> </h4> | |
75 | + | |
76 | + <%= render :partial => 'library_fields', :locals => {:object_name => 'community', :profile => @community, :libraries => @list_libraries } %> | |
77 | +</div> | |
78 | + | |
79 | +<br /> | |
80 | + | |
81 | +<div id='operating_system_fields'> | |
82 | + <h4> <%= _("Operating Systems") %> </h4> | |
83 | + | |
84 | + <%= render :partial => 'operating_system_fields', :locals => {:object_name => 'community', :profile => @community, :operating_systems_fields => @list_operating_systems} %> | |
85 | +</div> | |
86 | +<br /> | |
87 | + | |
88 | +<br /> | |
89 | +<div id='programming_languages_fields'> | |
90 | + <h4> <%= _("Programming languages") %> </h4> | |
91 | + | |
92 | + <%= render :partial => 'language_fields', :locals => { :object_name => 'community', :profile => @community, :languages => @list_languages } %> | |
93 | +</div> | |
94 | + | |
95 | +<br /> | |
96 | +<div id='database_fields'> | |
97 | + <h4> <%= _("Databases") %> </h4> | |
98 | + | |
99 | + <%= render :partial => 'database_fields', :locals => {:object_name => 'community', :profile => @community, :database => @list_databases } %> | |
100 | +</div> | |
101 | + | |
102 | +<br> | ... | ... |
views/software_communities_plugin_myprofile/edit_software.html.erb
1 | +<h1><%= _('Edit Software') %></h1> | |
2 | + | |
1 | 3 | <% tabs = [] %> |
2 | 4 | |
3 | 5 | <%= error_messages_for :software_info, :community %> |
4 | 6 | |
5 | 7 | <%= labelled_form_for :community, :html => { :multipart => true, :id => 'edit-form' } do |f| %> |
6 | 8 | |
7 | - <% tabs << {:title => _("Software"), :id => 'basic-info', | |
9 | + <% tabs << {:title => _("Main Information"), :id => 'basic-info', | |
8 | 10 | :content => (render :partial => 'main_software_editor_extras', :locals => {:f => f})} %> |
9 | 11 | |
10 | 12 | <% tabs << {:title => _("Specifications"), :id => 'especific-info', | ... | ... |
views/software_communities_plugin_myprofile/new_software.html.erb
... | ... | @@ -33,25 +33,31 @@ |
33 | 33 | |
34 | 34 | <%= required_fields_message %> |
35 | 35 | |
36 | - <%= label("name", _('Name'), {:class => 'formlabel mandatory'}) %> | |
37 | - <%= required text_field(:community, :name, :size => 30, :maxlength => 100, :id => 'community_name_id') %> | |
36 | + <div class= <%= @error_community_name %> > | |
37 | + <%= label("name", _('Name'), {:class => 'formlabel mandatory'}) %> | |
38 | + <%= required text_field(:community, :name, :size => 30, :maxlength => 100, :id => 'community_name_id') %> | |
39 | + </div> | |
38 | 40 | |
39 | 41 | <br> |
40 | 42 | <br> |
41 | 43 | |
42 | - <%= label("domain", _('Domain'), {:class => "formlabel mandatory"}) %> | |
43 | - <div id='software-name-field' class='formfield'> | |
44 | + <div class= <%= @error_software_domain %> > | |
45 | + <%= label("domain", _('Domain'), {:class => "formlabel mandatory"}) %> | |
46 | + <div id='software-name-field' class='formfield'> | |
44 | 47 | |
45 | - <span id='software-hostname'><%= environment.default_hostname %>/</span> | |
46 | - <%= required text_field(:community, :identifier, :size => 30, :maxlength => 100, :id => 'community-identifier') %> | |
48 | + <span id='software-hostname'><%= environment.default_hostname %>/</span> | |
49 | + <%= required text_field(:community, :identifier, :size => 30, :maxlength => 100, :id => 'community-identifier') %> | |
50 | + </div> | |
47 | 51 | </div> |
48 | 52 | |
49 | - <%= fields_for @software_info do |swf| %> | |
50 | - <div id="finality" class="formfield type-text"> | |
51 | - <%= swf.label("finality" ,_("Finality"), :class=>"formlabel mandatory") %> | |
52 | - <%= required swf.text_area(:finality, :placeholder => _("What is the software for?"), :maxlength => 120) %> | |
53 | - </div> | |
54 | - <% end %> | |
53 | + <div class= <%= @error_software_finality %> > | |
54 | + <%= fields_for @software_info do |swf| %> | |
55 | + <div id="finality" class="formfield type-text"> | |
56 | + <%= swf.label("finality" ,_("Finality"), :class=>"formlabel mandatory") %> | |
57 | + <%= required swf.text_area(:finality, :placeholder => _("What is the software for?"), :maxlength => 120) %> | |
58 | + </div> | |
59 | + <% end %> | |
60 | + </div> | |
55 | 61 | |
56 | 62 | <div id="profile_change_picture_title" class="formlabel"> |
57 | 63 | <label> |
... | ... | @@ -64,16 +70,18 @@ |
64 | 70 | <% end %> |
65 | 71 | </div> |
66 | 72 | |
67 | - <div id="profile_change_picture_title" class="formlabel formfieldline"> | |
68 | - <label class="formlabel mandatory"> | |
69 | - <%= _("License Version: ") %> | |
70 | - </label> | |
71 | - <%= render :partial => "license_info_fields", :locals => { | |
72 | - :license_version => "", | |
73 | - :license_id => "", | |
74 | - :another_version=>"", | |
75 | - :another_link=>"" | |
76 | - } %> | |
73 | + <div class= <%= @error_software_license %> > | |
74 | + <div id="profile_change_picture_title" class="formlabel formfieldline"> | |
75 | + <label class="formlabel mandatory"> | |
76 | + <%= _("License Version: ") %> | |
77 | + </label> | |
78 | + <%= render :partial => "license_info_fields", :locals => { | |
79 | + :license_version => "", | |
80 | + :license_id => "", | |
81 | + :another_version=>"", | |
82 | + :another_link=>"" | |
83 | + } %> | |
84 | + </div> | |
77 | 85 | </div> |
78 | 86 | |
79 | 87 | <%= fields_for @software_info do |swf| %> | ... | ... |