diff --git a/config/locales/en.yml b/config/locales/en.yml index 29dcc514..cfd0e963 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -667,4 +667,5 @@ en: "yes": "yes" You_re_the_administrator_of_this_systematic_review: "You’re the administrator of this systematic review" References_count_to_canonical: "Canonical references: cited by %{in} / reference to %{out} / %{in_sta} cited by STA" - create_new_field: "Create new personalized field" \ No newline at end of file + create_new_field: "Create new personalized field" + Select_an_option: "Select an option" \ No newline at end of file diff --git a/config/locales/es.yml b/config/locales/es.yml index a2ca512a..3f50ca7a 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -673,4 +673,5 @@ es: "yes": "sí" You_re_the_administrator_of_this_systematic_review: "Usted es el administrador de esta revisión sistemática" References_count_to_canonical: "Referencias canónicas: citado por %{in} / referencia a %{out} / %{in_sta} citado por TTR " - create_new_field: "Create new personalized field" \ No newline at end of file + create_new_field: "Create new personalized field" + Select_an_option: "Seleccione una opción" \ No newline at end of file diff --git a/controllers/reviews/fields.rb b/controllers/reviews/fields.rb index 8970a12e..695f1fec 100644 --- a/controllers/reviews/fields.rb +++ b/controllers/reviews/fields.rb @@ -16,6 +16,8 @@ raise Buhos::NoReviewIdError, rs_id if !@review @campos=@review.fields + + @xselect=get_xeditable_select(SrField.types_hash, "/review/edit_field/nil/type", 'select-type') haml %s{systematic_reviews/fields} end diff --git a/model/rs_campo.rb b/model/rs_campo.rb index 45ee4bb0..46f53140 100644 --- a/model/rs_campo.rb +++ b/model/rs_campo.rb @@ -31,6 +31,12 @@ class SrField < Sequel::Model def self.is_valid_type?(type) AVAILABLE_TYPES.include? type.to_s.chomp.to_sym end + def self.types_hash + AVAILABLE_TYPES.inject({}) {|ac,v| + ac[v]=I18n::t("fields.#{v}") + ac + } + end def self.types_a_sequel(campo) if campo[:type] == 'text' [campo[:name].to_sym, String, null: true] diff --git a/views/systematic_reviews/fields.haml b/views/systematic_reviews/fields.haml index 888f7b8b..c976a659 100644 --- a/views/systematic_reviews/fields.haml +++ b/views/systematic_reviews/fields.haml @@ -5,27 +5,35 @@ %a{:href=>url("/review/#{@review.id}")}=@review.name %li{:class=>:active}=t(:Fields) +:javascript + #{@xselect.javascript} - if @campos.empty? %p %em=t(:No_fields) - else - %ul.list-group - -@campos.each do |campo| - %li.list-group-item - =a_editable(campo[:id], 'campo-order', "/review/edit_field/#{campo[:id]}/order", campo[:order]) - %span=".-" - =a_editable(campo[:id], 'campo-name', "/review/edit_field/#{campo[:id]}/name", campo[:name]) - %span=":" - =a_textarea_editable(campo[:id], 'campo-description', "/review/edit_field/#{campo[:id]}/description", campo[:description]) - %span=". #{t(:Type)}: " - =a_editable(campo[:id], 'campo-type', "/review/edit_field/#{campo[:id]}/type", campo[:type]) - %span=". #{t(:Options)}: " - =a_textarea_editable(campo[:id], 'campo-options', "/review/edit_field/#{campo[:id]}/options", campo[:options]) - .btn-group.btn-group-sm - %a.btn.btn-danger{:href=>"/review/#{@review[:id]}/field/#{campo[:id]}/delete"} - %span.glyphicon.glyphicon-remove - =t(:Delete) + %table.table.table-bordered + %thead + %tr + %th=t(:Order) + %th=t(:Description) + %th=t("fields.code") + %th=t(:Type) + %th=t(:Options) + %th=t(:Delete) + %tbody + -@campos.each do |campo| + %tr + %td=a_editable(campo[:id], 'campo-order', "/review/edit_field/#{campo[:id]}/order", campo[:order]) + %td=a_textarea_editable(campo[:id], 'campo-description', "/review/edit_field/#{campo[:id]}/description", campo[:description]) + %td=a_editable(campo[:id], 'campo-name', "/review/edit_field/#{campo[:id]}/name", campo[:name]) + %td=@xselect.html(campo[:id], campo[:type]) + %td=a_textarea_editable(campo[:id], 'campo-options', "/review/edit_field/#{campo[:id]}/options", campo[:options]) + %td + .btn-group.btn-group-sm + %a.btn.btn-danger{:href=>"/review/#{@review[:id]}/field/#{campo[:id]}/delete"} + %span.glyphicon.glyphicon-remove + =t(:Delete) %a.btn.btn-primary{:href=>"/review/#{@review[:id]}/update_field_table"}=t("fields.update_fields_table")