Module: MeetingContentsHelper

Defined in:
app/helpers/meeting_contents_helper.rb

Overview

– copyright OpenProject is a project management system. Copyright © 2011-2013 the OpenProject Foundation (OPF)

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

See doc/COPYRIGHT.md for more details. ++

Instance Method Summary collapse

Instance Method Details

#can_edit_meeting_content?(content, content_type) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'app/helpers/meeting_contents_helper.rb', line 21

def can_edit_meeting_content?(content, content_type)
  authorize_for(content_type.pluralize, 'update') && content.editable?
end


48
49
50
51
52
53
54
55
# File 'app/helpers/meeting_contents_helper.rb', line 48

def close_meeting_agenda_link(content_type, meeting)
  case content_type
  when "meeting_agenda"
    link_to_if_authorized l(:label_meeting_close), {:controller => '/meeting_agendas', :action => 'close', :meeting_id => meeting}, :method => :put, :class => "icon icon-lock show-meeting_agenda"
  when "meeting_minutes"
    link_to_if_authorized l(:label_meeting_agenda_close), {:controller => '/meeting_agendas', :action => 'close', :meeting_id => meeting}, :method => :put, :class => "icon icon-lock show-meeting_minutes"
  end
end


42
43
44
45
46
# File 'app/helpers/meeting_contents_helper.rb', line 42

def meeting_agenda_toggle_status_link(content, content_type)
  content.meeting.agenda.present? && content.meeting.agenda.locked? ?
    open_meeting_agenda_link(content_type, content.meeting) :
    close_meeting_agenda_link(content_type, content.meeting)
end

#meeting_content_context_menu(content, content_type) ⇒ Object



33
34
35
36
37
38
39
40
# File 'app/helpers/meeting_contents_helper.rb', line 33

def meeting_content_context_menu(content, content_type)
  menu = []
  menu << meeting_agenda_toggle_status_link(content, content_type)
  menu << meeting_content_edit_link(content_type) if can_edit_meeting_content?(content, content_type)
  menu << meeting_content_history_link(content_type, content.meeting)
  menu << meeting_content_notify_link(content_type, content.meeting) if saved_meeting_content_text_present?(content)
  menu.join(" ")
end


65
66
67
# File 'app/helpers/meeting_contents_helper.rb', line 65

def meeting_content_edit_link(content_type)
  link_to l(:button_edit), "#", :class => "icon icon-edit show-#{content_type}", :accesskey => accesskey(:edit), :onclick => "$$('.edit-#{content_type}').invoke('show'); $$('.show-#{content_type}').invoke('hide'); return false;"
end


69
70
71
# File 'app/helpers/meeting_contents_helper.rb', line 69

def meeting_content_history_link(content_type, meeting)
  link_to_if_authorized l(:label_history), {:controller => '/' + content_type.pluralize, :action => 'history', :meeting_id => meeting}, :class => "icon icon-history show-#{content_type}"
end


73
74
75
# File 'app/helpers/meeting_contents_helper.rb', line 73

def meeting_content_notify_link(content_type, meeting)
  link_to_if_authorized l(:label_notify), {:controller => '/' + content_type.pluralize, :action => 'notify', :meeting_id => meeting}, :method => :put, :class => "icon icon-notification show-#{content_type}"
end


57
58
59
60
61
62
63
# File 'app/helpers/meeting_contents_helper.rb', line 57

def open_meeting_agenda_link(content_type, meeting)
  case content_type
  when "meeting_agenda"
    link_to_if_authorized l(:label_meeting_open), {:controller => '/meeting_agendas', :action => 'open', :meeting_id => meeting}, :method => :put, :class => 'icon icon-unlock show-meeting_agenda', :confirm => l(:text_meeting_agenda_open_are_you_sure)
  when "meeting_minutes"
  end
end

#saved_meeting_content_text_present?(content) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'app/helpers/meeting_contents_helper.rb', line 25

def saved_meeting_content_text_present?(content)
  !content.new_record? && content.text.present? && !content.text.empty?
end

#show_meeting_content_editor?(content, content_type) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'app/helpers/meeting_contents_helper.rb', line 29

def show_meeting_content_editor?(content, content_type)
  can_edit_meeting_content?(content, content_type) && (!saved_meeting_content_text_present?(content) || content.changed?)
end