diff --git a/projects/abtesting/src/app/features/dashboard/home/components/experiment-design/experiment-design.component.html b/projects/abtesting/src/app/features/dashboard/home/components/experiment-design/experiment-design.component.html index fb9e8ad6..14387e41 100644 --- a/projects/abtesting/src/app/features/dashboard/home/components/experiment-design/experiment-design.component.html +++ b/projects/abtesting/src/app/features/dashboard/home/components/experiment-design/experiment-design.component.html @@ -129,6 +129,20 @@ + + + +
+ + {{ 'home.new-experiment.design.equal-assignment-weights.text' | translate }} + +
+
+
+ { + this.previousAssignmentWeightValues.push(control.get('assignmentWeight').value); + control.get('assignmentWeight').setValue((100.0/len).toFixed(2)); + }); + } + else { + conditions.controls.forEach( (control, index) => { + control.get('assignmentWeight').setValue(this.previousAssignmentWeightValues[index]); + }); + this.previousAssignmentWeightValues = []; + } + } + get condition(): FormArray { return this.experimentDesignForm.get('conditions') as FormArray; } @@ -265,9 +285,8 @@ export class ExperimentDesignComponent implements OnInit, OnChanges, OnDestroy { return false; } - ngOnDestroy() { this.allPartitionsSub.unsubscribe(); this.partitionErrorMessagesSub.unsubscribe(); } -} +} \ No newline at end of file diff --git a/projects/abtesting/src/app/features/dashboard/home/validators/experiment-form.validators.ts b/projects/abtesting/src/app/features/dashboard/home/validators/experiment-form.validators.ts index f1a3796f..fda2d767 100644 --- a/projects/abtesting/src/app/features/dashboard/home/validators/experiment-form.validators.ts +++ b/projects/abtesting/src/app/features/dashboard/home/validators/experiment-form.validators.ts @@ -12,9 +12,10 @@ export class ExperimentFormValidators { if (conditions.length < 2) { return { conditionCountError: true }; } else if (conditions.length >= 2) { - let sumOfAssignmentWeights = 0; - conditions.forEach(condition => (sumOfAssignmentWeights += parseInt(condition.assignmentWeight, 10))); - return sumOfAssignmentWeights !== 100 ? { assignmentWightsSumError: true } : null; + // handling sum of decimal values for assignment weights: + let sumOfAssignmentWeights = 0.0; + conditions.forEach(condition => (sumOfAssignmentWeights += parseFloat(condition.assignmentWeight))); + return Math.ceil(sumOfAssignmentWeights) !== 100.0 ? { assignmentWightsSumError: true } : null; } if (partitions.length < 1) { return { partitionCountError: true }; diff --git a/projects/abtesting/src/assets/i18n/en.json b/projects/abtesting/src/assets/i18n/en.json index 7064c770..338c31a4 100755 --- a/projects/abtesting/src/assets/i18n/en.json +++ b/projects/abtesting/src/assets/i18n/en.json @@ -95,6 +95,7 @@ "home.new-experiment.design.partition-id.placeholder.text": "ID", "home.new-experiment.design.add-experiment-partition.text": "Add Experiment Site", "home.new-experiment.design.assignment-weight-validation.text": "Assignment weights' sum must be 100", + "home.new-experiment.design.equal-assignment-weights.text": "Equal Weight Assignment", "home.new-experiment.design.assignment-partition-error-1.text": " partition data is already exist", "home.new-experiment.design.assignment-partition-error-2.text": " partition data are already exist", "home.new-experiment.design.assignment-partition-error-3.text": " partition data is duplicate",