Module | Sadmin::EventsHelper
In: | app/helpers/sadmin/events_helper.rb

### Methods

can_create_only_one_type_of_event? event_agenda_check_form_url event_can_change_schedule? event_confirmed_short_info event_coverage_info event_data4table_cell event_dates_with_links event_div_class_name event_link_text event_link_url event_publication_state_info event_published_info event_row_class event_state_info num_events_in_cell num_events_in_cell= one_datetime_with_link render_calendar_cell

### Public Instance methods

can_create_only_one_type_of_event?()

Indica si el usuairo puede crear sólo un tipo de eventos.

[Source]

         # File app/helpers/sadmin/events_helper.rb, line 234
    234:   def can_create_only_one_type_of_event?
    235:     current_user.permissions.count(:conditions => ["module=?", 'events']) == 1
    236:   end

event_agenda_check_form_url()

[Source]

         # File app/helpers/sadmin/events_helper.rb, line 197
    197:   def event_agenda_check_form_url
    198:     url_params = if params[:action].eql?('index')
    199:       {:action => 'calendar'}
    200:     else
    201:       {:action => params[:action]}
    202:     end
    203:     url_params[:day] = params[:day]
    204:     url_params.merge(:year => @year || Time.now.year, :month => @month || Time.now.month)
    205:   end

event_can_change_schedule?(evt)

Indica si el evento `evt` puede cambiar de agenda.

Si el usuario conectado tiene permiso para cambiar una agenda privada, puede cambiar la agenda de los eventos de las agendas a las que tiene acceso.

Los eventos compartidos pueden cambiar de agenda si el usuairo conectado tiene permiso para modificar alguna agenda privada.

[Source]

         # File app/helpers/sadmin/events_helper.rb, line 224
    224:   def event_can_change_schedule?(evt)
    225:     res = if evt.schedule_id
    226:       !current_user.editable_schedules.blank? && current_user.can_change_schedule?(evt.schedule_id)
    227:     else
    228:       evt.is_private? && !current_user.changable_schedules.blank?
    229:     end
    230:     res
    231:   end

event_confirmed_short_info(evt)

Devuelve un texto que indica si el evento está confirmado o no.

[Source]

         # File app/helpers/sadmin/events_helper.rb, line 131
    131:   def event_confirmed_short_info(evt)
    132:     txt = []
    133:
    134:     if !evt.confirmed?
    135:       txt << content_tag(:span, t('sadmin.events.pendiente_confirmar'), :class => "unpublished_notice")
    136:     else
    137:       txt << content_tag(:span, t('sadmin.events.si_confirmado'), :class => "published_notice")
    138:     end
    139:
    140:     txt
    141:   end

event_coverage_info(evt)

Devuelve la información sobre si Irekia cubre el evento y qué tipo de cobertura se dará.

[Source]

         # File app/helpers/sadmin/events_helper.rb, line 189
    189:   def event_coverage_info(evt)
    190:     cov = []
    191:     cov.push(t('documents.fotos')) if evt. irekia_coverage_photo?
    192:     cov.push(t('documents.video')) if evt. irekia_coverage_video?
    193:     cov.push(t('documents.audio')) if evt. irekia_coverage_audio?
    194:     cov.join(", ")
    195:   end

event_data4table_cell(evt, d, pos)

Devuelve los datos del evento que salen en una celda del calendario.

[Source]

        # File app/helpers/sadmin/events_helper.rb, line 49
    49:   def event_data4table_cell(evt, d, pos)
    50:     content_tag(:div, content_tag(:span,
    51:                                   link_to(event_link_text(evt, d), event_link_url(evt),
    52:                                           :day => d.mday , :month => d.month, :pos => pos, :class => "event_title" )),
    53:                                   :class => "one_event_link #{event_div_class_name(evt)} #{evt.state}" )
    54:   end

event_dates_with_links(evt)

Devuelve las fechas del evento como enlaces a la lista de eventos del día.

[Source]

         # File app/helpers/sadmin/events_helper.rb, line 171
    171:   def event_dates_with_links(evt)
    172:     start_date = evt.starts_at.to_date
    173:     end_date = evt.ends_at.to_date
    174:
    175:     txt = one_datetime_with_link(evt.starts_at)
    176:
    177:     if evt.starts_at.to_date.eql?(evt.ends_at.to_date)
    178:       # Same day, different hours
    179:       txt = txt + " - #{evt.ends_at.strftime('%H:%M')}" if evt.ends_at.strftime('%H%M') != "0000"
    180:     else
    181:       # Different dates
    182:       txt = txt + " -- " +one_datetime_with_link(evt.ends_at)
    183:     end
    184:
    185:     txt
    186:   end

event_div_class_name(evt)

DOM clases para el div con los datos del evento.

[Source]

        # File app/helpers/sadmin/events_helper.rb, line 25
    25:   def event_div_class_name(evt)
    26:     cn = []
    27:     cn.push("agencia_event") if evt.show_in_agencia
    28:     cn.push("irekia_event") if evt.show_in_irekia
    29:     cn.push("private_event") if evt.is_private?
    30:     cn.push("deleted") if evt.deleted?
    31:     if evt.respond_to?('schedule')
    32:       cn.push("schedule")
    33:       cn.push(evt.schedule.dom_element_class)
    34:     end
    35:
    36:     cn.join(' ')
    37:   end

event_link_text(evt, d)

Texto para el enlace a la página del evento.

[Source]

        # File app/helpers/sadmin/events_helper.rb, line 14
    14:   def event_link_text(evt, d)
    15:     txt = ""
    16:     if d.to_date.eql?(evt.starts_at.to_date)
    17:       txt += content_tag(:span, I18n.localize(evt.starts_at, :format => :hour), :class => "event_hour") unless evt.starts_at.hour.eql?(0)
    18:     end
    19:
    20:     dept_no = evt.organization.internal_id.nil? ? "--" : "#{evt.organization.internal_id}:"
    21:     txt += content_tag(:span, dept_no+h(evt.title[0,10])+(evt.title.size > 10 ? "..." : ""), :class => "event_title irekia_coverage_#{evt.irekia_coverage}")
    22:   end

event_link_url(evt, opts={})

La URL del evento.

[Source]

        # File app/helpers/sadmin/events_helper.rb, line 40
    40:   def event_link_url(evt, opts={})
    41:     if evt.is_a?(ScheduleEvent)
    42:       sadmin_schedule_event_path({:id => evt.id, :schedule_id => evt.schedule.id}.merge(opts))
    43:     else
    44:       sadmin_event_path({:id => evt.id}.merge(opts))
    45:     end
    46:   end

event_publication_state_info(evt)

Devuelve un texto con información sobre dónde es visible el evento.

[Source]

         # File app/helpers/sadmin/events_helper.rb, line 144
    144:   def event_publication_state_info(evt)
    145:     txt = if evt.is_private?
    146:       if evt.respond_to?('schedule')
    147:         "<span class='#{evt.schedule.dom_element_class}'>#{evt.schedule.name}</span>"
    148:       else
    149:         "<span class='private_event'>#{t('sadmin.events.uso_interno')}</span>"
    150:       end
    151:     else
    152:       "<span class='public_event #{event_div_class_name(evt)}'>#{t('sadmin.events.visible_en', :en => event_published_info(evt))}</span>"
    153:     end
    154:
    155:     txt
    156:   end

event_published_info(evt)

Devuelve la información sobre dónde está publicado el evento.

[Source]

         # File app/helpers/sadmin/events_helper.rb, line 98
     98:   def event_published_info(evt)
     99:     places = []
    100:     places.push "Irekia" if evt.show_in_irekia
    101:     places.push "Agencia" if (evt.show_in_agencia? && evt.published_in_agencia?)
    102:
    103:     return "#{t('en')} #{places.join(' ' + t('y') + ' ')}"
    104:   end

event_row_class(evt)

Devuelve la clase para la fila con los datos del evento. Se usa para diferenciar a simple vista los diferentes tipos de eventos.

[Source]

         # File app/helpers/sadmin/events_helper.rb, line 208
    208:   def event_row_class(evt)
    209:     txt = if evt.respond_to?('schedule')
    210:       evt.schedule.dom_element_class
    211:     else
    212:       'event'
    213:     end
    214:     txt
    215:   end

event_state_info(evt)

Devuelve un texto que indica el estado del evento.

[Source]

         # File app/helpers/sadmin/events_helper.rb, line 107
    107:   def event_state_info(evt)
    108:     txt = []
    109:
    110:     if !evt.confirmed?
    111:       txt << content_tag(:span, t('sadmin.events.evento_no_confirmado'), :class => "unpublished_notice")
    112:     end
    113:
    114:     if evt.published?
    115:       txt << content_tag(:span, t('sadmin.events.evento_publicado_en', :en => event_published_info(evt)), :class => "published_notice")
    116:       if evt.show_in_agencia? && !evt.published_in_agencia?
    117:         txt << content_tag(:span, t('sadmin.events.publicara_en_agencia_en', :en =>I18n.localize(evt.starts_at-3.days, :format => :short)), :class => "unpublished_notice")
    118:       end
    119:     else
    120:       txt << content_tag(:span, t('sadmin.events.publicara_en', :en =>I18n.localize(evt.published_at, :format => :short)), :class => "unpublished_notice") unless evt.published_at.nil?
    121:     end
    122:
    123:     if evt.deleted?
    124:       txt = ["<span class='deleted'>#{t('sadmin.events.marcado_eliminado')}</span>"]
    125:     end
    126:
    127:     txt.join("<br />")
    128:   end

num_events_in_cell()

Devuelve el número máximo de eventos que se muestran en una celda del calendario.

[Source]

       # File app/helpers/sadmin/events_helper.rb, line 4
    4:   def num_events_in_cell
    5:     @show_in_cell || 3
    6:   end

num_events_in_cell=(num)

Asigna valor al número máximo de eventos que se muestran en una celda del calendario.

[Source]

        # File app/helpers/sadmin/events_helper.rb, line 9
     9:   def num_events_in_cell=(num)
    10:     @show_in_cell = num.to_i
    11:   end

one_datetime_with_link(datetime)

Devuelve el enlace a la lista de eventos de un día.

[Source]

         # File app/helpers/sadmin/events_helper.rb, line 159
    159:   def one_datetime_with_link(datetime)
    160:     date = datetime.to_date
    161:
    162:     txt = link_to(I18n.localize(date, :format => :long), list_sadmin_events_path(:day => date.day, :month => date.month, :year => date.year))
    163:     if datetime.strftime('%H%M') != "0000"
    164:       txt << ", #{I18n.localize(datetime, :format => :hour)}"
    165:     end
    166:
    167:     txt
    168:   end

render_calendar_cell(d, events, today)

Muestra una celda del calendario.

[Source]

        # File app/helpers/sadmin/events_helper.rb, line 57
    57:   def render_calendar_cell(d, events, today)
    58:     cell_class = ""
    59:     day_number = ""
    60:
    61:     if d.mday == d.beginning_of_week.mday
    62:       day_number = link_to("Semana", week_sadmin_events_path(:day => d.mday, :month => d.month, :year => d.year), :class => "week_link")
    63:     end
    64:
    65:     day_number << link_to(d.mday, list_sadmin_events_path(:day => d.mday, :month => d.month, :year => d.year), :class => "day_number")
    66:
    67:     txt = content_tag(:div, day_number, :class => "day_number")
    68:
    69:
    70:     if events.blank?
    71:       if (d >= today) && !([0, 6].include?(d.wday))
    72:         cell_class = "normalDay"
    73:       end
    74:     else
    75:       show_in_cell = num_events_in_cell()
    76:       events[0,show_in_cell].each_with_index do |evt, i|
    77:         txt << event_data4table_cell(evt, d, i)
    78:       end
    79:
    80:       case
    81:         when (events.size == (show_in_cell+1))
    82:           txt << event_data4table_cell(events[show_in_cell], d, show_in_cell)
    83:         when (events.size > (show_in_cell+1))
    84:           txt << content_tag(:div, content_tag(:span,
    85:                                    link_to("+ #{events.size - show_in_cell} #{t('mas')}",
    86:                                            list_sadmin_events_path(:day => d.mday, :month => d.month, :year => d.year))),
    87:                              :class => "more_events_link")
    88:       end
    89:
    90:       # link_to_function(d.mday, "showDayInfo(#{d.mday}, this)")
    91:       cell_class="busyDay"
    92:     end
    93:
    94:     [txt, {:class => "#{cell_class} day#{d.wday}", :id => "d#{d.mday}_#{d.month}"}]
    95:   end

[Validate]