diff --git a/app/controllers/admin/book_author_types_controller.rb b/app/controllers/admin/book_author_types_controller.rb index 4ef0ec4..cf11077 100644 --- a/app/controllers/admin/book_author_types_controller.rb +++ b/app/controllers/admin/book_author_types_controller.rb @@ -1,50 +1,43 @@ class Admin::BookAuthorTypesController < OrbitMemberController - before_action :set_book_author_type, only: [:edit, :update, :destroy] - - def initialize - super - @app_type = 'book_author_type' - end - + before_action :allow_admin_only + def new - @book_author_type = BookAuthorType.new - end - - def edit + @author_type = BookAuthorType.new + @url = admin_book_author_types_path(@author_type) + render :layout=>false end def create - @book_author_type = BookAuthorType.new(book_author_type_attributes) + @author_type = BookAuthorType.new(author_type_params) + @author_type.save + @author_types = BookAuthorType.all + render :partial=>'list', :layout=>false + end - respond_to do |format| - if @book_author_type.save - format.js { render 'create_book_setting' } - end - end + def edit + @author_type = BookAuthorType.find(params[:id]) + @url = admin_book_author_type_path(@author_type) + render :layout=>false 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 + @author_type = BookAuthorType.find(params[:id]) + @author_type.update_attributes(author_type_params) + @author_type.save + @author_types = BookAuthorType.all + render :partial=>'list', :layout=>false end def destroy - @book_author_type.destroy - respond_to do |format| - format.js { render 'delete_book_setting' } - end + author_type = BookAuthorType.find(params[:id]) + author_type.destroy + @author_types = BookAuthorType.all + render :partial=>'list', :layout=>false end private - def set_book_author_type - @book_author_type = BookAuthorType.find(params[:id]) - end - - def book_author_type_attributes + def author_type_params params.require(:book_author_type).permit! rescue nil end end diff --git a/app/controllers/admin/book_intros_controller.rb b/app/controllers/admin/book_intros_controller.rb deleted file mode 100644 index c852824..0000000 --- a/app/controllers/admin/book_intros_controller.rb +++ /dev/null @@ -1,8 +0,0 @@ -class Admin::BookIntrosController < Admin::PersonalPluginIntrosController - def initialize - super - @app_type = 'book_intro' - @app_type_name = 'book_paper' - @reback_name = 'Book' - end -end diff --git a/app/controllers/admin/book_types_controller.rb b/app/controllers/admin/book_types_controller.rb index 488dc13..684c33c 100644 --- a/app/controllers/admin/book_types_controller.rb +++ b/app/controllers/admin/book_types_controller.rb @@ -1,50 +1,43 @@ -class Admin::BookTypesController < ApplicationController - before_action :set_book_type, only: [:edit, :update, :destroy] - - def initialize - super - @app_type = 'book_type' - end - +class Admin::BookTypesController < OrbitMemberController + before_action :allow_admin_only + def new - @book_type = BookType.new - end - - def edit + @book_type = BookType.new + @url = admin_book_types_path(@book_type) + render :layout=>false 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 + @book_type = BookType.new(book_type_params) + @book_type.save + @book_types = BookType.all + render :partial=>'list', :layout=>false + end + + def edit + @book_type = BookType.find(params[:id]) + @url = admin_book_type_path(@book_type) + render :layout=>false end def update - respond_to do |format| - if @book_type.update_attributes(book_type_attributes) - format.js { render 'update_book_setting' } - end - end + @book_type = BookType.find(params[:id]) + @book_type.update_attributes(book_type_params) + @book_type.save + @book_types = BookType.all + render :partial=>'list', :layout=>false end def destroy - @book_type.destroy - respond_to do |format| - format.js { render 'delete_book_setting' } - end + book_type = BookType.find(params[:id]) + book_type.destroy + @book_types = BookType.all + render :partial=>'list', :layout=>false end private - def set_book_type - @book_type = BookType.find(params[:id]) - end - - def book_type_attributes + def book_type_params params.require(:book_type).permit! rescue nil end - -end +end \ No newline at end of file diff --git a/app/controllers/admin/books_controller.rb b/app/controllers/admin/books_controller.rb index ae43e4d..4c79966 100644 --- a/app/controllers/admin/books_controller.rb +++ b/app/controllers/admin/books_controller.rb @@ -1,15 +1,13 @@ class Admin::BooksController < OrbitMemberController - include Admin::BooksHelper layout "member_plugin" + include Admin::PersonalBooksHelper - before_action :set_book, only: [:show, :edit , :update] - before_action :find_book, only: [: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] + before_action :set_book, only: [:show, :edit , :update, :destroy] before_action :set_plugin + before_action :get_settings,:only => [:new, :edit, :setting] before_action :need_access_right - before_action :allow_admin_only, :only => [:index, :book_setting] + before_action :allow_admin_only, :only => [:index, :setting] def index @writing_books = Book.order_by(:year=>'desc').page(params[:page]).per(10) @@ -36,7 +34,7 @@ class Admin::BooksController < OrbitMemberController def update @member = @book.member_profile - @book.update_attributes(book_attributes) + @book.update_attributes(book_params) @book.save if params[:desktop] == "true" render json: {"data" => get_paper_list}.to_json @@ -47,15 +45,15 @@ class Admin::BooksController < OrbitMemberController def new @book = Book.new - @member = MemberProfile.find_by(:id=>params['member_profile_id']) rescue nil + @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil if params[:desktop] render :layout => false end end def create - @member = MemberProfile.find(book_attributes['member_profile_id']) rescue nil - @book = Book.new(book_attributes) + @member = MemberProfile.find(book_params['member_profile_id']) rescue nil + @book = Book.new(book_params) @book.save if params[:desktop] == "true" render json: {"data" => get_paper_list}.to_json @@ -64,18 +62,6 @@ class Admin::BooksController < OrbitMemberController end end - def book_setting - if current_user.is_admin? - @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 - else - render_401 - end - end - def destroy @book.destroy respond_to do |format| @@ -86,45 +72,7 @@ class Admin::BooksController < OrbitMemberController 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 + def toggle_hide if params[:ids] @books = Book.any_in(_id: params[:ids]) @@ -134,13 +82,34 @@ class Admin::BooksController < OrbitMemberController 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 + render json: {"success"=>true} end - def delete + def setting + end + + def frontend_setting + @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil + @intro = BookIntro.find_by(:member_profile_id=>@member.id) rescue nil + @intro = @intro.nil? ? BookIntro.new({:member_profile_id=>@member.id}) : @intro + end + + def update_frontend_setting + @member = MemberProfile.find(intro_params['member_profile_id']) rescue nil + @intro = BookIntro.find_by(:member_profile_id=>@member.id) rescue nil + @intro = @intro.nil? ? BookIntro.new({:member_profile_id=>@member.id}) : @intro + @intro.update_attributes(intro_params) + @intro.save + redirect_to URI.encode('/admin/members/'+@member.to_param+'/Book') + end + + def get_settings + @author_types = BookAuthorType.all + @book_types = BookType.all + end + + def set_plugin + @plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'Book'}.first end private @@ -154,27 +123,14 @@ class Admin::BooksController < OrbitMemberController uid = path[-2].split("-").last uid = uid.split("?").first end - @book = Book.find_by(uid: uid) + @book = Book.find_by(:uid => uid) rescue Book.find(params[:id]) end - def find_book - @book = Book.find_by(id: params[:id]) + def intro_params + params.require(:book_intro).permit! rescue nil end - def book_attributes + def book_params params.require(:book).permit! rescue nil end - - def get_plugins - @plugins = OrbitApp::Plugin::Registration.all rescue nil - end - - def set_plugin - @plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'Book'}.first - end - - def set_types - @author_types = BookAuthorType.all - @book_types = BookType.all - end end \ No newline at end of file diff --git a/app/controllers/books_controller.rb b/app/controllers/personal_books_controller.rb similarity index 78% rename from app/controllers/books_controller.rb rename to app/controllers/personal_books_controller.rb index 2a470a2..657f6d4 100644 --- a/app/controllers/books_controller.rb +++ b/app/controllers/personal_books_controller.rb @@ -1,11 +1,12 @@ -class BooksController < ApplicationController +class PersonalBooksController < ApplicationController def index - books = Book.order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) + books = Book.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) book_list = books.collect do |book| { - "book_title" => book.book_title, + "book_title" => book.create_link, "author" => book.authors, "year" => book.year, + "book_paper_type" => book.book_type.title, "link_to_show" => OrbitHelper.url_to_show(book.to_param) } end @@ -15,6 +16,7 @@ class BooksController < ApplicationController "widget-title" => t("module_name.book"), "th_year" => t('personal_plugins.year'), "th_title" => t("personal_book.book_title"), + "th_book_paper_type" => t("personal_book.book_paper_type"), "th_author" => t('personal_book.authors') }, "total_pages" => books.total_pages @@ -23,24 +25,25 @@ class BooksController < ApplicationController def show params = OrbitHelper.params - plugin = Book.find_by(uid: params[:uid]) - + plugin = Book.where(:is_hidden=>false).find_by(uid: params[:uid]) fields_to_show = [ - "book_title", + "year", "author_name", "authors", - "number_of_authors", - "editor", + "book_paper_type", + "book_title", + "extracted_chapters", "publisher", "publish_date", - "publication_date", - "isbn", - "extracted_chapters", "pages", + "editor", + "author_type", + "number_of_authors", + "isbn", "url", - "keywords", - "note", - "file" + "file", + "publication_date", + "language" ] {"plugin_datas"=>plugin.get_plugin_data(fields_to_show)} diff --git a/app/helpers/admin/book_author_types_helper.rb b/app/helpers/admin/book_author_types_helper.rb deleted file mode 100644 index 72adcd2..0000000 --- a/app/helpers/admin/book_author_types_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module Admin::BookAuthorTypesHelper -end diff --git a/app/helpers/admin/book_intros_helper.rb b/app/helpers/admin/book_intros_helper.rb deleted file mode 100644 index 31fce53..0000000 --- a/app/helpers/admin/book_intros_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module Admin::BookIntrosHelper -end diff --git a/app/helpers/admin/book_types_helper.rb b/app/helpers/admin/book_types_helper.rb deleted file mode 100644 index 7745eab..0000000 --- a/app/helpers/admin/book_types_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module Admin::BookTypesHelper -end diff --git a/app/helpers/admin/books_helper.rb b/app/helpers/admin/books_helper.rb deleted file mode 100644 index db9b76b..0000000 --- a/app/helpers/admin/books_helper.rb +++ /dev/null @@ -1,35 +0,0 @@ -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 - - def get_paper_list - user = current_user.nil? ? OrbitHelper.current_user : current_user - user_profile = user.member_profile - books = Book.where(:member_profile_id => user_profile.id) - books = books.collect do |b| - files = b.book_files.collect do |bf| - { - "title" => bf.title, - "description" => bf.description, - "link" => bf.member_book_file.url, - "extension" => (bf.file.url.split(".").last rescue "") - } - end - { - "id" => b.id.to_s, - "edit_url" => "/#{I18n.locale.to_s}/admin/books/#{b.to_param}/edit", - "delete_url" => "/#{I18n.locale.to_s}/admin/books/#{b.id.to_s}", - "paper_title" => b.book_title, - "keywords" => b.keywords, - "files" => files - } - - end - books - end -end diff --git a/app/helpers/admin/personal_books_helper.rb b/app/helpers/admin/personal_books_helper.rb new file mode 100644 index 0000000..bafee92 --- /dev/null +++ b/app/helpers/admin/personal_books_helper.rb @@ -0,0 +1,28 @@ +module Admin::PersonalBooksHelper + + def get_paper_list + user = current_user.nil? ? OrbitHelper.current_user : current_user + user_profile = user.member_profile + books = Book.where(:member_profile_id => user_profile.id) + books = books.collect do |b| + files = b.book_files.collect do |bf| + { + "title" => bf.title, + "description" => bf.description, + "link" => bf.member_book_file.url, + "extension" => (bf.file.url.split(".").last rescue "") + } + end + { + "id" => b.id.to_s, + "edit_url" => "/#{I18n.locale.to_s}/admin/members/#{user_profile.to_param}/books/#{b.to_param}/edit", + "delete_url" => "/#{I18n.locale.to_s}/admin/books/#{b.id.to_s}", + "paper_title" => b.book_title, + "keywords" => b.keywords, + "files" => files + } + + end + books + end +end \ No newline at end of file diff --git a/app/helpers/books_helper.rb b/app/helpers/books_helper.rb deleted file mode 100644 index 4b9311e..0000000 --- a/app/helpers/books_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module BooksHelper -end diff --git a/app/models/book.rb b/app/models/book.rb index 8d6edca..ce5baf1 100644 --- a/app/models/book.rb +++ b/app/models/book.rb @@ -30,13 +30,13 @@ class Book paginates_per 10 belongs_to :member_profile + belongs_to :book_type has_many :book_files, autosave: true, dependent: :destroy accepts_nested_attributes_for :book_files, :allow_destroy => true has_and_belongs_to_many :book_author_types - belongs_to :book_type before_validation :add_http def create_link @@ -44,6 +44,7 @@ class Book title << self.member_profile.name if self.member_profile.present? title << self.authors if self.authors.present? title << self.book_title if self.book_title.present? + title << self.extracted_chapters if self.extracted_chapters.present? title << self.publisher if self.publisher.present? title << self.isbn if self.isbn.present? @@ -52,6 +53,9 @@ class Book title << pd[0]+"/"+pd[1] end + title << self.pages if self.pages.present? + title << self.year + title.join(', ') end @@ -67,6 +71,10 @@ class Book def get_plugin_field_data(field) case field + when "book_paper_type" + value = self.book_type.title rescue "" + when "author_type" + value = self.book_author_types.collect{|type| type.title}.join(',') rescue "" when "author_name" value = [] ([I18n.locale]+(Site.first.in_use_locales-[I18n.locale])).each do |locale| diff --git a/app/models/book_author_type.rb b/app/models/book_author_type.rb index f1bc363..32be4ca 100644 --- a/app/models/book_author_type.rb +++ b/app/models/book_author_type.rb @@ -1,8 +1,6 @@ class BookAuthorType include Mongoid::Document include Mongoid::Timestamps - include Mongoid::Attributes::Dynamic - include OrbitCoreLib::ObjectDisable field :title, type: String, localize: true diff --git a/app/models/book_type.rb b/app/models/book_type.rb index 78bb90c..269fb20 100644 --- a/app/models/book_type.rb +++ b/app/models/book_type.rb @@ -1,10 +1,8 @@ class BookType include Mongoid::Document include Mongoid::Timestamps - include Mongoid::Attributes::Dynamic - include OrbitCoreLib::ObjectDisable - field :title, type: String, localize: true + field :title, localize: true has_many :books -end +end \ No newline at end of file diff --git a/app/views/admin/book_author_types/_form.html.erb b/app/views/admin/book_author_types/_form.html.erb new file mode 100644 index 0000000..0f3359b --- /dev/null +++ b/app/views/admin/book_author_types/_form.html.erb @@ -0,0 +1,24 @@ +<%= form_for(@author_type, :html =>{:class=>"form-horizontal", :style=>"margin: 0;"}, :remote => true, :url => @url ) do |f| %> + + + + + +<% end %> \ No newline at end of file diff --git a/app/views/admin/book_author_types/_list.js.erb b/app/views/admin/book_author_types/_list.js.erb new file mode 100644 index 0000000..462b50a --- /dev/null +++ b/app/views/admin/book_author_types/_list.js.erb @@ -0,0 +1,2 @@ +$('#author_types tbody').html("<%= j render :partial => '/admin/books/list_author_type', :collection => @author_types %>"); +$('#author_type_modal').modal('hide'); \ No newline at end of file diff --git a/app/views/admin/book_author_types/create_book_setting.js.erb b/app/views/admin/book_author_types/create_book_setting.js.erb deleted file mode 100644 index 9913b08..0000000 --- a/app/views/admin/book_author_types/create_book_setting.js.erb +++ /dev/null @@ -1,2 +0,0 @@ -$("#myModal2").modal('hide'); -$('<%= j render :partial => 'admin/books/list_author_type', :collection => [@book_author_type] %>').appendTo('#author_types').hide().fadeIn(); \ No newline at end of file diff --git a/app/views/admin/book_author_types/delete_book_setting.js.erb b/app/views/admin/book_author_types/delete_book_setting.js.erb deleted file mode 100644 index 1958000..0000000 --- a/app/views/admin/book_author_types/delete_book_setting.js.erb +++ /dev/null @@ -1,3 +0,0 @@ -$('.delete_author').bind('ajax:success', function() { - $(this).closest('tr').fadeOut(); -}); \ No newline at end of file diff --git a/app/views/admin/book_author_types/edit.js.erb b/app/views/admin/book_author_types/edit.js.erb new file mode 100644 index 0000000..3ac7380 --- /dev/null +++ b/app/views/admin/book_author_types/edit.js.erb @@ -0,0 +1 @@ +$('#author_type_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/book_author_types/new.js.erb b/app/views/admin/book_author_types/new.js.erb new file mode 100644 index 0000000..3ac7380 --- /dev/null +++ b/app/views/admin/book_author_types/new.js.erb @@ -0,0 +1 @@ +$('#author_type_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/book_author_types/update_book_setting.js.erb b/app/views/admin/book_author_types/update_book_setting.js.erb deleted file mode 100644 index 4a57749..0000000 --- a/app/views/admin/book_author_types/update_book_setting.js.erb +++ /dev/null @@ -1,2 +0,0 @@ -$("#myModal2").modal('hide'); -$("#<%= dom_id @book_author_type %>").replaceWith("<%= j render :partial => 'admin/books/list_author_type', :collection => [@book_author_type] %>"); \ No newline at end of file diff --git a/app/views/admin/book_types/_form.html.erb b/app/views/admin/book_types/_form.html.erb new file mode 100644 index 0000000..69a05df --- /dev/null +++ b/app/views/admin/book_types/_form.html.erb @@ -0,0 +1,24 @@ +<%= form_for(@book_type, :html =>{:class=>"form-horizontal", :style=>"margin: 0;"}, :remote => true, :url => @url ) do |f| %> + + + + + +<% end %> \ No newline at end of file diff --git a/app/views/admin/book_types/_list.js.erb b/app/views/admin/book_types/_list.js.erb new file mode 100644 index 0000000..504eddc --- /dev/null +++ b/app/views/admin/book_types/_list.js.erb @@ -0,0 +1,2 @@ +$('#book_types tbody').html("<%= j render :partial => '/admin/books/list_book_type', :collection => @book_types %>"); +$('#book_type_modal').modal('hide'); \ No newline at end of file diff --git a/app/views/admin/book_types/create_book_setting.js.erb b/app/views/admin/book_types/create_book_setting.js.erb deleted file mode 100644 index db9dce7..0000000 --- a/app/views/admin/book_types/create_book_setting.js.erb +++ /dev/null @@ -1,2 +0,0 @@ -$("#myModal1").modal('hide'); -$('<%= j render :partial => 'admin/books/list_book_type', :collection => [@book_type] %>').appendTo('#level_types').hide().fadeIn(); \ No newline at end of file diff --git a/app/views/admin/book_types/delete_book_setting.js.erb b/app/views/admin/book_types/delete_book_setting.js.erb deleted file mode 100644 index eb842a2..0000000 --- a/app/views/admin/book_types/delete_book_setting.js.erb +++ /dev/null @@ -1,3 +0,0 @@ -$('.delete_level').bind('ajax:success', function() { - $(this).closest('tr').fadeOut(); -}); \ No newline at end of file diff --git a/app/views/admin/book_types/edit.js.erb b/app/views/admin/book_types/edit.js.erb new file mode 100644 index 0000000..a32915f --- /dev/null +++ b/app/views/admin/book_types/edit.js.erb @@ -0,0 +1 @@ +$('#book_type_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/book_types/new.js.erb b/app/views/admin/book_types/new.js.erb new file mode 100644 index 0000000..a32915f --- /dev/null +++ b/app/views/admin/book_types/new.js.erb @@ -0,0 +1 @@ +$('#book_type_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/book_types/update_book_setting.js.erb b/app/views/admin/book_types/update_book_setting.js.erb deleted file mode 100644 index 90c0a3c..0000000 --- a/app/views/admin/book_types/update_book_setting.js.erb +++ /dev/null @@ -1,2 +0,0 @@ -$("#myModal1").modal('hide'); -$("#<%= dom_id @book_type %>").replaceWith("<%= j render :partial => 'admin/books/list_book_type', :collection => [@book_type] %>"); \ No newline at end of file diff --git a/app/views/admin/books/_author_type_qe.html.erb b/app/views/admin/books/_author_type_qe.html.erb deleted file mode 100644 index 97f5463..0000000 --- a/app/views/admin/books/_author_type_qe.html.erb +++ /dev/null @@ -1,27 +0,0 @@ -<% # encoding: utf-8 %> -<%= form_for(@set_author_type, :remote => true, :url => @author_type_url ) do |f| %> - - - - -<% end %> - \ No newline at end of file diff --git a/app/views/admin/books/_book_type_qe.html.erb b/app/views/admin/books/_book_type_qe.html.erb deleted file mode 100644 index 82fefa3..0000000 --- a/app/views/admin/books/_book_type_qe.html.erb +++ /dev/null @@ -1,28 +0,0 @@ -<% # encoding: utf-8 %> - -<%= form_for(@set_book_type, :remote => true, :url => @book_type_url ) do |f| %> - - - diff --git a/app/views/admin/books/_list_author_type.html.erb b/app/views/admin/books/_list_author_type.html.erb index 4d54ba3..9fe8504 100644 --- a/app/views/admin/books/_list_author_type.html.erb +++ b/app/views/admin/books/_list_author_type.html.erb @@ -1,11 +1,10 @@ <% # encoding: utf-8 %> - - <%= list_author_type.title %> - - - <%= t('edit')%> - <%= link_to 'Delete', - polymorphic_path([:admin, list_author_type]), data: { confirm: t('sure?') }, method: :delete, remote:true, class: "delete_author archive_toggle action" %> - - \ No newline at end of file + + <%= list_author_type.title %> + + + <%= t(:edit) %> + <%= link_to t(:delete_), admin_book_author_type_path(list_author_type), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %> + + \ No newline at end of file diff --git a/app/views/admin/books/_list_book_type.html.erb b/app/views/admin/books/_list_book_type.html.erb index 5e3a539..60e88c7 100644 --- a/app/views/admin/books/_list_book_type.html.erb +++ b/app/views/admin/books/_list_book_type.html.erb @@ -1,10 +1,8 @@ -<% # encoding: utf-8 %> - - - <%= list_book_type.title %> - - - <%= t('edit')%> - <%= link_to 'Delete', polymorphic_path([:admin, list_book_type]), data: { confirm: t('sure?') }, method: :delete, remote: true, class: "delete_level archive_toggle action" %> - - \ No newline at end of file + + <%= list_book_type.title %> + + + <%= t(:edit) %> + <%= link_to t(:delete_), admin_book_type_path(list_book_type), "data-confirm" => t('sure?'), :method => :delete, :remote => true,:class=>"archive_toggle action" %> + + \ No newline at end of file diff --git a/app/views/admin/books/_writing_book.html.erb b/app/views/admin/books/_writing_book.html.erb index cb08834..53140f2 100644 --- a/app/views/admin/books/_writing_book.html.erb +++ b/app/views/admin/books/_writing_book.html.erb @@ -2,16 +2,16 @@ <%= writing_book.year %> - <%= link_to writing_book.create_link, page_for_book(writing_book), target: "blank" %> + <%= link_to writing_book.create_link, OrbitHelper.url_to_plugin_show(writing_book.to_param,'personal_book'), target: "blank" %>
- <%= writing_book.authors%> + <%= writing_book.member_profile.name rescue "" %> -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/admin/books/add_author_type.js.erb b/app/views/admin/books/add_author_type.js.erb deleted file mode 100644 index d94a00e..0000000 --- a/app/views/admin/books/add_author_type.js.erb +++ /dev/null @@ -1 +0,0 @@ -$("#myModal2").html("<%= j render "author_type_qe" %>"); \ No newline at end of file diff --git a/app/views/admin/books/add_book_type.js.erb b/app/views/admin/books/add_book_type.js.erb deleted file mode 100644 index 2694557..0000000 --- a/app/views/admin/books/add_book_type.js.erb +++ /dev/null @@ -1 +0,0 @@ -$("#myModal1").html("<%= j render "book_type_qe" %>"); \ No newline at end of file diff --git a/app/views/admin/books/book_setting.html.erb b/app/views/admin/books/book_setting.html.erb deleted file mode 100644 index 036484b..0000000 --- a/app/views/admin/books/book_setting.html.erb +++ /dev/null @@ -1,97 +0,0 @@ -<% # encoding: utf-8 %> -
-
-
-

- <%= t('add')%> - <%= t("personal_book.book_paper_type") %> -

-
-
-
-
-
-
-
-
-
-
- - - <%= render partial: 'list_book_type', collection: @book_types %> - -
-
-
-
-
-
- -
-
-

- <%= t('add')%> - <%= t("personal_book.author_type") %> -

-
-
-
-
-
-
-
-
-
-
- - - <%= render partial: 'list_author_type', collection: @author_types %> - -
-
-
-
-
-
-
-
- - <%= 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' %> -
- - -
- -
- -
- -
- - \ No newline at end of file diff --git a/app/views/admin/books/create_book_setting.js.erb b/app/views/admin/books/create_book_setting.js.erb deleted file mode 100644 index 86fccec..0000000 --- a/app/views/admin/books/create_book_setting.js.erb +++ /dev/null @@ -1,9 +0,0 @@ -<% 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 %> \ No newline at end of file diff --git a/app/views/admin/books/edit_author_type.js.erb b/app/views/admin/books/edit_author_type.js.erb deleted file mode 100644 index d94a00e..0000000 --- a/app/views/admin/books/edit_author_type.js.erb +++ /dev/null @@ -1 +0,0 @@ -$("#myModal2").html("<%= j render "author_type_qe" %>"); \ No newline at end of file diff --git a/app/views/admin/books/edit_book_type.js.erb b/app/views/admin/books/edit_book_type.js.erb deleted file mode 100644 index 2694557..0000000 --- a/app/views/admin/books/edit_book_type.js.erb +++ /dev/null @@ -1 +0,0 @@ -$("#myModal1").html("<%= j render "book_type_qe" %>"); \ No newline at end of file diff --git a/app/views/admin/books/frontend_setting.html.erb b/app/views/admin/books/frontend_setting.html.erb new file mode 100644 index 0000000..7a987f3 --- /dev/null +++ b/app/views/admin/books/frontend_setting.html.erb @@ -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(:book_intro, :url => update_frontend_setting_admin_books_path, :method => "post", html: {class: "form-horizontal main-forms previewable"} ) do |f| %> +
+ +
+ + + + + + +
+ +
+ <% if !@member.blank? %> +
+ +
+ <%= @member.name rescue ''%> + <%= f.hidden_field :member_profile_id, :value => @member.id %> +
+
+ <% end %> + +
+ +
+ <%= f.check_box :brief_intro, :checked => @intro.brief_intro %> <%= t("personal_plugins.brief_intro") %> + <%= f.check_box :complete_list, :checked => @intro.complete_list %> <%= t("personal_plugins.complete_list") %> +
+
+
+
+ + + + + + +
+ + <% @site_in_use_locales.each_with_index do |locale, i| %> + +
"> + + +
+ +
+
+ <%= 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 %> +
+
+
+ + +
+ + <% end %> + + + +
+ + + +
+ + +
+ <%= 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" %> +
+
+<% end %> \ No newline at end of file diff --git a/app/views/admin/books/setting.html.erb b/app/views/admin/books/setting.html.erb new file mode 100644 index 0000000..20e7e0a --- /dev/null +++ b/app/views/admin/books/setting.html.erb @@ -0,0 +1,83 @@ + + +
+
+
+

+ <%= t('add')%> + <%= t("personal_book.book_paper_type") %> +

+
+
+
+
+
+
+
+
+
+
+ + + <%= render :partial => 'list_book_type', :collection => @book_types %> + +
+
+
+
+
+
+ +
+
+

+ <%= t('add')%> + <%= t("personal_book.author_type") %> +

+
+
+
+
+
+
+
+
+
+
+ + + <%= render :partial => 'list_author_type', :collection => @author_types %> + +
+
+
+
+
+
+ +
+ +
+ +
+ +
\ No newline at end of file diff --git a/app/views/admin/books/update_book_setting.js.erb b/app/views/admin/books/update_book_setting.js.erb deleted file mode 100644 index b6c897c..0000000 --- a/app/views/admin/books/update_book_setting.js.erb +++ /dev/null @@ -1,9 +0,0 @@ -<% 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 %> \ No newline at end of file diff --git a/app/views/books/index.html.erb b/app/views/personal_books/index.html.erb similarity index 100% rename from app/views/books/index.html.erb rename to app/views/personal_books/index.html.erb diff --git a/app/views/books/show.html.erb b/app/views/personal_books/show.html.erb similarity index 100% rename from app/views/books/show.html.erb rename to app/views/personal_books/show.html.erb diff --git a/app/views/plugin/book/_profile.html.erb b/app/views/plugin/personal_book/_profile.html.erb similarity index 57% rename from app/views/plugin/book/_profile.html.erb rename to app/views/plugin/personal_book/_profile.html.erb index 42e4299..336fa9e 100644 --- a/app/views/plugin/book/_profile.html.erb +++ b/app/views/plugin/personal_book/_profile.html.erb @@ -6,39 +6,20 @@ <% 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 - - is_autorized_user = (current_user==@member.user || current_user.is_admin?) - if is_autorized_user + if has_access? @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 has_access? %> -
-
- <%= 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') ) %> +
+
+ <%= link_to('Hide', '#', :class => "btn btn-mini list-active-btn disabled", "data-check-action" => "list-be-hide", :rel => toggle_hide_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 => toggle_hide_admin_books_path(member_profile_id: params[:id], disable: 'false') ) %> +
-
<% end -%> @@ -66,7 +47,7 @@ <% end -%>
<%= book.year %> - <%= link_to book.create_link, page_for_book(book), target: "blank"%> + <%= link_to book.create_link, OrbitHelper.url_to_plugin_show(book.to_param,'personal_book'), target: "blank"%> <% if has_access? %>
-<% if has_access? %> +
- -
- <%= 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' %> -
+ <% if has_access? %> +
+ <%= link_to content_tag(:i, nil, :class => 'icon-edit') +' '+ t('setting'),'/admin/members/'+@member.to_param+'/books/frontend_setting', :class => 'btn btn-primary' %> + <%= link_to content_tag(:i, nil, :class => 'icon-plus') +' '+ t('new_'), + '/admin/members/'+@member.to_param+'/books/new', :class => 'btn btn-primary' %> +
+ <% end %>
-<% end %>