New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

angular2-generic-table

Package Overview
Dependencies
Maintainers
3
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular2-generic-table - npm Package Compare versions

Comparing version

to
1.0.0-rc.9

generic-table/components/generic-table.component.d.ts

19

CHANGELOG.md
Release History
---------------
## [Unreleased]
# [1.0.0-rc.9] - 2016-12-10
### Added
- Ability to show text when no data is return or when filter and/or search has no matching results, see issue #24
- Pagination component, see issue #2
- Ability to pass default options to table, [see docs](https://github.com/hjalmers/angular2-generic-table)
- Loading state for table rows waiting for data (only when lazy loading), use `tr.row-loading` to style loading rows
- Table info component, [see examples](https://hjalmers.github.io/angular2-generic-table/examples)
### Fixed
- Searching table now updates total number of pages correctly
- Searching function now supports åäö and other strange characters
- Handling of null values, see issues #32 and #35
### Breaking changes
- Lazy loading will by default not cache data, override using `gt-options` and set `cache` to `true`
- `GtPagination` has been replaced with `GtInfo` and properties have changed names, [see docs](https://github.com/hjalmers/angular2-generic-table)
- Highlighting of search terms when using `[gtLazy]=true` has changed, set search terms in your server response, [see docs](https://github.com/hjalmers/angular2-generic-table)
- `GtTexts` now uses camel case instead of dash case so in case you've changed the default texts you need to change from `no_match` to `noMatch` etc.
- Event property names have changed from `page` to `currentPage` and from `pageLength` to `recordLength` to match names used by `GtInformation`
# [1.0.0-rc.8] - 2016-11-30

@@ -6,0 +25,0 @@ ### Fixed

0

generic-table/components/gt-expanding-row.component.d.ts

@@ -0,0 +0,0 @@ import { EventEmitter, Type } from '@angular/core';

@@ -0,0 +0,0 @@ import { ComponentFactoryResolver, EventEmitter, OnInit, Type, ViewContainerRef } from '@angular/core';

export declare class GenericTableModule {
}

12

generic-table/generic-table.module.js

@@ -11,3 +11,3 @@ "use strict";

};
var generic_table_component_1 = require('./generic-table.component');
var generic_table_component_1 = require('./components/generic-table.component');
var gt_render_pipe_1 = require('./pipes/gt-render.pipe');

@@ -25,2 +25,4 @@ var gt_visible_pipe_1 = require("./pipes/gt-visible.pipe");

var component_anchor_directive_1 = require('./directives/component-anchor.directive');
var gt_pagination_component_1 = require('./components/gt-pagination.component');
var gt_table_info_component_1 = require('./components/gt-table-info.component');
var GenericTableModule = (function () {

@@ -34,2 +36,3 @@ function GenericTableModule() {

generic_table_component_1.GenericTableComponent,
gt_pagination_component_1.GtPaginationComponent,
gt_visible_pipe_1.GtVisiblePipe,

@@ -43,6 +46,9 @@ gt_render_pipe_1.GtRenderPipe,

gt_expanding_row_component_1.GtExpandingRowComponent,
gt_search_pipe_1.GtSearchPipe
gt_search_pipe_1.GtSearchPipe,
gt_pagination_component_1.PaginationPipe,
gt_table_info_component_1.GtTableInfoComponent,
gt_table_info_component_1.TableInfoPipe
],
imports: [common_1.CommonModule],
exports: [generic_table_component_1.GenericTableComponent],
exports: [generic_table_component_1.GenericTableComponent, gt_pagination_component_1.GtPaginationComponent, gt_table_info_component_1.GtTableInfoComponent],
entryComponents: [],

@@ -49,0 +55,0 @@ providers: [],

@@ -0,0 +0,0 @@ import { GtRow } from './gt-row';

"use strict";
//# sourceMappingURL=gt-config-field.js.map

@@ -0,0 +0,0 @@ export interface GtConfigSetting {

"use strict";
//# sourceMappingURL=gt-config-setting.js.map
import { GtConfigField } from './gt-config-field';
import { GtConfigSetting } from './gt-config-setting';
import { GtPagingInfo } from './gt-paging-info';
import { GtRow } from './gt-row';
import { GtInformation } from './gt-information';
export interface GtConfig<R extends GtRow> {

@@ -9,3 +9,3 @@ settings: GtConfigSetting[];

data?: R[];
paging?: GtPagingInfo;
info?: GtInformation;
}
"use strict";
//# sourceMappingURL=gt-config.js.map
export interface GtInformation {
rowLength: number;
currentPage: number;
pagesTotal: number;
filter: boolean | Object;
refresh: any;
filter?: Object;
pageCurrent: number;
pageNext?: number;
pagePrevious?: number;
pageTotal?: number;
recordFrom?: number;
recordTo?: number;
recordLength: number;
recordsAll: number;
recordsAfterFilter: number;
recordsAfterSearch: number;
searchTerms?: string;
}
"use strict";
//# sourceMappingURL=gt-information.js.map
"use strict";
//# sourceMappingURL=gt-paging-info.js.map
export interface GtRow {
isOpen?: boolean;
}
"use strict";
//# sourceMappingURL=gt-row.js.map
export interface GtTexts {
loading: string;
noData: string;
noMatchingData: string;
tableInfo: string;
tableInfoAfterSearch: string;
}
"use strict";
//# sourceMappingURL=gt-texts.js.map

@@ -0,0 +0,0 @@ import { PipeTransform } from '@angular/core';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { PipeTransform } from '@angular/core';

@@ -0,0 +0,0 @@ "use strict";

@@ -1,4 +0,5 @@

import { PipeTransform } from '@angular/core';
import { PipeTransform, EventEmitter } from '@angular/core';
import { GtInformation } from '../interfaces/gt-information';
export declare class GtChunkPipe implements PipeTransform {
transform(array: any[], chunkSize: number, page: number, refreshPageArray: boolean, refreshData: number): any[];
transform(array: any[], gtInfo: GtInformation, chunkSize: number, page: number, refreshPageArray: boolean, refreshData: number, gtEvent: EventEmitter<any>): any[];
}

@@ -15,3 +15,3 @@ "use strict";

}
GtChunkPipe.prototype.transform = function (array, chunkSize, page, refreshPageArray, refreshData) {
GtChunkPipe.prototype.transform = function (array, gtInfo, chunkSize, page, refreshPageArray, refreshData, gtEvent) {
//console.log('chunk array');

@@ -21,7 +21,11 @@ //console.log(array,chunkSize,page);

return array;
var R = [];
var pages = [];
for (var i = 0, len = array.length; i < len; i += chunkSize)
R.push(array.slice(i, i + chunkSize));
//console.log(R)
return R[page - 1];
pages.push(array.slice(i, i + chunkSize));
gtInfo.pageTotal = pages.length;
setTimeout(function () { return gtEvent.emit({
name: 'gt-info',
value: gtInfo
}); }, 0);
return pages[page - 1];
};

@@ -28,0 +32,0 @@ GtChunkPipe = __decorate([

import { PipeTransform } from '@angular/core';
import { GtInformation } from '../interfaces/gt-information';
export declare class GtFilterPipe implements PipeTransform {
transform(array: any[], filterBy: Object, gt: {
filtered: number | boolean;
refresh: any;
}, refreshFilter: boolean, refreshData: number): any[];
transform(allRows: any[], filterBy: Object, gtInfo: GtInformation, refreshFilter: boolean, refreshData: number): any[];
}

@@ -16,14 +16,15 @@ "use strict";

//@Output() filterInfo = new EventEmitter();
GtFilterPipe.prototype.transform = function (array, filterBy, gt, refreshFilter, refreshData) {
//console.log(array,filterBy);
GtFilterPipe.prototype.transform = function (allRows, filterBy, gtInfo, refreshFilter, refreshData) {
//console.log(allRows,filterBy);
//console.log('filter by');
if (!Array.isArray(array) || !filterBy) {
//gt.filtered = false;
var length_1 = array === null ? 0 : array.length;
gt.refresh(length_1, gt);
return array;
gtInfo.recordsAll = allRows.length;
if (!Array.isArray(allRows) || !filterBy) {
//gtInfo.filtered = false;
var length_1 = allRows === null ? 0 : allRows.length;
gtInfo.recordsAfterFilter = length_1;
return allRows;
}
var output = [];
for (var i = 0; i < array.length; i++) {
var rowObject = array[i];
for (var i = 0; i < allRows.length; i++) {
var rowObject = allRows[i];
var match = true;

@@ -43,4 +44,3 @@ for (var property in filterBy) {

}
//gt.filtered = output.length; //.emit(output.length);
gt.refresh(output.length, gt);
gtInfo.recordsAfterFilter = output.length; //.emit(output.length);
return output;

@@ -47,0 +47,0 @@ };

@@ -0,0 +0,0 @@ import { PipeTransform } from '@angular/core';

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { PipeTransform } from '@angular/core';

@@ -108,7 +108,10 @@ "use strict";

};
if (highlight && searchString && this.getProperty(settings, key).search !== false) {
columnObject.renderValue = fieldSetting.render && typeof fieldSetting.render === 'function' ? this.highlight(fieldSetting.render(row), searchString) : this.highlight(row[key], searchString);
if (loading && row[key].indexOf('undefined') != -1) {
columnObject.renderValue = "";
}
else if (highlight && searchString && this.getProperty(settings, key).search !== false) {
columnObject.renderValue = fieldSetting.render && typeof fieldSetting.render === 'function' ? this.highlight(fieldSetting.render(row), searchString) : this.highlight(row[key] !== null ? row[key] : "", searchString);
}
else {
columnObject.renderValue = fieldSetting.render && typeof fieldSetting.render === 'function' ? this.sanitizer.bypassSecurityTrustHtml(fieldSetting.render(row)) : row[key];
columnObject.renderValue = fieldSetting.render && typeof fieldSetting.render === 'function' ? this.sanitizer.bypassSecurityTrustHtml(fieldSetting.render(row)) : row[key] !== null ? row[key] : "";
}

@@ -115,0 +118,0 @@ if (fieldSetting.click && typeof fieldSetting.click === 'function') {

@@ -5,6 +5,7 @@ import { PipeTransform } from '@angular/core';

import { GtConfigSetting } from '../interfaces/gt-config-setting';
import { GtInformation } from '../interfaces/gt-information';
export declare class GtSearchPipe<R extends GtRow> implements PipeTransform {
/** Return property */
private getProperty;
transform(allRows: any, searchTerms: string, settings: Array<GtConfigSetting>, fields: Array<GtConfigField<R>>, refreshData: number): any;
transform(allRows: any, searchTerms: string, gtInfo: GtInformation, settings: Array<GtConfigSetting>, fields: Array<GtConfigField<R>>, refreshData: number): any;
}

@@ -23,3 +23,10 @@ "use strict";

}
GtSearchPipe.prototype.transform = function (allRows, searchTerms, settings, fields, refreshData) {
GtSearchPipe.prototype.transform = function (allRows, searchTerms, gtInfo, settings, fields, refreshData) {
// if no search terms are defined...
if (!searchTerms || searchTerms.replace(/"/g, "").length === 0) {
// ...return all rows
var length_1 = allRows === null ? 0 : allRows.length;
gtInfo.recordsAfterSearch = length_1;
return allRows;
}
var searchFunction = {};

@@ -46,10 +53,5 @@ var fieldsTemp = [];

}
// if no search terms are defined...
if (!searchTerms || searchTerms.replace(/"/g, "").length === 0) {
// ...return all rows
return allRows;
}
var filteredRows = [];
searchTerms = typeof searchTerms === 'undefined' ? '' : searchTerms;
var searchTermsArray = searchTerms.toLowerCase().match(/"[^"]+"|[\w]+/g);
var searchTermsArray = searchTerms.toLowerCase().match(/(".*"|[^\s]+)/g);
for (var i = 0; i < allRows.length; i++) {

@@ -75,2 +77,4 @@ var row = allRows[i];

}
gtInfo.recordsAfterSearch = filteredRows.length;
//gtInfo.refresh(filteredRows.length,gt);
return filteredRows;

@@ -77,0 +81,0 @@ };

@@ -0,0 +0,0 @@ import { PipeTransform } from '@angular/core';

@@ -0,0 +0,0 @@ "use strict";

export * from './generic-table/components/gt-expanding-row.component';
export * from './generic-table/generic-table.component';
export * from './generic-table/components/generic-table.component';
export * from './generic-table/components/gt-table-info.component';
export * from './generic-table/components/gt-pagination.component';
export * from './generic-table/generic-table.module';

@@ -8,4 +10,4 @@ export * from './generic-table/interfaces/gt-config';

export * from './generic-table/interfaces/gt-information';
export * from './generic-table/interfaces/gt-paging-info';
export * from './generic-table/interfaces/gt-row';
export * from './generic-table/interfaces/gt-texts';
export * from './generic-table/interfaces/gt-options';

@@ -6,4 +6,6 @@ "use strict";

__export(require('./generic-table/components/gt-expanding-row.component'));
__export(require('./generic-table/generic-table.component'));
__export(require('./generic-table/components/generic-table.component'));
__export(require('./generic-table/components/gt-table-info.component'));
__export(require('./generic-table/components/gt-pagination.component'));
__export(require('./generic-table/generic-table.module'));
//# sourceMappingURL=index.js.map
{
"name": "angular2-generic-table",
"version": "1.0.0-rc.8",
"version": "1.0.0-rc.9",
"license": "MIT",

@@ -16,3 +16,3 @@ "repository": {

"e2e": "protractor",
"build": "tsc -p src",
"build": "tsc --declaration -p src",
"clean": "rimraf index* generic-table",

@@ -19,0 +19,0 @@ "prepublish": "npm run build",

@@ -1,2 +0,2 @@

import { GenericTableComponent } from './generic-table.component';
import { GenericTableComponent } from './components/generic-table.component';
import {GtRenderPipe} from './pipes/gt-render.pipe';

@@ -14,3 +14,6 @@ import {GtVisiblePipe} from "./pipes/gt-visible.pipe";

import { ComponentAnchorDirective } from './directives/component-anchor.directive';
import {GtPaginationComponent, PaginationPipe} from './components/gt-pagination.component';
import {GtTableInfoComponent, TableInfoPipe} from './components/gt-table-info.component';
@NgModule({

@@ -20,2 +23,3 @@ declarations: [

GenericTableComponent,
GtPaginationComponent,
GtVisiblePipe,

@@ -29,6 +33,9 @@ GtRenderPipe,

GtExpandingRowComponent,
GtSearchPipe
GtSearchPipe,
PaginationPipe,
GtTableInfoComponent,
TableInfoPipe
],
imports: [CommonModule],
exports: [GenericTableComponent],
exports: [GenericTableComponent,GtPaginationComponent,GtTableInfoComponent],
entryComponents: [],

@@ -35,0 +42,0 @@ providers: [],

@@ -0,0 +0,0 @@ import { GtRow } from './gt-row';

@@ -0,0 +0,0 @@ export interface GtConfigSetting {

import { GtConfigField } from './gt-config-field';
import { GtConfigSetting } from './gt-config-setting';
import { GtPagingInfo } from './gt-paging-info';
import { GtRow } from './gt-row';
import {GtInformation} from './gt-information';

@@ -10,3 +10,3 @@ export interface GtConfig<R extends GtRow> {

data?: R[];
paging?: GtPagingInfo;
info?: GtInformation;
}
export interface GtInformation {
rowLength: number;
currentPage: number;
pagesTotal: number;
filter: boolean | Object;
refresh: any;
filter?: Object;
pageCurrent: number;
pageNext?: number;
pagePrevious?: number;
pageTotal?: number;
recordFrom?:number;
recordTo?:number;
recordLength: number;
recordsAll: number;
recordsAfterFilter: number;
recordsAfterSearch: number;
searchTerms?: string;
}
export interface GtRow {
isOpen?: boolean;
}
export interface GtTexts {
loading: string;
noData: string;
noMatchingData: string;
tableInfo: string;
tableInfoAfterSearch: string;
}

@@ -0,0 +0,0 @@ import { Pipe, PipeTransform } from '@angular/core';

@@ -0,0 +0,0 @@ import { Pipe, PipeTransform } from '@angular/core';

@@ -1,2 +0,3 @@

import { Pipe, PipeTransform } from '@angular/core';
import {Pipe, PipeTransform, EventEmitter} from '@angular/core';
import {GtInformation} from '../interfaces/gt-information';

@@ -8,13 +9,16 @@ @Pipe({

transform(array: any[], chunkSize: number, page: number, refreshPageArray: boolean, refreshData: number): any[] {
transform(array: any[],gtInfo:GtInformation, chunkSize: number, page: number, refreshPageArray: boolean, refreshData: number, gtEvent: EventEmitter<any>): any[] {
//console.log('chunk array');
//console.log(array,chunkSize,page);
if(!Array.isArray(array)) return array;
var R = [];
for (var i=0,len=array.length; i<len; i+=chunkSize)
R.push(array.slice(i,i+chunkSize));
//console.log(R)
return R[page-1];
let pages = [];
for (let i=0,len=array.length; i<len; i+=chunkSize)
pages.push(array.slice(i,i+chunkSize));
gtInfo.pageTotal = pages.length;
setTimeout(()=>gtEvent.emit({
name:'gt-info',
value:gtInfo
}),0);
return pages[page-1];
}
}
import {Pipe, PipeTransform, EventEmitter, Output} from '@angular/core';
import {GtInformation} from '../interfaces/gt-information';

@@ -9,18 +10,19 @@ @Pipe({

transform(array: any[], filterBy: Object, gt: { filtered: number | boolean, refresh: any }, refreshFilter: boolean, refreshData: number): any[] {
//console.log(array,filterBy);
transform(allRows: any[], filterBy: Object, gtInfo:GtInformation, refreshFilter: boolean, refreshData: number): any[] {
//console.log(allRows,filterBy);
//console.log('filter by');
gtInfo.recordsAll = allRows.length;
if(!Array.isArray(array) || !filterBy) {
//gt.filtered = false;
if(!Array.isArray(allRows) || !filterBy) {
//gtInfo.filtered = false;
let length = array === null ? 0:array.length;
gt.refresh(length,gt);
return array;
let length = allRows === null ? 0:allRows.length;
gtInfo.recordsAfterFilter = length;
return allRows;
}
let output = [];
for(let i = 0; i < array.length; i++) {
for(let i = 0; i < allRows.length; i++) {
let rowObject = array[i];
let rowObject = allRows[i];
let match = true;

@@ -36,3 +38,2 @@

}
// do stuff
}

@@ -45,4 +46,3 @@ }

}
//gt.filtered = output.length; //.emit(output.length);
gt.refresh(output.length,gt);
gtInfo.recordsAfterFilter = output.length; //.emit(output.length);
return output;

@@ -49,0 +49,0 @@ }

@@ -0,0 +0,0 @@ import { Pipe, PipeTransform } from '@angular/core';

@@ -149,6 +149,8 @@ import {

if (highlight && searchString && this.getProperty(settings,key).search !== false){
columnObject.renderValue = fieldSetting.render && typeof fieldSetting.render === 'function' ? this.highlight(fieldSetting.render(row),searchString):this.highlight(row[key],searchString);
if(loading && row[key].indexOf('undefined') != -1){
columnObject.renderValue = "";
} else if (highlight && searchString && this.getProperty(settings,key).search !== false){
columnObject.renderValue = fieldSetting.render && typeof fieldSetting.render === 'function' ? this.highlight(fieldSetting.render(row),searchString):this.highlight(row[key] !== null ? row[key]:"",searchString);
} else {
columnObject.renderValue = fieldSetting.render && typeof fieldSetting.render === 'function' ? this.sanitizer.bypassSecurityTrustHtml(fieldSetting.render(row)):row[key];
columnObject.renderValue = fieldSetting.render && typeof fieldSetting.render === 'function' ? this.sanitizer.bypassSecurityTrustHtml(fieldSetting.render(row)):row[key] !== null ? row[key]:"";
}

@@ -155,0 +157,0 @@

@@ -5,2 +5,3 @@ import { Pipe, PipeTransform } from '@angular/core';

import {GtConfigSetting} from '../interfaces/gt-config-setting';
import {GtInformation} from '../interfaces/gt-information';

@@ -22,4 +23,13 @@

transform(allRows: any, searchTerms: string,settings: Array<GtConfigSetting>, fields: Array<GtConfigField<R>>, refreshData: number): any {
transform(allRows: any, searchTerms: string,gtInfo:GtInformation,settings: Array<GtConfigSetting>, fields: Array<GtConfigField<R>>, refreshData: number): any {
// if no search terms are defined...
if(!searchTerms || searchTerms.replace(/"/g,"").length === 0){
// ...return all rows
let length = allRows === null ? 0:allRows.length;
gtInfo.recordsAfterSearch = length;
return allRows;
}
let searchFunction: any = {};

@@ -53,12 +63,5 @@ let fieldsTemp: Array<any> = [];

// if no search terms are defined...
if(!searchTerms || searchTerms.replace(/"/g,"").length === 0){
// ...return all rows
return allRows;
}
let filteredRows: Array<any> = [];
searchTerms = typeof searchTerms === 'undefined' ? '':searchTerms;
const searchTermsArray = searchTerms.toLowerCase().match(/"[^"]+"|[\w]+/g);
const searchTermsArray = searchTerms.toLowerCase().match(/(".*"|[^\s]+)/g);

@@ -88,4 +91,6 @@ for(let i=0; i<allRows.length; i++){

}
gtInfo.recordsAfterSearch = filteredRows.length;
//gtInfo.refresh(filteredRows.length,gt);
return filteredRows;
}
}

@@ -0,0 +0,0 @@ import { Pipe, PipeTransform } from '@angular/core';

export * from './generic-table/components/gt-expanding-row.component';
export * from './generic-table/generic-table.component';
export * from './generic-table/components/generic-table.component';
export * from './generic-table/components/gt-table-info.component';
export * from './generic-table/components/gt-pagination.component';
export * from './generic-table/generic-table.module';

@@ -8,4 +10,4 @@ export * from './generic-table/interfaces/gt-config';

export * from './generic-table/interfaces/gt-information';
export * from './generic-table/interfaces/gt-paging-info';
export * from './generic-table/interfaces/gt-row';
export * from './generic-table/interfaces/gt-texts';
export * from './generic-table/interfaces/gt-options';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet