Skip to content

Commit d6f7a7d

Browse files
committed
remove functionality added and some code modify
1 parent c19664b commit d6f7a7d

10 files changed

+59
-16
lines changed

src/app/ram/product/product-add-edit/product-add-edit.component.ts

+15
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,24 @@ export class ProductAddEditComponent implements OnInit, AfterViewInit, OnDestroy
190190
onBack():void{
191191
this._router.navigate(['/product']);
192192
}
193+
194+
193195
onTrash():void{
194196
console.log('trash click');
195197
console.log(this.rank);
198+
199+
if (this.moviesDetails.id === 0) {
200+
// Don't delete, it was never saved.
201+
this.onSaveComplete();
202+
} else {
203+
if (confirm(`Really delete the movie : ${this.moviesDetails.title}?`)) {
204+
this._service.deleteMovie(this.moviesDetails.id)
205+
.subscribe(
206+
() => this.onSaveComplete(),
207+
(error: any) => this.errorMessage = <any>error
208+
);
209+
}
210+
}
196211
}
197212

198213
formUpdate() :void{

src/app/ram/product/product-details/product-details.component.html

+7-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44
<span *ngIf="moviesDetails">{{moviesDetails.title | capitalizeFirst : true}}</span>
55
</div>
66
<div class='panel-body'>
7+
<div class="row">
8+
<div class="col-sm-12">
9+
<button class="btn btn-primary pull-right" type="button" style="margin-right:10px;" (click)='addNewOne()'><i class='fa fa-vcard'></i > Add New Movie</button>
10+
</div>
11+
</div>
712
<div class="row">
813
<div class="col-sm-12">
914

10-
<div class="panel panel-primary" *ngIf="moviesDetails">
15+
<div class="" *ngIf="moviesDetails">
1116

1217
<div class="panel-body">
1318
<div class="row">
@@ -89,11 +94,8 @@
8994
<a class='btn btn-default' (click)='onBack()'>
9095
<i class='glyphicon glyphicon-chevron-left'></i> Back to movies list
9196
</a>
92-
<a tooltip="Remove" class='btn btn-primary pull-right' (click)='onTrash()' style="margin-left:10px;">
93-
<i class='glyphicon fa fa-trash'></i>
94-
</a>
9597
<a tooltip="Edit" class='btn btn-primary pull-right' (click)='onEdit()'>
96-
<i class='glyphicon fa fa-edit'></i>
98+
<i class='glyphicon fa fa-edit'></i> Edit Movie
9799
</a>
98100
</div>
99101
</div>

src/app/ram/product/product-details/product-details.component.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@ export class ProductDetailsComponent implements OnInit {
5353
onBack():void{
5454
this._router.navigate(['/product']);
5555
}
56-
onTrash():void{
57-
console.log('trash click');
58-
console.log(this.rank);
59-
}
56+
6057
onEdit():void{
6158
this._router.navigate(['/product/edit', this.rank]);
6259
}
60+
61+
addNewOne(){
62+
console.log('yes add to one');
63+
this._router.navigate(['/product/edit/0']);
64+
}
6365
}

src/app/ram/product/product-list/product-list.component.html

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
<div class='col-md-6'>
2020
<h4>Filtered by: {{listFilter}} </h4>
2121
</div>
22+
<div class="col-md-6">
23+
<button class="btn btn-primary pull-right" type="button" style="margin-right:10px;" (click)='addNewOne()'><i class='fa fa-vcard'></i > Add New Movie</button>
24+
</div>
2225
</div>
2326
<div class='table-responsive' *ngIf="moviesList && moviesList.length">
2427
<h5>{{title}}</h5>

src/app/ram/product/product-list/product-list.component.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, OnInit } from '@angular/core';
2-
2+
import { Router } from '@angular/router';
33
import { ProductServiceService } from '../product-service.service';
44

55
@Component({
@@ -90,7 +90,9 @@ export class ProductListComponent implements OnInit {
9090

9191
// ]
9292
moviesList: any[];
93-
constructor(private productService: ProductServiceService) { }
93+
constructor(private productService: ProductServiceService,
94+
private _router: Router,
95+
) { }
9496

9597
ngOnInit() {
9698
this.productService.getProducts()
@@ -105,4 +107,10 @@ export class ProductListComponent implements OnInit {
105107
let ratingItemClick = 'Product List: ' + message;
106108
console.log(ratingItemClick)
107109
}
110+
111+
addNewOne(){
112+
console.log('yes add to one');
113+
this._router.navigate(['/product/edit/0']);
114+
}
115+
108116
}

src/app/ram/product/product-service.service.ts

+11
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ export class ProductServiceService {
7070
}
7171

7272

73+
// movies list remove based on id
74+
deleteMovie(id:number):Observable<Response> {
75+
let headers = new Headers({ 'Content-Type': 'application/json' });
76+
let options = new RequestOptions({ headers: headers });
77+
78+
const url = `${this.baseUrl}/${id}`;
79+
return this.http.delete(url, options)
80+
.do(data => console.log('deleteMovie: ' + JSON.stringify(data)))
81+
.catch(this.handleError);
82+
}
83+
7384
private extractData(response: Response) {
7485
let body = response.json();
7586
return body.data || {};

src/app/ram/register-client/register-client.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function ratingRange(min: number, max: number): ValidatorFn {
3535
})
3636
export class RegisterClientComponent implements OnInit {
3737

38-
private clientMessage = {
38+
clientMessage = {
3939
title: 'Client Registration Form',
4040
validationMessages:{
4141
firtName :{

src/app/ram/sign-up-form/sign-up-form.component.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@
143143

144144
<div class="panel-footer">
145145
<br>Dirty: {{ customerForm.dirty }}
146-
<br>Touched: {{ customerForm.touched }}
147-
<br>Valid: {{ customerForm.valid }}
148-
<br>Value: {{ customerForm.value | json }}
146+
<br>Touched: {{ customerForm.touched }}
147+
<br>Valid: {{ customerForm.valid }}
148+
<br>Value: {{ customerForm.value | json }}
149149
</div>
150150
</div>
151151
</div>

src/app/share/footer/footer.component.html

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ <h5 class="heading5">Follow Us</h5>
2121
<a [routerLink]="['/home']">Home <span class="sr-only">(current)</span></a>
2222
</li>
2323
<li [routerLinkActive]="['active']"><a [routerLink]="['/product']">Product</a></li>
24+
<li [routerLinkActive]="['active']"><a [routerLink]="['/sign-up']">Sign Up</a></li>
25+
<li [routerLinkActive]="['active']"><a [routerLink]="['/client-register']">Client Register</a></li>
2426
<li [routerLinkActive]="['active']"><a [routerLink]="['/contact']">Contact</a></li>
2527
</ul>
2628
</div>

src/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<base href="/">
1010

1111
<meta name="viewport" content="width=device-width, initial-scale=1">
12-
<link rel="icon" type="image/x-icon" href="assets/images/fav.png">
12+
<link rel="icon" type="image/x-icon" href="http://rohitazad.com/ng-rohitazad/assets/faviIcon/apple-icon-60x60.png">
1313
</head>
1414
<body>
1515
<app-root></app-root>

0 commit comments

Comments
 (0)