Personal book module with frontend - modal needs fix
This commit is contained in:
parent
e1b85dfba1
commit
9db8ae9281
|
@ -0,0 +1,2 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -0,0 +1,2 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -0,0 +1,2 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -0,0 +1,2 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -0,0 +1,2 @@
|
|||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
|
@ -0,0 +1,4 @@
|
|||
/*
|
||||
Place all the styles related to the matching controller here.
|
||||
They will automatically be included in application.css.
|
||||
*/
|
|
@ -0,0 +1,4 @@
|
|||
/*
|
||||
Place all the styles related to the matching controller here.
|
||||
They will automatically be included in application.css.
|
||||
*/
|
|
@ -0,0 +1,4 @@
|
|||
/*
|
||||
Place all the styles related to the matching controller here.
|
||||
They will automatically be included in application.css.
|
||||
*/
|
|
@ -0,0 +1,4 @@
|
|||
/*
|
||||
Place all the styles related to the matching controller here.
|
||||
They will automatically be included in application.css.
|
||||
*/
|
|
@ -0,0 +1,4 @@
|
|||
/*
|
||||
Place all the styles related to the matching controller here.
|
||||
They will automatically be included in application.css.
|
||||
*/
|
|
@ -0,0 +1,50 @@
|
|||
class Admin::BookAuthorTypesController < ApplicationController
|
||||
before_action :set_book_author_type, only: [:edit, :update, :destroy]
|
||||
|
||||
def initialize
|
||||
super
|
||||
@app_type = 'book_author_type'
|
||||
end
|
||||
|
||||
def new
|
||||
@book_author_type = BookAuthorType.new
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def create
|
||||
@book_author_type = BookAuthorType.new(book_author_type_attributes)
|
||||
|
||||
respond_to do |format|
|
||||
if @book_author_type.save
|
||||
format.js { render 'create_book_setting' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @book_author_type.update_attributes(book_author_type_attributes)
|
||||
format.js { render 'update_book_setting' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@book_author_type.destroy
|
||||
respond_to do |format|
|
||||
format.js { render 'delete_book_setting' }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_book_author_type
|
||||
@book_author_type = BookAuthorType.find(params[:id])
|
||||
end
|
||||
|
||||
def book_author_type_attributes
|
||||
params.require(:book_author_type).permit! rescue nil
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
class Admin::BookIntrosController < Admin::PersonalPluginIntrosController
|
||||
def initialize
|
||||
super
|
||||
@app_type = 'book_intro'
|
||||
@app_type_name = 'book_paper'
|
||||
@reback_name = 'Book'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,50 @@
|
|||
class Admin::BookTypesController < ApplicationController
|
||||
before_action :set_book_type, only: [:edit, :update, :destroy]
|
||||
|
||||
def initialize
|
||||
super
|
||||
@app_type = 'book_type'
|
||||
end
|
||||
|
||||
def new
|
||||
@book_type = BookType.new
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def create
|
||||
@book_type = BookType.new(book_type_attributes)
|
||||
respond_to do |format|
|
||||
if @book_type.save
|
||||
format.js { render 'create_book_setting' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @book_type.update_attributes(book_type_attributes)
|
||||
format.js { render 'update_book_setting' }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@book_type.destroy
|
||||
respond_to do |format|
|
||||
format.js { render 'delete_book_setting' }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_book_type
|
||||
@book_type = BookType.find(params[:id])
|
||||
end
|
||||
|
||||
def book_type_attributes
|
||||
params.require(:book_type).permit! rescue nil
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,165 @@
|
|||
class Admin::BooksController < OrbitMemberController
|
||||
include Admin::JournalPapersHelper
|
||||
|
||||
before_action :set_book, only: [:show, :edit , :update, :destroy]
|
||||
before_action :get_plugins, only: [:index, :book_setting, :new, :create, :edit, :update]
|
||||
before_action :set_types, only: [:index,:book_setting, :new, :edit, :create, :update]
|
||||
|
||||
def index
|
||||
@writing_books = Book.all
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.js { }
|
||||
format.xml { render :xml => @books }
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.xml { render :xml => @book }
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@members_data = Book.member_data rescue nil
|
||||
end
|
||||
|
||||
def update
|
||||
@book_authors = @book.book_authors
|
||||
|
||||
respond_to do |format|
|
||||
if @book.update_attributes(book_attributes)
|
||||
format.html { redirect_to admin_books_path }
|
||||
format.xml { head :ok }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
format.xml { render :xml => @book.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@book = Book.new
|
||||
@members_data = Book.member_data rescue nil
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
format.xml { render :xml => @book }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@book = Book.new(book_attributes)
|
||||
respond_to do |format|
|
||||
if @book.save
|
||||
format.html { redirect_to admin_books_path }
|
||||
format.xml { render :xml => @book, :status => :created, :location => @book }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
format.xml { render :xml => @book.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def book_setting
|
||||
@set_author_type = BookAuthorType.new(display: 'List')
|
||||
@author_type_url = admin_books_path
|
||||
|
||||
@set_book_type = BookType.new(display: 'List')
|
||||
@book_type_url = admin_books_path
|
||||
end
|
||||
|
||||
def destroy
|
||||
@book.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(admin_books_url) }
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def add_author_type
|
||||
@set_author_type = BookAuthorType.new(display: 'List')
|
||||
@author_type_url = admin_book_author_types_path
|
||||
@set_author_type.id = params[:id]
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def edit_author_type
|
||||
@set_author_type = BookAuthorType.find(params[:book_id])
|
||||
@author_type_url = admin_book_author_type_path(@set_author_type)
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def add_book_type
|
||||
@set_book_type = BookType.new(display: 'List')
|
||||
@book_type_url = admin_book_types_path
|
||||
@set_book_type.id = params[:id]
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def edit_book_type
|
||||
@set_book_type = BookType.find(params[:book_id])
|
||||
@book_type_url = admin_book_type_path(@set_book_type)
|
||||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def data_share
|
||||
if params[:ids]
|
||||
@books = Book.any_in(_id: params[:ids])
|
||||
|
||||
@books.each do |book|
|
||||
book.is_hidden = params[:disable]
|
||||
book.save
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to(admin_member_path(id: params[:member_profile_id],show_plugin_profile: "Book")) }
|
||||
format.json { render json: {"success"=>true}.to_json}
|
||||
end
|
||||
end
|
||||
|
||||
def delete
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_book
|
||||
path = request.path.split('/')
|
||||
if path.last.include? '-'
|
||||
uid = path[-1].split("-").last
|
||||
uid = uid.split("?").first
|
||||
else
|
||||
uid = path[-2].split("-").last
|
||||
uid = uid.split("?").first
|
||||
end
|
||||
@book = Book.find_by(uid: uid)
|
||||
end
|
||||
|
||||
def book_attributes
|
||||
params.require(:book).permit! rescue nil
|
||||
end
|
||||
|
||||
def get_plugins
|
||||
@plugins = OrbitApp::Plugin::Registration.all rescue nil
|
||||
end
|
||||
|
||||
def set_types
|
||||
@author_types = BookAuthorType.all
|
||||
@book_types = BookType.all
|
||||
end
|
||||
end
|
|
@ -0,0 +1,43 @@
|
|||
class BooksController < ApplicationController
|
||||
def index
|
||||
books = Book.asc(:created_at)
|
||||
book_list = books.collect do |book|
|
||||
{
|
||||
"book_title" => book.book_title,
|
||||
"authors" => book.authors,
|
||||
"link_to_show" => OrbitHelper.url_to_show(book.to_param)
|
||||
}
|
||||
end
|
||||
{
|
||||
"books" => book_list,
|
||||
"extras" => {"widget-title" => "Books"}
|
||||
}
|
||||
end
|
||||
|
||||
def show
|
||||
params = OrbitHelper.params
|
||||
book = Book.find_by(uid: params[:uid])
|
||||
publication_date = book.publication_date.to_date.strftime("%Y/%m/%d") rescue nil
|
||||
publish_date = book.publish_date.to_date.strftime("%Y/%m/%d") rescue nil
|
||||
files = book.book_files.map{|file| { "file_url" => file.member_book_file.url, "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title) } } rescue []
|
||||
{
|
||||
"book_files" => files,
|
||||
"data" => {
|
||||
"title" => book.book_title,
|
||||
"year" => book.year,
|
||||
"authors" => book.authors,
|
||||
"isbn" => book.isbn,
|
||||
"language" => t(book.language),
|
||||
"pages" => book.pages,
|
||||
"keywords" => book.keywords,
|
||||
"publication_date" => publication_date ,
|
||||
"url" => book.url,
|
||||
"note" => book.note,
|
||||
"extracted_chapters" => book.extracted_chapters,
|
||||
"publish_date" => publish_date,
|
||||
"publisher" => book.publisher,
|
||||
"editor" => book.editor
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
module Admin::BookAuthorTypesHelper
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
module Admin::BookIntrosHelper
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
module Admin::BookTypesHelper
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
module Admin::BooksHelper
|
||||
def page_for_book(book_object)
|
||||
book_page = nil
|
||||
page = Page.find_by(:module=>"book") rescue nil
|
||||
|
||||
book_page = page if book_page.nil?
|
||||
request.protocol+(request.host_with_port+book_page.url+'/'+book_object.to_param).gsub('//','/') rescue "/"
|
||||
end
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
module BooksHelper
|
||||
end
|
|
@ -0,0 +1,94 @@
|
|||
class Book
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include Mongoid::Attributes::Dynamic
|
||||
|
||||
include OrbitModel::Status
|
||||
include MemberHelper
|
||||
include Slug
|
||||
|
||||
field :book_title, as: :slug_title, type: String, localize: true
|
||||
field :extracted_chapters, type: String, localize: true
|
||||
field :publisher, type: String, localize: true
|
||||
field :editor, type: String, localize: true
|
||||
field :year, type: String
|
||||
field :language, type: String
|
||||
field :publish_date, type: DateTime
|
||||
field :pages, type: String
|
||||
field :isbn, type: String
|
||||
field :keywords, type: String
|
||||
field :publication_date, type: DateTime
|
||||
field :url, type: String
|
||||
field :note, type: String
|
||||
|
||||
paginates_per 10
|
||||
|
||||
belongs_to :member_profile
|
||||
|
||||
has_many :book_files, autosave: true, dependent: :destroy
|
||||
accepts_nested_attributes_for :book_files
|
||||
|
||||
has_and_belongs_to_many :book_authors
|
||||
accepts_nested_attributes_for :book_authors
|
||||
|
||||
belongs_to :book_type
|
||||
before_validation :add_http
|
||||
|
||||
after_save :save_book_files, :save_book_authors
|
||||
|
||||
|
||||
def create_link
|
||||
title = []
|
||||
title << "#{self.book_authors.collect{|j| j.name}.join(', ')}" if self.book_authors.present?
|
||||
title << self.book_title if self.book_title.present?
|
||||
title << self.publisher if self.publisher.present?
|
||||
title << self.isbn if self.isbn.present?
|
||||
|
||||
if !self.publish_date.nil?
|
||||
pd = self.publish_date.strftime("%Y-%m-%d").split('-')
|
||||
title << pd[0]+"/"+pd[1]
|
||||
end
|
||||
|
||||
title.join(', ')
|
||||
end
|
||||
|
||||
def self.member_data
|
||||
members = MemberProfile.all
|
||||
member_data = []
|
||||
members.each do |m|
|
||||
member_data << {"memberId" => m.id.to_s, "memberName" => m.name}
|
||||
end
|
||||
member_data.to_json
|
||||
end
|
||||
|
||||
def save_book_files
|
||||
self.book_files.each do |t|
|
||||
if t.should_destroy
|
||||
t.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def save_book_authors
|
||||
self.book_authors.each do |t|
|
||||
if t.should_destroy
|
||||
t.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def authors
|
||||
authors = []
|
||||
authors << self.member_profile.name if self.member_profile_id.present?
|
||||
authors << (!self.book_authors.blank? ? "#{self.book_authors.collect{|j| j.name}.join(', ')}" : nil)
|
||||
authors.join(', ')
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def add_http
|
||||
unless self.url.blank? || self.url[/^http:\/\//] || self.url[/^https:\/\//]
|
||||
self.url = 'http://' + self.url
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
class BookAuthor
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :name, type: String, localize: true
|
||||
field :email, type: String
|
||||
field :should_destroy, type: Boolean
|
||||
|
||||
has_and_belongs_to_many :books
|
||||
has_and_belongs_to_many :book_author_types
|
||||
|
||||
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/
|
||||
validates :email, format: { with: VALID_EMAIL_REGEX }, allow_blank: true
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
class BookAuthorType
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include Mongoid::Attributes::Dynamic
|
||||
include OrbitCoreLib::ObjectDisable
|
||||
|
||||
field :key, type: String
|
||||
field :title, type: String, localize: true
|
||||
|
||||
has_and_belongs_to_many :book_authors
|
||||
end
|
|
@ -0,0 +1,12 @@
|
|||
class BookFile
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include Mongoid::Attributes::Dynamic
|
||||
|
||||
field :description, type: String, localize: true
|
||||
field :title, type: String, localize: true
|
||||
field :should_destroy, type: Boolean
|
||||
|
||||
mount_uploader :member_book_file, AssetUploader
|
||||
belongs_to :book
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
class BookIntro < PersonalPluginIntro
|
||||
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
class BookType
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include Mongoid::Attributes::Dynamic
|
||||
include OrbitCoreLib::ObjectDisable
|
||||
|
||||
field :key, type: String
|
||||
field :title, type: String, localize: true
|
||||
|
||||
has_many :books
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
$("#myModal2").modal('hide');
|
||||
$('<%= j render :partial => 'admin/books/list_author_type', :collection => [@book_author_type] %>').appendTo('#author_types').hide().fadeIn();
|
|
@ -0,0 +1,3 @@
|
|||
$('.delete_author').bind('ajax:success', function() {
|
||||
$(this).closest('tr').fadeOut();
|
||||
});
|
|
@ -0,0 +1,2 @@
|
|||
$("#myModal2").modal('hide');
|
||||
$("#<%= dom_id @book_author_type %>").replaceWith("<%= j render :partial => 'admin/books/list_author_type', :collection => [@book_author_type] %>");
|
|
@ -0,0 +1,2 @@
|
|||
$("#myModal1").modal('hide');
|
||||
$('<%= j render :partial => 'admin/books/list_book_type', :collection => [@book_type] %>').appendTo('#level_types').hide().fadeIn();
|
|
@ -0,0 +1,3 @@
|
|||
$('.delete_level').bind('ajax:success', function() {
|
||||
$(this).closest('tr').fadeOut();
|
||||
});
|
|
@ -0,0 +1,2 @@
|
|||
$("#myModal1").modal('hide');
|
||||
$("#<%= dom_id @book_type %>").replaceWith("<%= j render :partial => 'admin/books/list_book_type', :collection => [@book_type] %>");
|
|
@ -0,0 +1,33 @@
|
|||
<script type="text/javascript">
|
||||
var map = {},
|
||||
members = [],
|
||||
data = <%= raw @members_data %>;
|
||||
$.each(data, function (i, member) {
|
||||
map[member.memberName] = member;
|
||||
members.push(member.memberName);
|
||||
});
|
||||
$(document).ready(function(){
|
||||
$('#member_autocomplete').typeahead({
|
||||
source: function (query, process) {
|
||||
return members;
|
||||
},
|
||||
updater: function (item) {
|
||||
selectedMember = map[item].memberId;
|
||||
$('#member_value').val(selectedMember);
|
||||
return item;
|
||||
},
|
||||
matcher: function (item) {
|
||||
if (item.toLowerCase().indexOf(this.query.trim().toLowerCase()) != -1) {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
sorter: function (items) {
|
||||
return items.sort();
|
||||
},
|
||||
highlighter: function (item) {
|
||||
var regex = new RegExp( '(' + this.query + ')', 'gi' );
|
||||
return item.replace( regex, "<strong>$1</strong>" );
|
||||
},
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -0,0 +1,33 @@
|
|||
<% # encoding: utf-8 %>
|
||||
<%= form_for(@set_author_type, :remote => true, :url => @author_type_url ) do |f| %>
|
||||
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabe2"><%= (@set_author_type.new_record? ? 'Add 作者型態' : 'Edit 作者型態') %></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="control-group">
|
||||
<label for="http" class="control-label">Key</label>
|
||||
<div class="controls">
|
||||
<%= f.text_field :key %>
|
||||
</div>
|
||||
|
||||
<%= f.fields_for :title_translations do |f| %>
|
||||
<% @site_in_use_locales.each do |locale| %>
|
||||
<div class="control-group">
|
||||
<%= label_tag "link-#{locale}", "Name-#{t(locale)}", :class => 'control-label' %>
|
||||
<div class="controls">
|
||||
<%= f.text_field locale, :class => 'control-label', :value => (@set_author_type.title_translations[locale] rescue nil) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<%= hidden_field_tag 'book[author_type]', @set_author_type.id %>
|
||||
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
|
||||
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<% # encoding: utf-8 %>
|
||||
|
||||
<%= form_for(@set_book_type, :remote => true, :url => @book_type_url ) do |f| %>
|
||||
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabe1"><%= (@set_book_type.new_record? ? 'Add 類別' : 'Edit 類別') %></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<div class="control-group">
|
||||
<label for="http" class="control-label">Key</label>
|
||||
<div class="controls">
|
||||
<%= f.text_field :key %>
|
||||
</div>
|
||||
|
||||
<%= f.fields_for :title_translations do |f| %>
|
||||
<% @site_in_use_locales.each do |locale| %>
|
||||
<div class="control-group">
|
||||
<%= label_tag "link-#{locale}", "Name-#{t(locale)}", :class => 'control-label' %>
|
||||
<div class="controls">
|
||||
<%= f.text_field locale, :class => 'control-label', :value => (@set_book_type.title_translations[locale] rescue nil) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<div class="modal-footer">
|
||||
<%= hidden_field_tag 'book[book_type]', @set_book_type.id %>
|
||||
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
|
||||
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
@ -0,0 +1,344 @@
|
|||
<% # 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-fileupload" %>
|
||||
<%= javascript_include_tag "lib/file-type" %>
|
||||
<%= javascript_include_tag "lib/module-area" %>
|
||||
<%= javascript_include_tag "lib/bootstrap-datetimepicker.js" %>
|
||||
<%= javascript_include_tag "lib/bootstrap-typeahead.js" %>
|
||||
<%= javascript_include_tag "lib/datetimepicker/date.time.picker.js" %>
|
||||
<%= javascript_include_tag "lib/datetimepicker/datetimepicker" %>
|
||||
<% 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">
|
||||
|
||||
<!-- Category -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_book.author_type") %></label>
|
||||
<div class="controls">
|
||||
<% @author_types.each do |author_type| %>
|
||||
<%= content_tag :label,:class => "checkbox inline" do -%>
|
||||
<%= check_box_tag 'book[book_author_type_ids][]', author_type.id, @book.book_author_type_ids.include?(author_type.id)%>
|
||||
<%= author_type.title %>
|
||||
<%= hidden_field_tag 'book[book_author_type_ids][]', '' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- authors-->
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("personal_journal.author") %></label>
|
||||
<div class="controls">
|
||||
<%= f.text_field :member_profile_id, id: "member_autocomplete", autocomplete: "off", data: { provide: "typeahead"}, class: "input-block-level", value: (@book.member_profile.name rescue nil), placeholder: t("personal_journal.author")%>
|
||||
|
||||
<%= f.hidden_field :member_profile_id, value: (@book.member_profile_id ? @book.member_profile_id : ""), id: "member_value" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Category -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_book.book_paper_type") %></label>
|
||||
<div class="controls">
|
||||
<%= f.select :book_type_id, @book_types.collect {|t| [ t.title, t.id ]} %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- year -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_book.year") %></label>
|
||||
<div class="controls">
|
||||
<%= select_year((@book.year ? @book.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'writing_book[year]',:class => 'span1'} ) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- publish_date -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_book.publish_date") %></label>
|
||||
<div class="controls">
|
||||
<%= f.datetime_picker :publish_date, :no_label => true %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- publication_date -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_book.publication_date") %></label>
|
||||
<div class="controls">
|
||||
<%= f.datetime_picker :publication_date, :no_label => true %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- url -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_book.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_book.keywords") %></label>
|
||||
<div class="controls">
|
||||
<%= f.text_field :keywords %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- pages -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_book.pages") %></label>
|
||||
<div class="controls">
|
||||
<%= f.text_field :pages %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- isbn -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_book.isbn") %></label>
|
||||
<div class="controls">
|
||||
<%= f.text_field :isbn %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- language -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_book.language") %></label>
|
||||
<div class="controls">
|
||||
<%= f.radio_button :language, "Chinese" %> <%= t("personal_book.Chinese") %>
|
||||
<%= f.radio_button :language, "English" %> <%= t("personal_book.English") %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- note -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_book.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 @book.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" : '' %>">
|
||||
|
||||
<!-- book_title-->
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("personal_book.book_title") %></label>
|
||||
<div class="controls">
|
||||
<%= f.fields_for :book_title_translations do |f| %>
|
||||
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_book.book_title"), value: (@book.book_title_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- extracted_chapters-->
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("personal_book.extracted_chapters") %></label>
|
||||
<div class="controls">
|
||||
<%= f.fields_for :extracted_chapters_translations do |f| %>
|
||||
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_book.extracted_chapters"), value: (@book.extracted_chapters_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- publisher-->
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("personal_book.publisher") %></label>
|
||||
<div class="controls">
|
||||
<%= f.fields_for :publisher_translations do |f| %>
|
||||
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_book.publisher"), value: (@book.publisher_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- editor-->
|
||||
<div class="control-group input-title">
|
||||
<label class="control-label muted"><%= t("personal_book.editor") %></label>
|
||||
<div class="controls">
|
||||
<%= f.fields_for :editor_translations do |f| %>
|
||||
<%= f.text_field locale, class: "input-block-level", placeholder: t("personal_book.editor"), value: (@book.editor_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
||||
<!-- Authors-->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("personal_journal.co-authors") %></label>
|
||||
<div class="controls">
|
||||
|
||||
<% if @book && !@book.book_authors.blank? %>
|
||||
<div class="exist">
|
||||
<% @book.book_authors.each_with_index do |author, i| %>
|
||||
<%= f.fields_for :book_authors, author do |f| %>
|
||||
<%= render :partial => 'form_author', :object => author, :locals => {:f => f, :i => i} %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<hr>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<!-- Add -->
|
||||
<div class="add-target-box">
|
||||
</div>
|
||||
<p class="add-btn-box">
|
||||
<a id="add_author" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- File -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:file_) %></label>
|
||||
<div class="controls">
|
||||
|
||||
<!-- Exist -->
|
||||
<% if @book && !@book.book_files.blank? %>
|
||||
<div class="exist">
|
||||
<% @book.book_files.each_with_index do |book_file, i| %>
|
||||
<%= f.fields_for :book_files, book_file do |f| %>
|
||||
<%= render :partial => 'form_file', :object => book_file, :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', @book.book_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 %>
|
||||
<%= render 'author_autocomplete'%>
|
||||
<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_book_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, :book_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>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('.main-forms .add-on').tooltip();
|
||||
$(document).on('click', '#add_author', function(){
|
||||
var new_id = $(this).prev().attr('value');
|
||||
var old_id = new RegExp("new_authors", "g");
|
||||
var on = $('.language-nav li.active').index();
|
||||
var le = $(this).parent('.add-btn-box').prev('.add-target-box').children('.start-line').length;
|
||||
$(this).prev().attr('value', parseInt(new_id) + 1);
|
||||
$(this).parent().siblings('.add-target-box').append(("<%= escape_javascript(add_attribute 'form_author', f, :book_authors) %>").replace(old_id, new_id));
|
||||
$(this).parent('.add-btn-box').prev('.add-target-box').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 %>
|
|
@ -0,0 +1,39 @@
|
|||
<% if form_author.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_author.name.present? %>
|
||||
<%= form_author.name %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="input-prepend input-append">
|
||||
<label>
|
||||
<div class="span3 input-medium">
|
||||
<span class="add-on icons-mail" title='<%= t(:email) %>'></span>
|
||||
<%= f.email_field :email, placeholder: t(:email) %>
|
||||
</div>
|
||||
</label>
|
||||
<span class="add-on icons-pencil" title='<%= t(:name) %>'></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 :name_translations do |f| %>
|
||||
<%= f.text_field locale, :class => "input-medium", placeholder: t(:name), :value => (form_author.name_translations[locale] rescue nil) %>
|
||||
<% end %>
|
||||
</span>
|
||||
<% end %>
|
||||
</span>
|
||||
</span>
|
||||
<% if form_author.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 :should_destroy, :value => nil, :class => 'should_destroy' %>
|
||||
</span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,45 @@
|
|||
<% 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.member_book_file.blank? %>
|
||||
<%= t(:no_file) %>
|
||||
<% else %>
|
||||
<%= link_to content_tag(:i) + form_file.member_book_file_identifier, form_file.member_book_file.url, {:class => 'file-link file-type', :target => '_blank', :title => form_file.member_book_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 :member_book_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.member_book_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>
|
||||
<% 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>
|
|
@ -0,0 +1,11 @@
|
|||
<% # encoding: utf-8 %>
|
||||
|
||||
<tr id="<%= dom_id list_author_type %>">
|
||||
<td><%= list_author_type.title %></td>
|
||||
<td class="span2">
|
||||
|
||||
<a href="<%= admin_book_edit_author_type_path(list_author_type) %>#myModal2" data-toggle="modal" data-remote="true" class="action"><%= t('edit')%></a>
|
||||
<%= link_to 'Delete',
|
||||
polymorphic_path([:admin, list_author_type]), data: { confirm: t('sure?') }, method: :delete, remote:true, class: "delete_author archive_toggle action" %>
|
||||
</td>
|
||||
</tr>
|
|
@ -0,0 +1,10 @@
|
|||
<% # encoding: utf-8 %>
|
||||
|
||||
<tr id="<%= dom_id list_book_type %>">
|
||||
<td><%= list_book_type.title %></td>
|
||||
<td class="span2">
|
||||
|
||||
<a href="<%= admin_book_edit_book_type_path(list_book_type) %>#myModal1" data-toggle="modal" data-remote="true" class="action"><%= t('edit')%></a>
|
||||
<%= link_to 'Delete', polymorphic_path([:admin, list_book_type]), data: { confirm: t('sure?') }, method: :delete, remote: true, class: "delete_level archive_toggle action" %>
|
||||
</td>
|
||||
</tr>
|
|
@ -0,0 +1,15 @@
|
|||
<tr id="<%= dom_id writing_book %>" class="with_action">
|
||||
<td class="span1"><%= writing_book.year %></td>
|
||||
<td class="span1">
|
||||
<%= link_to writing_book.create_link, page_for_book(writing_book), target: "blank" %>
|
||||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills hide">
|
||||
<%if current_user.is_admin?%>
|
||||
<li><%= link_to t('edit'), edit_admin_book_path(writing_book) %></li>
|
||||
<li><%= link_to t(:delete_), admin_book_path(writing_book), method: :delete, remote: true, data: { confirm: 'Are you sure?' } %></li>
|
||||
<% end -%>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
<td class="span1"><%= writing_book.authors%></td>
|
||||
</tr>
|
|
@ -0,0 +1 @@
|
|||
$("#myModal2").html("<%= j render "author_type_qe" %>");
|
|
@ -0,0 +1 @@
|
|||
$("#myModal1").html("<%= j render "book_type_qe" %>");
|
|
@ -0,0 +1,110 @@
|
|||
<% # encoding: utf-8 %>
|
||||
|
||||
<% content_for :side_bar do %>
|
||||
<%= render :partial => 'layouts/side_bar', :locals => {:link_name => t(:user), :link_url => admin_site_site_info_path(site_id: current_site.id), :icon => 'icons-users', :side_bar_content => 'admin/members/side_bar'} %>
|
||||
<% end %>
|
||||
|
||||
<div class="subnav">
|
||||
|
||||
<%= render :partial => 'admin/personal_plugins/plugin_list' %>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="isotope">
|
||||
<div class="item element">
|
||||
<div class="detail w-a h-a">
|
||||
<p class="totle">
|
||||
<a class="btn btn-small btn-primary pull-right" href="<%= admin_book_add_book_type_path('add') %>#myModal1" data-toggle="modal" data-remote="true"><i class="icon-plus"></i> <%= t('add')%></a>
|
||||
<span><%= t("personal_book.book_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="level_types" class="table table-striped">
|
||||
<tbody>
|
||||
<%= render partial: 'list_book_type', collection: @book_types %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="item element">
|
||||
<div class="detail w-a h-a">
|
||||
<p class="totle">
|
||||
<a class="btn btn-small btn-primary pull-right" href="<%= admin_book_add_author_type_path('add') %>#myModal2" data-toggle="modal" data-remote="true"><i class="icon-plus"></i> <%= t('add')%></a>
|
||||
<span><%= t("personal_book.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 class="form-actions form-fixed pagination-right">
|
||||
<!-- <a class="btn btn-primary pull-right" href><i class="icon-plus icon-white"></i> 匯出</a>
|
||||
<a class="btn btn-primary pull-right" href><i class="icon-plus icon-white"></i> 匯入</a> -->
|
||||
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('announcement.add_new'), new_admin_book_path, :class => 'btn btn-primary pull-right' %>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="level_type_qe">
|
||||
<div style="display:none;" class="modal" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<%= render "book_type_qe" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="author_type_qe">
|
||||
<div style="display:none;" class="modal" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<%= render "author_type_qe" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display:none;" class="modal" id="myModal4" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3 id="myModalLabel">領域</h3>
|
||||
</div>
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="active"><a href="#">中文</a></li>
|
||||
<li><a href="#">English</a></li>
|
||||
</ul>
|
||||
<div class="modal-body">
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputvalue">名稱</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="inputvalue" placeholder="Value">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
|
||||
<button class="btn btn-primary">Save changes</button>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,9 @@
|
|||
<% if !@book_type.blank? %>
|
||||
$("#myModal1").modal('hide');
|
||||
$('<%= j render :partial => 'list_book_type', :collection => [@book_type] %>').appendTo('#level_types').hide().fadeIn();
|
||||
<% end %>
|
||||
|
||||
<% if !@book_author_type.blank? %>
|
||||
$("#myModal2").modal('hide');
|
||||
$('<%= j render :partial => 'list_author_type', :collection => [@book_author_type] %>').appendTo('#author_types').hide().fadeIn();
|
||||
<% end %>
|
|
@ -0,0 +1 @@
|
|||
$("#<%= dom_id @book %>").remove();
|
|
@ -0,0 +1,15 @@
|
|||
<% content_for :side_bar do %>
|
||||
<%= render :partial => 'layouts/side_bar', :locals => {:link_name => t(:user), :link_url => admin_site_site_info_path(current_site), :icon => 'icons-users', :side_bar_content => 'admin/members/side_bar'} %>
|
||||
<% end %>
|
||||
|
||||
<div class="subnav">
|
||||
|
||||
<%= render :partial => 'admin/personal_plugins/plugin_list' %>
|
||||
|
||||
</div>
|
||||
|
||||
<%= form_for @book, url: admin_book_path(@book), html: {class: "form-horizontal main-forms previewable"} do |f| %>
|
||||
<fieldset>
|
||||
<%= render partial: 'form', locals: {f: f} %>
|
||||
</fieldset>
|
||||
<% end %>
|
|
@ -0,0 +1 @@
|
|||
$("#myModal2").html("<%= j render "author_type_qe" %>");
|
|
@ -0,0 +1 @@
|
|||
$("#myModal1").html("<%= j render "book_type_qe" %>");
|
|
@ -0,0 +1,27 @@
|
|||
<% content_for :side_bar do %>
|
||||
<%= render :partial => 'layouts/side_bar', :locals => {:link_name => t(:user), :link_url => admin_site_site_info_path(current_site), :icon => 'icons-users', :side_bar_content => 'admin/members/side_bar'} %>
|
||||
<% end %>
|
||||
|
||||
<div class="subnav">
|
||||
<%= render :partial => 'admin/personal_plugins/plugin_list' %>
|
||||
</div>
|
||||
|
||||
<table class="table main-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="span1"><%= t("personal_book.year") %></th>
|
||||
<th class="span7"><%= t("personal_book.book_title") %></th>
|
||||
<th class="span1"><%= t("personal_plugins.author") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbody_writing_books" class="sort-holder">
|
||||
<%= render :partial => 'writing_book', :collection => @writing_books %>
|
||||
</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_book_setting_path, :class => 'btn btn-primary pull-right' %>
|
||||
<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('announcement.add_new'), new_admin_book_path, :class => 'btn btn-primary pull-right' %>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,15 @@
|
|||
<% content_for :side_bar do %>
|
||||
<%= render :partial => 'layouts/side_bar', :locals => {:link_name => t(:user), :link_url => admin_site_site_info_path(current_site), :icon => 'icons-users', :side_bar_content => 'admin/members/side_bar'} %>
|
||||
<% end %>
|
||||
|
||||
<div class="subnav">
|
||||
|
||||
<%= render :partial => 'admin/personal_plugins/plugin_list' %>
|
||||
|
||||
</div>
|
||||
|
||||
<%= form_for @book, url: admin_books_path, html: {class: "form-horizontal main-forms previewable"} do |f| %>
|
||||
<fieldset>
|
||||
<%= render partial: 'form', locals: {f: f} %>
|
||||
</fieldset>
|
||||
<% end %>
|
|
@ -0,0 +1,9 @@
|
|||
<% if !@book_type.blank? %>
|
||||
$("#myModal1").modal('hide');
|
||||
$("#<%= dom_id @book_type %>").replaceWith("<%= j render :partial => 'list_book_type', :collection => [@book_type] %>");
|
||||
<% end %>
|
||||
|
||||
<% if !@book_author_type.blank? %>
|
||||
$("#myModal2").modal('hide');
|
||||
$("#<%= dom_id @book_author_type %>").replaceWith("<%= j render :partial => 'list_author_type', :collection => [@book_author_type] %>");
|
||||
<% end %>
|
|
@ -0,0 +1 @@
|
|||
<%= render_view %>
|
|
@ -0,0 +1 @@
|
|||
<%= render_view %>
|
|
@ -0,0 +1,108 @@
|
|||
<% 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 %>
|
||||
|
||||
<%
|
||||
@filter = params[:filter]
|
||||
new_filter = params[:new_filter]
|
||||
|
||||
if @filter && params[:clear]
|
||||
@filter.delete(params[:type])
|
||||
elsif @filter && new_filter
|
||||
if @filter.has_key?(new_filter[:type]) && @filter[new_filter[:type]].include?(new_filter[:id].to_s)
|
||||
@filter[new_filter[:type]].delete(new_filter[:id].to_s)
|
||||
elsif @filter.has_key?(new_filter[:type])
|
||||
@filter[new_filter[:type]] << new_filter[:id].to_s
|
||||
else
|
||||
@filter.merge!({new_filter[:type] => [new_filter[:id].to_s]})
|
||||
end
|
||||
elsif new_filter
|
||||
@filter = {new_filter[:type] => [new_filter[:id].to_s]}
|
||||
end
|
||||
|
||||
if @member && @member.user.is_admin?
|
||||
@books = Book.where(member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
|
||||
else
|
||||
@books = Book.where(is_hidden: false, member_profile_id: @member.id).desc(:year).page(params[:page]).per(10)
|
||||
end
|
||||
|
||||
%>
|
||||
|
||||
<% if current_user.is_admin? %>
|
||||
<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 => data_share_admin_books_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 => data_share_admin_books_path(member_profile_id: params[:id], disable: 'false') ) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end -%>
|
||||
|
||||
<table class="table table-condensed table-striped main-list">
|
||||
<thead>
|
||||
<tr>
|
||||
<% if current_user.is_admin? %>
|
||||
<th><input type="checkbox" /></th>
|
||||
<% end -%>
|
||||
<th class="span1"><%= t('personal_journal.year') %></th>
|
||||
<th><%= t('module_name.book') %></th>
|
||||
<% if not @user%>
|
||||
<th><%= t('personal_journal.authors') %></th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<% @books.each do |book| %>
|
||||
|
||||
<tr id="<%= dom_id book %>" class="<%= book.is_hidden ? "checkHide" : "" %>">
|
||||
<% if is_admin? %>
|
||||
<td>
|
||||
<%= check_box_tag 'to_change[]', book.id.to_s, false, :class => "list-check" %>
|
||||
</td>
|
||||
<% end -%>
|
||||
<td><%= book.year %></td>
|
||||
<td>
|
||||
<%= link_to book.create_link, page_for_book(book), target: "blank"%>
|
||||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills hide">
|
||||
<li><%= link_to t('edit'), edit_admin_book_path(book, member_profile_id: @member.id) %></li>
|
||||
<li><%= link_to t(:delete_), admin_book_path(id: book.id, member_profile_id: @member.id), method: :delete, remote: true, data: { confirm: t('sure?') } %></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
<td><%= book.authors %></td>
|
||||
</tr>
|
||||
|
||||
<% end %>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<% if current_user.is_admin? %>
|
||||
<div class="bottomnav clearfix">
|
||||
|
||||
<div class="action pull-right">
|
||||
<%= link_to content_tag(:i, nil, :class => 'icon-plus') + t('personal_plugins.edit_brief_intro'),admin_book_intros_path(member_profile_id: @member.id), :class => 'btn btn-primary' %>
|
||||
|
||||
<%= link_to content_tag(:i, nil, :class => 'icon-plus') + t('announcement.add_new'), new_admin_book_path(member_profile_id: @member.id), :class => 'btn btn-primary' %>
|
||||
</div>
|
||||
<div class="pagination pagination-centered">
|
||||
<%= paginate @books, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil} %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<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>
|
|
@ -1,11 +1,13 @@
|
|||
en:
|
||||
module_name:
|
||||
personal_book: Book
|
||||
book: Book
|
||||
book_paper: Book
|
||||
personal_book:
|
||||
paper_title : "Paper Title"
|
||||
book_title : "Book Title"
|
||||
extracted_chapters : "Extracted Chapters"
|
||||
publisher : "Publishers"
|
||||
editor: "Editor"
|
||||
authors : "Authors"
|
||||
tags : "Tags"
|
||||
year : "Year"
|
||||
|
@ -29,7 +31,7 @@ en:
|
|||
file_name : "File name"
|
||||
description : "File Description"
|
||||
pages : "Pages"
|
||||
book_paper_type : "Book Paper Type"
|
||||
book_paper_type : "Book Type"
|
||||
frontend:
|
||||
writing_books: "Book Front-end"
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
zh_tw:
|
||||
module_name:
|
||||
personal_book: 專書
|
||||
book: 專書
|
||||
book_paper: 專書
|
||||
personal_book:
|
||||
paper_title : "論文名稱"
|
||||
book_title : "書名"
|
||||
|
|
|
@ -1,7 +1,22 @@
|
|||
Rails.application.routes.draw do
|
||||
|
||||
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
|
||||
match 'book_setting' => "books#book_setting" ,as: :book_setting, via: [:get]
|
||||
resources :books do
|
||||
collection do
|
||||
get 'delete'
|
||||
get 'data_share'
|
||||
end
|
||||
match "add_author_type" => "books#add_author_type" ,as: :add_author_type, via: [:get, :post]
|
||||
match "edit_author_type" => "books#edit_author_type" ,as: :edit_author_type, via: [:get, :post]
|
||||
match "add_book_type" => "books#add_book_type" ,as: :add_book_type, via: [:get, :post]
|
||||
match "edit_book_type" => "books#edit_book_type" ,as: :edit_book_type, via: [:get, :post]
|
||||
end
|
||||
resources :book_author_types
|
||||
resources :book_types
|
||||
resources :book_intros
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
module PersonalBook
|
||||
class Engine < ::Rails::Engine
|
||||
initializer "personal_book" do
|
||||
OrbitApp.registration "PersonalBook",:type=> 'ModuleApp' do
|
||||
module_label 'module_name.personal_book'
|
||||
OrbitApp.registration "Book",:type=> 'ModuleApp' do
|
||||
module_label 'module_name.book'
|
||||
base_url File.expand_path File.dirname(__FILE__)
|
||||
personal_plugin :enable => true, :sort_number => '25', :app_name=>"WritingBook", :intro_app_name=>"PersonalBookIntro",:path=>"/plugin/profile",:front_path=>"/profile",:admin_path=>"/admin/writing_books",:i18n=>'module_name.personal_book'
|
||||
personal_plugin :enable => true, :sort_number => '25', :app_name=>"Book", :intro_app_name=>"BookIntro",:path=>"/plugin/book/profile",:front_path=>"/profile",:admin_path=>"/admin/books",:i18n=>'module_name.book',:module_app_name=>'PersonalBook'
|
||||
|
||||
version "0.1"
|
||||
organization "Rulingcom"
|
||||
author "RD dep"
|
||||
intro "I am intro"
|
||||
update_info 'some update_info'
|
||||
|
||||
frontend_enabled
|
||||
icon_class_no_sidebar "icons-user"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
require 'test_helper'
|
||||
|
||||
class Admin::BookAuthorTypesControllerTest < ActionController::TestCase
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class Admin::BookIntrosControllerTest < ActionController::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class Admin::BookTypesControllerTest < ActionController::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
require 'test_helper'
|
||||
|
||||
class Admin::BooksControllerTest < ActionController::TestCase
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
require 'test_helper'
|
||||
|
||||
class BooksControllerTest < ActionController::TestCase
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get show" do
|
||||
get :show
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
|
@ -0,0 +1,11 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
|
@ -0,0 +1,11 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
|
@ -0,0 +1,11 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
|
@ -0,0 +1,11 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
# This model initially had no columns defined. If you add columns to the
|
||||
# model remove the '{}' from the fixture names and add the columns immediately
|
||||
# below each fixture, per the syntax in the comments below
|
||||
#
|
||||
one: {}
|
||||
# column: value
|
||||
#
|
||||
two: {}
|
||||
# column: value
|
|
@ -0,0 +1,31 @@
|
|||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
book_title: MyString
|
||||
extracted_chapters: MyString
|
||||
publisher: MyString
|
||||
editor: MyString
|
||||
year: MyString
|
||||
language: MyString
|
||||
publish_date: 2014-07-01
|
||||
pages: MyString
|
||||
isbn: MyString
|
||||
keywords: MyString
|
||||
publication_date: 2014-07-01
|
||||
url: MyString
|
||||
note: MyString
|
||||
|
||||
two:
|
||||
book_title: MyString
|
||||
extracted_chapters: MyString
|
||||
publisher: MyString
|
||||
editor: MyString
|
||||
year: MyString
|
||||
language: MyString
|
||||
publish_date: 2014-07-01
|
||||
pages: MyString
|
||||
isbn: MyString
|
||||
keywords: MyString
|
||||
publication_date: 2014-07-01
|
||||
url: MyString
|
||||
note: MyString
|
|
@ -0,0 +1,4 @@
|
|||
require 'test_helper'
|
||||
|
||||
class Admin::BookAuthorTypesHelperTest < ActionView::TestCase
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
require 'test_helper'
|
||||
|
||||
class Admin::BookIntrosHelperTest < ActionView::TestCase
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
require 'test_helper'
|
||||
|
||||
class Admin::BookTypesHelperTest < ActionView::TestCase
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
require 'test_helper'
|
||||
|
||||
class Admin::BooksHelperTest < ActionView::TestCase
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
require 'test_helper'
|
||||
|
||||
class BooksHelperTest < ActionView::TestCase
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class BookAuthorTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class BookAuthorTypeTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class BookFileTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class BookIntroTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class BookTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
require 'test_helper'
|
||||
|
||||
class BookTypeTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
Reference in New Issue