Skip to content

Commit

Permalink
removed disable on context change in experiment edit modal (#2094)
Browse files Browse the repository at this point in the history
* removed disable on context change in experiment edit modal

* Remove logging checkbox and enableSave variable; Add warning message for Context/Design Type changes in Overview step

---------

Co-authored-by: Zack Lee <[email protected]>
Co-authored-by: Zack Lee <[email protected]>
  • Loading branch information
3 people authored Nov 8, 2024
1 parent 3d0ef14 commit d7b25e9
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
} from './store/experiments.selectors';
import * as experimentAction from './store//experiments.actions';
import { AppState } from '../core.state';
import { map, first, filter, tap } from 'rxjs/operators';
import { map, filter, tap } from 'rxjs/operators';
import { LocalStorageService } from '../local-storage/local-storage.service';
import { ENV, Environment } from '../../../environments/environment-types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ export enum ExperimentDesignTypes {
FACTORIAL = 'Factorial',
}

export enum OverviewFormWarningStatus {
NO_WARNING = 'no warning',
CONTEXT_CHANGED = 'context changed',
DESIGN_TYPE_CHANGED = 'design type changed',
}

export interface NewExperimentDialogData {
type: NewExperimentDialogEvents;
formData?: any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ export class ExperimentDesignComponent implements OnInit, OnChanges, OnDestroy {
this.conditionCode.nativeElement.focus();
}

if (this.isContextChanged || this.isExperimentTypeChanged) {
this.isContextChanged = false;
if (this.isExperimentTypeChanged) {
this.decisionPoints?.clear();
this.conditions?.clear();
this.decisionPointDataSource.next(this.decisionPoints?.controls);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,21 @@
/>
</mat-chip-grid>
</mat-form-field>
<mat-checkbox class="check-box" color="primary" formControlName="logging">
<span class="ft-13-700 checkbox-label">
{{ 'home.view-experiment.logging.text' | translate }}
</span>
</mat-checkbox>
</form>
<div class="validation-container">
<span
class="ft-14-600 validation-message"
*ngIf="!isStratificationFactorSelected"
[innerHTML]="stratificationFactorNotSelectedMsg | translate"
></span>
<span class="ft-14-600 validation-message" *ngIf="isOverviewFormCompleted" [ngSwitch]="warningStatus">
<ng-container *ngSwitchCase="OverviewFormWarningStatus.CONTEXT_CHANGED">
{{ 'home.new-experiment.overview.context-changed.warning.text' | translate }}
</ng-container>
<ng-container *ngSwitchCase="OverviewFormWarningStatus.DESIGN_TYPE_CHANGED">
{{ 'home.new-experiment.overview.design-type-changed.warning.text' | translate }}
</ng-container>
</span>
</div>
</section>

Expand Down Expand Up @@ -209,13 +212,13 @@
</button>
<button
type="button"
*ngIf="experimentInfo && enableSave"
*ngIf="experimentInfo"
mat-raised-button
class="shared-modal--modal-btn default-button"
[ngClass]="{
'default-button--disabled': !isExperimentEditable || isContextOrTypeChanged
'default-button--disabled': !isExperimentEditable || isDesignTypeChanged
}"
[disabled]="!isExperimentEditable || isContextOrTypeChanged"
[disabled]="!isExperimentEditable || isDesignTypeChanged"
(click)="emitEvent(NewExperimentDialogEvents.SAVE_DATA)"
>
{{ 'global.save.text' | translate }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
}
}

.validation-container {
min-height: 30px;
margin-top: 5px;
margin-bottom: 5px;
}

.loading-container {
display: flex;
height: 500px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
NewExperimentPaths,
IContextMetaData,
ExperimentDesignTypes,
OverviewFormWarningStatus,
} from '../../../../../core/experiments/store/experiments.model';
import { ENTER, COMMA } from '@angular/cdk/keycodes';
import { UntypedFormGroup, UntypedFormBuilder, Validators, UntypedFormArray } from '@angular/forms';
Expand Down Expand Up @@ -53,11 +54,12 @@ export class ExperimentOverviewComponent implements OnInit, OnDestroy {
public ASSIGNMENT_UNIT = ASSIGNMENT_UNIT;

groupTypes = [];
enableSave = true;
allContexts = [];
currentContext = null;
initialDesignType = EXPERIMENT_TYPE.SIMPLE;
isContextOrTypeChanged = false;
warningStatus = OverviewFormWarningStatus.NO_WARNING;
OverviewFormWarningStatus = OverviewFormWarningStatus;
isOverviewFormCompleted = false;
consistencyRules = [{ value: CONSISTENCY_RULE.INDIVIDUAL }, { value: CONSISTENCY_RULE.GROUP }];
conditionOrders = [
{ value: CONDITION_ORDER.RANDOM },
Expand Down Expand Up @@ -134,7 +136,6 @@ export class ExperimentOverviewComponent implements OnInit, OnDestroy {
stratificationFactor: [null],
context: [null, Validators.required],
tags: [[]],
logging: [false],
});

this.overviewForm.get('unitOfAssignment').valueChanges.subscribe((assignmentUnit) => {
Expand Down Expand Up @@ -176,14 +177,18 @@ export class ExperimentOverviewComponent implements OnInit, OnDestroy {
});

this.overviewForm.get('context').valueChanges.subscribe((context) => {
this.isContextOrTypeChanged = this.currentContext !== context;
if (context && this.currentContext && this.currentContext !== context) {
this.warningStatus = OverviewFormWarningStatus.CONTEXT_CHANGED;
}
this.currentContext = context;
this.experimentService.setCurrentContext(context);
this.setGroupTypes();
});

this.overviewForm.get('designType').valueChanges.subscribe((type) => {
this.isContextOrTypeChanged = this.initialDesignType !== type;
if (this.initialDesignType !== type) {
this.warningStatus = OverviewFormWarningStatus.DESIGN_TYPE_CHANGED;
}
this.initialDesignType = type;
});

Expand Down Expand Up @@ -216,9 +221,9 @@ export class ExperimentOverviewComponent implements OnInit, OnDestroy {
stratificationFactor: this.experimentInfo.stratificationFactor?.stratificationFactorName || null,
context: this.currentContext,
tags: this.experimentInfo.tags,
logging: this.experimentInfo.logging,
});
this.checkExperiment();
this.isOverviewFormCompleted = true;
}
});
}
Expand Down Expand Up @@ -335,7 +340,6 @@ export class ExperimentOverviewComponent implements OnInit, OnDestroy {
assignmentAlgorithm,
stratificationFactor,
tags,
logging,
} = this.overviewForm.value;
const stratificationFactorValueToSend = this.stratificationFactorValueToSend(
stratificationFactor,
Expand All @@ -356,7 +360,6 @@ export class ExperimentOverviewComponent implements OnInit, OnDestroy {
? { stratificationFactorName: stratificationFactorValueToSend }
: null,
tags,
logging,
};
this.emitExperimentDialogEvent.emit({
type: eventType,
Expand All @@ -367,6 +370,9 @@ export class ExperimentOverviewComponent implements OnInit, OnDestroy {
if (eventType == NewExperimentDialogEvents.SAVE_DATA) {
this.experimentDesignStepperService.experimentStepperDataReset();
this.overviewForm.markAsPristine();
} else if (eventType == NewExperimentDialogEvents.SEND_FORM_DATA) {
this.warningStatus = OverviewFormWarningStatus.NO_WARNING;
this.isOverviewFormCompleted = true;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@
</button>
<button
type="button"
*ngIf="experimentInfo && enableSave"
*ngIf="experimentInfo"
mat-raised-button
class="shared-modal--modal-btn default-button"
(click)="emitEvent(NewExperimentDialogEvents.SAVE_DATA)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export class ExperimentParticipantsComponent implements OnInit {
inclusionCriteria = [{ value: INCLUSION_CRITERIA.INCLUDE_SPECIFIC }, { value: INCLUSION_CRITERIA.EXCEPT }];
membersDisplayedColumns = ['type', 'id', 'removeMember'];

enableSave = true;
contextMetaData: IContextMetaData | Record<string, unknown> = {};
contextMetaDataSub: Subscription;
allSegments: Segment[];
Expand Down
2 changes: 2 additions & 0 deletions frontend/projects/upgrade/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@
"home.new-experiment.overview.context.error.text": "Please enter at least one context",
"home.new-experiment.overview.stratification-factor.error.text": "Please select stratification factor",
"home.new-experiment.overview.no-stratification-factor.error.text": "Please import the stratification factor you require from Participants Menu > Stratification Tab",
"home.new-experiment.overview.context-changed.warning.text": "Changing the App Context will clear all fields in the Participants and Metrics steps. Please review before saving.",
"home.new-experiment.overview.design-type-changed.warning.text": "Changing the Design Type will clear all fields in the Design step. Please review before saving.",
"home.new-experiment.design.design-type.label": "Design Type",
"home.new-experiment.design.decision-point.initial.include-message": "Experiments require at least one decision point",
"home.new-experiment.design.factors.initial.include-message": "Factorial experiments require factors",
Expand Down

0 comments on commit d7b25e9

Please sign in to comment.