Merge pull request 'fix: Wrong amount of stars' (#29) from 3002833/Backend:main into main

Reviewed-on: Maradona/Backend#29
pull/1/head
David Hess 2024-11-04 13:02:09 +01:00
commit 6c126de7a9
4 changed files with 121 additions and 122 deletions

Binary file not shown.

View File

@ -1,143 +1,138 @@
package com.maradona.backend;
// package com.maradona.backend;
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.SecondarySkill;
import com.maradona.backend.repositories.EmployeeRepository;
import com.maradona.backend.repositories.FormOfAddressRepository;
import com.maradona.backend.repositories.PrimarySkillRepository;
import com.maradona.backend.repositories.SecondarySkillRepository;
import com.maradona.backend.repositories.EmployeeSecondarySkillRepository;
import com.maradona.backend.repositories.ProjectRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
// 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.SecondarySkill;
// import com.maradona.backend.repositories.EmployeeRepository;
// import com.maradona.backend.repositories.FormOfAddressRepository;
// import com.maradona.backend.repositories.PrimarySkillRepository;
// import com.maradona.backend.repositories.SecondarySkillRepository;
// import com.maradona.backend.repositories.EmployeeSecondarySkillRepository;
// import com.maradona.backend.repositories.ProjectRepository;
// import org.springframework.beans.factory.annotation.Autowired;
// import org.springframework.boot.CommandLineRunner;
// import org.springframework.stereotype.Component;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.List;
// import java.time.LocalTime;
// import java.util.ArrayList;
// import java.util.List;
@Component
public class DefaultValueLoader implements CommandLineRunner {
// @Component
// public class DefaultValueLoader implements CommandLineRunner {
@Autowired
private PrimarySkillRepository primarySkillRepository;
// @Autowired
// private PrimarySkillRepository primarySkillRepository;
@Autowired
private SecondarySkillRepository secondarySkillRepository;
// @Autowired
// private SecondarySkillRepository secondarySkillRepository;
@Autowired
private EmployeeRepository employeeRepository;
// @Autowired
// private EmployeeRepository employeeRepository;
@Autowired
private FormOfAddressRepository formOfAddressRepository;
// @Autowired
// private FormOfAddressRepository formOfAddressRepository;
@Autowired
private EmployeeSecondarySkillRepository employeeSecondarySkillRepository;
// @Autowired
// private EmployeeSecondarySkillRepository employeeSecondarySkillRepository;
@Autowired
private ProjectRepository projectRepository;
// @Autowired
// private ProjectRepository projectRepository;
@Override
public void run(String... args) throws Exception {
// Clear all data
employeeRepository.deleteAll();
secondarySkillRepository.deleteAll();
primarySkillRepository.deleteAll();
formOfAddressRepository.deleteAll();
projectRepository.deleteAll();
employeeSecondarySkillRepository.deleteAll();
// @Override
// public void run(String... args) throws Exception {
// // Create form of addresses
// FormOfAddress formOfAddress1 = new FormOfAddress();
// formOfAddress1.setDescription("Herr");
// Create form of addresses
FormOfAddress formOfAddress1 = new FormOfAddress();
formOfAddress1.setDescription("Herr");
// FormOfAddress formOfAddress2 = new FormOfAddress();
// formOfAddress2.setDescription("Frau");
FormOfAddress formOfAddress2 = new FormOfAddress();
formOfAddress2.setDescription("Frau");
// FormOfAddress formOfAddress3 = new FormOfAddress();
// formOfAddress3.setDescription("Einkaufstüte");
FormOfAddress formOfAddress3 = new FormOfAddress();
formOfAddress3.setDescription("Einkaufstüte");
// formOfAddress1 = formOfAddressRepository.save(formOfAddress1);
// formOfAddress2 = formOfAddressRepository.save(formOfAddress2);
formOfAddress1 = formOfAddressRepository.save(formOfAddress1);
formOfAddress2 = formOfAddressRepository.save(formOfAddress2);
// // Create primary skills
// PrimarySkill primarySkill1 = new PrimarySkill();
// primarySkill1.setDescription("Software Development");
// Create primary skills
PrimarySkill primarySkill1 = new PrimarySkill();
primarySkill1.setDescription("Software Development");
// PrimarySkill primarySkill2 = new PrimarySkill();
// primarySkill2.setDescription("Project Management");
PrimarySkill primarySkill2 = new PrimarySkill();
primarySkill2.setDescription("Project Management");
// primarySkillRepository.save(primarySkill1);
// primarySkillRepository.save(primarySkill2);
primarySkillRepository.save(primarySkill1);
primarySkillRepository.save(primarySkill2);
// // Create secondary skills
// SecondarySkill secondarySkill1 = new SecondarySkill();
// secondarySkill1.setDescription("Java");
// secondarySkill1.setPrimarySkill(primarySkill1);
// Create secondary skills
SecondarySkill secondarySkill1 = new SecondarySkill();
secondarySkill1.setDescription("Java");
secondarySkill1.setPrimarySkill(primarySkill1);
// SecondarySkill secondarySkill2 = new SecondarySkill();
// secondarySkill2.setDescription("Agile Methodology");
// secondarySkill2.setPrimarySkill(primarySkill2);
SecondarySkill secondarySkill2 = new SecondarySkill();
secondarySkill2.setDescription("Agile Methodology");
secondarySkill2.setPrimarySkill(primarySkill2);
// SecondarySkill secondarySkill3 = new SecondarySkill();
// secondarySkill3.setDescription("Risk Management");
// secondarySkill3.setPrimarySkill(primarySkill2);
SecondarySkill secondarySkill3 = new SecondarySkill();
secondarySkill3.setDescription("Risk Management");
secondarySkill3.setPrimarySkill(primarySkill2);
// secondarySkillRepository.save(secondarySkill1);
// secondarySkillRepository.save(secondarySkill2);
// secondarySkillRepository.save(secondarySkill3);
secondarySkillRepository.save(secondarySkill1);
secondarySkillRepository.save(secondarySkill2);
secondarySkillRepository.save(secondarySkill3);
// // Create employees
// Employee employee1 = new Employee();
// employee1.setEmployeeNr(1);
// employee1.setFirstName("John");
// employee1.setLastName("Doe");
// employee1.setMail("john.doe@example.com");
// employee1.setDStart(LocalTime.of(9, 0));
// employee1.setDEnd(LocalTime.of(17, 0));
// employee1.setFormOfAddress(formOfAddress1);
// Create employees
Employee employee1 = new Employee();
employee1.setEmployeeNr(1);
employee1.setFirstName("John");
employee1.setLastName("Doe");
employee1.setMail("john.doe@example.com");
employee1.setDStart(LocalTime.of(9, 0));
employee1.setDEnd(LocalTime.of(17, 0));
employee1.setFormOfAddress(formOfAddress1);
// Employee employee2 = new Employee();
// employee2.setEmployeeNr(2);
// employee2.setFirstName("Jane");
// employee2.setLastName("Smith");
// employee2.setMail("jane.smith@example.com");
// employee2.setDStart(LocalTime.of(9, 0));
// employee2.setDEnd(LocalTime.of(17, 0));
// employee2.setFormOfAddress(formOfAddress2);
Employee employee2 = new Employee();
employee2.setEmployeeNr(2);
employee2.setFirstName("Jane");
employee2.setLastName("Smith");
employee2.setMail("jane.smith@example.com");
employee2.setDStart(LocalTime.of(9, 0));
employee2.setDEnd(LocalTime.of(17, 0));
employee2.setFormOfAddress(formOfAddress2);
// employeeRepository.save(employee1);
// employeeRepository.save(employee2);
employeeRepository.save(employee1);
employeeRepository.save(employee2);
// // Assign secondary skills to employees
// EmployeeSecondarySkill employeeSecondarySkill1 = new
// EmployeeSecondarySkill();
// employeeSecondarySkill1.setEmployee(employee1);
// employeeSecondarySkill1.setSecondarySkill(secondarySkill1);
// employeeSecondarySkill1.setLevel(4);
// Assign secondary skills to employees
EmployeeSecondarySkill employeeSecondarySkill1 = new EmployeeSecondarySkill();
employeeSecondarySkill1.setEmployee(employee1);
employeeSecondarySkill1.setSecondarySkill(secondarySkill1);
employeeSecondarySkill1.setLevel(4);
// EmployeeSecondarySkill employeeSecondarySkill2 = new
// EmployeeSecondarySkill();
// employeeSecondarySkill2.setEmployee(employee1);
// employeeSecondarySkill2.setSecondarySkill(secondarySkill2);
// employeeSecondarySkill2.setLevel(3);
EmployeeSecondarySkill employeeSecondarySkill2 = new EmployeeSecondarySkill();
employeeSecondarySkill2.setEmployee(employee1);
employeeSecondarySkill2.setSecondarySkill(secondarySkill2);
employeeSecondarySkill2.setLevel(3);
// EmployeeSecondarySkill employeeSecondarySkill3 = new
// EmployeeSecondarySkill();
// employeeSecondarySkill3.setEmployee(employee2);
// employeeSecondarySkill3.setSecondarySkill(secondarySkill3);
// employeeSecondarySkill3.setLevel(5);
EmployeeSecondarySkill employeeSecondarySkill3 = new EmployeeSecondarySkill();
employeeSecondarySkill3.setEmployee(employee2);
employeeSecondarySkill3.setSecondarySkill(secondarySkill3);
employeeSecondarySkill3.setLevel(5);
// List<EmployeeSecondarySkill> employee1Skills = new ArrayList<>();
// employee1Skills.add(employeeSecondarySkill1);
// employee1Skills.add(employeeSecondarySkill2);
// employee1.setSecondarySkills(employee1Skills);
List<EmployeeSecondarySkill> employee1Skills = new ArrayList<>();
employee1Skills.add(employeeSecondarySkill1);
employee1Skills.add(employeeSecondarySkill2);
employee1.setSecondarySkills(employee1Skills);
// List<EmployeeSecondarySkill> employee2Skills = new ArrayList<>();
// employee2Skills.add(employeeSecondarySkill3);
// employee2.setSecondarySkills(employee2Skills);
List<EmployeeSecondarySkill> employee2Skills = new ArrayList<>();
employee2Skills.add(employeeSecondarySkill3);
employee2.setSecondarySkills(employee2Skills);
employeeRepository.save(employee1);
employeeRepository.save(employee2);
}
}
// employeeRepository.save(employee1);
// employeeRepository.save(employee2);
// }
// }

View File

@ -79,3 +79,11 @@
.form-control::placeholder {
color: var(--starlight-white-darker);
}
.star-filled {
color: var(--aurora-yellowgreen-lighter);
}
.star-empty {
color: var(--cosmic-dark-light);
}

View File

@ -50,15 +50,11 @@
>
<span class="stars">
<span
th:each="i : ${#numbers.sequence(1, pair.second)}"
class="star"
>&#9733;</span
>
<span
th:each="i : ${#numbers.sequence(pair.second + 1, 5)}"
class="star"
>&#9734;</span
th:each="i : ${#numbers.sequence(1, 5)}"
th:classappend="${i <= pair.second} ? 'star-filled' : 'star-empty'"
>
&#9733;
</span>
</span>
<form
th:action="@{/skills/remove}"