Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ComPlat
ela2
Commits
aabe43b1
Commit
aabe43b1
authored
Nov 14, 2020
by
chia-lin.lin
💬
Browse files
add comment feature
parent
1d3e7593
Changes
7
Hide whitespace changes
Inline
Side-by-side
app/assets/stylesheets/custom.scss
View file @
aabe43b1
...
...
@@ -33,7 +33,12 @@ p {
footer
{
background-color
:
#555
;
color
:
white
;
padding
:
15px
;
padding
:
5px
;
position
:
fixed
;
left
:
0
;
bottom
:
0
;
width
:
100%
;
text-align
:
left
;
}
/* On small screens, set height to 'auto' for sidenav and grid */
...
...
@@ -270,4 +275,8 @@ div.absolute {
#user_remember_me {
width: 10%;
}
}
\ No newline at end of file
}
.rm-mg-bottom {
margin-bottom: unset;
}
app/controllers/samples_controller.rb
View file @
aabe43b1
...
...
@@ -141,7 +141,7 @@ class SamplesController < ApplicationController
def
sample_params
keys
=
Sample
::
ELEMENTS
.
keys
params
.
require
(
:sample
).
permit
(
:name
,
:formula
,
results_attributes:
[
:id
,
:_destroy
,
:element_N
,
:element_C
,
:element_H
,
:element_S
])
if
params
[
:sample
].
present?
params
.
require
(
:sample
).
permit
(
:name
,
:formula
,
:comment_by_operator
,
:comment_by_user
,
results_attributes:
[
:id
,
:_destroy
,
:element_N
,
:element_C
,
:element_H
,
:element_S
])
if
params
[
:sample
].
present?
end
def
correct_user
...
...
app/views/layouts/_footer.html.erb
View file @
aabe43b1
<footer
class=
"container-fluid
text-center
"
>
<small>
<p
style=
"text-align:left"
>
© 2016 - ela
</
p></
small>
<footer
class=
"container-fluid"
>
<small>
© 2016 - ela
</small>
</footer>
app/views/samples/_comment.html.erb
0 → 100644
View file @
aabe43b1
<%=
form_for
(
@sample
)
do
|
f
|
%>
<%
if
@sample
.
errors
.
any?
%>
<div
id=
"error_explanation"
>
<h2>
<%=
pluralize
(
@sample
.
errors
.
count
,
"error"
)
%>
prohibited this sample from being saved:
</h2>
<ul>
<%
@sample
.
errors
.
full_messages
.
each
do
|
message
|
%>
<li>
<%=
message
%>
</li>
<%
end
%>
</ul>
</div>
<%
end
%>
<div
class=
"table-responsive"
style=
"margin-left: 20px"
>
<table
class=
"table rm-mg-bottom"
>
<tbody>
<tr>
<td>
<label
for=
"comment_by_op"
>
Operator comments
</label>
<%=
f
.
text_area
:comment_by_operator
,
class:
'form-control'
,
rows:
3
,
id:
'comment_by_op'
,
readonly:
!
operator?
%>
</td>
<td>
<label
for=
"comment_by_user"
>
Submitter comments
</label>
<%=
f
.
text_area
:comment_by_user
,
class:
'form-control'
,
rows:
3
,
id:
'comment_by_user'
,
readonly:
operator?
%>
</td>
</tr>
</tbody>
</table>
<div
class=
"links"
>
<%=
f
.
submit
"Save Comments"
,
class:
"btn btn-primary"
%>
</div>
</div>
<%
end
%>
app/views/samples/_edit.html.erb
View file @
aabe43b1
...
...
@@ -27,4 +27,5 @@
<br>
<%=
render
'form_operator'
%>
<%
end
%>
<%=
render
'comment'
%>
</div>
app/views/samples/_show.html.erb
View file @
aabe43b1
...
...
@@ -129,17 +129,18 @@ $(document).ready(function(){
</table>
<br>
<%
if
@sample
.
status
==
"in preparation"
%>
<div
class=
'
container
absolute'
>
<%=
link_to
(
@sample
.
status
?
"Submit for Measurement"
:
"No"
),
<div
class=
'absolute'
>
<%=
link_to
(
@sample
.
status
?
"Submit for Measurement"
:
"No"
),
Measured_sample_path
(
@sample
),
:action
=>
'solve'
,
:class
=>
'btn btn-block btn-success'
%>
</div>
<%
elsif
current_user?
(
@sample
.
user
)
&&
@sample
.
status
==
"submitted"
%>
<div
class=
'
container
absolute'
>
<%=
link_to
(
@sample
.
status
?
"Withdraw this Sample"
:
"No"
),
<div
class=
'absolute'
>
<%=
link_to
(
@sample
.
status
?
"Withdraw this Sample"
:
"No"
),
Withdraw_sample_path
(
@sample
),
:action
=>
'solve'
,
:class
=>
'btn btn-block btn-danger'
%>
</div>
<%
elsif
operator?
&&
@sample
.
status
==
"submitted"
%>
<div
class=
'
container
absolute'
>
<%=
link_to
(
@sample
.
status
?
"Release Measurement"
:
"No"
),
<div
class=
'absolute'
>
<%=
link_to
(
@sample
.
status
?
"Release Measurement"
:
"No"
),
ReleaseMeasurment_sample_path
(
@sample
),
:action
=>
'solve'
,
:class
=>
'btn btn-block btn-success'
%>
</div>
<%
end
%>
<%=
render
'samples/comment'
%>
<br>
<p>
<%=
link_to
"Download PDF"
,
sample_path
(
@sample
,
format:
"pdf"
),
target:
"_blank"
%>
<p>
db/migrate/20201113141600_add_comment_to_samples.rb
0 → 100644
View file @
aabe43b1
class
AddCommentToSamples
<
ActiveRecord
::
Migration
[
5.0
]
def
change
add_column
:samples
,
:comment_by_operator
,
:string
unless
column_exists?
:samples
,
:comment_by_operator
add_column
:samples
,
:comment_by_user
,
:string
unless
column_exists?
:samples
,
:comment_by_user
end
end
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