From 47a514343cd38250f0d632ccfa3598737a028811 Mon Sep 17 00:00:00 2001 From: William Correa Date: Sat, 30 Mar 2019 11:47:24 -0300 Subject: [PATCH] [#4/feature] Allow change order with drag and drop --- package.json | 1 + quasar.conf.js | 3 +- src/view/Studio/LayoutStudio.vue | 145 --------------- src/view/Studio/Sortable.js | 20 ++ src/view/Studio/StudioCanvas.vue | 309 ++++++++++++++++++++++--------- yarn.lock | 4 + 6 files changed, 246 insertions(+), 236 deletions(-) delete mode 100644 src/view/Studio/LayoutStudio.vue create mode 100644 src/view/Studio/Sortable.js diff --git a/package.json b/package.json index 9d45900..0f5516a 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "lodash": "^4.17.11", "quasar": "^1.0.0-beta.0", "siiimple-toast": "^3.1.6", + "sortablejs": "^1.8.4", "vue-hot-reload-loader": "^0.2.0", "vue-i18n": "^7.3.3", "vuelidate": "^0.7.4" diff --git a/quasar.conf.js b/quasar.conf.js index eb34f9e..e991674 100644 --- a/quasar.conf.js +++ b/quasar.conf.js @@ -98,7 +98,8 @@ module.exports = function (context) { 'QDialog', 'QBar', 'QTabs', - 'QTab' + 'QTab', + 'QFab' ], directives: [ diff --git a/src/view/Studio/LayoutStudio.vue b/src/view/Studio/LayoutStudio.vue deleted file mode 100644 index 7c55d98..0000000 --- a/src/view/Studio/LayoutStudio.vue +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - diff --git a/src/view/Studio/Sortable.js b/src/view/Studio/Sortable.js new file mode 100644 index 0000000..7ef4d08 --- /dev/null +++ b/src/view/Studio/Sortable.js @@ -0,0 +1,20 @@ +import Sortable from 'sortablejs' + +let sortable + +export default { + bind (el, binding) { + const options = { + ...binding.value.options, + onUpdate: function () { + binding.value.handle(this.toArray()) + } + } + + sortable = Sortable.create(el, options) + }, + + unbind () { + sortable.destroy() + } +} diff --git a/src/view/Studio/StudioCanvas.vue b/src/view/Studio/StudioCanvas.vue index 9c477e4..e35c583 100644 --- a/src/view/Studio/StudioCanvas.vue +++ b/src/view/Studio/StudioCanvas.vue @@ -1,115 +1,176 @@ @@ -194,6 +322,7 @@ export default { .properties-tab padding 10px + & > div margin-bottom 15px diff --git a/yarn.lock b/yarn.lock index 51632dc..a49f020 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8900,6 +8900,10 @@ socks@^1.1.10: ip "^1.1.4" smart-buffer "^1.0.13" +sortablejs@^1.8.4: + version "1.8.4" + resolved "https://registry.yarnpkg.com/sortablejs/-/sortablejs-1.8.4.tgz#1bbfeafa96d399b83f28e25d8e49d4fbfd867f30" + source-list-map@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34"