Переглянути джерело

Added Menuitem service, offer service, outlet service

master
kj1352 6 роки тому
джерело
коміт
d61efac20e
17 змінених файлів з 174 додано та 67 видалено
  1. +6
    -0
      src/app/app.module.ts
  2. +2
    -1
      src/app/mall-details/mall-details.page.ts
  3. +2
    -1
      src/app/malls/malls.page.ts
  4. +8
    -31
      src/app/mocks/malls.ts
  5. +3
    -3
      src/app/mocks/menu-items.ts
  6. +8
    -0
      src/app/mocks/offers.ts
  7. +2
    -6
      src/app/mocks/outlets.ts
  8. +72
    -1
      src/app/models/mall.ts
  9. +5
    -5
      src/app/models/offer.ts
  10. +2
    -1
      src/app/outlet-details/outlet-details.page.ts
  11. +1
    -18
      src/app/services/mall.service.ts
  12. +12
    -0
      src/app/services/menu-item.service.spec.ts
  13. +9
    -0
      src/app/services/menu-item.service.ts
  14. +12
    -0
      src/app/services/offer.service.spec.ts
  15. +9
    -0
      src/app/services/offer.service.ts
  16. +12
    -0
      src/app/services/outlet.service.spec.ts
  17. +9
    -0
      src/app/services/outlet.service.ts

+ 6
- 0
src/app/app.module.ts Переглянути файл

@@ -10,6 +10,9 @@ import { StatusBar } from '@ionic-native/status-bar/ngx';

// Services import
import { MallService } from './services/mall.service';
import { MenuItemService } from './services/menu-item.service';
import { OfferService } from './services/offer.service';
import { OutletService } from './services/outlet.service';

import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
@@ -28,6 +31,9 @@ import { environment } from '../environments/environment';
StatusBar,
SplashScreen,
MallService,
MenuItemService,
OfferService,
OutletService,
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
],
bootstrap: [AppComponent]


+ 2
- 1
src/app/mall-details/mall-details.page.ts Переглянути файл

@@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Mall, MallService } from '../services/mall.service';
import { MallService } from '../services/mall.service';
import Mall from '../models/mall';
import { Location } from '@angular/common';

@Component({


+ 2
- 1
src/app/malls/malls.page.ts Переглянути файл

@@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { MallService, Mall } from '../services/mall.service';
import { MallService } from '../services/mall.service';
import Mall from '../models/mall';
import { Router } from '@angular/router';

@Component({


+ 8
- 31
src/app/mocks/malls.ts Переглянути файл

@@ -1,7 +1,8 @@
import Offer from '../models/offer';
import Mall from '../models/mall';
import { OUTLETS } from './outlets';

export const MALLS = [{
export const MALLS = [new Mall({
id: '0001',
name: 'Gopalan Arcade Mall',
address: 'Mysore Road, Bangalore',
@@ -10,25 +11,14 @@ export const MALLS = [{
image_url: 'https://www.gopalanmall.com/images/mall-arcade-01.jpg',
description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
outlets: OUTLETS,
offer_collection: [{
name: 'Food',
offers: [new Offer({
name: 'McDonalds Offer',
description: 'Get 25% offer on you first meal',
coupon_code: 'MCD25F',
})]
}, {
name: 'Shopping',
offers: []
}],
offers: [],
rating: 4.1,
distance: 2,
location: {
latitude: 12.903903292,
longitude: 34.940349039
}
},
{
}), new Mall({
id: '0002',
name: 'Gopalan Cinemas',
address: 'Kenchana Halli',
@@ -37,21 +27,14 @@ export const MALLS = [{
image_url: 'https://www.gopalanmall.com/images/mall-arcade-01.jpg',
description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
outlets: [],
offer_collection: [{
name: 'Food',
offers: []
}, {
name: 'Shopping',
offers: []
}],
offers: [],
rating: 4.5,
distance: 2,
location: {
latitude: 12.903903292,
longitude: 34.940349039
}
},
{
}), new Mall({
id: '0003',
name: 'Gopalan Mall',
address: 'Mysore Road, Bangalore',
@@ -60,17 +43,11 @@ export const MALLS = [{
image_url: 'https://www.gopalanmall.com/images/mall-arcade-01.jpg',
description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
outlets: [],
offer_collection: [{
name: 'Food',
offers: []
}, {
name: 'Shopping',
offers: []
}],
offers: [],
rating: 4.3,
distance: 2,
location: {
latitude: 12.903903292,
longitude: 34.940349039
}
}];
})];

+ 3
- 3
src/app/mocks/menu-items.ts Переглянути файл

@@ -36,7 +36,7 @@ export const MENU_ITEMS_1 = [new MenuItem({
})];

export const MENU_ITEMS_2 = [new MenuItem({
id: '0001',
id: '0004',
name: 'Margherita Pizza',
image_url: 'https://www.cafecoffeeday.com/thelounge/images/ccd-lounge-pizzas-side-1.jpg',
description: 'Cheese pizza topped with tomato sauce, garlic sauce and fresh basil.',
@@ -47,7 +47,7 @@ export const MENU_ITEMS_2 = [new MenuItem({
rating: 3.5,
tags: ['pizza', 'hot']
}), new MenuItem({
id: '0002',
id: '0005',
name: 'Espresso Shot',
image_url: 'https://www.cafecoffeeday.com/thelounge/images/ccd-lounge-classic-hot-bottom.jpg',
description: 'Coffee at its simplest best. Without milk, served with cold water on the side. We call it a simple big-shot.',
@@ -58,7 +58,7 @@ export const MENU_ITEMS_2 = [new MenuItem({
rating: 4.5,
tags: ['hot', 'beverage']
}), new MenuItem({
id: '0003',
id: '0006',
name: 'The Coffee Gola',
image_url: 'https://www.cafecoffeeday.com/thelounge/images/ccd-lounge-Coffetini-Easel-side.jpg',
description: 'The perfect blend of coffee, almonds and a rich vanilla gola. Sure to give you an exotic kulfi experience.',


+ 8
- 0
src/app/mocks/offers.ts Переглянути файл

@@ -0,0 +1,8 @@
import Offer from '../models/offer';

export const OFFERS = [new Offer({
id: '0002',
name: 'McDonalds Offer',
description: 'Get 25% offer on you first meal',
coupon_code: 'MCD25F',
})];

+ 2
- 6
src/app/mocks/outlets.ts Переглянути файл

@@ -1,6 +1,6 @@
import Outlet, { OutletType } from '../models/outlet';
import Offer from '../models/offer';
import { MENU_ITEMS_1, MENU_ITEMS_2 } from './menu-items';
import { OFFERS } from './offers';

export const OUTLETS = [new Outlet({
id: '0001',
@@ -9,11 +9,7 @@ export const OUTLETS = [new Outlet({
description: 'Veg / Non-Veg Food Restaurant',
tags: ['dinner', 'spicy', 'breakfast', 'pork'],
menu_items: MENU_ITEMS_1,
offers: [new Offer({
name: 'McDonalds Offer',
description: 'Get 25% offer on you first meal',
coupon_code: 'MCD25F',
})],
offers: OFFERS,
outlet_type: OutletType.FOOD,
is_bookmarked: false,
rating: 3.5,


+ 72
- 1
src/app/models/mall.ts Переглянути файл

@@ -1,2 +1,73 @@
export class Mall {
import Offer from '../models/offer';
import { CoOrdinates } from '../shared/common-types';
import Outlet from '../models/outlet';

class Mall {
id: string;
name: string;
is_bookmarked: boolean;
is_archived: boolean;
image_url?: string;
description: string;
offers: Array<Offer>;
outlets: Array<Outlet>;
rating: number;
distance: number;
location: CoOrdinates;
address: string;


constructor(initializationObject: any) {
if (!initializationObject.hasOwnProperty('id')) {
throw new Error('Missing id');
}
if (!initializationObject.hasOwnProperty('name')) {
throw new Error('Missing name');
}
if (!initializationObject.hasOwnProperty('is_bookmarked')) {
throw new Error('Missing is_bookmarked');
}
if (!initializationObject.hasOwnProperty('is_archived')) {
throw new Error('Missing is_archived');
}
if (!initializationObject.hasOwnProperty('description')) {
throw new Error('Missing description');
}
if (!initializationObject.hasOwnProperty('offers')) {
throw new Error('Missing offers');
}
if (!initializationObject.hasOwnProperty('outlets')) {
throw new Error('Missing outlets');
}
if (!initializationObject.hasOwnProperty('rating')) {
throw new Error('Missing rating');
}
if (!initializationObject.hasOwnProperty('distance')) {
throw new Error('Missing distance');
}
if (!initializationObject.hasOwnProperty('location')) {
throw new Error('Missing location');
}
if (!initializationObject.hasOwnProperty('address')) {
throw new Error('Missing address');
}

this.id = initializationObject.id;
this.name = initializationObject.name;
this.is_bookmarked = initializationObject.is_bookmarked;
this.is_archived = initializationObject.is_archived;
this.description = initializationObject.description;
this.offers = initializationObject.offers;
this.outlets = initializationObject.outlets;
this.rating = initializationObject.rating;
this.distance = initializationObject.distance;
this.location = initializationObject.location;
this.address = initializationObject.address;

if (initializationObject.hasOwnProperty('image_url')) {
this.image_url = initializationObject.image_url;
}
}
}

export default Mall;

+ 5
- 5
src/app/models/offer.ts Переглянути файл

@@ -1,4 +1,5 @@
class Offer {
id: string;
name: string;
description: string;
coupon_code: string;
@@ -7,6 +8,10 @@ class Offer {
constructor(initializationObject: any) {

// Check if object has the required fields
if (!initializationObject.hasOwnProperty('id')) {
throw new Error('The offer needs a id');
}

if (!initializationObject.hasOwnProperty('name')) {
throw new Error('The offer needs a name');
}
@@ -30,8 +35,3 @@ class Offer {
}

export default Offer;

export type OfferCollection = {
name: string,
offers: Array<Offer>,
};

+ 2
- 1
src/app/outlet-details/outlet-details.page.ts Переглянути файл

@@ -1,7 +1,8 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Location } from '@angular/common';
import { Mall, MallService } from '../services/mall.service';
import { MallService } from '../services/mall.service';
import Mall from '../models/mall';
import CartItem from '../models/cart-item';
import Outlet from '../models/outlet';
import MenuItem from '../models/menu-item';


+ 1
- 18
src/app/services/mall.service.ts Переглянути файл

@@ -1,24 +1,7 @@
import { Injectable } from '@angular/core';
import { OfferCollection } from '../models/offer';
import { CoOrdinates } from '../shared/common-types';
import Outlet from '../models/outlet';
import { MALLS } from '../mocks/malls';
import CartItem from '../models/cart-item';

export type Mall = {
id: string,
name: string,
is_bookmarked: boolean,
is_archived: boolean,
image_url?: string,
description: string,
offer_collection: Array<OfferCollection>,
outlets: Array<Outlet>,
rating: number,
distance: number,
location: CoOrdinates,
address: string
};
import Mall from '../models/mall';

@Injectable({
providedIn: 'root'


+ 12
- 0
src/app/services/menu-item.service.spec.ts Переглянути файл

@@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';

import { MenuItemService } from './menu-item.service';

describe('MenuItemService', () => {
beforeEach(() => TestBed.configureTestingModule({}));

it('should be created', () => {
const service: MenuItemService = TestBed.get(MenuItemService);
expect(service).toBeTruthy();
});
});

+ 9
- 0
src/app/services/menu-item.service.ts Переглянути файл

@@ -0,0 +1,9 @@
import { Injectable } from '@angular/core';

@Injectable({
providedIn: 'root'
})
export class MenuItemService {

constructor() { }
}

+ 12
- 0
src/app/services/offer.service.spec.ts Переглянути файл

@@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';

import { OfferService } from './offer.service';

describe('OfferService', () => {
beforeEach(() => TestBed.configureTestingModule({}));

it('should be created', () => {
const service: OfferService = TestBed.get(OfferService);
expect(service).toBeTruthy();
});
});

+ 9
- 0
src/app/services/offer.service.ts Переглянути файл

@@ -0,0 +1,9 @@
import { Injectable } from '@angular/core';

@Injectable({
providedIn: 'root'
})
export class OfferService {

constructor() { }
}

+ 12
- 0
src/app/services/outlet.service.spec.ts Переглянути файл

@@ -0,0 +1,12 @@
import { TestBed } from '@angular/core/testing';

import { OutletService } from './outlet.service';

describe('OutletService', () => {
beforeEach(() => TestBed.configureTestingModule({}));

it('should be created', () => {
const service: OutletService = TestBed.get(OutletService);
expect(service).toBeTruthy();
});
});

+ 9
- 0
src/app/services/outlet.service.ts Переглянути файл

@@ -0,0 +1,9 @@
import { Injectable } from '@angular/core';

@Injectable({
providedIn: 'root'
})
export class OutletService {

constructor() { }
}

Завантаження…
Відмінити
Зберегти