From 26436395f59405252369509ff64442ac9d98f2d9 Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Sun, 18 Nov 2012 03:07:50 +0800 Subject: [PATCH] finished some method of list and journal --- .../javascripts/desktop/journal_pages.js.erb | 0 app/assets/javascripts/orbitdesktop.js | 2 +- .../desktop/journal_pages_controller.rb | 54 ++++++++ .../desktop_publications_controller.rb | 34 +++-- app/views/desktop/journal_p.html.erb | 64 ++++----- .../desktop/journal_pages/_form.html.erb | 28 ++-- app/views/desktop/journal_pages/add.html.erb | 3 - app/views/desktop/journal_pages/edit.html.erb | 2 + .../desktop/journal_pages/index.html.erb | 88 ++++++++++++ app/views/desktop/journal_pages/list.html.erb | 87 ------------ app/views/desktop/journal_pages/new.html.erb | 3 + app/views/desktop/journal_pages/show.html.erb | 2 + config/routes.rb | 127 +++++++----------- .../app/models/journal_author_type.rb | 6 +- .../app/models/journal_level_type.rb | 6 +- .../app/models/journal_paper_type.rb | 6 +- .../app/models/personal_journal_tag.rb | 10 +- .../app/models/writing_journal.rb | 82 ++++------- .../app/models/writing_journal_category.rb | 14 +- .../app/models/writing_journal_file.rb | 4 +- 20 files changed, 306 insertions(+), 316 deletions(-) create mode 100644 app/assets/javascripts/desktop/journal_pages.js.erb create mode 100644 app/controllers/desktop/journal_pages_controller.rb delete mode 100644 app/views/desktop/journal_pages/add.html.erb create mode 100644 app/views/desktop/journal_pages/edit.html.erb create mode 100644 app/views/desktop/journal_pages/index.html.erb delete mode 100644 app/views/desktop/journal_pages/list.html.erb create mode 100644 app/views/desktop/journal_pages/new.html.erb create mode 100644 app/views/desktop/journal_pages/show.html.erb diff --git a/app/assets/javascripts/desktop/journal_pages.js.erb b/app/assets/javascripts/desktop/journal_pages.js.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index 321292a2f..2de7da1b3 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -586,7 +586,7 @@ var orbitDesktop = function(dom){ $(this).val(sectionnames[i]); }) bindHandlers(); - }) + }) } diff --git a/app/controllers/desktop/journal_pages_controller.rb b/app/controllers/desktop/journal_pages_controller.rb new file mode 100644 index 000000000..4db1bbdf4 --- /dev/null +++ b/app/controllers/desktop/journal_pages_controller.rb @@ -0,0 +1,54 @@ +class Desktop::JournalPagesController < ApplicationController + def index + @writing_journal = WritingJournal.where(create_user_id: current_user.id) + @level_types = JournalLevelType.all + + respond_to do |format| + format.html { render :layout => false} + end + end + + def new + @writing_journal = WritingJournal.new + @level_types = JournalLevelType.all + @author_types = JournalAuthorType.all + @paper_types= JournalPaperType.all + + respond_to do |format| + format.html { render :layout => false} + end + end + + def edit + end + + def create + if params[:commit].eql?"Save" + if not params[:writing_journal][:publication_date].nil? + params[:writing_journal][:publication_date] = \ + Date.new *(params[:writing_journal][:publication_date].split("/").map{|s| s.to_i}) + end + + params[:writing_journal][:create_user_id] = current_user.id + + @writing_journal = WritingJournal.new(params[:writing_journal]) + if @writing_journal.save + respond_to do |format| + format.html { redirect_to desktop_journal_pages_url, :layout => false, notice: 'User was successfully created.'} + # format.json { render json: @writing_journal, status: :created, location: @writing_journal} + # format.js + end + else + end + end + end + + def show + end + + def update + if params[:commit].eql?"Edit" + params[:writing_journal][:update_user_id] = current_user.id + end + end +end diff --git a/app/controllers/desktop_publications_controller.rb b/app/controllers/desktop_publications_controller.rb index c55f348ef..1eb6b2449 100644 --- a/app/controllers/desktop_publications_controller.rb +++ b/app/controllers/desktop_publications_controller.rb @@ -4,21 +4,29 @@ class DesktopPublicationsController< ApplicationController def journal_p render "desktop/journal_p", :layout => false end +# +# def journal_p_list +# render "desktop/journal_pages/list", :layout => false +# end - def journal_p_list - render "desktop/journal_pages/list", :layout => false - end - - def journal_p_add - @writing_journal = WritingJournal.new - @level_types = JournalLevelType.all - +# def journal_p_add +# @writing_journal = WritingJournal.new +# @level_types = JournalLevelType.all +# # respond_to do |format| -# format.html # new.html.erb -# format.xml { render :xml => @writing_journal } +# format.html { render "desktop/journal_pages/add", :layout => false} # end - render "desktop/journal_pages/add", :layout => false - end +# end +# +# def journal_p_create +# @writing_journal = WritingJournal.all.first +# @level_types = JournalLevelType.all +# respond_to do |format| +# format.html { render "desktop/journal_pages/list", :layout => false} +# #format.js +# end +# +# end def books render "desktop/books", :layout => false @@ -75,8 +83,6 @@ class DesktopPublicationsController< ApplicationController def getjournals publications = WritingJournal.where(create_user_id: current_user.id) - p current_user.id -p "=======" sort_publications= Hash.new data = Array.new diff --git a/app/views/desktop/journal_p.html.erb b/app/views/desktop/journal_p.html.erb index 07452f20c..868136c43 100644 --- a/app/views/desktop/journal_p.html.erb +++ b/app/views/desktop/journal_p.html.erb @@ -1,33 +1,33 @@
-
- -
- -
-
-
-
-
-
- \ No newline at end of file +
+ +
+ +
+
+
+
+
+ + diff --git a/app/views/desktop/journal_pages/_form.html.erb b/app/views/desktop/journal_pages/_form.html.erb index 53707a6ac..9eecab853 100644 --- a/app/views/desktop/journal_pages/_form.html.erb +++ b/app/views/desktop/journal_pages/_form.html.erb @@ -60,7 +60,7 @@