-
Notifications
You must be signed in to change notification settings - Fork 15
Implement Upsert Decision Point Modal for Experiments #2633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
zackcl
merged 9 commits into
experiment-design-refresh
from
feature/2625-upsert-decision-point-modal
Sep 25, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
69e6cc0
Add upsert decision point modal component
zackcl 2d3633d
Implement sendUpsertDecisionPointRequest for Add/Edit Decision Point …
zackcl 043dfb5
Create decision-point-helper.service.ts and implement the Delete Deci…
zackcl 7824c2e
Remove unneeded experimentContext input
zackcl 2908884
Remove redundant fallback
zackcl 0532cff
Merge branch 'experiment-design-refresh' into feature/2625-upsert-dec…
zackcl 1bd1ced
refactor: add context validation and improve ternary readability
zackcl f2baccd
Merge branch 'experiment-design-refresh' into feature/2625-upsert-dec…
zackcl a645a0c
Fix duplicated import
zackcl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
frontend/projects/upgrade/src/app/core/experiments/decision-point-helper.service.ts
This file contains hidden or 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,90 @@ | ||
| import { Injectable } from '@angular/core'; | ||
| import { v4 as uuidv4 } from 'uuid'; | ||
|
|
||
| import { ExperimentService } from './experiments.service'; | ||
| import { | ||
| Experiment, | ||
| ExperimentDecisionPoint, | ||
| UpdateExperimentDecisionPointsRequest, | ||
| DecisionPointFormData, | ||
| } from './store/experiments.model'; | ||
|
|
||
| @Injectable({ | ||
| providedIn: 'root', | ||
| }) | ||
| export class DecisionPointHelperService { | ||
| constructor(private experimentService: ExperimentService) {} | ||
|
|
||
| /** | ||
| * Add a new decision point to an experiment | ||
| */ | ||
| addDecisionPoint(experiment: Experiment, decisionPointData: DecisionPointFormData): void { | ||
| const currentDecisionPoints = [...(experiment.partitions || [])]; | ||
| const newDecisionPoint = { | ||
| id: uuidv4(), | ||
| site: decisionPointData.site, | ||
| target: decisionPointData.target, | ||
| description: '', | ||
| order: currentDecisionPoints.length + 1, | ||
| excludeIfReached: decisionPointData.excludeIfReached, | ||
| }; | ||
|
|
||
| const updatedDecisionPoints = [...currentDecisionPoints, newDecisionPoint] as ExperimentDecisionPoint[]; | ||
|
|
||
| this.updateExperimentDecisionPoints(experiment, updatedDecisionPoints); | ||
| } | ||
|
|
||
| /** | ||
| * Update an existing decision point in an experiment | ||
| */ | ||
| updateDecisionPoint( | ||
| experiment: Experiment, | ||
| sourceDecisionPoint: ExperimentDecisionPoint, | ||
| decisionPointData: DecisionPointFormData | ||
| ): void { | ||
| const currentDecisionPoints = [...(experiment.partitions || [])]; | ||
| const updatedDecisionPoints = currentDecisionPoints.map((dp) => | ||
| dp.id === sourceDecisionPoint.id | ||
| ? { | ||
| ...dp, | ||
| site: decisionPointData.site, | ||
| target: decisionPointData.target, | ||
| excludeIfReached: decisionPointData.excludeIfReached, | ||
| } | ||
| : dp | ||
| ); | ||
|
|
||
| this.updateExperimentDecisionPoints(experiment, updatedDecisionPoints); | ||
| } | ||
|
|
||
| /** | ||
| * Delete a decision point from an experiment | ||
| */ | ||
| deleteDecisionPoint(experiment: Experiment, decisionPointToDelete: ExperimentDecisionPoint): void { | ||
| const currentDecisionPoints = [...(experiment.partitions || [])]; | ||
| const updatedDecisionPoints = currentDecisionPoints.filter((dp) => dp.id !== decisionPointToDelete.id); | ||
|
|
||
| // Reorder the remaining decision points | ||
| const reorderedDecisionPoints = updatedDecisionPoints.map((dp, index) => ({ | ||
| ...dp, | ||
| order: index + 1, | ||
| })); | ||
|
|
||
| this.updateExperimentDecisionPoints(experiment, reorderedDecisionPoints); | ||
| } | ||
|
|
||
| /** | ||
| * Common method to update experiment decision points | ||
| */ | ||
| private updateExperimentDecisionPoints( | ||
| experiment: Experiment, | ||
| updatedDecisionPoints: ExperimentDecisionPoint[] | ||
| ): void { | ||
| const updateRequest: UpdateExperimentDecisionPointsRequest = { | ||
| experiment, | ||
| decisionPoints: updatedDecisionPoints, | ||
| }; | ||
|
|
||
| this.experimentService.updateExperimentDecisionPoints(updateRequest); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
76 changes: 76 additions & 0 deletions
76
...experiments/modals/upsert-decision-point-modal/upsert-decision-point-modal.component.html
This file contains hidden or 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,76 @@ | ||
| <app-common-dialog | ||
| [title]="config.title" | ||
| [cancelBtnLabel]="config.cancelBtnLabel" | ||
| [primaryActionBtnLabel]="config.primaryActionBtnLabel" | ||
| [primaryActionBtnColor]="config.primaryActionBtnColor" | ||
| [primaryActionBtnDisabled]="isPrimaryButtonDisabled$ | async" | ||
| (primaryActionBtnClicked)="onPrimaryActionBtnClicked()" | ||
| > | ||
| <form [formGroup]="decisionPointForm" class="form-standard dense-3"> | ||
|
|
||
| <mat-form-field appearance="outline"> | ||
| <mat-label class="ft-14-400">Site</mat-label> | ||
| <input | ||
| matInput | ||
| formControlName="site" | ||
| placeholder="e.g., assignProblem" | ||
| class="ft-14-400" | ||
| [matAutocomplete]="siteAutocomplete" | ||
| /> | ||
| <mat-autocomplete #siteAutocomplete="matAutocomplete" panelWidth="auto"> | ||
| <mat-option | ||
| *ngFor="let site of filteredSites$ | async" | ||
| [value]="site" | ||
| class="ft-14-400" | ||
| > | ||
| {{ site }} | ||
| </mat-option> | ||
| </mat-autocomplete> | ||
| <mat-hint class="form-hint ft-12-400"> | ||
| {{ 'experiments.upsert-decision-point-modal.site-hint.text' | translate }} | ||
| <a class="learn-more-link" href="https://www.upgradeplatform.org/" target="_blank" rel="noopener noreferrer"> | ||
| Learn more | ||
| </a> | ||
| </mat-hint> | ||
| </mat-form-field> | ||
|
|
||
| <mat-form-field appearance="outline"> | ||
| <mat-label class="ft-14-400">Target</mat-label> | ||
| <input | ||
| matInput | ||
| formControlName="target" | ||
| placeholder="e.g., targetProblem" | ||
| class="ft-14-400" | ||
| [matAutocomplete]="targetAutocomplete" | ||
| /> | ||
| <mat-autocomplete #targetAutocomplete="matAutocomplete" panelWidth="auto"> | ||
| <mat-option | ||
| *ngFor="let target of filteredTargets$ | async" | ||
| [value]="target" | ||
| class="ft-14-400" | ||
| > | ||
| {{ target }} | ||
| </mat-option> | ||
| </mat-autocomplete> | ||
| <mat-hint class="form-hint ft-12-400"> | ||
| {{ 'experiments.upsert-decision-point-modal.target-hint.text' | translate }} | ||
| <a class="learn-more-link" href="https://www.upgradeplatform.org/" target="_blank" rel="noopener noreferrer"> | ||
| Learn more | ||
| </a> | ||
| </mat-hint> | ||
| </mat-form-field> | ||
|
|
||
| <div class="exclude-if-reached-container dense-1"> | ||
| <mat-checkbox formControlName="excludeIfReached"> | ||
| <span class="checkbox-label ft-14-600">Exclude If Reached</span> | ||
| <span class="form-hint ft-12-400" style="display:block; user-select: none;"> | ||
| {{ 'experiments.upsert-decision-point-modal.exclude-if-reached-hint.text' | translate }} | ||
| <a class="learn-more-link" href="https://www.upgradeplatform.org/" target="_blank" rel="noopener noreferrer"> | ||
| Learn more | ||
| </a> | ||
| </span> | ||
| </mat-checkbox> | ||
| </div> | ||
|
|
||
| </form> | ||
| </app-common-dialog> |
7 changes: 7 additions & 0 deletions
7
...experiments/modals/upsert-decision-point-modal/upsert-decision-point-modal.component.scss
This file contains hidden or 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,7 @@ | ||
| .exclude-if-reached-container { | ||
| margin-bottom: 16px; | ||
|
|
||
| .checkbox-label { | ||
| margin-left: 0; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.