File tree Expand file tree Collapse file tree 1 file changed +33
-2
lines changed
Expand file tree Collapse file tree 1 file changed +33
-2
lines changed Original file line number Diff line number Diff line change 11<template >
22 <div id =" app" class =" row" >
3- <div v-for =" list in original_lists " class =" col-md-3" >
3+ <div v-for =" ( list, index) in lists " class =" col-md-3" >
44 <h6 >{{ list.name }}</h6 >
55 <hr />
66
7- <div v-for =" (card, index) in list.cards" class =" card card-body" >
7+ <div v-for =" (card, index) in list.cards" class =" card card-body mb-3 " >
88 {{ card.name }}
99 </div >
10+
11+ <div class =" card card-body" >
12+ <textarea v-model =" messages[list.id]" class =" form-control" ></textarea >
13+ <button v-on:click =" submitMessages(list.id)" class =" btn btn-secondary" >Add</button >
14+ </div >
1015 </div >
1116 </div >
1217</template >
1318
1419<script >
1520export default {
1621 props: [" original_lists" ],
22+ data : function () {
23+ return {
24+ messages: {},
25+ lists: this .original_lists
26+ }
27+ },
28+
29+ methods: {
30+ submitMessages : function (list_id ) {
31+ var data = new FormData
32+ data .append (" card[list_id]" , list_id)
33+ data .append (" card[name]" , this .messages [list_id])
34+
35+ Rails .ajax ({
36+ url: " /cards" ,
37+ type: " POST" ,
38+ data: data,
39+ dataType: " json" ,
40+ success : (data ) => {
41+ const index = this .lists .findIndex (item => item .id == list_id)
42+ this .lists [index].cards .push (data)
43+ this .messages [list_id] = undefined
44+ }
45+ })
46+ }
47+ }
1748
1849}
1950 </script >
You can’t perform that action at this time.
0 commit comments