OSDN Git Service

fix panel viewer
authoryasushiito <yas@pen-chan.jp>
Tue, 3 Jun 2014 02:16:37 +0000 (11:16 +0900)
committeryasushiito <yas@pen-chan.jp>
Tue, 3 Jun 2014 02:16:37 +0000 (11:16 +0900)
app/controllers/panels_controller.rb
app/models/panel.rb
app/models/scroll_panel.rb
app/views/panels/index.html.erb [new file with mode: 0644]
app/views/panels/show.html.erb
app/views/scroll_panels/_licensed_pictures.html.erb [deleted file]
app/views/scrolls/play.html.erb
config/locales/pettanr.ja.yml

index 2cbd7eb..61b1018 100644 (file)
@@ -13,9 +13,28 @@ class PanelsController < ApplicationController
   def self.model
     Panel
   end
-  
+  private
+  def panel_list
+    set_list
+    list_result = @list.open(@operators, 
+      {:id => params[:id], :page => params[:page], :page_size => params[:page_size]}
+    )
+    @items = list_result.items 
+    @pager = list_result.paginate
+    respond_to do |format|
+      format.html 
+      format.json { render json: @items.to_json }
+      format.atom 
+      format.rss
+    end
+  end
+  public
   def index
-    filer_list
+    if params[:mode] == 'filer'
+      filer_list
+    else
+      panel_list
+    end
   end
   
   def by_scroll
index bbdf9ed..4ef23f9 100644 (file)
@@ -147,6 +147,14 @@ class Panel < Peta::Root
     }.join
   end
   
+  def self.licensed_pictures panels
+    r = {}
+    panels.each do |panel|
+      r.merge!(panel.licensed_pictures)
+    end
+    r
+  end
+  
   def licensed_pictures
     r = {}
     self.panel_elements.each do |elm|
index 8cfc3aa..6cc22b6 100644 (file)
@@ -71,11 +71,7 @@ class ScrollPanel < Peta::Leaf
   end
   
   def self.licensed_pictures scroll_panels
-    r = {}
-    scroll_panels.each do |scroll_panel|
-      r.merge!(scroll_panel.panel.licensed_pictures) if scroll_panel.panel
-    end
-    r
+    Panel.licensed_pictures scroll_panels.select {|sp| sp.panel }.map {|sp| sp.panel }
   end
   
   def allow? operators
diff --git a/app/views/panels/index.html.erb b/app/views/panels/index.html.erb
new file mode 100644 (file)
index 0000000..a90b013
--- /dev/null
@@ -0,0 +1,12 @@
+<% if @items.empty? -%>
+  <h2><%= t('panels.empty') %></h2>
+<% else %>
+  <h2><%= link_to t('panels.filer'), main_app.panels_path(:mode => 'filer', :page => params[:page], :page_size => params[:page_size]) %></h2>
+  <%= paginate(@pager) %>
+  <% @items.each do |panel| %>
+    <%= render 'body', :panel => panel, :operators => @operators, :spot => nil %>
+    <%= render 'panels/footer', :panel => panel, :operators => @operators %>
+  <% end %>
+  <%= render 'scroll_panels/licensed_pictures', :licensed_pictures => Panel.licensed_pictures(@items) %>
+  <%= paginate(@pager) %>
+<% end %>
index f6222f0..ed57f1c 100644 (file)
@@ -1,23 +1,22 @@
-<h1><%= t '.title' -%></h1>
-<p id="notice"><%= notice %></p>
+<h1>
+  <%= link_to icon_tag('Panel'), panel_path(@item) %>
+  <%= link_to h(@item.caption), panel_path(@item) %>
+  <%= link_to icon_tag('Prof'), panel_path(@item, :format => :prof) %>
+</h1>
 <%= render 'standard', :panel => @panel, :operators => @operators %>
 
 <% if @panel.own? @operators %>
-  <%= link_to t('link.edit'), edit_panel_path(@panel) %>
-  <%= link_to t('link.destroy'), panel_path(@panel), :method => :delete %>
-  <%= link_to t('link.catch'), catch_panel_path(@panel) %>
-<% end %>
-
-
-<% if @operators.author %>
-  <h2><%= t('panels.show.copy') -%></h2>
-  <%= form_for(Panel.new, :html => {:jqform => 'pettanr-panel-form'}) do |f| %>
-
-    <%= hidden_field_tag "json", @panel.post_attributes(:all).to_json %>
-    <div>
-      <%= submit_tag t('panels.show.inspire') -%>
-    </div>
-  <% end %>
+  <h3><%= t('editor') -%></h3>
+  <p id="notice"><%= notice %></p>
+  
+  <p>
+    <b><%= t_m 'Panel.publish' -%>:</b>
+    <%= t_selected_item('panel_visible_items', @item.publish) %>
+  </p>
+  <p>
+    <%= link_to t('link.edit'), edit_panel_path(@panel) %>
+    <%= link_to t('link.destroy'), panel_path(@panel), :method => :delete %>
+  </p>
   
   <h2><%= t('scroll_panels.append.new_scrolls') -%></h2>
   <table>
     <% end %>
   </table>
 <% end %>
+
+<% if @operators.author %>
+  <h2><%= t('panels.show.copy') -%></h2>
+  <%= form_for(Panel.new, :html => {:jqform => 'pettanr-panel-form'}) do |f| %>
+
+    <%= hidden_field_tag "json", @panel.post_attributes(:all).to_json %>
+    <div>
+      <%= submit_tag t('panels.show.inspire') -%>
+    </div>
+  <% end %>
+<% end %>
diff --git a/app/views/scroll_panels/_licensed_pictures.html.erb b/app/views/scroll_panels/_licensed_pictures.html.erb
deleted file mode 100644 (file)
index 1c10cc7..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-<div class="pettanr-licensed_pictures">
-  <% licensed_pictures.each do |pid, picture| %>
-    <table class="no-border">
-      <tr>
-        <td>
-          <%= link_to(tag(:img, picture.tmb_opt_img_tag), picture_path(picture.id)) -%>
-        </td>
-        <td>
-          <%= render picture.credit_template, :picture => picture %>
-        </td>
-      </tr>
-    </table>
-  <% end %>
-</div>
index 764417a..90c22fb 100644 (file)
@@ -16,7 +16,7 @@
     <% end %>
     <%= render 'scroll_panels/footer', :scroll_panel => scroll_panel, :operators => @operators %>
   <% end %>
-  <%= render 'scroll_panels/licensed_pictures', :licensed_pictures => ScrollPanel.licensed_pictures(@items) %>
+  <%= render 'panels/licensed_pictures', :licensed_pictures => ScrollPanel.licensed_pictures(@items) %>
   <%= paginate(@pager) %>
 <% end %>
 <% if @item.own? @operators -%>
index 079811d..f4c3a9b 100644 (file)
@@ -988,7 +988,9 @@ ja:
     create_from_json: jsonデータからコマ作成する
     element_copy: つかんでいるコマにコピーしたい
     inspire: インスパイヤ
+    filer: ファイラーで表示する
     hidden: 権限がありません
+    empty: 閲覧できるコマはありません
   panel_pictures:
     index:
       title: コマ絵一覧