add field :uid by slug; add :get_plugin_data and :get_plugin_field_data
This commit is contained in:
parent
e6e444bd77
commit
e9e471cf9c
|
@ -5,10 +5,10 @@ class Activity
|
||||||
#include Admin::PersonalActivitiesHelper
|
#include Admin::PersonalActivitiesHelper
|
||||||
include OrbitModel::Status
|
include OrbitModel::Status
|
||||||
include MemberHelper
|
include MemberHelper
|
||||||
#include Slug
|
include Slug
|
||||||
|
|
||||||
# Language
|
# Language
|
||||||
field :activity_name, type: String, localize: true
|
field :activity_name, as: :slug_title, type: String, localize: true
|
||||||
field :activity_organizer, type: String, localize: true
|
field :activity_organizer, type: String, localize: true
|
||||||
field :activity_area, type: String, localize: true
|
field :activity_area, type: String, localize: true
|
||||||
|
|
||||||
|
@ -19,4 +19,46 @@ class Activity
|
||||||
field :note, type: String
|
field :note, type: String
|
||||||
|
|
||||||
belongs_to :member_profile
|
belongs_to :member_profile
|
||||||
|
|
||||||
|
def get_plugin_data(fields_to_show)
|
||||||
|
plugin_datas = []
|
||||||
|
fields_to_show.each do |field|
|
||||||
|
plugin_data = self.get_plugin_field_data(field) rescue nil
|
||||||
|
next if plugin_data.blank? or plugin_data['value'].blank?
|
||||||
|
plugin_datas << plugin_data
|
||||||
|
end
|
||||||
|
plugin_datas
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_plugin_field_data(field)
|
||||||
|
case field
|
||||||
|
when 'attendee'
|
||||||
|
path = OrbitHelper.url_to_plugin_show(self.member_profile.to_param, 'member') rescue '#'
|
||||||
|
value = "<a href='#{path}'>#{self.member_profile.name}</a>"
|
||||||
|
when 'activity_name'
|
||||||
|
value = self.activity_name rescue ''
|
||||||
|
when 'activity_organizer'
|
||||||
|
value = self.activity_organizer rescue ''
|
||||||
|
when 'activity_area'
|
||||||
|
value = self.activity_area rescue ''
|
||||||
|
when 'activity_start_date'
|
||||||
|
value = self.activity_start_date rescue ''
|
||||||
|
when 'activity_end_date'
|
||||||
|
value = self.activity_end_date rescue ''
|
||||||
|
when 'year'
|
||||||
|
value = self.year rescue ''
|
||||||
|
when 'note'
|
||||||
|
value = self.note rescue ''
|
||||||
|
else
|
||||||
|
value = self.send(field) rescue ''
|
||||||
|
end
|
||||||
|
|
||||||
|
{
|
||||||
|
'key' => field,
|
||||||
|
'title_class' => "activity-#{field.gsub('_','-')}-field",
|
||||||
|
'value_class' => "activity-#{field.gsub('_','-')}-value",
|
||||||
|
'title' => I18n.t('personal_activity.'+ field),
|
||||||
|
'value' => value
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue