"
ret << (link_to node.title, dest, :class => 'js_history')
ret << "
"
ret << (link_to t(:edit), eval("edit_admin_#{node.class.to_s.downcase}_path(node)"), :class => 'js_history') if node.class.to_s.eql?('Page')
diff --git a/app/helpers/admin/page_parts_helper.rb b/app/helpers/admin/page_parts_helper.rb
index 8e2951f5..24f21b78 100644
--- a/app/helpers/admin/page_parts_helper.rb
+++ b/app/helpers/admin/page_parts_helper.rb
@@ -9,14 +9,86 @@ module Admin::PagePartsHelper
end
end
- def widget_field_options(i)
+ def widget_field_options(i,local_item=nil)
+ local_item = @part if local_item.nil? && @part
+ local_item = @page if local_item.nil? && @page
options = @module_app.widget_fields.collect{|widget_field| [I18n.t(widget_field[1]), widget_field[0]]}
- options_for_select(options, (@part[:widget_field][i][0] if (@part && !@part[:widget_field].blank? && !@part[:widget_field][i].blank?)) )
+
+ case local_item
+ when Page
+ options_for_select(options, (local_item[:frontend_field][i][0] if (local_item && !local_item[:frontend_field].blank? && !local_item[:frontend_field][i].blank?)) )
+ when PagePart
+ options_for_select(options, (local_item[:widget_field][i][0] if (local_item && !local_item[:widget_field].blank? && !local_item[:widget_field][i].blank?)) )
+ end
end
- def widget_fiield_type_options(i)
+ def widget_fiield_type_options(i,local_item=nil)
options = LIST[:widget_field_type].collect{|widget_field| [widget_field.humanize, widget_field]}
- options_for_select(options, (@part[:widget_field][i][1] if (@part && !@part[:widget_field].blank? && !@part[:widget_field][i].blank?)) )
+ local_item = @part if local_item.nil? && @part
+ local_item = @page if local_item.nil? && @page
+
+ case local_item
+ when Page
+ options_for_select(options, (local_item[:frontend_field][i][1] if (local_item && !local_item[:frontend_field].blank? && !local_item[:frontend_field][i].blank?)) )
+ when PagePart
+ options_for_select(options, (local_item[:widget_field][i][1] if (local_item && !local_item[:widget_field].blank? && !local_item[:widget_field][i].blank?)) )
+ end
+ end
+
+ def tag_checked_value(part,radio_value)
+ if radio_value.blank?
+ (part.nil? || part[:tag].blank?)? true : false
+ else
+ part and (part[:tag] == radio_value.to_s) ? true : false
+ end
+ end
+
+ def category_checked_value(part,radio_value)
+ if radio_value.blank?
+ (part.nil? || part[:category].blank?)? true : false
+ else
+ part and (part[:category] == radio_value.to_s) ? true : false
+ end
+ end
+
+ def style_checked_value(part,radio_value)
+ case part
+ when Page
+ if part.frontend_style.nil? && radio_value == "typeA"
+ true
+ else
+ (part.frontend_style == radio_value) ? true : false
+ end
+ when PagePart
+ if part.widget_style.nil? && radio_value == "typeA"
+ true
+ else
+ (part.widget_style == radio_value) ? true : false
+ end
+ when nil
+ false
+ end
+ end
+
+ def nil_radio_button(part,tag_or_cate)
+ field_name = case part
+ when PagePart
+ 'page_part'
+ when Page
+ 'page'
+ end
+ content_tag :label,:class=>"radio inline" do
+ op = radio_button(field_name, tag_or_cate, '' , :checked => eval("#{tag_or_cate}_checked_value(part,'')"))
+ op << I18n.t("default_widget.no_value")
+ end
+ end
+
+ def show_default_widget_setting_panel
+ @module_app && @module_app.has_default_widget? && (!@user_choose.nil? && @user_choose== 'default_widget') #&& @part.widget_path == 'default_widget'
+ end
+
+ def show_custom_widget_setting_panel
+ true
end
end
\ No newline at end of file
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e20a0c29..980db7bc 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -54,8 +54,14 @@ module ApplicationHelper
raw(formatted_messages.join)
end
- def link_back
- link_to t('back'), get_go_back, :class => 'nav'
+ def link_back(custom_class=nil)
+ case custom_class
+ when nil
+ link_to t('back'), get_go_back, :class => 'nav'
+ else
+ link_to t('back'), get_go_back, :class => custom_class
+ end
+
end
# Clean the link back
@@ -254,6 +260,10 @@ module ApplicationHelper
object.strftime("%Y-%m-%d")
end
+ def display_time(object)
+ object.strftime("%H:%M")
+ end
+
def share_links(object, key)
content_tag :div, :class => 'fb' do
concat social_share_button_tag(object.title, :fb_url => generate_fb_url(object,key), :image => "http://#{request.env['HTTP_HOST']}#{object.image_url}")
@@ -278,4 +288,9 @@ module ApplicationHelper
end
end
+ # NTU link
+ def get_link(site_number)
+ "http://#{request.host}:2#{site_number}00"
+ end
+
end
diff --git a/app/helpers/attribute_fields_helper.rb b/app/helpers/attribute_fields_helper.rb
index 2705dc8f..be1b39ee 100644
--- a/app/helpers/attribute_fields_helper.rb
+++ b/app/helpers/attribute_fields_helper.rb
@@ -149,7 +149,7 @@ protected
link_entry_ary = [".#{get_pairing_tab_class({})}",".#{key}"]
link_entry_ary << ".add_more_item_#{add_more_counter}" if can_add_more
link_entry = link_entry_ary.join
- content_tag(:li,link_to(I18n.t("langs."+key),link_entry,:data=>{:toggle=>"tab"}),:class=>(key == I18n.locale.to_s ? "active" : nil),:for=>key)
+ content_tag(:li,link_to(I18nVariable.from_locale(key),link_entry,:data=>{:toggle=>"tab"}),:class=>(key == I18n.locale.to_s ? "active" : nil),:for=>key)
end.join.html_safe # of VALID_LOCALES.collect for tabs
end # of content ul
end
diff --git a/app/helpers/default_widget_helper.rb b/app/helpers/default_widget_helper.rb
index acab557c..645f50f0 100644
--- a/app/helpers/default_widget_helper.rb
+++ b/app/helpers/default_widget_helper.rb
@@ -49,7 +49,8 @@ module DefaultWidgetHelper
when nil
eval method_entry
else
- eval("#{method_entry}('#{object}')" )
+ object = "'#{object.to_s}'" if object.class == BSON::ObjectId
+ eval("#{method_entry}(#{object})" )
end
end
diff --git a/app/helpers/desktop/co_author_relations_helper.rb b/app/helpers/desktop/co_author_relations_helper.rb
deleted file mode 100644
index fa03bbae..00000000
--- a/app/helpers/desktop/co_author_relations_helper.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-module Desktop::CoAuthorRelationsHelper
-end
diff --git a/app/helpers/desktop/journal_lists_helper.rb b/app/helpers/desktop/journal_lists_helper.rb
deleted file mode 100644
index e21dc09f..00000000
--- a/app/helpers/desktop/journal_lists_helper.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-module Desktop::JournalListsHelper
-end
diff --git a/app/helpers/front_helper.rb b/app/helpers/front_helper.rb
new file mode 100644
index 00000000..6a276d96
--- /dev/null
+++ b/app/helpers/front_helper.rb
@@ -0,0 +1,9 @@
+module FrontHelper
+
+ def ad_image_link(ad_image)
+ link = ad_image.out_link
+ link = front_show_inner_ad_image_path(:id=> ad_image.id) if link.blank? && !ad_image.context.blank?
+ link
+ end
+
+end
\ No newline at end of file
diff --git a/app/helpers/orbit_form_helper.rb b/app/helpers/orbit_form_helper.rb
new file mode 100644
index 00000000..30133f19
--- /dev/null
+++ b/app/helpers/orbit_form_helper.rb
@@ -0,0 +1,104 @@
+module OrbitFormHelper
+ def self.included(base)
+ ActionView::Helpers::FormBuilder.send(:include, Orbit::FormBuilder)
+ end
+
+ def datetime_picker(object_name, method, options = {})
+ options[:icon_time] ||= 'icons-clock'
+ options[:icon_date] ||= 'icons-calendar'
+ options[:icon_clear] ||= 'icons-cross-3'
+ options[:input_class] ||= 'input-large'
+ options[:value] ||= options[:object][method] if options[:object] && options[:object][method]
+ case options[:picker_type]
+ when 'date'
+ content_tag :div, :id => options[:id], :class => options[:class] do
+ date_picker(object_name, method, options)
+ end
+ when 'time'
+ content_tag :div, :id => options[:id], :class => options[:class] do
+ time_picker(object_name, method, options)
+ end
+ when 'separated'
+ options[:label] ||= I18n.t('datetime_picker.separated.label')
+ content_tag :div, :id => options[:id], :class => "separated_picker #{options[:class]}" do
+ concat label_tag options[:label] unless options[:no_label]
+ concat hidden_field(object_name, method)
+ concat separated_picker(object_name, method, options)
+ end
+ else
+ content_tag :div, :id => options[:id], :class => options[:class] do
+ default_picker(object_name, method, options)
+ end
+ end
+ end
+
+ def date_picker(object_name, method, options)
+ custom = {}
+ custom[:format] = 'yyyy-MM-dd'
+ custom[:value] = display_date(options[:value]) if options[:value]
+ custom[:picker_class] = 'date_picker'
+ custom[:label] = options[:label] || I18n.t('datetime_picker.date.label')
+ custom[:placeholder] = options[:placeholder] || I18n.t('datetime_picker.date.placeholder')
+ picker(object_name, method, options.merge(custom))
+ end
+
+ def default_picker(object_name, method, options)
+ custom = {}
+ custom[:format] = 'yyyy-MM-dd hh:mm'
+ custom[:value] = display_date_time(options[:value]) if options[:value]
+ custom[:picker_class] = 'default_picker'
+ custom[:label] = options[:label] || I18n.t('datetime_picker.default.label')
+ custom[:placeholder] = options[:placeholder] || I18n.t('datetime_picker.default.placeholder')
+ picker(object_name, method, options.merge(custom))
+ end
+
+ def time_picker(object_name, method, options)
+ custom = {}
+ custom[:format] = 'hh:mm'
+ custom[:value] = display_time(options[:value]) if options[:value]
+ custom[:picker_class] = 'time_picker'
+ custom[:label] = options[:label] || I18n.t('datetime_picker.time.label')
+ custom[:placeholder] = options[:placeholder] || I18n.t('datetime_picker.time.placeholder')
+ picker(object_name, method, options.merge(custom))
+ end
+
+ def separated_picker(object_name, method, options)
+ custom = {}
+ custom[:no_label] = true
+ custom[:separated] = true
+ date_picker(nil, nil, options.merge(custom)) + time_picker(nil, nil, options.merge(custom))
+ end
+
+
+ def single_picker(object_name, method, options)
+ content_tag :div, :id => options[:id], :class => options[:class] do
+ picker(object_name, method, options)
+ end
+ end
+
+ def double_picker(object_name, method, options)
+
+ end
+
+ def picker(object_name, method, options)
+ content_tag :div, :class => "#{options[:picker_class]} input-append", :style => "#{(options[:picker_class].eql?('time_picker') && options[:value].blank? && options[:separated]) ? 'pointer-events:none' : nil}" do
+ concat label_tag options[:label] unless options[:no_label]
+ concat text_field object_name, method, :placeholder => options[:placeholder], :class => options[:input_class], 'data-format' => options[:format], :value => options[:value]
+ concat (content_tag :span, :class => 'add-on clearDate' do
+ content_tag :i, nil, :class => options[:icon_clear]
+ end)
+ concat (content_tag :span, :class => 'add-on iconbtn' do
+ content_tag :i, nil, 'data-time-icon' => options[:icon_time], 'data-date-icon' => options[:icon_date]
+ end)
+ end
+ end
+
+end
+
+module Orbit::FormBuilder
+ # ActionPack's metaprogramming would have done this for us, if FormHelper#labeled_input
+ # had been defined at load. Instead we define it ourselves here.
+ def datetime_picker(method, options = {})
+ @template.datetime_picker(@object_name, method, objectify_options(options))
+ end
+end
\ No newline at end of file
diff --git a/app/models/ad_image.rb b/app/models/ad_image.rb
index c01bc6b4..aad34852 100644
--- a/app/models/ad_image.rb
+++ b/app/models/ad_image.rb
@@ -5,7 +5,10 @@ class AdImage
mount_uploader :file, ImageUploader
field :title, localize: true
- field :context, localize: true
+ field :context, localize: true
+ field :to_save, :type => Boolean
+ field :to_destroy, :type => Boolean
+
field :direct_to_after_click,type: Boolean
@@ -16,28 +19,12 @@ class AdImage
field :post_date,type: Date
field :unpost_date,type: Date
-
- field :to_save, :type => Boolean
- field :to_destroy, :type => Boolean
belongs_to :ad_banner
- # validates_numericality_of :weight, greater_than_or_equal_to: 1,less_than_or_equal_to: 10
- # validates_format_of :out_link, with: /(http:\/\/.*|)/ ,:message => 'Need a valid URL'
- attr_reader :parse_post_date,:parse_unpost_date
-
before_validation :add_http
validates :out_link, :format => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix, :allow_blank => true
- def parse_post_date=(att)
- self.post_date = (Date.parse att.gsub(/\s+/, "") rescue nil)
- end
-
-
- def parse_unpost_date=(att)
- self.unpost_date = (Date.parse att.gsub(/\s+/, "") rescue nil)
- end
-
def display?
if (self.post_date <= Date.today && (self.unpost_date.nil? || self.unpost_date>= Date.today) rescue false)
return true
diff --git a/app/models/module_app.rb b/app/models/module_app.rb
index aa0f0008..d188a70b 100644
--- a/app/models/module_app.rb
+++ b/app/models/module_app.rb
@@ -163,6 +163,16 @@ class ModuleApp
end
end
+ def has_default_widget?
+ case self[:widgets]
+ when Array
+ false
+ when Hash
+ self[:widgets].has_key? 'default_widget'
+ end
+
+ end
+
protected
def set_key
diff --git a/app/models/page_part.rb b/app/models/page_part.rb
index ebaac684..b48c8060 100644
--- a/app/models/page_part.rb
+++ b/app/models/page_part.rb
@@ -23,6 +23,15 @@ class PagePart
before_save :delete_empty_widget_field
after_save :update_parent
+ # def module_app
+ # if self[:module_app]
+ # self[:module_app]
+ # elsif self[:kind] == 'module_widget'
+ # self.page.module_app
+ # else
+ # nil
+ # end
+ # end
protected
@@ -37,5 +46,4 @@ class PagePart
self.page.save
end
-
end
\ No newline at end of file
diff --git a/app/models/user/attribute.rb b/app/models/user/attribute.rb
index c0970863..a1367c9f 100644
--- a/app/models/user/attribute.rb
+++ b/app/models/user/attribute.rb
@@ -6,7 +6,9 @@ class Attribute
field :key
field :built_in, :type => Boolean, :default => false
field :disabled, :type => Boolean, :default => false
- field :title, localize: true
+ field :title, localize: true
+
+ field :to_search, :type => Boolean, :default => false
has_many :attribute_fields, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :attribute_fields, :allow_destroy => true
diff --git a/app/models/user/attribute_field.rb b/app/models/user/attribute_field.rb
index d486ccd0..0a6c4ac3 100644
--- a/app/models/user/attribute_field.rb
+++ b/app/models/user/attribute_field.rb
@@ -11,6 +11,9 @@ class AttributeField
field :built_in, :type => Boolean, :default => false
field :disabled, :type => Boolean, :default => false
field :to_delete,:type=> Boolean,:default => false
+
+ field :to_search,:type=> Boolean,:default => false
+
field :typeA,:type=> Hash,:default=>{:cross_lang=>false}
field :typeB,:type=> Hash,:default=>{}
field :typeC,:type=> Hash,:default=>{:calendar=>"west_calendar",:format=>"format3"}
diff --git a/app/models/user/role.rb b/app/models/user/role.rb
index cd3d6775..7291c88c 100644
--- a/app/models/user/role.rb
+++ b/app/models/user/role.rb
@@ -1,4 +1,4 @@
-class Role
+class Role < Attribute
include Mongoid::Document
include Mongoid::Timestamps
@@ -6,12 +6,13 @@ class Role
field :key
field :built_in, :type => Boolean, :default => false
field :disabled, :type => Boolean, :default => false
+
field :title, localize: true
has_many :sub_roles, :autosave => true, :dependent => :destroy
has_many :users
has_many :statuses, :autosave => true, :dependent => :destroy
- has_many :attribute_fields, :autosave => true, :dependent => :destroy
+ # has_many :attribute_fields, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :sub_roles, :allow_destroy => true
def is_built_in?
diff --git a/app/models/user/user.rb b/app/models/user/user.rb
index ac32423f..26c8a042 100644
--- a/app/models/user/user.rb
+++ b/app/models/user/user.rb
@@ -72,14 +72,32 @@ class User
sub_roles.where(role_id: role.id)
end
- def disable_sub_role=(var)
+ def disable_role=(var)
var[:id].each do |id,val|
# binding.pry if id == '5052c5b22b5c49ab02000004'
if (val=="true")
+ self.roles = self.roles.reject{|t| t.id.to_s==id}
+ elsif(val=="false")
+ self.roles << Role.find(id)
+ end
+ end
+ end
+
+ def disable_sub_role=(var)
+ var[:id].each do |id,val|
+
+ @sr = SubRole.find(id)
+
+ @roid = Role.find(@sr.role_id.to_s)
+
+ # binding.pry if id == '5052c5b22b5c49ab02000004'
+
+ if ( self.roles.include?(@roid) == false or val=="true")
self.sub_roles = self.sub_roles.reject{|t| t.id.to_s==id}
elsif(val=="false")
self.sub_roles << SubRole.find(id)
end
+
end
end
@@ -189,7 +207,8 @@ class User
protected
def save_roles
- self.roles = self.sub_roles.collect{|t| t.role}.uniq
+ # self.roles = self.sub_roles.collect{|t| t.role}.uniq
+ self.roles = self.roles.uniq
end
diff --git a/app/views/admin/ad_banners/_ad_image_update.html.erb b/app/views/admin/ad_banners/_ad_image_update.html.erb
index 281d0753..b0f6c63c 100644
--- a/app/views/admin/ad_banners/_ad_image_update.html.erb
+++ b/app/views/admin/ad_banners/_ad_image_update.html.erb
@@ -2,7 +2,7 @@
<%= image_tag ad_image.file rescue nil%>
<%= ad_image.display? ? "[#{t('ad.showing')}]" : "[#{t('ad.not_showing')}]" %>
- <%= "#{ad_image.post_date ||'NeedReset' }~#{ad_image.unpost_date || 'NeedReset'}" %>
+ <%= "#{ad_image.post_date} ~ #{ad_image.unpost_date}" %>
<%if at_least_module_manager || sub_manager?(ad_image.ad_banner) %>
diff --git a/app/views/admin/ad_images/_form.html.erb b/app/views/admin/ad_images/_form.html.erb
index fd139347..884c08c0 100644
--- a/app/views/admin/ad_images/_form.html.erb
+++ b/app/views/admin/ad_images/_form.html.erb
@@ -1,13 +1,7 @@
-<% content_for :page_specific_css do %>
- <%= stylesheet_link_tag "lib/datepicker" %>
-<% end %>
<% content_for :page_specific_javascript do %>
- <%= javascript_include_tag "lib/datepicker" %>
- <%= javascript_include_tag "lib/date.format.js" %>
<%= javascript_include_tag "inc/modal-preview" %>
<%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %>
<%= javascript_include_tag "inc/jquery.imagesloaded.js" %>
-
<% end %>
@@ -16,62 +10,19 @@