diff --git a/app/assets/stylesheets/components/_button.scss b/app/assets/stylesheets/components/_button.scss index e69de29..da3b9fa 100644 --- a/app/assets/stylesheets/components/_button.scss +++ b/app/assets/stylesheets/components/_button.scss @@ -0,0 +1,4 @@ +#editing-btn { + color: $vintage; + font-size: 14px; +} diff --git a/app/assets/stylesheets/components/_list.scss b/app/assets/stylesheets/components/_list.scss index 1ed8883..ac32c1b 100644 --- a/app/assets/stylesheets/components/_list.scss +++ b/app/assets/stylesheets/components/_list.scss @@ -1,3 +1,5 @@ .list-title { - margin: 30px 15px; + display: flex; + justify-content: space-between; + align-item: baseline; } diff --git a/app/javascript/components/list.vue b/app/javascript/components/list.vue index 853f2fe..ae1f814 100644 --- a/app/javascript/components/list.vue +++ b/app/javascript/components/list.vue @@ -1,6 +1,30 @@ @@ -25,11 +49,37 @@ data: function() { return { editing: false, + name: this.list.name, message: "" } }, methods: { + // Clicking backdrop will close modal + closeModal: function(event) { + if (event.target.classList.contains("modal")) { this.editing = false } + }, + + // Save Modal Edit name + save: function() { + var data = new FormData + data.append("list[name]", this.name) + + Rails.ajax({ + url: `/lists/${this.list.id}`, + type: "PATCH", + data: data, + dataType: "json", + success: (data) => { + const list_index = window.store.lists.findIndex((item) => item.id == this.list.id) + window.store.lists.splice(list_index, 1, data) + + this.editing = false + } + }) + }, + + startEditing: function() { this.editing = true this.$nextTick(() => { this.$refs.message.focus() }) diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 42bda86..793ceaa 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -29,9 +29,6 @@ import TurbolinksAdapter from 'vue-turbolinks' import Vue from "vue/dist/vue.esm" import App from "../app.vue" -// Internal imports, e.g: -// import { initSelect2 } from '../components/init_select2'; - window.store = {} Vue.use(TurbolinksAdapter) diff --git a/app/views/lists/index.html.erb b/app/views/lists/index.html.erb index 5e11d09..ab76f14 100644 --- a/app/views/lists/index.html.erb +++ b/app/views/lists/index.html.erb @@ -2,8 +2,8 @@
- <%= link_to 'New List', new_list_path %> -
+ <%#= link_to 'New List', new_list_path %> +
<%= tag.div id: :boards, data: { lists: @lists.to_json(include: :cards) }