Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OHR Support
Manage
Activity
Members
Labels
Plan
Issues
97
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
OHR Support
Commits
a5b43954
Commit
a5b43954
authored
13 years ago
by
Gregor Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
[#416] introducing separate rjs view to reduce controller code
parent
ae76abd1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/controllers/watchers_controller.rb
+10
-30
10 additions, 30 deletions
app/controllers/watchers_controller.rb
app/views/watchers/replace_selectors.rjs
+22
-0
22 additions, 0 deletions
app/views/watchers/replace_selectors.rjs
with
32 additions
and
30 deletions
app/controllers/watchers_controller.rb
+
10
−
30
View file @
a5b43954
...
...
@@ -76,42 +76,22 @@ private
def
set_watcher
(
user
,
watching
)
@watched
.
set_watcher
(
user
,
watching
)
if
params
[
:replace
].
present?
if
params
[
:replace
].
is_a?
Array
replace_selectors
=
params
[
:replace
]
else
replace_selectors
=
params
[
:replace
].
split
(
','
).
map
(
&
:strip
)
end
else
replace_selectors
=
[
'#watcher'
]
end
respond_to
do
|
format
|
format
.
html
{
redirect_to
:back
}
format
.
js
do
render
(
:update
)
do
|
page
|
replace_selectors
.
each
do
|
selector
|
next
if
selector
.
blank?
case
selector
when
'#watchers'
page
.
replace_html
'watchers'
,
:partial
=>
'watchers/watchers'
,
:locals
=>
{
:watched
=>
@watched
}
else
page
.
select
(
selector
).
each
do
|
node
|
options
=
{
:replace
=>
replace_selectors
}
last_selector
=
selector
.
split
(
' '
).
last
if
last_selector
.
starts_with?
'.'
options
[
:class
]
=
last_selector
[
1
..-
1
]
elsif
last_selector
.
starts_with?
'#'
options
[
:id
]
=
last_selector
[
1
..-
1
]
end
node
.
replace
watcher_link
(
@watched
,
user
,
options
)
end
end
if
params
[
:replace
].
present?
if
params
[
:replace
].
is_a?
Array
@replace_selectors
=
params
[
:replace
]
else
@replace_selectors
=
params
[
:replace
].
split
(
','
).
map
(
&
:strip
)
end
else
@replace_selectors
=
[
'#watcher'
]
end
@user
=
user
render
:action
=>
'replace_selectors'
end
end
rescue
::
ActionController
::
RedirectBackError
...
...
This diff is collapsed.
Click to expand it.
app/views/watchers/replace_selectors.rjs
0 → 100644
+
22
−
0
View file @
a5b43954
@replace_selectors.each do |selector|
next if selector.blank?
case selector
when '#watchers'
page.replace_html 'watchers', :partial => 'watchers/watchers', :locals => {:watched => @watched}
else
page.select(selector).each do |node|
options = {:replace => @replace_selectors}
last_selector = selector.split(' ').last
if last_selector.starts_with? '.'
options[:class] = last_selector[1..-1]
elsif last_selector.starts_with? '#'
options[:id] = last_selector[1..-1]
end
node.replace watcher_link(@watched, @user, options)
end
end
end
This diff is collapsed.
Click to expand it.
Preview
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!
Save comment
Cancel
Please
register
or
sign in
to comment