From 8700c79e419eb18701b58fe92324a7afc24fc64d Mon Sep 17 00:00:00 2001 From: Saurabh Bhatia Date: Thu, 12 Jun 2014 18:27:26 +0800 Subject: [PATCH] Journal Papers,File,Author --- .../javascripts/admin/journal_levels.js | 2 + .../admin/journal_paper_author_types.js | 2 + .../javascripts/admin/journal_paper_types.js | 2 + .../javascripts/admin/journal_papers.js | 3 + .../personal_journal/author.js.erb | 24 ++ .../journal_paper_file.js.erb | 24 ++ .../stylesheets/admin/journal_levels.css | 4 + .../admin/journal_paper_author_types.css | 4 + .../stylesheets/admin/journal_paper_types.css | 4 + .../admin/journal_levels_controller.rb | 50 +++ .../journal_paper_author_types_controller.rb | 50 +++ .../admin/journal_paper_types_controller.rb | 50 +++ .../admin/journal_papers_controller.rb | 186 ++++++++- app/helpers/admin/journal_levels_helper.rb | 2 + .../journal_paper_author_types_helper.rb | 2 + .../admin/journal_paper_types_helper.rb | 2 + app/models/journal_level.rb | 20 + app/models/journal_paper.rb | 64 ++- app/models/journal_paper_author.rb | 17 + app/models/journal_paper_author_type.rb | 11 + app/models/journal_paper_file.rb | 11 + app/models/journal_paper_type.rb | 11 + .../create_writing_journal_setting.js.erb | 2 + .../delete_journal_setting.js.erb | 3 + .../update_writing_journal_setting.js.erb | 2 + .../create_writing_journal_setting.js.erb | 2 + .../delete_journal_setting.js.erb | 3 + .../update_writing_journal_setting.js.erb | 2 + .../create_writing_journal_setting.js.erb | 2 + .../delete_journal_setting.js.erb | 3 + .../update_writing_journal_setting.js.erb | 2 + .../_author_autocomplete.html.erb | 34 ++ .../journal_papers/_author_type_qe.html.erb | 33 ++ .../admin/journal_papers/_filter.html.erb | 9 + app/views/admin/journal_papers/_form.html.erb | 372 ++++++++++++++++++ .../journal_papers/_form_author.html.erb | 39 ++ .../admin/journal_papers/_form_file.html.erb | 45 +++ .../journal_papers/_level_type_qe.html.erb | 34 ++ .../journal_papers/_list_author_type.html.erb | 11 + .../journal_papers/_list_level_type.html.erb | 11 + .../journal_papers/_list_paper_type.html.erb | 11 + .../journal_papers/_paper_type_qe.html.erb | 29 ++ .../journal_papers/_sort_headers.html.erb | 0 .../journal_papers/_writing_journal.html.erb | 15 + .../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 + app/views/admin/journal_papers/destroy.js.erb | 1 + app/views/admin/journal_papers/edit.html.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 + app/views/admin/journal_papers/index.html.erb | 33 +- app/views/admin/journal_papers/index.js.erb | 3 + .../level_type_quick_add.js.erb | 1 + app/views/admin/journal_papers/new.html.erb | 15 + .../update_writing_journal_setting.js.erb | 14 + .../writing_journal_setting.html.erb | 142 +++++++ .../plugin/journal_paper/_profile.html.erb | 107 +++++ config/locales/en.yml | 2 + config/locales/zh_tw.yml | 1 + config/routes.rb | 18 +- lib/personal_journal/engine.rb | 4 +- personal_journal.gemspec | 4 +- .../admin/journal_levels_controller_test.rb | 7 + ...rnal_paper_author_types_controller_test.rb | 7 + .../journal_paper_types_controller_test.rb | 7 + test/fixtures/journal_levels.yml | 9 + test/fixtures/journal_paper_author_types.yml | 7 + test/fixtures/journal_paper_authors.yml | 9 + test/fixtures/journal_paper_files.yml | 11 + test/fixtures/journal_paper_types.yml | 9 + .../admin/journal_levels_helper_test.rb | 4 + .../journal_paper_author_types_helper_test.rb | 4 + .../admin/journal_paper_types_helper_test.rb | 4 + test/models/journal_level_test.rb | 7 + test/models/journal_paper_author_test.rb | 7 + test/models/journal_paper_author_type_test.rb | 7 + test/models/journal_paper_file_test.rb | 7 + test/models/journal_paper_type_test.rb | 7 + 81 files changed, 1693 insertions(+), 10 deletions(-) create mode 100644 app/assets/javascripts/admin/journal_levels.js create mode 100644 app/assets/javascripts/admin/journal_paper_author_types.js create mode 100644 app/assets/javascripts/admin/journal_paper_types.js create mode 100644 app/assets/javascripts/personal_journal/author.js.erb create mode 100644 app/assets/javascripts/personal_journal/journal_paper_file.js.erb create mode 100644 app/assets/stylesheets/admin/journal_levels.css create mode 100644 app/assets/stylesheets/admin/journal_paper_author_types.css create mode 100644 app/assets/stylesheets/admin/journal_paper_types.css create mode 100644 app/controllers/admin/journal_levels_controller.rb create mode 100644 app/controllers/admin/journal_paper_author_types_controller.rb create mode 100644 app/controllers/admin/journal_paper_types_controller.rb create mode 100644 app/helpers/admin/journal_levels_helper.rb create mode 100644 app/helpers/admin/journal_paper_author_types_helper.rb create mode 100644 app/helpers/admin/journal_paper_types_helper.rb create mode 100644 app/models/journal_level.rb create mode 100644 app/models/journal_paper_author.rb create mode 100644 app/models/journal_paper_author_type.rb create mode 100644 app/models/journal_paper_file.rb create mode 100644 app/models/journal_paper_type.rb create mode 100644 app/views/admin/journal_levels/create_writing_journal_setting.js.erb create mode 100644 app/views/admin/journal_levels/delete_journal_setting.js.erb create mode 100644 app/views/admin/journal_levels/update_writing_journal_setting.js.erb create mode 100644 app/views/admin/journal_paper_author_types/create_writing_journal_setting.js.erb create mode 100644 app/views/admin/journal_paper_author_types/delete_journal_setting.js.erb create mode 100644 app/views/admin/journal_paper_author_types/update_writing_journal_setting.js.erb create mode 100644 app/views/admin/journal_paper_types/create_writing_journal_setting.js.erb create mode 100644 app/views/admin/journal_paper_types/delete_journal_setting.js.erb create mode 100644 app/views/admin/journal_paper_types/update_writing_journal_setting.js.erb create mode 100644 app/views/admin/journal_papers/_author_autocomplete.html.erb create mode 100644 app/views/admin/journal_papers/_author_type_qe.html.erb create mode 100644 app/views/admin/journal_papers/_filter.html.erb create mode 100644 app/views/admin/journal_papers/_form.html.erb create mode 100644 app/views/admin/journal_papers/_form_author.html.erb create mode 100644 app/views/admin/journal_papers/_form_file.html.erb create mode 100644 app/views/admin/journal_papers/_level_type_qe.html.erb create mode 100644 app/views/admin/journal_papers/_list_author_type.html.erb create mode 100644 app/views/admin/journal_papers/_list_level_type.html.erb create mode 100644 app/views/admin/journal_papers/_list_paper_type.html.erb create mode 100644 app/views/admin/journal_papers/_paper_type_qe.html.erb create mode 100644 app/views/admin/journal_papers/_sort_headers.html.erb create mode 100644 app/views/admin/journal_papers/_writing_journal.html.erb create mode 100644 app/views/admin/journal_papers/add_author_type.js.erb create mode 100644 app/views/admin/journal_papers/add_level.js.erb create mode 100644 app/views/admin/journal_papers/add_paper_type.js.erb create mode 100644 app/views/admin/journal_papers/create_writing_journal_setting.js.erb create mode 100644 app/views/admin/journal_papers/destroy.js.erb create mode 100644 app/views/admin/journal_papers/edit.html.erb create mode 100644 app/views/admin/journal_papers/edit_author_type.js.erb create mode 100644 app/views/admin/journal_papers/edit_level.js.erb create mode 100644 app/views/admin/journal_papers/edit_paper_type.js.erb create mode 100644 app/views/admin/journal_papers/index.js.erb create mode 100644 app/views/admin/journal_papers/level_type_quick_add.js.erb create mode 100644 app/views/admin/journal_papers/new.html.erb create mode 100644 app/views/admin/journal_papers/update_writing_journal_setting.js.erb create mode 100644 app/views/admin/journal_papers/writing_journal_setting.html.erb create mode 100644 app/views/plugin/journal_paper/_profile.html.erb create mode 100644 test/controllers/admin/journal_levels_controller_test.rb create mode 100644 test/controllers/admin/journal_paper_author_types_controller_test.rb create mode 100644 test/controllers/admin/journal_paper_types_controller_test.rb create mode 100644 test/fixtures/journal_levels.yml create mode 100644 test/fixtures/journal_paper_author_types.yml create mode 100644 test/fixtures/journal_paper_authors.yml create mode 100644 test/fixtures/journal_paper_files.yml create mode 100644 test/fixtures/journal_paper_types.yml create mode 100644 test/helpers/admin/journal_levels_helper_test.rb create mode 100644 test/helpers/admin/journal_paper_author_types_helper_test.rb create mode 100644 test/helpers/admin/journal_paper_types_helper_test.rb create mode 100644 test/models/journal_level_test.rb create mode 100644 test/models/journal_paper_author_test.rb create mode 100644 test/models/journal_paper_author_type_test.rb create mode 100644 test/models/journal_paper_file_test.rb create mode 100644 test/models/journal_paper_type_test.rb diff --git a/app/assets/javascripts/admin/journal_levels.js b/app/assets/javascripts/admin/journal_levels.js new file mode 100644 index 0000000..dee720f --- /dev/null +++ b/app/assets/javascripts/admin/journal_levels.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. diff --git a/app/assets/javascripts/admin/journal_paper_author_types.js b/app/assets/javascripts/admin/journal_paper_author_types.js new file mode 100644 index 0000000..dee720f --- /dev/null +++ b/app/assets/javascripts/admin/journal_paper_author_types.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. diff --git a/app/assets/javascripts/admin/journal_paper_types.js b/app/assets/javascripts/admin/journal_paper_types.js new file mode 100644 index 0000000..dee720f --- /dev/null +++ b/app/assets/javascripts/admin/journal_paper_types.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. diff --git a/app/assets/javascripts/admin/journal_papers.js b/app/assets/javascripts/admin/journal_papers.js index dee720f..005d5e7 100644 --- a/app/assets/javascripts/admin/journal_papers.js +++ b/app/assets/javascripts/admin/journal_papers.js @@ -1,2 +1,5 @@ // Place all the behaviors and hooks related to the matching controller here. // All this logic will automatically be available in application.js. +jQuery -> + $('#product_category_name').autocomplete + source: $('#product_category_name').data('autocomplete-source') diff --git a/app/assets/javascripts/personal_journal/author.js.erb b/app/assets/javascripts/personal_journal/author.js.erb new file mode 100644 index 0000000..66289d2 --- /dev/null +++ b/app/assets/javascripts/personal_journal/author.js.erb @@ -0,0 +1,24 @@ + $(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, :journal_paper_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(); + } + }); + }); \ No newline at end of file diff --git a/app/assets/javascripts/personal_journal/journal_paper_file.js.erb b/app/assets/javascripts/personal_journal/journal_paper_file.js.erb new file mode 100644 index 0000000..d6f31c6 --- /dev/null +++ b/app/assets/javascripts/personal_journal/journal_paper_file.js.erb @@ -0,0 +1,24 @@ + $(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_journal_paper_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, :journal_paper_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(); + } + }); + }); \ No newline at end of file diff --git a/app/assets/stylesheets/admin/journal_levels.css b/app/assets/stylesheets/admin/journal_levels.css new file mode 100644 index 0000000..afad32d --- /dev/null +++ b/app/assets/stylesheets/admin/journal_levels.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/assets/stylesheets/admin/journal_paper_author_types.css b/app/assets/stylesheets/admin/journal_paper_author_types.css new file mode 100644 index 0000000..afad32d --- /dev/null +++ b/app/assets/stylesheets/admin/journal_paper_author_types.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/assets/stylesheets/admin/journal_paper_types.css b/app/assets/stylesheets/admin/journal_paper_types.css new file mode 100644 index 0000000..afad32d --- /dev/null +++ b/app/assets/stylesheets/admin/journal_paper_types.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/app/controllers/admin/journal_levels_controller.rb b/app/controllers/admin/journal_levels_controller.rb new file mode 100644 index 0000000..af60876 --- /dev/null +++ b/app/controllers/admin/journal_levels_controller.rb @@ -0,0 +1,50 @@ +class Admin::JournalLevelsController < ApplicationController + before_action :set_journal_level, only: [:edit, :update, :destroy] + + def initialize + super + @app_type = 'journal_level' + end + + def new + @journal_level = JournalLevel.new + 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 + end + + def edit + end + + def update + respond_to do |format| + if @journal_level.update_attributes(journal_level_attributes) + format.js { render 'update_writing_journal_setting' } + end + end + end + + def destroy + @journal_level.destroy + respond_to do |format| + format.js { render 'delete_journal_setting' } + end + end + + private + + def set_journal_level + @journal_level = JournalLevel.find(params[:id]) + end + + def journal_level_attributes + params.require(:journal_level).permit! rescue nil + end + +end diff --git a/app/controllers/admin/journal_paper_author_types_controller.rb b/app/controllers/admin/journal_paper_author_types_controller.rb new file mode 100644 index 0000000..b6bd815 --- /dev/null +++ b/app/controllers/admin/journal_paper_author_types_controller.rb @@ -0,0 +1,50 @@ +class Admin::JournalPaperAuthorTypesController < ApplicationController + 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 + 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 + end + + def edit + 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 + end + + def destroy + @journal_author_type.destroy + respond_to do |format| + format.js { render 'delete_journal_setting' } + end + end + + private + + def set_journal_paper_author_type + @journal_author_type = JournalPaperAuthorType.find(params[:id]) + end + + def journal_paper_author_type_attributes + params.require(:journal_paper_author_type).permit! rescue nil + end + +end diff --git a/app/controllers/admin/journal_paper_types_controller.rb b/app/controllers/admin/journal_paper_types_controller.rb new file mode 100644 index 0000000..a9471d9 --- /dev/null +++ b/app/controllers/admin/journal_paper_types_controller.rb @@ -0,0 +1,50 @@ +class Admin::JournalPaperTypesController < ApplicationController + + 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 + 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 + end + + def edit + 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 + end + + def destroy + @journal_paper_type.destroy + respond_to do |format| + format.js { render 'delete_journal_setting' } + end + end + + private + + def set_journal_paper_type + @journal_paper_type = JournalPaperType.find(params[:id]) + end + + def journal_paper_type_attributes + 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 fb70aa6..c028c38 100644 --- a/app/controllers/admin/journal_papers_controller.rb +++ b/app/controllers/admin/journal_papers_controller.rb @@ -1,4 +1,188 @@ -class Admin::JournalPapersController < ApplicationController +class Admin::JournalPapersController < OrbitMemberController + + before_action :set_journal_paper, only: [:show, :edit , :update, :destroy] + before_action :get_plugins, only: [:index, :writing_journal_setting, :new, :create, :edit, :update] + before_action :set_types, only: [:writing_journal_setting, :new, :edit, :create] + def index + @writing_journals = JournalPaper.all + 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 + @members_data = JournalPaper.member_data + + respond_to do |format| + format.html # new.html.erb + format.xml { render :xml => @journal_paper } + end + end + + def edit + @journal_paper = JournalPaper.find(params[:id]) + @members_data = JournalPaper.member_data + end + + def create + @journal_paper = JournalPaper.new(journal_paper_attributes) + respond_to do |format| + if @journal_paper.save + format.html { redirect_to admin_journal_papers_path } + format.xml { render :xml => @journal_paper, :status => :created, :location => @journal_paper } + else + format.html { render :action => "new" } + format.xml { render :xml => @journal_paper.errors, :status => :unprocessable_entity } + end + end + end + + def update + @writing_journal = JournalPaper.find(params[:id]) + @journal_paper_authors = @writing_journal.journal_paper_authors + + respond_to do |format| + if @writing_journal.update_attributes(journal_paper_attributes) + format.html { redirect_to admin_journal_papers_path } + # format.js { render 'toggle_enable' } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @writing_journal.errors, :status => :unprocessable_entity } + end + end + end + + def destroy + @journal_paper.destroy + + respond_to do |format| + format.html { redirect_to(admin_journal_papers_url) } + # format.xml { head :ok } + format.js + 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 + if params[:ids] + @writing_journals = JournalPaper.any_in(_id: params[:ids]) + + @writing_journals.each do |writing_journal| + writing_journal.is_hidden = params[:disable] + writing_journal.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 + + end + + private + + def set_journal_paper + @journal_paper = JournalPaper.find(params[:id]) + end + + def journal_paper_attributes + params.require(:journal_paper).permit! rescue nil + end + + def get_plugins + @plugins = OrbitApp::Plugin::Registration.all rescue nil + end + + def set_types + @journal_levels = JournalLevel.all + @author_types = JournalPaperAuthorType.all + @paper_types = JournalPaperType.all + end + end diff --git a/app/helpers/admin/journal_levels_helper.rb b/app/helpers/admin/journal_levels_helper.rb new file mode 100644 index 0000000..94b8fa6 --- /dev/null +++ b/app/helpers/admin/journal_levels_helper.rb @@ -0,0 +1,2 @@ +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 new file mode 100644 index 0000000..d3ca68e --- /dev/null +++ b/app/helpers/admin/journal_paper_author_types_helper.rb @@ -0,0 +1,2 @@ +module Admin::JournalPaperAuthorTypesHelper +end diff --git a/app/helpers/admin/journal_paper_types_helper.rb b/app/helpers/admin/journal_paper_types_helper.rb new file mode 100644 index 0000000..bcb48da --- /dev/null +++ b/app/helpers/admin/journal_paper_types_helper.rb @@ -0,0 +1,2 @@ +module Admin::JournalPaperTypesHelper +end diff --git a/app/models/journal_level.rb b/app/models/journal_level.rb new file mode 100644 index 0000000..070baf3 --- /dev/null +++ b/app/models/journal_level.rb @@ -0,0 +1,20 @@ +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 + + has_and_belongs_to_many :journal_papers + + def self.from_id(id) + self.find(id) rescue nil + end + + def self.is_localized?(field_name) + self.fields[field_name.to_s].localized? + end +end diff --git a/app/models/journal_paper.rb b/app/models/journal_paper.rb index cd302b7..9fea279 100644 --- a/app/models/journal_paper.rb +++ b/app/models/journal_paper.rb @@ -1,6 +1,7 @@ class JournalPaper include Mongoid::Document include Mongoid::Timestamps + include Mongoid::Attributes::Dynamic include OrbitModel::Status @@ -17,11 +18,72 @@ class JournalPaper field :total_pages, type: String field :keywords, type: String field :abstract, type: String - field :publication_date, type: Date + field :publication_date, type: DateTime field :url, type: String field :note, type: String paginates_per 10 + #relations belongs_to :member_profile + belongs_to :journal_paper_type + has_and_belongs_to_many :journal_levels + + has_many :journal_paper_files, autosave: true, dependent: :destroy + accepts_nested_attributes_for :journal_paper_files + + has_and_belongs_to_many :journal_paper_authors + accepts_nested_attributes_for :journal_paper_authors + + before_validation :add_http + validates :paper_title, presence: true + + def create_link + title = [] + + title << self.member_profile.name if self.member_profile_id.present? + title << (!self.journal_levels.blank? ? "#{self.journal_paper_authors.collect{|j| j.name}.join(', ')}" : 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) + title.join(', ') + end + + def authors + authors = [] + authors << self.member_profile.name if self.member_profile_id.present? + authors << (!self.journal_levels.blank? ? "#{self.journal_paper_authors.collect{|j| j.name}.join(', ')}" : nil) + authors.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 + + protected + + def add_http + unless self.url.blank? || self.url[/^http:\/\//] || self.url[/^https:\/\//] + self.url = 'http://' + self.url + end + end + + def clean_checkboxs + self.tagged_ids.delete('') + self.journal_paper_author_type_ids.delete('') + self.journal_level_ids.delete('') + end + end diff --git a/app/models/journal_paper_author.rb b/app/models/journal_paper_author.rb new file mode 100644 index 0000000..2a3a880 --- /dev/null +++ b/app/models/journal_paper_author.rb @@ -0,0 +1,17 @@ +class JournalPaperAuthor + include Mongoid::Document + include Mongoid::Timestamps + + field :name, type: String, localize: true + field :email, type: String + + has_and_belongs_to_many :journal_papers + has_and_belongs_to_many :journal_paper_author_types + + VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/ + validates :email, format: { with: VALID_EMAIL_REGEX }, + allow_blank: true, + uniqueness: { case_sensitive: false } + + before_save { |author| author.email = email.downcase if not author.email.nil?} +end diff --git a/app/models/journal_paper_author_type.rb b/app/models/journal_paper_author_type.rb new file mode 100644 index 0000000..71ad4d5 --- /dev/null +++ b/app/models/journal_paper_author_type.rb @@ -0,0 +1,11 @@ +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 + + has_and_belongs_to_many :journal_paper_authors +end diff --git a/app/models/journal_paper_file.rb b/app/models/journal_paper_file.rb new file mode 100644 index 0000000..e6040a1 --- /dev/null +++ b/app/models/journal_paper_file.rb @@ -0,0 +1,11 @@ +class JournalPaperFile + include Mongoid::Document + include Mongoid::Timestamps + include Mongoid::Attributes::Dynamic + + field :description, type: String, localize: true + field :title, type: String, localize: true + + mount_uploader :journal_file, AssetUploader + belongs_to :journal_paper +end diff --git a/app/models/journal_paper_type.rb b/app/models/journal_paper_type.rb new file mode 100644 index 0000000..b34bcbc --- /dev/null +++ b/app/models/journal_paper_type.rb @@ -0,0 +1,11 @@ +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 + + has_many :journal_papers +end 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 new file mode 100644 index 0000000..319c3a8 --- /dev/null +++ b/app/views/admin/journal_levels/create_writing_journal_setting.js.erb @@ -0,0 +1,2 @@ +$("#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 new file mode 100644 index 0000000..eb842a2 --- /dev/null +++ b/app/views/admin/journal_levels/delete_journal_setting.js.erb @@ -0,0 +1,3 @@ +$('.delete_level').bind('ajax:success', function() { + $(this).closest('tr').fadeOut(); +}); \ 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 new file mode 100644 index 0000000..5fcf715 --- /dev/null +++ b/app/views/admin/journal_levels/update_writing_journal_setting.js.erb @@ -0,0 +1,2 @@ +$("#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/create_writing_journal_setting.js.erb b/app/views/admin/journal_paper_author_types/create_writing_journal_setting.js.erb new file mode 100644 index 0000000..5dba121 --- /dev/null +++ b/app/views/admin/journal_paper_author_types/create_writing_journal_setting.js.erb @@ -0,0 +1,2 @@ +$("#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 new file mode 100644 index 0000000..1958000 --- /dev/null +++ b/app/views/admin/journal_paper_author_types/delete_journal_setting.js.erb @@ -0,0 +1,3 @@ +$('.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/update_writing_journal_setting.js.erb b/app/views/admin/journal_paper_author_types/update_writing_journal_setting.js.erb new file mode 100644 index 0000000..4f60ed1 --- /dev/null +++ b/app/views/admin/journal_paper_author_types/update_writing_journal_setting.js.erb @@ -0,0 +1,2 @@ +$("#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/create_writing_journal_setting.js.erb b/app/views/admin/journal_paper_types/create_writing_journal_setting.js.erb new file mode 100644 index 0000000..d3aa9c4 --- /dev/null +++ b/app/views/admin/journal_paper_types/create_writing_journal_setting.js.erb @@ -0,0 +1,2 @@ +$("#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 new file mode 100644 index 0000000..a035d69 --- /dev/null +++ b/app/views/admin/journal_paper_types/delete_journal_setting.js.erb @@ -0,0 +1,3 @@ +$('.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/update_writing_journal_setting.js.erb b/app/views/admin/journal_paper_types/update_writing_journal_setting.js.erb new file mode 100644 index 0000000..58128aa --- /dev/null +++ b/app/views/admin/journal_paper_types/update_writing_journal_setting.js.erb @@ -0,0 +1,2 @@ +$("#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 new file mode 100644 index 0000000..bf8902b --- /dev/null +++ b/app/views/admin/journal_papers/_author_autocomplete.html.erb @@ -0,0 +1,34 @@ + \ 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 new file mode 100644 index 0000000..6a9e6ef --- /dev/null +++ b/app/views/admin/journal_papers/_author_type_qe.html.erb @@ -0,0 +1,33 @@ +<% # encoding: utf-8 %> + +<%= form_for(@set_author_type, :remote => true, :url => @author_type_url ) do |f| %> + + +