ki-frontend/src/views/profile/Edit.vue

159 lines
4.1 KiB
Vue
Raw Normal View History

2021-06-07 17:41:25 +02:00
<template>
<div class="container">
<h1>Profil Ändern</h1>
<form @submit.prevent="submitForm()">
<div class="row">
<div class="col-6 col-xs-12">
<label for="nickname" class="form-label">Nickname:</label>
<input
type="text"
class="form-control"
id="nickname"
v-model="nickname"
required
/>
</div>
<div class="col-6 col-xs-12">
<label for="nickname" class="form-label">Pronomen:</label>
<input
type="text"
class="form-control"
id="pronouns"
v-model="pronouns"
required
/>
2021-06-24 00:40:27 +02:00
<div id="emailHelp" class="form-text">
Z.B.: Er/Ihn, Sie/Ihr, Es etc..
</div>
</div>
</div>
<div class="row">
<div class="col-12 col-xs-12">
2021-06-24 00:40:27 +02:00
<label for="freetext" class="form-label">Freitext Vorstellung:</label>
<textarea
class="form-control"
id="freetext"
rows="3"
v-model="freetext"
></textarea>
</div>
<div class="col-12 col-xs-12">
2021-06-24 00:40:27 +02:00
<label for="volunteerwork" class="form-label"
>Ehrentamtliche Arbeit:</label
>
<textarea
class="form-control"
id="volunteerwork"
rows="3"
v-model="volunteerwork"
></textarea>
</div>
</div>
<div>
<label for="skills" class="form-label">Deine Fähigkeiten: (Autocomplete)</label>
<input
autocomplete="off"
type="text"
class="form-control"
id="pronouns"
v-model="searchSkillsText"
@keyup="searchSkills()"
/>
<div class="" v-if="searchSkillResults">
<ul class="list-group">
<li
class="list-group-item"
v-for="result in searchSkillResults"
:key="result.id"
@click="addSkill(result)">{{result.name}}</li>
</ul>
</div>
<div>
<span
v-for="skill in skills"
:key="skill.id"
class="badge bg-primary m-2"
>
{{ skill.name }}
<button
type="button"
class="btn-close"
aria-label="Close"
@click="removeSkill(skill.id)"
></button>
</span>
</div>
</div>
2021-06-24 00:40:27 +02:00
<button type="submit" class="btn btn-primary mb-4 mt-4">Speichern</button>
<div
class="alert alert-danger mb-4 mt-4"
role="alert"
v-if="showErrorMessage"
>
Es ist Fehler aufgetreten
</div>
</form>
</div>
2021-06-07 17:41:25 +02:00
</template>
<script>
2021-06-24 00:40:27 +02:00
import axios from "axios";
2021-06-07 17:41:25 +02:00
export default {
name: "profileEdit",
created() {
2021-06-24 00:40:27 +02:00
// get user profile by jwt tocken and fill the form details
},
data() {
return {
showErrorMessage: false,
nickname: "",
pronouns: "",
freetext: "",
2021-06-14 15:06:02 +02:00
volunteerwork: "",
2021-06-24 00:40:27 +02:00
languages: [],
searchLanguagesText: "",
skills: [
{ id: 3, name: "PHP" },
{ id: 2, name: "PHP" },
],
searchSkillsText: "",
searchSkillResults: [],
};
},
methods: {
submitForm() {},
2021-06-24 00:40:27 +02:00
async searchSkills() {
this.searchSkillResults = [{ id: 5, name: "JavaScript" }]
try {
const skillResult = await axios.get(
`${process.env.VUE_APP_API_URL}/skills?search=${this.searchSkillsText}`
);
console.log(skillResult);
if (skillResult.status === 200) {
this.searchSkillResults = skillResult.skills;
}
} catch (error) {
console.error();
this.showErrorMessage = true;
}
},
addSkill(skill){
if(this.skills.includes(skill)) return false
this.skills.push(skill)
this.searchSkillsText = ''
this.searchSkillResults = []
},
removeSkill(skillId) {
this.skills = this.skills.filter((skill) => {
if (skillId === skill.id) {
return false;
} else {
return true;
}
});
},
searchLanguages() {},
},
};
2021-06-07 17:41:25 +02:00
</script>