Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to rc.5 and use ng2-webpack-config #268

Merged
merged 7 commits into from
Sep 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ npm-debug.log
/demo/**/*.js
/demo/**/*.js.map
/demo/**/*.d.ts
!/demo/custom-typings.d.ts
/components/**/*.js
/components/**/*.js.map
/components/**/*.d.ts
Expand Down
29 changes: 29 additions & 0 deletions .ng2-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';
var pkg = require('./package.json');

module.exports = {
// metadata
title: pkg.description,
baseUrl: '/',
// root folder name
src: 'demo',
dist: 'demo-build',
htmlIndexes: ['index.html'],
// karma bundle src
spec: './spec-bundle.js',
// webpack entry
entry: {
polyfills: './demo/polyfills.ts',
vendor: './demo/vendor.ts',
main: './demo/index.ts'
},
commonChunks: {
name: ['polyfills', 'vendor'].reverse()
},
// webpack alias
alias: {},
copy: [
{from: 'demo/favicon.ico', to: 'favicon.ico'},
{from: 'demo/assets', to: 'assets'}
]
};
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ typings

# testing
karma.conf.js
test.bundle.js
spec-bundle.js
coverage

# demo build
Expand Down
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ language: node_js
node_js:
- "6"

before_install: npm i -g npm@latest

script:
- npm run flow.install:typings
- npm test

after_success:
- ./node_modules/.bin/codecov
- ./node_modules/.bin/codecov -f coverage/coverage-final.json

addons:
# sauce labs tunel connector (read more https://docs.travis-ci.com/user/sauce-connect/ )
Expand Down
8 changes: 4 additions & 4 deletions components/ng-table-directives.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {NgTableComponent} from './table/ng-table.component';
import {NgTableFilteringDirective} from './table/ng-table-filtering.directive';
import {NgTablePagingDirective} from './table/ng-table-paging.directive';
import {NgTableSortingDirective} from './table/ng-table-sorting.directive';
import { NgTableComponent } from './table/ng-table.component';
import { NgTableFilteringDirective } from './table/ng-table-filtering.directive';
import { NgTablePagingDirective } from './table/ng-table-paging.directive';
import { NgTableSortingDirective } from './table/ng-table-sorting.directive';
export const NG_TABLE_DIRECTIVES = [NgTableComponent, NgTableFilteringDirective, NgTablePagingDirective, NgTableSortingDirective];
15 changes: 15 additions & 0 deletions components/ng-table-module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { NgTableComponent } from './table/ng-table.component';
import { NgTableFilteringDirective } from './table/ng-table-filtering.directive';
import { NgTablePagingDirective } from './table/ng-table-paging.directive';
import { NgTableSortingDirective } from './table/ng-table-sorting.directive';

@NgModule({
imports: [CommonModule],
declarations: [NgTableComponent, NgTableFilteringDirective, NgTablePagingDirective, NgTableSortingDirective],
exports: [NgTableComponent, NgTableFilteringDirective, NgTablePagingDirective, NgTableSortingDirective]
})
export class Ng2TableModule {
}
2 changes: 1 addition & 1 deletion components/table/ng-table-filtering.directive.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Directive, EventEmitter, ElementRef, Renderer, HostListener, Input, Output} from '@angular/core';
import { Directive, EventEmitter, ElementRef, Renderer, HostListener, Input, Output } from '@angular/core';

// import {setProperty} from 'angular2/ts/src/core/forms/directives/shared';
function setProperty(renderer:Renderer, elementRef:ElementRef, propName:string, propValue:any):void {
Expand Down
2 changes: 1 addition & 1 deletion components/table/ng-table-paging.directive.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Directive, EventEmitter, Input, Output, HostListener} from '@angular/core';
import { Directive, EventEmitter, Input, Output, HostListener } from '@angular/core';

@Directive({selector: '[ngTablePaging]'})
export class NgTablePagingDirective {
Expand Down
2 changes: 1 addition & 1 deletion components/table/ng-table-sorting.directive.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Directive, EventEmitter, Input, Output, HostListener} from '@angular/core';
import { Directive, EventEmitter, Input, Output, HostListener } from '@angular/core';

@Directive({selector: '[ngTableSorting]'})
export class NgTableSortingDirective {
Expand Down
42 changes: 34 additions & 8 deletions components/table/ng-table.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
import {it, expect, describe, inject, addProviders} from '@angular/core/testing';
import {ComponentFixture} from '@angular/compiler/testing';
import {NgTableComponent} from './ng-table.component';
import { Component } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { Ng2TableModule } from '../ng-table-module';

const html = ``;

describe('Component: ng2-table', () => {
let fixture:ComponentFixture<any>;
let context:TestTableComponent;
let element:any;
let clean:any;

describe('Directive: FileSelectDirective', () => {
beforeEach(() => {
addProviders([NgTableComponent]);
TestBed.configureTestingModule({
declarations: [TestTableComponent],
imports: [Ng2TableModule]
});
TestBed.overrideComponent(TestTableComponent, {set: {template: html}});
fixture = TestBed.createComponent(TestTableComponent);
context = fixture.componentInstance;
element = fixture.nativeElement.querySelector('#c1');
clean = fixture.nativeElement.querySelector('#c2');
fixture.detectChanges();
});

it('should be true', () => {
expect(true).toBe(true);
});
it('should be fine', inject([NgTableComponent], (fixture:ComponentFixture<NgTableComponent>) => {
expect(fixture).not.toBeNull();
}));
});

@Component({
selector: 'table-test',
template: ''
})

class TestTableComponent {
}
7 changes: 2 additions & 5 deletions components/table/ng-table.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {Component, EventEmitter, Input, Output} from '@angular/core';
import {CORE_DIRECTIVES, NgClass} from '@angular/common';
import {NgTableSortingDirective} from './ng-table-sorting.directive';
import { Component, EventEmitter, Input, Output } from '@angular/core';

@Component({
selector: 'ng-table',
Expand All @@ -22,8 +20,7 @@ import {NgTableSortingDirective} from './ng-table-sorting.directive';
</tr>
</tbody>
</table>
`,
directives: [NgTableSortingDirective, NgClass, CORE_DIRECTIVES]
`
})
export class NgTableComponent {
// Table values
Expand Down
4 changes: 2 additions & 2 deletions components/table/readme.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
### Usage
```typescript
import {NG_TABLE_DIRECTIVES} from 'ng2-table/ng2-table';
import { Ng2TableModule } from 'ng2-table/ng2-table';
```
or if you want to import specified plugins (Table component is required, the others are optional):
```typescript
import {NgTableComponent, NgTableFilteringDirective, NgTablePagingDirective, NgTableSortingDirective} from 'ng2-table/ng2-table';
import { NgTableComponent, NgTableFilteringDirective, NgTablePagingDirective, NgTableSortingDirective } from 'ng2-table/ng2-table';
```
in this case, don't forget to include all of the imported entities to the option `directives` in your component

Expand Down
39 changes: 39 additions & 0 deletions demo/components/table-section.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<br>
<section id="{{name.toLowerCase()}}">
<div class="row"><h1>{{name}}<small>(<a href="{{src}}">src</a>)</small></h1></div>

<hr>

<div class="row"><div class="col-md-12" [innerHTML]="titleDoc"></div></div>

<div class="row">
<h2>Example</h2>
<div class="card card-block panel panel-default panel-body">
<table-demo></table-demo>
</div>
</div>

<br>

<div class="row">
<tabset>
<tab heading="Markup">
<div class="card card-block panel panel-default panel-body">
<pre class="language-html"><code class="language-html" [innerHTML]="html"></code></pre>
</div>
</tab>
<tab heading="TypeScript">
<div class="card card-block panel panel-default panel-body">
<pre class="language-typescript"><code class="language-typescript" [innerHTML]="ts"></code></pre>
</div>
</tab>
</tabset>
</div>

<br>

<div class="row">
<h2>API</h2>
<div class="card card-block panel panel-default panel-body" [innerHTML]="doc"></div>
</div>
</section>
57 changes: 8 additions & 49 deletions demo/components/table-section.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {Component} from '@angular/core';
import {CORE_DIRECTIVES} from '@angular/common';

import {TableDemoComponent} from './table/table-demo';

let name = 'Table';
let src = 'https://github.com/valor-software/ng2-table/blob/master/components/table/table.ts';
import { Component } from '@angular/core';
// webpack html imports
let doc = require('../../components/table/readme.md');
let titleDoc = require('../../components/table/title.md');
Expand All @@ -13,48 +7,13 @@ let html = require('!!prismjs?lang=markup!./table/table-demo.html');

@Component({
selector: 'table-section',
template: `
<br>
<section id="${name.toLowerCase()}">
<div class="row"><h1>${name}<small>(<a href="${src}">src</a>)</small></h1></div>

<hr>

<div class="row"><div class="col-md-12">${titleDoc}</div></div>

<div class="row">
<h2>Example</h2>
<div class="card card-block panel panel-default panel-body">
<table-demo></table-demo>
</div>
</div>

<br>

<div class="row">
<tabset>
<tab heading="Markup">
<div class="card card-block panel panel-default panel-body">
<pre class="language-html"><code class="language-html">${html}</code></pre>
</div>
</tab>
<tab heading="TypeScript">
<div class="card card-block panel panel-default panel-body">
<pre class="language-typescript"><code class="language-typescript">${ts}</code></pre>
</div>
</tab>
</tabset>
</div>

<br>

<div class="row">
<h2>API</h2>
<div class="card card-block panel panel-default panel-body">${doc}</div>
</div>
</section>
`,
directives: [TableDemoComponent, CORE_DIRECTIVES]
templateUrl: './demo/components/table-section.html'
})
export class TableSectionComponent {
public name:string = 'Table';
public src:string = 'https://github.com/valor-software/ng2-table/tree/master/components/table';
public ts:string = ts;
public doc:string = doc;
public titleDoc:string = titleDoc;
public html:string = html;
}
2 changes: 1 addition & 1 deletion demo/components/table/table-data.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const TableData: Array<any> = [
export const TableData:Array<any> = [
{
'name': 'Victoria Cantrell',
'position': 'Integer Corporation',
Expand Down
4 changes: 2 additions & 2 deletions demo/components/table/table-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
(tableChanged)="onChangeTable(config)"/>

<ng-table [config]="config.sorting"
(tableChanged)="onChangeTable(config)"
[rows]="rows" [columns]="columns">
(tableChanged)="onChangeTable(config)"
[rows]="rows" [columns]="columns">
</ng-table>
<pagination *ngIf="config.paging"
class="pagination-sm"
Expand Down
11 changes: 3 additions & 8 deletions demo/components/table/table-demo.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import {Component, OnInit} from '@angular/core';
import {CORE_DIRECTIVES, NgClass, NgIf} from '@angular/common';
import {FORM_DIRECTIVES} from '@angular/forms';
import {PAGINATION_DIRECTIVES} from 'ng2-bootstrap/ng2-bootstrap';
import {NG_TABLE_DIRECTIVES} from '../../../ng2-table';
import {TableData} from './table-data';
import { Component, OnInit } from '@angular/core';
import { TableData } from './table-data';

// webpack html imports
let template = require('./table-demo.html');

@Component({
selector: 'table-demo',
template: template,
directives: [NG_TABLE_DIRECTIVES, PAGINATION_DIRECTIVES, NgClass, NgIf, CORE_DIRECTIVES, FORM_DIRECTIVES]
template
})
export class TableDemoComponent implements OnInit {
public rows:Array<any> = [];
Expand Down
1 change: 1 addition & 0 deletions demo/custom-typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare const ENV:string;
34 changes: 34 additions & 0 deletions demo/demo.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Component } from '@angular/core';

let gettingStarted = require('./getting-started.md');

@Component({
selector: 'app',
template: `
<main class="bd-pageheader">
<div class="container">
<h1>ng2-table</h1>
<p>Native Angular2 directives for Table</p>
<a class="btn btn-primary" href="https://github.com/valor-software/ng2-table">View on GitHub</a>
<div class="row">
<div class="col-lg-1"><iframe src="https://ghbtns.com/github-btn.html?user=valor-software&repo=ng2-table&type=star&count=true" frameborder="0" scrolling="0" width="170px" height="20px"></iframe></div>
<div class="col-lg-1"><iframe src="https://ghbtns.com/github-btn.html?user=valor-software&repo=ng2-table&type=fork&count=true" frameborder="0" scrolling="0" width="170px" height="20px"></iframe></div>
</div>
</div>
</main>

<div class="container">
<section id="getting-started">${gettingStarted}</section>

<table-section class="col-md-12"></table-section>
</div>

<footer class="footer">
<div class="container">
<p class="text-muted text-center"><a href="https://github.com/valor-software/ng2-table">ng2-table</a> is maintained by <a href="https://github.com/valor-software">valor-software</a>.</p>
</div>
</footer>
`
})
export class DemoComponent {
}
Loading