Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
OHR Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
97
Issues
97
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
OHR Support
Commits
508b23cf
Commit
508b23cf
authored
May 17, 2011
by
Gregor Schmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[#416] Watcher links work using of css selectors instead of ids
parent
9cb4feef
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
50 additions
and
35 deletions
+50
-35
watchers_controller.rb
app/controllers/watchers_controller.rb
+28
-8
watchers_helper.rb
app/helpers/watchers_helper.rb
+16
-20
show.rhtml
app/views/boards/show.rhtml
+1
-1
_action_menu.rhtml
app/views/issues/_action_menu.rhtml
+1
-2
show.rhtml
app/views/messages/show.rhtml
+1
-1
date_index.html.erb
app/views/wiki/date_index.html.erb
+1
-1
index.html.erb
app/views/wiki/index.html.erb
+1
-1
show.rhtml
app/views/wiki/show.rhtml
+1
-1
No files found.
app/controllers/watchers_controller.rb
View file @
508b23cf
...
@@ -78,23 +78,43 @@ private
...
@@ -78,23 +78,43 @@ private
@watched
.
set_watcher
(
user
,
watching
)
@watched
.
set_watcher
(
user
,
watching
)
if
params
[
:replace
].
present?
if
params
[
:replace
].
present?
if
params
[
:replace
].
is_a?
Array
if
params
[
:replace
].
is_a?
Array
replace_
id
s
=
params
[
:replace
]
replace_
selector
s
=
params
[
:replace
]
else
else
replace_
ids
=
[
params
[
:replace
]]
replace_
selectors
=
params
[
:replace
].
split
(
','
).
map
(
&
:strip
)
end
end
else
else
replace_
ids
=
[
'
watcher'
]
replace_
selectors
=
[
'#
watcher'
]
end
end
watcher_partial
=
lambda
do
render_to_string
(
:partial
=>
'watchers/watchers'
,
:locals
=>
{
:watched
=>
@watched
})
end
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
{
redirect_to
:back
}
format
.
html
{
redirect_to
:back
}
format
.
js
do
format
.
js
do
render
(
:update
)
do
|
page
|
render
(
:update
)
do
|
page
|
replace_ids
.
each
do
|
replace_id
|
replace_selectors
.
each
do
|
selector
|
case
replace_id
next
if
selector
.
blank?
when
'watchers'
page
.
replace_html
'watchers'
,
:partial
=>
'watchers/watchers'
,
:locals
=>
{
:watched
=>
@watched
}
case
selector
when
'#watchers'
page
.
select
(
'#watchers'
).
each
do
|
node
|
node
.
update
watcher_partial
.
call
end
else
else
page
.
replace_html
replace_id
,
watcher_link
(
@watched
,
user
,
:replace
=>
replace_ids
)
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
end
end
end
end
...
...
app/helpers/watchers_helper.rb
View file @
508b23cf
...
@@ -17,32 +17,28 @@
...
@@ -17,32 +17,28 @@
module
WatchersHelper
module
WatchersHelper
# Valid options
# Create a link to watch/unwatch object
# * :id - the element id
#
# * :replace - a string or array of element ids that will be
# * :replace - a string or array of strings with css selectors that will be updated, whenever the watcher status is changed
# replaced
def
watcher_link
(
object
,
user
,
options
=
{
:replace
=>
'.watcher_link'
,
:class
=>
'watcher_link'
})
def
watcher_tag
(
object
,
user
,
options
=
{
:replace
=>
'watcher'
})
options
=
options
.
with_indifferent_access
id
=
options
[
:id
]
raise
ArgumentError
,
'Missing :replace option in options hash'
if
options
[
'replace'
].
blank?
id
||=
options
[
:replace
]
if
options
[
:replace
].
is_a?
String
content_tag
(
"span"
,
watcher_link
(
object
,
user
,
options
),
:id
=>
id
)
end
# Valid options
# * :replace - a string or array of element ids that will be
# replaced
def
watcher_link
(
object
,
user
,
options
=
{
:replace
=>
'watcher'
})
return
''
unless
user
&&
user
.
logged?
&&
object
.
respond_to?
(
'watched_by?'
)
return
''
unless
user
&&
user
.
logged?
&&
object
.
respond_to?
(
'watched_by?'
)
watched
=
object
.
watched_by?
(
user
)
watched
=
object
.
watched_by?
(
user
)
url
=
{
:controller
=>
'watchers'
,
url
=
{
:controller
=>
'watchers'
,
:action
=>
(
watched
?
'unwatch'
:
'watch'
),
:action
=>
(
watched
?
'unwatch'
:
'watch'
),
:object_type
=>
object
.
class
.
to_s
.
underscore
,
:object_type
=>
object
.
class
.
to_s
.
underscore
,
:object_id
=>
object
.
id
,
:object_id
=>
object
.
id
,
:replace
=>
options
[
:replace
]}
:replace
=>
options
.
delete
(
'replace'
)}
link_to_remote
((
watched
?
l
(:
button_unwatch
)
:
l
(
:button_watch
)),
{
:url
=>
url
},
url_options
=
{
:url
=>
url
}
:href
=>
url_for
(
url
),
:class
=>
(
watched
?
'icon icon-fav'
:
'icon icon-fav-off'
))
html_options
=
options
.
merge
(
:href
=>
url_for
(
url
))
html_options
[
:class
]
+=
watched
?
' icon icon-fav'
:
' icon icon-fav-off'
link_to_remote
((
watched
?
l
(:
button_unwatch
)
:
l
(
:button_watch
)),
url_options
,
html_options
)
end
end
# Returns a comma separated list of users watching the given object
# Returns a comma separated list of users watching the given object
...
...
app/views/boards/show.rhtml
View file @
508b23cf
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
{
:controller
=>
'messages'
,
:action
=>
'new'
,
:board_id
=>
@board
},
{
:controller
=>
'messages'
,
:action
=>
'new'
,
:board_id
=>
@board
},
:class
=>
'icon icon-add'
,
:class
=>
'icon icon-add'
,
:onclick
=>
'Element.show("add-message"); Form.Element.focus("message_subject"); return false;'
%>
:onclick
=>
'Element.show("add-message"); Form.Element.focus("message_subject"); return false;'
%>
<%=
watcher_tag
(
@board
,
User
.
current
)
%>
<%=
watcher_link
(
@board
,
User
.
current
)
%>
</div>
</div>
<div
id=
"add-message"
style=
"display:none;"
>
<div
id=
"add-message"
style=
"display:none;"
>
...
...
app/views/issues/_action_menu.rhtml
View file @
508b23cf
<div
class=
"contextual"
>
<div
class=
"contextual"
>
<%=
link_to_if_authorized
(
l
(
:button_update
),
{
:controller
=>
'issues'
,
:action
=>
'edit'
,
:id
=>
@issue
},
:onclick
=>
'showAndScrollTo("update", "notes"); return false;'
,
:class
=>
'icon icon-edit'
,
:accesskey
=>
accesskey
(
:edit
))
%>
<%=
link_to_if_authorized
(
l
(
:button_update
),
{
:controller
=>
'issues'
,
:action
=>
'edit'
,
:id
=>
@issue
},
:onclick
=>
'showAndScrollTo("update", "notes"); return false;'
,
:class
=>
'icon icon-edit'
,
:accesskey
=>
accesskey
(
:edit
))
%>
<%=
link_to_if_authorized
l
(
:button_log_time
),
{
:controller
=>
'timelog'
,
:action
=>
'new'
,
:issue_id
=>
@issue
},
:class
=>
'icon icon-time-add'
%>
<%=
link_to_if_authorized
l
(
:button_log_time
),
{
:controller
=>
'timelog'
,
:action
=>
'new'
,
:issue_id
=>
@issue
},
:class
=>
'icon icon-time-add'
%>
<%
replace_watcher
||=
'watcher'
%>
<%=
watcher_link
(
@issue
,
User
.
current
,
{
:class
=>
'watcher_link'
,
:replace
=>
[
'#watchers'
,
'.watcher_link'
]})
%>
<%=
watcher_tag
(
@issue
,
User
.
current
,
{
:id
=>
replace_watcher
,
:replace
=>
[
'watchers'
,
'watcher'
,
'watcher2'
]})
%>
<%=
link_to_if_authorized
l
(
:button_duplicate
),
{
:controller
=>
'issues'
,
:action
=>
'new'
,
:project_id
=>
@project
,
:copy_from
=>
@issue
},
:class
=>
'icon icon-duplicate'
%>
<%=
link_to_if_authorized
l
(
:button_duplicate
),
{
:controller
=>
'issues'
,
:action
=>
'new'
,
:project_id
=>
@project
,
:copy_from
=>
@issue
},
:class
=>
'icon icon-duplicate'
%>
<%=
link_to_if_authorized
l
(
:button_copy
),
{
:controller
=>
'issue_moves'
,
:action
=>
'new'
,
:id
=>
@issue
,
:copy_options
=>
{
:copy
=>
't'
}},
:class
=>
'icon icon-copy'
%>
<%=
link_to_if_authorized
l
(
:button_copy
),
{
:controller
=>
'issue_moves'
,
:action
=>
'new'
,
:id
=>
@issue
,
:copy_options
=>
{
:copy
=>
't'
}},
:class
=>
'icon icon-copy'
%>
<%=
link_to_if_authorized
l
(
:button_move
),
{
:controller
=>
'issue_moves'
,
:action
=>
'new'
,
:id
=>
@issue
},
:class
=>
'icon icon-move'
%>
<%=
link_to_if_authorized
l
(
:button_move
),
{
:controller
=>
'issue_moves'
,
:action
=>
'new'
,
:id
=>
@issue
},
:class
=>
'icon icon-move'
%>
...
...
app/views/messages/show.rhtml
View file @
508b23cf
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
link_to
(
h
(
@board
.
name
),
{
:controller
=>
'boards'
,
:action
=>
'show'
,
:project_id
=>
@project
,
:id
=>
@board
})
%>
link_to
(
h
(
@board
.
name
),
{
:controller
=>
'boards'
,
:action
=>
'show'
,
:project_id
=>
@project
,
:id
=>
@board
})
%>
<div
class=
"contextual"
>
<div
class=
"contextual"
>
<%=
watcher_
tag
(
@topic
,
User
.
current
)
%>
<%=
watcher_
link
(
@topic
,
User
.
current
)
%>
<%=
link_to_remote_if_authorized
(
l
(
:button_quote
),
{
:url
=>
{
:action
=>
'quote'
,
:id
=>
@topic
}
},
:class
=>
'icon icon-comment'
)
unless
@topic
.
locked?
%>
<%=
link_to_remote_if_authorized
(
l
(
:button_quote
),
{
:url
=>
{
:action
=>
'quote'
,
:id
=>
@topic
}
},
:class
=>
'icon icon-comment'
)
unless
@topic
.
locked?
%>
<%=
link_to
(
l
(
:button_edit
),
{
:action
=>
'edit'
,
:id
=>
@topic
},
:class
=>
'icon icon-edit'
)
if
@message
.
editable_by?
(
User
.
current
)
%>
<%=
link_to
(
l
(
:button_edit
),
{
:action
=>
'edit'
,
:id
=>
@topic
},
:class
=>
'icon icon-edit'
)
if
@message
.
editable_by?
(
User
.
current
)
%>
<%=
link_to
(
l
(
:button_delete
),
{
:action
=>
'destroy'
,
:id
=>
@topic
},
:method
=>
:post
,
:confirm
=>
l
(
:text_are_you_sure
),
:class
=>
'icon icon-del'
)
if
@message
.
destroyable_by?
(
User
.
current
)
%>
<%=
link_to
(
l
(
:button_delete
),
{
:action
=>
'destroy'
,
:id
=>
@topic
},
:method
=>
:post
,
:confirm
=>
l
(
:text_are_you_sure
),
:class
=>
'icon icon-del'
)
if
@message
.
destroyable_by?
(
User
.
current
)
%>
...
...
app/views/wiki/date_index.html.erb
View file @
508b23cf
<div
class=
"contextual"
>
<div
class=
"contextual"
>
<%=
watcher_tag
(
@wiki
,
User
.
current
)
%>
<%=
watcher_link
(
@wiki
,
User
.
current
)
%>
</div>
</div>
<h2>
<%=
l
(
:label_index_by_date
)
%>
</h2>
<h2>
<%=
l
(
:label_index_by_date
)
%>
</h2>
...
...
app/views/wiki/index.html.erb
View file @
508b23cf
<div
class=
"contextual"
>
<div
class=
"contextual"
>
<%=
watcher_tag
(
@wiki
,
User
.
current
)
%>
<%=
watcher_link
(
@wiki
,
User
.
current
)
%>
</div>
</div>
<h2>
<%=
l
(
:label_index_by_title
)
%>
</h2>
<h2>
<%=
l
(
:label_index_by_title
)
%>
</h2>
...
...
app/views/wiki/show.rhtml
View file @
508b23cf
<div
class=
"contextual"
>
<div
class=
"contextual"
>
<%
if
@editable
%>
<%
if
@editable
%>
<%=
link_to_if_authorized
(
l
(
:button_edit
),
{
:action
=>
'edit'
,
:id
=>
@page
.
title
},
:class
=>
'icon icon-edit'
,
:accesskey
=>
accesskey
(
:edit
))
if
@content
.
version
==
@page
.
content
.
version
%>
<%=
link_to_if_authorized
(
l
(
:button_edit
),
{
:action
=>
'edit'
,
:id
=>
@page
.
title
},
:class
=>
'icon icon-edit'
,
:accesskey
=>
accesskey
(
:edit
))
if
@content
.
version
==
@page
.
content
.
version
%>
<%=
watcher_
tag
(
@page
,
User
.
current
)
%>
<%=
watcher_
link
(
@page
,
User
.
current
)
%>
<%=
link_to_if_authorized
(
l
(
:button_lock
),
{
:action
=>
'protect'
,
:id
=>
@page
.
title
,
:protected
=>
1
},
:method
=>
:post
,
:class
=>
'icon icon-lock'
)
if
!
@page
.
protected?
%>
<%=
link_to_if_authorized
(
l
(
:button_lock
),
{
:action
=>
'protect'
,
:id
=>
@page
.
title
,
:protected
=>
1
},
:method
=>
:post
,
:class
=>
'icon icon-lock'
)
if
!
@page
.
protected?
%>
<%=
link_to_if_authorized
(
l
(
:button_unlock
),
{
:action
=>
'protect'
,
:id
=>
@page
.
title
,
:protected
=>
0
},
:method
=>
:post
,
:class
=>
'icon icon-unlock'
)
if
@page
.
protected?
%>
<%=
link_to_if_authorized
(
l
(
:button_unlock
),
{
:action
=>
'protect'
,
:id
=>
@page
.
title
,
:protected
=>
0
},
:method
=>
:post
,
:class
=>
'icon icon-unlock'
)
if
@page
.
protected?
%>
<%=
link_to_if_authorized
(
l
(
:button_rename
),
{
:action
=>
'rename'
,
:id
=>
@page
.
title
},
:class
=>
'icon icon-move'
)
if
@content
.
version
==
@page
.
content
.
version
%>
<%=
link_to_if_authorized
(
l
(
:button_rename
),
{
:action
=>
'rename'
,
:id
=>
@page
.
title
},
:class
=>
'icon icon-move'
)
if
@content
.
version
==
@page
.
content
.
version
%>
...
...
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