From 9ca3b938471e539b3c5ba0c865fad29f0f963c5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Wed, 8 Aug 2018 22:32:25 +0200 Subject: [PATCH] Preparing column editor for backend requests, remove simple col editor and reuse one for both cases --- app/Http/Controllers/TableController.php | 6 +- .../assets/js/components/ColumnEditor.vue | 263 ++++++++++++++++-- .../js/components/ColumnEditorAdvanced.vue | 193 ------------- resources/assets/js/components/RowsEditor.vue | 187 +++++++------ .../js/components/table-editor-utils.js | 20 ++ resources/assets/js/vue-init.js | 4 - resources/views/table/create.blade.php | 4 +- .../table/propose/manage-columns.blade.php | 5 +- 8 files changed, 356 insertions(+), 326 deletions(-) delete mode 100644 resources/assets/js/components/ColumnEditorAdvanced.vue create mode 100644 resources/assets/js/components/table-editor-utils.js diff --git a/app/Http/Controllers/TableController.php b/app/Http/Controllers/TableController.php index bdfa575..e261007 100644 --- a/app/Http/Controllers/TableController.php +++ b/app/Http/Controllers/TableController.php @@ -85,9 +85,9 @@ class TableController extends Controller $columns = Column::columnsFromJson([ // fake 'id' to satisfy the check in Column constructor - ['name' => 'latin', 'type' => 'string', 'title' => 'Latin Name'], - ['name' => 'common', 'type' => 'string', 'title' => 'Common Name'], - ['name' => 'lifespan', 'type' => 'int', 'title' => 'Lifespan (years)'] + ['id' => 1, 'name' => 'latin', 'type' => 'string', 'title' => 'Latin Name'], + ['id' => 2, 'name' => 'common', 'type' => 'string', 'title' => 'Common Name'], + ['id' => 3, 'name' => 'lifespan', 'type' => 'int', 'title' => 'Lifespan (years)'] ]); return view('table.create', [ diff --git a/resources/assets/js/components/ColumnEditor.vue b/resources/assets/js/components/ColumnEditor.vue index 96ea5e7..a046cd5 100644 --- a/resources/assets/js/components/ColumnEditor.vue +++ b/resources/assets/js/components/ColumnEditor.vue @@ -1,42 +1,86 @@ + + @@ -53,36 +97,199 @@ @include py(1); } - td .btn { - @include mr(1); + tr.dragging { + position: relative; + z-index: 1; + background-color: $body-bg; + } + tr.dragging .drag-btn { + // fake hover + background-color: $secondary; + color: color-yiq($secondary); + } + + .col-list-enter-active { + transition: all .3s cubic-bezier(.2, .3, 0, 1); + } + + .col-list-enter { + opacity: 0; + transform: translateY(100%); + } + .col-list-leave { + // approximate position of delete button + clip-path: circle(calc(100% + 5em) at calc(100% - 4em) 50%); + } + .col-list-leave-active .delete-btn { + animation: col-list-leave-delete-btn .3s forwards; + } + .col-list-leave-active { + transition: all .3s cubic-bezier(.4, .1, .6, .9); + } + .col-list-leave-to { + clip-path: circle(0 at calc(100% - 4em) 50%); + } + + @keyframes col-list-leave-delete-btn { + 0% { + transition-timing-function: cubic-bezier(.2, .4, .6, .9); + } + 50% { + transition-timing-function: cubic-bezier(.5, 0, .8, .5); + transform: scale(1.1); + opacity: 1; + } + 100% { + transform: scale(0); + opacity: 0; + } + } + + .col-list-move { + transition: transform .3s cubic-bezier(.2, .3, 0, 1); } diff --git a/resources/assets/js/components/ColumnEditorAdvanced.vue b/resources/assets/js/components/ColumnEditorAdvanced.vue deleted file mode 100644 index c8d7a1c..0000000 --- a/resources/assets/js/components/ColumnEditorAdvanced.vue +++ /dev/null @@ -1,193 +0,0 @@ - - - - - diff --git a/resources/assets/js/components/RowsEditor.vue b/resources/assets/js/components/RowsEditor.vue index 4e8b846..4da3783 100644 --- a/resources/assets/js/components/RowsEditor.vue +++ b/resources/assets/js/components/RowsEditor.vue @@ -1,3 +1,14 @@ + +