-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
83 additions
and
67 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
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
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,55 +1,79 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatCardModule } from '@angular/material/card'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { Component, Input, OnInit } from "@angular/core"; | ||
import { MatButtonModule } from "@angular/material/button"; | ||
import { MatCardModule } from "@angular/material/card"; | ||
import { MatIconModule } from "@angular/material/icon"; | ||
|
||
import { DatePipe, NgFor, NgIf } from '@angular/common'; | ||
import { RouterLink } from '@angular/router'; | ||
import { DatePipe, NgFor, NgIf } from "@angular/common"; | ||
import { RouterLink } from "@angular/router"; | ||
import { ChoiceDataService } from "../shared/choice-data.service"; | ||
import { ChoiceGroup } from "../shared/choice-group"; | ||
import { SelectorService } from "../shared/selector.service"; | ||
|
||
@Component({ | ||
selector: 'choice-group-overview', | ||
templateUrl: './choice-group-card.component.html', | ||
styleUrls: ['./choice-group-card.component.css'], | ||
providers: [SelectorService], | ||
standalone: true, | ||
imports: [RouterLink, NgIf, NgFor, DatePipe, MatCardModule, MatButtonModule, MatIconModule] | ||
selector: "choice-group-overview", | ||
templateUrl: "./choice-group-card.component.html", | ||
styleUrls: ["./choice-group-card.component.css"], | ||
providers: [SelectorService], | ||
standalone: true, | ||
imports: [ | ||
RouterLink, | ||
NgIf, | ||
NgFor, | ||
DatePipe, | ||
MatCardModule, | ||
MatButtonModule, | ||
MatIconModule, | ||
], | ||
}) | ||
export class ChoiceGroupCardComponent implements OnInit { | ||
|
||
@Input() | ||
group: ChoiceGroup; | ||
|
||
constructor(private choiceDataService: ChoiceDataService, private md5Service: SelectorService) { } | ||
constructor( | ||
private choiceDataService: ChoiceDataService, | ||
private md5Service: SelectorService | ||
) {} | ||
|
||
deleteChoiceGroup() { | ||
if (confirm("Do you really want to delete this group?")) { | ||
this.choiceDataService.deleteChoiceGroupById(this.group.id); | ||
} | ||
if (confirm("Do you really want to delete this group?")) { | ||
this.choiceDataService.deleteChoiceGroupById(this.group.id); | ||
} | ||
} | ||
|
||
isColorLight(hex: string) { | ||
// https://awik.io/determine-color-bright-dark-using-javascript/ | ||
const color = +("0x" + hex.slice(1).replace(hex.length < 5 && /./g, '$&$&')); | ||
const r = color >> 16; | ||
const g = color >> 8 & 255; | ||
const b = color & 255; | ||
|
||
const hsp = Math.sqrt( | ||
0.299 * (r * r) + | ||
0.587 * (g * g) + | ||
0.114 * (b * b) | ||
) | ||
|
||
return hsp > 127.5; | ||
} | ||
|
||
getNextDaysSelections() { | ||
let outlook = []; | ||
let day = new Date(); // today | ||
for (let i=0; i<8; i++) { | ||
outlook.push({ | ||
day: new Date(day.getTime()), | ||
selections: this.md5Service.getChoicesForDate(this.group,day) | ||
}); | ||
day.setDate(day.getDate() + 1); | ||
} | ||
return outlook; | ||
let outlook = []; | ||
let day = new Date(); // today | ||
for (let i = 0; i < 8; i++) { | ||
outlook.push({ | ||
day: new Date(day.getTime()), | ||
selections: this.md5Service.getChoicesForDate(this.group, day), | ||
}); | ||
day.setDate(day.getDate() + 1); | ||
} | ||
return outlook; | ||
} | ||
|
||
getTodaysSelections() { | ||
let date = new Date(); | ||
let choices = this.md5Service.getChoicesForDate(this.group,date); | ||
let choices = this.md5Service.getChoicesForDate(this.group, date); | ||
return choices; | ||
} | ||
|
||
ngOnInit() { | ||
} | ||
|
||
ngOnInit() {} | ||
} |
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
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