Skip to content

Commit

Permalink
Reworked detail page
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuri0 committed Aug 24, 2024
1 parent 4196146 commit 26bc68b
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 64 deletions.
3 changes: 3 additions & 0 deletions src/app/choice-card/choice-card.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.choice-card {
max-width: fit-content;
}
22 changes: 22 additions & 0 deletions src/app/choice-card/choice-card.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<mat-card class="choice-card" appearance="outlined">
<mat-card-header>
<mat-card-title>{{choice.title}}</mat-card-title>
</mat-card-header>
<mat-card-content>
<table>
<tr>
<td><b>Color:</b></td>
<td><input type="color" [(ngModel)]="choice.color" (input)="choiceUpdated()" /></td>
</tr>
<tr>
<td><b>Weight:</b></td>
<td><input type="number" [(ngModel)]="choice.weight" min="0" (input)="choiceUpdated()" /></td>
</tr>
</table>
</mat-card-content>
<mat-card-actions align="end">
<button mat-icon-button (click)="deleteChoice()">
<mat-icon>delete</mat-icon>
</button>
</mat-card-actions>
</mat-card>
18 changes: 11 additions & 7 deletions ...ice-overview/choice-overview.component.ts → src/app/choice-card/choice-card.component.ts
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
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 {ChoiceDataService} from "./../shared/choice-data.service";
import {Choice } from "./../shared/choice";
import { FormsModule } from '@angular/forms';
import { Choice } from "../shared/choice";
import { ChoiceDataService } from "../shared/choice-data.service";

@Component({
selector: 'choice-overview',
templateUrl: './choice-overview.component.html',
styleUrls: ['./choice-overview.component.css'],
selector: 'choice-card',
templateUrl: './choice-card.component.html',
styleUrls: ['./choice-card.component.css'],
standalone: true,
imports: [FormsModule]
imports: [FormsModule, MatCardModule, MatIconModule, MatButtonModule]
})
export class ChoiceOverviewComponent implements OnInit {
export class ChoiceCardComponent implements OnInit {

@Input()
choice: Choice;
Expand All @@ -25,6 +28,7 @@ export class ChoiceOverviewComponent implements OnInit {
}

choiceUpdated() {
console.log('Hey');
this.choiceDataService.updateChoiceById(this.choice.id,this.groupId,this.choice);
}

Expand Down
9 changes: 4 additions & 5 deletions src/app/choice-group-detail/choice-group-detail.component.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.choice-list li {
.choice-list {
display: flex;
list-style-type: none;
}

.clear {
clear: both;
flex-wrap: wrap;
gap: 16px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ <h2>Choices</h2>

<div *ngIf=choiceGroup.choices.length>
<ul class="choice-list">
<li *ngFor="let choice of choiceGroup.choices">
<choice-overview [choice]="choice" [groupId]="choiceGroup.id"></choice-overview>
</li>
@for (choice of choiceGroup.choices; track choice.id) {
<choice-card [choice]="choice" [groupId]="choiceGroup.id"></choice-card>
}
</ul>
</div>

<div class="clear"></div>

<h2>Settings</h2>
Selections/Day <input type="number" [(ngModel)]="choiceGroup.choicesPerDay" (input)="choiceGroupUpdated()" />

Expand Down
8 changes: 4 additions & 4 deletions src/app/choice-group-detail/choice-group-detail.component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from "@angular/router";

import { NgFor, NgIf } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { ChoiceCardComponent } from '../choice-card/choice-card.component';
import { Choice } from "./../shared/choice";
import { ChoiceDataService } from "./../shared/choice-data.service";
import { ChoiceGroup } from "./../shared/choice-group";
import { SelectorService } from "./../shared/selector.service";
import { FormsModule } from '@angular/forms';
import { NgIf, NgFor } from '@angular/common';
import { ChoiceOverviewComponent } from '../choice-overview/choice-overview.component';

export interface AnalyticResult {
choice: string;
Expand All @@ -20,7 +20,7 @@ export interface AnalyticResult {
styleUrls: ['./choice-group-detail.component.css'],
providers: [SelectorService],
standalone: true,
imports: [FormsModule, NgIf, NgFor, ChoiceOverviewComponent]
imports: [FormsModule, NgIf, NgFor, ChoiceCardComponent]
})
export class ChoiceGroupDetailComponent implements OnInit {

Expand Down
23 changes: 0 additions & 23 deletions src/app/choice-overview/choice-overview.component.css

This file was deleted.

20 changes: 0 additions & 20 deletions src/app/choice-overview/choice-overview.component.html

This file was deleted.

0 comments on commit 26bc68b

Please sign in to comment.