Skip to content

Commit 4e05745

Browse files
committed
new services for rendering menu list, bread section added. function to upload data to firestore has been updated. Improved bs-card group-system.
1 parent c1c4ed0 commit 4e05745

18 files changed

+267
-88
lines changed

section_19-project/project/db/init-db.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ const firebase = require("firebase");
33
require("firebase/firestore");
44

55
const firestore = require('./actions');
6-
const vegetables = require('./vegetables');
6+
const vegetables = require('./seeds/vegetables');
7+
const categories = require("./seeds/categories");
8+
const bread = require("./seeds/bread");
79

810
// Initialize Cloud Firestore through Firebase
911
firebase.initializeApp({
@@ -14,6 +16,8 @@ firebase.initializeApp({
1416

1517
const db = firebase.firestore();
1618

19+
const collections = [];
20+
1721
const coursePayload = {
1822
db: db,
1923
collection: vegetables.collection,
@@ -25,9 +29,27 @@ const coursePayload = {
2529
// key: 'url',
2630
// value: 'serverless-angular'
2731
// }
28-
}
32+
};
33+
34+
const categoriesPayload = {
35+
db: db,
36+
collection: categories.collection,
37+
collectionPath: 'categories',
38+
};
39+
40+
const breadPayload = {
41+
db: db,
42+
collection: bread.collection,
43+
collectionPath: 'bread',
44+
};
45+
46+
// UPLOAD TO FIRESTORE
47+
collections.push(coursePayload, categoriesPayload, breadPayload);
48+
collections.forEach((payloadCollection) => {
49+
firestore.populate(payloadCollection);
50+
});
51+
2952

30-
firestore.populate(coursePayload);
3153

3254

3355

section_19-project/project/db/vegetables.js renamed to section_19-project/project/db/seeds/bread.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,59 @@
1-
const collection = [
1+
let collection = [
22
{
33
title: 'Pizza Slice',
44
imageUrl: 'https://www.dropbox.com/s/0dymh0nkdhccz6j/119627_01.jpg?raw=1',
55
price: 0.69,
66
categories: ['Bread', 'Dairy', 'Fruits', 'Seasoning and Spice', 'Vegetables'],
7-
category: 'Bakery'
7+
category: 'Bread',
88
},
99
{
1010
title: 'Italian Style Panini Roll',
1111
imageUrl: 'https://www.dropbox.com/s/b03fg3pjd8m9e0z/1950_01.jpg?raw=1',
1212
price: 0.25,
1313
categories: ['Bread', 'Dairy', 'Fruits', 'Seasoning and Spice', 'Vegetables'],
14-
category: 'Bakery'
14+
category: 'Bread',
1515
},
1616
{
1717
title: 'French Baguette',
1818
imageUrl: 'https://www.dropbox.com/s/kgpaae6jahstelz/6742_01.jpg?raw=1',
1919
price: 0.69,
2020
categories: ['Bread', 'Dairy', 'Fruits', 'Seasoning and Spice', 'Vegetables'],
21-
category: 'Bakery'
21+
category: 'Bread',
2222
},
2323
{
2424
title: 'Maple and Pecan',
2525
imageUrl: 'https://www.dropbox.com/s/8wqgzxumpz9e99w/6817_01.jpg?raw=1',
2626
price: 0.49,
2727
categories: ['Bread', 'Dairy', 'Fruits', 'Seasoning and Spice', 'Vegetables'],
28-
category: 'Bakery'
28+
category: 'Bread',
2929
},
3030
{
3131
title: 'Double Chocolate Cookie',
3232
imageUrl: 'https://www.dropbox.com/s/lqjddrhhehdwiow/5207811_01.jpg?raw=1',
3333
price: 0.39,
3434
categories: ['Bread', 'Dairy', 'Fruits', 'Seasoning and Spice', 'Vegetables'],
35-
category: 'Bakery'
35+
category: 'Bread',
3636
},
3737
{
3838
title: 'All Butter Croisssant',
3939
imageUrl: 'https://www.dropbox.com/s/ojwtiirrdvo1mhs/121278_01.jpg?raw=1',
4040
price: 0.37,
4141
categories: ['Bread', 'Dairy', 'Fruits', 'Seasoning and Spice', 'Vegetables'],
42-
category: 'Bakery'
42+
category: 'Bread',
4343
},
4444
]
4545

46-
const nestedCollection = [
47-
48-
]
49-
5046

47+
collection = collection.map((item, index) => {
48+
return {
49+
...item,
50+
seqN: index + 1
51+
}
52+
})
5153

5254

5355
module.exports = {
54-
collection,
55-
nestedCollection,
56+
collection
5657
}
5758

5859

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
let collection = [
2+
{
3+
categoryName: 'Bread',
4+
isActive: false,
5+
},
6+
{
7+
categoryName: 'Dairy',
8+
isActive: false,
9+
},
10+
{
11+
categoryName: 'Fruits',
12+
isActive: false,
13+
},
14+
{
15+
categoryName: 'Seasoning and Spice',
16+
isActive: false,
17+
},
18+
{
19+
categoryName: 'Vegetables',
20+
isActive: false,
21+
},
22+
]
23+
24+
collection = collection.map((item, index) => {
25+
return {
26+
...item,
27+
seqN: index + 1
28+
}
29+
})
30+
31+
// const nestedCollection = [];
32+
33+
module.exports = {
34+
collection
35+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
let collection = [
2+
{
3+
title: 'Oaklands Selection Pointed Red Peppers ',
4+
imageUrl: 'https://www.dropbox.com/s/3uvy83gkftwtmln/82632_01.jpg?raw=1',
5+
price: 1.05,
6+
categories: ['Bread', 'Dairy', 'Fruits', 'Seasoning and Spice', 'Vegetables'],
7+
category: 'Vegetables',
8+
},
9+
{
10+
title: 'Oaklands Organic Vine Tomatoes',
11+
imageUrl: 'https://www.dropbox.com/s/7qe68yj8wyh0jd0/84570_01.jpg?raw=1',
12+
price: 1.60,
13+
categories: ['Bread', 'Dairy', 'Fruits', 'Seasoning and Spice', 'Vegetables'],
14+
category: 'Vegetables',
15+
},
16+
{
17+
title: 'Oaklands Organic Carrots',
18+
imageUrl: 'https://www.dropbox.com/s/qf1597z38c1p2sy/84610_01.jpg?raw=1',
19+
price: 0.95,
20+
categories: ['Bread', 'Dairy', 'Fruits', 'Seasoning and Spice', 'Vegetables'],
21+
category: 'Vegetables',
22+
},
23+
{
24+
title: 'Oaklands Baby Corn',
25+
imageUrl: 'https://www.dropbox.com/s/0cd780450mo01ho/82190_65.jpg?raw=1',
26+
price: 1.09,
27+
categories: ['Bread', 'Dairy', 'Fruits', 'Seasoning and Spice', 'Vegetables'],
28+
category: 'Vegetables',
29+
},
30+
{
31+
title: 'Oaklands Selection British Piccolo Tomatoes',
32+
imageUrl: 'https://www.dropbox.com/s/daio1kdyrfw4jkp/82394_01.jpg?raw=1',
33+
price: 1.45,
34+
categories: ['Bread', 'Dairy', 'Fruits', 'Seasoning and Spice', 'Vegetables'],
35+
category: 'Vegetables',
36+
}
37+
]
38+
39+
40+
collection = collection.map((item, index) => {
41+
return {
42+
...item,
43+
seqN: index + 1
44+
}
45+
})
46+
47+
48+
module.exports = {
49+
collection
50+
}
51+
52+
53+
54+
55+
56+
57+
58+
59+
60+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<bootstrap-navbar></bootstrap-navbar>
2-
<main class="container">
2+
<main class="container-fluid">
33
<router-outlet></router-outlet>
44
</main>

section_19-project/project/src/app/app.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import { BootstrapFormComponent } from './reusable-components/bootstrap-form/boo
1515
import { BootstrapInputComponent } from './reusable-components/bootstrap-input/bootstrap-input.component';
1616
import { BootstrapSelectComponent } from './reusable-components/bootstrap-select/bootstrap-select.component';
1717
import { BootstrapListComponent } from './reusable-components/bootstrap-list/bootstrap-list.component';
18-
import { BootstrapCardComponent } from './reusable-components/bootstrap-card/bootstrap-card.component';
1918
import { BootstrapNavbarComponent } from './components/bootstrap-navbar/bootstrap-navbar.component';
19+
import { BootstrapCardGroupComponent } from './reusable-components/bootstrap-card/bootstrap-cards-group.component';
2020

2121
@NgModule({
2222
declarations: [
@@ -27,7 +27,7 @@ import { BootstrapNavbarComponent } from './components/bootstrap-navbar/bootstra
2727
BootstrapInputComponent,
2828
BootstrapSelectComponent,
2929
BootstrapListComponent,
30-
BootstrapCardComponent,
30+
BootstrapCardGroupComponent,
3131
BootstrapNavbarComponent,
3232
],
3333
imports: [

section_19-project/project/src/app/components/products/interfaces.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export interface IProduct {
22
title: string;
33
imageUrl: string;
44
price: number;
5-
categories?: string[];
5+
categories: string[];
66
category: string;
77
id: string;
88
count: number;
@@ -12,6 +12,8 @@ export interface IProduct {
1212
export interface ICategory {
1313
categoryName: string;
1414
isActive: boolean;
15+
id: string;
16+
cssClass?: string;
1517
}
1618

1719
export interface IListGroup {
Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,55 @@
1-
<div class="row mt-5">
2-
<div class="col-md-6 col-xl-2">
3-
<bootstrap-list [props]='listGroup'></bootstrap-list>
1+
<div class="row m-5">
2+
<div class="col-4">
3+
<bootstrap-list (handleSelection)='handleSelection($event)' [props]='listGroup'></bootstrap-list>
44
</div>
5-
<div class="col-md-6 col-xl-10">
6-
<div class="card-group">
7-
<bootstrap-card *ngFor="let product of products">
5+
<div class="col-8">
6+
7+
<div class="row row-cols-1 row-cols-md-3">
8+
<bootstrap-cards-group *ngFor="let product of products">
89
<img class="selector-header card-img-top" src={{product.imageUrl}} alt="{{product.title}}">
910
<ng-container class="selector-body">
1011
<div class="card-body">
11-
<h5 class="card-title">
12-
{{product.title}}
13-
</h5>
14-
<p class="card-text">
15-
${{product.price}}
16-
</p>
12+
<h5 class="card-title">{{product.title}}</h5>
13+
<p class="card-text">${{product.price}}</p>
14+
1715
<ng-container *ngIf="!product.isOpen
1816
then button
1917
else counter">
2018
</ng-container>
2119

20+
<ng-template #button>
21+
<button (click)="counterShow(product)" class="btn btn-secondary btn-block">ADD TO CART</button>
22+
</ng-template>
23+
2224
<ng-template #counter>
23-
<div class="input-group mb-3">
25+
<div class="input-group">
2426
<div class="input-group-prepend">
25-
<button (click)="removeItem(product)" class="btn btn-secondary" type="button" id="button-addon1">-</button>
27+
<button (click)="removeItem(product)" class="btn btn-secondary" type="button">-</button>
2628
</div>
2729
<input type="text" class="form-control text-center" [placeholder]="product.count + ' in cart'" readonly>
2830
<div class="input-group-append">
29-
<button (click)="addItem(product)" class="btn btn-secondary" type="button" id="button-addon2">+</button>
31+
<button (click)="addItem(product)" class="btn btn-secondary" type="button">+</button>
3032
</div>
3133
</div>
3234
</ng-template>
3335

34-
<ng-template #button>
35-
<button (click)="counterShow(product)" class="btn btn-secondary btn-block">ADD TO CART</button>
36-
</ng-template>
3736
</div>
3837
</ng-container>
39-
</bootstrap-card>
38+
</bootstrap-cards-group>
4039
</div>
40+
41+
<nav>
42+
<ul class="pagination justify-content-center m-5">
43+
<li class="page-item">
44+
<a class="page-link" href="#">
45+
Prev
46+
</a>
47+
</li>
48+
<li class="page-item">
49+
<a class="page-link" (click)="loadmore()">Next</a>
50+
</li>
51+
</ul>
52+
</nav>
53+
4154
</div>
4255
</div>

0 commit comments

Comments
 (0)