5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-25 03:36:21 +00:00
panel/app/views/i18n/_text_field.haml

37 lines
1.3 KiB
Text
Raw Normal View History

2018-02-19 19:33:28 +00:00
- dir = 'ltr'
- if @lang_to == 'ar'
- dir = 'rtl'
2018-02-09 21:28:27 +00:00
.form-group
- key = keys.pop
2018-02-19 19:33:28 +00:00
-# si la key es numerica, queremos un array de hashes, no un hash de
-# hashes con keys numericas
- form_keys = keys.map do |k|
- if k.is_a? Integer
- '[]'
- else
- "[#{k.to_s}]"
- form_keys = form_keys.join('')
2018-02-09 21:28:27 +00:00
- form_help = (keys.size > 0) ? [keys,key].flatten.join('.') : key
2018-02-19 19:33:28 +00:00
- value_to = @site.data[@lang_to]
-# recorrer el hash hasta obtener el valor original
2018-02-09 21:28:27 +00:00
- [keys,key].flatten.each do |k|
2018-02-19 19:33:28 +00:00
- if value_to.nil?
- value_to = ''
- break
2018-02-09 21:30:47 +00:00
- value_to = value_to[k]
2018-02-19 19:33:28 +00:00
-# no especificar el id en una key numerica para que no se genere un
-# hash en lugar de un array de valores
- key = '' if key.is_a? Integer
2018-02-19 20:00:21 +00:00
- value_to = value if value_to.blank?
= label_tag "i18n[#{@lang_to}]#{form_keys}[#{key}]", value,
class: (@lang_from == 'ar') ? 'rtl' : 'ltr'
2018-02-19 19:33:28 +00:00
-# creamos un campo a mano porque los helpers de niveles mas altos
-# quieren hacer magia con los ids y fallan
2018-02-09 21:28:27 +00:00
- if value.length > 140
2018-02-19 19:33:28 +00:00
= text_area_tag "i18n[#{@lang_to}]#{form_keys}[#{key}]", value_to,
class: "form-control #{dir}"
2018-02-09 21:28:27 +00:00
- else
2018-02-19 19:33:28 +00:00
= text_field_tag "i18n[#{@lang_to}]#{form_keys}[#{key}]", value_to,
class: "form-control #{dir}"
2018-02-09 21:28:27 +00:00
%small.text-muted.form-text= form_help