From cc6339d59b4caeddc2e1f17dba4ca8390d3fa369 Mon Sep 17 00:00:00 2001 From: Rueshyna Date: Fri, 30 Nov 2012 23:50:46 +0800 Subject: [PATCH] add journal_list. now, those pair, (journal_title, journal_levels), is uniq --- .../javascripts/desktop/journal_pages.js.erb | 17 ++++++-- .../desktop/journal_lists_controller.rb | 18 +++++++-- .../desktop/journal_lists/index.html.erb | 39 ++++++++++--------- app/views/desktop/journal_p.html.erb | 4 +- config/routes.rb | 1 + 5 files changed, 52 insertions(+), 27 deletions(-) diff --git a/app/assets/javascripts/desktop/journal_pages.js.erb b/app/assets/javascripts/desktop/journal_pages.js.erb index 44d3bc9c..2f6145e7 100644 --- a/app/assets/javascripts/desktop/journal_pages.js.erb +++ b/app/assets/javascripts/desktop/journal_pages.js.erb @@ -233,9 +233,20 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // }) } bindHandlers(); - - } + + this.initializeJournalPapers.journal = function(){ // to open add pages in journal papers page + var bindHandlers = function(){ // to bind handlers for add page + o.simple_drop_down(); + + o.tinyscrollbar_ext({ + main: '.tinycanvas', + fill: '.s_grid_con' + }) + } + bindHandlers(); + } + this.initializeJournalPapers.coAuthorformCallback = function(data){ if(data.success){ o.notify(data.msg,"success"); @@ -244,7 +255,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // o.notify(data.msg,"alert"); } } - this.initializeJournalPapers.coauthor = function(){ // to open add pages in journal papers page + this.initializeJournalPapers.coauthor = function(){ // to open add pages in coauthor page var bindHandlers = function(){ // to bind handlers for add page o.simple_drop_down(); diff --git a/app/controllers/desktop/journal_lists_controller.rb b/app/controllers/desktop/journal_lists_controller.rb index f4a0d980..1263f458 100644 --- a/app/controllers/desktop/journal_lists_controller.rb +++ b/app/controllers/desktop/journal_lists_controller.rb @@ -2,14 +2,23 @@ class Desktop::JournalListsController < ApplicationController # GET /desktop/journal_lists # GET /desktop/journal_lists.json def index - @desktop_journal_lists = Desktop::JournalList.all + level_types = JournalLevelType.all + all_journal_lists = WritingJournal.where(create_user_id: current_user.id) + all_journal_lists = all_journal_lists.map do |j| + [ j.journal_title, + j.journal_level_type_ids.map do |type| + level_types.find(type).title + end.join(",") + ].join(" -- ") + end + + @journal_lists = all_journal_lists.uniq respond_to do |format| - format.html # index.html.erb - format.json { render json: @desktop_journal_lists } + format.html { render :layout => false} end end - +=begin # GET /desktop/journal_lists/1 # GET /desktop/journal_lists/1.json def show @@ -80,4 +89,5 @@ class Desktop::JournalListsController < ApplicationController format.json { head :ok } end end +=end end diff --git a/app/views/desktop/journal_lists/index.html.erb b/app/views/desktop/journal_lists/index.html.erb index 618d2ae1..fad6ca66 100644 --- a/app/views/desktop/journal_lists/index.html.erb +++ b/app/views/desktop/journal_lists/index.html.erb @@ -1,21 +1,24 @@ -

Listing desktop_journal_lists

+

journal_title -- journal_level

- - - - - - +
+
+
+
-<% @desktop_journal_lists.each do |desktop_journal_list| %> -
- - - - -<% end %> -
<%= link_to 'Show', desktop_journal_list %><%= link_to 'Edit', edit_desktop_journal_list_path(desktop_journal_list) %><%= link_to 'Destroy', desktop_journal_list, confirm: 'Are you sure?', method: :delete %>
+ <% @journal_lists.each_with_index do |journal_list,i| %> + <% if ( i % 5 ) == 0 %> +
+ +
+ <% end %> + <% end %> -
- -<%= link_to 'New Journal list', new_desktop_journal_list_path %> + + + diff --git a/app/views/desktop/journal_p.html.erb b/app/views/desktop/journal_p.html.erb index e6b455a0..f9eec4ef 100644 --- a/app/views/desktop/journal_p.html.erb +++ b/app/views/desktop/journal_p.html.erb @@ -14,8 +14,8 @@