feat: Please sendh elp
parent
9a0ace7a70
commit
b22b867a6c
|
@ -4,15 +4,19 @@ import com.maradona.backend.entities.Employee;
|
|||
import com.maradona.backend.entities.EmployeeSecondarySkill;
|
||||
import com.maradona.backend.entities.FormOfAddress;
|
||||
import com.maradona.backend.entities.PrimarySkill;
|
||||
import com.maradona.backend.entities.Project;
|
||||
import com.maradona.backend.entities.SecondarySkill;
|
||||
import com.maradona.backend.repositories.EmployeeRepository;
|
||||
import com.maradona.backend.repositories.FormOfAddressRepository;
|
||||
import com.maradona.backend.repositories.PrimarySkillRepository;
|
||||
import com.maradona.backend.repositories.ProjectRepository;
|
||||
import com.maradona.backend.repositories.SecondarySkillRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -32,6 +36,9 @@ public class DefaultValueLoader implements CommandLineRunner {
|
|||
@Autowired
|
||||
private FormOfAddressRepository formOfAddressRepository;
|
||||
|
||||
@Autowired
|
||||
private ProjectRepository projectRepository;
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
|
||||
|
@ -104,5 +111,15 @@ public class DefaultValueLoader implements CommandLineRunner {
|
|||
employee1.setSecondarySkills(employee1Skills);
|
||||
|
||||
employeeRepository.save(employee1);
|
||||
|
||||
// add a default project
|
||||
Project project = new Project();
|
||||
project.setName("Project 1");
|
||||
project.setStartDate(LocalDate.now());
|
||||
project.setEndDate(LocalDate.now().plusDays(30));
|
||||
project.setDescription("This is a project description");
|
||||
|
||||
// save project
|
||||
project = projectRepository.save(project);
|
||||
}
|
||||
}
|
|
@ -13,48 +13,30 @@
|
|||
<div th:replace="~{/core/_header :: header(activePage='createSkill')}"></div>
|
||||
<div class="content container mt-4">
|
||||
<h2 class="mb-4">Create Skill</h2>
|
||||
<form
|
||||
th:action="@{/skills/save}"
|
||||
th:object="${skillPrototype}"
|
||||
method="post"
|
||||
class="project-card"
|
||||
>
|
||||
<form id="createSkillForm" class="project-card">
|
||||
<div class="card-body">
|
||||
<!-- Primary Skill Input -->
|
||||
<div class="form-group">
|
||||
<label for="primarySkill">Primary Skill:</label>
|
||||
<label for="primarySkill">Kategorie:</label>
|
||||
<input
|
||||
type="text"
|
||||
id="primarySkill"
|
||||
th:field="*{psid}"
|
||||
name="primarySkillDescription"
|
||||
class="form-control"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<!-- Secondary Skill Input -->
|
||||
<div class="form-group">
|
||||
<label for="secondarySkill">Secondary Skill:</label>
|
||||
<label for="secondarySkill">Fähigkeit:</label>
|
||||
<input
|
||||
type="text"
|
||||
id="secondarySkill"
|
||||
th:field="*{ssid}"
|
||||
name="secondarySkillDescription"
|
||||
class="form-control"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<!-- Skill Level Input -->
|
||||
<div class="form-group">
|
||||
<label for="level">Skill Level:</label>
|
||||
<input
|
||||
type="number"
|
||||
id="level"
|
||||
th:field="*{level}"
|
||||
class="form-control"
|
||||
min="1"
|
||||
max="5"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<!-- Submit Button -->
|
||||
<button type="submit" class="btn-create-project">Create Skill</button>
|
||||
</div>
|
||||
|
@ -62,5 +44,35 @@
|
|||
</div>
|
||||
<div th:replace="~{/core/_footer :: footer}"></div>
|
||||
</div>
|
||||
<script>
|
||||
document.getElementById("createSkillForm").addEventListener("submit", function(event) {
|
||||
event.preventDefault();
|
||||
const form = event.target;
|
||||
const formData = new FormData(form);
|
||||
const jsonData = {};
|
||||
formData.forEach((value, key) => {
|
||||
jsonData[key] = value;
|
||||
});
|
||||
fetch("/api/secondary-skill", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(jsonData),
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.ok) {
|
||||
window.location.href = "/skills";
|
||||
} else {
|
||||
return response.json().then((error) => {
|
||||
console.error("Error:", error);
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Error:", error);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue