Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/Dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
leoriofrio committed Aug 15, 2020
2 parents 9ffae06 + 639d952 commit ce7dce2
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 8 deletions.
5 changes: 5 additions & 0 deletions src/app/app.keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,9 @@ export const FilesType = {

export const ValidatesPattern = {
alphanumeric: "[a-zA-Z0-9\\s]+"
}

export declare interface TransformColumns {

namesToProps(json): any;
}
21 changes: 19 additions & 2 deletions src/app/configuration/client/client.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 } from '../../app.keys';
import { ClientColumns, TransformColumns } from '../../app.keys';
import { COLUMNS_CLIENT } from './clientColumns';
import { ProjectComponent } from '../../shared/components/project/project.component';
import { ExcelExportService } from '../../shared/service/export-excel.service';
Expand All @@ -14,7 +14,7 @@ const dataVal = require('./client.json');
templateUrl: './client.component.html',
styleUrls: ['./client.component.scss']
})
export class ClientComponent implements OnInit {
export class ClientComponent implements OnInit, TransformColumns {
@ViewChild(ProjectComponent, { static: true }) child: ProjectComponent;

public data = dataVal;
Expand Down Expand Up @@ -44,6 +44,23 @@ export class ClientComponent implements OnInit {

public onJsonData(jsonData) {
console.log('data de Cliente es', jsonData);
let jsonFinal = this.namesToProps(jsonData);
console.log('jsonFinal', jsonFinal);
}

public namesToProps(json){
return json.map(key => {
let res = {};
res[`${ClientColumns.ID.prop}`] = key[ClientColumns.ID.name];
res[`${ClientColumns.COD_CLIENT.prop}`] = key[ClientColumns.COD_CLIENT.name];
res[`${ClientColumns.PROVINCE.prop}`] = key[ClientColumns.PROVINCE.name];
res[`${ClientColumns.CITY.prop}`] = key[ClientColumns.CITY.name];
res[`${ClientColumns.NAME.prop}`] = key[ClientColumns.NAME.name];
res[`${ClientColumns.NICKNAME.prop}`] = key[ClientColumns.NICKNAME.name];
res[`${ClientColumns.TYPE.prop}`] = key[ClientColumns.TYPE.name];
res[`${ClientColumns.STATUS.prop}`] = key[ClientColumns.STATUS.name];
return res;
});
}

}
32 changes: 30 additions & 2 deletions 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 } from '../../app.keys';
import { ClientColumns, CollegesColumns } 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 All @@ -14,7 +14,7 @@ const dataVal = require('./colleges.json');
templateUrl: './colleges.component.html',
styleUrls: ['./colleges.component.css']
})
export class CollegesComponent implements OnInit {
export class CollegesComponent implements OnInit, TransformColumns {
@ViewChild(ProjectComponent, {static: true}) child: ProjectComponent;

public data = dataVal;
Expand Down Expand Up @@ -46,6 +46,34 @@ export class CollegesComponent implements OnInit {

public onJsonData(jsonData){
console.log('data de Colleges es', jsonData);
let jsonFinal = this.namesToProps(jsonData);
console.log('jsonFinal', jsonFinal);
}

public namesToProps(json){
return json.map(key => {
let res = {};
res[`${CollegesColumns.ID.prop}`] = key[CollegesColumns.ID.name];
res[`${CollegesColumns.COD_SANTILLANA.prop}`] = key[CollegesColumns.COD_SANTILLANA.name];
res[`${CollegesColumns.COD_INSTITUTO.prop}`] = key[CollegesColumns.COD_INSTITUTO.name];
res[`${CollegesColumns.STATUS.prop}`] = key[CollegesColumns.STATUS.name];
res[`${CollegesColumns.DELEGATE_TEXT.prop}`] = key[CollegesColumns.DELEGATE_TEXT.name];
res[`${CollegesColumns.DELEGATE_ENGLISH.prop}`] = key[CollegesColumns.DELEGATE_ENGLISH.name];
res[`${CollegesColumns.DELEGATE_SHARED.prop}`] = key[CollegesColumns.DELEGATE_SHARED.name];
res[`${CollegesColumns.PROVINCE.prop}`] = key[CollegesColumns.PROVINCE.name];
res[`${CollegesColumns.CANTON.prop}`] = key[CollegesColumns.CANTON.name];
res[`${CollegesColumns.PARISH.prop}`] = key[CollegesColumns.PARISH.name];

res[`${CollegesColumns.NAME.prop}`] = key[CollegesColumns.NAME.name];
res[`${CollegesColumns.ADDRESS.prop}`] = key[CollegesColumns.ADDRESS.name];
res[`${CollegesColumns.NIVEL.prop}`] = key[CollegesColumns.NIVEL.name];
res[`${CollegesColumns.TYPE.prop}`] = key[CollegesColumns.TYPE.name];
res[`${CollegesColumns.SCHOOL_SYSTEM.prop}`] = key[CollegesColumns.SCHOOL_SYSTEM.name];
res[`${CollegesColumns.MODALITY.prop}`] = key[CollegesColumns.MODALITY.name];
res[`${CollegesColumns.SCHOOL_DAY.prop}`] = key[CollegesColumns.SCHOOL_DAY.name];
res[`${CollegesColumns.REGION_ID.prop}`] = key[CollegesColumns.REGION_ID.name];
return res;
});
}

}
27 changes: 23 additions & 4 deletions src/app/configuration/product/product.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 { ProductColumns, TypeRegion } from '../../app.keys';
import { ProductColumns, TypeRegion, TransformColumns } from '../../app.keys';
import { ProjectComponent } from '../../shared/components/project/project.component';
import { COLUMNS_PRODUCT, COLUMNS_PINNED_TOP_DATA } from './productColumns';
import { ExcelExportService } from '../../shared/service/export-excel.service';
Expand All @@ -15,7 +15,7 @@ import { ProductService } from 'src/app/shared/service/product.service';
templateUrl: './product.component.html',
styleUrls: ['./product.component.scss']
})
export class ProductComponent implements OnInit {
export class ProductComponent implements OnInit, TransformColumns {
@ViewChild(ProjectComponent, {static: true}) child: ProjectComponent;


Expand Down Expand Up @@ -79,12 +79,31 @@ export class ProductComponent implements OnInit {
}

public onJsonData(jsonData){
console.log('data de Producto es', JSON.stringify(jsonData));
return this.productService.createProduct('1', JSON.stringify(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 getDataProduct() {
return this.productService.getProductByRegion(TypeRegion.SIERRA);
}

public namesToProps(json){
return json.map(key => {
let res = {};
res[`${ProductColumns.ID.prop}`] = key[ProductColumns.ID.name];
res[`${ProductColumns.COD.prop}`] = key[ProductColumns.COD.name];
res[`${ProductColumns.SUBLINE.prop}`] = key[ProductColumns.SUBLINE.name];
res[`${ProductColumns.DESCRIPTION.prop}`] = key[ProductColumns.DESCRIPTION.name];
res[`${ProductColumns.SERIE.prop}`] = key[ProductColumns.SERIE.name];
res[`${ProductColumns.NIVEL.prop}`] = key[ProductColumns.NIVEL.name];
res[`${ProductColumns.DEGREE.prop}`] = key[ProductColumns.DEGREE.name];
res[`${ProductColumns.BUSINESS_LINE.prop}`] = key[ProductColumns.BUSINESS_LINE.name];
res[`${ProductColumns.ISBN.prop}`] = key[ProductColumns.ISBN.name];
res[`${ProductColumns.REGION.prop}`] = key[ProductColumns.REGION.name];
return res;
});
}

}
1 change: 1 addition & 0 deletions src/app/shared/service/import-excel.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ export class ExcelImportService {
}
});
}

}

0 comments on commit ce7dce2

Please sign in to comment.