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

refactor(module:st): remove deprecated events #281

Merged
merged 2 commits into from
Nov 17, 2018
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
12 changes: 6 additions & 6 deletions docs/upgrade-v2.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ e.g:
| `[isPageIndexReset]` | `page` | `indexReset` | √ | - | - |
| `[toTopInChange]` | `page` | `toTop` | √ | - | - |
| `[toTopOffset]` | `page` | `toTopOffset` | √ | - | - |
| `(checkboxChange)` | `(change)` | - | √ | | Error reminder |
| `(radioChange)` | `(change)` | - | √ | | Error reminder |
| `(sortChange)` | `(change)` | - | √ | | Error reminder |
| `(filterChange)` | `(change)` | - | √ | | Error reminder |
| `(rowClick)` | `(change)` | - | √ | | Error reminder |
| `(rowDblClick)` | `(change)` | - | √ | | Error reminder |
| `(checkboxChange)` | `(change)` | - | √ | × | Error reminder |
| `(radioChange)` | `(change)` | - | √ | × | Error reminder |
| `(sortChange)` | `(change)` | - | √ | × | Error reminder |
| `(filterChange)` | `(change)` | - | √ | × | Error reminder |
| `(rowClick)` | `(change)` | - | √ | × | Error reminder |
| `(rowDblClick)` | `(change)` | - | √ | × | Error reminder |

> A demo [#diff](https://github.com/ng-alain/ng-alain/pull/673/files#diff-f573fc0900f21b377dac432f1668c584L164)

Expand Down
12 changes: 6 additions & 6 deletions docs/upgrade-v2.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ ng-alain 2.0 启用全新的 [ng-alain 组织](https://github.com/ng-alain/),
| `[isPageIndexReset]` | `page` | `indexReset` | √ | - | - |
| `[toTopInChange]` | `page` | `toTop` | √ | - | - |
| `[toTopOffset]` | `page` | `toTopOffset` | √ | - | - |
| `(checkboxChange)` | `(change)` | - | √ | - | 过期提醒 |
| `(radioChange)` | `(change)` | - | √ | - | 过期提醒 |
| `(sortChange)` | `(change)` | - | √ | - | 过期提醒 |
| `(filterChange)` | `(change)` | - | √ | - | 过期提醒 |
| `(rowClick)` | `(change)` | - | √ | - | 过期提醒 |
| `(rowDblClick)` | `(change)` | - | √ | - | 过期提醒 |
| `(checkboxChange)` | `(change)` | - | √ | × | 过期提醒 |
| `(radioChange)` | `(change)` | - | √ | × | 过期提醒 |
| `(sortChange)` | `(change)` | - | √ | × | 过期提醒 |
| `(filterChange)` | `(change)` | - | √ | × | 过期提醒 |
| `(rowClick)` | `(change)` | - | √ | × | 过期提醒 |
| `(rowDblClick)` | `(change)` | - | √ | × | 过期提醒 |

> 一个示例说明 [#diff](https://github.com/ng-alain/ng-alain/pull/673/files#diff-f573fc0900f21b377dac432f1668c584L164)

Expand Down
6 changes: 0 additions & 6 deletions packages/abc/table/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ Property | Description | Type | Default
`[expand]` | Whether current column include expand icon | `TemplateRef<void>` | -
`(change)` | Events | `EventEmitter<STChange>` | -
`(error)` | Error event | `EventEmitter<STError>` | -
(deprecated)`(sortChange)` | Sort event | `EventEmitter` | -
(deprecated)`(checkboxChange)` | Checkbox event | `EventEmitter` | -
(deprecated)`(radioChange)` | Radio event | `EventEmitter` | -
(deprecated)`(filterChange)` | Filter event | `EventEmitter` | -
(deprecated)`(rowClick)` | Rows click event | `EventEmitter<STRowClick>` | -
(deprecated)`(rowDblClick)` | Rows double click event | `EventEmitter<STRowClick>` | -

### Methods

Expand Down
6 changes: 0 additions & 6 deletions packages/abc/table/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ config: STConfig
`[expand]` | 当前列是否包含展开按钮,当数据源中包括 `expand` 表示展开状态 | `TemplateRef<void>` | -
`(change)` | 变化时回调,包括:`pi`、`ps`、`checkbox`、`radio`、`sort`、`filter`、`click`、`dblClick` 变动 | `EventEmitter<STChange>` | -
`(error)` | 异常时回调 | `EventEmitter<STError>` | -
(deprecated)`(sortChange)` | 排序回调 | `EventEmitter` | -
(deprecated)`(checkboxChange)` | checkbox变化时回调,参数为当前所选清单 | `EventEmitter` | -
(deprecated)`(radioChange)` | radio变化时回调,参数为当前所选 | `EventEmitter` | -
(deprecated)`(filterChange)` | Filter回调 | `EventEmitter` | -
(deprecated)`(rowClick)` | 行单击回调 | `EventEmitter<STRowClick>` | -
(deprecated)`(rowDblClick)` | 行双击回调 | `EventEmitter<STRowClick>` | -

### 组件方法

Expand Down
60 changes: 0 additions & 60 deletions packages/abc/table/table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,52 +237,6 @@ export class STComponent implements AfterViewInit, OnChanges, OnDestroy {

// #endregion

// #region compatible

/**
* checkbox变化时回调,参数为当前所选清单
* @deprecated 使用 `change` 替代
* @deprecated as of v3
*/
@Output()
readonly checkboxChange = new EventEmitter<STData[]>();
/**
* radio变化时回调,参数为当前所选
* @deprecated 使用 `change` 替代
* @deprecated as of v3
*/
@Output()
readonly radioChange = new EventEmitter<STData>();
/**
* 排序回调
* @deprecated 使用 `change` 替代
* @deprecated as of v3
*/
@Output()
readonly sortChange = new EventEmitter<any>();
/**
* 过滤变化时回调
* @deprecated 使用 `change` 替代
* @deprecated as of v3
*/
@Output()
readonly filterChange = new EventEmitter<STColumn>();
/**
* 行单击回调
* @deprecated 使用 `change` 替代
* @deprecated as of v3
*/
@Output()
readonly rowClick = new EventEmitter<STChangeRowClick>();
/**
* 行双击回调
* @deprecated 使用 `change` 替代
* @deprecated as of v3
*/
@Output()
readonly rowDblClick = new EventEmitter<STChangeRowClick>();
//#endregion

constructor(
private cd: ChangeDetectorRef,
private cog: STConfig,
Expand Down Expand Up @@ -457,12 +411,8 @@ export class STComponent implements AfterViewInit, OnChanges, OnDestroy {
const data = { e, item, index };
if (this.rowClickCount === 1) {
this.changeEmit('click', data);
// @deprecated as of v3
this.rowClick.emit(data);
} else {
this.changeEmit('dblClick', data);
// @deprecated as of v3
this.rowDblClick.emit(data);
}
this.rowClickCount = 0;
}, this.rowClickTime);
Expand Down Expand Up @@ -500,8 +450,6 @@ export class STComponent implements AfterViewInit, OnChanges, OnDestroy {
column: col,
};
this.changeEmit('sort', res);
// @deprecated as of v3
this.sortChange.emit(res);
}

clearSort() {
Expand All @@ -516,8 +464,6 @@ export class STComponent implements AfterViewInit, OnChanges, OnDestroy {
col.filter.default = col.filter.menus.findIndex(w => w.checked) !== -1;
this._load();
this.changeEmit('filter', col);
// @deprecated as of v3
this.filterChange.emit(col);
}

_filterConfirm(col: STColumn) {
Expand Down Expand Up @@ -583,8 +529,6 @@ export class STComponent implements AfterViewInit, OnChanges, OnDestroy {
_checkNotify(): this {
const res = this._data.filter(w => !w.disabled && w.checked === true);
this.changeEmit('checkbox', res);
// @deprecated as of v3
this.checkboxChange.emit(res);
return this;
}

Expand All @@ -596,8 +540,6 @@ export class STComponent implements AfterViewInit, OnChanges, OnDestroy {
clearRadio(): this {
this._data.filter(w => w.checked).forEach(item => (item.checked = false));
this.changeEmit('radio', null);
// @deprecated as of v3
this.radioChange.emit(null);
return this;
}

Expand All @@ -606,8 +548,6 @@ export class STComponent implements AfterViewInit, OnChanges, OnDestroy {
this._data.filter(w => !w.disabled).forEach(i => (i.checked = false));
item.checked = checked;
this.changeEmit('radio', item);
// @deprecated as of v3
this.radioChange.emit(item);
return this;
}

Expand Down
81 changes: 22 additions & 59 deletions packages/abc/table/test/table.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ComponentFixture,
fakeAsync,
discardPeriodicTasks,
tick,
} from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { RouterTestingModule } from '@angular/router/testing';
Expand All @@ -32,6 +33,7 @@ import {
STPage,
STRes,
STColumnFilter,
STChange,
} from '../table.interfaces';
import { STModule } from '../table.module';
import { STComponent } from '../table.component';
Expand Down Expand Up @@ -172,7 +174,6 @@ describe('abc: table', () => {
.then(() => {
page.click('.st__checkall');
expect(comp._data.filter(w => w.checked).length).toBe(PS);
expect(context.checkboxChange).toHaveBeenCalled();
page.click('.st__checkall');
expect(comp._data.filter(w => w.checked).length).toBe(0);
done();
Expand Down Expand Up @@ -1235,56 +1236,37 @@ describe('abc: table', () => {
});

describe('[row events]', () => {
beforeEach((done: () => void) => {
beforeEach(fakeAsync(() => {
genModule({ minColumn: true });
context.rowClickTime = 10;
fixture.detectChanges();
fixture.whenStable().then(() => done());
});
it(`should be row click`, (done: () => void) => {
expect(context.rowClick).not.toHaveBeenCalled();
expect(context.rowDblClick).not.toHaveBeenCalled();
tick();
}));
it(`should be row click`, fakeAsync(() => {
(page.getCell() as HTMLElement).click();
fixture.detectChanges();
fixture.whenStable().then(() => {
setTimeout(() => {
expect(context.rowClick).toHaveBeenCalled();
expect(context.rowDblClick).not.toHaveBeenCalled();
done();
}, 25);
});
});
it(`should be row double click`, (done: () => void) => {
expect(context.rowClick).not.toHaveBeenCalled();
expect(context.rowDblClick).not.toHaveBeenCalled();
tick(100);
expect(page._changeData.type).toBe('click');
}));
it(`should be row double click`, fakeAsync(() => {
const cell = page.getCell() as HTMLElement;
cell.click();
cell.click();
fixture.detectChanges();
fixture.whenStable().then(() => {
setTimeout(() => {
expect(context.rowClick).not.toHaveBeenCalled();
expect(context.rowDblClick).toHaveBeenCalled();
done();
}, 25);
});
});
it('should be ingore input', (done: () => void) => {
expect(context.rowClick).not.toHaveBeenCalled();
expect(context.rowDblClick).not.toHaveBeenCalled();
tick(100);
expect(page._changeData.type).toBe('dblClick');
console.log('2', page._changeData);
}));
it('should be ingore input', fakeAsync(() => {
expect(context.change).not.toHaveBeenCalled();
const el = page.getCell() as HTMLElement;
// mock input nodeName
spyOnProperty(el, 'nodeName', 'get').and.returnValue('INPUT');
el.click();
fixture.detectChanges();
fixture.whenStable().then(() => {
setTimeout(() => {
expect(context.rowClick).not.toHaveBeenCalled();
expect(context.rowDblClick).not.toHaveBeenCalled();
done();
}, 25);
});
});
tick(100);
expect(context.change).not.toHaveBeenCalled();
}));
});

describe('[i18n]', () => {
Expand Down Expand Up @@ -1471,15 +1453,10 @@ describe('abc: table', () => {
});

class PageObject {
_changeData: STChange;
constructor() {
spyOn(context, 'error');
spyOn(context, 'change');
spyOn(context, 'checkboxChange');
spyOn(context, 'radioChange');
spyOn(context, 'sortChange');
spyOn(context, 'filterChange');
spyOn(context, 'rowClick');
spyOn(context, 'rowDblClick');
spyOn(context, 'change').and.callFake(e => this._changeData = e);
comp = context.comp;
}
get(cls: string): DebugElement {
Expand Down Expand Up @@ -1678,15 +1655,8 @@ describe('abc: table', () => {
[widthConfig]="widthConfig"
[rowClickTime]="rowClickTime"

(change)="change()"
(change)="change($event)"
(error)="error()"

(checkboxChange)="checkboxChange()"
(radioChange)="radioChange()"
(sortChange)="sortChange()"
(filterChange)="filterChange()"
(rowClick)="rowClick()"
(rowDblClick)="rowDblClick()"
>
</st>`,
})
Expand Down Expand Up @@ -1714,11 +1684,4 @@ class TestComponent {

error() {}
change() {}

checkboxChange() {}
radioChange() {}
sortChange() {}
filterChange() {}
rowClick() {}
rowDblClick() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class Walker extends ComponentWalker {
start: node.getStart() + list.offset,
end: node.getStart() + list.offset + list.attr.length,
message:
`Found deprecated @Output() "${chalk.red(list.attr)}" on "${chalk.bold(
`Found removed @Output() "${chalk.red(list.attr)}" on "${chalk.bold(
'st(simple-table)',
)}". ` +
`Use "${chalk.green(
Expand Down