Make app work again
This commit is contained in:
parent
a9ad628488
commit
938f3def1f
30 changed files with 235 additions and 154 deletions
|
|
@ -22,6 +22,7 @@ import { CreateBlockComponent } from './components/modal/modals/create-block/cre
|
||||||
import { RemoveBlockComponent } from './components/modal/modals/remove-block/remove-block.component';
|
import { RemoveBlockComponent } from './components/modal/modals/remove-block/remove-block.component';
|
||||||
import { ToggleComponent } from './components/shared/toggle/toggle.component';
|
import { ToggleComponent } from './components/shared/toggle/toggle.component';
|
||||||
import { TasksComponent } from './components/pages/page/tower/tasks/tasks.component';
|
import { TasksComponent } from './components/pages/page/tower/tasks/tasks.component';
|
||||||
|
import { ColorPipe } from './pipes/color.pipe';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
|
|
@ -41,7 +42,8 @@ import { TasksComponent } from './components/pages/page/tower/tasks/tasks.compon
|
||||||
CreateBlockComponent,
|
CreateBlockComponent,
|
||||||
RemoveBlockComponent,
|
RemoveBlockComponent,
|
||||||
ToggleComponent,
|
ToggleComponent,
|
||||||
TasksComponent
|
TasksComponent,
|
||||||
|
ColorPipe
|
||||||
],
|
],
|
||||||
imports: [BrowserModule, AppRoutingModule, FormsModule, BrowserAnimationsModule, DragDropModule],
|
imports: [BrowserModule, AppRoutingModule, FormsModule, BrowserAnimationsModule, DragDropModule],
|
||||||
providers: [],
|
providers: [],
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
<app-toggle
|
<app-toggle
|
||||||
[beforeText]="'This task hasn\'t been finished yet'"
|
[beforeText]="'This task hasn\'t been finished yet'"
|
||||||
[afterText]="'Goal already accomplished'"
|
[afterText]="'Goal already accomplished'"
|
||||||
[default]="!modalService.active.input.isTask"
|
[default]="isDone"
|
||||||
(value)="isDone = $event"
|
(value)="isDone = $event"
|
||||||
></app-toggle>
|
></app-toggle>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import { ModalService } from '../../../../services/modal.service';
|
||||||
export class CreateBlockComponent {
|
export class CreateBlockComponent {
|
||||||
selected: string;
|
selected: string;
|
||||||
description: string = null;
|
description: string = null;
|
||||||
isDone: boolean;
|
isDone: boolean = !this.modalService.active.input.isTask;
|
||||||
|
|
||||||
constructor(public modalService: ModalService) {}
|
constructor(public modalService: ModalService) {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
<app-select-add
|
<app-select-add
|
||||||
class="select"
|
class="select"
|
||||||
[options]="modalService.active.input.options"
|
[options]="modalService.active.input.options"
|
||||||
[default]="modalService.active.input.options[0]"
|
[default]="modalService.active.input.default"
|
||||||
[alwaysDropShadow]="true"
|
[alwaysDropShadow]="true"
|
||||||
[onlyShadowBorder]="true"
|
[onlyShadowBorder]="true"
|
||||||
[placeholder]="'Tag this item…'"
|
[placeholder]="'Tag this item…'"
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
You are trying to remove
|
You are trying to remove
|
||||||
<span [ngStyle]="{ color: modalService.active.input.baseColor.toString() }">{{
|
<span [ngStyle]="{ color: modalService.active.input.baseColor | color }">{{
|
||||||
modalService.active.input.name ? modalService.active.input.name : 'an unnamed tower'
|
modalService.active.input.name ? modalService.active.input.name : 'an unnamed tower'
|
||||||
}}</span
|
}}</span
|
||||||
>.
|
>.
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
<div [ngStyle]="{ 'background-color': block.color }" (click)="handleClick()"></div>
|
<div [ngStyle]="{ 'background-color': block.color | color }" (click)="handleClick()"></div>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { Block } from '../../../../../model/block';
|
import { Block } from '../../../../../model/block';
|
||||||
import { ModalService } from '../../../../../services/modal.service';
|
import { ModalService } from '../../../../../services/modal.service';
|
||||||
import { Tower } from '../../../../../model/tower';
|
import { ColoredBlock, Tower } from '../../../../../model/tower';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-block',
|
selector: 'app-block',
|
||||||
|
|
@ -9,7 +9,7 @@ import { Tower } from '../../../../../model/tower';
|
||||||
styleUrls: ['./block.component.scss']
|
styleUrls: ['./block.component.scss']
|
||||||
})
|
})
|
||||||
export class BlockComponent {
|
export class BlockComponent {
|
||||||
@Input() block: Block;
|
@Input() block: ColoredBlock;
|
||||||
@Input() tower: Tower;
|
@Input() tower: Tower;
|
||||||
|
|
||||||
constructor(private modalService: ModalService) {}
|
constructor(private modalService: ModalService) {}
|
||||||
|
|
@ -22,9 +22,12 @@ export class BlockComponent {
|
||||||
description: this.block.description,
|
description: this.block.description,
|
||||||
isDone: this.block.isDone
|
isDone: this.block.isDone
|
||||||
});
|
});
|
||||||
this.block.tag = selected;
|
console.log(description);
|
||||||
this.block.description = description;
|
this.block.changeProperties({
|
||||||
this.block.isDone = isDone;
|
tag: selected,
|
||||||
|
description,
|
||||||
|
isDone
|
||||||
|
});
|
||||||
} catch {
|
} catch {
|
||||||
// pass
|
// pass
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
{{ tasks.length == 0 ? '​' : tasks.length == 1 ? 'task' : 'tasks' }}
|
{{ tasks.length == 0 ? '​' : tasks.length == 1 ? 'task' : 'tasks' }}
|
||||||
</p>
|
</p>
|
||||||
<div class="all-task" #allTask [ngStyle]="{ height: (isOpen ? allTask?.scrollHeight : 0) + 'px' }">
|
<div class="all-task" #allTask [ngStyle]="{ height: (isOpen ? allTask?.scrollHeight : 0) + 'px' }">
|
||||||
<div class="task-container" *ngFor="let task of tasks" [ngStyle]="{ color: toHslString(task.color) }">
|
<div class="task-container" *ngFor="let task of tasks" [ngStyle]="{ color: task.color | color }">
|
||||||
<div [ngStyle]="{ 'background-color': toHslString(task.color) }"></div>
|
<div [ngStyle]="{ 'background-color': task.color | color }"></div>
|
||||||
<p (click)="handleClick(task)" [innerText]="task.description ? task.description : 'unknown'"></p>
|
<p (click)="handleClick(task)" [innerText]="task.description ? task.description : 'unknown'"></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ import { Block } from '../../../../../model/block';
|
||||||
import { Tower } from '../../../../../model/tower';
|
import { Tower } from '../../../../../model/tower';
|
||||||
import { ModalService } from '../../../../../services/modal.service';
|
import { ModalService } from '../../../../../services/modal.service';
|
||||||
import { CancelService } from '../../../../../services/cancel.service';
|
import { CancelService } from '../../../../../services/cancel.service';
|
||||||
import { toHslString } from '../../../../../utils/color';
|
import { IColor } from '../../../../../interfaces/color';
|
||||||
import { IColor } from '../../../../../interfaces/persistance/color';
|
import { IBlock } from '../../../../../interfaces/persistance/block';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-tasks',
|
selector: 'app-tasks',
|
||||||
|
|
@ -12,8 +12,6 @@ import { IColor } from '../../../../../interfaces/persistance/color';
|
||||||
styleUrls: ['./tasks.component.scss']
|
styleUrls: ['./tasks.component.scss']
|
||||||
})
|
})
|
||||||
export class TasksComponent implements OnInit {
|
export class TasksComponent implements OnInit {
|
||||||
readonly toHslString = toHslString;
|
|
||||||
|
|
||||||
@Input() tasks: Array<Block & { color: IColor }>;
|
@Input() tasks: Array<Block & { color: IColor }>;
|
||||||
@Input() tower: Tower;
|
@Input() tower: Tower;
|
||||||
|
|
||||||
|
|
@ -48,12 +46,16 @@ export class TasksComponent implements OnInit {
|
||||||
isDone: block.isDone
|
isDone: block.isDone
|
||||||
});
|
});
|
||||||
|
|
||||||
block.tag = selected;
|
const change: Partial<IBlock> = {
|
||||||
block.description = description;
|
tag: selected,
|
||||||
|
description,
|
||||||
|
isDone
|
||||||
|
};
|
||||||
if (!block.isDone && isDone) {
|
if (!block.isDone && isDone) {
|
||||||
block.created = new Date();
|
change.created = new Date();
|
||||||
}
|
}
|
||||||
block.isDone = isDone;
|
|
||||||
|
block.changeProperties(change);
|
||||||
} catch {
|
} catch {
|
||||||
// pass
|
// pass
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
id="tower-name"
|
id="tower-name"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="name…"
|
placeholder="name…"
|
||||||
[(ngModel)]="tower.name"
|
[(ngModel)]="towerName"
|
||||||
[ngStyle]="{ color: toHslString(tower?.baseColor) }"
|
[ngStyle]="{ color: tower?.baseColor | color }"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { Tower } from '../../../../model/tower';
|
import { ColoredBlock, Tower } from '../../../../model/tower';
|
||||||
import { ModalService } from '../../../../services/modal.service';
|
import { ModalService } from '../../../../services/modal.service';
|
||||||
import { Block } from '../../../../model/block';
|
|
||||||
import { IColor } from '../../../../interfaces/persistance/color';
|
|
||||||
import { toHslString } from '../../../../utils/color';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-tower',
|
selector: 'app-tower',
|
||||||
|
|
@ -11,7 +8,13 @@ import { toHslString } from '../../../../utils/color';
|
||||||
styleUrls: ['./tower.component.scss']
|
styleUrls: ['./tower.component.scss']
|
||||||
})
|
})
|
||||||
export class TowerComponent {
|
export class TowerComponent {
|
||||||
readonly toHslString = toHslString;
|
get towerName(): string {
|
||||||
|
return this.tower.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
set towerName(value: string) {
|
||||||
|
this.tower.changeName(value);
|
||||||
|
}
|
||||||
|
|
||||||
@Input() set dateRange(value: { from: Date; to: Date }) {
|
@Input() set dateRange(value: { from: Date; to: Date }) {
|
||||||
if (this.dateRange !== undefined && this.dateRange.from === value.from && this.dateRange.to === value.to) {
|
if (this.dateRange !== undefined && this.dateRange.from === value.from && this.dateRange.to === value.to) {
|
||||||
|
|
@ -26,13 +29,13 @@ export class TowerComponent {
|
||||||
|
|
||||||
public constructor(private modalService: ModalService) {}
|
public constructor(private modalService: ModalService) {}
|
||||||
|
|
||||||
get drawableBlocks(): Array<Block & { color: IColor }> {
|
get drawableBlocks(): Array<ColoredBlock> {
|
||||||
return this.tower.coloredBlocks.filter(
|
return this.tower.coloredBlocks.filter(
|
||||||
block => this.dateRange.from <= block.created && block.created <= this.dateRange.to && block.isDone
|
block => this.dateRange.from <= block.created && block.created <= this.dateRange.to && block.isDone
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
get tasks(): Array<Block & { color: IColor }> {
|
get tasks(): Array<ColoredBlock> {
|
||||||
return this.tower.coloredBlocks.filter(
|
return this.tower.coloredBlocks.filter(
|
||||||
block => this.dateRange.from <= block.created && block.created <= this.dateRange.to && !block.isDone
|
block => this.dateRange.from <= block.created && block.created <= this.dateRange.to && !block.isDone
|
||||||
);
|
);
|
||||||
|
|
|
||||||
5
src/app/interfaces/color.ts
Normal file
5
src/app/interfaces/color.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
export interface IColor {
|
||||||
|
h: number;
|
||||||
|
s: number;
|
||||||
|
l: number;
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
import { Typed } from './typed';
|
export interface IBlock {
|
||||||
|
|
||||||
export interface IBlock extends Typed {
|
|
||||||
type: 'Block';
|
|
||||||
created: Date;
|
created: Date;
|
||||||
tag: string;
|
tag: string;
|
||||||
isDone: boolean;
|
isDone: boolean;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
import { Typed } from './typed';
|
|
||||||
|
|
||||||
export interface IColor extends Typed {
|
|
||||||
type: 'Color';
|
|
||||||
h: number;
|
|
||||||
s: number;
|
|
||||||
l: number;
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
import { ITower } from './tower';
|
import { ITower } from './tower';
|
||||||
import { Typed } from './typed';
|
|
||||||
|
|
||||||
export interface IPage extends Typed {
|
export interface IPage {
|
||||||
type: 'Page';
|
|
||||||
name: string;
|
name: string;
|
||||||
towers: ITower[];
|
towers: ITower[];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
import { IBlock } from './block';
|
import { IBlock } from './block';
|
||||||
import { IColor } from './color';
|
import { IColor } from '../color';
|
||||||
import { Typed } from './typed';
|
|
||||||
|
|
||||||
export interface ITower extends Typed {
|
export interface ITower {
|
||||||
type: 'Tower';
|
|
||||||
name: string;
|
name: string;
|
||||||
blocks: IBlock[];
|
blocks: IBlock[];
|
||||||
baseColor: IColor;
|
baseColor: IColor;
|
||||||
|
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
export interface Typed {
|
|
||||||
type: string;
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
export interface Vector {
|
|
||||||
x: number;
|
|
||||||
y: number;
|
|
||||||
}
|
|
||||||
|
|
@ -1,20 +1,30 @@
|
||||||
import { Serializable } from './serializable';
|
import { Serializable } from './serializable';
|
||||||
import { IBlock } from '../interfaces/persistance/block';
|
import { IBlock } from '../interfaces/persistance/block';
|
||||||
import { Node } from '../storage/node';
|
import { Node } from '../store/node';
|
||||||
|
|
||||||
export class Block extends Serializable implements IBlock {
|
export class Block extends Serializable implements IBlock {
|
||||||
constructor(parent: Node, props: IBlock) {
|
constructor(parent: Node, props: IBlock) {
|
||||||
super(parent, props);
|
super(parent, props);
|
||||||
|
this.onAfterClone();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected onAfterClone(): void {
|
||||||
if (this.created.constructor.name !== 'Date') {
|
if (this.created.constructor.name !== 'Date') {
|
||||||
this.created = new Date(this.created);
|
this.created = new Date(this.created);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: remove.
|
||||||
|
if (this.isDone === null || this.isDone === undefined) {
|
||||||
|
this.isDone = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
changeProperties(values: Partial<IBlock>) {
|
||||||
|
this.changeKeys(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only here to prevent ts warnings.
|
|
||||||
type: 'Block';
|
|
||||||
created: Date;
|
created: Date;
|
||||||
isDone: boolean;
|
isDone: boolean;
|
||||||
description: string;
|
readonly description: string;
|
||||||
tag: string;
|
readonly tag: string;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,19 @@
|
||||||
import { Serializable } from './serializable';
|
import { Serializable } from './serializable';
|
||||||
import { IPage } from '../interfaces/persistance/page';
|
import { IPage } from '../interfaces/persistance/page';
|
||||||
import { Tower } from './tower';
|
import { Tower } from './tower';
|
||||||
import { Node } from '../storage/node';
|
import { Node } from '../store/node';
|
||||||
|
|
||||||
export class Page extends Serializable implements IPage {
|
export class Page extends Serializable implements IPage {
|
||||||
constructor(parent: Node, props: IPage) {
|
constructor(parent: Node, props: IPage) {
|
||||||
super(parent, props);
|
super(parent, props);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only here to prevent ts warnings.
|
readonly name: string;
|
||||||
name: string;
|
|
||||||
get towers(): Array<Tower> {
|
get towers(): Array<Tower> {
|
||||||
return this.children as Array<Tower>;
|
return this.children as Array<Tower>;
|
||||||
}
|
}
|
||||||
type: 'Page';
|
|
||||||
|
|
||||||
userData: {
|
readonly userData: {
|
||||||
hideCreateTowerButton: boolean;
|
hideCreateTowerButton: boolean;
|
||||||
defaultDateRange: {
|
defaultDateRange: {
|
||||||
from: Date;
|
from: Date;
|
||||||
|
|
@ -38,10 +36,14 @@ export class Page extends Serializable implements IPage {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.map(page => {
|
const towers = [...this.towers];
|
||||||
const tower = page.towers[previousIndex];
|
const tower = towers[previousIndex];
|
||||||
page.towers.splice(previousIndex, 1);
|
towers.splice(previousIndex, 1);
|
||||||
page.towers.splice(currentIndex, 0, tower);
|
towers.splice(currentIndex, 0, tower);
|
||||||
|
|
||||||
|
this.changeValue({
|
||||||
|
oldValue: this.towers,
|
||||||
|
newValue: towers
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -52,10 +54,9 @@ export class Page extends Serializable implements IPage {
|
||||||
} while (30 <= hue && hue <= 200);
|
} while (30 <= hue && hue <= 200);
|
||||||
|
|
||||||
new Tower(this, {
|
new Tower(this, {
|
||||||
type: 'Tower',
|
|
||||||
name,
|
name,
|
||||||
blocks: [],
|
blocks: [],
|
||||||
baseColor: { h: hue, s: 100, l: 50, type: 'Color' }
|
baseColor: { h: hue, s: 100, l: 50 }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue