Skip to content
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
7 changes: 5 additions & 2 deletions ng16/patch/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { SocketComponent } from './presets/classic/components/socket/socket.comp
import { ConnectionWrapperComponent } from './presets/classic/components/connection/connection-wrapper.component';
import { ControlComponent } from './presets/classic/components/control/control.component';
import { RefDirective } from './ref';
import { ImpureKeyvaluePipe } from './shared/pipes/impure-keyvalue.pipe';

@NgModule({
declarations: [
Expand All @@ -15,7 +16,8 @@ import { RefDirective } from './ref';
ConnectionComponent,
ConnectionWrapperComponent,
SocketComponent,
ControlComponent
ControlComponent,
ImpureKeyvaluePipe
],
imports: [
CommonModule
Expand All @@ -26,7 +28,8 @@ import { RefDirective } from './ref';
ConnectionComponent,
ConnectionWrapperComponent,
SocketComponent,
ControlComponent
ControlComponent,
ImpureKeyvaluePipe
]
})
export class ReteModule { }
7 changes: 5 additions & 2 deletions ng17/patch/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { SocketComponent } from './presets/classic/components/socket/socket.comp
import { ConnectionWrapperComponent } from './presets/classic/components/connection/connection-wrapper.component';
import { ControlComponent } from './presets/classic/components/control/control.component';
import { RefDirective } from './ref';
import { ImpureKeyvaluePipe } from './shared/pipes/impure-keyvalue.pipe';

@NgModule({
declarations: [
Expand All @@ -15,7 +16,8 @@ import { RefDirective } from './ref';
ConnectionComponent,
ConnectionWrapperComponent,
SocketComponent,
ControlComponent
ControlComponent,
ImpureKeyvaluePipe
],
imports: [
CommonModule
Expand All @@ -26,7 +28,8 @@ import { RefDirective } from './ref';
ConnectionComponent,
ConnectionWrapperComponent,
SocketComponent,
ControlComponent
ControlComponent,
ImpureKeyvaluePipe
]
})
export class ReteModule { }
7 changes: 5 additions & 2 deletions ng18/patch/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { SocketComponent } from './presets/classic/components/socket/socket.comp
import { ConnectionWrapperComponent } from './presets/classic/components/connection/connection-wrapper.component';
import { ControlComponent } from './presets/classic/components/control/control.component';
import { RefDirective } from './ref';
import { ImpureKeyvaluePipe } from './shared/pipes/impure-keyvalue.pipe';

@NgModule({
declarations: [
Expand All @@ -15,7 +16,8 @@ import { RefDirective } from './ref';
ConnectionComponent,
ConnectionWrapperComponent,
SocketComponent,
ControlComponent
ControlComponent,
ImpureKeyvaluePipe
],
imports: [
CommonModule
Expand All @@ -26,7 +28,8 @@ import { RefDirective } from './ref';
ConnectionComponent,
ConnectionWrapperComponent,
SocketComponent,
ControlComponent
ControlComponent,
ImpureKeyvaluePipe
]
})
export class ReteModule { }
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// [imports]
import { CommonModule } from '@angular/common';
import { RefDirective } from '../../../../ref';
import { ImpureKeyvaluePipe } from '../../../../shared/pipes/impure-keyvalue.pipe';
// [component-directive]
imports: [CommonModule, RefDirective],
imports: [CommonModule, RefDirective, ImpureKeyvaluePipe],
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// [imports]
import { CommonModule } from '@angular/common';
import { RefDirective } from '../../../../ref';
import { ImpureKeyvaluePipe } from '../../../../shared/pipes/impure-keyvalue.pipe';
// [component-directive]
imports: [CommonModule, RefDirective],
imports: [CommonModule, RefDirective, ImpureKeyvaluePipe],
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export * from './presets/classic/components'
export * from './presets/context-menu/components'
export * from './presets/minimap/components'
export * from './presets/reroute/components'
export * from './shared/pipes'
export * from './ref'
export * from './core'
7 changes: 5 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { SocketComponent } from './presets/classic/components/socket/socket.comp
import { ConnectionWrapperComponent } from './presets/classic/components/connection/connection-wrapper.component';
import { ControlComponent } from './presets/classic/components/control/control.component';
import { RefDirective } from './ref';
import { ImpureKeyvaluePipe } from './shared/pipes/impure-keyvalue.pipe';

@NgModule({
declarations: [
Expand All @@ -15,7 +16,8 @@ import { RefDirective } from './ref';
ConnectionComponent,
ConnectionWrapperComponent,
SocketComponent,
ControlComponent
ControlComponent,
ImpureKeyvaluePipe
],
imports: [
CommonModule
Expand All @@ -26,7 +28,8 @@ import { RefDirective } from './ref';
ConnectionComponent,
ConnectionWrapperComponent,
SocketComponent,
ControlComponent
ControlComponent,
ImpureKeyvaluePipe
],
entryComponents: [
NodeComponent,
Expand Down
6 changes: 3 additions & 3 deletions src/presets/classic/components/node/node.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="title" data-testid="title">{{data.label}}</div>
<div class="output" *ngFor="let output of data.outputs | keyvalue: sortByIndex" [attr.data-testid]="'output-'+output.key">
<div class="output" *ngFor="let output of data.outputs | keyvalueimpure: sortByIndex" [attr.data-testid]="'output-'+output.key">
<div class="output-title" data-testid="output-title">{{output.value?.label}}</div>
<div
class="output-socket"
Expand All @@ -11,13 +11,13 @@
</div>
<div
class="control"
*ngFor="let control of data.controls | keyvalue: sortByIndex"
*ngFor="let control of data.controls | keyvalueimpure: sortByIndex"
refComponent
[data]="{type: 'control', payload: control.value }"
[emit]="emit"
[attr.data-testid]="'control-'+control.key"
></div>
<div class="input" *ngFor="let input of data.inputs | keyvalue: sortByIndex" [attr.data-testid]="'input-'+input.key">
<div class="input" *ngFor="let input of data.inputs | keyvalueimpure: sortByIndex" [attr.data-testid]="'input-'+input.key">
<div
class="input-socket"
refComponent
Expand Down
2 changes: 2 additions & 0 deletions src/shared/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './drag';
export * from './pipes';
22 changes: 22 additions & 0 deletions src/shared/pipes/impure-keyvalue.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'keyvalueimpure',
pure: false
})
export class ImpureKeyvaluePipe implements PipeTransform {

transform(value: {[key: string]: any} | null | undefined, compareFn?: (a: any, b: any) => number): Array<{key: string, value: any}> {
if (!value || typeof value !== 'object') {
return [];
}

const result = Object.entries(value).map(([key, val]) => ({key, value: val}));

if (compareFn) {
result.sort(compareFn);
}

return result;
}
}
1 change: 1 addition & 0 deletions src/shared/pipes/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ImpureKeyvaluePipe } from './impure-keyvalue.pipe';
Loading