Skip to content

Commit

Permalink
changes for each row pathc or post
Browse files Browse the repository at this point in the history
  • Loading branch information
jogaec22 committed Sep 1, 2020
1 parent a9ee865 commit ff5a45b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/app/configuration/colleges/colleges.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import { Component, OnInit, ViewChild } from '@angular/core';
import { ClientColumns, CollegesColumns } from '../../app.keys';
import { ClientColumns, CollegesColumns, TransformColumns } from '../../app.keys';
import { COLUMNS_COLLEGES } from './collegesColumns';
import { ProjectComponent } from '../../shared/components/project/project.component';
import { ExcelExportService } from '../../shared/service/export-excel.service';
Expand Down
14 changes: 9 additions & 5 deletions src/app/configuration/product/product.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { COLUMNS_PRODUCT, COLUMNS_PINNED_TOP_DATA } from './productColumns';
import { ExcelExportService } from '../../shared/service/export-excel.service';
import * as _ from 'lodash';
import { ProductService } from 'src/app/shared/service/product.service';
import { ExcelImportService } from 'src/app/shared/service/import-excel.service';

//const dataVal = require('./product.json');

Expand All @@ -31,6 +32,7 @@ export class ProductComponent implements OnInit, TransformColumns {

constructor(
private excelExportService: ExcelExportService,
private excelImportService: ExcelImportService,
private productService: ProductService,
) {
const self = this;
Expand Down Expand Up @@ -78,11 +80,13 @@ export class ProductComponent implements OnInit, TransformColumns {
}
}

public onJsonData(jsonData){
console.log('data de Producto es', JSON.stringify(jsonData));
let jsonFinal = this.namesToProps(jsonData);
console.log('jsonFinal', jsonFinal);
return this.productService.createProduct('1', JSON.stringify(jsonFinal));
public onJsonData(jsonData){
//console.log('data de Producto es', JSON.stringify(jsonData));
const jsonFinal = this.namesToProps(jsonData);
const postPatch = this.excelImportService.setDataToPostOrPatch(jsonFinal);
console.log('POST', postPatch.POST);
console.log('PATCH', postPatch.PATCH);
//return this.productService.createProduct('1', JSON.stringify(jsonFinal));
}

public getDataProduct() {
Expand Down
11 changes: 11 additions & 0 deletions src/app/shared/service/import-excel.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,15 @@ export class ExcelImportService {
});
}

public setDataToPostOrPatch(json){
/*const a = json.filter( j => j.id );
const b = json.filter( j => !j.id );
console.log('a es', a);
console.log('b es', b);*/
return {
POST: json.filter( j => !j.id ),
PATCH: json.filter( j => j.id )
}
}

}
2 changes: 1 addition & 1 deletion src/app/shared/service/product.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class ProductService {
}

public createProduct(id: string, product: any): Observable<any> {
debugger;
//debugger;
const url = this.baseUrl+`product/Sierra`;
return this.http.post<any>(url, product, httpOptions);
}
Expand Down

0 comments on commit ff5a45b

Please sign in to comment.