@@ -2,7 +2,7 @@ import type { IFilter } from '$comp/faceted-filter';
2
2
import type { PersistentEventKnownTypes } from '$features/events/models' ;
3
3
import type { StackStatus } from '$features/stacks/models' ;
4
4
5
- import { quoteIfSpecialCharacters } from './helpers' ;
5
+ import { quoteIfSpecialCharacters } from './helpers.svelte ' ;
6
6
7
7
export class BooleanFilter implements IFilter {
8
8
public id : string = crypto . randomUUID ( ) ;
@@ -20,6 +20,12 @@ export class BooleanFilter implements IFilter {
20
20
this . value = value ;
21
21
}
22
22
23
+ public clone ( ) : IFilter {
24
+ const filter = new BooleanFilter ( this . term , this . value ) ;
25
+ filter . id = this . id ;
26
+ return filter ;
27
+ }
28
+
23
29
public toFilter ( ) : string {
24
30
if ( this . term === undefined ) {
25
31
return '' ;
@@ -31,14 +37,6 @@ export class BooleanFilter implements IFilter {
31
37
32
38
return `${ this . term } :${ this . value } ` ;
33
39
}
34
-
35
- public toJSON ( ) {
36
- return {
37
- term : this . term ,
38
- type : this . type ,
39
- value : this . value
40
- } ;
41
- }
42
40
}
43
41
44
42
export class DateFilter implements IFilter {
@@ -57,6 +55,12 @@ export class DateFilter implements IFilter {
57
55
this . value = value ;
58
56
}
59
57
58
+ public clone ( ) : IFilter {
59
+ const filter = new DateFilter ( this . term , this . value ) ;
60
+ filter . id = this . id ;
61
+ return filter ;
62
+ }
63
+
60
64
public toFilter ( ) : string {
61
65
if ( this . term === undefined ) {
62
66
return '' ;
@@ -69,14 +73,6 @@ export class DateFilter implements IFilter {
69
73
const date = this . value instanceof Date ? this . value . toISOString ( ) : this . value ;
70
74
return `${ this . term } :${ quoteIfSpecialCharacters ( date ) } ` ;
71
75
}
72
-
73
- public toJSON ( ) {
74
- return {
75
- term : this . term ,
76
- type : this . type ,
77
- value : this . value
78
- } ;
79
- }
80
76
}
81
77
82
78
export class KeywordFilter implements IFilter {
@@ -93,20 +89,19 @@ export class KeywordFilter implements IFilter {
93
89
this . value = value ;
94
90
}
95
91
92
+ public clone ( ) : IFilter {
93
+ const filter = new KeywordFilter ( this . value ) ;
94
+ filter . id = this . id ;
95
+ return filter ;
96
+ }
97
+
96
98
public toFilter ( ) : string {
97
99
if ( ! this . value ?. trim ( ) ) {
98
100
return '' ;
99
101
}
100
102
101
103
return this . value ! . trim ( ) ;
102
104
}
103
-
104
- public toJSON ( ) {
105
- return {
106
- type : this . type ,
107
- value : this . value
108
- } ;
109
- }
110
105
}
111
106
112
107
export class NumberFilter implements IFilter {
@@ -125,6 +120,12 @@ export class NumberFilter implements IFilter {
125
120
this . value = value ;
126
121
}
127
122
123
+ public clone ( ) : IFilter {
124
+ const filter = new NumberFilter ( this . term , this . value ) ;
125
+ filter . id = this . id ;
126
+ return filter ;
127
+ }
128
+
128
129
public toFilter ( ) : string {
129
130
if ( this . term === undefined ) {
130
131
return '' ;
@@ -136,14 +137,6 @@ export class NumberFilter implements IFilter {
136
137
137
138
return `${ this . term } :${ this . value } ` ;
138
139
}
139
-
140
- public toJSON ( ) {
141
- return {
142
- term : this . term ,
143
- type : this . type ,
144
- value : this . value
145
- } ;
146
- }
147
140
}
148
141
149
142
export class ProjectFilter implements IFilter {
@@ -160,6 +153,12 @@ export class ProjectFilter implements IFilter {
160
153
this . value = value ;
161
154
}
162
155
156
+ public clone ( ) : IFilter {
157
+ const filter = new ProjectFilter ( this . value ) ;
158
+ filter . id = this . id ;
159
+ return filter ;
160
+ }
161
+
163
162
public toFilter ( ) : string {
164
163
if ( this . value . length == 0 ) {
165
164
return '' ;
@@ -171,13 +170,6 @@ export class ProjectFilter implements IFilter {
171
170
172
171
return `(${ this . value . map ( ( val ) => `project:${ val } ` ) . join ( ' OR ' ) } )` ;
173
172
}
174
-
175
- public toJSON ( ) {
176
- return {
177
- type : this . type ,
178
- value : this . value
179
- } ;
180
- }
181
173
}
182
174
183
175
export class ReferenceFilter implements IFilter {
@@ -194,20 +186,19 @@ export class ReferenceFilter implements IFilter {
194
186
this . value = value ;
195
187
}
196
188
189
+ public clone ( ) : IFilter {
190
+ const filter = new ReferenceFilter ( this . value ) ;
191
+ filter . id = this . id ;
192
+ return filter ;
193
+ }
194
+
197
195
public toFilter ( ) : string {
198
196
if ( ! this . value ?. trim ( ) ) {
199
197
return '' ;
200
198
}
201
199
202
200
return `reference:${ quoteIfSpecialCharacters ( this . value ) } ` ;
203
201
}
204
-
205
- public toJSON ( ) {
206
- return {
207
- type : this . type ,
208
- value : this . value
209
- } ;
210
- }
211
202
}
212
203
213
204
export class SessionFilter implements IFilter {
@@ -224,6 +215,12 @@ export class SessionFilter implements IFilter {
224
215
this . value = value ;
225
216
}
226
217
218
+ public clone ( ) : IFilter {
219
+ const filter = new SessionFilter ( this . value ) ;
220
+ filter . id = this . id ;
221
+ return filter ;
222
+ }
223
+
227
224
public toFilter ( ) : string {
228
225
if ( ! this . value ?. trim ( ) ) {
229
226
return '' ;
@@ -232,13 +229,6 @@ export class SessionFilter implements IFilter {
232
229
const session = quoteIfSpecialCharacters ( this . value ) ;
233
230
return `(reference:${ session } OR ref.session:${ session } )` ;
234
231
}
235
-
236
- public toJSON ( ) {
237
- return {
238
- type : this . type ,
239
- value : this . value
240
- } ;
241
- }
242
232
}
243
233
244
234
export class StatusFilter implements IFilter {
@@ -255,6 +245,12 @@ export class StatusFilter implements IFilter {
255
245
this . value = value ;
256
246
}
257
247
248
+ public clone ( ) : IFilter {
249
+ const filter = new StatusFilter ( this . value ) ;
250
+ filter . id = this . id ;
251
+ return filter ;
252
+ }
253
+
258
254
public toFilter ( ) : string {
259
255
if ( this . value . length == 0 ) {
260
256
return '' ;
@@ -266,13 +262,6 @@ export class StatusFilter implements IFilter {
266
262
267
263
return `(${ this . value . map ( ( val ) => `status:${ val } ` ) . join ( ' OR ' ) } )` ;
268
264
}
269
-
270
- public toJSON ( ) {
271
- return {
272
- type : this . type ,
273
- value : this . value
274
- } ;
275
- }
276
265
}
277
266
278
267
export class StringFilter implements IFilter {
@@ -291,6 +280,12 @@ export class StringFilter implements IFilter {
291
280
this . value = value ;
292
281
}
293
282
283
+ public clone ( ) : IFilter {
284
+ const filter = new StringFilter ( this . term , this . value ) ;
285
+ filter . id = this . id ;
286
+ return filter ;
287
+ }
288
+
294
289
public toFilter ( ) : string {
295
290
if ( this . term === undefined ) {
296
291
return '' ;
@@ -302,14 +297,6 @@ export class StringFilter implements IFilter {
302
297
303
298
return `${ this . term } :${ quoteIfSpecialCharacters ( this . value ) } ` ;
304
299
}
305
-
306
- public toJSON ( ) {
307
- return {
308
- term : this . term ,
309
- type : this . type ,
310
- value : this . value
311
- } ;
312
- }
313
300
}
314
301
315
302
export class TypeFilter implements IFilter {
@@ -326,6 +313,12 @@ export class TypeFilter implements IFilter {
326
313
this . value = value ;
327
314
}
328
315
316
+ public clone ( ) : IFilter {
317
+ const filter = new TypeFilter ( this . value ) ;
318
+ filter . id = this . id ;
319
+ return filter ;
320
+ }
321
+
329
322
public toFilter ( ) : string {
330
323
if ( this . value . length == 0 ) {
331
324
return '' ;
@@ -337,13 +330,6 @@ export class TypeFilter implements IFilter {
337
330
338
331
return `(${ this . value . map ( ( val ) => `type:${ val } ` ) . join ( ' OR ' ) } )` ;
339
332
}
340
-
341
- public toJSON ( ) {
342
- return {
343
- type : this . type ,
344
- value : this . value
345
- } ;
346
- }
347
333
}
348
334
349
335
export class VersionFilter implements IFilter {
@@ -362,6 +348,12 @@ export class VersionFilter implements IFilter {
362
348
this . value = value ;
363
349
}
364
350
351
+ public clone ( ) : IFilter {
352
+ const filter = new VersionFilter ( this . term , this . value ) ;
353
+ filter . id = this . id ;
354
+ return filter ;
355
+ }
356
+
365
357
public toFilter ( ) : string {
366
358
if ( this . term === undefined ) {
367
359
return '' ;
@@ -373,12 +365,4 @@ export class VersionFilter implements IFilter {
373
365
374
366
return `${ this . term } :${ quoteIfSpecialCharacters ( this . value ) } ` ;
375
367
}
376
-
377
- public toJSON ( ) {
378
- return {
379
- term : this . term ,
380
- type : this . type ,
381
- value : this . value
382
- } ;
383
- }
384
368
}
0 commit comments