OSDN Git Service

t#32066:validate_forms
authoryasushiito <yas@pen-chan.jp>
Tue, 22 Oct 2013 23:23:41 +0000 (08:23 +0900)
committeryasushiito <yas@pen-chan.jp>
Tue, 22 Oct 2013 23:23:41 +0000 (08:23 +0900)
13 files changed:
Gemfile
app/assets/javascripts/application.js
app/assets/javascripts/configurations.js.coffee
app/assets/javascripts/panels.js.coffee
app/assets/stylesheets/test.css.scss
app/helpers/application_helper.rb
app/models/panel.rb
app/models/speech_balloon.rb
app/views/home/index.html.erb
app/views/panels/_element_form.html.erb
app/views/panels/_element_tab.html.erb
app/views/panels/_form.html.erb
lib/element.rb

diff --git a/Gemfile b/Gemfile
index dcd755b..80208ee 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -33,6 +33,7 @@ end
 
 gem 'jquery-rails'
 gem 'jquery-ui-rails'
+gem "jquery-validation-rails"
 
 # To use ActiveModel has_secure_password
 gem 'bcrypt-ruby', '~> 3.0.0'
index b61302f..9dbdb97 100644 (file)
@@ -7,6 +7,9 @@
 //= require jquery
 //= require jquery_ujs
 //= require jquery.ui.all
+//= require jquery.validate
+//= require jquery.validate.additional-methods
+//= require jquery.validate.localization/messages_ja
 //= require textchange
 //= require configurations
 //= require pettanr_editor
index ea2884c..091a42a 100644 (file)
@@ -1,5 +1,68 @@
 @configurations = {\r
   models: {\r
+    Panel: 'panel',\r
+    panel: {\r
+      class_name: 'Panel',\r
+      table_name: 'panels',\r
+      attributes: {\r
+        id: {\r
+          type: 'number',\r
+          primary_key: 1,\r
+          rules : {\r
+            number: true,\r
+          }\r
+        },\r
+        width: {\r
+          type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            min: 1,\r
+          }\r
+        },\r
+        height: {\r
+          type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            min: 1,\r
+          }\r
+        },\r
+        border: {\r
+          type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            min: 0,\r
+          }\r
+        },\r
+        caption: {\r
+          type: 'text',\r
+          rules : {\r
+          }\r
+        },\r
+        publish: {\r
+          type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+          }\r
+        },\r
+        author_id: {\r
+          type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+          }\r
+        },\r
+        created_at: {\r
+          type: 'datetime',\r
+        },\r
+        updated_at: {\r
+          type: 'datetime',\r
+        }\r
+      }\r
+    },\r
     PanelPicture: 'panel_picture',\r
     panel_picture: {\r
       class_name: 'PanelPicture',\r
         id: {\r
           type: 'number',\r
           primary_key: 1,\r
+          rules : {\r
+            number: true,\r
+          }\r
         },\r
         panel_id: {\r
           type: 'number',\r
+          rules : {\r
+            number: true,\r
+          }\r
         },\r
         picture_id: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+          }\r
         },\r
         caption: {\r
           type: 'text',\r
+          rules : {\r
+          }\r
         },\r
         x: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+          }\r
         },\r
         y: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+          }\r
         },\r
         width: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+          }\r
         },\r
         height: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+          }\r
         },\r
         link: {\r
           type: 'text',\r
+          rules : {\r
+            url: true,\r
+          }\r
         },\r
         z: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            min: 1,\r
+          }\r
         },\r
         t: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            min: 0,\r
+          }\r
         },\r
         created_at: {\r
           type: 'datetime',\r
         id: {\r
           type: 'number',\r
           primary_key: 1,\r
+          rules : {\r
+            number: true,\r
+          }\r
         },\r
         panel_id: {\r
           type: 'number',\r
+          rules : {\r
+            number: true,\r
+          }\r
         },\r
         speech_balloon_template_id: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+          }\r
         },\r
         classname: {\r
           type: 'text',\r
+          rules : {\r
+            required: true,\r
+          }\r
         },\r
         z: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            min: 1,\r
+          }\r
         },\r
         t: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            min: 0,\r
+          }\r
         },\r
         settings: {\r
           type: 'text',\r
+          rules : {\r
+          }\r
         },\r
         caption: {\r
           type: 'text',\r
+          rules : {\r
+          }\r
         },\r
         created_at: {\r
           type: 'datetime',\r
         id: {\r
           type: 'number',\r
           primary_key: 1,\r
+          rules : {\r
+            number: true,\r
+          }\r
         },\r
         speech_balloon_id: {\r
           type: 'number',\r
+          rules : {\r
+            number: true,\r
+          }\r
         },\r
         system_picture_id: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+          }\r
         },\r
         x: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+          }\r
         },\r
         y: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+          }\r
         },\r
         width: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            min: 1,\r
+          }\r
         },\r
         height: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            min: 1,\r
+          }\r
         },\r
         r: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+          }\r
         },\r
         settings: {\r
           type: 'text',\r
+          rules : {\r
+          }\r
         },\r
         created_at: {\r
           type: 'datetime',\r
         id: {\r
           type: 'number',\r
           primary_key: 1,\r
+          rules : {\r
+            number: true,\r
+          }\r
         },\r
         speech_balloon_id: {\r
           type: 'number',\r
+          rules : {\r
+            number: true,\r
+          }\r
         },\r
         writing_format_id: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+          }\r
         },\r
         content: {\r
           type: 'text',\r
+          rules : {\r
+          }\r
         },\r
         font_size: {\r
           type: 'float',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            min: 0,\r
+          }\r
         },\r
         text_align: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            range: [0, 3],\r
+          }\r
         },\r
         fore_color: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            range: [0, 0xffffff],\r
+          }\r
         },\r
         x: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+          }\r
         },\r
         y: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+          }\r
         },\r
         width: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            min: 1,\r
+          }\r
         },\r
         height: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            min: 1,\r
+          }\r
         },\r
         quotes: {\r
           type: 'text',\r
+          rules : {\r
+          }\r
         },\r
         settings: {\r
           type: 'text',\r
+          rules : {\r
+          }\r
         },\r
         created_at: {\r
           type: 'datetime',\r
         id: {\r
           type: 'number',\r
           primary_key: 1,\r
+          rules : {\r
+            number: true,\r
+          }\r
         },\r
         panel_id: {\r
           type: 'number',\r
+          rules : {\r
+            number: true,\r
+          }\r
         },\r
         picture_id: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+          }\r
         },\r
         caption: {\r
           type: 'text',\r
+          rules : {\r
+          }\r
         },\r
         repeat: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            range: [0, 3],\r
+          }\r
         },\r
         x: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+          }\r
         },\r
         y: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+          }\r
         },\r
         z: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            min: 1,\r
+          }\r
         },\r
         t: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            min: 0,\r
+          }\r
         },\r
         created_at: {\r
           type: 'datetime',\r
         id: {\r
           type: 'number',\r
           primary_key: 1,\r
+          rules : {\r
+            number: true,\r
+          }\r
         },\r
         panel_id: {\r
           type: 'number',\r
+          rules : {\r
+            number: true,\r
+          }\r
         },\r
         caption: {\r
           type: 'text',\r
+          rules : {\r
+          }\r
         },\r
         code: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            range: [0, 0xffffff],\r
+          }\r
         },\r
         z: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            min: 1,\r
+          }\r
         },\r
         t: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+            min: 0,\r
+          }\r
         },\r
         created_at: {\r
           type: 'datetime',\r
         id: {\r
           type: 'number',\r
           primary_key: 1,\r
+          rules : {\r
+            number: true,\r
+          }\r
         },\r
         name: {\r
           type: 'text',\r
+          rules : {\r
+            required: true,\r
+          }\r
         },\r
         classname: {\r
           type: 'text',\r
+          rules : {\r
+            required: true,\r
+          }\r
         },\r
         caption: {\r
           type: 'text',\r
+          rules : {\r
+            required: true,\r
+          }\r
         },\r
         system_picture_id: {\r
           type: 'number',\r
+          rules : {\r
+            required: true,\r
+            number: true,\r
+          }\r
         },\r
         settings: {\r
           type: 'text',\r
+          rules : {\r
+            required: true,\r
+          }\r
         },\r
         created_at: {\r
           type: 'datetime',\r
     },\r
   ],\r
   forms: {\r
+    Panel: 'panel',\r
+    panel: {\r
+      attributes: {\r
+        caption: {\r
+          column: 'caption',\r
+          type: 'text',\r
+          label: {\r
+          },\r
+          options: {\r
+            row_break: true\r
+          }\r
+        },\r
+        width: {\r
+          column: 'width',\r
+          type: 'number',\r
+          label: {\r
+          },\r
+          options: {\r
+            size: 5, \r
+          },\r
+        },\r
+        height: {\r
+          column: 'height',\r
+          type: 'number',\r
+          label: {\r
+          },\r
+          options: {\r
+            size: 5, \r
+            row_break: true\r
+          }, \r
+        },\r
+        border: {\r
+          column: 'border',\r
+          type: 'number',\r
+          label: {\r
+          },\r
+          options: {\r
+            size: 5, \r
+          },\r
+        },\r
+        publish: {\r
+          column: 'publish',\r
+          type: 'select',\r
+          label: {\r
+          },\r
+          options: {\r
+            source: 'magic_number',\r
+            key: 'comic_visible_items',\r
+            size: 5, \r
+            row_break: true\r
+          }\r
+        },\r
+        id: {\r
+          column: 'id',\r
+          type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
+          options: {\r
+          }\r
+        },\r
+        author_id: {\r
+          column: 'author_id',\r
+          type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
+          options: {\r
+          }\r
+        },\r
+      },\r
+      fields: [\r
+        'caption',\r
+        'width',\r
+        'height',\r
+        'border',\r
+        'publish',\r
+        'id',\r
+        'author_id',\r
+      ]\r
+    },\r
     PanelPicture: 'panel_picture',\r
     panel_picture: {\r
-      fields: [\r
-        {\r
+      attributes: {\r
+        caption: {\r
           column: 'caption',\r
           type: 'text',\r
+          label: {\r
+          },\r
           options: {\r
-            label_break: false,\r
             row_break: true\r
           }\r
         },\r
-        {\r
+        x: {\r
           column: 'x',\r
           type: 'number',\r
+          label: {\r
+          },\r
           options: {\r
             size: 5, \r
           }\r
         },\r
-        {\r
+        y: {\r
           column: 'y',\r
           type: 'number',\r
+          label: {\r
+          },\r
           options: {\r
             size: 5, \r
             row_break: true\r
           }\r
         },\r
-        {\r
+        width: {\r
           column: 'width',\r
           type: 'number',\r
+          label: {\r
+          },\r
           options: {\r
             size: 5, \r
             row_break: true\r
             }\r
           },\r
         },\r
-        {\r
+        height: {\r
           column: 'height',\r
           type: 'number',\r
+          label: {\r
+          },\r
           options: {\r
             size: 5, \r
             row_break: true\r
             }\r
           },\r
         },\r
-        {\r
+        link: {\r
           column: 'link',\r
           type: 'text',\r
+          label: {\r
+          },\r
           options: {\r
             row_break: true\r
           }\r
         },\r
-        {\r
+        id: {\r
           column: 'id',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
         },\r
-        {\r
+        panel_id: {\r
           column: 'panel_id',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
         },\r
-        {\r
+        picture_id: {\r
           column: 'picture_id',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
         },\r
-        {\r
+        z: {\r
           column: 'z',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
         },\r
-        {\r
+        t: {\r
           column: 't',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
         },\r
+      },\r
+      fields: [\r
+        'caption',\r
+        'x',\r
+        'y',\r
+        'width',\r
+        'height',\r
+        'link',\r
+        'id',\r
+        'panel_id',\r
+        'picture_id',\r
+        'z',\r
+        't',\r
       ]\r
     },\r
-    CircleSpeechBalloon: 'circle_speech_balloon',\r
-    circle_speech_balloon: {\r
-      base: 'speech_balloon',\r
-      fields: [\r
-        {\r
+    speech_balloon: {\r
+      attributes: {\r
+        'speech_balloon.id': {\r
+          column: 'id',\r
+          type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
+          options: {\r
+          }\r
+        },\r
+        'speech_balloon.panel_id': {\r
+          column: 'panel_id',\r
+          type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
+          options: {\r
+          }\r
+        },\r
+        'speech_balloon.speech_balloon_template_id': {\r
+          column: 'speech_balloon_template_id',\r
+          type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
+          options: {\r
+          }\r
+        },\r
+        'speech_balloon.caption': {\r
           column: 'caption',\r
           type: 'text',\r
+          label: {\r
+          },\r
           options: {\r
             row_break: true\r
           }\r
         },\r
-        {\r
+        'speech_balloon.z': {\r
+          column: 'z',\r
+          type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
+          options: {\r
+          }\r
+        },\r
+        'speech_balloon.t': {\r
+          column: 't',\r
+          type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
+          options: {\r
+          }\r
+        },\r
+        'speech_balloon.classname': {\r
+          column: 'classname',\r
+          type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
+          options: {\r
+          }\r
+        },\r
+        'speech_balloon.settings': {\r
+          column: 'settings',\r
+          type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
+          options: {\r
+          }\r
+        },\r
+        'balloon.id': {\r
+          model: 'balloon',\r
+          part: 'balloon',\r
+          column: 'id',\r
+          type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
+          options: {\r
+          }\r
+        },\r
+        'balloon.speech_balloon_id': {\r
+          model: 'balloon',\r
+          part: 'balloon',\r
+          column: 'speech_balloon_id',\r
+          type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
+          options: {\r
+          }\r
+        },\r
+        'balloon.system_picture_id': {\r
+          model: 'balloon',\r
+          part: 'balloon',\r
+          column: 'system_picture_id',\r
+          type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
+          options: {\r
+          }\r
+        },\r
+        'balloon.r': {\r
+          model: 'balloon',\r
           part: 'balloon',\r
           column: 'r',\r
           type: 'number',\r
+          label: {\r
+          },\r
           options: {\r
             size: 5, \r
             row_break: true\r
             }\r
           }\r
         },\r
-        {\r
+        'balloon.x': {\r
+          model: 'balloon',\r
           part: 'balloon',\r
           column: 'x',\r
           type: 'number',\r
+          label: {\r
+          },\r
           options: {\r
             size: 5, \r
           }\r
         },\r
-        {\r
+        'balloon.y': {\r
+          model: 'balloon',\r
           part: 'balloon',\r
           column: 'y',\r
           type: 'number',\r
+          label: {\r
+          },\r
           options: {\r
             size: 5, \r
             row_break: true\r
           }\r
         },\r
-        {\r
+        'balloon.width': {\r
+          model: 'balloon',\r
           part: 'balloon',\r
           column: 'width',\r
           type: 'number',\r
+          label: {\r
+          },\r
           options: {\r
             size: 5, \r
           }\r
         },\r
-        {\r
+        'balloon.height': {\r
+          model: 'balloon',\r
           part: 'balloon',\r
           column: 'height',\r
           type: 'number',\r
+          label: {\r
+          },\r
           options: {\r
             size: 5, \r
             row_break: true\r
           }\r
         },\r
-        {\r
+        'balloon.settings': {\r
+          model: 'balloon',\r
           part: 'balloon',\r
-          column: 'id',\r
+          column: 'settings',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
         },\r
-        {\r
-          part: 'balloon',\r
-          column: 'speech_balloon_id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'balloon',\r
-          column: 'system_picture_id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'balloon',\r
-          column: 'settings',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'writing_format_id',\r
-          type: 'select',\r
-          options: {\r
-            source: 'model',\r
-            model: 'writing_format',\r
-            method: 'enable_list',\r
-            caption: 'caption'\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'font_size',\r
-          type: 'select',\r
-          options: {\r
-            source: 'magic_number',\r
-            key: 'speech_font_size_items',\r
-            row_break: true\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'text_align',\r
-          type: 'select',\r
-          options: {\r
-            source: 'magic_number',\r
-            key: 'speech_text_align_items',\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'quotes',\r
-          type: 'text',\r
-          options: {\r
-            size: 5, \r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'content',\r
-          type: 'text_area',\r
-          options: {\r
-            label_break: true,\r
-            size: '45x5', \r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'fore_color',\r
-          type: 'hidden',\r
-          options: {\r
-            label_break: true,\r
-          },\r
-          helpers: {\r
-            color: {\r
-              path: 'panels/color_helper',\r
-              options: {\r
-              },\r
-              wrapper: 'speech-fore_color-wrap'\r
-            }\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'speech_balloon_id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'x',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'y',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'width',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'height',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'settings',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          column: 'id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          column: 'panel_id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          column: 'speech_balloon_template_id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          column: 'classname',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          column: 'z',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          column: 't',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          column: 'settings',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        }\r
-      ]\r
-    },\r
-    PlainSpeechBalloon: 'plain_speech_balloon',\r
-    plain_speech_balloon: {\r
-      base: 'speech_balloon',\r
-      fields: [\r
-        {\r
-          column: 'caption',\r
-          type: 'text',\r
-          options: {\r
-            row_break: true\r
-          }\r
-        },\r
-        {\r
-          part: 'balloon',\r
-          column: 'r',\r
-          type: 'hidden',\r
-          options: {\r
-          },\r
-        },\r
-        {\r
-          part: 'balloon',\r
-          column: 'x',\r
-          type: 'number',\r
-          options: {\r
-            size: 5, \r
-          }\r
-        },\r
-        {\r
-          part: 'balloon',\r
-          column: 'y',\r
-          type: 'number',\r
-          options: {\r
-            size: 5, \r
-            row_break: true\r
-          }\r
-        },\r
-        {\r
-          part: 'balloon',\r
-          column: 'width',\r
-          type: 'number',\r
-          options: {\r
-            size: 5, \r
-          }\r
-        },\r
-        {\r
-          part: 'balloon',\r
-          column: 'height',\r
-          type: 'number',\r
-          options: {\r
-            size: 5, \r
-            row_break: true\r
-          }\r
-        },\r
-        {\r
-          part: 'balloon',\r
-          column: 'id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'balloon',\r
-          column: 'speech_balloon_id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'balloon',\r
-          column: 'system_picture_id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'balloon',\r
-          column: 'settings',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'writing_format_id',\r
-          type: 'select',\r
-          options: {\r
-            source: 'model',\r
-            model: 'writing_format',\r
-            method: 'enable_list',\r
-            caption: 'caption'\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'font_size',\r
-          type: 'select',\r
-          options: {\r
-            source: 'magic_number',\r
-            key: 'speech_font_size_items',\r
-            row_break: true\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'text_align',\r
-          type: 'select',\r
-          options: {\r
-            source: 'magic_number',\r
-            key: 'speech_text_align_items',\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'quotes',\r
-          type: 'text',\r
-          options: {\r
-            size: 5, \r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'content',\r
-          type: 'text_area',\r
-          options: {\r
-            label_break: true,\r
-            size: '45x5', \r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'fore_color',\r
-          type: 'hidden',\r
-          options: {\r
-            label_break: true,\r
-          },\r
-          helpers: {\r
-            color: {\r
-              path: 'panels/color_helper',\r
-              options: {\r
-              },\r
-              wrapper: 'speech-fore_color-wrap'\r
-            }\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'speech_balloon_id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'x',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'y',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'width',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'height',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'settings',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
+        'speech.id': {\r
+          model: 'speech',\r
+          part: 'speech',\r
           column: 'id',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
         },\r
-        {\r
-          column: 'panel_id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          column: 'speech_balloon_template_id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          column: 'classname',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          column: 'z',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          column: 't',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          column: 'settings',\r
+        'speech.speech_balloon_id': {\r
+          model: 'speech',\r
+          part: 'speech',\r
+          column: 'speech_balloon_id',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
-        }\r
-      ]\r
-    },\r
-    SquareSpeechBalloon: 'square_speech_balloon',\r
-    square_speech_balloon: {\r
-      base: 'speech_balloon',\r
-      fields: [\r
-        {\r
-          column: 'caption',\r
-          type: 'text',\r
-          options: {\r
-            row_break: true\r
-          }\r
         },\r
-        {\r
-          part: 'balloon',\r
-          column: 'r',\r
+        'speech.x': {\r
+          model: 'speech',\r
+          part: 'speech',\r
+          column: 'x',\r
           type: 'hidden',\r
-          options: {\r
+          label: {\r
+            type: 'hidden'\r
           },\r
-        },\r
-        {\r
-          part: 'balloon',\r
-          column: 'x',\r
-          type: 'number',\r
           options: {\r
-            size: 5, \r
           }\r
         },\r
-        {\r
-          part: 'balloon',\r
+        'speech.y': {\r
+          model: 'speech',\r
+          part: 'speech',\r
           column: 'y',\r
-          type: 'number',\r
-          options: {\r
-            size: 5, \r
-            row_break: true\r
-          }\r
-        },\r
-        {\r
-          part: 'balloon',\r
-          column: 'width',\r
-          type: 'number',\r
-          options: {\r
-            size: 5, \r
-          }\r
-        },\r
-        {\r
-          part: 'balloon',\r
-          column: 'height',\r
-          type: 'number',\r
-          options: {\r
-            size: 5, \r
-            row_break: true\r
-          }\r
-        },\r
-        {\r
-          part: 'balloon',\r
-          column: 'id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'balloon',\r
-          column: 'speech_balloon_id',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
         },\r
-        {\r
-          part: 'balloon',\r
-          column: 'system_picture_id',\r
+        'speech.width': {\r
+          model: 'speech',\r
+          part: 'speech',\r
+          column: 'width',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
         },\r
-        {\r
-          part: 'balloon',\r
-          column: 'settings',\r
+        'speech.height': {\r
+          model: 'speech',\r
+          part: 'speech',\r
+          column: 'height',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
         },\r
-        {\r
+        'speech.writing_format_id': {\r
+          model: 'speech',\r
           part: 'speech',\r
           column: 'writing_format_id',\r
           type: 'select',\r
+          label: {\r
+          },\r
           options: {\r
             source: 'model',\r
             model: 'writing_format',\r
             caption: 'caption'\r
           }\r
         },\r
-        {\r
+        'speech.font_size': {\r
+          model: 'speech',\r
           part: 'speech',\r
           column: 'font_size',\r
           type: 'select',\r
+          label: {\r
+          },\r
           options: {\r
             source: 'magic_number',\r
             key: 'speech_font_size_items',\r
             row_break: true\r
           }\r
         },\r
-        {\r
+        'speech.text_align': {\r
+          model: 'speech',\r
           part: 'speech',\r
           column: 'text_align',\r
           type: 'select',\r
+          label: {\r
+          },\r
           options: {\r
             source: 'magic_number',\r
             key: 'speech_text_align_items',\r
           }\r
         },\r
-        {\r
+        'speech.quotes': {\r
+          model: 'speech',\r
           part: 'speech',\r
           column: 'quotes',\r
           type: 'text',\r
+          label: {\r
+          },\r
           options: {\r
             size: 5, \r
           }\r
         },\r
-        {\r
+        'speech.content': {\r
+          model: 'speech',\r
           part: 'speech',\r
           column: 'content',\r
           type: 'text_area',\r
+          label: {\r
+            row_break: true\r
+          },\r
           options: {\r
-            label_break: true,\r
             size: '45x5', \r
           }\r
         },\r
-        {\r
+        'speech.fore_color': {\r
+          model: 'speech',\r
           part: 'speech',\r
           column: 'fore_color',\r
           type: 'hidden',\r
+          label: {\r
+            row_break: true\r
+          },\r
           options: {\r
-            label_break: true,\r
           },\r
           helpers: {\r
             color: {\r
             }\r
           }\r
         },\r
-        {\r
-          part: 'speech',\r
-          column: 'id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'speech_balloon_id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'x',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          part: 'speech',\r
-          column: 'y',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
+        'speech.settings': {\r
+          model: 'speech',\r
           part: 'speech',\r
-          column: 'width',\r
+          column: 'settings',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
         },\r
-        {\r
-          part: 'speech',\r
-          column: 'height',\r
+      },\r
+    },\r
+    CircleSpeechBalloon: 'circle_speech_balloon',\r
+    circle_speech_balloon: {\r
+      base: 'speech_balloon',\r
+      attributes: {\r
+      },\r
+      fields: [\r
+          'speech_balloon.caption',\r
+          'balloon.r',\r
+          'balloon.x',\r
+          'balloon.y',\r
+          'balloon.width',\r
+          'balloon.height',\r
+          'balloon.id',\r
+          'balloon.speech_balloon_id',\r
+          'balloon.system_picture_id',\r
+          'balloon.settings',\r
+          'speech.writing_format_id',\r
+          'speech.font_size',\r
+          'speech.text_align',\r
+          'speech.quotes',\r
+          'speech.content',\r
+          'speech.fore_color',\r
+          'speech.id',\r
+          'speech.speech_balloon_id',\r
+          'speech.x',\r
+          'speech.y',\r
+          'speech.width',\r
+          'speech.height',\r
+          'speech.settings',\r
+          'speech_balloon.id',\r
+          'speech_balloon.panel_id',\r
+          'speech_balloon.speech_balloon_template_id',\r
+          'speech_balloon.classname',\r
+          'speech_balloon.z',\r
+          'speech_balloon.t',\r
+          'speech_balloon.settings',\r
+      ]\r
+    },\r
+    PlainSpeechBalloon: 'plain_speech_balloon',\r
+    plain_speech_balloon: {\r
+      base: 'speech_balloon',\r
+      attributes: {\r
+        'balloon.r': {\r
+          model: 'balloon',\r
+          part: 'balloon',\r
+          column: 'r',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
-          }\r
+          },\r
         },\r
-        {\r
-          part: 'speech',\r
-          column: 'settings',\r
+      },\r
+      fields: [\r
+        'speech_balloon.caption',\r
+        'balloon.r',\r
+        'balloon.x',\r
+        'balloon.y',\r
+        'balloon.width',\r
+        'balloon.height',\r
+        'balloon.id',\r
+        'balloon.speech_balloon_id',\r
+        'balloon.system_picture_id',\r
+        'balloon.settings',\r
+        'speech.writing_format_id',\r
+        'speech.font_size',\r
+        'speech.text_align',\r
+        'speech.quotes',\r
+        'speech.content',\r
+        'speech.fore_color',\r
+        'speech.id',\r
+        'speech.speech_balloon_id',\r
+        'speech.x',\r
+        'speech.y',\r
+        'speech.width',\r
+        'speech.height',\r
+        'speech.settings',\r
+        'speech_balloon.id',\r
+        'speech_balloon.panel_id',\r
+        'speech_balloon.speech_balloon_template_id',\r
+        'speech_balloon.classname',\r
+        'speech_balloon.z',\r
+        'speech_balloon.t',\r
+        'speech_balloon.settings',\r
+      ]\r
+    },\r
+    SquareSpeechBalloon: 'square_speech_balloon',\r
+    square_speech_balloon: {\r
+      base: 'speech_balloon',\r
+      attributes: {\r
+        'balloon.r': {\r
+          model: 'balloon',\r
+          part: 'balloon',\r
+          column: 'r',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
-          }\r
+          },\r
         },\r
-        {\r
+      },\r
+      fields: [\r
+        'speech_balloon.caption',\r
+        'balloon.r',\r
+        'balloon.x',\r
+        'balloon.y',\r
+        'balloon.width',\r
+        'balloon.height',\r
+        'balloon.id',\r
+        'balloon.speech_balloon_id',\r
+        'balloon.system_picture_id',\r
+        'balloon.settings',\r
+        'speech.writing_format_id',\r
+        'speech.font_size',\r
+        'speech.text_align',\r
+        'speech.quotes',\r
+        'speech.content',\r
+        'speech.fore_color',\r
+        'speech.id',\r
+        'speech.speech_balloon_id',\r
+        'speech.x',\r
+        'speech.y',\r
+        'speech.width',\r
+        'speech.height',\r
+        'speech.settings',\r
+        'speech_balloon.id',\r
+        'speech_balloon.panel_id',\r
+        'speech_balloon.speech_balloon_template_id',\r
+        'speech_balloon.classname',\r
+        'speech_balloon.z',\r
+        'speech_balloon.t',\r
+        'speech_balloon.settings',\r
+      ]\r
+    },\r
+    GroundPicture: 'ground_picture',\r
+    ground_picture: {\r
+      attributes: {\r
+        id: {\r
           column: 'id',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
         },\r
-        {\r
+        panel_id: {\r
           column: 'panel_id',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
         },\r
-        {\r
-          column: 'speech_balloon_template_id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          column: 'classname',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          column: 'z',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          column: 't',\r
+        picture_id: {\r
+          column: 'picture_id',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
         },\r
-        {\r
-          column: 'settings',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        }\r
-      ]\r
-    },\r
-    GroundPicture: 'ground_picture',\r
-    ground_picture: {\r
-      fields: [\r
-        {\r
+        caption: {\r
           column: 'caption',\r
           type: 'text',\r
+          label: {\r
+          },\r
           options: {\r
             row_break: true\r
           }\r
         },\r
-        {\r
+        repeat: {\r
           column: 'repeat',\r
           type: 'select',\r
+          label: {\r
+          },\r
           options: {\r
             source: 'magic_number',\r
             key: 'ground_picture_repeat_items',\r
             row_break: true\r
           }\r
         },\r
-        {\r
+        x: {\r
           column: 'x',\r
           type: 'number',\r
+          label: {\r
+          },\r
           options: {\r
             size: 5, \r
           }\r
         },\r
-        {\r
+        y: {\r
           column: 'y',\r
           type: 'number',\r
+          label: {\r
+          },\r
           options: {\r
             size: 5, \r
             row_break: true\r
           }\r
         },\r
-        {\r
+        z: {\r
           column: 'z',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
         },\r
-        {\r
+        t: {\r
           column: 't',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
         },\r
-        {\r
+      },\r
+      fields: [\r
+        'caption',\r
+        'repeat',\r
+        'x',\r
+        'y',\r
+        'z',\r
+        't',\r
+        'id',\r
+        'panel_id',\r
+        'picture_id',\r
+      ]\r
+    },\r
+    GroundColor: 'ground_color',\r
+    ground_color: {\r
+      attributes: {\r
+        id: {\r
           column: 'id',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
         },\r
-        {\r
+        panel_id: {\r
           column: 'panel_id',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
         },\r
-        {\r
-          column: 'picture_id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-      ]\r
-    },\r
-    GroundColor: 'ground_color',\r
-    ground_color: {\r
-      fields: [\r
-        {\r
+        caption: {\r
           column: 'caption',\r
           type: 'text',\r
+          label: {\r
+          },\r
           options: {\r
             row_break: true\r
           }\r
         },\r
-        {\r
+        code: {\r
           column: 'code',\r
           type: 'hidden',\r
+          label: {\r
+            row_break: true\r
+          },\r
           options: {\r
-            label_break: true,\r
             row_break: true\r
           }\r
           helpers: {\r
             }\r
           },\r
         },\r
-        {\r
+        z: {\r
           column: 'z',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
         },\r
-        {\r
+        t: {\r
           column: 't',\r
           type: 'hidden',\r
+          label: {\r
+            type: 'hidden'\r
+          },\r
           options: {\r
           }\r
         },\r
-        {\r
-          column: 'id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
-        {\r
-          column: 'panel_id',\r
-          type: 'hidden',\r
-          options: {\r
-          }\r
-        },\r
+      },\r
+      fields: [\r
+        'id',\r
+        'panel_id',\r
+        'caption',\r
+        'code',\r
+        'z',\r
+        't',\r
       ]\r
     }\r
   },\r
index c2c50e0..4099805 100644 (file)
@@ -2,6 +2,7 @@ $ ->
   confirm_confirm_confirm = () ->\r
     confirm(  )\r
   editor = window.PettanrEditor\r
+  configurations =  window.configurations\r
   WritingFormat = window.PettanrWritingFormat\r
   WritingFormat.load($('#writing_formats'))\r
   SpeechBalloonTemplate = window.PettanrSpeechBalloonTemplate\r
@@ -12,6 +13,64 @@ $ ->
   PictureSizeHelper = window.PettanrPictureSizeHelper\r
   ColorHelper = window.PettanrColorHelper\r
   \r
+  find_configurations = ( hash, key) ->\r
+    if typeof(hash[key]) == 'string'\r
+      find_configurations(hash, hash[key])\r
+    else\r
+      return hash[key]\r
+  \r
+  set_validates = (form) ->\r
+    rules = {}\r
+    $('input', form).map ->\r
+      model_name = $(@).attr('data-model')\r
+      column_name = $(@).attr('column')\r
+      name = $(@).attr('name')\r
+      if model_name and column_name\r
+        model = find_configurations(configurations['models'], model_name)\r
+        rule = model['attributes'][column_name]['rules']\r
+        trace = editor.element_tag_id($(@)) \r
+        if rule\r
+          rules[name] = rule\r
+    if Object.keys(rules).length > 0\r
+      v = form.validate({ignore:[],rules: rules})\r
+\r
+  validate_forms = () ->\r
+    valid = true\r
+    $('form', $('#tabs-1')).map  ->\r
+      form_name = $(@).attr('data-form-name')\r
+      if form_name\r
+        if $(@).valid()\r
+          bc = ''\r
+        else\r
+          valid = false\r
+          bc = '#ef29ef'\r
+        $('a', $('#tabs-1-tab')).map ->\r
+          $(@).css('background-color', bc)\r
+    invalid_elements = []\r
+    $('form', $('#tabs-2')).map  ->\r
+      form_name = $(@).attr('data-form-name')\r
+      if form_name\r
+        if $(@).valid()\r
+          bc = ''\r
+        else\r
+          valid = false\r
+          bc = '#ef29ef'\r
+          invalid_elements.push form_name\r
+        trace = editor.element_tag_id($(@)) \r
+        $('.elements-tab', $(trace + 'element_tab')).map  ->\r
+          $(@).css('background-color', bc)\r
+    if invalid_elements.length > 0\r
+      bc = '#ef29ef'\r
+    else\r
+      bc = ''\r
+    $('a', $('#tabs-2-tab')).map ->\r
+      $(@).css('background-color', bc)\r
+    return valid\r
+  $('form').map  ->\r
+    form_name = $(@).attr('data-form-name')\r
+    if form_name\r
+      form = $(this)\r
+      set_validates(form)\r
   $('.panel-editor').map ->\r
     if $(@).attr('current') and parseInt($(@).attr('current')) > 0\r
       editor.pettanr_current_panel_id = parseInt($(@).attr('panel_id'))\r
@@ -421,6 +480,11 @@ $ ->
     \r
     $('.edit_panel' ).map ->\r
       if $(@).attr('jqform')\r
+        $(@).submit ->\r
+          if validate_forms()\r
+            true\r
+          else\r
+            false\r
       else\r
         $(@).submit ->\r
           false\r
index a6fdfe8..b3a7462 100644 (file)
@@ -271,6 +271,8 @@ font-family : monospace;
 .ui-tabs .ui-tabs-nav li.ui-tabs-active {
     margin-bottom: 0.2em;
 }
+.element-tab {
+}
 .elements-tab {
   width: 100%;
    overflow: hidden;
index bac1cae..a63fee4 100644 (file)
@@ -67,6 +67,69 @@ module ApplicationHelper
     JSON.parse(<<HD
 {
     "models": {
+        "Panel": "panel",
+        "panel": {
+            "class_name": "Panel",
+            "table_name": "panels",
+            "attributes": {
+                "id": {
+                    "type": "number",
+                    "primary_key": 1,
+                    "rules": {
+                        "number": true
+                    }
+                },
+                "width": {
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "min": 1
+                    }
+                },
+                "height": {
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "min": 1
+                    }
+                },
+                "border": {
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "min": 0
+                    }
+                },
+                "caption": {
+                    "type": "text",
+                    "rules": {
+                    }
+                },
+                "publish": {
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true
+                    }
+                },
+                "author_id": {
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true
+                    }
+                },
+                "created_at": {
+                    "type": "datetime"
+                },
+                "updated_at": {
+                    "type": "datetime"
+                }
+            }
+        },
         "PanelPicture": "panel_picture",
         "panel_picture": {
             "class_name": "PanelPicture",
@@ -74,37 +137,77 @@ module ApplicationHelper
             "attributes": {
                 "id": {
                     "type": "number",
-                    "primary_key": 1
+                    "primary_key": 1,
+                    "rules": {
+                        "number": true
+                    }
                 },
                 "panel_id": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "number": true
+                    }
                 },
                 "picture_id": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true
+                    }
                 },
                 "caption": {
-                    "type": "text"
+                    "type": "text",
+                    "rules": {}
                 },
                 "x": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true
+                    }
                 },
                 "y": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true
+                    }
                 },
                 "width": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true
+                    }
                 },
                 "height": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true
+                    }
                 },
                 "link": {
-                    "type": "text"
+                    "type": "text",
+                    "rules": {
+                        "url": true
+                    }
                 },
                 "z": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "min": 1
+                    }
                 },
                 "t": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "min": 0
+                    }
                 },
                 "created_at": {
                     "type": "datetime"
@@ -122,28 +225,53 @@ module ApplicationHelper
             "attributes": {
                 "id": {
                     "type": "number",
-                    "primary_key": 1
+                    "primary_key": 1,
+                    "rules": {
+                        "number": true
+                    }
                 },
                 "panel_id": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "number": true
+                    }
                 },
                 "speech_balloon_template_id": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true
+                    }
                 },
                 "classname": {
-                    "type": "text"
+                    "type": "text",
+                    "rules": {
+                        "required": true
+                    }
                 },
                 "z": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "min": 1
+                    }
                 },
                 "t": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "min": 0
+                    }
                 },
                 "settings": {
-                    "type": "text"
+                    "type": "text",
+                    "rules": {}
                 },
                 "caption": {
-                    "type": "text"
+                    "type": "text",
+                    "rules": {}
                 },
                 "created_at": {
                     "type": "datetime"
@@ -160,31 +288,64 @@ module ApplicationHelper
             "attributes": {
                 "id": {
                     "type": "number",
-                    "primary_key": 1
+                    "primary_key": 1,
+                    "rules": {
+                        "number": true
+                    }
                 },
                 "speech_balloon_id": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "number": true
+                    }
                 },
                 "system_picture_id": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true
+                    }
                 },
                 "x": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true
+                    }
                 },
                 "y": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true
+                    }
                 },
                 "width": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "min": 1
+                    }
                 },
                 "height": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "min": 1
+                    }
                 },
                 "r": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true
+                    }
                 },
                 "settings": {
-                    "type": "text"
+                    "type": "text",
+                    "rules": {}
                 },
                 "created_at": {
                     "type": "datetime"
@@ -201,43 +362,95 @@ module ApplicationHelper
             "attributes": {
                 "id": {
                     "type": "number",
-                    "primary_key": 1
+                    "primary_key": 1,
+                    "rules": {
+                        "number": true
+                    }
                 },
                 "speech_balloon_id": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "number": true
+                    }
                 },
                 "writing_format_id": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true
+                    }
                 },
                 "content": {
-                    "type": "text"
+                    "type": "text",
+                    "rules": {}
                 },
                 "font_size": {
-                    "type": "float"
+                    "type": "float",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "min": 0
+                    }
                 },
                 "text_align": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "range": [
+                            0,
+                            3
+                        ]
+                    }
                 },
                 "fore_color": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "range": [
+                            0,
+                            16777215
+                        ]
+                    }
                 },
                 "x": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true
+                    }
                 },
                 "y": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true
+                    }
                 },
                 "width": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "min": 1
+                    }
                 },
                 "height": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "min": 1
+                    }
                 },
                 "quotes": {
-                    "type": "text"
+                    "type": "text",
+                    "rules": {}
                 },
                 "settings": {
-                    "type": "text"
+                    "type": "text",
+                    "rules": {}
                 },
                 "created_at": {
                     "type": "datetime"
@@ -254,31 +467,68 @@ module ApplicationHelper
             "attributes": {
                 "id": {
                     "type": "number",
-                    "primary_key": 1
+                    "primary_key": 1,
+                    "rules": {
+                        "number": true
+                    }
                 },
                 "panel_id": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "number": true
+                    }
                 },
                 "picture_id": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true
+                    }
                 },
                 "caption": {
-                    "type": "text"
+                    "type": "text",
+                    "rules": {}
                 },
                 "repeat": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "range": [
+                            0,
+                            3
+                        ]
+                    }
                 },
                 "x": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true
+                    }
                 },
                 "y": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true
+                    }
                 },
                 "z": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "min": 1
+                    }
                 },
                 "t": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "min": 0
+                    }
                 },
                 "created_at": {
                     "type": "datetime"
@@ -295,22 +545,47 @@ module ApplicationHelper
             "attributes": {
                 "id": {
                     "type": "number",
-                    "primary_key": 1
+                    "primary_key": 1,
+                    "rules": {
+                        "number": true
+                    }
                 },
                 "panel_id": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "number": true
+                    }
                 },
                 "caption": {
-                    "type": "text"
+                    "type": "text",
+                    "rules": {}
                 },
                 "code": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "range": [
+                            0,
+                            16777215
+                        ]
+                    }
                 },
                 "z": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "min": 1
+                    }
                 },
                 "t": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true,
+                        "min": 0
+                    }
                 },
                 "created_at": {
                     "type": "datetime"
@@ -327,22 +602,41 @@ module ApplicationHelper
             "attributes": {
                 "id": {
                     "type": "number",
-                    "primary_key": 1
+                    "primary_key": 1,
+                    "rules": {
+                        "number": true
+                    }
                 },
                 "name": {
-                    "type": "text"
+                    "type": "text",
+                    "rules": {
+                        "required": true
+                    }
                 },
                 "classname": {
-                    "type": "text"
+                    "type": "text",
+                    "rules": {
+                        "required": true
+                    }
                 },
                 "caption": {
-                    "type": "text"
+                    "type": "text",
+                    "rules": {
+                        "required": true
+                    }
                 },
                 "system_picture_id": {
-                    "type": "number"
+                    "type": "number",
+                    "rules": {
+                        "required": true,
+                        "number": true
+                    }
                 },
                 "settings": {
-                    "type": "text"
+                    "type": "text",
+                    "rules": {
+                        "required": true
+                    }
                 },
                 "created_at": {
                     "type": "datetime"
@@ -379,35 +673,112 @@ module ApplicationHelper
         }
     ],
     "forms": {
+        "Panel": "panel",
+        "panel": {
+            "attributes": {
+                "caption": {
+                    "column": "caption",
+                    "type": "text",
+                    "label": {},
+                    "options": {
+                        "row_break": true
+                    }
+                },
+                "width": {
+                    "column": "width",
+                    "type": "number",
+                    "label": {},
+                    "options": {
+                        "size": 5
+                    }
+                },
+                "height": {
+                    "column": "height",
+                    "type": "number",
+                    "label": {},
+                    "options": {
+                        "size": 5,
+                        "row_break": true
+                    }
+                },
+                "border": {
+                    "column": "border",
+                    "type": "number",
+                    "label": {},
+                    "options": {
+                        "size": 5
+                    }
+                },
+                "publish": {
+                    "column": "publish",
+                    "type": "select",
+                    "label": {},
+                    "options": {
+                        "source": "magic_number",
+                        "key": "comic_visible_items",
+                        "size": 5,
+                        "row_break": true
+                    }
+                },
+                "id": {
+                    "column": "id",
+                    "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
+                    "options": {}
+                },
+                "author_id": {
+                    "column": "author_id",
+                    "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
+                    "options": {}
+                }
+            },
+            "fields": [
+                "caption",
+                "width",
+                "height",
+                "border",
+                "publish",
+                "id",
+                "author_id"
+            ]
+        },
         "PanelPicture": "panel_picture",
         "panel_picture": {
-            "fields": [
-                {
+            "attributes": {
+                "caption": {
                     "column": "caption",
                     "type": "text",
+                    "label": {},
                     "options": {
-                        "label_break": false,
                         "row_break": true
                     }
                 },
-                {
+                "x": {
                     "column": "x",
                     "type": "number",
+                    "label": {},
                     "options": {
                         "size": 5
                     }
                 },
-                {
+                "y": {
                     "column": "y",
                     "type": "number",
+                    "label": {},
                     "options": {
                         "size": 5,
                         "row_break": true
                     }
                 },
-                {
+                "width": {
                     "column": "width",
                     "type": "number",
+                    "label": {},
                     "options": {
                         "size": 5,
                         "row_break": true
@@ -421,9 +792,10 @@ module ApplicationHelper
                         }
                     }
                 },
-                {
+                "height": {
                     "column": "height",
                     "type": "number",
+                    "label": {},
                     "options": {
                         "size": 5,
                         "row_break": true
@@ -437,560 +809,300 @@ module ApplicationHelper
                         }
                     }
                 },
-                {
+                "link": {
                     "column": "link",
                     "type": "text",
+                    "label": {},
                     "options": {
                         "row_break": true
                     }
                 },
-                {
+                "id": {
                     "column": "id",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 },
-                {
+                "panel_id": {
                     "column": "panel_id",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 },
-                {
+                "picture_id": {
                     "column": "picture_id",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 },
-                {
+                "z": {
                     "column": "z",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 },
-                {
+                "t": {
                     "column": "t",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 }
+            },
+            "fields": [
+                "caption",
+                "x",
+                "y",
+                "width",
+                "height",
+                "link",
+                "id",
+                "panel_id",
+                "picture_id",
+                "z",
+                "t"
             ]
         },
-        "CircleSpeechBalloon": "circle_speech_balloon",
-        "circle_speech_balloon": {
-            "base": "speech_balloon",
-            "fields": [
-                {
+        "speech_balloon": {
+            "attributes": {
+                "speech_balloon.id": {
+                    "column": "id",
+                    "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
+                    "options": {}
+                },
+                "speech_balloon.panel_id": {
+                    "column": "panel_id",
+                    "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
+                    "options": {}
+                },
+                "speech_balloon.speech_balloon_template_id": {
+                    "column": "speech_balloon_template_id",
+                    "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
+                    "options": {}
+                },
+                "speech_balloon.caption": {
                     "column": "caption",
                     "type": "text",
+                    "label": {},
                     "options": {
                         "row_break": true
                     }
                 },
-                {
-                    "part": "balloon",
-                    "column": "r",
-                    "type": "number",
-                    "options": {
-                        "size": 5,
-                        "row_break": true
+                "speech_balloon.z": {
+                    "column": "z",
+                    "type": "hidden",
+                    "label": {
+                        "type": "hidden"
                     },
-                    "helpers": {
-                        "tail_angle": {
-                            "path": "panels/tail_angle_helper",
-                            "options": {}
-                        }
-                    }
+                    "options": {}
                 },
-                {
-                    "part": "balloon",
-                    "column": "x",
-                    "type": "number",
-                    "options": {
-                        "size": 5
-                    }
+                "speech_balloon.t": {
+                    "column": "t",
+                    "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
+                    "options": {}
                 },
-                {
-                    "part": "balloon",
-                    "column": "y",
-                    "type": "number",
-                    "options": {
-                        "size": 5,
-                        "row_break": true
-                    }
-                },
-                {
-                    "part": "balloon",
-                    "column": "width",
-                    "type": "number",
-                    "options": {
-                        "size": 5
-                    }
+                "speech_balloon.classname": {
+                    "column": "classname",
+                    "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
+                    "options": {}
                 },
-                {
-                    "part": "balloon",
-                    "column": "height",
-                    "type": "number",
-                    "options": {
-                        "size": 5,
-                        "row_break": true
-                    }
+                "speech_balloon.settings": {
+                    "column": "settings",
+                    "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
+                    "options": {}
                 },
-                {
+                "balloon.id": {
+                    "model": "balloon",
                     "part": "balloon",
                     "column": "id",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 },
-                {
+                "balloon.speech_balloon_id": {
+                    "model": "balloon",
                     "part": "balloon",
                     "column": "speech_balloon_id",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 },
-                {
+                "balloon.system_picture_id": {
+                    "model": "balloon",
                     "part": "balloon",
                     "column": "system_picture_id",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 },
-                {
+                "balloon.r": {
+                    "model": "balloon",
                     "part": "balloon",
-                    "column": "settings",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "part": "speech",
-                    "column": "writing_format_id",
-                    "type": "select",
-                    "options": {
-                        "source": "model",
-                        "model": "writing_format",
-                        "method": "enable_list",
-                        "caption": "caption"
-                    }
-                },
-                {
-                    "part": "speech",
-                    "column": "font_size",
-                    "type": "select",
+                    "column": "r",
+                    "type": "number",
+                    "label": {},
                     "options": {
-                        "source": "magic_number",
-                        "key": "speech_font_size_items",
+                        "size": 5,
                         "row_break": true
-                    }
-                },
-                {
-                    "part": "speech",
-                    "column": "text_align",
-                    "type": "select",
-                    "options": {
-                        "source": "magic_number",
-                        "key": "speech_text_align_items"
-                    }
-                },
-                {
-                    "part": "speech",
-                    "column": "quotes",
-                    "type": "text",
-                    "options": {
-                        "size": 5
-                    }
-                },
-                {
-                    "part": "speech",
-                    "column": "content",
-                    "type": "text_area",
-                    "options": {
-                        "label_break": true,
-                        "size": "45x5"
-                    }
-                },
-                {
-                    "part": "speech",
-                    "column": "fore_color",
-                    "type": "hidden",
-                    "options": {
-                        "label_break": true
                     },
                     "helpers": {
-                        "color": {
-                            "path": "panels/color_helper",
-                            "options": {},
-                            "wrapper": "speech-fore_color-wrap"
+                        "tail_angle": {
+                            "path": "panels/tail_angle_helper",
+                            "options": {}
                         }
                     }
                 },
-                {
-                    "part": "speech",
-                    "column": "id",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "part": "speech",
-                    "column": "speech_balloon_id",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "part": "speech",
-                    "column": "x",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "part": "speech",
-                    "column": "y",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "part": "speech",
-                    "column": "width",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "part": "speech",
-                    "column": "height",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "part": "speech",
-                    "column": "settings",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "column": "id",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "column": "panel_id",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "column": "speech_balloon_template_id",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "column": "classname",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "column": "z",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "column": "t",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "column": "settings",
-                    "type": "hidden",
-                    "options": {}
-                }
-            ]
-        },
-        "PlainSpeechBalloon": "plain_speech_balloon",
-        "plain_speech_balloon": {
-            "base": "speech_balloon",
-            "fields": [
-                {
-                    "column": "caption",
-                    "type": "text",
-                    "options": {
-                        "row_break": true
-                    }
-                },
-                {
-                    "part": "balloon",
-                    "column": "r",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
+                "balloon.x": {
+                    "model": "balloon",
                     "part": "balloon",
                     "column": "x",
                     "type": "number",
+                    "label": {},
                     "options": {
                         "size": 5
                     }
                 },
-                {
+                "balloon.y": {
+                    "model": "balloon",
                     "part": "balloon",
                     "column": "y",
                     "type": "number",
+                    "label": {},
                     "options": {
                         "size": 5,
                         "row_break": true
                     }
                 },
-                {
+                "balloon.width": {
+                    "model": "balloon",
                     "part": "balloon",
                     "column": "width",
                     "type": "number",
+                    "label": {},
                     "options": {
                         "size": 5
                     }
                 },
-                {
+                "balloon.height": {
+                    "model": "balloon",
                     "part": "balloon",
                     "column": "height",
                     "type": "number",
+                    "label": {},
                     "options": {
                         "size": 5,
                         "row_break": true
                     }
                 },
-                {
-                    "part": "balloon",
-                    "column": "id",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "part": "balloon",
-                    "column": "speech_balloon_id",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "part": "balloon",
-                    "column": "system_picture_id",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
+                "balloon.settings": {
+                    "model": "balloon",
                     "part": "balloon",
                     "column": "settings",
                     "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "part": "speech",
-                    "column": "writing_format_id",
-                    "type": "select",
-                    "options": {
-                        "source": "model",
-                        "model": "writing_format",
-                        "method": "enable_list",
-                        "caption": "caption"
-                    }
-                },
-                {
-                    "part": "speech",
-                    "column": "font_size",
-                    "type": "select",
-                    "options": {
-                        "source": "magic_number",
-                        "key": "speech_font_size_items",
-                        "row_break": true
-                    }
-                },
-                {
-                    "part": "speech",
-                    "column": "text_align",
-                    "type": "select",
-                    "options": {
-                        "source": "magic_number",
-                        "key": "speech_text_align_items"
-                    }
-                },
-                {
-                    "part": "speech",
-                    "column": "quotes",
-                    "type": "text",
-                    "options": {
-                        "size": 5
-                    }
-                },
-                {
-                    "part": "speech",
-                    "column": "content",
-                    "type": "text_area",
-                    "options": {
-                        "label_break": true,
-                        "size": "45x5"
-                    }
-                },
-                {
-                    "part": "speech",
-                    "column": "fore_color",
-                    "type": "hidden",
-                    "options": {
-                        "label_break": true
+                    "label": {
+                        "type": "hidden"
                     },
-                    "helpers": {
-                        "color": {
-                            "path": "panels/color_helper",
-                            "options": {},
-                            "wrapper": "speech-fore_color-wrap"
-                        }
-                    }
+                    "options": {}
                 },
-                {
+                "speech.id": {
+                    "model": "speech",
                     "part": "speech",
                     "column": "id",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 },
-                {
+                "speech.speech_balloon_id": {
+                    "model": "speech",
                     "part": "speech",
                     "column": "speech_balloon_id",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 },
-                {
+                "speech.x": {
+                    "model": "speech",
                     "part": "speech",
                     "column": "x",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 },
-                {
+                "speech.y": {
+                    "model": "speech",
                     "part": "speech",
                     "column": "y",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 },
-                {
+                "speech.width": {
+                    "model": "speech",
                     "part": "speech",
                     "column": "width",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 },
-                {
-                    "part": "speech",
-                    "column": "height",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
+                "speech.height": {
+                    "model": "speech",
                     "part": "speech",
-                    "column": "settings",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "column": "id",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "column": "panel_id",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "column": "speech_balloon_template_id",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "column": "classname",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "column": "z",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "column": "t",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "column": "settings",
-                    "type": "hidden",
-                    "options": {}
-                }
-            ]
-        },
-        "SquareSpeechBalloon": "square_speech_balloon",
-        "square_speech_balloon": {
-            "base": "speech_balloon",
-            "fields": [
-                {
-                    "column": "caption",
-                    "type": "text",
-                    "options": {
-                        "row_break": true
-                    }
-                },
-                {
-                    "part": "balloon",
-                    "column": "r",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "part": "balloon",
-                    "column": "x",
-                    "type": "number",
-                    "options": {
-                        "size": 5
-                    }
-                },
-                {
-                    "part": "balloon",
-                    "column": "y",
-                    "type": "number",
-                    "options": {
-                        "size": 5,
-                        "row_break": true
-                    }
-                },
-                {
-                    "part": "balloon",
-                    "column": "width",
-                    "type": "number",
-                    "options": {
-                        "size": 5
-                    }
-                },
-                {
-                    "part": "balloon",
                     "column": "height",
-                    "type": "number",
-                    "options": {
-                        "size": 5,
-                        "row_break": true
-                    }
-                },
-                {
-                    "part": "balloon",
-                    "column": "id",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "part": "balloon",
-                    "column": "speech_balloon_id",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "part": "balloon",
-                    "column": "system_picture_id",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "part": "balloon",
-                    "column": "settings",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 },
-                {
+                "speech.writing_format_id": {
+                    "model": "speech",
                     "part": "speech",
                     "column": "writing_format_id",
                     "type": "select",
+                    "label": {},
                     "options": {
                         "source": "model",
                         "model": "writing_format",
@@ -998,49 +1110,60 @@ module ApplicationHelper
                         "caption": "caption"
                     }
                 },
-                {
+                "speech.font_size": {
+                    "model": "speech",
                     "part": "speech",
                     "column": "font_size",
                     "type": "select",
+                    "label": {},
                     "options": {
                         "source": "magic_number",
                         "key": "speech_font_size_items",
                         "row_break": true
                     }
                 },
-                {
+                "speech.text_align": {
+                    "model": "speech",
                     "part": "speech",
                     "column": "text_align",
                     "type": "select",
+                    "label": {},
                     "options": {
                         "source": "magic_number",
                         "key": "speech_text_align_items"
                     }
                 },
-                {
+                "speech.quotes": {
+                    "model": "speech",
                     "part": "speech",
                     "column": "quotes",
                     "type": "text",
+                    "label": {},
                     "options": {
                         "size": 5
                     }
                 },
-                {
+                "speech.content": {
+                    "model": "speech",
                     "part": "speech",
                     "column": "content",
                     "type": "text_area",
+                    "label": {
+                        "row_break": true
+                    },
                     "options": {
-                        "label_break": true,
                         "size": "45x5"
                     }
                 },
-                {
+                "speech.fore_color": {
+                    "model": "speech",
                     "part": "speech",
                     "column": "fore_color",
                     "type": "hidden",
-                    "options": {
-                        "label_break": true
+                    "label": {
+                        "row_break": true
                     },
+                    "options": {},
                     "helpers": {
                         "color": {
                             "path": "panels/color_helper",
@@ -1049,161 +1172,276 @@ module ApplicationHelper
                         }
                     }
                 },
-                {
-                    "part": "speech",
-                    "column": "id",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "part": "speech",
-                    "column": "speech_balloon_id",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
+                "speech.settings": {
+                    "model": "speech",
                     "part": "speech",
-                    "column": "x",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "part": "speech",
-                    "column": "y",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "part": "speech",
-                    "column": "width",
+                    "column": "settings",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
-                },
-                {
-                    "part": "speech",
-                    "column": "height",
+                }
+            }
+        },
+        "CircleSpeechBalloon": "circle_speech_balloon",
+        "circle_speech_balloon": {
+            "base": "speech_balloon",
+            "attributes": {},
+            "fields": [
+                "speech_balloon.caption",
+                "balloon.r",
+                "balloon.x",
+                "balloon.y",
+                "balloon.width",
+                "balloon.height",
+                "balloon.id",
+                "balloon.speech_balloon_id",
+                "balloon.system_picture_id",
+                "balloon.settings",
+                "speech.writing_format_id",
+                "speech.font_size",
+                "speech.text_align",
+                "speech.quotes",
+                "speech.content",
+                "speech.fore_color",
+                "speech.id",
+                "speech.speech_balloon_id",
+                "speech.x",
+                "speech.y",
+                "speech.width",
+                "speech.height",
+                "speech.settings",
+                "speech_balloon.id",
+                "speech_balloon.panel_id",
+                "speech_balloon.speech_balloon_template_id",
+                "speech_balloon.classname",
+                "speech_balloon.z",
+                "speech_balloon.t",
+                "speech_balloon.settings"
+            ]
+        },
+        "PlainSpeechBalloon": "plain_speech_balloon",
+        "plain_speech_balloon": {
+            "base": "speech_balloon",
+            "attributes": {
+                "balloon.r": {
+                    "model": "balloon",
+                    "part": "balloon",
+                    "column": "r",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
-                },
-                {
-                    "part": "speech",
-                    "column": "settings",
+                }
+            },
+            "fields": [
+                "speech_balloon.caption",
+                "balloon.r",
+                "balloon.x",
+                "balloon.y",
+                "balloon.width",
+                "balloon.height",
+                "balloon.id",
+                "balloon.speech_balloon_id",
+                "balloon.system_picture_id",
+                "balloon.settings",
+                "speech.writing_format_id",
+                "speech.font_size",
+                "speech.text_align",
+                "speech.quotes",
+                "speech.content",
+                "speech.fore_color",
+                "speech.id",
+                "speech.speech_balloon_id",
+                "speech.x",
+                "speech.y",
+                "speech.width",
+                "speech.height",
+                "speech.settings",
+                "speech_balloon.id",
+                "speech_balloon.panel_id",
+                "speech_balloon.speech_balloon_template_id",
+                "speech_balloon.classname",
+                "speech_balloon.z",
+                "speech_balloon.t",
+                "speech_balloon.settings"
+            ]
+        },
+        "SquareSpeechBalloon": "square_speech_balloon",
+        "square_speech_balloon": {
+            "base": "speech_balloon",
+            "attributes": {
+                "balloon.r": {
+                    "model": "balloon",
+                    "part": "balloon",
+                    "column": "r",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
-                },
-                {
+                }
+            },
+            "fields": [
+                "speech_balloon.caption",
+                "balloon.r",
+                "balloon.x",
+                "balloon.y",
+                "balloon.width",
+                "balloon.height",
+                "balloon.id",
+                "balloon.speech_balloon_id",
+                "balloon.system_picture_id",
+                "balloon.settings",
+                "speech.writing_format_id",
+                "speech.font_size",
+                "speech.text_align",
+                "speech.quotes",
+                "speech.content",
+                "speech.fore_color",
+                "speech.id",
+                "speech.speech_balloon_id",
+                "speech.x",
+                "speech.y",
+                "speech.width",
+                "speech.height",
+                "speech.settings",
+                "speech_balloon.id",
+                "speech_balloon.panel_id",
+                "speech_balloon.speech_balloon_template_id",
+                "speech_balloon.classname",
+                "speech_balloon.z",
+                "speech_balloon.t",
+                "speech_balloon.settings"
+            ]
+        },
+        "GroundPicture": "ground_picture",
+        "ground_picture": {
+            "attributes": {
+                "id": {
                     "column": "id",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 },
-                {
+                "panel_id": {
                     "column": "panel_id",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 },
-                {
-                    "column": "speech_balloon_template_id",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "column": "classname",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "column": "z",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "column": "t",
+                "picture_id": {
+                    "column": "picture_id",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 },
-                {
-                    "column": "settings",
-                    "type": "hidden",
-                    "options": {}
-                }
-            ]
-        },
-        "GroundPicture": "ground_picture",
-        "ground_picture": {
-            "fields": [
-                {
+                "caption": {
                     "column": "caption",
                     "type": "text",
+                    "label": {},
                     "options": {
                         "row_break": true
                     }
                 },
-                {
+                "repeat": {
                     "column": "repeat",
                     "type": "select",
+                    "label": {},
                     "options": {
                         "source": "magic_number",
                         "key": "ground_picture_repeat_items",
                         "row_break": true
                     }
                 },
-                {
+                "x": {
                     "column": "x",
                     "type": "number",
+                    "label": {},
                     "options": {
                         "size": 5
                     }
                 },
-                {
+                "y": {
                     "column": "y",
                     "type": "number",
+                    "label": {},
                     "options": {
                         "size": 5,
                         "row_break": true
                     }
                 },
-                {
+                "z": {
                     "column": "z",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 },
-                {
+                "t": {
                     "column": "t",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
-                },
-                {
+                }
+            },
+            "fields": [
+                "caption",
+                "repeat",
+                "x",
+                "y",
+                "z",
+                "t",
+                "id",
+                "panel_id",
+                "picture_id"
+            ]
+        },
+        "GroundColor": "ground_color",
+        "ground_color": {
+            "attributes": {
+                "id": {
                     "column": "id",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 },
-                {
+                "panel_id": {
                     "column": "panel_id",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 },
-                {
-                    "column": "picture_id",
-                    "type": "hidden",
-                    "options": {}
-                }
-            ]
-        },
-        "GroundColor": "ground_color",
-        "ground_color": {
-            "fields": [
-                {
+                "caption": {
                     "column": "caption",
                     "type": "text",
+                    "label": {},
                     "options": {
                         "row_break": true
                     }
                 },
-                {
+                "code": {
                     "column": "code",
                     "type": "hidden",
+                    "label": {
+                        "row_break": true
+                    },
                     "options": {
-                        "label_break": true,
                         "row_break": true
                     },
                     "helpers": {
@@ -1214,26 +1452,30 @@ module ApplicationHelper
                         }
                     }
                 },
-                {
+                "z": {
                     "column": "z",
                     "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 },
-                {
+                "t": {
                     "column": "t",
                     "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "column": "id",
-                    "type": "hidden",
-                    "options": {}
-                },
-                {
-                    "column": "panel_id",
-                    "type": "hidden",
+                    "label": {
+                        "type": "hidden"
+                    },
                     "options": {}
                 }
+            },
+            "fields": [
+                "id",
+                "panel_id",
+                "caption",
+                "code",
+                "z",
+                "t"
             ]
         }
     },
index f0ccdd6..3bfcbf3 100644 (file)
@@ -15,9 +15,6 @@ class Panel < ActiveRecord::Base
   validates :width, :presence => true, :numericality => true, :natural_number => true
   validates :height, :presence => true, :numericality => true, :natural_number => true
   validates :border, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
-  validates :x, :numericality => {:allow_blank => true}
-  validates :y, :numericality => {:allow_blank => true}
-  validates :z, :numericality => {:allow_blank => true, :greater_than => 0}
   validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :publish, :presence => true, :numericality => true
   
@@ -85,8 +82,8 @@ class Panel < ActiveRecord::Base
     self.publish > 0
   end
   
-  def tag_id
-    'panel' + self.tag_panel_id
+  def tag_id c = nil
+    'panel' + self.tag_panel_id + c.to_s
   end
   
   def tag_panel_id
@@ -103,11 +100,11 @@ class Panel < ActiveRecord::Base
     }.merge(opt)
   end
   
-  def select_tag_attributes(selected, column)
+  def select_tag_attributes(selected, column, opt = {})
     [
       :last, :first, 
       {:html => {:selected => selected}}, 
-      self.field_tag_attributes(column)
+      self.field_tag_attributes(column, opt)
     ]
   end
   
index 06e1881..7877283 100644 (file)
@@ -47,6 +47,10 @@ class SpeechBalloon < ActiveRecord::Base
     false
   end
   
+  def extend_column
+    'classname'
+  end
+  
   def supply_default
     if self.panel
       self.t = self.panel.new_t 
index 392ac95..d8653b1 100644 (file)
@@ -1,5 +1,4 @@
 <h1><%= t '.title' -%></h1>
-
 <h2><%= link_to h(@author.name), main_app.author_path(@author) -%></h2>
 <h3><%= t('.updated_comic') -%></h3>
 <table>
index 2ca3be2..24d4966 100644 (file)
@@ -1,69 +1,59 @@
-<%= form_for(elm) do |f| %>
-  <% element_name = elm.class.to_s.underscore %>
-  <% model = @configurations['models'][element_name] %>
-  <% view = if model['extend'] %>
-    <% elm.attributes[model['extend']] %>
-    <% @configurations['forms'][elm.attributes[model['extend']]] %>
-  <% else %>
-    <% @configurations['forms'][element_name] %>
-  <% end %>
-  <% form = if view.is_a? String %>
-    <% @configurations['forms'][view] %>
-  <% else %>
-    <% view %>
-  <% end %>
-  <% form['fields'].each do |field_conf| %>
-    <% e = if field_conf['part'] %>
-      <% @configurations['models'][field_conf['part']] %>
-    <% else %>
-      <% model %>
-    <% end %>
-    <% column = field_conf['column'] %>
-    <% primary_key = e['attributes'][column]['primary_key'] %>
+<% element_name = elm.element_name %>
+<% extend_element_name = elm.extend_element_name %>
+<% form_configurations = elm.find_configurations @configurations['forms'], extend_element_name %>
+<% base_attributes = if form_configurations['base'] %>
+  <% @configurations['forms'][form_configurations['base']]['attributes'] %>
+<% else %>
+  <% {} %>
+<% end %>
+<% extend_attributes = form_configurations['attributes'] || {} %>
+<% form_attributes = base_attributes.merge(extend_attributes) %>
+<% form_model_name = form_configurations['model'] || form_configurations['base'] || element_name %>
+<%= form_for(elm, :html => elm.tag_attributes('form', 'data-form-name' => extend_element_name)) do |f| %>
+  <% form_configurations['fields'].each do |field_name| %>
+    <% field_configurations = form_attributes[field_name] || {} %>
+    <% field_model_name = field_configurations['model'] || form_model_name %>
+    <% model_configurations =  @configurations['models'][field_model_name] %>
+    <% column = field_configurations['column'] %>
+    <% model_configurations['attributes'] %>
+    <% primary_key = model_configurations['attributes'][column]['primary_key'] %>
     
     <% next if primary_key and elm.new_record? %>
     
-    <% options = field_conf['options'] || {} %>
+    <% options = field_configurations['options'] || {} %>
     <% opt = {} %>
-    <% form_model_name = if form['base'] %>
-      <% form['base'] %>
-    <% else %>
-      <% element_name %>
-    <% end %>
-    <% field_model_name = if field_conf['part'] %>
-      <% field_conf['part'] %>
-    <% else %>
-      <% form_model_name %>
-    <% end %>
-    <% field_elm = if field_conf['part'] %>
-      <% elm.__send__ field_conf['part'] %>
+    <% opt.merge!('data-model' => field_model_name) %>
+    <% field_element = if field_configurations['part'] %>
+      <% elm.__send__ field_configurations['part'] %>
     <% else %>
       <% elm %>
     <% end %>
-    <% name = if field_conf['part'] %>
+    <% name = if field_configurations['part'] %>
       <% form_model_name + '[' + field_model_name + '_attributes][' + column + ']' %>
     <% else %>
       <% form_model_name + '[' + column + ']' %>
     <% end %>
     <div class="field">
-      <% unless field_conf['type'] == 'hidden' %>
+      <% label = field_configurations['label'] || {}  %>
+      <% if label['type'] and label['type'] == 'hidden' %>
+      <% else %>
         <%= t 'activerecord.attributes.' + field_model_name + '.' +  column %>
       <% end %>
-      <% if options['label_break'] %>
+      <% if label['row_break'] %>
         <br>
       <% end %>
-      <% case field_conf['type'] %>
+      <% case field_configurations['type'] %>
       <% when 'text' %>
-        <% opt['size'] = field_conf['options']['size'] if field_conf['options']['size'] %>
-        <%= text_field_tag name, field_elm.attributes[column], field_elm.field_tag_attributes(column, no_attr, opt) %>
+        <% opt['size'] = field_configurations['options']['size'] if field_configurations['options']['size'] %>
+        <%= text_field_tag name, field_element.attributes[column], field_element.field_tag_attributes(column, no_attr, opt) %>
       <% when 'text_area' %>
-        <% opt['size'] = field_conf['options']['size'] if field_conf['options']['size'] %>
-        <%= text_area_tag name, field_elm.attributes[column], field_elm.field_tag_attributes(column, no_attr, opt) %>
+        <% opt['size'] = field_configurations['options']['size'] if field_configurations['options']['size'] %>
+        <%= text_area_tag name, field_element.attributes[column], field_element.field_tag_attributes(column, no_attr, opt) %>
       <% when 'number' %>
-        <% opt['size'] = field_conf['options']['size'] if field_conf['options']['size'] %>
-        <%= number_field_tag name, field_elm.attributes[column], field_elm.field_tag_attributes(column, no_attr, opt) %>
+        <% opt['size'] = field_configurations['options']['size'] if field_configurations['options']['size'] %>
+        <%= number_field_tag name, field_element.attributes[column], field_element.field_tag_attributes(column, no_attr, opt) %>
       <% when 'hidden' %>
-        <%= hidden_field_tag name, field_elm.attributes[column], field_elm.field_tag_attributes(column, no_attr, opt) %>
+        <%= hidden_field_tag name, field_element.attributes[column], field_element.field_tag_attributes(column, no_attr, opt) %>
       <% when 'select' %>
         <% items = case options['source'] %>
         <% when 'model' %>
           <% t_select_items(MagicNumber[options['key']]) %>
         <% else %>
         <% end %>
-        <%= select_tag name, options_for_select(items, field_elm.attributes[column]), field_elm.field_tag_attributes(column, no_attr) %>
+        <%= select_tag name, options_for_select(items, field_element.attributes[column]), field_element.field_tag_attributes(column, no_attr, opt) %>
       <% end %>
-      <% if field_conf['helpers'] %>
-        <% field_conf['helpers'].each do |n, helper| %>
+      <% if field_configurations['helpers'] %>
+        <% field_configurations['helpers'].each do |n, helper| %>
           <% if helper['wrapper'] %>
             <div class="<%= helper['wrapper'] -%>">
           <% end %>
-          <%= render helper['path'], :elm => field_elm, :no_attr => no_attr, :opt => helper['options'] %>
+          <%= render helper['path'], :elm => field_element, :no_attr => no_attr, :opt => helper['options'] %>
           <% if helper['wrapper'] %>
             </div>
           <% end %>
index c56c1ab..10de5b0 100644 (file)
@@ -1,4 +1,4 @@
-<li <%= raw elm.tag_attr(:element_tab) -%>>
+<li class="element_tab" <%= raw elm.tag_attr(:element_tab) -%>>
   <a href="#elements-tabs-<%= elm.t -%>">
     <div class="elements-tab">
       <%= render elm.element_face_template, :elm => elm %>
index 363a045..67217dc 100644 (file)
@@ -1,44 +1,44 @@
 <% @configurations = configurations %>
 <div id="tabs" class="panel-editor" panel_id="<%= @panel.tag_panel_id -%>" current="1">
   <ul>
-    <li><a href="#tabs-1">panel</a></li>
-    <li><a href="#tabs-2">elements</a></li>
-    <li><a href="#tabs-3">t order</a></li>
-    <li><a href="#tabs-4">z order</a></li>
-    <li><a href="#tabs-5">new</a></li>
+    <li id="tabs-1-tab"><a href="#tabs-1">panel</a></li>
+    <li id="tabs-2-tab"><a href="#tabs-2">elements</a></li>
+    <li id="tabs-3-tab"><a href="#tabs-3">t order</a></li>
+    <li id="tabs-4-tab"><a href="#tabs-4">z order</a></li>
+    <li id="tabs-5-tab"><a href="#tabs-5">new</a></li>
   </ul>
   <div id="tabs-1">
-    <%= form_for(@panel) do |f| %>
+    <%= form_for(@panel, :html => {:id => @panel.tag_id('form'), 'data-form-name' => 'panel'}) do |f| %>
       <%= render 'system/error_explanation', :obj => @panel %>
 
       <div class="field">
         <%= f.label :caption %>
-        <%= f.text_field :caption, @panel.field_tag_attributes(:caption) -%>
+        <%= f.text_field :caption, @panel.field_tag_attributes(:caption, 'data-model' => 'panel') -%>
       </div>
       <div class="row_break">
       </div>
       <div class="field">
         <%= f.label :width %>
-        <%= f.number_field :width, @panel.field_tag_attributes(:width, :size => 5) %>
+        <%= f.number_field :width, @panel.field_tag_attributes(:width, :size => 5, 'data-model' => 'panel') %>
       </div>
       <div class="field">
         <%= f.label :height %>
-        <%= f.number_field :height, @panel.field_tag_attributes(:height, :size => 5) %>
+        <%= f.number_field :height, @panel.field_tag_attributes(:height, :size => 5, 'data-model' => 'panel') %>
       </div>
       <div class="row_break">
       </div>
       <div class="field">
         <%= f.label :border %>
-        <%= f.number_field :border, @panel.field_tag_attributes(:border, :size => 5) %>
+        <%= f.number_field :border, @panel.field_tag_attributes(:border, :size => 5, 'data-model' => 'panel') %>
       </div>
       <div class="field">
         <%= f.label :publish %>
-        <%= f.collection_select :publish, t_select_items(MagicNumber['panel_visible_items']), *@panel.select_tag_attributes(@panel.publish, :publish) %>
+        <%= f.collection_select :publish, t_select_items(MagicNumber['panel_visible_items']), *@panel.select_tag_attributes(@panel.publish, :publish, 'data-model' => 'panel') %>
       </div>
       <div class="row_break">
       </div>
       <% unless @panel.new_record?  %>
-        <%= f.hidden_field :id, @panel.field_tag_attributes(:id) %>
+        <%= f.hidden_field :id, @panel.field_tag_attributes(:id, 'data-model' => 'panel') %>
       <% end %>
       <div class="actions">
         <%= f.submit 'panels.submit', :class => "submit" %>
     </div>
   <% end %>
 </div>
-  <%= text_field_tag "json", '', :id => 'pettanr-configurations' %>
+  <%# text_field_tag "json", '', :id => 'pettanr-configurations' %>
index dc9b2c6..a92f430 100644 (file)
@@ -48,6 +48,26 @@ module Element
       self.class.colum_structures[column_name] and self.class.colum_structures[column_name][:helper]
     end
     
+    def element_name
+      self.class.to_s.underscore
+    end
+    
+    def extend_column
+      nil
+    end
+    
+    def extend_element_name
+      self.extend_column ? self.attributes[extend_column] : self.element_name
+    end
+    
+    def find_configurations hash, key
+       if hash[key].is_a? String
+         self.find_configurations hash, hash[key]
+       else
+         return hash[key]
+       end
+    end
+    
     def new_index
       @new_index
     end