-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from yebin-jeong/main
[Feature] #26 -์์ฝํด๋ฆฌ์คEdit ํ๊ทธ ๊ธฐ๋ฅ ์์
- Loading branch information
Showing
1 changed file
with
157 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,209 +1,166 @@ | ||
<template> | ||
<div class="akopolio-edit"> | ||
<MainHeader /> | ||
<div class="edit-container"> | ||
<h2>ํฌํธํด๋ฆฌ์ค ์์ ํ๊ธฐ</h2> | ||
<form @submit.prevent="savePortfolio"> | ||
<div class="form-group"> | ||
<label for="title">ํ๋๋ช </label> | ||
<input | ||
type="text" | ||
id="title" | ||
v-model="portfolio.title" | ||
required | ||
/> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="createdDate">ํ๋์ผ</label> | ||
<input | ||
type="date" | ||
id="createdDate" | ||
v-model="portfolio.createdDate" | ||
required | ||
/> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label for="tags">๋ถ์ผ ์ค์ </label> | ||
<input | ||
type="text" | ||
id="tags" | ||
v-model="newTag" | ||
placeholder="ํ๊ทธ ์ ๋ ฅ ํ ์ถ๊ฐ ๋ฒํผ์ ๋๋ฌ์ฃผ์ธ์" | ||
/> | ||
<button type="button" @click="addTag">์ถ๊ฐ</button> | ||
<div class="tags"> | ||
<span v-for="(tag, index) in portfolio.tags" :key="index" class="tag-badge"> | ||
{{ tag }} | ||
<button type="button" @click="removeTag(index)">x</button> | ||
</span> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label>๊ฒฝํ (STAR)</label> | ||
<div class="star-section"> | ||
<label>Situation</label> | ||
<textarea v-model="portfolio.star.situation" /> | ||
</div> | ||
<div class="star-section"> | ||
<label>Task</label> | ||
<textarea v-model="portfolio.star.task" /> | ||
</div> | ||
<div class="star-section"> | ||
<label>Action</label> | ||
<textarea v-model="portfolio.star.action" /> | ||
</div> | ||
<div class="star-section"> | ||
<label>Result</label> | ||
<textarea v-model="portfolio.star.result" /> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<label>์ค๋์ PMI</label> | ||
<label>Plus</label> | ||
<textarea v-model="portfolio.pmi.plus" /> | ||
<label>Minus</label> | ||
<textarea v-model="portfolio.pmi.minus" /> | ||
<label>Interesting</label> | ||
<textarea v-model="portfolio.pmi.interesting" /> | ||
</div> | ||
|
||
<button type="submit" class="save-button">์ ์ฅํ๊ธฐ</button> | ||
</form> | ||
<div class="container"> | ||
<!-- ํค๋ --> | ||
<MainHeader /> | ||
|
||
<!-- ํ๋๋ช ๊ณผ ํ๋์ผ --> | ||
<div class="activity-info"> | ||
<div class="activity-name-container"> | ||
<label for="activity-name"><h2>ํ๋๋ช </h2></label> | ||
<input type="text" id="activity-name" v-model="activityName" placeholder="ํ๋๋ช ์ ์ ๋ ฅํด์ฃผ์ธ์" /> | ||
</div> | ||
|
||
<div class="activity-date-container"> | ||
<label for="activity-date"><h2>ํ๋์ผ</h2></label> | ||
<input type="date" id="activity-date" v-model="activityDate" /> | ||
</div> | ||
</div> | ||
|
||
<!-- ๋ถ์ผ ์ค์ --> | ||
<div class="category-box"> | ||
<div class="category"> | ||
<label @click="toggleDropdown" class="category-label"> | ||
<h2>๋ถ์ผ ์ค์ </h2> | ||
<span v-if="selectedTags.length"> | ||
<span class="tag-badge" v-for="tag in selectedTags" :key="tag"> | ||
{{ tag }} | ||
</span> | ||
</span> | ||
</label> | ||
|
||
<div v-show="isDropdownOpen" class="tag-container"> | ||
<button | ||
v-for="tag in tags" | ||
:key="tag" | ||
@click="toggleTag(tag)" | ||
:class="{ active: selectedTags.includes(tag) }" | ||
> | ||
{{ tag }} | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<!-- ๊ฒฝํ (STAR ๋ชจ๋ธ) --> | ||
<div class="experience-container"> | ||
<div class="experience-box star-box"> | ||
<h2>๊ฒฝํ</h2> | ||
<div class="star-section" v-for="section in Object.keys(star)" :key="section"> | ||
<h3>{{ section.charAt(0).toUpperCase() + section.slice(1) }}</h3> | ||
<textarea v-model="star[section]" :placeholder="`${section}๋ฅผ ์์ฑํด์ฃผ์ธ์`" @input="autoResize($event)"></textarea> | ||
</div> | ||
</div> | ||
<MainFooter /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import MainHeader from '../../components/layout/Header.vue'; | ||
import MainFooter from '../../components/layout/Footer.vue'; | ||
import { mapGetters } from 'vuex'; | ||
export default { | ||
components: { | ||
MainHeader, | ||
MainFooter, | ||
|
||
<!-- ์ค๋์ PMI --> | ||
<div class="pmi-container"> | ||
<div class="pmi-box"> | ||
<h2>์ค๋์ PMI</h2> | ||
|
||
<div class="pmi-section" v-for="section in Object.keys(pmi)" :key="section"> | ||
<h3>{{ section.charAt(0).toUpperCase() + section.slice(1) }}</h3> | ||
<textarea v-model="pmi[section]" :placeholder="`${section}๋ฅผ ์์ฑํด์ฃผ์ธ์`" @input="autoResize($event)"></textarea> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<!-- ์ ์ฅ ๋ฒํผ --> | ||
<button @click="saveData" class="save-button">์ ์ฅํ๊ธฐ</button> | ||
<MainFooter /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import MainHeader from '../../components/layout/Header.vue' | ||
import MainFooter from '../../components/layout/Footer.vue' | ||
export default { | ||
components: { | ||
MainHeader, | ||
MainFooter | ||
}, | ||
data() { | ||
return { | ||
portfolioId: this.$route.params.id, // ํ์ฌ ํฌํธํด๋ฆฌ์ค ID | ||
activityName: '', | ||
activityDate: '', | ||
tags: [ | ||
'์ ๊ณต', '๊ต์', '๊ต๋ด๋์๋ฆฌ', '๊ต์ธ๋์๋ฆฌ', 'ํํ', '๋ด์ฌํ๋', '์ธํด', '์๋ฅด๋ฐ์ดํธ', | ||
'๋์ธํ๋', '์ํฌํฐ์ฆ', '๊ธฐ์๋จ', '๊ฐ์ฐ/ํ์ฌ', '์คํฐ๋', '๋ถํธ์บ ํ', 'ํ๋ก์ ํธ', | ||
'์ฐ๊ตฌ', 'ํ์ํ', '๊ธฐํ' | ||
], | ||
selectedTags: [], | ||
isDropdownOpen: false, | ||
star: { situation: '', task: '', action: '', result: '' }, | ||
pmi: { plus: '', minus: '', interesting: '' }, | ||
tooltipVisible: false | ||
}; | ||
}, | ||
computed: { | ||
isFormComplete() { | ||
return ( | ||
this.activityName && | ||
this.activityDate && | ||
this.selectedTags.length > 0 && | ||
Object.values(this.star).every((field) => field) && | ||
Object.values(this.pmi).every((field) => field) | ||
); | ||
} | ||
}, | ||
methods: { | ||
toggleDropdown() { | ||
this.isDropdownOpen = !this.isDropdownOpen; | ||
}, | ||
data() { | ||
return { | ||
portfolio: { | ||
title: '', | ||
createdDate: '', | ||
tags: [], | ||
star: { situation: '', task: '', action: '', result: '' }, | ||
pmi: { plus: '', minus: '', interesting: '' }, | ||
}, | ||
newTag: '', | ||
}; | ||
toggleTag(tag) { | ||
const index = this.selectedTags.indexOf(tag); | ||
if (index > -1) { | ||
this.selectedTags.splice(index, 1); | ||
} else { | ||
this.selectedTags.push(tag); | ||
} | ||
}, | ||
computed: { | ||
...mapGetters(['getPortfolios']), | ||
autoResize(event) { | ||
const textarea = event.target; | ||
textarea.style.height = 'auto'; | ||
textarea.style.height = `${textarea.scrollHeight}px`; | ||
}, | ||
created() { | ||
const portfolioId = this.$route.params.id; | ||
const existingPortfolio = this.getPortfolios.find((item) => item.id === portfolioId); | ||
if (existingPortfolio) { | ||
this.portfolio = JSON.parse(JSON.stringify(existingPortfolio)); | ||
saveData() { | ||
if (!this.isFormComplete) { | ||
alert('๋ชจ๋ ํ๋๋ฅผ ์ ๋ ฅํด์ฃผ์ธ์.'); | ||
return; | ||
} | ||
const updatedPortfolio = { | ||
id: this.portfolioId, | ||
title: this.activityName, | ||
createdDate: this.activityDate, | ||
tags: this.selectedTags, | ||
star: { ...this.star }, | ||
pmi: { ...this.pmi } | ||
}; | ||
this.$store.dispatch('updatePortfolio', updatedPortfolio).then(() => { | ||
alert('ํ๋์ด ์์ ๋์์ต๋๋ค!'); | ||
this.$router.push('/akopolio/main'); | ||
}); | ||
}, | ||
methods: { | ||
addTag() { | ||
if (this.newTag && !this.portfolio.tags.includes(this.newTag)) { | ||
this.portfolio.tags.push(this.newTag); | ||
this.newTag = ''; | ||
} | ||
}, | ||
removeTag(index) { | ||
this.portfolio.tags.splice(index, 1); | ||
}, | ||
savePortfolio() { | ||
this.$store | ||
.dispatch('updatePortfolio', this.portfolio) | ||
.then(() => { | ||
alert('ํฌํธํด๋ฆฌ์ค๊ฐ ์ ์ฅ๋์์ต๋๋ค.'); | ||
this.$router.push('/akopolio/main'); | ||
}); | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style scoped> | ||
.akopolio-edit { | ||
width: 375px; | ||
margin: 4rem auto; | ||
padding: 20px; | ||
background-color: #ffe8d1; | ||
min-height: calc(100vh - 120px); | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
.edit-container { | ||
background-color: #fff3e6; | ||
padding: 20px; | ||
border-radius: 10px; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | ||
} | ||
.form-group { | ||
margin-bottom: 20px; | ||
} | ||
.form-group label { | ||
font-size: 16px; | ||
color: #ff7f00; | ||
margin-bottom: 5px; | ||
display: block; | ||
} | ||
input, | ||
textarea { | ||
width: 100%; | ||
padding: 10px; | ||
border: 1px solid #ddd; | ||
border-radius: 5px; | ||
font-size: 14px; | ||
} | ||
.save-button { | ||
background-color: #f6b87a; | ||
color: white; | ||
padding: 10px 20px; | ||
border: none; | ||
border-radius: 10px; | ||
cursor: pointer; | ||
font-size: 16px; | ||
} | ||
.tags { | ||
display: flex; | ||
flex-wrap: wrap; | ||
gap: 5px; | ||
margin-top: 10px; | ||
} | ||
.tag-badge { | ||
background-color: #f6b87a; | ||
color: white; | ||
padding: 5px 10px; | ||
border-radius: 20px; | ||
font-size: 13px; | ||
display: flex; | ||
align-items: center; | ||
} | ||
.tag-badge button { | ||
margin-left: 5px; | ||
background: none; | ||
border: none; | ||
color: white; | ||
font-size: 12px; | ||
cursor: pointer; | ||
loadPortfolioData() { | ||
const portfolio = this.$store.getters.getPortfolios.find(port => port.id === this.portfolioId); | ||
if (portfolio) { | ||
this.activityName = portfolio.title; | ||
this.activityDate = portfolio.createdDate; | ||
this.selectedTags = portfolio.tags; | ||
this.star = { ...portfolio.star }; | ||
this.pmi = { ...portfolio.pmi }; | ||
} | ||
} | ||
}, | ||
mounted() { | ||
this.loadPortfolioData(); // ํฌํธํด๋ฆฌ์ค ๋ฐ์ดํฐ ๋ก๋ | ||
} | ||
</style> | ||
|
||
}; | ||
</script> | ||
|
||
<style scoped> | ||
/* ์คํ์ผ ์ ์๋ ๊ธฐ์กด๊ณผ ๋์ผํ๊ฒ ์ ์ง */ | ||
</style> |