Skip to content

Commit

Permalink
fix(abc:st): correct default value of date type (#1823)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk authored Aug 5, 2024
1 parent 772ecb4 commit 40ae0dc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/abc/st/st-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,10 @@ export class STDataSource {
text = this.currencySrv.format(value, col.currency?.format);
break;
case 'date':
text = value === col.default ? col.default : this.datePipe.transform(value, col.dateFormat);
text =
value == null || value === col.default || (typeof value === 'number' && value <= 0)
? col.default
: this.datePipe.transform(value, col.dateFormat);
break;
case 'yn':
text = this.ynPipe.transform(value === col.yn!.truth, col.yn!.yes!, col.yn!.no!, col.yn!.mode!, false);
Expand Down
8 changes: 8 additions & 0 deletions packages/abc/st/test/st-data-source.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,14 @@ describe('abc: table: data-souce', () => {
done();
});
});
it('should be return default value when is 0 timestamp', done => {
options.columns[0] = { index: 'date', type: 'date', default: '-' } as _STColumn;
options.data = [{ date: 0 }, { date: new Date() }];
srv.process(options).subscribe(res => {
expect(res.list[0]._values[0].text).toBe('-');
done();
});
});
});
it('via yn', done => {
options.columns[0].type = 'yn';
Expand Down

0 comments on commit 40ae0dc

Please sign in to comment.