Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.editor
Commits
fd1f1078
Commit
fd1f1078
authored
Sep 24, 2018
by
Flavio TARSETTI
Browse files
[js][plotter] added possibility to add libraries
parent
134e1a10
Changes
1
Hide whitespace changes
Inline
Side-by-side
conda/js/src/components/plotter/PlotterEditor.jsx
View file @
fd1f1078
...
...
@@ -86,6 +86,81 @@ export class PlotterEditor extends React.Component<Props, State> {
this
.
setContents
({
parameters
:
params
});
}
// helper to change a value in the "contents" subobject of a plotter
// (this is where the vast majority of change happens)
changeContentsVal
=
(
field
:
string
,
val
:
any
)
=>
{
const
newCache
=
{
...
this
.
props
.
data
,
contents
:
{
...
this
.
props
.
data
.
contents
,
[
field
]:
val
}
};
this
.
props
.
updateFunc
(
newCache
);
}
renderLibraries
=
()
=>
(
<
TabPane
tabId
=
'2'
>
<
Row
>
<
Col
sm
=
'12'
>
{
// loop through all the used libs
(
Object
.
entries
(
this
.
props
.
data
.
contents
.
uses
):
[
string
,
any
][])
.
map
(([
name
,
lib
],
i
,
lEntries
)
=>
(
<
TypedField
key
=
{
i
}
name
=
{
name
}
type
=
{
lib
}
types
=
{
this
.
props
.
libraries
.
map
(
l
=>
l
.
name
)
}
existingFields
=
{
lEntries
.
map
(([
n
,
v
])
=>
n
)
}
nameUpdateFunc
=
{
str
=>
{
// update the alias
this
.
changeContentsVal
(
'
uses
'
,
changeObjFieldName
(
this
.
props
.
data
.
contents
.
uses
,
name
,
str
)
);
}
}
typeUpdateFunc
=
{
str
=>
{
// update the chosen library for the alias
const
libs
=
{
...
this
.
props
.
data
.
contents
.
uses
,
[
name
]:
str
};
this
.
changeContentsVal
(
'
uses
'
,
libs
);
}
}
deleteFunc
=
{
()
=>
{
const
libs
=
{
...
this
.
props
.
data
.
contents
.
uses
};
delete
libs
[
name
];
this
.
changeContentsVal
(
'
uses
'
,
libs
);
}
}
/>
))
}
</
Col
>
</
Row
>
<
Button
outline
block
id
=
'newLibraryBtn'
onClick
=
{
()
=>
{
const
newKey
=
generateNewKey
(
'
library
'
,
Object
.
keys
(
this
.
props
.
data
.
contents
.
uses
));
this
.
changeContentsVal
(
'
uses
'
,
{
...
this
.
props
.
data
.
contents
.
uses
,
[
newKey
]:
''
}
);
}
}
>
New Library
</
Button
>
</
TabPane
>
);
render
=
()
=>
{
return
(
<
div
>
...
...
@@ -131,6 +206,10 @@ export class PlotterEditor extends React.Component<Props, State> {
}
</
Input
>
</
FormGroup
>
<
FormGroup
>
<
h5
>
Libraries
</
h5
>
{
this
.
renderLibraries
()
}
</
FormGroup
>
<
FormGroup
>
<
h5
>
Parameters
</
h5
>
{
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment