Merge branch 'various_bugs' into nccu_master
Conflicts: Gemfile.lock app/assets/javascripts/ajax_form.js.erb app/assets/stylesheets/style.css.erb app/controllers/application_controller.rb app/controllers/sessions_controller.rb app/helpers/admin/web_link_helper.rb app/views/admin/attributes/_attribute_field.html.erb app/views/admin/designs/_form.html.erb app/views/admin/pages/_form.html.erb app/views/admin/sites/_side_bar.html.erb app/views/layouts/_orbit_bar.html.erb app/views/layouts/_side_bar.html.erb config/locales/en.yml config/locales/zh_tw.yml config/mongoid.yml vendor/built_in_modules/announcement/app/controllers/panel/announcement/back_end/bulletins_controller.rb vendor/built_in_modules/announcement/app/controllers/panel/announcement/front_end/bulletins_controller.rb vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_bulletin.html.erb vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/_filter.html.erb vendor/built_in_modules/announcement/app/views/panel/announcement/back_end/bulletins/index.html.erb vendor/built_in_modules/announcement/app/views/panel/announcement/widget/bulletins/_index.html.erb vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/_filter.html.erb vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/_filter_status.html.erb vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/_news_bulletin.html.erb vendor/built_in_modules/news/app/views/panel/news/back_end/news_bulletins/index.html.erb vendor/built_in_modules/web_resource/app/views/panel/web_resource/back_end/web_links/index.html.erb
This commit is contained in:
commit
65ac6980c4
2087 files changed
+80434
-3692
No files matched your search
@@ -1,4 +1,4 @@
|
||||
module Admin::AdBannerHelper
|
||||
module Admin::AdBannersHelper
|
||||
def preview_block_ad_images_helper(ad_banner)
|
||||
printable_ad_images = []
|
||||
ad_banner.ad_images.each do |ad_image|
|
||||
@@ -1,3 +0,0 @@
|
||||
module Admin::AdImagesHelper
|
||||
|
||||
end
|
||||
@@ -1,4 +1,4 @@
|
||||
module Admin::AppAuthHelper
|
||||
module Admin::AppAuthsHelper
|
||||
def on_off_switch(attribute,attribute_type)
|
||||
link_to t(:enable), eval("admin_#{attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{attribute_type} => {:disabled => true})"), :remote => true, :method => :put, :id => "disable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? 'none' : ''}", :class => 'switch'
|
||||
link_to t(:disable), eval("admin_#{attribute_type}_path(attribute, :authenticity_token => form_authenticity_token, :#{attribute_type} => {:disabled => false})"), :remote => true, :method => :put, :id => "enable_#{attribute.id}", :style => "display:#{attribute.is_disabled? ? '' : 'none'}", :class => 'switch'
|
||||
@@ -1,4 +1,4 @@
|
||||
module Admin::AssetHelper
|
||||
module Admin::AssetsHelper
|
||||
|
||||
def show_all_fields(asset, field)
|
||||
a = []
|
||||
@@ -1,4 +1,4 @@
|
||||
module Admin::DashboardHelper
|
||||
module Admin::DashboardsHelper
|
||||
|
||||
def get_link(title)
|
||||
case title
|
||||
@@ -1,4 +1,4 @@
|
||||
module Admin::ItemHelper
|
||||
module Admin::ItemsHelper
|
||||
|
||||
def render_node_and_children(node)
|
||||
ret = ''
|
||||
@@ -1,4 +1,4 @@
|
||||
module Admin::ModuleAppHelper
|
||||
module Admin::ModuleAppsHelper
|
||||
|
||||
def if_permit_to_delete(item)
|
||||
case item.downcase
|
||||
@@ -1,18 +0,0 @@
|
||||
module Admin::PageContentHelper
|
||||
include ActionView::Helpers::UrlHelper
|
||||
|
||||
|
||||
def show_page_context_edit_auth_link(page_context)
|
||||
type = 'Edit'
|
||||
# debugger
|
||||
# a=1
|
||||
oa = page_context.get_object_auth_by_title(type)
|
||||
if oa.nil?
|
||||
page_context.object_auths.new(title: type ).save rescue
|
||||
oa = page_context.get_object_auth_by_title(type)
|
||||
end
|
||||
# link_to t(:category_auth), edit_admin_object_auth_path(oa)
|
||||
link_to t(:category_auth),admin_object_auth_ob_auth_path(oa)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,30 @@
|
||||
module Admin::PluginsHelper
|
||||
|
||||
def render_plugin_list
|
||||
ret = ''
|
||||
|
||||
ret << "<div class=\"subnav\">"
|
||||
ret << "<div id=\"module-nav\">"
|
||||
ret << "<div class=\"arrow_next pull-right\"><i class=\"icon-chevron-right\"></i></div>"
|
||||
ret << "<div class=\"arrow_prev pull-left\"><i class=\"icon-chevron-left\"></i></div>"
|
||||
ret << "<div class=\"module-nav-view\">"
|
||||
|
||||
ret << "<ul class=\"nav nav-pills\">"
|
||||
|
||||
@plugins.each do |plugin|
|
||||
ret << "<li>"
|
||||
ret << (link_to eval("#{plugin.title}") , eval("panel_#{plugin.title}_back_end_#{plugin.object}s_path")) rescue nil
|
||||
ret << "</li>"
|
||||
end
|
||||
|
||||
ret << "</ul>"
|
||||
|
||||
ret << "</div>"
|
||||
ret << "</div>"
|
||||
ret << "</div>"
|
||||
|
||||
ret.html_safe
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,4 +1,4 @@
|
||||
module Admin::UserHelper
|
||||
module Admin::UsersHelper
|
||||
|
||||
def show_attribute(object, field_id, locale = '')
|
||||
attribute = object.attribute_values.detect {|av| av.attribute_field_id.eql?(field_id) || av[locale.to_s].eql?(locale.to_s) } rescue nil
|
||||
@@ -1,11 +0,0 @@
|
||||
module Admin::WebLinkHelper
|
||||
def show_web_link_permission_link(web_link)
|
||||
type = 'edit'
|
||||
oa = web_link.get_object_auth_by_title(type)
|
||||
if oa.nil?
|
||||
web_link.object_auths.new(title: type ).save
|
||||
oa = web_link.get_object_auth_by_title(type)
|
||||
end
|
||||
link_to t(:category_auth),admin_object_auth_ob_auth_path(oa)
|
||||
end
|
||||
end
|
||||
@@ -7,15 +7,31 @@ module AdminHelper
|
||||
|
||||
# Check if the current_user is manager in current module app
|
||||
def is_manager?
|
||||
@module_app.is_manager?(current_user) || is_admin?
|
||||
@module_app.is_manager?(current_or_guest_user) || is_admin?
|
||||
end
|
||||
|
||||
# Check if the current_user is sub manager in current module app
|
||||
def is_sub_manager?
|
||||
@module_app.is_sub_manager?(current_user)|| is_admin?
|
||||
@module_app.is_sub_manager?(current_or_guest_user)|| is_admin?
|
||||
end
|
||||
|
||||
def is_admin?
|
||||
current_user.admin?
|
||||
current_or_guest_user.admin?
|
||||
end
|
||||
|
||||
def is_member?
|
||||
if (current_user rescue false)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
def is_guest?
|
||||
if session[:guest_user_id]
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,6 +1,48 @@
|
||||
module ApplicationHelper
|
||||
|
||||
FLASH_NOTICE_KEYS = [:error, :notice, :warning]
|
||||
def check_user_role_enable(attribute_fields)
|
||||
@user.attribute_values.collect{|t| attribute_fields.include?(t.attribute_field) }.include?(true) rescue false
|
||||
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_guest_user
|
||||
u = User.create(:name => "guest", :email => "guest_#{Time.now.to_i}#{rand(99)}@example.com")
|
||||
u.admin = false
|
||||
u.save(:validate => false)
|
||||
u
|
||||
end
|
||||
|
||||
# if user is logged in, return current_user, else return guest_user
|
||||
def current_or_guest_user
|
||||
if current_user
|
||||
if session[:guest_user_id]
|
||||
guest_user.destroy
|
||||
session[:guest_user_id] = nil
|
||||
end
|
||||
current_user
|
||||
else
|
||||
guest_user
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# find guest_user object associated with the current session,
|
||||
# creating one as needed
|
||||
def guest_user
|
||||
User.find(session[:guest_user_id].nil? ? session[:guest_user_id] = create_guest_user.id : session[:guest_user_id])
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
def colorize_in_use_locale(locale)
|
||||
@site_in_use_locales.include?(locale)? 'green' : 'red'
|
||||
@@ -135,15 +177,17 @@ module ApplicationHelper
|
||||
|
||||
def page_stylesheets(page, edit=nil)
|
||||
stylesheets = ''
|
||||
unless edit
|
||||
stylesheets << "<link href='/assets/bootstrap.css' rel='stylesheet' type='text/css' />\n"
|
||||
unless edit
|
||||
stylesheets << "<link href='/assets/bootstrap-orbit.css' rel='stylesheet' type='text/css' />\n"
|
||||
stylesheets << "<link href='/assets/style.css' rel='stylesheet' type='text/css' />\n"
|
||||
end
|
||||
stylesheets << "<link href='#{page.design.css_reset.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.css_reset
|
||||
stylesheets << "<link href='/assets/bootstrap.css' rel='stylesheet' type='text/css' />\n"
|
||||
stylesheets << "<link href='/assets/font-awesome.css' rel='stylesheet' type='text/css' />\n"
|
||||
stylesheets << "<link href='/assets/orbit-bar.css' rel='stylesheet' type='text/css' />\n"
|
||||
stylesheets << "<link href='/assets/social-share-button.css' rel='stylesheet' type='text/css' />\n"
|
||||
stylesheets << "<link href='#{page.design.reset_css.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.reset_css
|
||||
stylesheets << "<link href='#{asset_path 'banner_nav.css'}' rel='stylesheet' type='text/css' />\n"
|
||||
stylesheets << "<link href='#{page.design.default_css.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.default_css
|
||||
stylesheets << "<link href='#{page.design.css_default.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.css_default
|
||||
theme = page.design.themes.detect{ |d| d.id == page.theme_id }
|
||||
stylesheets << "<link href='#{theme.file.url}' rel='stylesheet' type='text/css' />\n" if theme
|
||||
stylesheets
|
||||
@@ -204,10 +248,6 @@ module ApplicationHelper
|
||||
display_visitors(created_at: {'$gte' => Date.today.beginning_of_year, '$lte' => Date.today.end_of_year})
|
||||
end
|
||||
|
||||
def at_least_module_manager
|
||||
is_manager? || is_admin?
|
||||
end
|
||||
|
||||
def display_date_time(object)
|
||||
object.strftime("%Y-%m-%d %H:%M")
|
||||
end
|
||||
@@ -236,4 +276,13 @@ module ApplicationHelper
|
||||
wrap_mark = options[:wrap_mark] || "<br />"
|
||||
str.scan((/.{0,#{line_width}}/)).join(wrap_mark)
|
||||
end
|
||||
|
||||
def show_avatar(user)
|
||||
if (user.avatar? rescue false)
|
||||
image_tag(user.avatar.thumb.url)
|
||||
else
|
||||
image_tag "person.png"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,216 @@
|
||||
#encoding: utf-8
|
||||
# require ActionView::Helpers::FormTagHelper
|
||||
|
||||
module AttributeFieldsHelper
|
||||
include ActionView::Helpers::FormTagHelper
|
||||
include ActionView::Helpers::FormOptionsHelper
|
||||
include ActionView::Helpers::DateHelper
|
||||
include ActionView::Helpers::TagHelper
|
||||
include ActionView::Helpers::RenderingHelper
|
||||
|
||||
def block_helper(user,index,disable = false)
|
||||
@index = index
|
||||
@markup_options = markup_options.merge(:disabled=>disable)
|
||||
@user = user
|
||||
@attribute_value = @user.get_value_from_field_id(id)
|
||||
@new_attribute = @attribute_value.nil?
|
||||
@attribute_value = @attribute_value || @user.attribute_values.build(attribute_field_id: id)
|
||||
@prefiled_value = @attribute_value.get_values
|
||||
return instance_eval("render_#{markup}") #rescue ""
|
||||
end
|
||||
|
||||
def lang_tab(str,lang)
|
||||
content_tag(:div,str,:class=>"tab-pane fade",:id=>(get_field_name_base+"tab_#{lang}"))
|
||||
end
|
||||
|
||||
def render_address
|
||||
control_group_wrapper do |key,value|
|
||||
result = '<div class="input-append">'.html_safe
|
||||
|
||||
if(add_more and value.is_a?(Array))
|
||||
values = value
|
||||
result << values.each_with_index.collect do |value,index|
|
||||
text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options)
|
||||
end.join.html_safe
|
||||
else
|
||||
result << text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}]"), value,@markup_options)
|
||||
end
|
||||
|
||||
result << ('<a href="#'+self.key+'-edit" class="btn" type="button" data-toggle="modal"><i class="icon-edit"></i></a>').html_safe
|
||||
result << '<a href="#" class="btn" type="button"><i class="icon-trash"></i></a>'.html_safe
|
||||
result << '</div>'.html_safe
|
||||
result << gen_modal_dialog
|
||||
end
|
||||
end
|
||||
|
||||
def render_checkbox
|
||||
@prefiled_value ||=[]
|
||||
markup_value = eval(self.markup_value) rescue {}
|
||||
control_group_wrapper do
|
||||
markup_value.collect do |key,value|
|
||||
label_tag(key,check_box_tag(get_field_name_base+"[value][#{key}]", value[I18n.locale.to_s], (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label"))
|
||||
end.join rescue ""
|
||||
end
|
||||
end
|
||||
|
||||
def render_date
|
||||
control_group_wrapper{date_select(get_field_name_base+"[value]",nil,@markup_options.merge(:default=>@prefiled_value),:class=>"input-small")}
|
||||
end
|
||||
|
||||
def render_date_durnation #Need re-write low priority
|
||||
|
||||
end
|
||||
|
||||
def render_radio_button
|
||||
@prefiled_value ||=[]
|
||||
markup_value = eval(self.markup_value) rescue {}
|
||||
control_group_wrapper do
|
||||
markup_value.collect do |key,value|
|
||||
label_tag(key,radio_button_tag(get_field_name_base+"[value][#{key}]", value[I18n.locale.to_s], (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label"))
|
||||
end.join rescue ""
|
||||
end
|
||||
end
|
||||
|
||||
def render_select
|
||||
markup_value = (self.markup_value.is_a?(Hash) ? self.markup_value : eval(self.markup_value) )rescue {}
|
||||
control_group_wrapper{select_tag( get_field_name_base+"[value]",options_for_select(markup_value.collect{|p| [p[1][I18n.locale.to_s],p[0]]},@prefiled_value),@markup_options)} rescue ""
|
||||
end
|
||||
|
||||
def render_text_area
|
||||
control_group_wrapper do |key,value|
|
||||
if(add_more and value.is_a?(Hash))
|
||||
values = value
|
||||
values.each_with_index.collect do |value,index|
|
||||
text_area_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options)
|
||||
end.join.html_safe
|
||||
else
|
||||
value = can_muti_lang_input ? @prefiled_value[key] : @prefiled_value
|
||||
key = can_muti_lang_input ? "[#{key}]" : "[value]"
|
||||
text_area_tag(get_field_name_base + key, value,@markup_options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def render_text_field
|
||||
control_group_wrapper do |key,value|
|
||||
if(add_more and value.is_a?(Hash))
|
||||
values = value
|
||||
values.each_with_index.collect do |value,index|
|
||||
|
||||
text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options)
|
||||
end.join.html_safe
|
||||
else
|
||||
value = can_muti_lang_input ? @prefiled_value[key] : @prefiled_value
|
||||
key = can_muti_lang_input ? "[#{key}]" : "[value]"
|
||||
text_field_tag(get_field_name_base + key, value,@markup_options)
|
||||
end
|
||||
end
|
||||
end
|
||||
protected
|
||||
def lang_panel_control_wrapper(&block)
|
||||
result = '<div class="tabbable">'
|
||||
result << '<div class="tab-content">'
|
||||
result << controls_wrapper{yield}
|
||||
result << '</div>'
|
||||
result << '</div>'
|
||||
result.html_safe
|
||||
end
|
||||
|
||||
def controls_wrapper(&block)
|
||||
result = "<div class='controls'>"
|
||||
if can_muti_lang_input
|
||||
result << "<div class='tabbable'>"
|
||||
result << "<div class='tab-content'>"
|
||||
VALID_LOCALES.collect do |key|
|
||||
value = @prefiled_value[key.to_s] rescue nil
|
||||
div_class = ["tab-pane" ,"fade"].join(" ")
|
||||
div_class << (key == I18n.locale.to_s ? " active in" : '')
|
||||
result << content_tag(:div,yield(key,value),:class=>div_class,:id=>"tab"+id.to_s+"_#{key}")
|
||||
end
|
||||
result << "</div>"
|
||||
result << "<ul class='nav nav-pills'>"
|
||||
VALID_LOCALES.each do |key|
|
||||
result << content_tag(:li,link_to(t(:_locale, :locale => key),"#tab"+id.to_s+"_#{key}",:data=>{:toggle=>"tab"}),:class=>(key == I18n.locale.to_s ? "active" : nil))
|
||||
end
|
||||
result << "</ul>"
|
||||
result << "</div>"
|
||||
# @prefiled_value.collect do |key,value|
|
||||
# result << yield(key,value)
|
||||
# end
|
||||
else
|
||||
result << yield
|
||||
end
|
||||
if can_add_more
|
||||
result << '<span class="help-block">'
|
||||
result << '<a href="#"><i class="icon-plus-sign"></i> Add</a>'
|
||||
result << '</span>'
|
||||
end
|
||||
result << "</div>"
|
||||
result.html_safe
|
||||
end
|
||||
|
||||
def control_group_wrapper(&block)
|
||||
div_class = can_muti_lang_input ? "control-group language-swich" : "control-group"
|
||||
temp = label + controls_wrapper(&block)
|
||||
|
||||
result = content_tag(:div,temp,:class=>div_class)
|
||||
result << end_block
|
||||
|
||||
result.html_safe
|
||||
end
|
||||
|
||||
def end_block
|
||||
if @new_attribute
|
||||
hidden_field_tag(get_field_name_base+"[attribute_field_id]",id,:for=>"field_#{@index}")
|
||||
else
|
||||
hidden_field_tag(get_field_name_base+"[id]",@attribute_value.id,:for=>"field_#{@index}")
|
||||
end
|
||||
end
|
||||
|
||||
def get_field_name_base
|
||||
# "user[#{self.attribute._type.downcase.pluralize}][#{self.attribute._id.to_s}][attribute_values][#{attribute_value.id}]"
|
||||
# binding.pry if @attribute_value[:key] == 'status'
|
||||
if @new_attribute
|
||||
"user[new_attribute_values][#{@index}]"
|
||||
else
|
||||
"user[attribute_values][#{@index}]"
|
||||
end
|
||||
end
|
||||
|
||||
def label
|
||||
label_tag(key,title,:class=>"control-label")
|
||||
end
|
||||
|
||||
def can_muti_lang_input
|
||||
locale and LIST[:markups][markup]["muti_lang_input_supprt"]
|
||||
end
|
||||
|
||||
def can_add_more
|
||||
locale and LIST[:markups][markup]["ext_support"] && add_more
|
||||
end
|
||||
|
||||
def render_anywhere(partial, assigns)
|
||||
view = ActionView::Base.new(Rails::Configuration.new.view_path, assigns)
|
||||
ActionView::Base.helper_modules.each { |helper| view.extend helper }
|
||||
view.extend ApplicationHelper
|
||||
view.render(:partial => partial)
|
||||
end
|
||||
|
||||
def gen_modal_dialog
|
||||
result = '<div class="modal hide fade" id="address-edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none; ">'
|
||||
result << '<div class="modal-header">'
|
||||
result << '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>'
|
||||
result << '<h3 id="myModalLabel">'+title+'</h3>'
|
||||
result << '</div>'
|
||||
result << '<div class="modal-body">'
|
||||
result << '<p>One fine body…</p>'
|
||||
result << '</div>'
|
||||
result << '<div class="modal-footer">'
|
||||
result << '<button class="btn" data-dismiss="modal" aria-hidden="true">'+I18n.t("modal.close")+'</button>'
|
||||
result << '<button class="btn btn-primary">'+I18n.t("modal.save_and_close")+'</button>'
|
||||
result << '</div>'
|
||||
result << '</div>'
|
||||
result.html_safe
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,4 +0,0 @@
|
||||
module DesignHelper
|
||||
|
||||
|
||||
end
|
||||
@@ -38,7 +38,9 @@ module OrbitBackendHelper
|
||||
|
||||
def render_title(title, fields, span, translation)
|
||||
content_tag :th, :class => "sort #{span} #{is_sort_active?(title)}" do
|
||||
link_to (t(translation) + content_tag(:b, nil, :class => is_sort?(title))).html_safe, url_for({:filter => @filter}.merge(sortable(title).merge(:sort_options => fields))), :class => 'js_history'
|
||||
content_tag :span do
|
||||
link_to (t(translation) + content_tag(:b, nil, :class => is_sort?(title))).html_safe, url_for({:filter => @filter}.merge(sortable(title).merge(:sort_options => fields))), :class => 'js_history'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
module SitesHelper
|
||||
end
|
||||
Reference in new issue
Block a user