From 61e93785244c3a2ac6df2c883c89a19a20ac9a4c Mon Sep 17 00:00:00 2001 From: f Date: Fri, 27 Apr 2018 16:46:21 -0300 Subject: [PATCH] arrastrar y soltar posts --- app/assets/javascripts/application.js | 1 + app/assets/javascripts/drag.js | 7 +++ app/assets/stylesheets/application.scss | 5 ++ app/views/posts/index.haml | 4 +- package.json | 3 +- yarn.lock | 70 +++++++++++++++++++++++++ 6 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 app/assets/javascripts/drag.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 733c70a..247dd59 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -22,4 +22,5 @@ //= require bootstrap-markdown/js/bootstrap-markdown //= require markdown-it/dist/markdown-it //= require select2/dist/js/select2 +//= require table-dragger/dist/table-dragger.js //= require_tree . diff --git a/app/assets/javascripts/drag.js b/app/assets/javascripts/drag.js new file mode 100644 index 0000000..b99b9c6 --- /dev/null +++ b/app/assets/javascripts/drag.js @@ -0,0 +1,7 @@ +$(document).on('turbolinks:load', function() { + tableDragger(document.querySelector('.table-draggable'), { + mode: 'row', + onlyBody: true, + dragHandler: '.handle' + }); +}); diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 0e47ffe..b00df3a 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -2,6 +2,7 @@ @import "bootstrap-markdown/css/bootstrap-markdown.min"; @import "font-awesome"; @import "select2/dist/css/select2"; +@import "dragula-with-animation/dist/dragula.css"; $footer-height: 60px; @@ -101,3 +102,7 @@ textarea.post-content { .inline { display: inline; } + +.sindu_dragger table { + background: transparent !important; +} diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index 60b88cf..3034fae 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -19,7 +19,7 @@ .row .col - if @posts.present? - %table.table.table-condensed.table-striped + %table.table.table-condensed.table-striped.table-draggable %tbody - @posts.each do |post| - if @category @@ -29,6 +29,8 @@ -# establecer la direccion del texto - direction = post.get_front_matter(:dir) %tr + %td + = fa_icon 'arrows-v', class: 'handle' %td{class: direction} = link_to post.title, site_post_path(@site, post, lang: @lang) %br diff --git a/package.json b/package.json index 575e176..a9dc485 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "markdown-it": "^8.4.0", "marked": "^0.3.12", "popper.js": "^1.12.9", - "select2": "^4.0.6-rc.1" + "select2": "^4.0.6-rc.1", + "table-dragger": "^1.0.2" } } diff --git a/yarn.lock b/yarn.lock index 71693e8..13a49c4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16,10 +16,59 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" +atoa@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/atoa/-/atoa-1.0.0.tgz#0cc0e91a480e738f923ebc103676471779b34a49" + +babel-runtime@^6.20.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" + dependencies: + core-js "^2.4.0" + regenerator-runtime "^0.11.0" + "bootstrap-markdown@https://0xacab.org/itacate-kefir/bootstrap-markdown.git": version "2.10.0" resolved "https://0xacab.org/itacate-kefir/bootstrap-markdown.git#580184dc214ea2364fca0fdcb70e3c5e08bd5605" +contra@1.9.4: + version "1.9.4" + resolved "https://registry.yarnpkg.com/contra/-/contra-1.9.4.tgz#f53bde42d7e5b5985cae4d99a8d610526de8f28d" + dependencies: + atoa "1.0.0" + ticky "1.0.1" + +core-js@^2.4.0: + version "2.5.5" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.5.tgz#b14dde936c640c0579a6b50cabcc132dd6127e3b" + +crossvent@1.5.4: + version "1.5.4" + resolved "https://registry.yarnpkg.com/crossvent/-/crossvent-1.5.4.tgz#da2c4f8f40c94782517bf2beec1044148194ab92" + dependencies: + custom-event "1.0.0" + +crossvent@^1.5.5: + version "1.5.5" + resolved "https://registry.yarnpkg.com/crossvent/-/crossvent-1.5.5.tgz#ad20878e4921e9be73d9d6976f8b2ecd0f71a0b1" + dependencies: + custom-event "^1.0.0" + +custom-event@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.0.tgz#2e4628be19dc4b214b5c02630c5971e811618062" + +custom-event@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" + +dragula-with-animation@^3.7.2: + version "3.7.2" + resolved "https://registry.yarnpkg.com/dragula-with-animation/-/dragula-with-animation-3.7.2.tgz#9b992db2a274324325c70bb0cb752e77e1faa8af" + dependencies: + contra "1.9.4" + crossvent "1.5.4" + entities@~1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0" @@ -76,6 +125,14 @@ popper.js@^1.12.9: version "1.12.9" resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.12.9.tgz#0dfbc2dff96c451bb332edcfcfaaf566d331d5b3" +regenerator-runtime@^0.11.0: + version "0.11.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" + +rx@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/rx/-/rx-4.1.0.tgz#a5f13ff79ef3b740fe30aa803fb09f98805d4782" + select2@^4.0.6-rc.1: version "4.0.6-rc.1" resolved "https://registry.yarnpkg.com/select2/-/select2-4.0.6-rc.1.tgz#aa6c3038a7f0f2e91ffade38f0a21c15e1813276" @@ -87,6 +144,19 @@ sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" +table-dragger@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/table-dragger/-/table-dragger-1.0.2.tgz#981f46c62fd2899b3fc5e644055ea72831949707" + dependencies: + babel-runtime "^6.20.0" + crossvent "^1.5.5" + dragula-with-animation "^3.7.2" + rx "^4.1.0" + +ticky@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/ticky/-/ticky-1.0.1.tgz#b7cfa71e768f1c9000c497b9151b30947c50e46d" + uc.micro@^1.0.1, uc.micro@^1.0.3: version "1.0.5" resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.5.tgz#0c65f15f815aa08b560a61ce8b4db7ffc3f45376"