Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
c564c77f
Commit
c564c77f
authored
May 18, 2023
by
Alejandro Celaya
Committed by
Alejandro Celaya
May 18, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate StreamFilter to TS
parent
67ccfb08
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
24 deletions
+43
-24
stream-filter.ts
src/sidebar/services/stream-filter.ts
+43
-24
No files found.
src/sidebar/services/stream-filter.
j
s
→
src/sidebar/services/stream-filter.
t
s
View file @
c564c77f
/**
/**
* Filter clause against which annotation updates are tested before being
* Filter clause against which annotation updates are tested before being
* sent to the client.
* sent to the client.
*
* @typedef FilterClause
* @prop {'/group'|'/id'|'/references'|'/uri'} field
* @prop {'equals'|'one_of'} operator
* @prop {string|string[]} value
* @prop {boolean} case_sensitive - TODO: Backend doesn't use this at present,
* but it seems important for certain fields (eg. ID).
*/
*/
type
FilterClause
=
{
field
:
'/group'
|
'/id'
|
'/references'
|
'/uri'
;
operator
:
'equals'
|
'one_of'
;
value
:
string
|
string
[];
/**
/**
* @typedef Filter
* @todo Backend doesn't use this at present, but it seems important for
* @prop {string} match_policy - TODO: Remove this, the backend doesn't use it any more.
* certain fields (eg. ID).
* @prop {FilterClause[]} clauses
*/
* @prop {object} actions - TODO: Remove this, the backend doesn't use it any more.
case_sensitive
:
boolean
;
* @prop {boolean} [actions.create]
};
* @prop {boolean} [actions.update]
* @prop {boolean} [actions.delete]
type
Filter
=
{
*/
clauses
:
FilterClause
[];
/**
* @deprecated
* @todo Remove this, the backend doesn't use it any more.
*/
match_policy
:
string
;
/**
* @deprecated
* @todo Remove this, the backend doesn't use it any more.
*/
actions
:
{
create
:
boolean
;
update
:
boolean
;
delete
:
boolean
;
};
};
/**
/**
* Return a filter which matches every update that is visible to the current user.
* Return a filter which matches every update that is visible to the current user.
*
* @return {Filter}
*/
*/
function
defaultFilter
()
{
function
defaultFilter
()
:
Filter
{
return
{
return
{
match_policy
:
'include_any'
,
match_policy
:
'include_any'
,
clauses
:
[],
clauses
:
[],
...
@@ -45,6 +57,8 @@ function defaultFilter() {
...
@@ -45,6 +57,8 @@ function defaultFilter() {
* for the schema.
* for the schema.
*/
*/
export
class
StreamFilter
{
export
class
StreamFilter
{
private
_filter
:
Filter
;
constructor
()
{
constructor
()
{
this
.
_filter
=
defaultFilter
();
this
.
_filter
=
defaultFilter
();
}
}
...
@@ -52,12 +66,17 @@ export class StreamFilter {
...
@@ -52,12 +66,17 @@ export class StreamFilter {
/**
/**
* Add a matching clause to the configuration.
* Add a matching clause to the configuration.
*
*
* @param
{FilterClause['field']}
field - Field to filter by
* @param field - Field to filter by
* @param
{FilterClause['operator']}
operator - How to filter
* @param operator - How to filter
* @param
{FilterClause['value']}
value - Value to match
* @param value - Value to match
* @param
{FilterClause['case_sensitive']} caseSensitive - Whether matching should be case
sensitive
* @param
caseSensitive - Whether matching should be case-
sensitive
*/
*/
addClause
(
field
,
operator
,
value
,
caseSensitive
=
false
)
{
addClause
(
field
:
FilterClause
[
'field'
],
operator
:
FilterClause
[
'operator'
],
value
:
FilterClause
[
'value'
],
caseSensitive
:
FilterClause
[
'case_sensitive'
]
=
false
)
{
this
.
_filter
.
clauses
.
push
({
this
.
_filter
.
clauses
.
push
({
field
,
field
,
operator
,
operator
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment