bug fixed
This commit is contained in:
parent
ed5e5df081
commit
ee82dc61fa
8
package-lock.json
generated
8
package-lock.json
generated
|
@ -3382,9 +3382,8 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@ucap/ng-ui": {
|
"@ucap/ng-ui": {
|
||||||
"version": "file:pack/ucap-ng-ui-0.0.3.tgz",
|
"version": "file:pack/ucap-ng-ui-0.0.4.tgz",
|
||||||
"integrity": "sha512-fd9zmOt2/mHM1iIEnST4pr+IUEnKFLkZkvQLBtybOdu1YgdFB1wvsK7Hk+OTuYdUYCGdg31iBoSgTYXZrAJufw==",
|
"integrity": "sha512-DcrZx55uGvvc70vUxP2fkgQhORMMBgkKWRdG5zH1PpgB4wY1Od887DgFJISEQzbcFNBNr6TiX+I8e64maGQp0A=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"@ucap/ng-ui-authentication": {
|
"@ucap/ng-ui-authentication": {
|
||||||
"version": "file:pack/ucap-ng-ui-authentication-0.0.16.tgz",
|
"version": "file:pack/ucap-ng-ui-authentication-0.0.16.tgz",
|
||||||
|
@ -3398,7 +3397,8 @@
|
||||||
},
|
},
|
||||||
"@ucap/ng-ui-skin-default": {
|
"@ucap/ng-ui-skin-default": {
|
||||||
"version": "file:pack/ucap-ng-ui-skin-default-0.0.1.tgz",
|
"version": "file:pack/ucap-ng-ui-skin-default-0.0.1.tgz",
|
||||||
"integrity": "sha512-vtgJBOsJj/S2GjP02PpBz9ebGikNtzdsC7JQc5HKkCZRC6JKkzZmWzcaFGlLPsh9dcWEeZuNhwnAZfmPXgz6Aw=="
|
"integrity": "sha512-vtgJBOsJj/S2GjP02PpBz9ebGikNtzdsC7JQc5HKkCZRC6JKkzZmWzcaFGlLPsh9dcWEeZuNhwnAZfmPXgz6Aw==",
|
||||||
|
"dev": true
|
||||||
},
|
},
|
||||||
"@ucap/ng-web-socket": {
|
"@ucap/ng-web-socket": {
|
||||||
"version": "file:pack/ucap-ng-web-socket-0.0.2.tgz",
|
"version": "file:pack/ucap-ng-web-socket-0.0.2.tgz",
|
||||||
|
|
|
@ -179,7 +179,7 @@
|
||||||
"@ucap/ng-store-chat": "file:pack/ucap-ng-store-chat-0.0.5.tgz",
|
"@ucap/ng-store-chat": "file:pack/ucap-ng-store-chat-0.0.5.tgz",
|
||||||
"@ucap/ng-store-group": "file:pack/ucap-ng-store-group-0.0.6.tgz",
|
"@ucap/ng-store-group": "file:pack/ucap-ng-store-group-0.0.6.tgz",
|
||||||
"@ucap/ng-store-organization": "file:pack/ucap-ng-store-organization-0.0.4.tgz",
|
"@ucap/ng-store-organization": "file:pack/ucap-ng-store-organization-0.0.4.tgz",
|
||||||
"@ucap/ng-ui": "file:pack/ucap-ng-ui-0.0.3.tgz",
|
"@ucap/ng-ui": "file:pack/ucap-ng-ui-0.0.4.tgz",
|
||||||
"@ucap/ng-ui-authentication": "file:pack/ucap-ng-ui-authentication-0.0.16.tgz",
|
"@ucap/ng-ui-authentication": "file:pack/ucap-ng-ui-authentication-0.0.16.tgz",
|
||||||
"@ucap/ng-ui-organization": "file:pack/ucap-ng-ui-organization-0.0.2.tgz",
|
"@ucap/ng-ui-organization": "file:pack/ucap-ng-ui-organization-0.0.2.tgz",
|
||||||
"@ucap/ng-ui-skin-default": "file:pack/ucap-ng-ui-skin-default-0.0.1.tgz",
|
"@ucap/ng-ui-skin-default": "file:pack/ucap-ng-ui-skin-default-0.0.1.tgz",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@ucap/ng-ui",
|
"name": "@ucap/ng-ui",
|
||||||
"version": "0.0.3",
|
"version": "0.0.4",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"registry": "http://10.81.13.221:8081/nexus/repository/npm-ucap/"
|
"registry": "http://10.81.13.221:8081/nexus/repository/npm-ucap/"
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,16 +14,20 @@ import { FlatTreeControl } from '@angular/cdk/tree';
|
||||||
import { MatTreeFlattener } from '@angular/material/tree';
|
import { MatTreeFlattener } from '@angular/material/tree';
|
||||||
|
|
||||||
export class VirtualScrollTreeFlatDataSource<T, F> extends DataSource<F> {
|
export class VirtualScrollTreeFlatDataSource<T, F> extends DataSource<F> {
|
||||||
private flattenedDataSubject = new BehaviorSubject<F[]>([]);
|
|
||||||
|
|
||||||
expandedDataSubject = new BehaviorSubject<F[]>([]);
|
expandedDataSubject = new BehaviorSubject<F[]>([]);
|
||||||
expandedData$: Observable<F[]>;
|
expandedData$: Observable<F[]>;
|
||||||
|
|
||||||
private connectSubject: Subject<F[]>;
|
// tslint:disable-next-line: variable-name
|
||||||
private dataChangeSubscription: Subscription;
|
private _flattenedDataSubject = new BehaviorSubject<F[]>([]);
|
||||||
private rangeChangeSubscription: Subscription;
|
// tslint:disable-next-line: variable-name
|
||||||
|
private _connectSubject: Subject<F[]>;
|
||||||
|
// tslint:disable-next-line: variable-name
|
||||||
|
private _dataChangeSubscription: Subscription;
|
||||||
|
// tslint:disable-next-line: variable-name
|
||||||
|
private _rangeChangeSubscription: Subscription;
|
||||||
|
|
||||||
private rangeSubject: BehaviorSubject<{
|
// tslint:disable-next-line: variable-name
|
||||||
|
private _rangeSubject: BehaviorSubject<{
|
||||||
start: number;
|
start: number;
|
||||||
end: number;
|
end: number;
|
||||||
}>;
|
}>;
|
||||||
|
@ -37,22 +41,22 @@ export class VirtualScrollTreeFlatDataSource<T, F> extends DataSource<F> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._cdkVirtualScrollViewport = cdkVirtualScrollViewport;
|
this._cdkVirtualScrollViewport = cdkVirtualScrollViewport;
|
||||||
this.rangeSubject = new BehaviorSubject<{ start: number; end: number }>({
|
this._rangeSubject = new BehaviorSubject<{ start: number; end: number }>({
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 1
|
end: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
this.rangeChangeSubscription = cdkVirtualScrollViewport.renderedRangeStream.subscribe(
|
this._rangeChangeSubscription = cdkVirtualScrollViewport.renderedRangeStream.subscribe(
|
||||||
range => {
|
(range) => {
|
||||||
this.rangeSubject.next({
|
this._rangeSubject.next({
|
||||||
start: range.start,
|
start: range.start,
|
||||||
end: range.end
|
end: range.end
|
||||||
});
|
});
|
||||||
if (!!this.connectSubject) {
|
if (!!this._connectSubject) {
|
||||||
this.connectSubject.next(
|
this._connectSubject.next(
|
||||||
this.expandedDataSubject.value.slice(
|
this.expandedDataSubject.value.slice(
|
||||||
this.rangeSubject.value.start,
|
this._rangeSubject.value.start,
|
||||||
this.rangeSubject.value.end
|
this._rangeSubject.value.end
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -67,13 +71,17 @@ export class VirtualScrollTreeFlatDataSource<T, F> extends DataSource<F> {
|
||||||
}
|
}
|
||||||
set data(value: T[]) {
|
set data(value: T[]) {
|
||||||
this._data.next(value);
|
this._data.next(value);
|
||||||
this.flattenedDataSubject.next(this.treeFlattener.flattenNodes(this.data));
|
this._flattenedDataSubject.next(
|
||||||
this.treeControl.dataNodes = this.flattenedDataSubject.value;
|
this._treeFlattener.flattenNodes(this.data)
|
||||||
|
);
|
||||||
|
this._treeControl.dataNodes = this._flattenedDataSubject.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private treeControl: FlatTreeControl<F>,
|
// tslint:disable-next-line: variable-name
|
||||||
private treeFlattener: MatTreeFlattener<T, F>,
|
private _treeControl: FlatTreeControl<F>,
|
||||||
|
// tslint:disable-next-line: variable-name
|
||||||
|
private _treeFlattener: MatTreeFlattener<T, F>,
|
||||||
initialData: T[] = []
|
initialData: T[] = []
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
@ -82,52 +90,52 @@ export class VirtualScrollTreeFlatDataSource<T, F> extends DataSource<F> {
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(collectionViewer: CollectionViewer): Observable<F[]> {
|
connect(collectionViewer: CollectionViewer): Observable<F[]> {
|
||||||
this.connectSubject = new Subject<F[]>();
|
this._connectSubject = new Subject<F[]>();
|
||||||
|
|
||||||
this.dataChangeSubscription = merge(
|
this._dataChangeSubscription = merge(
|
||||||
collectionViewer.viewChange,
|
collectionViewer.viewChange,
|
||||||
this.treeControl.expansionModel.changed,
|
this._treeControl.expansionModel.changed,
|
||||||
this.flattenedDataSubject
|
this._flattenedDataSubject
|
||||||
)
|
)
|
||||||
.pipe(
|
.pipe(
|
||||||
map(() => {
|
map(() => {
|
||||||
this.expandedDataSubject.next(
|
this.expandedDataSubject.next(
|
||||||
this.treeFlattener.expandFlattenedNodes(
|
this._treeFlattener.expandFlattenedNodes(
|
||||||
this.flattenedDataSubject.value,
|
this._flattenedDataSubject.value,
|
||||||
this.treeControl
|
this._treeControl
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
return !this.rangeSubject
|
return !this._rangeSubject
|
||||||
? this.expandedDataSubject.value
|
? this.expandedDataSubject.value
|
||||||
: this.expandedDataSubject.value.slice(
|
: this.expandedDataSubject.value.slice(
|
||||||
this.rangeSubject.value.start,
|
this._rangeSubject.value.start,
|
||||||
this.rangeSubject.value.end
|
this._rangeSubject.value.end
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.subscribe(datas => {
|
.subscribe((datas) => {
|
||||||
this.connectSubject.next(datas);
|
this._connectSubject.next(datas);
|
||||||
if (!!this._cdkVirtualScrollViewport) {
|
if (!!this._cdkVirtualScrollViewport) {
|
||||||
this._cdkVirtualScrollViewport.checkViewportSize();
|
this._cdkVirtualScrollViewport.checkViewportSize();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return this.connectSubject.asObservable();
|
return this._connectSubject.asObservable();
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect() {
|
disconnect() {
|
||||||
if (!!this.connectSubject) {
|
if (!!this._connectSubject) {
|
||||||
this.connectSubject.next();
|
this._connectSubject.next();
|
||||||
this.connectSubject.unsubscribe();
|
this._connectSubject.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!!this.dataChangeSubscription) {
|
if (!!this._dataChangeSubscription) {
|
||||||
this.dataChangeSubscription.unsubscribe();
|
this._dataChangeSubscription.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!!this.rangeChangeSubscription) {
|
if (!!this._rangeChangeSubscription) {
|
||||||
this.rangeChangeSubscription.unsubscribe();
|
this._rangeChangeSubscription.unsubscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user