clean code
This commit is contained in:
parent
02fe8bf613
commit
8aadd146b8
5 changed files with 29 additions and 11 deletions
|
|
@ -30,7 +30,11 @@
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<div class="footer-badge">
|
<div class="footer-badge">
|
||||||
@for (assigned of task.assigned; track assigned) {
|
@for (assigned of task.assigned; track assigned) {
|
||||||
<span class="footer-badged">{{ userBadged(assigned) }}</span>
|
<span
|
||||||
|
class="footer-badged"
|
||||||
|
[style.background-color]="userBadgedColor(assigned)"
|
||||||
|
>{{ userBadged(assigned) }}</span
|
||||||
|
>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="footer-priority prio-{{ task.priority }}"></div>
|
<div class="footer-priority prio-{{ task.priority }}"></div>
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,6 @@ section {
|
||||||
min-height: 32px;
|
min-height: 32px;
|
||||||
border-radius: 45px;
|
border-radius: 45px;
|
||||||
border: 1px solid var(--white);
|
border: 1px solid var(--white);
|
||||||
background-color: red;
|
|
||||||
color: var(--white);
|
color: var(--white);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,9 @@ export class TaskComponent {
|
||||||
|
|
||||||
userBadged(id: number) {
|
userBadged(id: number) {
|
||||||
const userId = String(id);
|
const userId = String(id);
|
||||||
const user = this.userService.getUsers().find((user) => user.id === userId);
|
const user = this.userService
|
||||||
|
.getAllUsers()
|
||||||
|
.find((user) => user.id === userId);
|
||||||
if (user) {
|
if (user) {
|
||||||
if (user.firstName === 'Guest') {
|
if (user.firstName === 'Guest') {
|
||||||
return user.firstName.charAt(0);
|
return user.firstName.charAt(0);
|
||||||
|
|
@ -58,4 +60,16 @@ export class TaskComponent {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
userBadgedColor(id: number) {
|
||||||
|
const userId = String(id);
|
||||||
|
const user = this.userService
|
||||||
|
.getAllUsers()
|
||||||
|
.find((user) => user.id === userId);
|
||||||
|
if (user) {
|
||||||
|
return user.color;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,9 @@ export class ContactsComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
loadAllUserWithoutGuest(): User[] {
|
loadAllUserWithoutGuest(): User[] {
|
||||||
return this.userService.getUsers().filter((user) => user.initials !== 'G');
|
return this.userService
|
||||||
|
.getAllUsers()
|
||||||
|
.filter((user) => user.initials !== 'G');
|
||||||
}
|
}
|
||||||
|
|
||||||
sortUsersByFirstLetter(sortLetter: string) {
|
sortUsersByFirstLetter(sortLetter: string) {
|
||||||
|
|
|
||||||
|
|
@ -21,21 +21,20 @@ export class UserService implements OnDestroy {
|
||||||
return onSnapshot(collection(this.firestore, 'users'), (list) => {
|
return onSnapshot(collection(this.firestore, 'users'), (list) => {
|
||||||
this.allUsers = [];
|
this.allUsers = [];
|
||||||
list.forEach((element) => {
|
list.forEach((element) => {
|
||||||
const taskData = element.data() as User;
|
const userWithId = { id: element.id, ...element.data() } as User;
|
||||||
const taskWithId = { ...taskData };
|
this.allUsers.push(userWithId);
|
||||||
taskWithId.id = element.id;
|
|
||||||
this.allUsers.push(taskWithId);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getUsers(): User[] {
|
getAllUsers(): User[] {
|
||||||
return this.allUsers;
|
return this.allUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
getUserDetails(userId: string, query: keyof User) {
|
getUserDetails(userId: string, query: keyof User) {
|
||||||
const filteredUsers = this.getUsers().filter((user) => user.id === userId);
|
return this.getAllUsers()
|
||||||
return filteredUsers.map((user) => user[query]);
|
.filter((user) => user.id === userId)
|
||||||
|
.map((user) => user[query]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue