mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-15 03:41:41 +00:00
reordenar los articulos al soltar
This commit is contained in:
parent
801602c062
commit
925d83320d
3 changed files with 37 additions and 30 deletions
|
@ -3,5 +3,8 @@ $(document).on('turbolinks:load', function() {
|
||||||
mode: 'row',
|
mode: 'row',
|
||||||
onlyBody: true,
|
onlyBody: true,
|
||||||
dragHandler: '.handle'
|
dragHandler: '.handle'
|
||||||
|
}).on('drop', function(from, to, el, mode) {
|
||||||
|
// Al soltar, reordenamos toda la tabla
|
||||||
|
$('.post_order').val(function(i,v) { return i; });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,36 +19,39 @@
|
||||||
.row
|
.row
|
||||||
.col
|
.col
|
||||||
- if @posts.present?
|
- if @posts.present?
|
||||||
%table.table.table-condensed.table-striped.table-draggable
|
= form_tag site_reorder_posts_path, method: :post do
|
||||||
%tbody
|
%table.table.table-condensed.table-striped.table-draggable
|
||||||
- @posts.each do |post|
|
%tbody
|
||||||
- if @category
|
- @posts.each_with_index do |post, i|
|
||||||
-# saltearse el post a menos que esté en la categoría
|
- if @category
|
||||||
-# por la que estamos filtrando
|
-# saltearse el post a menos que esté en la categoría
|
||||||
- next unless post.categories.include?(@category)
|
-# por la que estamos filtrando
|
||||||
-# establecer la direccion del texto
|
- next unless post.categories.include?(@category)
|
||||||
- direction = post.get_front_matter(:dir)
|
-# establecer la direccion del texto
|
||||||
%tr
|
- direction = post.get_front_matter(:dir)
|
||||||
%td
|
%tr
|
||||||
= fa_icon 'arrows-v', class: 'handle'
|
%td
|
||||||
%td{class: direction}
|
= fa_icon 'arrows-v', class: 'handle'
|
||||||
= link_to post.title, site_post_path(@site, post, lang: @lang)
|
= text_field 'posts[order]', i, value: post.order || i, class: 'post_order'
|
||||||
%br
|
|
||||||
%small
|
|
||||||
- post.categories.each do |c|
|
|
||||||
= link_to c, site_posts_path(@site, category: c, lang: @lang),
|
|
||||||
data: { toggle: 'tooltip' }, title: t('help.category')
|
|
||||||
%td
|
|
||||||
- if post.translations
|
|
||||||
%small
|
|
||||||
- post.translations.each do |pt|
|
|
||||||
= link_to pt.title, site_post_path(@site, pt, lang: pt.lang),
|
|
||||||
data: { toggle: 'tooltip' }, title: t("i18n.#{pt.lang}")
|
|
||||||
%br
|
|
||||||
|
|
||||||
%td= post.date.strftime('%F')
|
%td{class: direction}
|
||||||
%td= link_to t('posts.edit'),
|
= link_to post.title, site_post_path(@site, post, lang: @lang)
|
||||||
edit_site_post_path(@site, post, lang: @lang),
|
%br
|
||||||
class: 'btn btn-info'
|
%small
|
||||||
|
- post.categories.each do |c|
|
||||||
|
= link_to c, site_posts_path(@site, category: c, lang: @lang),
|
||||||
|
data: { toggle: 'tooltip' }, title: t('help.category')
|
||||||
|
%td
|
||||||
|
- if post.translations
|
||||||
|
%small
|
||||||
|
- post.translations.each do |pt|
|
||||||
|
= link_to pt.title, site_post_path(@site, pt, lang: pt.lang),
|
||||||
|
data: { toggle: 'tooltip' }, title: t("i18n.#{pt.lang}")
|
||||||
|
%br
|
||||||
|
|
||||||
|
%td= post.date.strftime('%F')
|
||||||
|
%td= link_to t('posts.edit'),
|
||||||
|
edit_site_post_path(@site, post, lang: @lang),
|
||||||
|
class: 'btn btn-info'
|
||||||
- else
|
- else
|
||||||
%h2= t('posts.none')
|
%h2= t('posts.none')
|
||||||
|
|
|
@ -16,5 +16,6 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
post 'enqueue', to: 'sites#enqueue'
|
post 'enqueue', to: 'sites#enqueue'
|
||||||
get 'build_log', to: 'sites#build_log'
|
get 'build_log', to: 'sites#build_log'
|
||||||
|
post 'reorder_posts', to: 'sites#reorder_posts'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue