share setting included in orbit kernel to toggle on and off

This commit is contained in:
Harry Bomrah 2014-02-24 14:56:58 +08:00
parent e705ba9a26
commit f47835c390
6 changed files with 22 additions and 3 deletions

View File

@ -31,6 +31,8 @@ class Admin::PagesController < Admin::ItemsController
params[:page][:tag] = []
end
end
params[:page][:facebook_enabled] = params[:page][:facebook_enabled] ? true : false
@item = Page.find(params[:id])
if @item.module_app && @item.module_app.key == 'page_content' && @item.page_contexts.blank?
@item.page_contexts.build(:create_user_id => current_user.id, :update_user_id => current_user.id )
@ -70,6 +72,7 @@ class Admin::PagesController < Admin::ItemsController
if params[:val].eql?("default_widget")
@checked_style = @item.frontend_style.present? ? @item.frontend_style : nil if @item && @item.app_frontend_url.eql?("default_widget")
@enabled_styles = @module_app.get_default_widget["enabled_styles"]
@facebook_enabled = @module_app.get_default_widget["facebook_enabled"]
@widget_fields = @module_app.widget_fields.collect do |widget_field|
label = I18n.t("#{@module_app.key}.default_widget.#{widget_field[0]}")
[label, widget_field[0], class: widget_field[2]]

View File

@ -43,7 +43,7 @@ class DefaultWidgetController< OrbitWidgetController
if !params[:id].blank? and !params["clicked_field_name"].blank?
clicked_field_name = params["clicked_field_name"].to_sym
redirect_to eval("#{@page_part.module_app.widget_fields_link_method[clicked_field_name][:method]}('#{params[:id]}', {inner: #{params[:inner] || true}})")
redirect_to eval("#{@page_part.module_app.widget_fields_link_method[clicked_field_name][:method]}('#{params[:id]}', {inner: #{params[:inner] || true}, facebook_share: #{@page_part.facebook_enabled}})")
elsif !params[:id].blank? and params["preview"]
clicked_field_name = :title
@preview_pages = @page_part.module_app.widget_fields_link_method.find_all{|t| t[1].has_key?(:preview)}.collect{|t| t[0]}

View File

@ -21,6 +21,7 @@ class Page < Item
field :frontend_sat_to_link , :type => Array,:default => []
field :frontend_data_count
field :facebook_enabled, :type => Boolean, :default => false
belongs_to :theme
belongs_to :design

View File

@ -43,6 +43,15 @@
</li>
<% end %>
</ul>
<div id="facebook-enabled" class="checkbox-groups">
<label>Share setting</label>
<p>
<label class="radio inline">
<%= check_box_tag 'page[facebook_enabled]', true, @item && @item.facebook_enabled || false %>
Enable facebook sharing
</label>
</p>
</div>
<label><%= t("default_widget.fields_") %></label>
<table>
<thead>

View File

@ -1,5 +1,6 @@
#built-in-modules
gem 'announcement', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-announcement.git'
# gem 'announcement', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-announcement.git'
gem 'announcement', '0.0.1', :path => '/Users/H4RRY/github/modules'
gem 'gallery', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-gallery.git'
gem 'member', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-member.git'
gem 'member_staff', '0.0.1', :git => 'git@gitlab.tp.rulingcom.com:root/orbit-memberstaff.git'

View File

@ -103,6 +103,7 @@ module OrbitApp
@query = nil
@widget_title_enabled = false
@column_title_enabled = true
@facebook_enabled = false
@image = nil
@more_link = {}
@fields = []
@ -124,7 +125,7 @@ module OrbitApp
end
def to_module_app_format
{"query"=>@query,"image"=>@image,"more_link"=>@more_link,"enabled_styles"=>@enabled_styles,"widget_title_enabled"=>@widget_title_enabled, "column_title_enabled"=>@column_title_enabled} rescue nil
{"query"=>@query,"image"=>@image,"more_link"=>@more_link,"enabled_styles"=>@enabled_styles,"widget_title_enabled"=>@widget_title_enabled, "column_title_enabled"=>@column_title_enabled, "facebook_enabled"=>@facebook_enabled} rescue nil
end
def link_field(field_name,setting)
@ -151,6 +152,10 @@ module OrbitApp
@widget_title_enabled = var
end
def facebook_enabled(var)
@facebook_enabled = var
end
def column_title_enabled(var)
@column_title_enabled = var
end