Backend finished

This commit is contained in:
manson 2014-07-01 18:19:07 +08:00
parent 73968d9ed8
commit 49cef0ab7a
39 changed files with 1250 additions and 5 deletions

View File

@ -0,0 +1,41 @@
class Admin::ConferenceAuthorTypesController < OrbitAdminController
def new
@author_type = ConferenceAuthorType.new
@url = admin_conference_author_types_path(@author_type)
render :layout=>false
end
def create
@author_type = ConferenceAuthorType.new(author_type_params)
@author_type.save
@author_types = ConferenceAuthorType.all
render :partial=>'list', :layout=>false
end
def edit
@author_type = ConferenceAuthorType.find(params[:id])
@url = admin_conference_author_type_path(@author_type)
render :layout=>false
end
def update
@author_type = ConferenceAuthorType.find(params[:id])
@author_type.update_attributes(author_type_params)
@author_type.save
@author_types = ConferenceAuthorType.all
render :partial=>'list', :layout=>false
end
def destroy
author_type = ConferenceAuthorType.find(params[:id])
author_type.destroy
@author_types = ConferenceAuthorType.all
render :partial=>'list', :layout=>false
end
private
def author_type_params
params.require(:conference_author_type).permit! rescue nil
end
end

View File

@ -0,0 +1,41 @@
class Admin::ConferencePaperLevelsController < OrbitAdminController
def new
@paper_level = ConferencePaperLevel.new
@url = admin_conference_paper_levels_path(@paper_level)
render :layout=>false
end
def create
@paper_level = ConferencePaperLevel.new(paper_level_params)
@paper_level.save
@paper_levels = ConferencePaperLevel.all
render :partial=>'index', :layout=>false
end
def edit
@paper_level = ConferencePaperLevel.find(params[:id])
@url = admin_conference_paper_level_path(@paper_level)
render :layout=>false
end
def update
@paper_level = ConferencePaperLevel.find(params[:id])
@paper_level.update_attributes(paper_level_params)
@paper_level.save
@paper_levels = ConferencePaperLevel.all
render :partial=>'index', :layout=>false
end
def destroy
paper_level = ConferencePaperLevel.find(params[:id])
paper_level.destroy
@paper_levels = ConferencePaperLevel.all
render :partial=>'index', :layout=>false
end
private
def paper_level_params
params.require(:conference_paper_level).permit! rescue nil
end
end

View File

@ -0,0 +1,41 @@
class Admin::ConferencePaperTypesController < OrbitAdminController
def new
@paper_type = ConferencePaperType.new
@url = admin_conference_paper_types_path(@paper_type)
render :layout=>false
end
def create
@paper_type = ConferencePaperType.new(paper_type_params)
@paper_type.save
@paper_types = ConferencePaperType.all
render :partial=>'index', :layout=>false
end
def edit
@paper_type = ConferencePaperType.find(params[:id])
@url = admin_conference_paper_type_path(@paper_type)
render :layout=>false
end
def update
@paper_type = ConferencePaperType.find(params[:id])
@paper_type.update_attributes(paper_type_params)
@paper_type.save
@paper_types = ConferencePaperType.all
render :partial=>'index', :layout=>false
end
def destroy
paper_type = ConferencePaperType.find(params[:id])
paper_type.destroy
@paper_types = ConferencePaperType.all
render :partial=>'index', :layout=>false
end
private
def paper_type_params
params.require(:conference_paper_type).permit! rescue nil
end
end

View File

@ -0,0 +1,86 @@
class Admin::WritingConferencesController < OrbitMemberController
layout "member_plugin"
before_action :set_plugin
before_action :get_settings,:only => [:new, :edit, :setting]
def index
@writing_conferences = WritingConference.all
end
def new
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
@writing_conference = WritingConference.new
end
def create
@member = MemberProfile.find(conference_params['member_profile_id']) rescue nil
@writing_conference = WritingConference.new(conference_params)
@writing_conference.save
redirect_to '/admin/members/'+@member.to_param+'/WritingConference'
end
def edit
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
@writing_conference = WritingConference.find(params[:id])
end
def update
@member = MemberProfile.find(conference_params['member_profile_id']) rescue nil
@writing_conference = WritingConference.find(params[:id])
@writing_conference.update_attributes(conference_params)
@writing_conference.save
redirect_to '/admin/members/'+@member.to_param+'/WritingConference'
end
def toggle_hide
if params[:ids]
@writing_conferences = WritingConference.any_in(_id: params[:ids])
@writing_conferences.each do |writing_conference|
writing_conference.is_hidden = params[:disable]
writing_conference.save
end
end
render json: {"success"=>true}
end
def setting
end
def frontend_setting
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
@intro = WritingConferenceIntro.find_by(:member_profile_id=>@member.id) rescue nil
@intro = @intro.nil? ? WritingConferenceIntro.new({:member_profile_id=>@member.id}) : @intro
end
def update_frontend_setting
@member = MemberProfile.find(intro_params['member_profile_id']) rescue nil
@intro = WritingConferenceIntro.find_by(:member_profile_id=>@member.id) rescue nil
@intro = @intro.nil? ? WritingConferenceIntro.new({:member_profile_id=>@member.id}) : @intro
@intro.update_attributes(intro_params)
@intro.save
redirect_to '/admin/members/'+@member.to_param+'/WritingConference'
end
def get_settings
@paper_types = ConferencePaperType.all
@paper_levels = ConferencePaperLevel.all
@author_types = ConferenceAuthorType.all
end
def set_plugin
@plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'WritingConference'}.first
end
private
def conference_params
params.require(:writing_conference).permit! rescue nil
end
def intro_params
params.require(:writing_conference_intro).permit! rescue nil
end
end

View File

@ -0,0 +1,6 @@
class WritingConferencesController
def show
writing_conference = WritingConference.find_by(:uid=>param[:uid])
end
end

View File

@ -0,0 +1,11 @@
# encoding: utf-8
class ConferenceAuthorType
include Mongoid::Document
include Mongoid::Timestamps
field :title, localize: true
has_and_belongs_to_many :writing_conferences
end

View File

@ -0,0 +1,11 @@
# encoding: utf-8
class ConferencePaperLevel
include Mongoid::Document
include Mongoid::Timestamps
field :title, localize: true
has_and_belongs_to_many :writing_conferences
end

View File

@ -0,0 +1,11 @@
# encoding: utf-8
class ConferencePaperType
include Mongoid::Document
include Mongoid::Timestamps
field :title, localize: true
has_and_belongs_to_many :writing_conferences
end

View File

@ -0,0 +1,95 @@
class WritingConference
include Mongoid::Document
include Mongoid::Timestamps
include OrbitModel::Status
include OrbitTag::Taggable
include Slug
field :paper_title, as: :slug_title, localize: true
field :conference_title, localize: true
field :authors, localize: true
field :location, localize: true
field :sponsor, localize: true
field :year
field :language
field :period_start_date, :type => Date
field :period_end_date, :type => Date
field :keywords
field :abstract
field :publication_date, :type => Date
field :url
field :note
field :create_user_id, :type => BSON::ObjectId
field :update_user_id, :type => BSON::ObjectId
field :isbn
field :isi_number
belongs_to :member_profile
has_and_belongs_to_many :conference_author_types
has_and_belongs_to_many :conference_paper_types
has_and_belongs_to_many :conference_paper_levels
has_many :writing_conference_files, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :writing_conference_files, :allow_destroy => true
before_validation :add_http
def create_link
title = []
title << self.authors if self.authors.present?
if !self.publication_date.nil?
pd = self.publication_date.strftime("%Y-%m-%d").split('-')
title << pd[0]
end
title << self.paper_title if self.paper_title.present?
title << self.conference_title if self.conference_title.present?
title << self.location if self.location.present?
title << "#{period_start_date}-#{period_end_date}" if (self.period_start_date.present? && self.period_end_date.present?)
title.join(', ')
end
def values_for_view
attribute_values = self.attributes.select{|k,v| v if (k.in?(
[ "year",
"language",
"period_start_date",
"period_end_date",
"publication_date",
"keywords",
"abstract",
"url",
"note",
"isbn",
"isi_number"]) && v.present?)}
localized_fields = {
"paper_title" => self.paper_title,
"conference_title" => self.conference_title,
"location"=>self.location,
"sponsor"=>self.sponsor}
authors = {"authors" => self.authors}
files = Hash.new
# self.writing_conference_files.each do |f, index|
# title = f.title.blank? ? File.basename(f.file.path) : f.title
# end
values = [localized_fields, attribute_values, authors,files]
values.inject(&:merge)
end
protected
def add_http
unless self.url.blank? || self.url[/^http:\/\//] || self.url[/^https:\/\//]
self.url = 'http://' + self.url
end
end
end

View File

@ -0,0 +1,14 @@
class WritingConferenceFile
include Mongoid::Document
include Mongoid::Timestamps
mount_uploader :file, AssetUploader
field :description, localize: true
field :should_destroy, :type => Boolean
field :title, localize: true
belongs_to :writing_conference
end

View File

@ -0,0 +1,10 @@
class WritingConferenceIntro
include Mongoid::Document
include Mongoid::Timestamps
belongs_to :member_profile
field :text, localize: true
field :display_intro, :type => Boolean, :default => true
field :display_conference_list, :type => Boolean, :default => true
end

View File

@ -0,0 +1,24 @@
<%= form_for(@author_type, :html =>{:class=>"form-horizontal", :style=>"margin: 0;"}, :remote => true, :url => @url ) do |f| %>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel"><%= t("personal_conference.author_type") %></h3>
</div>
<div class="modal-body">
<%= f.fields_for :title_translations do |f| %>
<% @site_in_use_locales.each do |locale| %>
<div class="control-group">
<%= label_tag t(locale), t(locale), :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :value => (@author_type.title_translations[locale] rescue nil) %>
</div>
</div>
<% end %>
<% end %>
</div>
<div class="modal-footer">
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
</div>
<% end %>

View File

@ -0,0 +1,2 @@
$('#author_types tbody').html("<%= j render :partial => '/admin/writing_conferences/list_author_type', :collection => @author_types %>");
$('#author_type_modal').modal('hide');

View File

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

View File

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

View File

@ -0,0 +1,24 @@
<%= form_for(@paper_level, :html =>{:class=>"form-horizontal", :style=>"margin: 0;"}, :remote => true, :url => @url ) do |f| %>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel"><%= t("personal_conference.paper_level") %></h3>
</div>
<div class="modal-body">
<%= f.fields_for :title_translations do |f| %>
<% @site_in_use_locales.each do |locale| %>
<div class="control-group">
<%= label_tag t(locale), t(locale), :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :value => (@paper_level.title_translations[locale] rescue nil) %>
</div>
</div>
<% end %>
<% end %>
</div>
<div class="modal-footer">
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
</div>
<% end %>

View File

@ -0,0 +1,2 @@
$('#paper_levels tbody').html("<%= j render :partial => '/admin/writing_conferences/list_paper_level', :collection => @paper_levels %>");
$('#paper_level_modal').modal('hide');

View File

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

View File

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

View File

@ -0,0 +1,24 @@
<%= form_for(@paper_type, :html =>{:class=>"form-horizontal", :style=>"margin: 0;"}, :remote => true, :url => @url ) do |f| %>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel"><%= t("personal_conference.paper_type") %></h3>
</div>
<div class="modal-body">
<%= f.fields_for :title_translations do |f| %>
<% @site_in_use_locales.each do |locale| %>
<div class="control-group">
<%= label_tag t(locale), t(locale), :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :value => (@paper_type.title_translations[locale] rescue nil) %>
</div>
</div>
<% end %>
<% end %>
</div>
<div class="modal-footer">
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
</div>
<% end %>

View File

@ -0,0 +1,2 @@
$('#paper_types tbody').html("<%= j render :partial => '/admin/writing_conferences/list_paper_type', :collection => @paper_types %>");
$('#paper_type_modal').modal('hide');

View File

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

View File

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

View File

@ -0,0 +1,339 @@
<% # encoding: utf-8 %>
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<% end %>
<!-- Input Area -->
<div class="input-area">
<!-- Module Tabs -->
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li></li>
<li class="active">
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
</li>
<li>
<a href="#status" data-toggle="tab"><%= t(:status) %></a>
</li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<div class="control-group">
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
<div class="controls">
<%= @member.name rescue ''%>
<%= f.hidden_field :member_profile_id, :value => @member.id %>
</div>
</div>
<!-- year -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_conference.year") %></label>
<div class="controls">
<%= select_year((@writing_conference.year ? @writing_conference.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'writing_conference[year]',:class => 'span1'} ) %>
</div>
</div>
<!-- paper_type -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_conference.paper_type") %></label>
<div class="controls">
<% @paper_types.each do |paper_type| %>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= check_box_tag 'writing_conference[conference_paper_type_ids][]', paper_type.id, @writing_conference.conference_paper_type_ids.include?(paper_type.id)%>
<%= paper_type.title %>
<%= hidden_field_tag 'writing_conference[conference_paper_type_ids][]', '' %>
<% end %>
<% end %>
</div>
</div>
<!-- paper_level -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_conference.paper_level") %></label>
<div class="controls">
<% @paper_levels.each do |paper_level| %>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= check_box_tag 'writing_conference[conference_paper_level_ids][]', paper_level.id, @writing_conference.conference_paper_level_ids.include?(paper_level.id)%>
<%= paper_level.title %>
<%= hidden_field_tag 'writing_conference[conference_paper_level_ids][]', '' %>
<% end %>
<% end %>
</div>
</div>
<!-- author_type -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_conference.author_type") %></label>
<div class="controls">
<% @author_types.each do |author_type| %>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= check_box_tag 'writing_conference[conference_author_type_ids][]', author_type.id, @writing_conference.conference_author_type_ids.include?(author_type.id)%>
<%= author_type.title %>
<%= hidden_field_tag 'writing_conference[conference_author_type_ids][]', '' %>
<% end %>
<% end %>
</div>
</div>
<!-- period_start_date -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_conference.period_start_date") %></label>
<div class="controls">
<%= f.datetime_picker :period_start_date, :no_label => true, :format=>"yyyy/MM/dd" %>
</div>
</div>
<!-- period_end_date -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_conference.period_end_date") %></label>
<div class="controls">
<%= f.datetime_picker :period_end_date, :no_label => true, :format=>"yyyy/MM/dd" %>
</div>
</div>
<!-- publication_date -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_conference.publication_date") %></label>
<div class="controls">
<%= f.datetime_picker :publication_date, :no_label => true, :format=>"yyyy/MM/dd" %>
</div>
</div>
<!-- language -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_conference.language") %></label>
<div class="controls">
<select id="writing_conference_language" name="writing_conference[language]">
<% @site_in_use_locales.each do |locale| %>
<option value="<%= locale %>" <%= @writing_conference.language.eql?(locale.to_s) ? "selected" : ""%>><%= t(locale) %></option>
<% end %>
</select>
</div>
</div>
<!-- ISBN -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_conference.isbn") %></label>
<div class="controls">
<%= f.text_field :isbn %>
</div>
</div>
<!-- ISI Numebr -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_conference.isi_number") %></label>
<div class="controls">
<%= f.text_field :isi_number %>
</div>
</div>
<!-- url -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_conference.url") %></label>
<div class="controls">
<%= f.text_field :url , :class => "span6" %>
</div>
</div>
<!-- keywords -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_conference.keywords") %></label>
<div class="controls">
<%= f.text_field :keywords, :class => "span6" %>
</div>
</div>
<!-- abstract -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_conference.abstract") %></label>
<div class="controls">
<%= f.text_area :abstract, rows: 2, class: "input-block-level" %>
</div>
</div>
<!-- note -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_conference.note") %></label>
<div class="controls">
<%= f.text_area :note, rows: 2, class: "input-block-level" %>
</div>
</div>
</div>
<!-- Status Module -->
<div class="tab-pane fade" id="status">
<!-- Status -->
<div class="control-group">
<label class="control-label muted"><%= t(:status) %></label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn <%= 'active' if @writing_conference.is_hidden? %>">
<%= f.check_box :is_hidden %> <%= t(:hide) %>
</label>
</div>
</div>
</div>
</div>
<!-- Language Tabs -->
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
</li>
<% end %>
</ul>
<!-- Language -->
<div class="tab-content language-area">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<!-- paper_title-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_conference.paper_title") %></label>
<div class="controls">
<%= f.fields_for :paper_title_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_conference.paper_title"), value: (@writing_conference.paper_title_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- conference_title-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_conference.conference_title") %></label>
<div class="controls">
<%= f.fields_for :conference_title_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_conference.conference_title"), value: (@writing_conference.conference_title_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- location-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_conference.location") %></label>
<div class="controls">
<%= f.fields_for :location_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_conference.location"), value: (@writing_conference.location_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- sponsor-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_conference.sponsor") %></label>
<div class="controls">
<%= f.fields_for :sponsor_translations do |f| %>
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_conference.sponsor"), value: (@writing_conference.sponsor_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
<!-- authors-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("personal_conference.authors") %></label>
<div class="controls">
<%= f.fields_for :authors_translations do |f| %>
<%= f.text_area locale, class: "input-block-level", placeholder: t("personal_conference.authors"), value: (@writing_conference.authors_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
<% end %>
<!-- File -->
<div class="control-group">
<label class="control-label muted"><%= t(:file_) %></label>
<div class="controls">
<!-- Exist -->
<% if @writing_conference && !@writing_conference.writing_conference_files.blank? %>
<div class="exist">
<% @writing_conference.writing_conference_files.each_with_index do |archive_file_multiple, i| %>
<%= f.fields_for :writing_conference_files, archive_file_multiple do |f| %>
<%= render :partial => 'form_file', :object => archive_file_multiple, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'plugin_file_field_count', @writing_conference.writing_conference_files.count %>
<a id="add_file" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %>
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
<% content_for :page_specific_javascript do %>
<script>
$(document).ready(function() {
$('.main-forms .add-on').tooltip();
$(document).on('click', '#add_file', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_writing_conference_files", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_file', f, :writing_conference_files) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
});
formTip();
});
$(document).on('click', '.delete_file', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.remove_existing_record', function(){
if(confirm("<%= I18n.t(:sure?)%>")){
$(this).children('.should_destroy').attr('value', 1);
$(this).parents('.start-line').hide();
}
});
});
</script>
<% end %>

View File

@ -0,0 +1,55 @@
<% if form_file.new_record? %>
<div class="fileupload fileupload-new start-line" data-provides="fileupload">
<% else %>
<div class="fileupload fileupload-exist start-line" data-provides="fileupload">
<% if form_file.file.blank? %>
<%= t(:no_file) %>
<% else %>
<%= link_to content_tag(:i) + form_file.file_identifier, form_file.file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.file_identifier} %>
<% end %>
<% end %>
<div class="input-prepend input-append">
<label>
<span class="add-on btn btn-file" title='<%= t(:file_) %>'>
<i class="icons-paperclip"></i>
<%= f.file_field :file %>
</span>
<div class="uneditable-input input-medium">
<i class="icon-file fileupload-exists"></i>
<span class="fileupload-preview"><%= (form_file.new_record? || form_file.file.blank?) ? t(:select_file) : t(:change_file) %></span>
</div>
</label>
<span class="add-on icons-pencil" title='<%= t(:alternative) %>'></span>
<span class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :title_translations do |f| %>
<%= f.text_field locale, :class => "input-medium", placeholder: t(:alternative), :value => (form_file.title_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span>
<span class="add-on icons-pencil" title='<%= t(:description) %>'></span>
<span class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<span class="tab-pane fade <%= ( i == 0 ) ? "in active" : '' %> <%= locale %>">
<%= f.fields_for :description_translations do |f| %>
<%= f.text_field locale, :class => "input-medium", placeholder: t(:description), :value => (form_file.description_translations[locale] rescue nil) %>
<% end %>
</span>
<% end %>
</span>
</span>
<% if form_file.new_record? %>
<span class="delete_file add-on btn" title="<%= t(:delete_) %>">
<a class="icon-trash"></a>
</span>
<% else %>
<span class="remove_existing_record add-on btn" title="<%= t(:remove) %>">
<%= f.hidden_field :id %>
<a class="icon-remove"></a>
<%= f.hidden_field :_destroy, :value => nil, :class => 'should_destroy' %>
</span>
<% end %>
</div>
</div>

View File

@ -0,0 +1,8 @@
<tr id="<%= dom_id list_author_type %>">
<td><%= list_author_type.title %></td>
<td class="span2">
<a href="<%= edit_admin_conference_author_type_path(list_author_type) %>#author_type_modal" data-toggle="modal" data-remote="true" class="action"><%= t(:edit) %></a>
<%= link_to t(:delete_), admin_conference_author_type_path(list_author_type), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %>
</td>
</tr>

View File

@ -0,0 +1,8 @@
<tr id="<%= dom_id list_paper_level %>">
<td><%= list_paper_level.title %></td>
<td class="span2">
<a href="<%= edit_admin_conference_paper_level_path(list_paper_level) %>#paper_level_modal" data-toggle="modal" data-remote="true" class="action"><%= t(:edit) %></a>
<%= link_to t(:delete_), admin_conference_paper_level_path(list_paper_level), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %>
</td>
</tr>

View File

@ -0,0 +1,8 @@
<tr id="<%= dom_id list_paper_type %>">
<td><%= list_paper_type.title %></td>
<td class="span2">
<a href="<%= edit_admin_conference_paper_type_path(list_paper_type) %>#paper_type_modal" data-toggle="modal" data-remote="true" class="action"><%= t(:edit) %></a>
<%= link_to t(:delete_), admin_conference_paper_type_path(list_paper_type), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %>
</td>
</tr>

View File

@ -0,0 +1,15 @@
<% @writing_conferences.each do |writing_conference| %>
<tr id="<%= dom_id writing_conference %>" class="<%= writing_conference.is_hidden ? "checkHide" : "" %>">
<td><%= writing_conference.year %></td>
<td>
<%= link_to writing_conference.create_link, '', target: "blank"%>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<li><%= link_to t('edit'), '/admin/members/'+writing_conference.member_profile.to_param+'/writing_conferences/'+writing_conference.id+'/edit' %></li>
<li><%= link_to t(:delete_), admin_writing_conference_path(id: writing_conference.id, member_profile_id: writing_conference.member_profile.id), method: :delete, remote: true, data: { confirm: t('sure?') } %></li>
</ul>
</div>
</td>
<td><%= writing_conference.member_profile.name %></td>
</tr>
<% end %>

View File

@ -0,0 +1,5 @@
<%= form_for @writing_conference, url:'/admin/writing_conferences/'+@writing_conference.id.to_s, html: {class: "form-horizontal main-forms previewable"} do |f| %>
<fieldset>
<%= render partial: 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -0,0 +1,93 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/main-list" %>
<% end %>
<%= form_for(:writing_conference_intro, :url => update_frontend_setting_admin_writing_conferences_path, :method => "post", html: {class: "form-horizontal main-forms previewable"} ) do |f| %>
<fieldset>
<!-- Input Area -->
<div class="input-area">
<!-- Module Tabs -->
<div class="nav-name"><strong><%= t("module_name.personal_conference") %></strong></div>
<ul class="nav nav-pills module-nav">
<li></li>
<li class="active">
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
</li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<% if !@member.blank? %>
<div class="control-group">
<label class="control-label muted"><%= t("personal_plugins.author") %></label>
<div class="controls">
<%= @member.name rescue ''%>
<%= f.hidden_field :member_profile_id, :value => @member.id %>
</div>
</div>
<% end %>
<!-- frontend_page -->
<div class="control-group">
<label class="control-label muted"><%= t("personal_plugins.frontend_page") %></label>
<div class="controls">
<%= f.check_box :display_intro, :checked => @intro.display_intro %> <%= t("personal_plugins.brief_intro") %>
<%= f.check_box :display_conference_list, :checked => @intro.display_conference_list %> <%= t("personal_plugins.complete_list") %>
</div>
</div>
</div>
</div>
<!-- Language Tabs -->
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale) %></a>
</li>
<% end %>
</ul>
<!-- Language -->
<div class="tab-content language-area">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<!-- Content -->
<div class="control-group input-content">
<label class="control-label muted"><%= t(:content) %></label>
<div class="controls">
<div class="textarea">
<%= f.fields_for :text_translations do |f| %>
<%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@intro.text_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
</div>
</div>
<% end %>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %>
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
</fieldset>
<% end %>

View File

@ -0,0 +1,21 @@
<table class="table main-list">
<thead>
<tr>
<th class="span1"><%= t('personal_plugins.year') %></th>
<th class="span7"><%= t('module_name.personal_conference') %></th>
<th class="span1"><%= t('personal_plugins.author') %></th>
</tr>
</thead>
<tbody id="tbody_writing_conferences" class="sort-holder">
<%= render :partial => 'writing_conference', :collection => @writing_conferences %>
</tbody>
</table>
<div class="bottomnav clearfix">
<div class="action pull-right">
<%= link_to content_tag(:i, nil, :class => 'icon-cog icon-white') + t('setting'), admin_writing_conference_setting_path, :class => 'btn btn-primary pull-right' %>
<%#= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('new_'), new_admin_writing_conference_path, :class => 'btn btn-primary pull-right' %>
</div>
<div class="pagination pagination-centered">
</div>
</div>

View File

@ -0,0 +1,5 @@
<%= form_for @writing_conference, url: admin_writing_conferences_path(@writing_conference), html: {class: "form-horizontal main-forms previewable"} do |f| %>
<fieldset>
<%= render partial: 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -0,0 +1,116 @@
<style type="text/css">
.element{
background: #FFF;
margin-bottom: 10px;
border-radius: 5px;
border: 1px solid #DDD;
}
.detail{
padding: 10px;
min-height: 250px;
}
.totle{
margin-bottom: 25px;
}
.totle span{
font-size: 18px;
}
</style>
<div class="row">
<div class="element span4">
<div class="detail w-a h-a">
<p class="totle">
<a class="btn btn-small btn-primary pull-right" href="<%= new_admin_conference_paper_type_path %>#paper_type_modal" data-toggle="modal" data-remote="true"><i class="icon-plus"></i> <%= t('add')%></a>
<span><%= t("personal_conference.paper_type") %></span>
</p>
<div class="detal-list my_scroll">
<div class="scrollbar">
<div class="track">
<div class="thumb">
<div class="end"></div>
</div>
</div>
</div>
<div class="viewport">
<div class="overview">
<table id="paper_types" class="table table-striped">
<tbody>
<%= render :partial => 'list_paper_type', :collection => @paper_types %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="element span4">
<div class="detail w-a h-a">
<p class="totle">
<a class="btn btn-small btn-primary pull-right" href="<%= new_admin_conference_paper_level_path %>#paper_level_modal" data-toggle="modal" data-remote="true"><i class="icon-plus"></i> <%= t('add')%></a>
<span><%= t("personal_conference.paper_level") %></span>
</p>
<div class="detal-list my_scroll">
<div class="scrollbar">
<div class="track">
<div class="thumb">
<div class="end"></div>
</div>
</div>
</div>
<div class="viewport">
<div class="overview">
<table id="paper_levels" class="table table-striped">
<tbody>
<%= render :partial => 'list_paper_level', :collection => @paper_levels %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="element span4">
<div class="detail w-a h-a">
<p class="totle">
<a class="btn btn-small btn-primary pull-right" href="<%= new_admin_conference_author_type_path %>#author_type_modal" data-toggle="modal" data-remote="true"><i class="icon-plus"></i> <%= t('add')%></a>
<span><%= t("personal_conference.author_type") %></span>
</p>
<div class="detal-list my_scroll">
<div class="scrollbar">
<div class="track">
<div class="thumb">
<div class="end"></div>
</div>
</div>
</div>
<div class="viewport">
<div class="overview">
<table id="author_types" class="table table-striped">
<tbody>
<%= render :partial => 'list_author_type', :collection => @author_types %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="paper_type_qe">
<div style="display:none;" class="modal" id="paper_type_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
</div>
</div>
<div id="paper_level_qe">
<div style="display:none;" class="modal" id="paper_level_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
</div>
</div>
<div id="author_type_qe">
<div style="display:none;" class="modal" id="author_type_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
</div>
</div>

View File

@ -0,0 +1,86 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/list-check" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/list-check" %>
<% end %>
<%
is_autorized_user = (current_user==@member.user || current_user.is_admin?)
if is_autorized_user
@writing_conferences = WritingConference.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
else
@writing_conferences = WritingConference.where(is_hidden: false, member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
end
%>
<% if is_autorized_user %>
<div class="list-active">
<div class="btn-group">
<%= link_to('Hide', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-hide", :rel => toggle_hide_admin_writing_conferences_path(member_profile_id: params[:id], disable: 'true') ) %>
<%= link_to('Show', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-show", :rel => toggle_hide_admin_writing_conferences_path(member_profile_id: params[:id], disable: 'false') ) %>
</div>
</div>
<% end -%>
<table class="table table-condensed table-striped main-list">
<thead>
<tr>
<% if is_autorized_user %>
<th><input type="checkbox" /></th>
<% end -%>
<th class="span1"><%= t('personal_plugins.year') %></th>
<th><%= t('module_name.personal_conference') %></th>
<% if not @user%>
<th><%= t('personal_plugins.author') %></th>
<% end %>
</tr>
</thead>
<tbody>
<% @writing_conferences.each do |writing_conference| %>
<tr id="<%= dom_id writing_conference %>" class="<%= writing_conference.is_hidden ? "checkHide" : "" %>">
<% if is_autorized_user %>
<td>
<%= check_box_tag 'to_change[]', writing_conference.id.to_s, false, :class => "list-check" %>
</td>
<% end %>
<td><%= writing_conference.year %></td>
<td>
<%= link_to writing_conference.create_link, '', target: "blank"%>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<li><%= link_to t('edit'), '/admin/members/'+@member.to_param+'/writing_conferences/'+writing_conference.id+'/edit' %></li>
<li><%= link_to t(:delete_), admin_writing_conference_path(id: writing_conference.id, member_profile_id: @member.id), method: :delete, remote: true, data: { confirm: t('sure?') } %></li>
</ul>
</div>
</td>
<td><%= writing_conference.authors %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="bottomnav clearfix">
<% if is_autorized_user %>
<div class="action pull-right">
<%= link_to content_tag(:i, nil, :class => 'icon-edit') +' '+ t('setting'),'/admin/members/'+@member.to_param+'/writing_conferences/frontend_setting', :class => 'btn btn-primary' %>
<%= link_to content_tag(:i, nil, :class => 'icon-plus') +' '+ t('new_'),
'/admin/members/'+@member.to_param+'/writing_conferences/new', :class => 'btn btn-primary' %>
</div>
<% end %>
<div class="pagination pagination-centered">
<%= paginate @writing_conferences, :params => {:direction => params[:direction], :sort => params[:sort] } %>
</div>
</div>
<div id="dialog" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="Delete item" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3><%= t(:sure?) %></h3>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true"><%= t(:close) %></button>
<button class="delete-item btn btn-danger"><%= t(:submit) %></button>
</div>
</div>

View File

@ -8,6 +8,7 @@ en:
language : "Language" language : "Language"
paper_title : "Paper Title" paper_title : "Paper Title"
paper_type : "Paper Type" paper_type : "Paper Type"
paper_level : "Paper Level"
conference_title : "Conference Name" conference_title : "Conference Name"
conference_time: "Conference Time" conference_time: "Conference Time"
period_start_date : "Start Date" period_start_date : "Start Date"
@ -17,6 +18,8 @@ en:
authors : "Authors" authors : "Authors"
tags : "Tags" tags : "Tags"
keywords : "Keywords" keywords : "Keywords"
isbn: "ISSN (ISBN)"
isi_number: "ISI Number"
# total_pages : "Total Pages" # total_pages : "Total Pages"
# form_to_start : "From" # form_to_start : "From"
# form_to_end : "To" # form_to_end : "To"
@ -33,6 +36,7 @@ en:
frontend: frontend:
writing_conferences: "Conference Paper Frontend" writing_conferences: "Conference Paper Frontend"
frontend_setting: "Frontend Setting"
create_success : "Successfully Create" create_success : "Successfully Create"
update_success : "Successfully Update" update_success : "Successfully Update"
delete_success : "Successfully Delete" delete_success : "Successfully Delete"
@ -50,4 +54,5 @@ en:
save: "save" save: "save"
hintText: "Type in a search term" hintText: "Type in a search term"
noResultsText: "No results" noResultsText: "No results"
searchingText: "Searching…" searchingText: "Searching…"
setting: "Setting"

View File

@ -6,16 +6,19 @@ zh_tw:
year : "年度" year : "年度"
language : "語言" language : "語言"
paper_title : "論文名稱" paper_title : "論文名稱"
paper_type : "論文型態" paper_type : "論文類型"
paper_level: "論文等級"
conference_title : "會議名稱" conference_title : "會議名稱"
conference_time: "會議時間" conference_time: "會議時間"
period_start_date : "起" period_start_date : "起"
period_end_date : "訖" period_end_date : "訖"
location : "地點" location : "地點"
sponsor : "主辦單位" sponsor : "主辦單位"
authors : "作者" authors : "全部作者"
tags : "領域" tags : "領域"
keywords : "關鍵字" keywords : "關鍵字"
isbn: "ISSN (ISBN)"
isi_number: "ISI Number"
# total_pages : "總頁數" # total_pages : "總頁數"
# form_to_start : "From" # form_to_start : "From"
# form_to_end : "To" # form_to_end : "To"
@ -32,6 +35,7 @@ zh_tw:
frontend: frontend:
writing_conferences: "研討會論文前台" writing_conferences: "研討會論文前台"
frontend_setting: "前台設定"
create_success : "新增完成!!" create_success : "新增完成!!"
update_success : "更新完成!!" update_success : "更新完成!!"
add: "新增" add: "新增"
@ -48,4 +52,5 @@ zh_tw:
save: "儲存" save: "儲存"
hintText: "請輸入搜尋關鍵字" hintText: "請輸入搜尋關鍵字"
noResultsText: "沒有相關的比對結果" noResultsText: "沒有相關的比對結果"
searchingText: "搜尋中…" searchingText: "搜尋中…"
setting: "設定"

View File

@ -2,6 +2,31 @@ Rails.application.routes.draw do
locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales
scope "(:locale)", locale: Regexp.new(locales.join("|")) do scope "(:locale)", locale: Regexp.new(locales.join("|")) do
namespace :admin do namespace :admin do
get 'writing_conference_setting' => "writing_conferences#setting"
resources :writing_conferences do
collection do
get 'toggle_hide' => 'writing_conferences#toggle_hide'
end
end
resources :members do
collection do
scope '(:name-:uid)' do
resources :writing_conferences do
collection do
get 'frontend_setting' => 'writing_conferences#frontend_setting'
post 'update_frontend_setting' => 'writing_conferences#update_frontend_setting'
end
end
end
end
end
resources :conference_paper_types
resources :conference_paper_levels
resources :conference_author_types
resources :tags
end end
end end
end end

View File

@ -4,7 +4,7 @@ module PersonalConference
OrbitApp.registration "PersonalConference",:type=> 'ModuleApp' do OrbitApp.registration "PersonalConference",:type=> 'ModuleApp' do
module_label 'module_name.personal_conference' module_label 'module_name.personal_conference'
base_url File.expand_path File.dirname(__FILE__) base_url File.expand_path File.dirname(__FILE__)
personal_plugin :enable => true, :sort_number => '10', :app_name=>"WritingConference", :intro_app_name=>"PersonalConferenceIntro",:path=>"/plugin/profile",:front_path=>"/profile",:admin_path=>"/admin/writing_conferences",:i18n=>'module_name.personal_conference' personal_plugin :enable => true, :sort_number => '6', :app_name=>"WritingConference", :intro_app_name=>"PersonalConferenceIntro",:path=>"/plugin/personal_conference/profile",:front_path=>"/profile",:admin_path=>"/admin/writing_conferences",:i18n=>'module_name.personal_conference'
version "0.1" version "0.1"
organization "Rulingcom" organization "Rulingcom"