From 41d11e12a3193d5ede72ca70aa7ba97c259bfe41 Mon Sep 17 00:00:00 2001 From: spen Date: Fri, 9 Jan 2015 15:30:13 +0800 Subject: [PATCH] something fix --- .../admin/journal_levels_controller.rb | 52 +-- .../journal_paper_author_types_controller.rb | 50 +-- .../admin/journal_paper_intros_controller.rb | 8 - .../admin/journal_paper_types_controller.rb | 49 +-- .../admin/journal_papers_controller.rb | 216 +++------- app/controllers/journal_papers_controller.rb | 52 --- .../personal_journals_controller.rb | 52 +++ app/helpers/admin/journal_levels_helper.rb | 2 - .../journal_paper_author_types_helper.rb | 2 - .../admin/journal_paper_intros_helper.rb | 2 - .../admin/journal_paper_types_helper.rb | 2 - app/helpers/admin/journal_papers_helper.rb | 44 +- app/helpers/journal_papers_helper.rb | 2 - app/models/journal_level.rb | 3 - app/models/journal_paper.rb | 11 +- app/models/journal_paper_author_type.rb | 2 - app/models/journal_paper_type.rb | 2 - app/views/admin/journal_levels/_form.html.erb | 24 ++ app/views/admin/journal_levels/_index.js.erb | 2 + .../create_writing_journal_setting.js.erb | 2 - .../delete_journal_setting.js.erb | 3 - app/views/admin/journal_levels/edit.js.erb | 1 + app/views/admin/journal_levels/new.js.erb | 1 + .../update_writing_journal_setting.js.erb | 2 - .../journal_paper_author_types/_form.html.erb | 24 ++ .../journal_paper_author_types/_list.js.erb | 2 + .../create_writing_journal_setting.js.erb | 2 - .../delete_journal_setting.js.erb | 3 - .../journal_paper_author_types/edit.js.erb | 1 + .../journal_paper_author_types/new.js.erb | 1 + .../update_writing_journal_setting.js.erb | 2 - .../admin/journal_paper_types/_form.html.erb | 24 ++ .../admin/journal_paper_types/_index.js.erb | 2 + .../create_writing_journal_setting.js.erb | 2 - .../delete_journal_setting.js.erb | 3 - .../admin/journal_paper_types/edit.js.erb | 1 + .../admin/journal_paper_types/new.js.erb | 1 + .../update_writing_journal_setting.js.erb | 2 - .../_author_autocomplete.html.erb | 33 -- .../journal_papers/_author_type_qe.html.erb | 33 -- .../admin/journal_papers/_filter.html.erb | 9 - app/views/admin/journal_papers/_form.html.erb | 391 +++++++++--------- .../journal_papers/_level_type_qe.html.erb | 34 -- .../journal_papers/_list_author_type.html.erb | 17 +- .../journal_papers/_list_level_type.html.erb | 17 +- .../journal_papers/_list_paper_type.html.erb | 17 +- .../journal_papers/_paper_type_qe.html.erb | 29 -- .../journal_papers/_sort_headers.html.erb | 0 .../journal_papers/_writing_journal.html.erb | 2 +- .../journal_papers/add_author_type.js.erb | 1 - .../admin/journal_papers/add_level.js.erb | 1 - .../journal_papers/add_paper_type.js.erb | 1 - .../create_writing_journal_setting.js.erb | 15 - .../journal_papers/edit_author_type.js.erb | 1 - .../admin/journal_papers/edit_level.js.erb | 1 - .../journal_papers/edit_paper_type.js.erb | 1 - .../journal_papers/frontend_setting.html.erb | 93 +++++ app/views/admin/journal_papers/index.html.erb | 2 +- .../level_type_quick_add.js.erb | 1 - .../admin/journal_papers/setting.html.erb | 116 ++++++ .../update_writing_journal_setting.js.erb | 14 - .../writing_journal_setting.html.erb | 131 ------ .../index.html.erb | 0 .../show.html.erb | 0 .../_profile.html.erb | 29 +- config/locales/en.yml | 1 + config/locales/zh_tw.yml | 3 +- config/routes.rb | 53 ++- lib/personal_journal/engine.rb | 7 +- ...urnal_tasks.rake => personal_journal.rake} | 0 70 files changed, 768 insertions(+), 941 deletions(-) delete mode 100644 app/controllers/admin/journal_paper_intros_controller.rb delete mode 100644 app/controllers/journal_papers_controller.rb create mode 100644 app/controllers/personal_journals_controller.rb delete mode 100644 app/helpers/admin/journal_levels_helper.rb delete mode 100644 app/helpers/admin/journal_paper_author_types_helper.rb delete mode 100644 app/helpers/admin/journal_paper_intros_helper.rb delete mode 100644 app/helpers/admin/journal_paper_types_helper.rb delete mode 100644 app/helpers/journal_papers_helper.rb create mode 100644 app/views/admin/journal_levels/_form.html.erb create mode 100644 app/views/admin/journal_levels/_index.js.erb delete mode 100644 app/views/admin/journal_levels/create_writing_journal_setting.js.erb delete mode 100644 app/views/admin/journal_levels/delete_journal_setting.js.erb create mode 100644 app/views/admin/journal_levels/edit.js.erb create mode 100644 app/views/admin/journal_levels/new.js.erb delete mode 100644 app/views/admin/journal_levels/update_writing_journal_setting.js.erb create mode 100644 app/views/admin/journal_paper_author_types/_form.html.erb create mode 100644 app/views/admin/journal_paper_author_types/_list.js.erb delete mode 100644 app/views/admin/journal_paper_author_types/create_writing_journal_setting.js.erb delete mode 100644 app/views/admin/journal_paper_author_types/delete_journal_setting.js.erb create mode 100644 app/views/admin/journal_paper_author_types/edit.js.erb create mode 100644 app/views/admin/journal_paper_author_types/new.js.erb delete mode 100644 app/views/admin/journal_paper_author_types/update_writing_journal_setting.js.erb create mode 100644 app/views/admin/journal_paper_types/_form.html.erb create mode 100644 app/views/admin/journal_paper_types/_index.js.erb delete mode 100644 app/views/admin/journal_paper_types/create_writing_journal_setting.js.erb delete mode 100644 app/views/admin/journal_paper_types/delete_journal_setting.js.erb create mode 100644 app/views/admin/journal_paper_types/edit.js.erb create mode 100644 app/views/admin/journal_paper_types/new.js.erb delete mode 100644 app/views/admin/journal_paper_types/update_writing_journal_setting.js.erb delete mode 100644 app/views/admin/journal_papers/_author_autocomplete.html.erb delete mode 100644 app/views/admin/journal_papers/_author_type_qe.html.erb delete mode 100644 app/views/admin/journal_papers/_filter.html.erb delete mode 100644 app/views/admin/journal_papers/_level_type_qe.html.erb delete mode 100644 app/views/admin/journal_papers/_paper_type_qe.html.erb delete mode 100644 app/views/admin/journal_papers/_sort_headers.html.erb delete mode 100644 app/views/admin/journal_papers/add_author_type.js.erb delete mode 100644 app/views/admin/journal_papers/add_level.js.erb delete mode 100644 app/views/admin/journal_papers/add_paper_type.js.erb delete mode 100644 app/views/admin/journal_papers/create_writing_journal_setting.js.erb delete mode 100644 app/views/admin/journal_papers/edit_author_type.js.erb delete mode 100644 app/views/admin/journal_papers/edit_level.js.erb delete mode 100644 app/views/admin/journal_papers/edit_paper_type.js.erb create mode 100644 app/views/admin/journal_papers/frontend_setting.html.erb delete mode 100644 app/views/admin/journal_papers/level_type_quick_add.js.erb create mode 100644 app/views/admin/journal_papers/setting.html.erb delete mode 100644 app/views/admin/journal_papers/update_writing_journal_setting.js.erb delete mode 100644 app/views/admin/journal_papers/writing_journal_setting.html.erb rename app/views/{journal_papers => personal_journals}/index.html.erb (100%) rename app/views/{journal_papers => personal_journals}/show.html.erb (100%) rename app/views/plugin/{journal_paper => personal_journal}/_profile.html.erb (68%) rename lib/tasks/{personal_journal_tasks.rake => personal_journal.rake} (100%) diff --git a/app/controllers/admin/journal_levels_controller.rb b/app/controllers/admin/journal_levels_controller.rb index 6ddd63c..d502f9d 100644 --- a/app/controllers/admin/journal_levels_controller.rb +++ b/app/controllers/admin/journal_levels_controller.rb @@ -1,51 +1,43 @@ class Admin::JournalLevelsController < OrbitMemberController before_action :allow_admin_only - before_action :set_journal_level, only: [:edit, :update, :destroy] - - def initialize - super - @app_type = 'journal_level' - end - + def new - @journal_level = JournalLevel.new + @paper_level = JournalLevel.new + @url = admin_journal_levels_path(@paper_level) + render :layout=>false end def create - @journal_level = JournalLevel.new(journal_level_attributes) - respond_to do |format| - if @journal_level.save - format.js { render 'create_writing_journal_setting' } - end - end + @paper_level = JournalLevel.new(paper_level_params) + @paper_level.save + @paper_levels = JournalLevel.all + render :partial=>'index', :layout=>false end def edit + @paper_level = JournalLevel.find(params[:id]) + @url = admin_journal_level_path(@paper_level) + render :layout=>false end def update - respond_to do |format| - if @journal_level.update_attributes(journal_level_attributes) - format.js { render 'update_writing_journal_setting' } - end - end + @paper_level = JournalLevel.find(params[:id]) + @paper_level.update_attributes(paper_level_params) + @paper_level.save + @paper_levels = JournalLevel.all + render :partial=>'index', :layout=>false end def destroy - @journal_level.destroy - respond_to do |format| - format.js { render 'delete_journal_setting' } - end + paper_level = JournalLevel.find(params[:id]) + paper_level.destroy + @paper_levels = JournalLevel.all + render :partial=>'index', :layout=>false end private - def set_journal_level - @journal_level = JournalLevel.find(params[:id]) - end - - def journal_level_attributes + def paper_level_params params.require(:journal_level).permit! rescue nil end - -end +end \ No newline at end of file diff --git a/app/controllers/admin/journal_paper_author_types_controller.rb b/app/controllers/admin/journal_paper_author_types_controller.rb index 6aa7110..5645a3d 100644 --- a/app/controllers/admin/journal_paper_author_types_controller.rb +++ b/app/controllers/admin/journal_paper_author_types_controller.rb @@ -1,51 +1,43 @@ class Admin::JournalPaperAuthorTypesController < OrbitMemberController before_action :allow_admin_only - before_action :set_journal_paper_author_type, only: [:edit, :update, :destroy] - - def initialize - super - @app_type = 'journal_paper_author_type' - end - + def new - @journal_author_type = JournalPaperAuthorType.new + @author_type = JournalPaperAuthorType.new + @url = admin_journal_paper_author_types_path(@author_type) + render :layout=>false end def create - @journal_author_type = JournalPaperAuthorType.new(journal_paper_author_type_attributes) - respond_to do |format| - if @journal_author_type.save - format.js { render 'create_writing_journal_setting' } - end - end + @author_type = JournalPaperAuthorType.new(author_type_params) + @author_type.save + @author_types = JournalPaperAuthorType.all + render :partial=>'list', :layout=>false end def edit + @author_type = JournalPaperAuthorType.find(params[:id]) + @url = admin_journal_paper_author_type_path(@author_type) + render :layout=>false end def update - respond_to do |format| - if @journal_author_type.update_attributes(journal_paper_author_type_attributes) - format.js { render 'update_writing_journal_setting' } - end - end + @author_type = JournalPaperAuthorType.find(params[:id]) + @author_type.update_attributes(author_type_params) + @author_type.save + @author_types = JournalPaperAuthorType.all + render :partial=>'list', :layout=>false end def destroy - @journal_author_type.destroy - respond_to do |format| - format.js { render 'delete_journal_setting' } - end + author_type = JournalPaperAuthorType.find(params[:id]) + author_type.destroy + @author_types = JournalPaperAuthorType.all + render :partial=>'list', :layout=>false end private - def set_journal_paper_author_type - @journal_author_type = JournalPaperAuthorType.find(params[:id]) - end - - def journal_paper_author_type_attributes + def author_type_params params.require(:journal_paper_author_type).permit! rescue nil end - end diff --git a/app/controllers/admin/journal_paper_intros_controller.rb b/app/controllers/admin/journal_paper_intros_controller.rb deleted file mode 100644 index f2efd52..0000000 --- a/app/controllers/admin/journal_paper_intros_controller.rb +++ /dev/null @@ -1,8 +0,0 @@ -class Admin::JournalPaperIntrosController < Admin::PersonalPluginIntrosController - def initialize - super - @app_type = 'journal_paper_intro' - @app_type_name = 'journal_paper' - @reback_name = 'JournalPaper' - end -end diff --git a/app/controllers/admin/journal_paper_types_controller.rb b/app/controllers/admin/journal_paper_types_controller.rb index b7144a6..0adeeac 100644 --- a/app/controllers/admin/journal_paper_types_controller.rb +++ b/app/controllers/admin/journal_paper_types_controller.rb @@ -1,50 +1,43 @@ class Admin::JournalPaperTypesController < OrbitMemberController before_action :allow_admin_only - before_action :set_journal_paper_type, only: [:edit, :update, :destroy] - - def initialize - super - @app_type = 'journal_paper_type' - end - + def new - @journal_paper_type = JournalPaperType.new + @paper_type = JournalPaperType.new + @url = admin_journal_paper_types_path(@paper_type) + render :layout=>false end def create - @journal_paper_type = JournalPaperType.new(journal_paper_type_attributes) - respond_to do |format| - if @journal_paper_type.save - format.js { render 'create_writing_journal_setting' } - end - end + @paper_type = JournalPaperType.new(paper_type_params) + @paper_type.save + @paper_types = JournalPaperType.all + render :partial=>'index', :layout=>false end def edit + @paper_type = JournalPaperType.find(params[:id]) + @url = admin_journal_paper_type_path(@paper_type) + render :layout=>false end def update - respond_to do |format| - if @journal_paper_type.update_attributes(journal_paper_type_attributes) - format.js { render 'update_writing_journal_setting' } - end - end + @paper_type = JournalPaperType.find(params[:id]) + @paper_type.update_attributes(paper_type_params) + @paper_type.save + @paper_types = JournalPaperType.all + render :partial=>'index', :layout=>false end def destroy - @journal_paper_type.destroy - respond_to do |format| - format.js { render 'delete_journal_setting' } - end + paper_type = JournalPaperType.find(params[:id]) + paper_type.destroy + @paper_types = JournalPaperType.all + render :partial=>'index', :layout=>false end private - def set_journal_paper_type - @journal_paper_type = JournalPaperType.find(params[:id]) - end - - def journal_paper_type_attributes + def paper_type_params params.require(:journal_paper_type).permit! rescue nil end end diff --git a/app/controllers/admin/journal_papers_controller.rb b/app/controllers/admin/journal_papers_controller.rb index e0ae30a..7166af5 100644 --- a/app/controllers/admin/journal_papers_controller.rb +++ b/app/controllers/admin/journal_papers_controller.rb @@ -2,177 +2,104 @@ class Admin::JournalPapersController < OrbitMemberController include Admin::JournalPapersHelper layout "member_plugin" - before_action :set_journal_paper, only: [:show, :edit , :update] - before_action :get_plugins, only: [:index, :writing_journal_setting, :new, :create, :edit, :update] - before_action :set_types, only: [:writing_journal_setting, :new, :edit, :create, :update] - before_action :find_journal_paper, only: [:destroy] + before_action :set_journal_paper, 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, :writing_journal_setting] + before_action :allow_admin_only, :only => [:index, :setting] def index @writing_journals = JournalPaper.order_by(:year=>'desc').page(params[:page]).per(10) - respond_to do |format| - format.html # index.html.erb - format.js { } - format.xml { render :xml => @writing_journals } - end - - end - - def show - respond_to do |format| - format.html # show.html.erb - format.xml { render :xml => @journal_paper } - end end def new - @journal_paper = JournalPaper.new @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil + @journal_paper = JournalPaper.new + if params[:desktop] render :layout => false end end + def create + @member = MemberProfile.find(journal_paper_params['member_profile_id']) rescue nil + @journal_paper = JournalPaper.new(journal_paper_params) + @journal_paper.save + if params[:desktop] == "true" + render json: {"data" => get_paper_list}.to_json + else + redirect_to params['referer_url'] + end + end + def edit @member = @journal_paper.member_profile - if params[:desktop] + if params[:desktop] render :layout => false end end - def create - @journal_paper = JournalPaper.new(journal_paper_attributes) - respond_to do |format| - if @journal_paper.save - if params[:desktop] == "true" - format.json { render json: get_paper_list } - end - format.html { redirect_to params['referer_url'] } - format.json { render action: 'show', status: :created, location: @journal_paper } - else - format.html { render action: 'new' } - format.json { render json: @journal_paper.errors, status: :unprocessable_entity } - end - end - end - def update - respond_to do |format| - if @journal_paper.update_attributes(journal_paper_attributes) - if params[:desktop] == "true" - format.json { render json: get_paper_list } - end - format.html { redirect_to params['referer_url'] } - # format.js { render 'toggle_enable' } - format.json { head :no_content } - else - format.html { render action: "edit" } - format.json { render json: @journal_paper.errors, status: :unprocessable_entity } - end + @member = @journal_paper.member_profile + @journal_paper.update_attributes(journal_paper_params) + @journal_paper.save + if params[:desktop] == "true" + render json: {"data" => get_paper_list}.to_json + else + redirect_to params['referer_url'] end end def destroy @journal_paper.destroy - respond_to do |format| - format.html { redirect_to(admin_journal_papers_url) } + respond_to do |format| + format.html { redirect_to(admin_journal_paper_url) } # format.xml { head :ok } format.js format.json {render json: {"success" => true}} end end - def delete - end - - def writing_journal_setting - - @set_level_type = JournalLevel.new(display: 'List') - @level_type_url = admin_journal_papers_path - - @set_author_type = JournalPaperAuthorType.new(display: 'List') - @author_type_url = admin_journal_papers_path - - @set_paper_type = JournalPaperType.new(display: 'List') - @paper_type_url = admin_journal_papers_path - end - - def add_level - @set_level_type = JournalLevel.new(display: 'List') - @level_type_url = admin_journal_levels_path - @set_level_type.id = params[:id] - - respond_to do |format| - format.js - end - end - - def edit_level - @set_level_type = JournalLevel.find(params[:journal_paper_id]) - @level_type_url = admin_journal_level_path(@set_level_type) - - respond_to do |format| - format.js - end - end - - def add_author_type - @set_author_type = JournalPaperAuthorType.new(display: 'List') - @author_type_url = admin_journal_paper_author_types_path - @set_author_type.id = params[:id] - - respond_to do |format| - format.js - end - end - - def edit_author_type - @set_author_type = JournalPaperAuthorType.find(params[:journal_paper_id]) - @author_type_url = admin_journal_paper_author_type_path(@set_author_type) - - respond_to do |format| - format.js - end - end - - def add_paper_type - @set_paper_type = JournalPaperType.new(:display => 'List') - @paper_type_url = admin_journal_paper_types_path - @set_paper_type.id = params[:id] - - respond_to do |format| - format.js - end - - end - - def edit_paper_type - @set_paper_type = JournalPaperType.find(params[:journal_paper_id]) - @paper_type_url = admin_journal_paper_type_path(@set_paper_type) - - respond_to do |format| - format.js - end - end - - def data_share + def toggle_hide if params[:ids] - @writing_journals = JournalPaper.any_in(_id: params[:ids]) + @journal_papers = JournalPaper.any_in(_id: params[:ids]) - @writing_journals.each do |writing_journal| - writing_journal.is_hidden = params[:disable] - writing_journal.save + @journal_papers.each do |journal_paper| + journal_paper.is_hidden = params[:disable] + journal_paper.save end end - respond_to do |format| - format.html { redirect_to(admin_member_path(id: params[:member_profile_id],show_plugin_profile: "JournalPaper")) } - format.json { render json: {"success"=>true}.to_json} - end + render json: {"success"=>true} + end + def setting + end + + def frontend_setting + @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil + @intro = JournalPaperIntro.find_by(:member_profile_id=>@member.id) rescue nil + @intro = @intro.nil? ? JournalPaperIntro.new({:member_profile_id=>@member.id}) : @intro + end + + def update_frontend_setting + @member = MemberProfile.find(intro_params['member_profile_id']) rescue nil + @intro = JournalPaperIntro.find_by(:member_profile_id=>@member.id) rescue nil + @intro = @intro.nil? ? JournalPaperIntro.new({:member_profile_id=>@member.id}) : @intro + @intro.update_attributes(intro_params) + @intro.save + redirect_to URI.encode('/admin/members/'+@member.to_param+'/JournalPaper') + end + + def get_settings + @journal_levels = JournalLevel.all + @author_types = JournalPaperAuthorType.all + @paper_types = JournalPaperType.all + end + + def set_plugin + @plugin = OrbitApp::Plugin::Registration.all.select{|plugin| plugin.app_name.eql? 'JournalPaper'}.first end private @@ -186,29 +113,14 @@ class Admin::JournalPapersController < OrbitMemberController uid = path[-2].split("-").last uid = uid.split("?").first end - @journal_paper = JournalPaper.find_by(uid: uid) + @journal_paper = JournalPaper.find_by(:uid => uid) rescue JournalPaper.find(params[:id]) end - def find_journal_paper - @journal_paper = JournalPaper.find_by(id: params[:id]) + def journal_paper_params + params.require(:journal_paper).permit! rescue nil end - def journal_paper_attributes - params.require(:journal_paper).permit! rescue nil + def intro_params + params.require(:journal_paper_intro).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? 'JournalPaper'}.first - end - - def set_types - @journal_levels = JournalLevel.all - @author_types = JournalPaperAuthorType.all - @paper_types = JournalPaperType.all - end - end diff --git a/app/controllers/journal_papers_controller.rb b/app/controllers/journal_papers_controller.rb deleted file mode 100644 index cd2477c..0000000 --- a/app/controllers/journal_papers_controller.rb +++ /dev/null @@ -1,52 +0,0 @@ -class JournalPapersController < ApplicationController - def index - journal_papers = JournalPaper.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) - journal_paper_list = journal_papers.collect do |journal_paper| - { - "year" => journal_paper.year, - "paper_title" => journal_paper.create_link, - "author" => journal_paper.authors, - "link_to_show" => OrbitHelper.url_to_show(journal_paper.to_param) - } - end - { - "journal_papers" => journal_paper_list, - "extras" => { - "widget-title" => t("module_name.journal_paper"), - "th_year" => t('personal_plugins.year'), - "th_title" => t("personal_conference.paper_title"), - "th_author" => t('personal_plugins.author') - }, - "total_pages" => journal_papers.total_pages - } - end - - def show - params = OrbitHelper.params - plugin = JournalPaper.find_by(uid: params[:uid]) - fields_to_show = [ - "paper_title", - "journal_title", - "level_type", - "paper_type", - "author_name", - "authors", - "author_type", - "year", - "publication_date", - "language", - "vol_no", - "issue_no", - "form_to_start", - "form_to_end", - "total_pages", - "isbn", - "url", - "associated_project", - "note", - "file" - ] - - {"plugin_datas"=>plugin.get_plugin_data(fields_to_show)} - end -end diff --git a/app/controllers/personal_journals_controller.rb b/app/controllers/personal_journals_controller.rb new file mode 100644 index 0000000..fa0ee76 --- /dev/null +++ b/app/controllers/personal_journals_controller.rb @@ -0,0 +1,52 @@ +class PersonalJournalsController < ApplicationController + def index + journal_papers = JournalPaper.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) + journal_paper_list = journal_papers.collect do |journal_paper| + { + "year" => journal_paper.year, + "paper_title" => journal_paper.create_link, + "author" => journal_paper.authors, + "link_to_show" => OrbitHelper.url_to_show(journal_paper.to_param) + } + end + { + "journal_papers" => journal_paper_list, + "extras" => { + "widget-title" => t("module_name.journal_paper"), + "th_year" => t('personal_plugins.year'), + "th_title" => t("personal_conference.paper_title"), + "th_author" => t('personal_plugins.author') + }, + "total_pages" => journal_papers.total_pages + } + end + + def show + params = OrbitHelper.params + plugin = JournalPaper.where(:is_hidden=>false).find_by(uid: params[:uid]) + fields_to_show = [ + "year", + "author_name", + "authors", + "author_type", + "paper_title", + "journal_title", + "vol_no", + "issue_no", + "form_to_start", + "form_to_end", + "level_type", + "paper_type", + "total_pages", + "publication_date", + "isbn", + "abstract", + "language", + "url", + "associated_project", + "file" + ] + + {"plugin_datas"=>plugin.get_plugin_data(fields_to_show)} + end +end diff --git a/app/helpers/admin/journal_levels_helper.rb b/app/helpers/admin/journal_levels_helper.rb deleted file mode 100644 index 94b8fa6..0000000 --- a/app/helpers/admin/journal_levels_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module Admin::JournalLevelsHelper -end diff --git a/app/helpers/admin/journal_paper_author_types_helper.rb b/app/helpers/admin/journal_paper_author_types_helper.rb deleted file mode 100644 index d3ca68e..0000000 --- a/app/helpers/admin/journal_paper_author_types_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module Admin::JournalPaperAuthorTypesHelper -end diff --git a/app/helpers/admin/journal_paper_intros_helper.rb b/app/helpers/admin/journal_paper_intros_helper.rb deleted file mode 100644 index 3dc03bf..0000000 --- a/app/helpers/admin/journal_paper_intros_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module Admin::JournalPaperIntrosHelper -end diff --git a/app/helpers/admin/journal_paper_types_helper.rb b/app/helpers/admin/journal_paper_types_helper.rb deleted file mode 100644 index bcb48da..0000000 --- a/app/helpers/admin/journal_paper_types_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module Admin::JournalPaperTypesHelper -end diff --git a/app/helpers/admin/journal_papers_helper.rb b/app/helpers/admin/journal_papers_helper.rb index d3da186..3607785 100644 --- a/app/helpers/admin/journal_papers_helper.rb +++ b/app/helpers/admin/journal_papers_helper.rb @@ -7,30 +7,30 @@ module Admin::JournalPapersHelper request.protocol+(request.host_with_port+journal_paper_page.url+'/'+journal_paper_object.to_param).gsub('//','/') rescue "/" end def get_paper_list - user = current_user.nil? ? OrbitHelper.current_user : current_user - user_profile = user.member_profile - journals = JournalPaper.where(:member_profile_id => user_profile.id) - journals = journals.collect do |j| - files = j.journal_paper_files.collect do |jpf| - { - "title" => jpf.title, - "description" => jpf.description, - "link" => jpf.journal_file.url, - "extension" => (jpf.journal_file.url.split(".").last rescue "") - } - end - + user = current_user.nil? ? OrbitHelper.current_user : current_user + user_profile = user.member_profile + journals = JournalPaper.where(:member_profile_id => user_profile.id) + journals = journals.collect do |j| + files = j.journal_paper_files.collect do |jpf| { - "id" => j.id.to_s, - "edit_url" => "/#{I18n.locale.to_s}/admin/journal_papers/#{j.to_param}/edit", - "delete_url" => "/#{I18n.locale.to_s}/admin/journal_papers/#{j.id.to_s}", - "paper_title" => j.paper_title, - "journal_title" => j.journal_title, - "keywords" => j.keywords, - "abstract" => j.abstract, - "files" => files + "title" => jpf.title, + "description" => jpf.description, + "link" => jpf.journal_file.url, + "extension" => (jpf.journal_file.url.split(".").last rescue "") } end - journals + + { + "id" => j.id.to_s, + "edit_url" => "/#{I18n.locale.to_s}/admin/members/#{user_profile.to_param}/journal_papers/#{j.to_param}/edit", + "delete_url" => "/#{I18n.locale.to_s}/admin/journal_papers/#{j.id.to_s}", + "paper_title" => j.paper_title, + "journal_title" => j.journal_title, + "keywords" => j.keywords, + "abstract" => j.abstract, + "files" => files + } end + journals + end end diff --git a/app/helpers/journal_papers_helper.rb b/app/helpers/journal_papers_helper.rb deleted file mode 100644 index 68f4404..0000000 --- a/app/helpers/journal_papers_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module JournalPapersHelper -end diff --git a/app/models/journal_level.rb b/app/models/journal_level.rb index 070baf3..778fff2 100644 --- a/app/models/journal_level.rb +++ b/app/models/journal_level.rb @@ -1,9 +1,6 @@ class JournalLevel include Mongoid::Document include Mongoid::Timestamps - include Mongoid::Attributes::Dynamic - - include OrbitCoreLib::ObjectDisable field :key, type: String field :title, type: String, localize: true diff --git a/app/models/journal_paper.rb b/app/models/journal_paper.rb index 09ba660..7051468 100644 --- a/app/models/journal_paper.rb +++ b/app/models/journal_paper.rb @@ -53,16 +53,17 @@ class JournalPaper title << self.member_profile.name if self.member_profile_id.present? title << (!self.authors.blank? ? self.authors : nil) - if !self.publication_date.nil? - pd = self.publication_date.strftime("%Y-%m-%d").split('-') - title << pd[0] - end title << self.paper_title if self.paper_title.present? title << self.journal_title if self.journal_title.present? title << self.vol_no if (self.vol_no.present? && self.vol_no != "0") title << self.issue_no if (self.issue_no.present? && self.issue_no != "0") title << "pp"+self.form_to_start+"-"+self.form_to_end if (self.form_to_start.present? && self.form_to_start != "0") title << ( !self.journal_levels.blank? ? "(#{self.journal_levels.collect{|x| x.title}.join(', ')})" : nil) + # if !self.publication_date.nil? + # pd = self.publication_date.strftime("%Y-%m-%d").split('-') + # title << pd[0] + # end + title << self.year title.join(', ').gsub(', ,',',') end @@ -125,6 +126,8 @@ class JournalPaper value = self.publication_date.to_date.strftime("%Y-%m-%d") rescue "" when "language" value = I18n.t(self.language) rescue "" + when "abstract" + value = nl2br(self.abstract) when "file" files = [] self.journal_paper_files.each do |file| diff --git a/app/models/journal_paper_author_type.rb b/app/models/journal_paper_author_type.rb index 97672dc..f14392f 100644 --- a/app/models/journal_paper_author_type.rb +++ b/app/models/journal_paper_author_type.rb @@ -1,8 +1,6 @@ class JournalPaperAuthorType include Mongoid::Document include Mongoid::Timestamps - include Mongoid::Attributes::Dynamic - include OrbitCoreLib::ObjectDisable field :key, type: String field :title, type: String, localize: true diff --git a/app/models/journal_paper_type.rb b/app/models/journal_paper_type.rb index b34bcbc..1f29c4f 100644 --- a/app/models/journal_paper_type.rb +++ b/app/models/journal_paper_type.rb @@ -1,8 +1,6 @@ class JournalPaperType include Mongoid::Document include Mongoid::Timestamps - include Mongoid::Attributes::Dynamic - include OrbitCoreLib::ObjectDisable field :key, type: String field :title, type: String, localize: true diff --git a/app/views/admin/journal_levels/_form.html.erb b/app/views/admin/journal_levels/_form.html.erb new file mode 100644 index 0000000..4e12886 --- /dev/null +++ b/app/views/admin/journal_levels/_form.html.erb @@ -0,0 +1,24 @@ +<%= form_for(@paper_level, :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/journal_levels/_index.js.erb b/app/views/admin/journal_levels/_index.js.erb new file mode 100644 index 0000000..63a5105 --- /dev/null +++ b/app/views/admin/journal_levels/_index.js.erb @@ -0,0 +1,2 @@ +$('#paper_levels tbody').html("<%= j render :partial => '/admin/journal_papers/list_level_type', :collection => @paper_levels %>"); +$('#paper_level_modal').modal('hide'); \ No newline at end of file diff --git a/app/views/admin/journal_levels/create_writing_journal_setting.js.erb b/app/views/admin/journal_levels/create_writing_journal_setting.js.erb deleted file mode 100644 index 319c3a8..0000000 --- a/app/views/admin/journal_levels/create_writing_journal_setting.js.erb +++ /dev/null @@ -1,2 +0,0 @@ -$("#myModal1").modal('hide'); -$('<%= j render :partial => 'admin/journal_papers/list_level_type', :collection => [@journal_level] %>').appendTo('#level_types').hide().fadeIn(); \ No newline at end of file diff --git a/app/views/admin/journal_levels/delete_journal_setting.js.erb b/app/views/admin/journal_levels/delete_journal_setting.js.erb deleted file mode 100644 index eb842a2..0000000 --- a/app/views/admin/journal_levels/delete_journal_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/journal_levels/edit.js.erb b/app/views/admin/journal_levels/edit.js.erb new file mode 100644 index 0000000..baee16d --- /dev/null +++ b/app/views/admin/journal_levels/edit.js.erb @@ -0,0 +1 @@ +$('#paper_level_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/journal_levels/new.js.erb b/app/views/admin/journal_levels/new.js.erb new file mode 100644 index 0000000..baee16d --- /dev/null +++ b/app/views/admin/journal_levels/new.js.erb @@ -0,0 +1 @@ +$('#paper_level_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/journal_levels/update_writing_journal_setting.js.erb b/app/views/admin/journal_levels/update_writing_journal_setting.js.erb deleted file mode 100644 index 5fcf715..0000000 --- a/app/views/admin/journal_levels/update_writing_journal_setting.js.erb +++ /dev/null @@ -1,2 +0,0 @@ -$("#myModal1").modal('hide'); -$("#<%= dom_id @journal_level %>").replaceWith("<%= j render :partial => 'admin/journal_papers/list_level_type', :collection => [@journal_level] %>"); \ No newline at end of file diff --git a/app/views/admin/journal_paper_author_types/_form.html.erb b/app/views/admin/journal_paper_author_types/_form.html.erb new file mode 100644 index 0000000..08b414e --- /dev/null +++ b/app/views/admin/journal_paper_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/journal_paper_author_types/_list.js.erb b/app/views/admin/journal_paper_author_types/_list.js.erb new file mode 100644 index 0000000..5c83704 --- /dev/null +++ b/app/views/admin/journal_paper_author_types/_list.js.erb @@ -0,0 +1,2 @@ +$('#author_types tbody').html("<%= j render :partial => '/admin/journal_papers/list_author_type', :collection => @author_types %>"); +$('#author_type_modal').modal('hide'); \ No newline at end of file diff --git a/app/views/admin/journal_paper_author_types/create_writing_journal_setting.js.erb b/app/views/admin/journal_paper_author_types/create_writing_journal_setting.js.erb deleted file mode 100644 index 5dba121..0000000 --- a/app/views/admin/journal_paper_author_types/create_writing_journal_setting.js.erb +++ /dev/null @@ -1,2 +0,0 @@ -$("#myModal2").modal('hide'); -$('<%= j render :partial => 'admin/journal_papers/list_author_type', :collection => [@journal_author_type] %>').appendTo('#author_types').hide().fadeIn(); \ No newline at end of file diff --git a/app/views/admin/journal_paper_author_types/delete_journal_setting.js.erb b/app/views/admin/journal_paper_author_types/delete_journal_setting.js.erb deleted file mode 100644 index 1958000..0000000 --- a/app/views/admin/journal_paper_author_types/delete_journal_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/journal_paper_author_types/edit.js.erb b/app/views/admin/journal_paper_author_types/edit.js.erb new file mode 100644 index 0000000..3ac7380 --- /dev/null +++ b/app/views/admin/journal_paper_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/journal_paper_author_types/new.js.erb b/app/views/admin/journal_paper_author_types/new.js.erb new file mode 100644 index 0000000..3ac7380 --- /dev/null +++ b/app/views/admin/journal_paper_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/journal_paper_author_types/update_writing_journal_setting.js.erb b/app/views/admin/journal_paper_author_types/update_writing_journal_setting.js.erb deleted file mode 100644 index 4f60ed1..0000000 --- a/app/views/admin/journal_paper_author_types/update_writing_journal_setting.js.erb +++ /dev/null @@ -1,2 +0,0 @@ -$("#myModal2").modal('hide'); -$("#<%= dom_id @journal_author_type %>").replaceWith("<%= j render :partial => 'admin/journal_papers/list_author_type', :collection => [@journal_author_type] %>"); \ No newline at end of file diff --git a/app/views/admin/journal_paper_types/_form.html.erb b/app/views/admin/journal_paper_types/_form.html.erb new file mode 100644 index 0000000..a69e8c5 --- /dev/null +++ b/app/views/admin/journal_paper_types/_form.html.erb @@ -0,0 +1,24 @@ +<%= form_for(@paper_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/journal_paper_types/_index.js.erb b/app/views/admin/journal_paper_types/_index.js.erb new file mode 100644 index 0000000..0362d31 --- /dev/null +++ b/app/views/admin/journal_paper_types/_index.js.erb @@ -0,0 +1,2 @@ +$('#paper_types tbody').html("<%= j render :partial => '/admin/journal_papers/list_paper_type', :collection => @paper_types %>"); +$('#paper_type_modal').modal('hide'); \ No newline at end of file diff --git a/app/views/admin/journal_paper_types/create_writing_journal_setting.js.erb b/app/views/admin/journal_paper_types/create_writing_journal_setting.js.erb deleted file mode 100644 index d3aa9c4..0000000 --- a/app/views/admin/journal_paper_types/create_writing_journal_setting.js.erb +++ /dev/null @@ -1,2 +0,0 @@ -$("#myModal3").modal('hide'); -$('<%= j render :partial => 'admin/journal_papers/list_paper_type', :collection => [@journal_paper_type] %>').appendTo('#paper_types').hide().fadeIn(); \ No newline at end of file diff --git a/app/views/admin/journal_paper_types/delete_journal_setting.js.erb b/app/views/admin/journal_paper_types/delete_journal_setting.js.erb deleted file mode 100644 index a035d69..0000000 --- a/app/views/admin/journal_paper_types/delete_journal_setting.js.erb +++ /dev/null @@ -1,3 +0,0 @@ -$('.delete_paper').bind('ajax:success', function() { - $(this).closest('tr').fadeOut(); -}); \ No newline at end of file diff --git a/app/views/admin/journal_paper_types/edit.js.erb b/app/views/admin/journal_paper_types/edit.js.erb new file mode 100644 index 0000000..e738913 --- /dev/null +++ b/app/views/admin/journal_paper_types/edit.js.erb @@ -0,0 +1 @@ +$('#paper_type_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/journal_paper_types/new.js.erb b/app/views/admin/journal_paper_types/new.js.erb new file mode 100644 index 0000000..e738913 --- /dev/null +++ b/app/views/admin/journal_paper_types/new.js.erb @@ -0,0 +1 @@ +$('#paper_type_modal').html("<%= j render 'form' %>"); \ No newline at end of file diff --git a/app/views/admin/journal_paper_types/update_writing_journal_setting.js.erb b/app/views/admin/journal_paper_types/update_writing_journal_setting.js.erb deleted file mode 100644 index 58128aa..0000000 --- a/app/views/admin/journal_paper_types/update_writing_journal_setting.js.erb +++ /dev/null @@ -1,2 +0,0 @@ -$("#myModal3").modal('hide'); -$("#<%= dom_id @journal_paper_type %>").replaceWith("<%= j render :partial => 'admin/journal_papers/list_paper_type', :collection => [@journal_paper_type] %>"); \ No newline at end of file diff --git a/app/views/admin/journal_papers/_author_autocomplete.html.erb b/app/views/admin/journal_papers/_author_autocomplete.html.erb deleted file mode 100644 index 1c0226c..0000000 --- a/app/views/admin/journal_papers/_author_autocomplete.html.erb +++ /dev/null @@ -1,33 +0,0 @@ - \ No newline at end of file diff --git a/app/views/admin/journal_papers/_author_type_qe.html.erb b/app/views/admin/journal_papers/_author_type_qe.html.erb deleted file mode 100644 index 5ad6a8f..0000000 --- a/app/views/admin/journal_papers/_author_type_qe.html.erb +++ /dev/null @@ -1,33 +0,0 @@ -<% # encoding: utf-8 %> - -<%= form_for(@set_author_type, :remote => true, :url => @author_type_url ) do |f| %> - - - + + + + +
+ + +
+ +
+ +
+ <%= @member.name rescue ''%> + <%= f.hidden_field :member_profile_id, :value => @member.id if !@member.nil? %> +
+
+ + +
+ +
+ <%= select_year((@journal_paper.year ? @journal_paper.year.to_i : DateTime.now.year), {:start_year => DateTime.now.year, :end_year => 1930}, {:name => 'journal_paper[year]', :class => "span1"} ) %> +
+
+ + +
+ +
+ +
+
+ + +
+ +
+ <%= f.text_field :vol_no %> +
+
+ + +
+ +
+ <%= f.text_field :issue_no %> +
+
+ + +
+ +
+ <%= f.text_field :form_to_start, :class=>'span1' %> ~ <%= f.text_field :form_to_end, :class=>'span1' %> +
+
+ + +
+ +
+ <%= f.text_field :total_pages %> +
+
+ + +
+ +
+ <% @journal_levels.each do |level_type| %> + <%= content_tag :label,:class => "checkbox inline" do -%> + <%= check_box_tag 'journal_paper[journal_level_ids][]', level_type.id, @journal_paper.journal_level_ids.include?(level_type.id)%> + <%= level_type.title %> + <%= hidden_field_tag 'journal_paper[journal_level_ids][]', '' %> + <% end %> + <% end %> +
+
+ + +
+ +
+ <%= f.select :journal_paper_type_id, @paper_types.collect {|t| [ t.title, t.id ]}, :class => "span3" %> +
+
+ + +
+ +
+ <% @author_types.each do |author_type| %> + <%= content_tag :label,:class => "checkbox inline" do -%> + <%= check_box_tag 'journal_paper[journal_paper_author_type_ids][]', author_type.id, @journal_paper.journal_paper_author_type_ids.include?(author_type.id)%> + <%= author_type.title %> + <% end %> + <% end %> +
+
+ + +
+ +
+ <%= f.text_field :number_of_authors, :class=>'span1' %> +
+
+ + +
+ +
+ <%= f.text_field :isbn %> +
+
+ + +
+ +
+ <%= f.datetime_picker :publication_date, :no_label => true, :format=>"yyyy/MM/dd", :placeholder=>"YYYY/MM/DD" %> +
+
+ + +
+ +
+ <%= f.text_field :url , :class => "span6" %> +
+
+ + +
+ +
+ <%= f.text_field :keywords %> +
+
+ + +
+ +
+ <%= f.text_area :abstract, rows: 2, class: "input-block-level" %> +
+
+ + +
+ +
+ <%= f.text_area :note, rows: 2, class: "input-block-level" %> +
+
+ + +
+ +
+ <%= f.text_field :associated_project %> +
+
+ +
+ + +
+ + +
+ +
+ +
+
+ +
+ +
+ diff --git a/app/views/admin/journal_papers/_level_type_qe.html.erb b/app/views/admin/journal_papers/_level_type_qe.html.erb deleted file mode 100644 index 22704c9..0000000 --- a/app/views/admin/journal_papers/_level_type_qe.html.erb +++ /dev/null @@ -1,34 +0,0 @@ -<% # encoding: utf-8 %> -<%= form_for(@set_level_type, remote: true, url: @level_type_url) do |f| %> - - -