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
return false unless reader_role_check(roles)
end
return true if self.own?(roles)
+ return true if self.new_record?
self.publish?
end
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
self.tag_id + f.to_s
end
+ def tag_attributes column = nil, opt = {}
+ {
+ :id => self.field_tag_id(column), :panel_id => self.tag_panel_id
+ }.merge(opt)
+ end
+
+ def select_tag_attributes(selected, column, opt = {})
+ [
+ :last, :first,
+ {:html => {:selected => selected}},
+ self.field_tag_attributes(column, opt)
+ ]
+ end
+
+ def field_tag_attributes column, opt = {}
+ self.tag_attributes(column).merge(
+ {:column => column}
+ ).merge(opt)
+ end
+
+ def tag_attr column = nil, opt = {}
+ self.tag_attributes(column, opt).to_attr
+ end
+
+ def field_tag_attr column, no_attr, opt = {}
+ self.field_tag_attributes(column, no_attr, opt).to_attr
+ end
+
def self.default_page_size
25
end
<%= render 'system/error_explanation', :obj => elm %>
<div class="field">
+ <%= f.label :sheet_id %>
+ <% if elm.new_record? %>
+ <%= f.number_field :sheet_id %>
+ <% else %>
+ <%= f.number_field :sheet_id, elm.field_tag_attributes(:sheet_id, no_attr) %>
+ <% end %>
+
+ <%= f.label :panel_id %>
+ <% if elm.new_record? %>
+ <%= f.number_field :panel_id %>
+ <% else %>
+ <%= f.number_field :panel_id, elm.field_tag_attributes(:panel_id, no_attr) %>
+ <% end %>
+ </div>
+ <div class="field">
<%= f.label :x %>
- <%= f.number_field :x, elm.field_tag_attributes(:x, no_attr, :size => 5) %>
+ <% if elm.new_record? %>
+ <%= f.number_field :x %>
+ <% else %>
+ <%= f.number_field :x, elm.field_tag_attributes(:x, no_attr, :size => 5) %>
+ <% end %>
<%= f.label :y %>
- <%= f.number_field :y, elm.field_tag_attributes(:y, no_attr, :size => 5) %>
+ <% if elm.new_record? %>
+ <%= f.number_field :y %>
+ <% else %>
+ <%= f.number_field :y, elm.field_tag_attributes(:y, no_attr, :size => 5) %>
+ <% end %>
</div>
+ <div class="row_break">
+ </div>
<div class="field">
<%= f.label :z %>
- <%= f.number_field :z, elm.field_tag_attributes(:z, no_attr, :size => 5) %>
+ <% if elm.new_record? %>
+ <%= f.number_field :z %>
+ <% else %>
+ <%= f.number_field :z, elm.field_tag_attributes(:z, no_attr, :size => 5) %>
+ <% end %>
<%= f.label :t %>
- <%= f.number_field :t, elm.field_tag_attributes(:t, no_attr, :size => 5) %>
+ <% if elm.new_record? %>
+ <%= f.number_field :t %>
+ <% else %>
+ <%= f.number_field :t, elm.field_tag_attributes(:t, no_attr, :size => 5) %>
+ <% end %>
</div>
+ <div class="row_break">
+ </div>
- <%= f.hidden_field :panel_id, elm.field_tag_attributes(:panel_id, no_attr) %>
- <%= f.hidden_field :sheet_id, elm.field_tag_attributes(:sheet_id, no_attr) %>
<% unless elm.new_record? %>
<%= f.hidden_field :id, elm.field_tag_attributes(:id, no_attr) %>
<% end %>
<%= f.label :caption %>
<%= f.text_field :caption, :id => @sheet.field_tag_id(:caption), :sheet_id => @sheet.tag_sheet_id, :column => :caption -%>
</div>
+ <div class="row_break">
+ </div>
<div class="field">
<%= f.label :width %>
<%= f.number_field :width, :size => 5, :id => @sheet.field_tag_id(:width), :sheet_id => @sheet.tag_sheet_id, :column => :width %>
<%= f.number_field :height, :size => 5, :id => @sheet.field_tag_id(:height), :sheet_id => @sheet.tag_sheet_id, :column => :height %>
</div>
+ <div class="row_break">
+ </div>
<div class="field">
<%= f.label :visible %>
<%= f.collection_select :visible, t_select_items(MagicNumber['sheet_visible_items']), :last, :first, {:html => {:selected => @sheet.visible}}, {:id => @sheet.field_tag_id(:visible), :sheet_id => @sheet.tag_sheet_id, :column => :visible} %>
</div>
+ <div class="row_break">
+ </div>
<% unless @sheet.new_record? %>
<%= f.hidden_field :id, :id => @sheet.field_tag_id(:id), :sheet_id => @sheet.tag_sheet_id, :column => :id %>
<% end %>
</div>
</div>
<%= form_for(@sheet, :html => {:jqform => 'pettanr-sheet-form'}) do |f| %>
- <%= render 'system/error_explanation', :obj => @sheet %>
-
<%= text_field_tag "json", '', :id => 'pettanr-sheet-json' %>
<div>
<%= submit_tag t('sheets.create_from_json'), :id => 'pettanr-sheet-submit' -%>