Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Commit fee28ff

Browse files
committed
fix: DT v2 bug fixes
1 parent 27511c8 commit fee28ff

File tree

52 files changed

+284
-153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+284
-153
lines changed

DEVELOPER.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,18 @@ To test schematics, you will need to setup `verdaccio`, publish the library loca
159159
- Run `npm adduser --registry=http://localhost:4873`
160160
- Give a username, password and an email address to create an account in `verdaccio`.
161161

162-
4. Now, publish the library to `verdaccio` by running the command:
162+
4. Make your changes in the project.
163163

164-
`npm publish angular-datatables --registry http://localhost:4873`
164+
5. Run `npm run build:lib` to build the library and `ng add` functionality related code.
165+
166+
6. Now, publish the library to `verdaccio` by running the command:
167+
168+
```sh
169+
# Make sure you compiled the library first!
170+
# `npm run build:lib`
171+
cd dist/lib
172+
npm publish --registry http://localhost:4873
173+
```
165174

166175
5. Create an empty Angular project like:
167176

angular.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
"build": {
154154
"builder": "@angular-devkit/build-angular:ng-packagr",
155155
"options": {
156-
"project": "lib/ng-package.json"
156+
"project": "lib/ng-package.prod.json"
157157
},
158158
"configurations": {
159159
"production": {

demo/README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@ Run `npm start` for a dev server. Navigate to `http://localhost:4200/`. The app
88

99
## Build
1010

11-
Run `npm run build:prod` to build the project. The build artifacts will be stored in the `dist/` directory.
11+
Run `npm run demo:build:prod` to build the project. The build artifacts will be stored in the `dist/` directory.
1212

1313
## Further help
1414

1515
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
1616

1717
## Using the current version of angular-datatables
1818

19-
If you need to check if the currenct version of angular-datatables still works with the demo, you can use [node-install-local](https://github.com/nicojs/node-install-local):
19+
If you need to check if the currenct version of angular-datatables still works with the demo, simply follow the instructions below:
20+
21+
> We use [linklocal](https://npmjs.org/package/linklocal) to link library with demo app.
2022
2123
```bash
2224
cd /path/to/angular-datatables
23-
npm run build
24-
cd demo/
25-
rm -rf node-modules/angular-datatables
26-
install-local ..
2725
npm start
28-
# Application will run on localhost:4200
26+
# The application will first build library (under dist/lib),
27+
# copy it to demo/node_modules and run the app on localhost:4200
2928
```

demo/src/app/advanced/custom-range-search.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { CustomRangeSearchComponent } from './custom-range-search.component';
1111
import { FormsModule } from '@angular/forms';
1212

1313

14-
let fixture: ComponentFixture<CustomRangeSearchComponent>, component: CustomRangeSearchComponent = null;
14+
let fixture: ComponentFixture<CustomRangeSearchComponent>, component: null| CustomRangeSearchComponent = null;
1515

1616
describe('CustomRangeSearchComponent', () => {
1717
beforeEach(() => {
@@ -24,7 +24,7 @@ describe('CustomRangeSearchComponent', () => {
2424
imports: [
2525
AppRoutingModule,
2626
RouterTestingModule,
27-
DataTablesModule.forRoot(),
27+
DataTablesModule,
2828
HttpClientModule,
2929
MarkdownModule.forRoot(
3030
{

demo/src/app/advanced/custom-range-search.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export class CustomRangeSearchComponent implements OnDestroy, OnInit {
1717
mdTSV2 = 'assets/docs/advanced/custom-range/source-ts-dtv2.md';
1818

1919
@ViewChild(DataTableDirective, {static: false})
20-
datatableElement: DataTableDirective;
21-
min: number;
22-
max: number;
20+
datatableElement!: DataTableDirective;
21+
min!: number;
22+
max!: number;
2323

2424
dtOptions: Config = {};
2525

demo/src/app/advanced/dt-instance.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</button>
66
</p>
77
<blockquote>
8-
The DataTable instance ID is: {{ $any((datatableElement?.dtInstance | async)?.table().node())['id'] }}
8+
The DataTable instance ID is: {{ $any((datatableElement?.dtInstance | async)?.table()?.node())['id'] }}
99
</blockquote>
1010
<table datatable [dtOptions]="dtOptions" class="row-border hover"></table>
1111
</ng-template>

demo/src/app/advanced/dt-instance.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { FormsModule } from '@angular/forms';
1111
import { DtInstanceComponent } from './dt-instance.component';
1212

1313

14-
let fixture: ComponentFixture<DtInstanceComponent>, component: DtInstanceComponent = null;
14+
let fixture: ComponentFixture<DtInstanceComponent>, component: null| DtInstanceComponent = null;
1515

1616
describe('DtInstanceComponent', () => {
1717
beforeEach(() => {
@@ -24,7 +24,7 @@ describe('DtInstanceComponent', () => {
2424
imports: [
2525
AppRoutingModule,
2626
RouterTestingModule,
27-
DataTablesModule.forRoot(),
27+
DataTablesModule,
2828
HttpClientModule,
2929
MarkdownModule.forRoot(
3030
{

demo/src/app/advanced/dt-instance.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ export class DtInstanceComponent implements OnInit {
1616
mdTSV2 = 'assets/docs/advanced/dt-instance/source-ts-dtv2.md';
1717

1818
@ViewChild(DataTableDirective, {static: false})
19-
datatableElement: DataTableDirective;
19+
datatableElement: DataTableDirective|undefined;
2020

2121
dtOptions: Config = {};
2222

23-
displayToConsole(datatableElement: DataTableDirective): void {
23+
displayToConsole(datatableElement: DataTableDirective | undefined): void {
24+
if (!datatableElement) return;
2425
datatableElement.dtInstance.then(dtInstance => console.log(dtInstance));
2526
}
2627

demo/src/app/advanced/individual-column-filtering.component.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { IndividualColumnFilteringComponent } from './individual-column-filterin
1212
import { Api } from 'datatables.net';
1313

1414

15-
let fixture: ComponentFixture<IndividualColumnFilteringComponent>, component: IndividualColumnFilteringComponent = null;
15+
let fixture: ComponentFixture<IndividualColumnFilteringComponent>, component: null| IndividualColumnFilteringComponent = null;
1616

1717
function applyValueToInput(inputElement: HTMLInputElement, value: string, table: Api) {
1818
inputElement.value = value;
@@ -32,7 +32,7 @@ describe('IndividualColumnFilteringComponent', () => {
3232
imports: [
3333
AppRoutingModule,
3434
RouterTestingModule,
35-
DataTablesModule.forRoot(),
35+
DataTablesModule,
3636
HttpClientModule,
3737
MarkdownModule.forRoot(
3838
{
@@ -72,9 +72,9 @@ describe('IndividualColumnFilteringComponent', () => {
7272
const instance = await dir.dtInstance;
7373

7474
const inputFields = Array.from(fixture.nativeElement.querySelectorAll('input')) as HTMLInputElement[];
75-
const inputFieldID = inputFields.find(e => e.name == "search-id");
76-
const inputFieldFirstName = inputFields.find(e => e.name == "search-first-name");
77-
const inputFieldLastName = inputFields.find(e => e.name == "search-last-name");
75+
const inputFieldID = inputFields.find(e => e.name == "search-id")!;
76+
const inputFieldFirstName = inputFields.find(e => e.name == "search-first-name")!;
77+
const inputFieldLastName = inputFields.find(e => e.name == "search-last-name")!;
7878

7979
// # Test 1
8080
applyValueToInput(inputFieldID, '113', instance);

demo/src/app/advanced/individual-column-filtering.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class IndividualColumnFilteringComponent implements OnInit, AfterViewInit
1616
mdTSV2 = 'assets/docs/advanced/indi-col-filter/source-ts-dtv2.md';
1717

1818
@ViewChild(DataTableDirective, {static: false})
19-
datatableElement: DataTableDirective;
19+
datatableElement!: DataTableDirective;
2020

2121
dtOptions: Config = {};
2222

0 commit comments

Comments
 (0)