Skip to content

Commit

Permalink
fix: import cycles would need to be created to compile this component…
Browse files Browse the repository at this point in the history
… #INFR-2077
  • Loading branch information
why520crazy authored and walkerkay committed Jul 12, 2021
1 parent 5a6a1a7 commit f3eba0b
Show file tree
Hide file tree
Showing 15 changed files with 332 additions and 170 deletions.
3 changes: 2 additions & 1 deletion src/dialog/confirm.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ThyFormGroupFooterAlign } from 'ngx-tethys/form';
import { Observable } from 'rxjs';

import { InjectionToken } from '@angular/core';
import { ThyFormGroupFooterAlign } from 'ngx-tethys/form';

export interface ThyConfirmConfig {
title?: string;
Expand Down
10 changes: 6 additions & 4 deletions src/dialog/confirm/confirm.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Component, OnInit, OnDestroy, ChangeDetectionStrategy, ChangeDetectorRef, Inject, Input } from '@angular/core';
import { ThyDialogRef } from '../dialog-ref';
import { ThyConfirmConfig, THY_CONFIRM_DEFAULT_OPTIONS, THY_CONFIRM_DEFAULT_OPTIONS_VALUE } from '../confirm.config';
import { finalize } from 'rxjs/operators';
import { ThyFormGroupFooterAlign } from 'ngx-tethys/form';
import { finalize } from 'rxjs/operators';

import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Inject, Input, OnDestroy, OnInit } from '@angular/core';

import { THY_CONFIRM_DEFAULT_OPTIONS, THY_CONFIRM_DEFAULT_OPTIONS_VALUE, ThyConfirmConfig } from '../confirm.config';
import { ThyDialogRef } from '../dialog-ref';

@Component({
selector: 'thy-confirm-default',
Expand Down
10 changes: 10 additions & 0 deletions src/dialog/confirm/token.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { InjectionToken } from '@angular/core';

export interface ThyConfirmAbstractComponent {
okText: string;
okType: string;
cancelText: string;
okLoadingText: string;
}

export const THY_CONFIRM_COMPONENT_TOKEN = new InjectionToken<ThyConfirmAbstractComponent>('thy-confirm-component-token');
13 changes: 11 additions & 2 deletions src/dialog/dialog.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { PortalModule } from '@angular/cdk/portal';
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';

import { ThyButtonModule } from 'ngx-tethys/button';
import { ThyFormModule } from 'ngx-tethys/form';
import { ThyIconModule } from 'ngx-tethys/icon';
import { ThySharedModule } from 'ngx-tethys/shared';
import { DialogBodyComponent } from './body/dialog-body.component';
import { THY_CONFIRM_DEFAULT_OPTIONS_PROVIDER } from './confirm.config';
import { ThyConfirmComponent } from './confirm/confirm.component';
import { THY_CONFIRM_COMPONENT_TOKEN } from './confirm/token';
import { ThyDialogContainerComponent } from './dialog-container.component';
import { THY_DIALOG_DEFAULT_OPTIONS_PROVIDER, THY_DIALOG_LAYOUT_CONFIG_PROVIDER } from './dialog.config';
import { ThyDialog } from './dialog.service';
Expand All @@ -20,7 +20,16 @@ import { DialogHeaderComponent } from './header/dialog-header.component';
@NgModule({
declarations: [ThyDialogContainerComponent, DialogHeaderComponent, DialogBodyComponent, DialogFooterComponent, ThyConfirmComponent],
imports: [CommonModule, ThySharedModule, PortalModule, OverlayModule, ThyButtonModule, ThyIconModule, ThyFormModule, FormsModule],
providers: [ThyDialog, THY_DIALOG_DEFAULT_OPTIONS_PROVIDER, THY_CONFIRM_DEFAULT_OPTIONS_PROVIDER, THY_DIALOG_LAYOUT_CONFIG_PROVIDER],
providers: [
ThyDialog,
THY_DIALOG_DEFAULT_OPTIONS_PROVIDER,
THY_CONFIRM_DEFAULT_OPTIONS_PROVIDER,
THY_DIALOG_LAYOUT_CONFIG_PROVIDER,
{
provide: THY_CONFIRM_COMPONENT_TOKEN,
useValue: ThyConfirmComponent
}
],
entryComponents: [ThyDialogContainerComponent, ThyConfirmComponent],
exports: [ThyDialogContainerComponent, DialogHeaderComponent, DialogBodyComponent, DialogFooterComponent]
})
Expand Down
7 changes: 4 additions & 3 deletions src/dialog/dialog.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ComponentPortal, ComponentType } from '@angular/cdk/portal';
import { Inject, Injectable, Injector, OnDestroy, Optional, StaticProvider, TemplateRef } from '@angular/core';

import { ThyConfirmConfig } from './confirm.config';
import { ThyConfirmComponent } from './confirm/confirm.component';
import { ThyConfirmAbstractComponent, THY_CONFIRM_COMPONENT_TOKEN } from './confirm/token';
import { ThyDialogContainerComponent } from './dialog-container.component';
import { ThyDialogRef, ThyInternalDialogRef } from './dialog-ref';
import { THY_DIALOG_DEFAULT_OPTIONS, ThyDialogConfig, ThyDialogSizes } from './dialog.config';
Expand Down Expand Up @@ -77,7 +77,8 @@ export class ThyDialog extends ThyAbstractOverlayService<ThyDialogConfig, ThyDia
@Optional()
@Inject(THY_DIALOG_DEFAULT_OPTIONS)
defaultConfig: ThyDialogConfig,
clickPositioner: ThyClickPositioner
clickPositioner: ThyClickPositioner,
@Inject(THY_CONFIRM_COMPONENT_TOKEN) private confirmComponentType: ComponentType<ThyConfirmAbstractComponent>
) {
super(dialogAbstractOverlayOptions, overlay, injector, defaultConfig);
clickPositioner.initialize();
Expand All @@ -98,7 +99,7 @@ export class ThyDialog extends ThyAbstractOverlayService<ThyDialogConfig, ThyDia
}

confirm(options: ThyConfirmConfig) {
return this.open(ThyConfirmComponent, {
return this.open(this.confirmComponentType, {
initialState: {
options: options
}
Expand Down
24 changes: 11 additions & 13 deletions src/transfer/transfer-list.component.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
import { CdkDragDrop, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop';
import {
Component,
Input,
Output,
ElementRef,
ViewEncapsulation,
HostBinding,
DoCheck,
EventEmitter,
TemplateRef,
HostBinding,
Input,
IterableChanges,
IterableDiffer,
IterableDiffers,
OnInit,
OnDestroy,
DoCheck,
IterableChanges
Output,
TemplateRef,
ViewEncapsulation
} from '@angular/core';
import { ThyTransferSelectEvent, ThyTransferItem, ThyTransferDragEvent, InnerTransferDragEvent, Direction } from './transfer.interface';
import { ThyTransferComponent } from './transfer.component';
import { CdkDragDrop, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop';

import { InnerTransferDragEvent, ThyTransferDragEvent, ThyTransferItem, ThyTransferSelectEvent } from './transfer.interface';

@Component({
selector: 'thy-transfer-list',
Expand Down Expand Up @@ -56,7 +54,7 @@ export class ThyTransferListComponent implements OnInit, DoCheck {

@HostBinding('class') hostClass = 'thy-transfer-list';

constructor(private root: ThyTransferComponent, private differs: IterableDiffers) {}
constructor(private differs: IterableDiffers) {}

ngOnInit() {
this._combineTransferData();
Expand Down
1 change: 0 additions & 1 deletion src/tree-select/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './module';
export * from './tree-select.component';
export * from './tree-select.class';
export { ThyTreeSelectNodesComponent } from './tree-select-nodes.component';
3 changes: 1 addition & 2 deletions src/tree-select/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { OverlayModule } from '@angular/cdk/overlay';
import { ThyLabelModule } from 'ngx-tethys/label';
import { ThyTreeSelectComponent } from './tree-select.component';
import { ThyTreeSelectNodesComponent } from './tree-select-nodes.component';
import { ThyTreeSelectComponent, ThyTreeSelectNodesComponent } from './tree-select.component';
import { ThyListModule } from 'ngx-tethys/list';
import { ThyIconModule } from 'ngx-tethys/icon';
import { ThyEmptyModule } from 'ngx-tethys/empty';
Expand Down
224 changes: 112 additions & 112 deletions src/tree-select/tree-select-nodes.component.ts
Original file line number Diff line number Diff line change
@@ -1,112 +1,112 @@
import { BehaviorSubject, Subject } from 'rxjs';
import { Component, OnInit, HostBinding, Input } from '@angular/core';
import { ThyTreeSelectComponent } from './tree-select.component';
import { ThyTreeSelectNode } from './tree-select.class';

@Component({
selector: 'thy-tree-select-nodes',
templateUrl: './tree-select-nodes.component.html'
})
export class ThyTreeSelectNodesComponent implements OnInit {
@HostBinding('class') class: string;

@Input() treeNodes: ThyTreeSelectNode[];

public primaryKey = this.parent.thyPrimaryKey;

public showKey = this.parent.thyShowKey;

public isMultiple = this.parent.thyMultiple;

public valueIsObject = this.parent.valueIsObject;

public selectedValue = this.parent.selectedValue;

public childCountKey = this.parent.thyChildCountKey;

public treeNodeTemplateRef = this.parent.treeNodeTemplateRef;

constructor(public parent: ThyTreeSelectComponent) {}

ngOnInit() {
this.class = this.isMultiple ? 'thy-tree-select-dropdown thy-tree-select-dropdown-multiple' : 'thy-tree-select-dropdown';
}

treeNodeIsSelected(node: ThyTreeSelectNode) {
if (this.parent.thyMultiple) {
return (this.parent.selectedNodes || []).find(item => {
return item[this.primaryKey] === node[this.primaryKey];
});
} else {
return this.parent.selectedNode && this.parent.selectedNode[this.primaryKey] === node[this.primaryKey];
}
}

treeNodeIsHidden(node: ThyTreeSelectNode) {
if (this.parent.thyHiddenNodeKey) {
return node[this.parent.thyHiddenNodeKey];
}
if (this.parent.thyHiddenNodeFn) {
return this.parent.thyHiddenNodeFn(node);
}
return false;
}

treeNodeIsDisable(node: ThyTreeSelectNode) {
if (this.parent.thyDisableNodeKey) {
return node[this.parent.thyDisableNodeKey];
}
if (this.parent.thyDisableNodeFn) {
return this.parent.thyDisableNodeFn(node);
}
return false;
}

treeNodeIsExpand(node: ThyTreeSelectNode) {
let isSelectedNodeParent = false;
if (this.parent.thyMultiple) {
isSelectedNodeParent = !!(this.parent.selectedNodes || []).find(item => {
return item.parentValues.indexOf(node[this.primaryKey]) > -1;
});
} else {
isSelectedNodeParent = this.parent.selectedNode
? this.parent.selectedNode.parentValues.indexOf(node[this.primaryKey]) > -1
: false;
}
const isExpand = node.expand || (Object.keys(node).indexOf('expand') < 0 && isSelectedNodeParent);
node.expand = isExpand;
return isExpand;
}

getNodeChildren(node: ThyTreeSelectNode) {
return this.parent.getNodeChildren(node);
}

selectTreeNode(event: Event, node: ThyTreeSelectNode) {
event.stopPropagation();
if (this.treeNodeIsDisable(node)) {
return;
}
this.parent.selectNode(node);
}

nodeExpandToggle(event: Event, node: ThyTreeSelectNode) {
event.stopPropagation();
if (Object.keys(node).indexOf('expand') > -1) {
node.expand = !node.expand;
} else {
if (this.treeNodeIsExpand(node)) {
node.expand = false;
} else {
node.expand = true;
}
}

if (node.expand && this.parent.thyAsyncNode) {
this.getNodeChildren(node).subscribe(() => {
this.parent.setPosition();
});
}
this.parent.setPosition();
}
}
// import { BehaviorSubject, Subject } from 'rxjs';
// import { Component, OnInit, HostBinding, Input } from '@angular/core';
// import { ThyTreeSelectComponent } from './tree-select.component';
// import { ThyTreeSelectNode } from './tree-select.class';

// @Component({
// selector: 'thy-tree-select-nodes',
// templateUrl: './tree-select-nodes.component.html'
// })
// export class ThyTreeSelectNodesComponent implements OnInit {
// @HostBinding('class') class: string;

// @Input() treeNodes: ThyTreeSelectNode[];

// public primaryKey = this.parent.thyPrimaryKey;

// public showKey = this.parent.thyShowKey;

// public isMultiple = this.parent.thyMultiple;

// public valueIsObject = this.parent.valueIsObject;

// public selectedValue = this.parent.selectedValue;

// public childCountKey = this.parent.thyChildCountKey;

// public treeNodeTemplateRef = this.parent.treeNodeTemplateRef;

// constructor(public parent: ThyTreeSelectComponent) {}

// ngOnInit() {
// this.class = this.isMultiple ? 'thy-tree-select-dropdown thy-tree-select-dropdown-multiple' : 'thy-tree-select-dropdown';
// }

// treeNodeIsSelected(node: ThyTreeSelectNode) {
// if (this.parent.thyMultiple) {
// return (this.parent.selectedNodes || []).find(item => {
// return item[this.primaryKey] === node[this.primaryKey];
// });
// } else {
// return this.parent.selectedNode && this.parent.selectedNode[this.primaryKey] === node[this.primaryKey];
// }
// }

// treeNodeIsHidden(node: ThyTreeSelectNode) {
// if (this.parent.thyHiddenNodeKey) {
// return node[this.parent.thyHiddenNodeKey];
// }
// if (this.parent.thyHiddenNodeFn) {
// return this.parent.thyHiddenNodeFn(node);
// }
// return false;
// }

// treeNodeIsDisable(node: ThyTreeSelectNode) {
// if (this.parent.thyDisableNodeKey) {
// return node[this.parent.thyDisableNodeKey];
// }
// if (this.parent.thyDisableNodeFn) {
// return this.parent.thyDisableNodeFn(node);
// }
// return false;
// }

// treeNodeIsExpand(node: ThyTreeSelectNode) {
// let isSelectedNodeParent = false;
// if (this.parent.thyMultiple) {
// isSelectedNodeParent = !!(this.parent.selectedNodes || []).find(item => {
// return item.parentValues.indexOf(node[this.primaryKey]) > -1;
// });
// } else {
// isSelectedNodeParent = this.parent.selectedNode
// ? this.parent.selectedNode.parentValues.indexOf(node[this.primaryKey]) > -1
// : false;
// }
// const isExpand = node.expand || (Object.keys(node).indexOf('expand') < 0 && isSelectedNodeParent);
// node.expand = isExpand;
// return isExpand;
// }

// getNodeChildren(node: ThyTreeSelectNode) {
// return this.parent.getNodeChildren(node);
// }

// selectTreeNode(event: Event, node: ThyTreeSelectNode) {
// event.stopPropagation();
// if (this.treeNodeIsDisable(node)) {
// return;
// }
// this.parent.selectNode(node);
// }

// nodeExpandToggle(event: Event, node: ThyTreeSelectNode) {
// event.stopPropagation();
// if (Object.keys(node).indexOf('expand') > -1) {
// node.expand = !node.expand;
// } else {
// if (this.treeNodeIsExpand(node)) {
// node.expand = false;
// } else {
// node.expand = true;
// }
// }

// if (node.expand && this.parent.thyAsyncNode) {
// this.getNodeChildren(node).subscribe(() => {
// this.parent.setPosition();
// });
// }
// this.parent.setPosition();
// }
// }
Loading

0 comments on commit f3eba0b

Please sign in to comment.