From 1cc24cc819597fc09c476a651138678092503974 Mon Sep 17 00:00:00 2001 From: f Date: Fri, 23 Feb 2018 16:45:47 -0300 Subject: [PATCH] seleccionar posts en otros idiomas para relacionar --- app/assets/javascripts/select2.js | 7 ++++++- app/views/posts/_form.haml | 6 ++++-- config/locales/en.yml | 8 ++++---- config/locales/es.yml | 8 ++++---- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/select2.js b/app/assets/javascripts/select2.js index 32b17292..59f68b93 100644 --- a/app/assets/javascripts/select2.js +++ b/app/assets/javascripts/select2.js @@ -1,3 +1,8 @@ $(document).on('turbolinks:load', function() { - $('.select2').select2({ tags: true, tokenSeparators: [',']}); + $('.select2').select2({ + tags: true, + tokenSeparators: [','], + allowClear: true, + placeholder: '' + }); }); diff --git a/app/views/posts/_form.haml b/app/views/posts/_form.haml index 9696bf06..2336115c 100644 --- a/app/views/posts/_form.haml +++ b/app/views/posts/_form.haml @@ -115,8 +115,10 @@ - %w[es en ar].each do |lang| .form-group = label_tag 'post_lang', t("posts.lang.#{lang}") - = text_field 'post', "lang[#{lang}]", value: @post.get_front_matter(:lang).dig(lang), - class: 'form-control' + = select_tag "post[lang][#{lang}]", + options_for_select(@site.posts_for(lang).map { |p| [p.title, p.id] }, + @post.get_front_matter(:lang).dig(lang)), + { class: 'form-control select2' } %small.text-muted.form-text= t('posts.lang_help') .form-group = submit_tag t('posts.save'), class: 'btn btn-success' diff --git a/config/locales/en.yml b/config/locales/en.yml index a40e5e9a..b2bb5ae9 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -62,10 +62,10 @@ en: materiales_requeridos: 'Needed materials' materiales_requeridos_help: 'Select all materials needed for this session' lang: - es: 'Slug for Castillian Spanish' - en: 'Slug for English' - ar: 'Slug for Arabic' - lang_help: 'Complete this field with the slug for the post in another language to associate them' + es: 'Castillian Spanish' + en: 'English' + ar: 'Arabic' + lang_help: 'The same article in another language.' rtl: 'Right to left' ltr: 'Left to right' dir: 'Text direction' diff --git a/config/locales/es.yml b/config/locales/es.yml index ca14e7cc..f41c6307 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -60,10 +60,10 @@ es: duracion: 'Duración' duracion_help: '¿Cuánto dura la sesión?' lang: - es: 'Slug en castellano' - en: 'Slug en inglés' - ar: 'Slug en árabe' - lang_help: 'El mismo artículo en otro idioma, completa con su slug para poder saltar de uno a otro' + es: 'Artículo en castellano' + en: 'Artículo en inglés' + ar: 'Artículo en árabe' + lang_help: 'El mismo artículo en otro idioma' rtl: 'Derecha a izquierda' ltr: 'Izquierda a derecha' dir: 'Dirección del texto'