mirror of
https://0xacab.org/sutty/sutty
synced 2025-01-19 16:43:39 +00:00
campos numericos
This commit is contained in:
parent
bdedaf67cc
commit
abae3b5141
3 changed files with 24 additions and 0 deletions
15
app/models/metadata_number.rb
Normal file
15
app/models/metadata_number.rb
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Un campo numérico
|
||||||
|
class MetadataNumber < MetadataTemplate
|
||||||
|
# Nada
|
||||||
|
def default_value
|
||||||
|
nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def save
|
||||||
|
self[:value] = value.to_i
|
||||||
|
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
3
app/views/posts/attribute_ro/_number.haml
Normal file
3
app/views/posts/attribute_ro/_number.haml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
%tr{ id: attribute }
|
||||||
|
%th= post_label_t(attribute, post: post)
|
||||||
|
%td= metadata.value
|
6
app/views/posts/attributes/_number.haml
Normal file
6
app/views/posts/attributes/_number.haml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
.form-group
|
||||||
|
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
|
||||||
|
= number_field 'post', attribute, value: metadata.value,
|
||||||
|
**field_options(attribute, metadata)
|
||||||
|
= render 'posts/attribute_feedback',
|
||||||
|
post: post, attribute: attribute, metadata: metadata
|
Loading…
Reference in a new issue