@@ -10,20 +10,13 @@ import { observer } from 'mobx-react';
10
10
import { StudyViewPageStore } from 'pages/studyView/StudyViewPageStore' ;
11
11
12
12
export interface IPillTagProps {
13
- content : { uniqueChartKey : string ; element : JSX . Element } | string ;
13
+ content : string | { uniqueChartKey : string ; element : JSX . Element } ;
14
14
backgroundColor : string ;
15
15
infoSection ?: JSX . Element | null ;
16
16
onDelete ?: ( ) => void ;
17
17
store : StudyViewPageStore ;
18
18
}
19
19
20
- /**
21
- * Contains:
22
- * {id: "<pill text>"}
23
- * Wrinkles:
24
- * - when bookmarking, and in hesitation mode: are filters saved?
25
- */
26
-
27
20
type hesitantPillStoreEntry = {
28
21
key : string ;
29
22
onDeleteCallback ?: ( ) => void ;
@@ -42,9 +35,8 @@ export class PillTag extends React.Component<IPillTagProps, {}> {
42
35
constructor ( props : IPillTagProps ) {
43
36
super ( props ) ;
44
37
makeObservable ( this ) ;
45
- console . log ( 'this.props.content' , this . props . content ) ;
46
38
if ( this . hesitateUpdate ) {
47
- this . registerHesitantPill ( ) ;
39
+ this . putHesitantPill ( ) ;
48
40
}
49
41
}
50
42
@@ -76,7 +68,7 @@ export class PillTag extends React.Component<IPillTagProps, {}> {
76
68
if ( this . hesitateUpdate && ! this . hesitantPillStoreEntry ) {
77
69
// Postpone deleting of submitted filters in hesitate mode:
78
70
this . isDeleted = true ;
79
- this . registerHesitantPill ( ) ;
71
+ this . putHesitantPill ( ) ;
80
72
}
81
73
}
82
74
@@ -89,7 +81,7 @@ export class PillTag extends React.Component<IPillTagProps, {}> {
89
81
/**
90
82
* Add or update pill in hesitantPillStore
91
83
*/
92
- private registerHesitantPill ( ) {
84
+ private putHesitantPill ( ) {
93
85
const onDeleteCallback = this . isDeleted
94
86
? ( ) => {
95
87
if ( this . props . onDelete ) {
@@ -108,6 +100,25 @@ export class PillTag extends React.Component<IPillTagProps, {}> {
108
100
return getBrowserWindow ( ) . hesitantPillStore ;
109
101
}
110
102
103
+ /**
104
+ * Only pills of queued filters have an entry in this store
105
+ */
106
+ private get hesitantPillStoreEntry ( ) {
107
+ const key = this . hesitantPillStoreKey ;
108
+ return ( this . hesitantPillStore as any ) [ key ] ;
109
+ }
110
+
111
+ private get hesitantPillStoreKey ( ) {
112
+ return _ . isString ( this . props . content )
113
+ ? this . props . content
114
+ : this . props . content . uniqueChartKey ;
115
+ }
116
+ private get contentToRender ( ) {
117
+ return _ . isString ( this . props . content )
118
+ ? this . props . content
119
+ : this . props . content . element ;
120
+ }
121
+
111
122
render ( ) {
112
123
const isPending = ! ! this . hesitantPillStoreEntry ;
113
124
@@ -116,7 +127,7 @@ export class PillTag extends React.Component<IPillTagProps, {}> {
116
127
className = { classnames ( {
117
128
[ styles . main ] : true ,
118
129
[ styles . pending ] : isPending ,
119
- [ styles . deleted ] : this . isDeleted ,
130
+ [ styles . pendingDelete ] : this . isDeleted ,
120
131
} ) }
121
132
style = { {
122
133
background : this . props . backgroundColor ,
@@ -147,23 +158,4 @@ export class PillTag extends React.Component<IPillTagProps, {}> {
147
158
</ div >
148
159
) ;
149
160
}
150
-
151
- /**
152
- * Only pills of queued filters have an entry in this store
153
- */
154
- private get hesitantPillStoreEntry ( ) {
155
- const key = this . hesitantPillStoreKey ;
156
- return ( this . hesitantPillStore as any ) [ key ] ;
157
- }
158
-
159
- private get hesitantPillStoreKey ( ) {
160
- return _ . isString ( this . props . content )
161
- ? this . props . content
162
- : this . props . content . uniqueChartKey ;
163
- }
164
- private get contentToRender ( ) {
165
- return _ . isString ( this . props . content )
166
- ? this . props . content
167
- : this . props . content . element ;
168
- }
169
161
}
0 commit comments