Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
hh1966
chemotion_eln_server
Commits
dd678d00
Commit
dd678d00
authored
Aug 27, 2019
by
hh1966
Browse files
Fix tables schemas in research plan detail
parent
0b16e22d
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/api/chemotion/research_plan_api.rb
View file @
dd678d00
...
...
@@ -69,6 +69,41 @@ module Chemotion
research_plan
end
namespace
:table_schemas
do
desc
"Return serialized table schemas of current user"
get
do
{
table_schemas:
ResearchPlanTableSchema
.
where
(
creator:
current_user
)}
end
desc
"Save table schema"
params
do
requires
:name
,
type:
String
requires
:value
,
type:
Hash
end
post
do
attributes
=
{
name:
params
[
:name
],
value:
params
[
:value
]
}
table_schema
=
ResearchPlanTableSchema
.
new
attributes
table_schema
.
creator
=
current_user
table_schema
.
save!
table_schema
end
desc
"Delete table schema"
route_param
:id
do
before
do
error!
(
'401 Unauthorized'
,
401
)
unless
TableSchemaPolicy
.
new
(
current_user
,
ResearchPlanTableSchema
.
find
(
params
[
:id
])).
destroy?
end
delete
do
ResearchPlanTableSchema
.
find
(
params
[
:id
]).
destroy
end
end
end
desc
"Return serialized research plan by id"
params
do
requires
:id
,
type:
Integer
,
desc:
"Research plan id"
...
...
@@ -186,42 +221,6 @@ module Chemotion
end
end
end
namespace
:table_schemas
do
desc
"Return serialized table schemas of current user"
get
do
{
table_schemas:
ResearchPlanTableSchema
.
where
(
creator:
current_user
)}
end
desc
"Save table schema"
params
do
requires
:name
,
type:
String
requires
:value
,
type:
Hash
end
post
do
attributes
=
{
name:
params
[
:name
],
value:
params
[
:value
]
}
table_schema
=
ResearchPlanTableSchema
.
new
attributes
table_schema
.
creator
=
current_user
table_schema
.
save!
table_schema
end
desc
"Delete table schema"
route_param
:id
do
before
do
error!
(
'401 Unauthorized'
,
401
)
unless
TableSchemaPolicy
.
new
(
current_user
,
ResearchPlanTableSchema
.
find
(
params
[
:id
])).
destroy?
end
delete
do
ResearchPlanTableSchema
.
find
(
params
[
:id
]).
destroy
end
end
end
end
end
end
app/assets/javascripts/components/fetchers/ResearchPlansFetcher.js
View file @
dd678d00
...
...
@@ -159,7 +159,11 @@ export default class ResearchPlansFetcher {
'
Content-Type
'
:
'
application/json
'
}
}).
then
(
response
=>
{
return
response
.
json
()
if
(
response
.
ok
)
{
return
response
.
json
()
}
else
{
console
.
log
(
response
)
}
}).
catch
((
errorMessage
)
=>
{
console
.
log
(
errorMessage
)
})
...
...
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