Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
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
Vũ Hoàng Anh
canifa_note
Commits
9a3afc56
Commit
9a3afc56
authored
May 20, 2022
by
boojack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: shortcutId in filter
parent
3fc907d4
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
40 additions
and
35 deletions
+40
-35
CreateShortcutDialog.tsx
web/src/components/CreateShortcutDialog.tsx
+10
-8
ShortcutList.tsx
web/src/components/ShortcutList.tsx
+4
-3
api.ts
web/src/helpers/api.ts
+4
-4
locationService.ts
web/src/services/locationService.ts
+2
-4
shortcutService.ts
web/src/services/shortcutService.ts
+16
-11
locationStore.ts
web/src/stores/locationStore.ts
+1
-2
shortcutStore.ts
web/src/stores/shortcutStore.ts
+1
-1
location.d.ts
web/src/types/location.d.ts
+1
-1
shortcut.d.ts
web/src/types/modules/shortcut.d.ts
+1
-1
No files found.
web/src/components/CreateShortcutDialog.tsx
View file @
9a3afc56
...
@@ -8,7 +8,7 @@ import Selector from "./common/Selector";
...
@@ -8,7 +8,7 @@ import Selector from "./common/Selector";
import
"../less/create-shortcut-dialog.less"
;
import
"../less/create-shortcut-dialog.less"
;
interface
Props
extends
DialogProps
{
interface
Props
extends
DialogProps
{
shortcutId
?:
string
;
shortcutId
?:
ShortcutId
;
}
}
const
CreateShortcutDialog
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
const
CreateShortcutDialog
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
...
@@ -23,7 +23,8 @@ const CreateShortcutDialog: React.FC<Props> = (props: Props) => {
...
@@ -23,7 +23,8 @@ const CreateShortcutDialog: React.FC<Props> = (props: Props) => {
}).
length
;
}).
length
;
useEffect
(()
=>
{
useEffect
(()
=>
{
const
shortcutTemp
=
shortcutService
.
getShortcutById
(
shortcutId
??
""
);
if
(
shortcutId
)
{
const
shortcutTemp
=
shortcutService
.
getShortcutById
(
shortcutId
);
if
(
shortcutTemp
)
{
if
(
shortcutTemp
)
{
setTitle
(
shortcutTemp
.
title
);
setTitle
(
shortcutTemp
.
title
);
const
temp
=
JSON
.
parse
(
shortcutTemp
.
payload
);
const
temp
=
JSON
.
parse
(
shortcutTemp
.
payload
);
...
@@ -31,6 +32,7 @@ const CreateShortcutDialog: React.FC<Props> = (props: Props) => {
...
@@ -31,6 +32,7 @@ const CreateShortcutDialog: React.FC<Props> = (props: Props) => {
setFilters
(
temp
);
setFilters
(
temp
);
}
}
}
}
}
},
[
shortcutId
]);
},
[
shortcutId
]);
const
handleTitleInputChange
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
handleTitleInputChange
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
...
@@ -298,7 +300,7 @@ const FilterInputer: React.FC<MemoFilterInputerProps> = (props: MemoFilterInpute
...
@@ -298,7 +300,7 @@ const FilterInputer: React.FC<MemoFilterInputerProps> = (props: MemoFilterInpute
const
MemoFilterInputer
:
React
.
FC
<
MemoFilterInputerProps
>
=
memo
(
FilterInputer
);
const
MemoFilterInputer
:
React
.
FC
<
MemoFilterInputerProps
>
=
memo
(
FilterInputer
);
export
default
function
showCreateShortcutDialog
(
shortcutId
?:
string
):
void
{
export
default
function
showCreateShortcutDialog
(
shortcutId
?:
ShortcutId
):
void
{
showDialog
(
showDialog
(
{
{
className
:
"create-shortcut-dialog"
,
className
:
"create-shortcut-dialog"
,
...
...
web/src/components/ShortcutList.tsx
View file @
9a3afc56
import
{
useContext
,
useEffect
}
from
"react"
;
import
{
useContext
,
useEffect
}
from
"react"
;
import
{
locationService
,
shortcutService
}
from
"../services"
;
import
{
locationService
,
shortcutService
}
from
"../services"
;
import
appContext
from
"../stores/appContext"
;
import
appContext
from
"../stores/appContext"
;
import
{
UNKNOWN_ID
}
from
"../helpers/consts"
;
import
utils
from
"../helpers/utils"
;
import
useToggle
from
"../hooks/useToggle"
;
import
useToggle
from
"../hooks/useToggle"
;
import
useLoading
from
"../hooks/useLoading"
;
import
useLoading
from
"../hooks/useLoading"
;
import
utils
from
"../helpers/utils"
;
import
toastHelper
from
"./Toast"
;
import
toastHelper
from
"./Toast"
;
import
showCreateShortcutDialog
from
"./CreateShortcutDialog"
;
import
showCreateShortcutDialog
from
"./CreateShortcutDialog"
;
import
"../less/shortcut-list.less"
;
import
"../less/shortcut-list.less"
;
...
@@ -47,7 +48,7 @@ const ShortcutList: React.FC<Props> = () => {
...
@@ -47,7 +48,7 @@ const ShortcutList: React.FC<Props> = () => {
</
p
>
</
p
>
<
div
className=
"shortcuts-container"
>
<
div
className=
"shortcuts-container"
>
{
sortedShortcuts
.
map
((
s
)
=>
{
{
sortedShortcuts
.
map
((
s
)
=>
{
return
<
ShortcutContainer
key=
{
s
.
id
}
shortcut=
{
s
}
isActive=
{
s
.
id
===
shortcutId
}
/>;
return
<
ShortcutContainer
key=
{
s
.
id
}
shortcut=
{
s
}
isActive=
{
s
.
id
===
Number
(
shortcutId
)
}
/>;
})
}
})
}
</
div
>
</
div
>
</
div
>
</
div
>
...
@@ -65,7 +66,7 @@ const ShortcutContainer: React.FC<ShortcutContainerProps> = (props: ShortcutCont
...
@@ -65,7 +66,7 @@ const ShortcutContainer: React.FC<ShortcutContainerProps> = (props: ShortcutCont
const
handleShortcutClick
=
()
=>
{
const
handleShortcutClick
=
()
=>
{
if
(
isActive
)
{
if
(
isActive
)
{
locationService
.
setMemoShortcut
(
""
);
locationService
.
setMemoShortcut
(
UNKNOWN_ID
);
}
else
{
}
else
{
if
(
!
[
"/"
].
includes
(
locationService
.
getState
().
pathname
))
{
if
(
!
[
"/"
].
includes
(
locationService
.
getState
().
pathname
))
{
locationService
.
setPathname
(
"/"
);
locationService
.
setPathname
(
"/"
);
...
...
web/src/helpers/api.ts
View file @
9a3afc56
...
@@ -204,7 +204,7 @@ namespace api {
...
@@ -204,7 +204,7 @@ namespace api {
});
});
}
}
export
function
updateShortcut
(
shortcutId
:
string
,
title
:
string
,
payload
:
string
)
{
export
function
updateShortcut
(
shortcutId
:
ShortcutId
,
title
:
string
,
payload
:
string
)
{
return
request
<
Shortcut
>
({
return
request
<
Shortcut
>
({
method
:
"PATCH"
,
method
:
"PATCH"
,
url
:
`/api/shortcut/
${
shortcutId
}
`
,
url
:
`/api/shortcut/
${
shortcutId
}
`
,
...
@@ -215,14 +215,14 @@ namespace api {
...
@@ -215,14 +215,14 @@ namespace api {
});
});
}
}
export
function
deleteShortcutById
(
shortcutId
:
string
)
{
export
function
deleteShortcutById
(
shortcutId
:
ShortcutId
)
{
return
request
({
return
request
({
method
:
"DELETE"
,
method
:
"DELETE"
,
url
:
`/api/shortcut/
${
shortcutId
}
`
,
url
:
`/api/shortcut/
${
shortcutId
}
`
,
});
});
}
}
export
function
pinShortcut
(
shortcutId
:
string
)
{
export
function
pinShortcut
(
shortcutId
:
ShortcutId
)
{
return
request
({
return
request
({
method
:
"PATCH"
,
method
:
"PATCH"
,
url
:
`/api/shortcut/
${
shortcutId
}
`
,
url
:
`/api/shortcut/
${
shortcutId
}
`
,
...
@@ -232,7 +232,7 @@ namespace api {
...
@@ -232,7 +232,7 @@ namespace api {
});
});
}
}
export
function
unpinShortcut
(
shortcutId
:
string
)
{
export
function
unpinShortcut
(
shortcutId
:
ShortcutId
)
{
return
request
({
return
request
({
method
:
"PATCH"
,
method
:
"PATCH"
,
url
:
`/api/shortcut/
${
shortcutId
}
`
,
url
:
`/api/shortcut/
${
shortcutId
}
`
,
...
...
web/src/services/locationService.ts
View file @
9a3afc56
...
@@ -36,13 +36,12 @@ class LocationService {
...
@@ -36,13 +36,12 @@ class LocationService {
duration
:
null
,
duration
:
null
,
text
:
""
,
text
:
""
,
type
:
""
,
type
:
""
,
shortcutId
:
""
,
},
},
};
};
state
.
query
.
tag
=
urlParams
.
get
(
"tag"
)
??
""
;
state
.
query
.
tag
=
urlParams
.
get
(
"tag"
)
??
""
;
state
.
query
.
type
=
(
urlParams
.
get
(
"type"
)
??
""
)
as
MemoSpecType
;
state
.
query
.
type
=
(
urlParams
.
get
(
"type"
)
??
""
)
as
MemoSpecType
;
state
.
query
.
text
=
urlParams
.
get
(
"text"
)
??
""
;
state
.
query
.
text
=
urlParams
.
get
(
"text"
)
??
""
;
state
.
query
.
shortcutId
=
urlParams
.
get
(
"shortcutId"
)
??
""
;
state
.
query
.
shortcutId
=
Number
(
urlParams
.
get
(
"shortcutId"
))
??
undefined
;
const
from
=
parseInt
(
urlParams
.
get
(
"from"
)
??
"0"
);
const
from
=
parseInt
(
urlParams
.
get
(
"from"
)
??
"0"
);
const
to
=
parseInt
(
urlParams
.
get
(
"to"
)
??
"0"
);
const
to
=
parseInt
(
urlParams
.
get
(
"to"
)
??
"0"
);
if
(
to
>
from
&&
to
!==
0
)
{
if
(
to
>
from
&&
to
!==
0
)
{
...
@@ -71,7 +70,6 @@ class LocationService {
...
@@ -71,7 +70,6 @@ class LocationService {
duration
:
null
,
duration
:
null
,
text
:
""
,
text
:
""
,
type
:
""
,
type
:
""
,
shortcutId
:
""
,
},
},
});
});
...
@@ -142,7 +140,7 @@ class LocationService {
...
@@ -142,7 +140,7 @@ class LocationService {
updateLocationUrl
();
updateLocationUrl
();
};
};
public
setMemoShortcut
=
(
shortcutId
:
string
)
=>
{
public
setMemoShortcut
=
(
shortcutId
?:
ShortcutId
)
=>
{
appStore
.
dispatch
({
appStore
.
dispatch
({
type
:
"SET_SHORTCUT_ID"
,
type
:
"SET_SHORTCUT_ID"
,
payload
:
shortcutId
,
payload
:
shortcutId
,
...
...
web/src/services/shortcutService.ts
View file @
9a3afc56
import
userService
from
"./userService"
;
import
userService
from
"./userService"
;
import
api
from
"../helpers/api"
;
import
api
from
"../helpers/api"
;
import
appStore
from
"../stores/appStore"
;
import
appStore
from
"../stores/appStore"
;
import
{
UNKNOWN_ID
}
from
"../helpers/consts"
;
class
ShortcutService
{
class
ShortcutService
{
public
getState
()
{
public
getState
()
{
...
@@ -22,10 +23,14 @@ class ShortcutService {
...
@@ -22,10 +23,14 @@ class ShortcutService {
return
data
;
return
data
;
}
}
public
getShortcutById
(
id
:
string
)
{
public
getShortcutById
(
id
:
ShortcutId
)
{
for
(
const
q
of
this
.
getState
().
shortcuts
)
{
if
(
id
===
UNKNOWN_ID
)
{
if
(
q
.
id
===
id
)
{
return
null
;
return
q
;
}
for
(
const
s
of
this
.
getState
().
shortcuts
)
{
if
(
s
.
id
===
id
)
{
return
s
;
}
}
}
}
...
@@ -50,7 +55,7 @@ class ShortcutService {
...
@@ -50,7 +55,7 @@ class ShortcutService {
});
});
}
}
public
async
deleteShortcut
(
shortcutId
:
string
)
{
public
async
deleteShortcut
(
shortcutId
:
ShortcutId
)
{
await
api
.
deleteShortcutById
(
shortcutId
);
await
api
.
deleteShortcutById
(
shortcutId
);
appStore
.
dispatch
({
appStore
.
dispatch
({
type
:
"DELETE_SHORTCUT_BY_ID"
,
type
:
"DELETE_SHORTCUT_BY_ID"
,
...
@@ -60,21 +65,21 @@ class ShortcutService {
...
@@ -60,21 +65,21 @@ class ShortcutService {
});
});
}
}
public
async
createShortcut
(
title
:
string
,
shortcutstring
:
string
)
{
public
async
createShortcut
(
title
:
string
,
payload
:
string
)
{
const
data
=
await
api
.
createShortcut
(
title
,
shortcutstring
);
const
data
=
await
api
.
createShortcut
(
title
,
payload
);
return
data
;
return
data
;
}
}
public
async
updateShortcut
(
shortcutId
:
string
,
title
:
string
,
shortcutstring
:
string
)
{
public
async
updateShortcut
(
shortcutId
:
ShortcutId
,
title
:
string
,
payload
:
string
)
{
const
data
=
await
api
.
updateShortcut
(
shortcutId
,
title
,
shortcutstring
);
const
data
=
await
api
.
updateShortcut
(
shortcutId
,
title
,
payload
);
return
data
;
return
data
;
}
}
public
async
pinShortcut
(
shortcutId
:
string
)
{
public
async
pinShortcut
(
shortcutId
:
ShortcutId
)
{
await
api
.
pinShortcut
(
shortcutId
);
await
api
.
pinShortcut
(
shortcutId
);
}
}
public
async
unpinShortcut
(
shortcutId
:
string
)
{
public
async
unpinShortcut
(
shortcutId
:
ShortcutId
)
{
await
api
.
unpinShortcut
(
shortcutId
);
await
api
.
unpinShortcut
(
shortcutId
);
}
}
...
...
web/src/stores/locationStore.ts
View file @
9a3afc56
...
@@ -19,7 +19,7 @@ interface SetQueryAction {
...
@@ -19,7 +19,7 @@ interface SetQueryAction {
interface
SetShortcutIdAction
{
interface
SetShortcutIdAction
{
type
:
"SET_SHORTCUT_ID"
;
type
:
"SET_SHORTCUT_ID"
;
payload
:
string
;
payload
:
ShortcutId
|
undefined
;
}
}
interface
SetTagQueryAction
{
interface
SetTagQueryAction
{
...
@@ -183,6 +183,5 @@ export const defaultState: State = {
...
@@ -183,6 +183,5 @@ export const defaultState: State = {
duration
:
null
,
duration
:
null
,
type
:
""
,
type
:
""
,
text
:
""
,
text
:
""
,
shortcutId
:
""
,
},
},
};
};
web/src/stores/shortcutStore.ts
View file @
9a3afc56
...
@@ -21,7 +21,7 @@ interface InsertShortcutAction {
...
@@ -21,7 +21,7 @@ interface InsertShortcutAction {
interface
DeleteShortcutByIdAction
{
interface
DeleteShortcutByIdAction
{
type
:
"DELETE_SHORTCUT_BY_ID"
;
type
:
"DELETE_SHORTCUT_BY_ID"
;
payload
:
{
payload
:
{
id
:
string
;
id
:
ShortcutId
;
};
};
}
}
...
...
web/src/types/location.d.ts
View file @
9a3afc56
...
@@ -8,7 +8,7 @@ interface Query {
...
@@ -8,7 +8,7 @@ interface Query {
duration
:
Duration
|
null
;
duration
:
Duration
|
null
;
type
:
MemoSpecType
|
""
;
type
:
MemoSpecType
|
""
;
text
:
string
;
text
:
string
;
shortcutId
:
string
;
shortcutId
?:
ShortcutId
;
}
}
type
AppRouter
=
"/"
|
"/signin"
;
type
AppRouter
=
"/"
|
"/signin"
;
...
...
web/src/types/modules/shortcut.d.ts
View file @
9a3afc56
type
ShortcutId
=
number
;
type
ShortcutId
=
number
;
interface
Shortcut
{
interface
Shortcut
{
id
:
string
;
id
:
ShortcutId
;
rowStatus
:
RowStatus
;
rowStatus
:
RowStatus
;
createdTs
:
TimeStamp
;
createdTs
:
TimeStamp
;
...
...
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