This repository has been archived by the owner on Oct 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CardModal.vue
213 lines (197 loc) · 4.87 KB
/
CardModal.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<template>
<CardModalBase>
<div slot="header">
<div class="modal-card-header-title">
<awesome
:icon="['far', 'clipboard']"
class="far fa-clipboard"
></awesome>
<input
v-if="isEditTitle"
ref="inputTitle"
v-focus
class="form-control card-title-input"
type="text"
:value="card.title"
maxlength="44"
@blur="onSubmitTitle"
@keypress.enter="onKeyupEnter"
/>
<a v-else href="" @click.prevent="onEditTitle">
{{ card.title }} <awesome icon="edit" class="fas fa-edit"></awesome>
</a>
<span class="card-list-title">in list {{ listTitle }}</span>
</div>
</div>
<div slot="body" class="modal-card-body">
<ul class="body-items">
<CardLabels />
<CardDueDate />
<CardDescription
:card-description="card.description"
:card-id="card.id"
/>
<CardAttachment />
<CardChecklist />
<CardLocation />
<CardComment />
</ul>
</div>
<div slot="footer"></div>
<div slot="side" class="side-slot">
<SubModal />
</div>
</CardModalBase>
</template>
<script>
import CardModalBase from '@/components/card/cardModal/CardModalBase.vue';
import SubModal from '@/components/card/cardModal/subModal/SubModal.vue';
import CardLabels from '@/components/card/cardModal/mainModal/CardLabels.vue';
import CardChecklist from '@/components/card/cardModal/mainModal/checklists/CardChecklist.vue';
import CardDueDate from '@/components/card/cardModal/mainModal/CardDueDate.vue';
import CardLocation from '@/components/card/cardModal/mainModal/location/CardLocation.vue';
import CardDescription from '@/components/card/cardModal/mainModal/CardDescription.vue';
import CardComment from '@/components/card/cardModal/mainModal/comment/CardComment.vue';
import CardAttachment from '@/components/card/cardModal/mainModal/attachment/CardAttachment.vue';
import { updateCardAPI } from '@/api/card';
import { mapActions, mapState } from 'vuex';
export default {
components: {
CardModalBase,
SubModal,
CardLabels,
CardChecklist,
CardDueDate,
CardDescription,
CardLocation,
CardComment,
CardAttachment,
},
data() {
return {
isEditTitle: false,
listTitle: '',
};
},
computed: {
...mapState(['board', 'card']),
},
watch: {
// updateCard 후 card가 들어오면 실행되도록.
card() {
const { title } = this.board.lists.filter(l => {
return l.id == this.card.listId;
})[0];
this.listTitle = title;
},
},
created() {
this.readCardInfo();
},
methods: {
...mapActions(['READ_CARD', 'READ_BOARD_DETAIL']),
async readCardInfo() {
try {
await this.READ_CARD(this.$route.params.cardId);
} catch (error) {
console.log(error);
alert('카드 정보를 읽어오지 못했습니다.');
}
},
onEditTitle() {
this.isEditTitle = true;
},
async onSubmitTitle() {
this.isEditTitle = false;
const inputTitle = this.$refs.inputTitle.value || '';
if (inputTitle === this.card.title) {
return;
}
try {
await updateCardAPI(this.card.id, { title: inputTitle });
await this.READ_BOARD_DETAIL(this.board.id);
await this.readCardInfo();
} catch (error) {
console.log(error);
alert('카드 정보를 수정하지 못했습니다.');
}
},
onKeyupEnter(event) {
event.target.blur();
},
},
};
</script>
<style lang="scss">
.modal-card-header-title {
padding-right: 30px;
min-height: 30px;
a {
color: #212732;
font-size: 20px;
margin-left: 15px;
.fa-edit {
display: none;
font-size: 10px;
color: #4f5d76;
}
&:hover {
color: rgba(0, 0, 0, 0.3);
.fa-edit {
display: inline-block;
color: #4f5d76;
}
}
}
.card-title-input {
position: absolute;
margin: 0 0 0 15px;
padding: 3px 6px;
width: 80%;
display: inline;
overflow: hidden;
overflow-wrap: break-word;
height: 28px;
font-size: 17px;
}
.card-list-title {
position: absolute;
padding: 7px 0 40px 39px;
display: block;
font-size: 13px;
font-weight: 400;
}
.fa-clipboard {
padding: 1px;
margin-top: 5px;
font-size: 20px;
color: #4f5d76;
}
}
.modal-card-body {
margin-bottom: 10px;
.body-items {
.body-item {
padding-top: 40px;
.fas,
.fa {
font-size: 16px;
color: #4f5d76;
}
.body-card-text {
display: inline;
margin-left: 14px;
padding: 3px 6px;
width: 90%;
overflow: hidden;
overflow-wrap: break-word;
height: 28px;
font-size: 18px;
}
}
}
}
.side-slot {
height: 100%;
}
</style>