Watchers of the particular issue
I'd like to be able to see the list of watchers of the particular issue.
So I wrote this in views/issues/_edit.rhtml:
<p> <% i = @issue %> <% s = i.watchers%> <%= text_field_tag 'i[s]', s.join(', '), :size => 50 %> <%= l(:text_comma_separated) %> </p>
(don't ask me why i did like this - just looked at how it is realized in
As a result I've got a text field showing: "#<Watcher:0x2199be4>, #<Watcher:0x2199928>" (this issue is really watchable by two users at the moment)
1. How can I make it to show real names instead of these codes?
2. And how can I do that if I modify this field (add or remove users from it) so that it adds or removes watchers from the issue?
Thanks in advance.
RE: Watchers of the particular issue - Added by Eric Davis about 11 years ago
If you want a basic read-only list this will work:
<p> <%= @issue.watchers.collect(&:user).collect(&:name).uniq.join(', ') %> </p>
In Engish that will:
- Get the watchers on an issue
- Collect their user accounts
- Collect the names of their user accounts
- Remove any duplicates
- Merge them all together with a comma
In order to edit the list, you would need a lot more done in terms of backend database.
Thank you very much Eric for the good explanation.
The first task is done..
We have a list of watchers put in textfield (by the way - I've added 'wathers' right after text_field_tag and ruby api says it is the 'name' though i can't imagine how and where to use it):
<% w = @issue.watchers.collect(&:user).collect(&:name).uniq.join(', ') %> <%= text_field_tag 'watchers', w, :size => 50 %> <%= l(:text_comma_separated) %>
It's time for the next hard challenge: :-) how to do so they react on changements..
As far as I understand with my weak programming skills:
1. Watchers plugin can be found here: vendor/plugins/acts_as_watchable/
2. Then it appears in app/models/issue.rb - so it says that issue is watchable
3. In app/models/watcher.rb - described something i can't get.. I suppose not important for this task.
4. app/helpers/watchers_helper.rb - is quite an interesting part - seems that something similar to "watcher_tag" must be added there..
5. app/controllers/watchers_controller.rb - is the most important part i believe - there must be a function that forms a list and adds or removes watchers from the list..
Do I think correctly or it is absolutely hopelessly?
P.S. Sorry for that it looks like I speak with myself - I just need this feature VERY much.. And will be grateful for any piece of info that can lead me into the right direction.
RE: Reviewing and managing watchers of a particular issue - Added by Bradley Whittington about 11 years ago
I have taken this a bit further and added management tools for watchers.
The patch included on ticket #1338 adds basic review and management for watchers.
See attached screenshot for how it looks...
Screenshot-2.png - Screenshot showing watcher management (97.7 KB)
Bradley, thank you very much for the patch - it really rocks...
Thought there is one small addition I think may be interesting..
What if to add this watchers list right into "app/views/issues/_form.rhtml" ?
So that it can be visible even when the issue is created or edited.
In this case when the issue is created all the watchers initially assigned to it can immediately get email notifications of issue creation.
When I put it right into "app/views/issues/_form.rhtml" - it doesn't add any watchers..
Is there a way to do that?
I haven't looked at it yet, but I might because it is the ideal I set out with when building the patch. I wanted to first cut my teeth on building something new, and then look at editing existing stuff. It is not as straightforward to add watchers at creation time, because until the issue is created you don't have a reference ID//issue ID, so you need to add members using JS on the form, and then at form submission process the added watchers.
As I said on the ticket, the additional feature (of adding watchers at issue creation) may be built, but it depends on if we feel it is needed (for our uses). The other soft target would be mailing a notification when a watch is added by someone else. That should just need a template and a few lines in the watch controller.
My idea is that the purpose of the feature of adding wathchers - is to INFORM people about the issue they need to be informed.
And right now in its current iteration this feature doesn't solve it's purpose, so it needs to be improved.
Btw I like the idea of mailing when the user was added to the watchers.
mailing a notification when a watch is added by someone else. That should just need a template and a few lines in the watch controller.
Do you know how and what should be added to the watch controller? (i'm going to look myself also, but maybe you already know).
RE: Watchers of the particular issue - Added by Daniel Srb about 11 years ago
Better than nothing and thanks for the patch.
E-mail notification about being added as watcher, would be very useful for us too.
RE: Watchers of the particular issue - Added by jern abraham over 8 years ago
please , can you help me how to add a watcher from a plugin,..
i have a ms_project plugin and want to add a coloumn for watchers while creating a new issue,..