Skip to content

Commit

Permalink
Improve stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippMDoerner committed Dec 12, 2024
1 parent 007cb32 commit 72e1134
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 21 deletions.
2 changes: 2 additions & 0 deletions src/app/_models/formly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export interface FormlyInputConfig<T> extends FormlyInterface<T> {
placeholder?: string;
maxLength?: number;
minLength?: number;
max?: number;
min?: number;
parsers?: any;
inputKind: InputKind;
}
Expand Down
4 changes: 3 additions & 1 deletion src/app/_services/formly/formly-service.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class FormlyService {
warningMessage: config.warningMessage,
additionalProperties: {
disabledExpression: config.disabledExpression,
tooltipMessage: config.tooltipMessage ?? 'WHAT',
tooltipMessage: config.tooltipMessage ?? '',
showWrapperLabel: config.showWrapperLabel ?? true,
},
},
Expand Down Expand Up @@ -165,7 +165,9 @@ export class FormlyService {
parsers: config.parsers,
props: {
maxLength: config.maxLength,
max: config.max,
minLength: config.minLength,
min: config.min,
label: config.label ?? capitalize(`${config.key}`),
type: innerInputType,
required: config.required ?? true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<button
btn
aria-label="shows modal explaining graph data"
class="rounded-pill"
[kind]="'NONE'"
[icon]="'info-circle'"
[text]="'Help'"
(click)="openModal(infoModal)"
>
Help
<app-icon [icon]="'info-circle'"></app-icon>
</button>
></button>

<ng-template #infoModal let-modal>
<div class="modal-header">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
TemplateRef,
} from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ButtonComponent } from 'src/design/atoms/button/button.component';
import { IconComponent } from '../../../../design/atoms/icon/icon.component';
import { SeparatorComponent } from '../../../../design/atoms/separator/separator.component';

Expand Down Expand Up @@ -79,7 +80,7 @@ const GRAPH_INTERACTIONS = [
@Component({
selector: 'app-graph-help-modal',
standalone: true,
imports: [IconComponent, SeparatorComponent],
imports: [IconComponent, SeparatorComponent, ButtonComponent],
templateUrl: './graph-help-modal.component.html',
styleUrl: './graph-help-modal.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,20 @@ export class GraphSettingsModalComponent {
this.formlyService.buildInputConfig<typeof GRAPH_SETTINGS>({
key: 'linkAttractingForce',
inputKind: 'NUMBER_FRACTION',
label: 'Strength of links pulling nodes together',
label: 'Strength of links pulling nodes together (0-3)',
max: 3,
min: 0,
}),
this.formlyService.buildInputConfig<typeof GRAPH_SETTINGS>({
key: 'nodeRepellingForce',
inputKind: 'NUMBER_FRACTION',
label: 'Strength of nodes repelling each other',
}),
this.formlyService.buildInputConfig<typeof GRAPH_SETTINGS>({
key: 'xForce',
inputKind: 'NUMBER_FRACTION',
label: 'Horizontal force',
}),
this.formlyService.buildInputConfig<typeof GRAPH_SETTINGS>({
key: 'yForce',
inputKind: 'NUMBER_FRACTION',
label: 'Vertical force',
}),
]);

onSettingsSubmit(model: any) {
const newSettings: typeof GRAPH_SETTINGS = {
...model,
xForce: parseFloat(model.xForce),
yForce: parseFloat(model.yForce),
linkAttractingForce: parseFloat(model.linkAttractingForce),
nodeRepellingForce: parseFloat(model.nodeRepellingForce),
};
Expand Down
4 changes: 2 additions & 2 deletions src/design/organisms/graph/graph.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ export class GraphService {
'charge',
forceManyBody().strength(-1 * settings.nodeRepellingForce),
)
.force('x', forceX().strength(settings.undirectedForce))
.force('y', forceY().strength(settings.undirectedForce))
.force('x', forceX(settings.width / 2).strength(settings.undirectedForce))
.force('y', forceY(height / 2).strength(settings.undirectedForce))
.force('center', forceCenter(settings.width / 2, height / 2));
addDragBehavior(allNodesElement, simulation);

Expand Down

0 comments on commit 72e1134

Please sign in to comment.