Skip to content

Commit

Permalink
Merge pull request NG-ZORRO#6 from giscafer/master
Browse files Browse the repository at this point in the history
fetch update
  • Loading branch information
giscafer authored Feb 23, 2018
2 parents 92e8f83 + 2e65a96 commit 069dbe4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
15 changes: 8 additions & 7 deletions src/components/datepicker/nz-rangepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ import { measureScrollbar } from '../util/mesureScrollBar';
<ng-container *ngTemplateOutlet="inputRangePart; context: { part: _part.Start }"></ng-container>
<span class="ant-calendar-range-picker-separator"> ~ </span>
<ng-container *ngTemplateOutlet="inputRangePart; context: { part: _part.End }"></ng-container>
</span>
<i class="ant-calendar-picker-clear anticon anticon-cross-circle"
<i class="ant-calendar-picker-clear anticon anticon-cross-circle"
*ngIf="showClearIcon"
(click)="onTouched();
_clearValue($event)">
</i>
<span class="ant-calendar-picker-icon"></span>
</i>
<span class="ant-calendar-picker-icon"></span>
</span>
</span>
<ng-template cdkConnectedOverlay
Expand Down Expand Up @@ -99,7 +99,7 @@ import { measureScrollbar } from '../util/mesureScrollBar';
</ng-template>
<!-- input template -->
<ng-template #inputRangePart let-part="part">
<input class="ant-calendar-range-picker-input" nz-input [nzDisabled]="nzDisabled"
<input class="ant-calendar-range-picker-input" [disabled]="nzDisabled"
[value]="nzValue[part] | nzDate: nzFormat"
[placeholder]="nzPlaceholder[part]">
</ng-template>
Expand Down Expand Up @@ -564,10 +564,11 @@ export class NzRangePickerComponent implements ControlValueAccessor, OnInit {
if (typeof window !== 'undefined' && this._open && this._cdkOverlay && this._cdkOverlay.overlayRef) {
const originElement = this._cdkOverlay.origin.elementRef.nativeElement;
const overlayElement = this._cdkOverlay.overlayRef.overlayElement;
const originX = originElement.getBoundingClientRect().x;
const originX = originElement.getBoundingClientRect().left;
const overlayWidth = overlayElement.getBoundingClientRect().width;
const margin = window.innerWidth - originX - overlayWidth;
this._offsetX = margin > 0 ? 0 : margin - (measureScrollbar() || 15);
const offsetX = margin > 0 ? 0 : margin - (measureScrollbar() || 15);
this._offsetX = Number.isFinite(offsetX) ? offsetX : 0;
this._cdr.detectChanges();
}
}
Expand Down
10 changes: 2 additions & 8 deletions src/components/upload/nz-upload.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ export class NzUploadComponent implements OnInit, OnChanges, OnDestroy {
onRemove = (file: UploadFile): void => {
this.upload.abort(file);
file.status = 'removed';
(this.nzRemove ? this.nzRemove instanceof Observable ? this.nzRemove : of(this.nzRemove(file)) : of(true))
((this.nzRemove ? this.nzRemove instanceof Observable ? this.nzRemove : of(this.nzRemove(file)) : of(true)) as Observable<any>)
.pipe(filter((res: boolean) => res))
.subscribe(res => {
const removedFileList = this.removeFileItem(file, this.nzFileList);
Expand Down Expand Up @@ -411,13 +411,7 @@ export class NzUploadComponent implements OnInit, OnChanges, OnDestroy {
}

ngOnChanges(changes: { [P in keyof this]?: SimpleChange } & SimpleChanges): void {
if (changes.nzFileList) {
(this.nzFileList || []).forEach(file => file.message = this.genErr(file));
if (!changes.nzFileList.firstChange) return;
}
if (this.inited) {
if (changes.nzPreview || changes.nzCustomRequest || changes.nzBeforeUpload || changes.nzRemove) return;
}
if (changes.nzFileList) (this.nzFileList || []).forEach(file => file.message = this.genErr(file));
this.zipOptions()._setClassMap();
}

Expand Down
19 changes: 18 additions & 1 deletion src/components/upload/nz-upload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,30 @@ describe('NzUpload', () => {
it('should create an instance', () => {
expect(instance).toBeTruthy();
});

it('recreate bug https://github.com/NG-ZORRO/ng-zorro-antd/issues/1038', () => {
expect(instance.ref._btnOptions.disabled).toBe(false);
instance.fileList = [{
uid: -1,
name: 'xxx.png',
status: 'done',
url: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
}];
fixture.detectChanges();
expect(instance.ref._btnOptions.disabled).toBe(true);
});
});

@Component({
template: `<nz-upload #ref [nzShowUploadList]="false">Upload</nz-upload>`
template: `<nz-upload #ref
[(nzFileList)]="fileList"
[nzDisabled]="fileList.length >= 1"
[nzShowUploadList]="false">Upload</nz-upload>`
})
class TestComponent {

@ViewChild('ref') ref: NzUploadComponent;

fileList = [];

}

0 comments on commit 069dbe4

Please sign in to comment.