member module fixes for frontend,personal plugin frontend

This commit is contained in:
Saurabh Bhatia 2014-06-25 13:27:34 +08:00
parent 10567f1c74
commit e8c9d6b036
9 changed files with 46 additions and 5 deletions

View File

@ -37,7 +37,7 @@ class MembersController < ApplicationController
pd = plugin_data.collect do |p|
{
"data_title" => p.slug_title,
"link_to_show" => OrbitHelper.url_to_show(p.to_param)
"link_to_show" => OrbitHelper.url_to_show(p.to_param) + "?method=personal_plugin&plugin_name=#{plugin.app_name}"
}
end
@ -132,4 +132,17 @@ class MembersController < ApplicationController
}
}
end
def personal_plugin
params = OrbitHelper.params
plugin_class = params[:plugin_name].constantize
plugin_value = plugin_class.find_by(uid: params[:uid])
data = []
plugin_value.values_for_view.each do |key,value|
data << {"key" => key.humanize, "value" => value}
end
{
"plugin_data" => data
}
end
end

View File

@ -341,6 +341,16 @@ module ApplicationHelper
html.html_safe
end
def show_attribute_value(value)
if value.kind_of? Hash
result = []
value.each{|t| result.push(t.last)}
result.join ","
else
value
end
end
def create_pagination(total_pages)
file = File.join(Rails.root, 'app', 'templates', "#{@key}", 'home', "pagination.html.erb")
html = ""

View File

@ -1,2 +1,11 @@
module MemberHelper
include ActionView::Helpers::UrlHelper
def url_to_file(url,title)
link_to "#{title}", url
end
def nl2br(val)
val.gsub(/\r\n/, '<br />').html_safe
end
end

View File

@ -46,7 +46,6 @@ class AttributeValue
def get_value_by_locale(locale,add_more_index=nil)
case self.attribute_field.markup
when "text_field"
case self.attribute_field.add_more
@ -86,8 +85,7 @@ class AttributeValue
when "checkbox"
markup_values = self.attribute_field.markup_value
self.value.collect{|key| markup_values[key][locale.to_s]}.join(",")
self.value.collect{|key| markup_values["#{key}"][I18n.locale]}.join(",")
when "date_durnation"
self.value

View File

@ -0,0 +1 @@
<p>test</p>

View File

@ -0,0 +1,5 @@
<article class="personal_plugin" module="member">
<div data-list="plugin_data" data-level="0">
<p>{{key}} : {{value}}</p>
</div>
</article>

View File

@ -4,5 +4,9 @@
<dl>
<dt><%= t('status') %></dt>
<dd><%= @member.role_statuses.where(role_id: show_roles.id).map{|t|t.title.to_s}.join(',') rescue '' %></dd>
<% show_roles.attribute_fields.where(:disabled=>false).asc(:_id).each do |rf| %>
<dt><%= rf.title %></dt>
<dd><%= nl2br(show_attribute_value(@member.get_attribute_value(rf,"role").get_value_by_locale(I18n.locale))) rescue '' %></dd>
<% end -%>
</dl>
</div>

View File

@ -17,7 +17,7 @@
<dd><%= t("users.#{(@member.sex.nil? ? 'unknown' : @member.sex)}") %></dd>
<% items.each do |item| %>
<dt><%= item.member_profile_field.title %></dt>
<dd><%= item.value %></dd>
<dd><%= nl2br(show_attribute_value(@member.get_attribute_value(item.member_profile_field).get_value_by_locale(I18n.locale))) rescue '' %></dd>
<% end -%>
</dl>
</div>

View File

@ -0,0 +1 @@
<%= render_view %>