Compare commits

...

6 Commits

Author SHA1 Message Date
iCross 11e9f5d7cd Fix announcement versioning
Conflicts:

	Gemfile
2013-06-26 21:50:03 +08:00
iCross 2eaa44c279 announcement module: versioning 2013-06-08 01:52:49 +08:00
iCross fe7393b9e2 Merge branch 'lukas/picked_archive' into development 2013-06-07 22:44:26 +08:00
iCross f12e5b8768 archive module: add sort to frontend module
Conflicts:

	vendor/built_in_modules/archive/app/controllers/panel/archive/front_end/archive_files_controller.rb
	vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.html.erb
2013-06-07 22:43:15 +08:00
iCross 57e1ef7bae Merge branch 'lukas/picked_ques' into development 2013-06-07 18:48:06 +08:00
iCross 642d0ed239 survey module: ensure the commit 2013-06-07 18:47:20 +08:00
21 changed files with 195 additions and 71 deletions

View File

@ -64,6 +64,8 @@ gem 'rmmseg-cpp-huacnlee', '0.2.9'
gem 'redis-namespace'
gem 'redis-search'
gem 'syslog-logger'
gem "recaptcha", :require => "recaptcha/rails"
gem 'mongoid-versioning'
# Gems used only for assets and not required
# in production environments by default.

View File

@ -0,0 +1,12 @@
class Panel::Announcement::BackEnd::BulletinVersionsController < OrbitBackendController
include OrbitControllerLib::DivisionForDisable
def index
@bulletin = Bulletin.find(params[:bulletin_id])
end
def show
@bulletin = Bulletin.find(params[:bulletin_id])
@version = @bulletin.versions.where(version: params[:id]).first
end
end

View File

@ -6,6 +6,7 @@ class Bulletin
include Mongoid::MultiParameterAttributes
include Sunspot::Mongo
include Impressionist::Impressionable
include Mongoid::Versioning
BelongsToCategory = :bulletin_category
include OrbitCoreLib::BelongsToCategoryMayDisable

View File

@ -0,0 +1,25 @@
<table class="table main-list">
<thead>
<tr>
<th class="span7 select"><%= t(:name) %></th>
<th class="span1-2"><%= t(:version) %></th>
<th class="span1-2"><%= t(:update_at) %></th>
<th class="span1-2"><%= t(:last_modified) %></th>
</tr>
</thead>
<tbody>
<% @bulletin.versions.reverse.each do |version| %>
<tr class="with_action">
<td>
<%= version.title %>
<div class="quick-edit">
<%= link_to '顯示', panel_announcement_back_end_bulletin_bulletin_version_path(@bulletin, version.version) %>
</div>
</td>
<td><%= version.version %></td>
<td><%= display_date(version.updated_at) %></td>
<td><%= User.from_id(version.update_user_id).name rescue ''%></td>
</tr>
<% end %>
</tbody>
</table>

View File

@ -0,0 +1,33 @@
<ul>
<li>
<b><%= t(:name) %></b>
<%= @version.title %>
</li>
<li>
<b><%= t(:subtitle) %></b>
<%= @version.subtitle %>
</li>
<li>
<b><%= t(:text) %></b>
<%= simple_format @version.text %>
</li>
<li>
<b><%= t(:deadline) %></b>
<%= display_date(@version.deadline) if @version.deadline %>
</li>
<li>
<b><%= t(:postdate) %></b>
<%= display_date(@version.postdate) if @version.postdate %>
</li>
<li>
<b><%= t(:posted_by) %></b>
<%= User.find(@version.create_user_id).name %>
</li>
<li>
<b><%= t(:last_modified) %></b>
<%= display_date(@version.updated_at) %>
</li>
</ul>
<%= link_back %>

View File

@ -61,6 +61,7 @@
</ul>
</div>
</td>
<td><%= link_to bulletin.version, panel_announcement_back_end_bulletin_bulletin_versions_path(bulletin) %></td>
<td><%= display_date_time(bulletin.postdate) %></td>
<td><%= (bulletin.deadline) ? display_date_time(bulletin.deadline ): t(:no_deadline) %></td>
<td>

View File

@ -7,6 +7,7 @@
<th class="span1-2"></th>
<th class="span1-2"></th>
<th class="span1-2"></th>
<th class="span1-2"></th>
<th class="span1-3"></th>
</tr>
</thead>

View File

@ -2,6 +2,7 @@
['status', ['is_top', 'is_hot', 'is_hidden', 'is_pending', 'is_checked', 'is_rejected'], 'span1-2', :status],
['category', 'bulletin_category', 'span1-2', :category],
['title', 'title','span7', :title],
['version', 'version', 'span1-2', :version],
['start_date', 'postdate', 'span1-2', :start_date],
['end_date', 'deadline', 'span1-2', :end_date],
['tags', 'tags', 'span1-2', :tags],

View File

@ -23,6 +23,8 @@ Rails.application.routes.draw do
end
match "file_quick_add/:bulletin_id" => "bulletins#file_quick_add" ,:as => :file_quick_add
match "file_quick_edit/:bulletin_id" => "bulletins#file_quick_edit" ,:as => :file_quick_edit
resources :bulletin_versions
end
resources :bulletin_categorys do

View File

@ -1,4 +1,5 @@
class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController
include AdminHelper
def initialize
super
@ -30,27 +31,26 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController
@archive_file_categorys = ArchiveFileCategory.all
# @archive_files = ArchiveFile.where( :is_hidden => false ).desc(:is_top).page(params[:page]).per(@page_num)
if params[:search_query]
get_search_result
@archive_files = ArchiveFile.can_display.where(:archive_file_category_id.in => @archive_file_categorys.collect{|t| t.id}).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
else
if !params[:category_id].blank? && !params[:tag_id].blank?
@archive_files = @archive_files.can_display.where(:archive_file_category_id.in => params[:category_id], :tagged_ids.in => params[:tag_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
@archive_files = @archive_files.default_sort(params[:sort]).can_display.where(:archive_file_category_id.in => params[:category_id], :tagged_ids.in => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num)
@current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
elsif !params[:category_id].blank?
@archive_files = ArchiveFile.can_display.where(:archive_file_category_id.in => params[:category_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
@archive_files = ArchiveFile.default_sort(params[:sort]).can_display.where(:archive_file_category_id.in => params[:category_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num)
@current_category = ArchiveFileCategory.from_id(params[:category_id]) rescue nil
elsif !params[:tag_id].blank?
@archive_files = ArchiveFile.can_display.where(:tagged_ids.in => params[:tag_id]).desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
@archive_files = ArchiveFile.default_sort(params[:sort]).can_display.where(:tagged_ids.in => params[:tag_id]).desc( :is_top ).page( params[:page_main] ).per(@page_num)
else
@archive_files = ArchiveFile.can_display.desc( :is_top, :created_at ).page( params[:page_main] ).per(@page_num)
end
@archive_files = ArchiveFile.default_sort(params[:sort]).can_display.desc( :is_top ).page( params[:page_main] ).per(@page_num)
end
get_categorys
if params[:sort]
@archive_files = get_sorted_and_filtered('archive_file', nil, @archive_files)
end
end
def show

View File

@ -0,0 +1,56 @@
<% # encoding: utf-8 %>
<div class="o-archives layout-table">
<table>
<thead>
<tr>
<th class="column-ctrl col-title"><%= sortable(:title, t("archive.Title"))%></th>
<th class="column-ctrl col-file"><%= t("archive.Files")%></th>
<th class="column-ctrl col-category"><%= sortable(:archive_file_category, t("archive.Category"))%></th>
</tr>
</thead>
<tbody>
<% @archive_files.each_with_index do |post,i| %>
<tr <% if ( (i + 1) % 2 ) == 0 %> class="even" <% end %>>
<td><div class="o-archives-title"><%= post.title %></div></td>
<td>
<div class="o-archives-list-item">
<% if !post.archive_file_multiples.blank? %>
<ol>
<% post.archive_file_multiples.asc(:_id).each do | afile | %>
<% if afile.file.file and afile.choose_lang_display(I18n.locale.to_s) %>
<li>
<%= link_to afile.file_title, afile.file.url, {:target => '_blank', :title => afile.file_title, :class => "o-archives-file"} %>
<%= post.get_file_icon(afile.file.url) %>
</li>
<% end %>
<% end %>
</ol>
<% end %>
</div>
</td>
<td><div class="o-archives-category">
<%= post.archive_file_category.title %>
</div></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<%= paginate @archive_files, :param_name => :page_main, :params => {:inner => 'false'} %>
<%= stylesheet_link_tag "archive/archives" %>

View File

@ -1,57 +1,9 @@
<% # encoding: utf-8 %>
<%= stylesheet_link_tag "default_widget" %>
<script type='text/javascript' src='/assets/jquery.mu.image.resize.js'></script>
<script type='text/javascript' src='/assets/jquery.mu.image.resize.degsin.js'></script>
<%= render :partial => 'shared/search_header',:locals=>{:items=>@archive_files} %>
<div class="o-archives layout-table">
<table>
<thead>
<tr>
<th class="column-ctrl col-title"><%= t("archive.Title")%></th>
<th class="column-ctrl col-file"><%= t("archive.Files")%></th>
<th class="column-ctrl col-category"><%= t("archive.Category")%></th>
</tr>
</thead>
<tbody>
<% @archive_files.each_with_index do |post,i| %>
<tr <% if i.even?%> class="even" <% end %>>
<td><div class="o-archives-title"><%= post.title %></div></td>
<td>
<div class="o-archives-list-item">
<% if !post.archive_file_multiples.blank? %>
<ol>
<% post.archive_file_multiples.asc(:_id).each do | afile | %>
<% if afile.file.file and afile.choose_lang_display(I18n.locale.to_s) %>
<li>
<%= link_to afile.file_title, afile.file.url, {:target => '_blank', :title => afile.file_title, :class => "o-archives-file"} %>
<%= post.get_file_icon(afile.file.url) %>
</li>
<% end %>
<% end %>
</ol>
<% end %>
<div id="archive_file_widget">
<%= render 'index' %>
</div>
</td>
<td><div class="o-archives-category">
<%= post.archive_file_category.title %>
</div></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<%= paginate @archive_files, :param_name => :page_main, :params => {:inner => 'false'} %>
<%= stylesheet_link_tag "archive/archives" %>

View File

@ -0,0 +1 @@
$('#archive_file_widget').html("<%= j render 'index' %>")

View File

@ -17,6 +17,8 @@ class SurveyQuestion
# allow custom answer option
field :custom_option, :type => Boolean
field :sequence, :type => Integer, :default => 0
belongs_to :survey
embeds_many :survey_question_options
embeds_many :survey_question_radiogroups
@ -24,6 +26,8 @@ class SurveyQuestion
accepts_nested_attributes_for :survey_question_options, :allow_destroy => true
accepts_nested_attributes_for :survey_question_radiogroups, :allow_destroy => true
default_scope asc(:sequence)
def jumpable?
case type
when SurveyQuestion::Radio, SurveyQuestion::Select

View File

@ -103,7 +103,31 @@
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "survey_form" %>
<script>
var refresh_sequence_input = function() {
var sequence = 0;
$('.sequence input').each(function(){
sequence += 1;
$(this).val(sequence);
});
}
$(document).ready(function() {
$('.sequence .move-up').bind('click', function(){
$survey_question_item = $(this).parents('.survey_question_item')
$prev = $survey_question_item.prev();
$survey_question_item.insertBefore($prev);
refresh_sequence_input();
return false;
});
$('.sequence .move-down').bind('click', function(){
$survey_question_item = $(this).parents('.survey_question_item')
$next = $survey_question_item.next();
$survey_question_item.insertAfter($next);
refresh_sequence_input();
return false;
});
refresh_sequence_input();
$('#add_survey_question a.add').live('click', function(){
var new_id = $(this).prev().attr('value');

View File

@ -0,0 +1 @@
alert("<%= @survey_answer_error %>");

View File

@ -0,0 +1,2 @@
alert("<%= t('survey.answer_success')%>");
window.location.href = "<%= root_path %>";

View File

@ -0,0 +1 @@
<%= render 'answer_error' %>

View File

@ -0,0 +1 @@
<%= render 'answer_success' %>

View File

@ -53,6 +53,7 @@ en:
survey_question:
title: Question
description: Description
sequence: Sequence
type: Type
is_required: Is Required
required: Required
@ -74,3 +75,5 @@ en:
move_up: Move up
move_down: Move down

View File

@ -55,6 +55,7 @@ zh_tw:
survey_question:
title: 題目
description: 說明
sequence: 順序
type: 作答方式
is_required: 設為必填
required: 必填