Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
openproject
Service Pack
Commits
48332249
Verified
Commit
48332249
authored
6 years ago
by
Tam Le
Browse files
Options
Download
Email Patches
Plain Diff
Refactor Assigns#show view
parent
d2cd4b34
master
addtional_notification_email
api-fix-time-entry
dont_have_notify
edit_total_units
feature/multiple-SP
feature/notification
feature/report-with-filter
fix/1-gitlab
fix/3-gitlab
fix/3bis-gitlab
fix/handle_when_remain_unit_is_zero
fix_run_out_mail_sent_3_times
improvement/rollback_when_logtime_exceed_remain_unit
make_notify_email_send_once_only
threshold_uses_unit_instead_of_percent
v1.0.5
v1.0.4
v1.0.3
v1.0.2
v1.0.1
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/controllers/assigns_controller.rb
+6
-4
app/controllers/assigns_controller.rb
app/views/assigns/not_assigned_yet.html.erb
+15
-18
app/views/assigns/not_assigned_yet.html.erb
app/views/assigns/unassignable.html.erb
+4
-0
app/views/assigns/unassignable.html.erb
with
25 additions
and
22 deletions
+25
-22
app/controllers/assigns_controller.rb
+
6
-
4
View file @
48332249
...
...
@@ -18,7 +18,7 @@ class AssignsController < ApplicationController
if
@service_pack
.
available?
assign_to
(
@service_pack
,
@project
)
flash
[
:notice
]
=
"Service Pack
#{
@service_pack
.
name
}
successfully assigned to project
#{
@project
.
name
}
"
re
direct_to
action: :
show
and
return
re
nder
'
show
'
and
return
else
# already assigned for another project
# constraint need
...
...
@@ -47,7 +47,6 @@ class AssignsController < ApplicationController
User
.
current
.
allowed_to?
(
:see_assigned_service_packs
,
@project
)
||
(
@can_assign
=
User
.
current
.
allowed_to?
(
:assign_service_packs
,
@project
))
||
(
@can_unassign
=
User
.
current
.
allowed_to?
(
:unassign_service_packs
,
@project
))
# binding.pry
if
@assignment
=
@project
.
assigns
.
find_by
(
assigned:
true
)
if
@assignment
.
service_pack
.
unavailable?
...
...
@@ -59,10 +58,13 @@ class AssignsController < ApplicationController
# binding.pry
if
@assignment
.
nil?
if
@can_assign
||=
User
.
current
.
allowed_to?
(
:assign_service_packs
,
@project
)
@assignment
=
Assign
.
new
@assignables
=
ServicePack
.
availables
if
@assignables
.
exists?
@assignment
=
Assign
.
new
render
-
'not_assigned_yet'
and
return
end
end
render
-
'n
ot_
assign
ed_yet
'
render
-
'
u
nassign
able
'
# binding.pry
else
@service_pack
=
@assignment
.
service_pack
...
...
This diff is collapsed.
Click to expand it.
app/views/assigns/not_assigned_yet.html.erb
+
15
-
18
View file @
48332249
<%=
javascript_include_tag
'assigns.js'
,
plugin: :openproject_service_packs
if
@can_assign
||=
User
.
current
.
allowed_to?
(
:assign_service_packs
,
@project
)
%>
<%=
javascript_include_tag
'assigns.js'
,
plugin: :openproject_service_packs
%>
<div
id=
"sp-assign"
>
<h2>
No Service Pack is assigned to this project.
</h2>
<br/>
<%
if
@can_assign
&&
@assignables
.
any?
%>
<%=
form_with
model:
@assignment
,
url:
assigns_assign_path
(
@project
),
local:
true
,
method: :post
do
|
f
|
%>
Choose a Service Pack to apply:
<%=
f
.
select
:service_pack_id
,
{},{},{
id:
"select-sp"
}
do
%>
<option
selected
>
--Pick one Service Pack--
</option>
<%
@assignables
.
find_each
do
|
assignable
|
%>
<%=
content_tag
(
:option
,
assignable
.
name
,
value:
assignable
.
id
,
data:
{
start:
assignable
.
started_date
.
to_s
,
end:
assignable
.
expired_date
.
to_s
,
cap:
assignable
.
total_units
,
rem:
assignable
.
remained_units
})
%>
<%
end
%>
<%
end
%>
<br/>
<%=
f
.
submit
-
'Assign a Service Pack'
,
class:
-
'button -alt-highlight'
,
id:
'sp-assign-button'
%>
<h2>
No Service Pack is assigned to this project.
</h2>
<br/>
<%=
form_with
model:
@assignment
,
url:
assigns_assign_path
(
@project
),
local:
true
,
method: :post
do
|
f
|
%>
Choose a Service Pack to apply:
<%=
f
.
select
:service_pack_id
,
{},{},{
id:
"select-sp"
}
do
%>
<option
selected
>
--Pick one Service Pack--
</option>
<%
@assignables
.
find_each
do
|
assignable
|
%>
<%=
content_tag
(
:option
,
assignable
.
name
,
value:
assignable
.
id
,
data:
{
start:
assignable
.
started_date
.
to_s
,
end:
assignable
.
expired_date
.
to_s
,
cap:
assignable
.
total_units
,
rem:
assignable
.
remained_units
})
%>
<%
end
%>
<%
else
%>
<h3>
No Service Pack can be assigned.
</h3>
<%
end
%>
</div>
<div
id=
"sp-content"
>
<!-- todo: ajax -->
</div>
\ No newline at end of file
<br/>
<%=
f
.
submit
-
'Assign a Service Pack'
,
class:
-
'button -alt-highlight'
,
id:
'sp-assign-button'
%>
<%
end
%>
</div>
<div
id=
"sp-content"
></div>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
app/views/assigns/unassignable.html.erb
0 → 100644
+
4
-
0
View file @
48332249
<div
id=
'sp-assign'
>
<h2>
No Service Pack is assigned to this project.
</h2><br/>
<h3>
No Service Pack can be assigned.
</h3>
</div>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help