Commit eb3e7ed3 authored by prumde's avatar prumde

Changes for Subcategory and Category


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@174329 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 69e9b7cf
......@@ -25,6 +25,13 @@ export class SubCategory {
console.log('comp this.resourceUrl[' + this.resourceUrl + ']');
}
}
export class Item {
public itemCode: string = '';
public descr: string = '';
public shDescr: string = '';
}
export const MockTrendings: Category[] = [
new Category('food', 'Kabab Special', 'Authentic Home Made recipe','',''),
new Category('tour', 'Into the blue', 'Scuba diving in deep blue ocean','',''),
......
......@@ -2,6 +2,7 @@
padding: 0;
margin: 0;
padding-top: 100px;
padding-top: 50px;
background-color: #FFF;
}
.ecm-section-info {
......
......@@ -2,7 +2,8 @@
<section class="categories-section">
<div class="row row-category">
<div class="ecm-section-info">
<span class="ecm-section-info-title">Categories</span> <span class="ecm-section-info-subhead">Explore top AuthenticRegional Foods, Outings, Celebrations around {{selectedPlace}}</span>
<span class="ecm-section-info-title">Categories</span>
<span class="ecm-section-info-subhead">Explore top Authentic Regional Foods, Outings, Celebrations around {{selectedPlace}}</span>
</div>
<div class="small-12 medium-6 large-4 column end "*ngFor="let _category of categories">
<ecm-card [category]="_category"></ecm-card>
......
import { Component, OnInit } from '@angular/core';
import { ECMCategoryService } from './ecm-category.service';
import { ECMCard } from '../ecm-card/card-model';
import { Category, SubCategory } from '../ecm-category/category-model';
import { Category, SubCategory } from './category-model';
@Component({
selector: 'ecm-category',
templateUrl: './ecm-category.component.html',
......@@ -12,42 +12,17 @@ export class ECMCategoryComponent implements OnInit {
errorMessage: string;
selectedPlace = 'Mumbai';
categories: Category[];
// cat_cards: ECMCard[];
constructor(public categoryService: ECMCategoryService) { }
ngOnInit() {
this.getCategories();
}
/*
getCategories(): void {
this.categoryService.getCategories().then( categories => {
this.categories = categories;
this.cat_cards = [];
for ( let i = 0; i < this.categories.length ; ++i ) {
let img = 'assets/images/' + this.categories[i].type + '.png';
let info_img = 'assets/images/' + this.categories[i].type + '_icon.png';
let info_title = this.categories[i].title;
let info_subhead = this.categories[i].descr;
this.cat_cards.push( new ECMCard( img, info_img, info_title, info_subhead, false ) );
}
}
);
}
*/
getCategories() {
this.categoryService.getCategories().subscribe(
categories => {
this.categories = categories;
console.log('comp categories[' + JSON.stringify( categories ) + '] \n this.categories[' + JSON.stringify( this.categories ) + ']');
/*
this.cat_cards = [];
for ( let i = 0; i < this.categories.length ; ++i ) {
let img = 'assets/images/category/' + this.categories[i].catCode + '.png';
let info_img = 'assets/images/category/' + this.categories[i].catCode + '_icon.png';
let info_title = this.categories[i].catDescr;
let info_subhead = this.categories[i].catShortDescr;
this.cat_cards.push( new ECMCard( img, info_img, info_title, info_subhead, false ) );
}
*/
},
error => {
this.errorMessage = <any>error;
......@@ -55,15 +30,4 @@ export class ECMCategoryComponent implements OnInit {
});
}
/*
addCategory (name: string) {
if (!name) { return; }
this.categoryService.addCategory(name)
.subscribe(
hero => this.categories.push(category),
error => this.errorMessage = <any>error);
}
*/
}
......@@ -4,53 +4,72 @@ import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/map';
import { Category, SubCategory } from '../ecm-category/category-model';
import { Category, SubCategory, Item } from '../ecm-category/category-model';
@Injectable()
export class ECMCategoryService {
private categoriesUrl = '/ecm/service/category'; // URL to web service
private subCategoriesUrl = '/ecm/service/category'; // URL to web service
private categoryUrl = '/ecm/service/category'; // URL to web service
constructor (private http: Http) {}
/*
getCategories(): Promise<Category[]> {
return Promise.resolve(MockCategories);
getCategories(): Observable<Category[]> {
let headers = new Headers( { 'Content-Type': 'application/json' });
let options = new RequestOptions( { headers: headers });
return this.http.get( this.categoryUrl, options )
.map( this.extractData )
.catch( this.handleError );
}
getSubCategories( catCode: string ): Observable<SubCategory[]> {
let subCategoriesUrl = this.categoryUrl + '/' + catCode + '/list';
let headers = new Headers( { 'Content-Type': 'application/json' });
let options = new RequestOptions( { headers: headers });
return this.http.get( subCategoriesUrl, options )
.map( this.extractData )
.catch( this.handleError );
}
getCategoriesSlowly(): Promise<Category[]> {
return new Promise(resolve => {
// Simulate server latency with 2 second delay
setTimeout(() => resolve(this.getCategories()), 2000);
});
getCategory (catCode : string): Observable<Category> {
let categoryUrl = this.categoryUrl + '/' + catCode;
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.http.get(categoryUrl, options)
.map(this.extractData)
.catch(this.handleError);
}
constructor() { }
*/
getCategories (): Observable<Category[]> {
getSubCategory (scatCode : string): Observable<SubCategory> {
let subCategoryUrl = this.categoryUrl + '/list/' + scatCode;
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.http.get(this.categoriesUrl, options)
return this.http.get(subCategoryUrl, options)
.map(this.extractData)
.catch(this.handleError);
}
getSubCategories (scatCode : string): Observable<SubCategory[]> {
this.subCategoriesUrl = this.subCategoriesUrl + '/' + scatCode + '/list';
getItems (scatCode : string): Observable<Item[]> {
let itemsUrl = this.categoryUrl + '/itemlist/' + scatCode ;
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.http.get(this.subCategoriesUrl, options)
return this.http.get(itemsUrl, options)
.map(this.extractData)
.catch(this.handleError);
}
private extractData(res: Response) {
let body = res.json();
console.log('comp categories[' + JSON.stringify(body) + ']');
console.log('extractData[' + JSON.stringify(body) + ']');
return body || { };
}
......@@ -68,15 +87,4 @@ export class ECMCategoryService {
return Observable.throw(errMsg);
}
/*
addCategory (name: string): Observable<Hero> {
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
return this.http.post(this.categoriesUrl, { name }, options)
.map(this.extractData)
.catch(this.handleError);
}
*/
}
.subcategories-section {
padding: 0;
margin: 0;
padding-top: 100px;
padding-top: 50px;
background-color: #FFF;
}
.ecm-section-info {
padding: 10px;
}
.ecm-section-info-title {
font-size: 26px;
color: #444;
display: block;
}
.ecm-section-info-subhead {
font-size: 16px;
color: #888;
display: block;
}
.end {
padding-top: 15px;
padding-bottom: 50px;
}
.row.row-subcategory {
max-width: 72rem;
}
<div *ngIf="subcategories">
<section class="subcategories-section">
<div class="row row-subcategory">
<div class="ecm-section-info">
<span class="ecm-section-info-title">{{category.shDescr}}</span>
<span class="ecm-section-info-subhead">{{category.descr}}</span>
</div>
<div class="small-12 medium-6 large-4 column end "*ngFor="let _subcategory of subcategories">
<ecm-card [subcategory]="_subcategory"></ecm-card>
</div>
</div>
</section>
</div>
<div *ngIf="items">
<section class="subcategories-section">
<div class="row row-subcategory">
<div class="ecm-section-info">
<span class="ecm-section-info-title">{{subcategory.shDescr}}</span>
<span class="ecm-section-info-subhead">{{subcategory.descr}}</span>
</div>
<div class="small-12 medium-6 large-4 column end "*ngFor="let _item of items">
<ecm-item-caption [itemData]="_item"></ecm-item-caption>
</div>
</div>
</section>
</div>
import { Component, OnInit } from '@angular/core';
import { Item, SubCategory, Category } from './category-model';
import { ECMCategoryService } from './ecm-category.service';
import { Router, ActivatedRoute } from '@angular/router';
@Component({
selector: 'ecm-sub-category',
templateUrl: './ecm-sub-category.component.html',
styleUrls: ['./ecm-sub-category.component.css'],
providers: [ECMCategoryService]
})
export class EcmSubCategoryComponent implements OnInit {
private subcategories: SubCategory[];
private items: Item[];
private category : Category;
private subcategory : SubCategory;
constructor(private route: ActivatedRoute, private router:Router,public subcategoryService: ECMCategoryService) { }
ngOnInit() {
this.route.params.subscribe( params => {
//let id: number = +params['id']; // (+) converts string 'id' to a number
// In a real app: dispatch action to load the details here.
let viewType = params['type'];
let viewKey = params['key'];
console.log( 'ngOnInit viewType[' + viewType + ']viewKey[' + viewKey + ']' );
this.openView(viewType, viewKey);
});
}
openView(viewType:string, viewKey:string){
if( viewType == 'SUB_CATEGORY')
{
this.getCategory( viewKey );
}
else if( viewType == 'ITEMS')
{
this.getSubCategory( viewKey );
}
}
getCategory( catCode: string ) {
this.subcategoryService.getCategory( catCode ).subscribe(
category => {
this.category = category;
console.log( 'comp catCode[' + catCode + '] \n this.category[' + JSON.stringify( this.category ) + ']' );
this.getSubCategories( catCode );
},
);
}
getSubCategory( scatCode: string ) {
this.subcategoryService.getSubCategory( scatCode ).subscribe(
subcategory => {
this.subcategory = subcategory;
console.log( 'comp scatCode[' + scatCode + '] \n this.subcategory[' + JSON.stringify( this.subcategory ) + ']' );
this.getItems( scatCode );
},
);
}
getSubCategories( catCode: string ) {
this.subcategoryService.getSubCategories( catCode ).subscribe(
subcategories => {
this.subcategories = subcategories;
this.items = null;
console.log( 'comp catCode[' + catCode + '] \n this.subcategories[' + JSON.stringify( this.subcategories ) + ']' );
},
);
}
getItems( scatCode: string ) {
this.subcategoryService.getItems( scatCode ).subscribe(
items => {
this.items = items;
this.subcategories = null;
console.log( 'comp scatCode[' + scatCode + '] \n this.items[' + JSON.stringify( this.items ) + ']' );
},
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment