-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b349b9
commit 007cb32
Showing
16 changed files
with
231 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
src/app/campaign/components/graph-help-modal/graph-help-modal.component.spec.ts
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
src/app/campaign/components/graph-settings-modal/graph-settings-modal.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<button | ||
class="rounded-pill" | ||
aria-label="Shows modal to modify settings used to create the graph" | ||
btn | ||
[kind]="'NONE'" | ||
[icon]="'gear'" | ||
[text]="'settings'" | ||
(click)="openModal(settingsModal)" | ||
></button> | ||
|
||
<ng-template #settingsModal let-modal> | ||
<div class="modal-header"> | ||
<h2 | ||
class="modal-title w-100 d-flex justify-content-between" | ||
id="modal-title" | ||
> | ||
<span>Graph Settings</span> | ||
<button type="button" aria-label="Close" (click)="modal.dismiss()"> | ||
<app-icon [icon]="'times'"></app-icon> | ||
</button> | ||
</h2> | ||
</div> | ||
|
||
<div class="modal-body"> | ||
<app-form | ||
[model]="settings()" | ||
[fields]="formlyFields()" | ||
(formlySubmit)="onSettingsSubmit($event)" | ||
(formlyCancel)="modal.dismiss()" | ||
></app-form> | ||
</div> | ||
</ng-template> |
Empty file.
77 changes: 77 additions & 0 deletions
77
src/app/campaign/components/graph-settings-modal/graph-settings-modal.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
computed, | ||
inject, | ||
input, | ||
output, | ||
TemplateRef, | ||
} from '@angular/core'; | ||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; | ||
import { FormlyFieldConfig } from '@ngx-formly/core'; | ||
import { FormlyService } from 'src/app/_services/formly/formly-service.service'; | ||
import { ButtonComponent } from 'src/design/atoms/button/button.component'; | ||
import { GRAPH_SETTINGS } from 'src/design/organisms/_model/graph'; | ||
import { IconComponent } from '../../../../design/atoms/icon/icon.component'; | ||
import { FormComponent } from '../../../../design/molecules/form/form.component'; | ||
|
||
@Component({ | ||
selector: 'app-graph-settings-modal', | ||
standalone: true, | ||
imports: [ButtonComponent, FormComponent, IconComponent], | ||
templateUrl: './graph-settings-modal.component.html', | ||
styleUrl: './graph-settings-modal.component.scss', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class GraphSettingsModalComponent { | ||
modalService = inject(NgbModal); | ||
formlyService = inject(FormlyService); | ||
|
||
settings = input(GRAPH_SETTINGS); | ||
|
||
newSettings = output<typeof GRAPH_SETTINGS>(); | ||
|
||
formlyFields = computed<FormlyFieldConfig[]>(() => [ | ||
this.formlyService.buildInputConfig<typeof GRAPH_SETTINGS>({ | ||
key: 'linkAttractingForce', | ||
inputKind: 'NUMBER_FRACTION', | ||
label: 'Strength of links pulling nodes together', | ||
}), | ||
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), | ||
}; | ||
|
||
this.newSettings.emit(newSettings); | ||
|
||
this.modalService.dismissAll(); | ||
} | ||
|
||
openModal(content: TemplateRef<any>) { | ||
this.modalService.open(content, { | ||
ariaLabelledBy: 'modal-title', | ||
modalDialogClass: 'border border-info border-3 rounded mymodal', | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.