Commit c67611254034f27809fc8a7637a4b6b87bca3fc4

Authored by Joenio Costa
Committed by Antonio Terceiro
1 parent 44ccfb3f

More improvements to agenda

 - Button to create new event
 - Displaying header and footer even without side boxes
 - Display links to events in bold
 - Fixing previous and next month boxes on IE
 - Display environment name in header of global agenda

(ActionItem1255)
app/helpers/boxes_helper.rb
... ... @@ -4,11 +4,13 @@ module BoxesHelper
4 4 if @controller.send(:boxes_editor?) && @controller.send(:uses_design_blocks?)
5 5 content + display_boxes_editor(@controller.boxes_holder)
6 6 else
  7 + maybe_display_custom_element(@controller.boxes_holder, :custom_header_expanded, :id => 'profile-header') +
7 8 if @controller.send(:uses_design_blocks?)
8 9 display_boxes(@controller.boxes_holder, content)
9 10 else
10 11 content_tag('div', content, :class => 'no-boxes')
11   - end
  12 + end +
  13 + maybe_display_custom_element(@controller.boxes_holder, :custom_footer_expanded, :id => 'profile-footer')
12 14 end
13 15 end
14 16  
... ... @@ -35,9 +37,7 @@ module BoxesHelper
35 37 content = boxes.reverse.map { |item| display_box(item, main_content) }.join("\n")
36 38 content = main_content if (content.blank?)
37 39  
38   - maybe_display_custom_element(holder, :custom_header_expanded, :id => 'profile-header') +
39   - content_tag('div', content, :class => 'boxes', :id => 'boxes' ) +
40   - maybe_display_custom_element(holder, :custom_footer_expanded, :id => 'profile-footer')
  40 + content_tag('div', content, :class => 'boxes', :id => 'boxes' )
41 41 end
42 42  
43 43 def maybe_display_custom_element(holder, element, options = {})
... ...
app/views/events/events.rhtml
1   -<%= button :back, _('Back to %s') % profile.name, profile.public_profile_url %>
2   -
3   -<h1><%= _("%s's events") % profile.name %></h1>
  1 +<h1>
  2 + <div id='toolbar'>
  3 + <%= button :back, _('Back to %s') % profile.name, profile.public_profile_url %>
  4 + <% if user && user.has_permission?('post_content', profile) %>
  5 + <%= button :new, _('New event'), myprofile_url(:controller => 'cms', :action => 'new', :type => 'Event') %>
  6 + <% end %>
  7 + </div>
  8 + <%= _("%s's events") % profile.name %>
  9 +</h1>
4 10  
5 11 <%= render :partial => 'agenda' %>
... ...
app/views/search/events.rhtml
1 1 <h1>
  2 + <%= _("%s's events") % @environment.name %>
2 3 <% if @category %>
3   - <%= @category.name %>
  4 + :<small><%= @category.name %></small>
4 5 <% end %>
5 6 </h1>
6 7  
... ...
features/events.feature
... ... @@ -149,3 +149,24 @@ Feature: events
149 149 Scenario: warn when there is no events
150 150 When I am on /profile/josesilva/events/2020/12/1
151 151 Then I should see "No events for this date"
  152 +
  153 + Scenario: provide button to create new event
  154 + Given I am logged in as "josesilva"
  155 + When I am on /profile/josesilva/events/2020/12/1
  156 + Then I should see "New event" link
  157 +
  158 + Scenario: not provide button to create new event if I am not logged
  159 + When I am on /profile/josesilva/events/2020/12/1
  160 + Then I should not see "New event" link
  161 +
  162 + Scenario: not provide button to create new event if I haven't permission
  163 + Given the following users
  164 + | login |
  165 + | fudencio |
  166 + Given I am logged in as "josesilva"
  167 + When I am on /profile/fudencio/events/2020/12/1
  168 + Then I should not see "New events" link
  169 +
  170 + Scenario: display environment name in global agenda
  171 + When I am on /assets/events
  172 + Then I should see "Colivre.net's events"
... ...
public/stylesheets/controller_events.css
... ... @@ -28,6 +28,9 @@
28 28 #agenda .agenda-calendar .calendar-day-out span {
29 29 display: none;
30 30 }
  31 +#agenda .agenda-calendar .calendar-day a {
  32 + font-weight: bold;
  33 +}
31 34 #agenda .agenda-calendar td {
32 35 text-align: center;
33 36 padding: 0px;
... ... @@ -44,15 +47,27 @@
44 47 float: left;
45 48 width: 50%;
46 49 }
  50 +.msie #agenda .agenda-calendar .previous-month,
  51 +.msie #agenda .agenda-calendar .next-month {
  52 + width: 49%;
  53 +}
47 54 #agenda .agenda-calendar .previous-month {
48 55 }
49 56 #agenda .agenda-calendar .next-month {
50 57 border-left: 1px solid #BFC2BC;
51 58 }
52 59 #agenda .selected {
53   - background: #ff9;
  60 + background: gray;
  61 + font-weight: bold;
54 62 font-style: normal;
55 63 }
  64 +#agenda .selected a,
  65 +#agenda .selected span {
  66 + color: white;
  67 +}
  68 +#agenda .calendar-day-out.selected {
  69 + background: none;
  70 +}
56 71 #agenda td {
57 72 vertical-align: middle;
58 73 }
... ... @@ -78,11 +93,19 @@
78 93 height: 90%;
79 94 }
80 95  
81   -body.noosfero #content .no-boxes a.button.icon-back {
82   - float: left;
  96 +#content .no-boxes h1 #toolbar {
83 97 position: absolute;
  98 + left: 0;
  99 + font-variant: normal;
  100 + font-weight: normal;
  101 +}
  102 +#content .no-boxes h1 {
  103 + position: relative;
  104 +}
  105 +
  106 +#content .no-boxes h1 #toolbar a.button {
84 107 border: none;
85   - opacity: 0.5;
  108 + opacity: 0.6;
86 109 }
87 110  
88 111 #agenda #events-of-the-day .select-a-day {
... ...
test/unit/boxes_helper_test.rb
... ... @@ -5,13 +5,20 @@ class BoxesHelperTest &lt; Test::Unit::TestCase
5 5 include BoxesHelper
6 6 include ActionView::Helpers::TagHelper
7 7  
  8 + def setup
  9 + @controller = mock
  10 + @controller.stubs(:boxes_editor?).returns(false)
  11 + @controller.stubs(:uses_design_blocks?).returns(true)
  12 + end
  13 +
8 14 should 'include profile-specific header' do
9 15 holder = mock
10 16 holder.stubs(:boxes).returns([])
11 17 holder.stubs(:boxes_limit).returns(0)
12 18 holder.stubs(:custom_header_expanded).returns('my custom header')
  19 + @controller.stubs(:boxes_holder).returns(holder)
13 20  
14   - assert_tag_in_string display_boxes(holder, 'main content'), :tag => "div", :attributes => { :id => 'profile-header' }, :content => 'my custom header'
  21 + assert_tag_in_string insert_boxes('main content'), :tag => "div", :attributes => { :id => 'profile-header' }, :content => 'my custom header'
15 22 end
16 23  
17 24 should 'include profile-specific footer' do
... ... @@ -19,8 +26,9 @@ class BoxesHelperTest &lt; Test::Unit::TestCase
19 26 holder.stubs(:boxes).returns([])
20 27 holder.stubs(:boxes_limit).returns(0)
21 28 holder.stubs(:custom_footer_expanded).returns('my custom footer')
  29 + @controller.stubs(:boxes_holder).returns(holder)
22 30  
23   - assert_tag_in_string display_boxes(holder, 'main content'), :tag => "div", :attributes => { :id => 'profile-footer' }, :content => 'my custom footer'
  31 + assert_tag_in_string insert_boxes('main content'), :tag => "div", :attributes => { :id => 'profile-footer' }, :content => 'my custom footer'
24 32 end
25 33  
26 34 def create_user_with_blocks
... ... @@ -55,4 +63,26 @@ class BoxesHelperTest &lt; Test::Unit::TestCase
55 63 display_box_content(box, '')
56 64 end
57 65  
  66 + should 'include profile-specific header without side boxes' do
  67 + @controller.stubs(:uses_design_blocks?).returns(false)
  68 + holder = mock
  69 + holder.stubs(:boxes).returns([])
  70 + holder.stubs(:boxes_limit).returns(0)
  71 + holder.stubs(:custom_header_expanded).returns('my custom header')
  72 + @controller.stubs(:boxes_holder).returns(holder)
  73 +
  74 + assert_tag_in_string insert_boxes('main content'), :tag => "div", :attributes => { :id => 'profile-header' }, :content => 'my custom header'
  75 + end
  76 +
  77 + should 'include profile-specific footer without side boxes' do
  78 + @controller.stubs(:uses_design_blocks?).returns(false)
  79 + holder = mock
  80 + holder.stubs(:boxes).returns([])
  81 + holder.stubs(:boxes_limit).returns(0)
  82 + holder.stubs(:custom_footer_expanded).returns('my custom footer')
  83 + @controller.stubs(:boxes_holder).returns(holder)
  84 +
  85 + assert_tag_in_string insert_boxes('main content'), :tag => "div", :attributes => { :id => 'profile-footer' }, :content => 'my custom footer'
  86 + end
  87 +
58 88 end
... ...