permitir cambiar la base de los formularios

This commit is contained in:
f 2020-11-27 19:32:16 -03:00
parent e28a14e8b0
commit ac82d609d4
29 changed files with 79 additions and 79 deletions

View file

@ -45,7 +45,7 @@
- cache metadata do
= render("posts/attributes/#{type}",
post: post, attribute: attribute,
base: 'post', post: post, attribute: attribute,
metadata: metadata, site: site,
dir: dir, locale: @locale,
autofocus: (post.attributes.first == attribute))

View file

@ -1,13 +1,13 @@
.form-group
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
.taggable{ dir: dir, lang: locale, data: { values: metadata.value.to_json,
name: "post[#{attribute}][]", list: id_for_datalist(attribute),
name: "#{base}[#{attribute}][]", list: id_for_datalist(attribute),
remove: 'false', legend: post_label_t(attribute, post: post),
button: t('posts.attributes.add'),
described: id_for_help(attribute) } }
= text_field(*field_name_for('post', attribute, '[]'),
= text_field(*field_name_for(base, attribute, '[]'),
value: metadata.value.join(', '),
**field_options(attribute, metadata))

View file

@ -1,6 +1,6 @@
.form-group
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
= text_field 'post', attribute, value: metadata.value,
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
= text_field base, attribute, value: metadata.value,
dir: dir, lang: locale, list: id_for_datalist(attribute),
pattern: metadata.values.values.join('|'), autocomplete: 'off',
**field_options(attribute, metadata)

View file

@ -1,11 +1,11 @@
.form-check
= hidden_field_tag "post[#{attribute}]", '0', id: ''
= hidden_field_tag "#{base}[#{attribute}]", '0', id: ''
.custom-control.custom-switch
= check_box_tag "post[#{attribute}]", '1', metadata.value,
= check_box_tag "#{base}[#{attribute}]", '1', metadata.value,
class: "custom-control-input #{invalid(post, attribute)}",
aria: { describedby: id_for_help(attribute) },
autofocus: autofocus
= label_tag "post_#{attribute}", post_label_t(attribute, post: post),
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post),
class: 'custom-control-label'
= render 'posts/attribute_feedback',

View file

@ -1,6 +1,6 @@
.form-group
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
= color_field 'post', attribute, value: metadata.value,
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
= color_field base, attribute, value: metadata.value,
**field_options(attribute, metadata)
= render 'posts/attribute_feedback',
post: post, attribute: attribute, metadata: metadata

View file

@ -1,5 +1,5 @@
.form-group
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
= render 'posts/attribute_feedback',
post: post, attribute: attribute, metadata: metadata
@ -9,7 +9,7 @@
.alert.alert-info
:markdown
#{t('editor.alert')}
= text_area_tag "post[#{attribute}]", '',
= text_area_tag "#{base}[#{attribute}]", '',
dir: dir, lang: locale,
**field_options(attribute, metadata), class: 'd-none'

View file

@ -1,6 +1,6 @@
.form-group
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
= date_field 'post', attribute, value: metadata.value.to_date.strftime('%F'),
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
= date_field base, attribute, value: metadata.value.to_date.strftime('%F'),
**field_options(attribute, metadata)
= render 'posts/attribute_feedback',
post: post, attribute: attribute, metadata: metadata

View file

@ -1,6 +1,6 @@
.form-group
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
= date_field 'post', attribute, value: metadata.value.strftime('%F'),
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
= date_field base, attribute, value: metadata.value.strftime('%F'),
**field_options(attribute, metadata)
= render 'posts/attribute_feedback',
post: post, attribute: attribute, metadata: metadata

View file

@ -1,6 +1,6 @@
.form-group
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
= email_field 'post', attribute, value: metadata.value,
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
= email_field base, attribute, value: metadata.value,
**field_options(attribute, metadata)
= render 'posts/attribute_feedback',
post: post, attribute: attribute, metadata: metadata

View file

@ -1,10 +1,10 @@
.form-group
= label_tag "post_#{attribute}" do
= label_tag "#{base}_#{attribute}" do
%abbr{ title: t('lockbox.help.description') }
🔒
%span.sr-only= t('lockbox.help.title')
= post_label_t(attribute, post: post)
= text_area_tag "post[#{attribute}]", metadata.value,
= text_area_tag "#{base}[#{attribute}]", metadata.value,
dir: dir, lang: locale,
**field_options(attribute, metadata)
= render 'posts/attribute_feedback',

View file

@ -11,22 +11,22 @@
.row{ class: dt }
.col
.date.form-group
= label_tag "post_#{attribute}_#{dt}_date",
= label_tag "#{base}_#{attribute}_#{dt}_date",
post_label_t(attribute, :date, post: post)
= date_field_tag(*field_name_for('post', attribute, dt, :date),
= date_field_tag(*field_name_for(base, attribute, dt, :date),
value: metadata.value.dig(dt.to_s, 'date'),
**field_options(attribute, metadata, required: true))
.col
.time.form-group
= label_tag "post_#{attribute}_#{dt}_time",
= label_tag "#{base}_#{attribute}_#{dt}_time",
post_label_t(attribute, :time, post: post)
= time_field_tag(*field_name_for('post', attribute, dt, :time),
= time_field_tag(*field_name_for(base, attribute, dt, :time),
value: metadata.value.dig(dt.to_s, 'time'),
**field_options(attribute, metadata))
.col
.zone.form-group
= label_tag "post_#{attribute}_#{dt}_zone",
= label_tag "#{base}_#{attribute}_#{dt}_zone",
post_label_t(attribute, :zone, post: post)
= select_tag(plain_field_name_for('post', attribute, dt, :zone),
= select_tag(plain_field_name_for(base, attribute, dt, :zone),
options_for_select(MetadataEvent::TIMEZONES, metadata.value.dig(dt.to_s, 'zone') || '00:00'),
**field_options(attribute, metadata))

View file

@ -1,6 +1,6 @@
.form-group
- if metadata.uploaded?
= hidden_field_tag "post[#{attribute}][path]", metadata.value['path']
= hidden_field_tag "#{base}[#{attribute}][path]", metadata.value['path']
- case metadata.static_file.blob.content_type
- when %r{\Avideo/}
@ -15,23 +15,23 @@
= link_to t('posts.attribute_ro.file.download'),
url_for(metadata.static_file)
.custom-control.custom-switch
= check_box_tag "post[#{attribute}][path]", '', false, id: "post_#{attribute}_destroy", class: 'custom-control-input'
= label_tag "post_#{attribute}_destroy", t('posts.attributes.file.destroy'), class: 'custom-control-label'
= check_box_tag "#{base}[#{attribute}][path]", '', false, id: "#{base}_#{attribute}_destroy", class: 'custom-control-input'
= label_tag "#{base}_#{attribute}_destroy", t('posts.attributes.file.destroy'), class: 'custom-control-label'
.custom-file
= file_field(*field_name_for('post', attribute, :path),
= file_field(*field_name_for(base, attribute, :path),
**field_options(attribute, metadata),
class: "custom-file-input #{invalid(post, attribute)}",
data: { preview: "#{attribute}-preview" })
= label_tag "post_#{attribute}_path",
= label_tag "#{base}_#{attribute}_path",
post_label_t(attribute, :path, post: post), class: 'custom-file-label'
= render 'posts/attribute_feedback',
post: post, attribute: [attribute, :path], metadata: metadata
.form-group
= label_tag "post_#{attribute}_description",
= label_tag "#{base}_#{attribute}_description",
post_label_t(attribute, :description, post: post)
= text_field(*field_name_for('post', attribute, :description),
= text_field(*field_name_for(base, attribute, :description),
value: metadata.value['description'],
dir: dir, lang: locale,
**field_options(attribute, metadata))

View file

@ -1,9 +1,9 @@
.row{ data: { controller: 'geo' } }
.col
.form-group
= label_tag "post_#{attribute}_lat",
= label_tag "#{base}_#{attribute}_lat",
post_label_t(attribute, :lat, post: post)
= text_field(*field_name_for('post', attribute, :lat),
= text_field(*field_name_for(base, attribute, :lat),
value: metadata.value['lat'],
**field_options(attribute, metadata),
data: { target: 'geo.lat' })
@ -11,9 +11,9 @@
post: post, attribute: [attribute, :lat], metadata: metadata
.col
.form-group
= label_tag "post_#{attribute}_lng",
= label_tag "#{base}_#{attribute}_lng",
post_label_t(attribute, :lng, post: post)
= text_field(*field_name_for('post', attribute, :lng),
= text_field(*field_name_for(base, attribute, :lng),
value: metadata.value['lng'],
**field_options(attribute, metadata),
data: { target: 'geo.lng' })

View file

@ -1,15 +1,15 @@
.form-group
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
.mapable{ dir: dir, lang: locale,
data: { values: metadata.value.to_json,
'default-values': metadata.values.to_json,
name: "post[#{attribute}][]", list: id_for_datalist(attribute),
name: "#{base}[#{attribute}][]", list: id_for_datalist(attribute),
remove: 'false', legend: post_label_t(attribute, post: post),
button: t('posts.attributes.add'),
described: id_for_help(attribute) } }
= text_field(*field_name_for('post', attribute, '[]'),
= text_field(*field_name_for(base, attribute, '[]'),
value: metadata.value.join(', '),
dir: dir, lang: locale,
**field_options(attribute, metadata))

View file

@ -1,15 +1,15 @@
.form-group
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
.mapable{ dir: dir, lang: locale,
data: { values: metadata.value.to_json,
'default-values': metadata.values.to_json,
name: "post[#{attribute}][]", list: id_for_datalist(attribute),
name: "#{base}[#{attribute}][]", list: id_for_datalist(attribute),
remove: 'false', legend: post_label_t(attribute, post: post),
button: t('posts.attributes.add'),
described: id_for_help(attribute) } }
= text_field(*field_name_for('post', attribute, '[]'),
= text_field(*field_name_for(base, attribute, '[]'),
value: metadata.value.join(', '),
dir: dir, lang: locale,
**field_options(attribute, metadata))

View file

@ -6,10 +6,10 @@
id: "#{attribute}-preview"
-# Mantener el valor si no enviamos ninguna imagen
= hidden_field_tag "post[#{attribute}][path]", metadata.value['path']
= hidden_field_tag "#{base}[#{attribute}][path]", metadata.value['path']
.custom-control.custom-switch
= check_box_tag "post[#{attribute}][path]", '', false, id: "post_#{attribute}_destroy", class: 'custom-control-input'
= label_tag "post_#{attribute}_destroy", t('posts.attributes.image.destroy'), class: 'custom-control-label'
= check_box_tag "#{base}[#{attribute}][path]", '', false, id: "#{base}_#{attribute}_destroy", class: 'custom-control-input'
= label_tag "#{base}_#{attribute}_destroy", t('posts.attributes.image.destroy'), class: 'custom-control-label'
- else
= image_tag '',
alt: metadata.value['description'],
@ -17,19 +17,19 @@
id: "#{attribute}-preview"
.custom-file
= file_field(*field_name_for('post', attribute, :path),
= file_field(*field_name_for(base, attribute, :path),
**field_options(attribute, metadata),
class: "custom-file-input #{invalid(post, attribute)}",
accept: 'image/*', data: { preview: "#{attribute}-preview" })
= label_tag "post_#{attribute}_path",
= label_tag "#{base}_#{attribute}_path",
post_label_t(attribute, :path, post: post), class: 'custom-file-label'
= render 'posts/attribute_feedback',
post: post, attribute: [attribute, :path], metadata: metadata
.form-group
= label_tag "post_#{attribute}_description",
= label_tag "#{base}_#{attribute}_description",
post_label_t(attribute, :description, post: post)
= text_field(*field_name_for('post', attribute, :description),
= text_field(*field_name_for(base, attribute, :description),
value: metadata.value['description'],
dir: dir, lang: locale,
**field_options(attribute, metadata))

View file

@ -1 +1 @@
= hidden_field_tag 'post[lang]', post&.lang&.value
= hidden_field_tag "#{base}[lang]", post&.lang&.value

View file

@ -13,18 +13,18 @@
- metadata.values[locale.to_sym].values.include? x
.form-group
= label_tag "post_#{attribute}_#{locale}", locale_t
= label_tag "#{base}_#{attribute}_#{locale}", locale_t
.mapable{ dir: t("locales.#{locale}.dir"), lang: locale,
data: { values: values.to_json,
'default-values': metadata.values[locale.to_sym].to_json,
name: "post[#{attribute}][]",
name: "#{base}[#{attribute}][]",
list: id_for_datalist(attribute, locale),
button: t('posts.attributes.add'),
remove: 'false', legend: locale_t,
described: id_for_help(attribute, locale) } }
= text_field(*field_name_for('post', attribute, '[]'),
= text_field(*field_name_for(base, attribute, '[]'),
value: values.join(', '),
dir: t("locales.#{locale}.dir"), lang: locale,
**field_options(attribute, metadata))

View file

@ -1,6 +1,6 @@
.form-group.markdown-content
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
= text_area_tag "post[#{attribute}]", metadata.value,
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
= text_area_tag "#{base}[#{attribute}]", metadata.value,
dir: dir, lang: locale,
**field_options(attribute, metadata, class: 'content')
.editor.mt-1

View file

@ -1,8 +1,8 @@
.form-group.markdown-content
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
= render 'posts/attribute_feedback',
post: post, attribute: attribute, metadata: metadata
= text_area_tag "post[#{attribute}]", metadata.value,
= text_area_tag "#{base}[#{attribute}]", metadata.value,
dir: dir, lang: locale,
**field_options(attribute, metadata, class: 'content')
.markdown-editor.mt-1

View file

@ -1,6 +1,6 @@
.form-group
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
= number_field 'post', attribute, value: metadata.value,
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
= number_field base, attribute, value: metadata.value,
**field_options(attribute, metadata)
= render 'posts/attribute_feedback',
post: post, attribute: attribute, metadata: metadata

View file

@ -1,6 +1,6 @@
.form-group
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
= text_field 'post', attribute, value: metadata.value,
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
= text_field base, attribute, value: metadata.value,
dir: dir, lang: locale,
**field_options(attribute, metadata)
= render 'posts/attribute_feedback',

View file

@ -1,14 +1,14 @@
.form-group
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
.mapable{ data: { values: metadata.value.to_json,
'default-values': metadata.values.to_json,
name: "post[#{attribute}][]", list: id_for_datalist(attribute),
name: "#{base}[#{attribute}][]", list: id_for_datalist(attribute),
remove: 'false', legend: post_label_t(attribute, post: post),
button: t('posts.attributes.add'),
described: id_for_help(attribute) } }
= text_field(*field_name_for('post', attribute, '[]'),
= text_field(*field_name_for(base, attribute, '[]'),
value: metadata.value.join(', '),
dir: dir, lang: locale,
**field_options(attribute, metadata))

View file

@ -1,15 +1,15 @@
.form-group
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
.mapable{ dir: dir, lang: locale,
data: { values: metadata.value.to_json,
'default-values': metadata.values.to_json,
name: "post[#{attribute}][]", list: id_for_datalist(attribute),
name: "#{base}[#{attribute}][]", list: id_for_datalist(attribute),
remove: 'false', legend: post_label_t(attribute, post: post),
button: t('posts.attributes.add'),
described: id_for_help(attribute) } }
= text_field(*field_name_for('post', attribute, '[]'),
= text_field(*field_name_for(base, attribute, '[]'),
value: metadata.value.join(', '),
dir: dir, lang: locale,
**field_options(attribute, metadata))

View file

@ -1,6 +1,6 @@
.form-group
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
= text_field 'post', attribute, value: metadata.value,
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
= text_field base, attribute, value: metadata.value,
dir: dir, lang: locale,
**field_options(attribute, metadata)
= render 'posts/attribute_feedback',

View file

@ -1,6 +1,6 @@
.form-group
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
= text_field 'post', attribute, value: metadata.value,
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
= text_field base, attribute, value: metadata.value,
dir: dir, lang: locale,
**field_options(attribute, metadata)
= render 'posts/attribute_feedback',

View file

@ -1,6 +1,6 @@
.form-group
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
= telephone_field 'post', attribute, value: metadata.value,
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
= telephone_field base, attribute, value: metadata.value,
**field_options(attribute, metadata)
= render 'posts/attribute_feedback',
post: post, attribute: attribute, metadata: metadata

View file

@ -1,6 +1,6 @@
.form-group
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
= text_area_tag "post[#{attribute}]", metadata.value,
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
= text_area_tag "#{base}[#{attribute}]", metadata.value,
dir: dir, lang: locale,
**field_options(attribute, metadata)
= render 'posts/attribute_feedback',

View file

@ -1,6 +1,6 @@
.form-group
= label_tag "post_#{attribute}", post_label_t(attribute, post: post)
= url_field 'post', attribute, value: metadata.value,
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
= url_field base, attribute, value: metadata.value,
**field_options(attribute, metadata)
= render 'posts/attribute_feedback',
post: post, attribute: attribute, metadata: metadata