Compare commits

...

12 Commits

31 changed files with 427 additions and 35 deletions

View File

@ -15,6 +15,11 @@ function load_tinymce() {
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
// Domain Absolute URLs
relative_urls : false,
remove_script_host : false,
document_base_url: window.location.protocol + '//' + window.location.host,
// Skin options
skin : "o2k7",
skin_variant : "silver",

View File

@ -43,7 +43,7 @@ class MobileController < ApplicationController
def page
@page_title = t('mobile.page')
@page_contexts = PageContext.where(:archived => false).page(params[:page_main]).per(15)
@page_contexts = get_sorted_page_from_structure
end
def page_content
@ -57,4 +57,12 @@ class MobileController < ApplicationController
@no_footer = true if request.path =~ /app/
end
def get_sorted_page_from_structure
page_contexts = Item.structure_ordered_items.inject([]){ |pages, page|
pages << page.page_contexts.where(archived: false).limit(1)[0] if page.is_a?(Page) && !page.page_contexts.blank?
pages
}
Kaminari.paginate_array(page_contexts).page(params[:page]).per(15)
end
end

View File

@ -42,7 +42,6 @@ class User
before_create :initialize_desktop
before_save :rebuild_status_record
before_save :save_roles
scope :remote_account, where(:nccu_id.ne => nil)
scope :not_guest_user, all_of(:name.ne => "guest")
@ -89,9 +88,9 @@ class User
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}
self.role_ids.reject!{|t| t.to_s == id}
elsif(val=="false")
self.roles << Role.find(id)
self.role_ids += Array(id)
end
end
end
@ -106,9 +105,9 @@ class User
# 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}
self.sub_role_ids.reject!{|t| t.to_s == id}
elsif(val=="false")
self.sub_roles << SubRole.find(id)
self.sub_role_ids += Array(id)
end
end
@ -273,10 +272,6 @@ class User
end
protected
def save_roles
# self.roles = self.sub_roles.collect{|t| t.role}.uniq
self.roles = self.roles.uniq
end
def rebuild_status_record
self.status_record = {}

View File

@ -326,4 +326,44 @@ namespace :migrate do
`mongo #{Mongoid.config.database.name} --eval "db.tags.remove({_type: {$ne: 'Tag'}})"`
end
task :add_missing_user_link => :environment do
User.all.each do |user|
user.role_ids.uniq!
user.sub_role_ids.uniq!
user.save
user.roles.each do |role|
unless role.user_ids.include?(user.id)
role.user_ids << user.id
role.save
end
end
user.sub_roles.each do |sub_role|
unless sub_role.user_ids.include?(user.id)
sub_role.user_ids << user.id
sub_role.save
end
end
end
Role.all.each do |role|
role.user_ids.uniq!
role.save
role.users.each do |user|
unless user.role_ids.include?(role.id)
user.role_ids << role.id
user.save
end
end
end
SubRole.all.each do |sub_role|
sub_role.user_ids.uniq!
sub_role.save
sub_role.users.each do |user|
unless user.sub_role_ids.include?(sub_role.id)
user.sub_role_ids << sub_role.id
user.save
end
end
end
end
end

View File

@ -0,0 +1,78 @@
.mega_tab_block {
clear: both;
position: relative;
}
.mega_tab_block h3 {
font: 22px/100% 'arial',sans-serif;
margin: 0 0 10px;
padding: 0;
}
.mega_tab_block .pagination {
float: left;
height: auto;
margin: 10px 0 0;
width: auto;
}
.mega_tab_block .pagination a {
background: none repeat scroll 0 0 #EEEEEE;
display: block;
float: left;
margin: 0 5px 0 0;
padding: 10px;
}
.tag_block {
clear: both;
margin: 0 0 20px;
position: relative;
}
.mega_tab_block .tag_list {
background: none repeat scroll 0 0 #EEEEEE;
margin: 0;
overflow: hidden;
padding: 0 0 0 5px;
}
.mega_tab_block .tag_list li {
float: left;
list-style: none outside none;
}
.mega_tab_block .tag_list li a {
background: none repeat scroll 0 0 #DDDDDD;
float: left;
margin: 0 5px 0 0;
padding: 10px;
}
.news_block {
clear: both;
margin: 0 0 20px;
overflow: hidden;
position: relative;
}
.mega_tab_block .news_list {
margin: 0;
padding: 0;
}
.mega_tab_block .news_list li {
list-style: none outside none;
padding: 5px 0;
}
.links_block {
clear: both;
overflow: hidden;
position: relative;
}
.mega_tab_block .links_list {
margin: 0;
padding: 0;
}
.mega_tab_block .links_list li {
list-style: none outside none;
padding: 5px 0;
}

View File

@ -66,14 +66,75 @@ class Panel::Announcement::Widget::BulletinsController < OrbitWidgetController
end
def bulletins_and_web_links
@part = PagePart.find(params[:part_id]) if !params[:part_id].blank?
@title = @part.title_translations[I18n.locale.to_s]
if !@part.blank? and @part.widget_data_count
@page_num = @part.widget_data_count
else
@page_num = 5
end
date_now = Time.now
if !params[:tag_id].blank?
@tags = Tag.any_in(:_id => params[:tag_id]).asc(:created_at)
elsif params[:tag_id].blank? and !@part.tag.blank?
@tags = Tag.any_in(:_id => @part.tag).asc(:created_at)
else
@ModuleApp_b = ModuleApp.first(:conditions => {:key=>'announcement'})
@tags = Tag.where(:module_tag_id => @ModuleApp_b.id).asc(:created_at)
end
@selected_tag = Tag.find(params[:id]).first rescue @tags[0]
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => @selected_tag.id.to_s, :is_hidden => false).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc(:is_top, :postdate).page(params[:page]).per(@page_num) rescue nil
if @part.widget_style == 'bulletins_and_web_links'
@ModuleApp_w = ModuleApp.first(:conditions => {:key=>'web_resource'})
@link_selected_tag = Tag.first(:conditions => {:name => @selected_tag.name, :module_tag_id => @ModuleApp_w.id})
@web_links = WebLink.where(:tagged_ids => @link_selected_tag.id.to_s, :is_hidden => false).desc(:is_top,:created_at).available_for_lang(I18n.locale).page(params[:page]).per(@page_num) rescue nil
end
end
def reload_bulletins
@selected_tag = Tag.find(params[:tag_id])
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => params[:tag_id]).where(:is_hidden => false).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc(:is_top, sort).page(params[:page]).per(5) rescue nil
@part = PagePart.find(params[:part_id]) if !params[:part_id].blank?
@title = @part.title_translations[I18n.locale.to_s]
if !@part.blank? and @part.widget_data_count
@page_num = @part.widget_data_count
else
@page_num = 5
end
date_now = Time.now
@selected_tag = Tag.find(params[:tag_id]).first
@bulletins = Bulletin.available_for_lang(I18n.locale).can_display.where(:tagged_ids => @selected_tag.id.to_s, :is_hidden => false).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc(:is_top, :postdate).page(params[:page]).per(@page_num) rescue nil
end
def reload_web_links
@selected_tag = Tag.find(params[:tag_id])
@web_links = WebLink.where(:name => @selected_tag.name).where(:is_hidden => false).desc(:is_top, sort).available_for_lang(I18n.locale).page(params[:page]).per(5) rescue nil
@part = PagePart.find(params[:part_id]) if !params[:part_id].blank?
if !@part.blank? and @part.widget_data_count
@page_num = @part.widget_data_count
else
@page_num = 5
end
date_now = Time.now
@selected_tag = Tag.find(params[:tag_id]).first
@ModuleApp = ModuleApp.first(:conditions => {:key=>'web_resource'})
@link_selected_tag = Tag.first(:conditions => {:name => @selected_tag.name, :module_tag_id => @ModuleApp.id})
@web_links = WebLink.where(:tagged_ids => @link_selected_tag.id.to_s, :is_hidden => false).desc(:is_top,:created_at).available_for_lang(I18n.locale).page(params[:page]).per(@page_num) rescue nil
end
def bulletins_side_bar

View File

@ -1,10 +1,10 @@
<% @bulletins.each do |bulletin| %>
<li>
<%= link_to bulletin.title, panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.bulletin_category_id , :tag_id => @selected_tag.id ) %>
<%= link_to bulletin.title, panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.bulletin_category_id , :part_id => params[:part_id], :tag_id => [@selected_tag.id] ) %>
</li>
<% end %>
<div class='pagination'>
<%= link_to_previous_page @bulletins, 'Previous Page', :params => {:controller => 'widget/bulletins', :action => 'reload_bulletins', :tag_id => @selected_tag.id}, :remote => true, :class => 'previous' %>
<%= link_to_next_page @bulletins, 'Next Page', :params => {:controller => 'widget/bulletins', :action => 'reload_bulletins', :tag_id => @selected_tag.id}, :remote => true, :class => 'next' %>
<%= link_to_previous_page @bulletins, 'Previous Page', :params => {:controller => 'widget/bulletins', :action => 'reload_bulletins', :part_id => params[:part_id], :tag_id => [@selected_tag.id]}, :remote => true, :class => 'previous' %>
<%= link_to_next_page @bulletins, 'Next Page', :params => {:controller => 'widget/bulletins', :action => 'reload_bulletins', :part_id => params[:part_id], :tag_id => [@selected_tag.id]}, :remote => true, :class => 'next' %>
</div>

View File

@ -1,3 +1,3 @@
<li>
<%= link_to tag.name, panel_announcement_widget_bulletins_and_web_links_path(:id => tag.id), :remote => true, :class => ('active' if tag.eql?(@selected_tag)) %>
<%= link_to tag.name, panel_announcement_widget_bulletins_and_web_links_path(:inner=>true, :id => [tag.id], :part_id=>params[:part_id]), :remote => true, :class => ('active' if tag.eql?(@selected_tag)) %>
</li>

View File

@ -5,6 +5,6 @@
<% end %>
<div class='pagination'>
<%= link_to_previous_page @web_links, 'Previous Page', :params => {:controller => 'widget/bulletins', :action => 'reload_web_links', :tag_id => @selected_tag.id}, :remote => true, :class => 'previous' %>
<%= link_to_next_page @web_links, 'Next Page', :params => {:controller => 'widget/bulletins', :action => 'reload_web_links', :tag_id => @selected_tag.id}, :remote => true, :class => 'next' %>
<%= link_to_previous_page @web_links, 'Previous Page', :params => {:controller => 'widget/bulletins', :action => 'reload_web_links', :part_id => params[:part_id], :tag_id => @selected_tag.id}, :remote => true, :class => 'previous' %>
<%= link_to_next_page @web_links, 'Next Page', :params => {:controller => 'widget/bulletins', :action => 'reload_web_links', :part_id => params[:part_id], :tag_id => @selected_tag.id}, :remote => true, :class => 'next' %>
</div>

View File

@ -0,0 +1,36 @@
<div class="mega_tab_block">
<div class="tag_block">
<ul id='bulletins_web_links_tags' class="tag_list">
<%= render :partial => 'tag', :collection => @tags %>
</ul>
</div>
<div class="news_block">
<h3 class="news_title2">
<%#= link_to t("announcement.bulletins"), panel_announcement_front_end_bulletins_path, :class => 'more' %>
<%= link_to @title, panel_announcement_front_end_bulletins_path, :class => 'more' %>
</h3>
<ul id='bulletins_web_links_bulletins' class="news_list">
<%= render 'bulletins' if @bulletins %>
</ul>
</div>
<% if @part.widget_style == 'bulletins_and_web_links' %>
<div class="links_block">
<h3 class="links_title"><%= t(:related_links) %></h3>
<ul id='bulletins_web_links_web_links' class="links_list">
<%= render 'web_links' if @web_links %>
</ul>
</div>
<% end %>
</div>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "news_link" %>
<% end %>
<%= stylesheet_link_tag "announcement/bulletins_and_web_links" %>

View File

@ -0,0 +1,3 @@
$('#bulletins_web_links_tags').html("<%= j render :partial => 'tag', :collection => @tags %>")
$('#bulletins_web_links_bulletins').html("<%= j render 'bulletins' if @bulletins %>")
$('#bulletins_web_links_web_links').html("<%= j render 'web_links' if @web_links %>")

View File

@ -35,6 +35,6 @@ en:
update_bulletin_category_success: Update Category Successfully
url: URL
widget:
bulletins_and_web_links: Bulletins and Web Resources
bulletins_and_web_links: Differential Nav.
index: Index
search: Search

View File

@ -35,6 +35,6 @@ zh_tw:
update_bulletin_category_success: 更新類別成功
url: 連結位置
widget:
bulletins_and_web_links: 索引
bulletins_and_web_links: 分眾頁籤
index: 索引
search: 搜尋

View File

@ -29,8 +29,8 @@ module Announcement
widgets do
default_widget do
sorting 'desc(:postdate)'
query 'Bulletin.available_for_lang(I18n.locale).any_of( {deadline: nil,:postdate.lte => Time.now} , {:deadline.gte => Time.now,:postdate.lte => Time.now} )'
sorting 'desc(:is_top, :postdate)'
query 'Bulletin.can_display.available_for_lang(I18n.locale).any_of( {deadline: nil,:postdate.lte => Time.now} , {:deadline.gte => Time.now,:postdate.lte => Time.now} )'
enable ["typeA","typeB_style3","typeC"]
image :image
field :postdate
@ -52,6 +52,11 @@ module Announcement
widget_i18n "announcement.widget.search"
end
customize_widget "bulletins_and_web_links" do
widget_i18n "announcement.widget.bulletins_and_web_links"
style ["bulletins_and_links","bulletins_only"]
end
# item "index","announcement.widget.index",:default_template=>true,:fields=>["title","category","postdate"]
# item "bulletins_and_web_links","announcement.widget.bulletins_and_web_links"
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -9,15 +9,38 @@ class Panel::Gallery::Widget::AlbumsController < OrbitWidgetController
@album = GalleryAlbum.find(@part.widget_options['album_id']) rescue nil
@album_images = @album.gallery_images if @album
@settings = {"vertical"=>vertical,"horizontal"=>horizontal} #[note] horizontal has it's limitation from 2 to 6
@class = "c" + @settings["horizontal"].to_s
@total = @settings["vertical"] * @settings["horizontal"]
@rnd = Random.new
@images = []
for i in 0..@total-1
image = @album_images[@rnd.rand(0...@album_images.count)]
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url}
@images << values
if @album_images.count > @total
@randoms = []
until @randoms.count == @total do
r = @rnd.rand(0...@album_images.count)
if !@randoms.include?r
@randoms << r
image = @album_images[r]
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url}
@images << values
end
end
elsif @album_images.count == @total
@album_images.each do |image|
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url}
@images << values
end
else
@album_images.each do |image|
values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url}
@images << values
end
until @images.count == @total do
values = {"show_link"=>"javascript:void(0);","thumb"=>"assets/gallery/nodata.jpg"}
@images << values
end
end
end

View File

@ -0,0 +1,36 @@
class Panel::Location::BackEnd::LocationCategoriesController < OrbitBackendController
def index
@categorylist = LocationCategory.all
@new_category = LocationCategory.new
end
def create
@category = LocationCategory.new(params[:location_category])
@category.save!
respond_to do |h|
h.js
end
end
def edit
@category = LocationCategory.find(params[:id])
render :layout => false
end
def update
@category = LocationCategory.find(params[:id])
@category.update_attributes(params[:location_category])
respond_to do |h|
h.js
end
end
def destroy
@category = LocationCategory.find(params['id'])
@category.delete
render :json=>{"success"=>"true"}.to_json
end
end

View File

@ -14,7 +14,6 @@ class Panel::Location::BackEnd::LocationsController < OrbitBackendController
def new
@location_info = LocationInfo.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @location }

View File

@ -8,4 +8,6 @@ class Location
field :description
field :longitude, type: Float
field :latitude, type: Float
belongs_to :location_category
end

View File

@ -0,0 +1,14 @@
class LocationCategory
include Mongoid::Document
include Mongoid::Timestamps
# include OrbitCoreLib::ObjectAuthable
# ObjectAuthTitlesOptions = %W{new_album}
# APP_NAME = "album"
field :name, localize: true
has_many :location_infos, :autosave => true, :dependent => :destroy
end

View File

@ -9,6 +9,8 @@ class LocationInfo
field :longitude, type: Float
field :latitude, type: Float
belongs_to :location_category
validates :file, presence: true
validates :longitude,
numericality: { less_than_or_equal_to: 180.0, greater_than_or_equal_to: -180.0 },

View File

@ -0,0 +1,13 @@
<div class="tag clear">
<div class="tagitem">
<i class="icon-folder-close"></i>
<% @site_valid_locales.each do |locale| %>
<span class="value" for="<%= locale %>"><%= category.name_translations[locale] rescue nil %> </span>
<% end %>
</div>
<div class="action">
<%= link_to(t(:delete_), panel_location_back_end_location_category_path(category), :method => :delete, :confirm => t("sure?"), :remote => true, :class => "delete") %>
<%= link_to(t(:edit), edit_panel_location_back_end_location_category_path(category), :remote => true, :class => "edit") %>
<%#= show_gallery_category_permission_link(category) %>
</div>
</div>

View File

@ -0,0 +1,2 @@
var dom = $("<%= j render :partial => 'category', :object => @category %>");
$("div#tags").append(dom);

View File

@ -0,0 +1,10 @@
<%= form_for @category, :url => panel_location_back_end_location_category_path(@category), :remote => true do |f| %>
<%= f.fields_for :name_translations do |name| %>
<% @site_valid_locales.each do |locale| %>
<%= label_tag(locale,t("location.new_category")+"["+I18nVariable.from_locale(locale)+"]") %>
<%= name.text_field locale, :value =>(@category.name_translations[locale]) %>
<% end %>
<% end %>
<%= f.submit "Save", :class=> "btn btn-primary temp_save_btn" %>
<a href="#" class="btn btn-primary" id="temp_cancel_btn" onclick="return false;"><%= I18n.t(:cancel) %></a>
<% end %>

View File

@ -0,0 +1,41 @@
<div id="tags" class="clear">
<%= render :partial => 'category', :collection => @categorylist %>
</div>
<div class="form-actions form-fixed form-inline pagination-right">
<%= form_for @new_category, :url => {:action => "create"}, :remote => true do |f| %>
<%= f.fields_for :name_translations do |name| %>
<% @site_valid_locales.each do |locale| %>
<%= label_tag(locale,t("location.new_category")+"["+I18nVariable.from_locale(locale)+"]") %>
<%= name.text_field locale %>
<% end %>
<% end %>
<%= f.submit "Save", :class=> "btn btn-primary" %>
<% end %>
</div>
<script type="text/javascript">
var deleteCategory = function(a){
var parent = a.parent().parent();
parent.hide("slide",function(){parent.remove();})
}
var parent;
var editCategory = function(a,data){
parent = a.parent().parent();
var parenthtml = parent.html();
var tempdom = $("<div class='tagitem'></div>");
tempdom.append(data);
parent.html(tempdom);
tempdom.find("a#temp_cancel_btn").click(function(){
parent.html(parenthtml);
})
}
$(document).ready(function(){
$("#tags div.action a.delete").live('ajax:success', function(){
deleteCategory($(this));
})
$("#tags div.action a.edit").live('ajax:success',function(evt, data, status, xhr){
editCategory($(this),data);
})
})
</script>

View File

@ -0,0 +1,2 @@
var dom = $("<%= j render :partial => 'category', :object => @category %>");
parent.html(dom.html());

View File

@ -9,6 +9,12 @@
<% end %>
</div>
</div>
<div class="control-group">
<label class="control-label" for=""><%= t "category" %></label>
<div class="controls">
<%= f.select(:location_category_id, LocationCategory.all.collect {|p| [ p.name, p.id ] },{:prompt => t("location.select_category")},:class => "validate input-xlarge") %>
</div>
</div>
<div class="control-group">
<label class="control-label" for=""><%= t 'picture' %></label>
<div class="controls">
@ -20,7 +26,7 @@
<label class="control-label" for=""><%= t 'coordinates' %></label>
<div class="controls">
<%= f.text_field :longitude, :class=>"span2", :placeholder => "Longitude" %>
<%= f.text_field :latitude, :class=>"span2", :placeholder => "Langitude" %>
<%= f.text_field :latitude, :class=>"span2", :placeholder => "Lantitude" %>
</div>
</div>
<div class="control-group">

View File

@ -1,3 +1,3 @@
<%= form_for @location_info, :url=> panel_location_back_end_locations_path, :html => { :class=>"form-horizontal"} do |f| %>
<%= form_for @location_info, :url=> panel_location_back_end_locations_path, :html => { :class=>"form-horizontal",:multipart => true} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>

View File

@ -1,3 +1,6 @@
en:
location:
location: Location
location: Location
locations: Locations
new_category: "New Category"
save: Save
select_category: "Select Category"

View File

@ -6,6 +6,7 @@ Rails.application.routes.draw do
match "locations/get_locations" => "locations#get_locations"
resources :locations
resources :location_categories
end
end
end

View File

@ -1,6 +1,6 @@
module Location
OrbitApp.registration "Location",:type=> 'ModuleApp' do
module_label 'location.location'
module_label 'locations'
base_url File.expand_path File.dirname(__FILE__)
# personal_plugin :enable => true,:path=>"panel/location/plugin/profile",:i18n=>'admin.location'
@ -32,12 +32,19 @@ module Location
# end
side_bar do
head_label_i18n 'location.location',:icon_class=>"icons-location"
head_label_i18n 'locations',:icon_class=>"icons-location"
available_for [:admin,:guest,:manager,:sub_manager]
active_for_controllers ({:private=>['locations']})
head_link_path "panel_location_back_end_locations_path"
context_link 'categories',
:link_path=>"panel_location_back_end_location_categories_path" ,
:priority=>1,
:active_for_action=>{:localtion_categories=>:index},
:available_for => [:manager]
end
end
end