Skip to content

Commit bdda2d3

Browse files
author
NarrowsProjects
committed
chore: add mundain normalized setters
1 parent 913cea9 commit bdda2d3

12 files changed

Lines changed: 115 additions & 5 deletions

lib/public/components/Filters/RunsFilter/DetectorsFilterModel.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ export class DetectorsFilterModel extends FilterModel {
6767
return normalized;
6868
}
6969

70+
/**
71+
* @inheritDoc
72+
*/
73+
set normalized({ operator, values }) {
74+
this._combinationOperatorModel.normalized = operator;
75+
this._dropdownModel.normalized = values;
76+
}
77+
7078
/**
7179
* Return true if the current combination operator is none
7280
*

lib/public/components/Filters/RunsFilter/EorReasonFilterModel.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ export class EorReasonFilterModel extends FilterModel {
6666
return ret;
6767
}
6868

69+
/**
70+
* @inheritDoc
71+
*/
72+
set normalized({ category, title, description }) {
73+
this._category = category;
74+
this._title = title;
75+
this._description = description;
76+
}
77+
6978
/**
7079
* Returns the EOR reason filter category
7180
*

lib/public/components/Filters/RunsFilter/GaqFilterModel.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ export class GaqFilterModel extends FilterModel {
6969
return normalized;
7070
}
7171

72+
/**
73+
* @inheritDoc
74+
*/
75+
set normalized({ notBadFraction, mcReproducibleAsNotBad }) {
76+
this._notBadFraction.normalized = notBadFraction;
77+
this._mcReproducibleAsNotBad.normalized = mcReproducibleAsNotBad;
78+
}
79+
7280
/**
7381
* Return the underlying notBadFraction model
7482
*

lib/public/components/Filters/RunsFilter/MultiCompositionFilterModel.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,15 @@ export class MultiCompositionFilterModel extends FilterModel {
8989

9090
return normalized;
9191
}
92+
93+
/**
94+
* @inheritDoc
95+
*/
96+
set normalized(filters) {
97+
for (const [key, value] of Object.entries(filters)) {
98+
if (key in this._filters) {
99+
this._filters[key].normalized = value;
100+
}
101+
}
102+
}
92103
}

lib/public/components/Filters/RunsFilter/TimeRangeFilter.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ export class TimeRangeFilterModel extends FilterModel {
4545
return normalized;
4646
}
4747

48+
/**
49+
* @inheritDoc
50+
*/
51+
set normalized({ from, to }) {
52+
this._timeRangeInputModel.normalized = { from, to };
53+
}
54+
4855
/**
4956
* Return the underlying time range input model
5057
*

lib/public/components/Filters/common/TagFilterModel.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,19 @@ export class TagFilterModel extends FilterModel {
5858
*/
5959
get normalized() {
6060
return {
61-
values: this.selected.join(),
61+
values: this._selectionModel.normalized,
6262
operation: this.combinationOperator,
6363
};
6464
}
6565

66+
/**
67+
* @inheritDoc
68+
*/
69+
set normalized({ values, operation }) {
70+
this._selectionModel.normalized = values;
71+
this._combinationOperatorModel.normalized = operation;
72+
}
73+
6674
/**
6775
* Return the model handling tag selection state
6876
*

lib/public/components/Filters/common/filters/NumericalComparisonFilterModel.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class NumericalComparisonFilterModel extends FilterModel {
2727
constructor(options) {
2828
super();
2929
const { scale = 1, integer = false } = options || {};
30+
this._scale = scale;
3031

3132
this._operatorSelectionModel = new ComparisonSelectionModel();
3233
this._operatorSelectionModel.visualChange$.bubbleTo(this._visualChange$);
@@ -82,11 +83,19 @@ export class NumericalComparisonFilterModel extends FilterModel {
8283
*/
8384
get normalized() {
8485
return {
85-
operator: this._operatorSelectionModel.current,
86-
limit: this._operandInputModel.value,
86+
operator: this._operatorSelectionModel.normalized,
87+
limit: this._operandInputModel.normalized,
8788
};
8889
}
8990

91+
/**
92+
* @inheritDoc
93+
*/
94+
set normalized({ operator, limit }) {
95+
this._operatorSelectionModel.normalized = operator;
96+
this._operandInputModel.normalized = parseFloat(limit) / this._scale;
97+
}
98+
9099
/**
91100
* @inheritDoc
92101
*/

lib/public/components/Filters/common/filters/ProcessedTextInputModel.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,26 @@ export class ProcessedTextInputModel extends Observable {
9898
this._value = null;
9999
}
100100

101+
/**
102+
* Returns the normalized value of the filter, that can be used as URL parameter
103+
* @returns {string}
104+
*/
105+
get normalized() {
106+
return this._value;
107+
}
108+
109+
/**
110+
* Sets filters from normalised values.
111+
*
112+
* @param {string} value The value used to set filters
113+
* @return {void}
114+
* @abstract
115+
*/
116+
set normalized(value) {
117+
this._value = value;
118+
this._raw = value;
119+
}
120+
101121
/**
102122
* Return the visual change observable
103123
*

lib/public/components/Filters/common/filters/RawTextFilterModel.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ export class RawTextFilterModel extends FilterModel {
3535
return this._value;
3636
}
3737

38+
/**
39+
* @inheritDoc
40+
*/
41+
set normalized(value) {
42+
this._value = value;
43+
}
44+
3845
/**
3946
* Return the filter current value
4047
*

lib/public/components/Filters/common/filters/TextComparisonFilterModel.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,19 @@ export class TextComparisonFilterModel extends FilterModel {
6464
*/
6565
get normalized() {
6666
return {
67-
operator: this._operatorSelectionModel.current,
68-
limit: this._operandInputModel.value,
67+
operator: this._operatorSelectionModel.normalized,
68+
limit: this._operandInputModel.normalized,
6969
};
7070
}
7171

72+
/**
73+
* @inheritDoc
74+
*/
75+
set normalized({ operator, limit }) {
76+
this._operatorSelectionModel.normalized = operator;
77+
this._operandInputModel.normalized = limit;
78+
}
79+
7280
/**
7381
* @inheritDoc
7482
*/

0 commit comments

Comments
 (0)