From 9fd9e5fa4e3fd69b833bce22daed61b42a46e9d2 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 24 May 2023 10:58:08 -0300 Subject: [PATCH] fix: deshabilitar la interfaz de orden para invitades #13439 --- app/views/posts/index.haml | 49 ++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index e8c3dea7..46fafa49 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -1,3 +1,10 @@ +- reorder_allowed = policy(site).reorder? +- if reorder_allowed + - reorder_controller = { controller: 'reorder' } + - reorder_target = { target: 'reorder.row' } +- else + - reorder_target = reorder_controller = {} + %main.row %aside.menu.col-md-3 = render 'sites/header', site: @site @@ -67,22 +74,23 @@ %h2= t('posts.empty') - else = form_tag site_posts_reorder_path, method: :post do - %input{ type: 'hidden', name: 'post[lang]', value: @locale } - %table.table{ data: { controller: 'reorder' } } + %table.table{ data: reorder_controller } %caption.sr-only= t('posts.caption') %thead %tr.sticky-top %th.border-0{ colspan: '4' } .d-flex.flex-row.justify-content-between %div - = submit_tag t('posts.reorder.submit'), class: 'btn' - %button.btn{ data: { action: 'reorder#unselect' } } - = t('posts.reorder.unselect') - %span.badge{ data: { target: 'reorder.counter' } } 0 - %button.btn{ data: { action: 'reorder#up' } }= t('posts.reorder.up') - %button.btn{ data: { action: 'reorder#down' } }= t('posts.reorder.down') - %button.btn{ data: { action: 'reorder#top' } }= t('posts.reorder.top') - %button.btn{ data: { action: 'reorder#bottom' } }= t('posts.reorder.bottom') + - if reorder_allowed + = submit_tag t('posts.reorder.submit'), class: 'btn' + %button.btn{ data: { action: 'reorder#unselect' } } + = t('posts.reorder.unselect') + %span.badge{ data: { target: 'reorder.counter' } } 0 + %button.btn{ data: { action: 'reorder#up' } }= t('posts.reorder.up') + %button.btn{ data: { action: 'reorder#down' } }= t('posts.reorder.down') + %button.btn{ data: { action: 'reorder#top' } }= t('posts.reorder.top') + %button.btn{ data: { action: 'reorder#bottom' } }= t('posts.reorder.bottom') + %input{ type: 'hidden', name: 'post[lang]', value: @locale } %div %tbody @@ -94,16 +102,17 @@ les botones por permisos. - cache_if @usuarie, [post, I18n.locale] do - checkbox_id = "checkbox-#{post.post_id}" - %tr{ id: post.post_id, data: { target: 'reorder.row' } } - %td - .custom-control.custom-checkbox - %input.custom-control-input{ id: checkbox_id, type: 'checkbox', autocomplete: 'off', data: { action: 'reorder#select' } } - %label.custom-control-label{ for: checkbox_id } - %span.sr-only= t('posts.reorder.select') - -# Orden más alto es mayor prioridad - = hidden_field 'post[reorder]', post.post_id, - value: size - i, - data: { reorder: true } + %tr{ id: post.post_id, data: reorder_target } + - if reorder_allowed + %td + .custom-control.custom-checkbox + %input.custom-control-input{ id: checkbox_id, type: 'checkbox', autocomplete: 'off', data: { action: 'reorder#select' } } + %label.custom-control-label{ for: checkbox_id } + %span.sr-only= t('posts.reorder.select') + -# Orden más alto es mayor prioridad + = hidden_field 'post[reorder]', post.post_id, + value: size - i, + data: { reorder: true } %td.w-100{ class: dir } = link_to site_post_path(@site, post.path) do %span{ lang: post.locale, dir: dir }= post.title