-
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
14 changed files
with
280 additions
and
23 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,21 +1,2 @@ | ||
<!--The content below is only a placeholder and can be replaced.--> | ||
<div style="text-align:center"> | ||
<h1> | ||
Welcome to {{ title }}! | ||
</h1> | ||
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg=="> | ||
</div> | ||
<h2>Here are some links to help you start: </h2> | ||
<ul> | ||
<li> | ||
<h2><a target="_blank" rel="noopener" href="https://angular.io/tutorial">Tour of Heroes</a></h2> | ||
</li> | ||
<li> | ||
<h2><a target="_blank" rel="noopener" href="https://angular.io/cli">CLI Documentation</a></h2> | ||
</li> | ||
<li> | ||
<h2><a target="_blank" rel="noopener" href="https://blog.angular.io/">Angular blog</a></h2> | ||
</li> | ||
</ul> | ||
|
||
<app-main-page></app-main-page> | ||
<router-outlet></router-outlet> |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { DataService } from './data.service'; | ||
|
||
describe('DataService', () => { | ||
beforeEach(() => TestBed.configureTestingModule({})); | ||
|
||
it('should be created', () => { | ||
const service: DataService = TestBed.get(DataService); | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Injectable } from '@angular/core'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class DataService { | ||
|
||
constructor() { } | ||
|
||
getData(){ | ||
return [ | ||
{"_id":1, "description":"something to do 1","date":"date 1","checked":true}, | ||
{"_id":2, "description":"something to do 2","date":"date 2","checked":false}, | ||
{"_id":3, "description":"something to do 3","date":"date 3","checked":false}, | ||
{"_id":4, "description":"something to do 4","date":"date 4","checked":true} | ||
] | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<mat-toolbar> | ||
<mat-toolbar-row> | ||
<span>fake to do</span> | ||
</mat-toolbar-row> | ||
</mat-toolbar> | ||
|
||
<div class="container"> | ||
<div class="checkbox"> | ||
<div cdkDropList class="example-list" (cdkDropListDropped)="drop($event)"> | ||
<mat-checkbox class="example-box" *ngFor="let data of datas" [(ngModel)]="data.checked" cdkDrag> | ||
id : {{ data._id }} | ||
description : {{ data.description }} | ||
date : {{ data.date | date:'medium' }} | ||
{{ data.checked }} | ||
</mat-checkbox> | ||
</div> | ||
</div> | ||
|
||
<form #myForm="ngForm" class="form"> | ||
|
||
<mat-form-field class="full-width"> | ||
<input #descriptionModel="ngModel" matInput placeholder="Description" required minlength="5" name="description" [(ngModel)]="description"> | ||
<mat-error *ngIf="descriptionModel?.errors?.required">This field is required</mat-error> | ||
<mat-error *ngIf="descriptionModel?.errors?.minlength">You must type at least {{descriptionModel?.errors.minlength.requiredLength}} characters</mat-error> | ||
</mat-form-field> | ||
|
||
<mat-form-field> | ||
<input #dateModel="ngModel" matInput [matDatepicker]="picker" placeholder="Choose a date" required name="date" [(ngModel)]="date"> | ||
<mat-datepicker-toggle matSuffix [for]="picker" ></mat-datepicker-toggle> | ||
<mat-datepicker #picker></mat-datepicker> | ||
<mat-error *ngIf="dateModel?.errors?.required">This field is required</mat-error> | ||
</mat-form-field> | ||
|
||
<button mat-button (click)="pushData()" [disabled]="myForm.invalid">Add Task</button> | ||
<button mat-button (click)="myForm.resetForm()">Cancel</button> | ||
|
||
</form> | ||
<!--{{ descriptionModel.errors | json}}--> | ||
</div> |
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
$first-color: #5085ca; | ||
|
||
.cdk-drag-preview { | ||
box-sizing: border-box; | ||
border-radius: 10px; | ||
box-shadow: 0 5px 5px -3px rgba(0, 0, 0, 0.2), | ||
0 8px 10px 1px rgba(0, 0, 0, 0.14), | ||
0 3px 14px 2px rgba(0, 0, 0, 0.12); | ||
} | ||
.cdk-drag-placeholder { | ||
opacity: 0; | ||
} | ||
|
||
.cdk-drag-animating { | ||
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1); | ||
} | ||
|
||
.example-box:last-child { | ||
border: none; | ||
} | ||
|
||
.example-list.cdk-drop-list-dragging .example-box:not(.cdk-drag-placeholder) { | ||
transition: transform 250ms cubic-bezier(0, 0, 0.2, 1); | ||
} | ||
|
||
:host { | ||
mat-toolbar { | ||
background-color: $first-color; | ||
height: 44px; | ||
min-height: 0px; | ||
border-bottom: solid 2px #4a80bd; | ||
|
||
span { | ||
color:rgba(255, 255, 255, 0.973); | ||
} | ||
} | ||
|
||
.container { | ||
max-width: 1000px; | ||
margin: 0px auto; | ||
|
||
.checkbox { | ||
max-width: 500px; | ||
margin: 10px auto; | ||
|
||
.example-list { | ||
width: 500px; | ||
max-width: 100%; | ||
border: solid 1px #ccc; | ||
min-height: 44px; | ||
background: white; | ||
border-radius: 4px; | ||
overflow: hidden; | ||
|
||
.example-box { | ||
padding: 10px 10px; | ||
border-bottom: solid 1px #ccc; | ||
color: rgba(0, 0, 0, 0.87); | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: space-between; | ||
box-sizing: border-box; | ||
cursor: move; | ||
background: white; | ||
font-size: 14px; | ||
} | ||
} | ||
} | ||
} | ||
|
||
.form { | ||
max-width: 500px; | ||
margin: 0 auto; | ||
|
||
.full-width { | ||
width: 100%; | ||
} | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { MainPageComponent } from './main-page.component'; | ||
|
||
describe('MainPageComponent', () => { | ||
let component: MainPageComponent; | ||
let fixture: ComponentFixture<MainPageComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ MainPageComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(MainPageComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Component, OnInit, ViewChild } from '@angular/core'; | ||
import { DataService } from '../data.service'; | ||
import {CdkDragDrop, moveItemInArray} from '@angular/cdk/drag-drop'; | ||
import { NgForm } from '@angular/forms'; | ||
|
||
@Component({ | ||
selector: 'app-main-page', | ||
templateUrl: './main-page.component.html', | ||
styleUrls: ['./main-page.component.scss'] | ||
}) | ||
export class MainPageComponent implements OnInit { | ||
|
||
public datas = []; | ||
public description = ""; | ||
public date = ""; | ||
@ViewChild('myForm') myForm: NgForm; | ||
|
||
constructor(private _dataService: DataService) { } | ||
|
||
ngOnInit() { | ||
//this.datas = this._dataService.getData(); | ||
} | ||
|
||
pushData(){ | ||
this.datas.push({description: this.description, date: this.date}); | ||
this.myForm.resetForm(); | ||
this.myForm.control.markAsUntouched(); | ||
//this.myForm.controls.description.markAsUntouched(); | ||
console.log(this.myForm.controls); | ||
} | ||
|
||
drop(event: CdkDragDrop<string[]>) { | ||
moveItemInArray(this.datas, event.previousIndex, event.currentIndex); | ||
} | ||
|
||
} |
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 +1,5 @@ | ||
/* You can add global styles to this file, and also import other style files */ | ||
@import "~@angular/material/prebuilt-themes/indigo-pink.css"; | ||
|
||
html, body { height: 100%; } | ||
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; } |