Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Knowledge Space WP Plugin
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
alg
Knowledge Space WP Plugin
Commits
32c8c16d
Commit
32c8c16d
authored
2 years ago
by
Maximilian Giller
Browse files
Options
Downloads
Patches
Plain Diff
Allows color input to be edited
parent
8b768acb
No related branches found
No related tags found
1 merge request
!2
Implemented editor in the react framework
Pipeline
#56831
passed
2 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/editor/js/components/nodetypeentry.tsx
+32
-9
32 additions, 9 deletions
src/editor/js/components/nodetypeentry.tsx
with
32 additions
and
9 deletions
src/editor/js/components/nodetypeentry.tsx
+
32
−
9
View file @
32c8c16d
...
@@ -18,10 +18,11 @@ export class NodeTypeEntry extends React.Component<propTypes, stateTypes> {
...
@@ -18,10 +18,11 @@ export class NodeTypeEntry extends React.Component<propTypes, stateTypes> {
super
(
props
);
super
(
props
);
this
.
deleteType
=
this
.
deleteType
.
bind
(
this
);
this
.
deleteType
=
this
.
deleteType
.
bind
(
this
);
this
.
handleTextChange
=
this
.
handleTextChange
.
bind
(
this
);
this
.
handleTextChange
=
this
.
handleTextChange
.
bind
(
this
);
this
.
handleColorChange
=
this
.
handleColorChange
.
bind
(
this
);
this
.
s
etS
tate
(
{
this
.
state
=
{
temporaryColor
:
undefined
,
temporaryColor
:
undefined
,
}
)
;
};
}
}
private
deleteType
()
{
private
deleteType
()
{
...
@@ -29,17 +30,39 @@ export class NodeTypeEntry extends React.Component<propTypes, stateTypes> {
...
@@ -29,17 +30,39 @@ export class NodeTypeEntry extends React.Component<propTypes, stateTypes> {
}
}
private
isValidColor
(
color
:
string
):
boolean
{
private
isValidColor
(
color
:
string
):
boolean
{
if
(
color
.
length
<=
0
||
color
[
0
]
!==
"
#
"
)
{
if
(
color
.
length
<=
0
)
{
return
false
;
return
false
;
}
}
const
colorCode
=
color
.
substring
(
1
);
// Source: https://stackoverflow.com/a/8027444
return
/^#
([
0-9A-F
]{3}){1,2}
$/i
.
test
(
color
);
}
if
(
!
(
colorCode
.
length
===
3
||
colorCode
.
length
===
6
))
{
private
handleColorChange
(
event
:
any
)
{
return
false
;
const
newColor
=
event
.
target
.
value
;
if
(
this
.
isValidColor
(
newColor
))
{
// Is actual change?
if
(
this
.
props
.
type
.
color
!==
newColor
)
{
// Update proper color
this
.
props
.
type
.
color
=
newColor
;
this
.
props
.
type
.
graph
.
storeCurrentData
(
"
Changed color of type [
"
+
this
.
props
.
type
+
"
]
"
);
}
// Reset temporary value
this
.
setState
({
temporaryColor
:
undefined
,
});
}
else
{
// Only set as temporary value
this
.
setState
({
temporaryColor
:
newColor
,
});
}
}
colorCode
;
this
.
props
.
onChange
()
;
}
}
/**
/**
...
@@ -77,11 +100,11 @@ export class NodeTypeEntry extends React.Component<propTypes, stateTypes> {
...
@@ -77,11 +100,11 @@ export class NodeTypeEntry extends React.Component<propTypes, stateTypes> {
className
=
"node-type-color"
className
=
"node-type-color"
type
=
{
"
text
"
}
type
=
{
"
text
"
}
value
=
{
value
=
{
this
.
state
.
temporaryColor
this
.
state
.
temporaryColor
!==
undefined
?
this
.
state
.
temporaryColor
?
this
.
state
.
temporaryColor
:
this
.
props
.
type
.
color
:
this
.
props
.
type
.
color
}
}
onChange
=
{
(
event
)
=>
this
.
handle
Text
Change
(
event
,
"
color
"
)
}
onChange
=
{
(
event
)
=>
this
.
handle
Color
Change
(
event
)
}
/>
/>
{
this
.
props
.
graph
&&
this
.
props
.
graph
.
types
.
length
>
1
?
(
{
this
.
props
.
graph
&&
this
.
props
.
graph
.
types
.
length
>
1
?
(
<
button
onClick
=
{
this
.
deleteType
}
>
Delete
</
button
>
<
button
onClick
=
{
this
.
deleteType
}
>
Delete
</
button
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment