Skip to content

Commit 2ba04ce

Browse files
committed
Reorganize coauthor forms
1 parent d5ccc85 commit 2ba04ce

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

app/controllers/registers_controller.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ def validate
264264

265265
# GET /registers/r:abc/coauthors
266266
def coauthors
267+
@crumbs = [
268+
['Lists', registers_url], [@register.acc_url, @register], 'Coauthors'
269+
]
267270
end
268271

269272
# POST /registers/r:abc/coauthors
@@ -273,7 +276,7 @@ def coauthors_commit
273276
if @coauthor.present?
274277
rc_par = { register: @register, user: @coauthor }
275278
success =
276-
case params['action']
279+
case params['register']['action']
277280
when 'unlink'
278281
RegisterCoauthor.find_by(rc_par).destroy
279282
when 'up'
@@ -288,10 +291,12 @@ def coauthors_commit
288291
redirect_back(fallback_location: @register)
289292
else
290293
flash.now[:alert] = 'Error updating coauthors'
294+
coauthors
291295
render :coauthors
292296
end
293297
else
294298
@register.add_error(:coauthor, 'does not exist in the system')
299+
coauthors
295300
render :coauthors
296301
end
297302
end

app/views/registers/coauthors.html.erb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@
2323
<%= display_link(author) %>
2424
<%= link_to(
2525
coauthors_register_url(@register, {
26-
action: :unlink,
27-
register: { coauthor: author.username }
26+
register: { coauthor: author.username, action: :unlink }
2827
}),
2928
class: 'badge badge-pill badge-primary',
3029
method: :post, title: 'Unlink coauthor',
@@ -35,8 +34,7 @@
3534
<% unless rc.first? %>
3635
<%= link_to(
3736
coauthors_register_url(@register, {
38-
action: :up,
39-
register: { coauthor: author.username }
37+
register: { coauthor: author.username, action: :up }
4038
}),
4139
class: 'badge badge-pill badge-primary',
4240
method: :post, title: 'Move coauthor up'

0 commit comments

Comments
 (0)