OSDN Git Service

t#31918:sbt, wf can disable by yml
authoryasushiito <yas@pen-chan.jp>
Fri, 6 Sep 2013 04:13:30 +0000 (13:13 +0900)
committeryasushiito <yas@pen-chan.jp>
Fri, 6 Sep 2013 04:13:30 +0000 (13:13 +0900)
app/controllers/speech_balloon_templates_controller.rb
app/helpers/application_helper.rb
app/models/writing_format.rb
app/views/panels/_form.html.erb

index 051b9da..ab39367 100644 (file)
@@ -11,7 +11,7 @@ class SpeechBalloonTemplatesController < ApplicationController
   # GET /speech_balloon_templates
   # GET /speech_balloon_templates.json
   def index
-    @speech_balloon_templates = SpeechBalloonTemplate.list
+    @speech_balloon_templates = SpeechBalloonTemplate.enable_list
 
     respond_to do |format|
       format.html # index.html.erb
index f53da6f..953c54b 100644 (file)
@@ -51,7 +51,7 @@ module ApplicationHelper
   end
   
   def panel_editor_javascript_include_tags
-    WritingFormat.list().map {|wf|
+    WritingFormat.enable_list().map {|wf|
 #      javascript_include_tag wf.engine_name
       javascript_include_tag wf.engine_name + "/application"
     }.join("\n") + 
index afa4198..4cdfd73 100644 (file)
@@ -36,6 +36,12 @@ class WritingFormat < ActiveRecord::Base
     WritingFormat.find(:all, opt)
   end
   
+  def self.enable_list
+    WritingFormat.list.delete_if {|wf|
+      wf.enable? == false
+    }
+  end
+  
   def self.list_opt
     {}
   end
@@ -77,6 +83,10 @@ class WritingFormat < ActiveRecord::Base
     Pettanr::Application.writing_formats[self.classname]
   end
   
+  def enable?
+    Pettanr::Application.writing_formats.include? self.classname
+  end
+  
   def engine_module_name
     self.engine_name.camelize
   end
index 06370c0..59768b9 100644 (file)
             <% when 'SpeechBalloon' %>
               <div id="new-speech_balloon-tabs">
                 <ul>
-                  <% SpeechBalloonTemplate.list().each_with_index do |sbt, index| %>
+                  <% SpeechBalloonTemplate.enable_list().each_with_index do |sbt, index| %>
                     <li>
                       <a href="#new-speech_balloon-tabs-<%= index -%>">
                         <div class="new-speech_balloon-tab">
   </div>
 <% end %>
 <div id="writing_formats">
-  <% WritingFormat.list().each do |wf| %>
+  <% WritingFormat.enable_list().each do |wf| %>
     <div id="writing_format-<%= wf.id -%>" writing_format_id="<%= wf.id -%>" writing_format_engine_name="<%= wf.engine_name -%>">
     </div>
   <% end %>