import { Component, OnInit, NgZone } from '@angular/core';
import { EditService, ToolbarService, PageService } from '@syncfusion/ej2-angular-grids';
import { orderData } from './data';
import { RecipeService } from '../shared/recipe.service';
import { HttpClient } from '@angular/common/http';
import { Ajax } from '@syncfusion/ej2-base';
@Component({
selector: 'app-editproduct',
templateUrl: './editproduct.component.html',
styleUrls: ['./editproduct.component.scss'],
providers: [ToolbarService, EditService, PageService]
})
export class EditproductComponent implements OnInit {
constructor(private recipeService:RecipeService,private ngZone: NgZone,private http:HttpClient,) {
}
ngOnInit() {
this.data=[{
image: [
'https://firebasestorage.googleapis.com/v0/b/adfproductimages.appspot.com/o/kurti%2F110.0.jpg?alt=media',
'https://firebasestorage.googleapis.com/v0/b/adfproductimages.appspot.com/o/kurti%2F110.1.jpg?alt=media'
],
_id: 5e861a1a6a38a126ac30fbd4,
productId: 121,
title: 'ADF FASHION',
description: 'Black Printed Kurti',
price: 999,
discount: 10,
ProductDetails: {
Fabric: 'Heavy rayon',
Color: 'Black',
Neck: 'V Neck',
Pattern: 'Printed',
SleeveLength: '3/4 sleeve',
FabricCare: 'gentle machine wash',
Description: 'Long frill concept'
},
category: 'kurti',
size: 'xxl'
},
{
image: [
'https://firebasestorage.googleapis.com/v0/b/adfproductimages.appspot.com/o/kurti%2F112.0.jpg?alt=media'
],
_id: 5e861a596a38a126ac30fbd5,
productId: 122,
title: 'ADF FASHION',
description: 'Marroon Printed Kurti',
price: 999,
discount: 10,
ProductDetails: {
Fabric: 'Heavy rayon',
Color: 'marroon',
size: 'xxl',
Neck: 'V Neck',
Pattern: 'Printed',
SleeveLength: '3/4 sleeve',
FabricCare: 'gentle machine wash',
Description: 'Long frill concept'
},
category: 'kurti'
},
{
image: [
'https://firebasestorage.googleapis.com/v0/b/adfproductimages.appspot.com/o/kurti%2F113.0.jpg?alt=media',
'https://firebasestorage.googleapis.com/v0/b/adfproductimages.appspot.com/o/kurti%2F113.1.jpg?alt=media'
],
_id: 5e861ae66a38a126ac30fbd6,
productId: 123,
title: 'ADF FASHION',
description: 'Light Green Printed Kurti',
price: 999,
discount: 10,
ProductDetails: {
Fabric: 'Heavy rayon',
Color: 'Light Green',
size: 'xxl',
Neck: 'V Neck',
Pattern: 'Printed',
SleeveLength: '3/4 sleeve',
FabricCare: 'gentle machine wash',
Description: 'Long frill concept'
},
category: 'kurti'
},
{
image: [
'https://firebasestorage.googleapis.com/v0/b/adfproductimages.appspot.com/o/kurti%2F114.1.jpg?alt=media',
'https://firebasestorage.googleapis.com/v0/b/adfproductimages.appspot.com/o/kurti%2F114.2.jpg?alt=media'
],
_id: 5e861b266a38a126ac30fbd7,
productId: 124,
title: 'ADF FASHION',
description: 'Dark Green Printed Kurti',
price: 999,
discount: 10,
ProductDetails: {
Fabric: 'Heavy rayon',
Color: 'Dark Green',
size: 'xxl',
Neck: 'V Neck',
Pattern: 'Printed',
SleeveLength: '3/4 sleeve',
FabricCare: 'gentle machine wash',
Description: 'Long frill concept'
},
category: 'kurti'
},
{
image: [
'https://firebasestorage.googleapis.com/v0/b/adfproductimages.appspot.com/o/kurti%2F115.jpg?alt=media',
'https://firebasestorage.googleapis.com/v0/b/adfproductimages.appspot.com/o/kurti%2F115.1.jpg?alt=media'
],
_id: 5e861b576a38a126ac30fbd8,
productId: 125,
title: 'ADF FASHION',
description: 'Yellow Printed Kurti',
price: 999,
discount: 10,
ProductDetails: {
Fabric: 'Heavy rayon',
Color: 'Yellow',
size: 'xxl',
Neck: 'V Neck',
Pattern: 'Printed',
SleeveLength: '3/4 sleeve',
FabricCare: 'gentle machine wash',
Description: 'Long frill concept'
},
category: 'kurti'
}]
this.editSettings = { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Batch' };
this.toolbar = ['Add', 'Delete', 'Update', 'Cancel'];
this.productidrules = { required: true, number: true, minLength: [this.customFn, 'ProductId Exists...'] };
this.descriptionrules = { required: true };
this.pricerules = { required: true };
this.editparams = { params: { popupHeight: '300px' }};
this.pageSettings = {pageCount: 5};
}
AllProductString:Object[]=[];
public data:Object[];
public editSettings: Object;
public toolbar: string[];
public productidrules: Object;
public descriptionrules: Object;
public pricerules: Object;
public editparams: Object;
public pageSettings: Object;
public value = 'value';
public flag=true;
public customFn: (args) => boolean = (args) => {
let ajax = new Ajax("/api/products/checkProduct", "POST", true);
ajax.send(JSON.stringify({ Id : "111" })).then( //
(value) => {
this.flag = false;
});
return true;
};
}
}