Skip to content

Commit c10cf77

Browse files
Akihiro MATOBARedmine Patch Meetup
authored andcommitted
add some guards
1 parent 0d2e6cc commit c10cf77

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

app/views/issues/_action_menu.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="contextual">
22
<%= link_to l(:button_edit), edit_issue_path(@issue),
3-
:onclick => '$("#issue-notes-form").hide(); showAndScrollTo("update", "issue_notes"); return false;',
3+
:onclick => 'showAndScrollTo("update", "issue_notes"); if ($("#issue-notes-form").length) {$("#issue-notes-form").hide();}; return false;',
44
:class => 'icon icon-edit', :accesskey => accesskey(:edit) if @issue.editable? %>
55
<%= link_to l(:button_log_time), new_issue_time_entry_path(@issue),
66
:class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project) %>

app/views/issues/_action_menu_edit.html.erb

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,26 @@
99
</div>
1010
<% end %>
1111

12-
<%= labelled_form_for @issue, :html => {:id => 'issue-notes-form', :multipart => true} do |f| %>
13-
<%= render :partial => 'conflict' if @conflict %>
14-
<div class="box">
15-
<% if @issue.notes_addable? %>
16-
<fieldset><legend><%= l(:field_notes) %></legend>
17-
<%= f.text_area :notes, :cols => 60, :rows => 4, :class => 'wiki-edit',
18-
:data => {
19-
:auto_complete => true
20-
},
21-
:no_label => true, :id => 'only-issue-notes' %>
22-
<%= wikitoolbar_for 'only-issue-notes', preview_issue_path(:project_id => @project, :issue_id => @issue) %>
12+
<% if @issue.notes_addable? %>
13+
<%= labelled_form_for @issue, :html => {:id => 'issue-notes-form', :multipart => true} do |f| %>
14+
<%= render :partial => 'conflict' if @conflict %>
15+
<div class="box">
16+
<fieldset><legend><%= l(:field_notes) %></legend>
17+
<%= f.text_area :notes, :cols => 60, :rows => 4, :class => 'wiki-edit',
18+
:data => {
19+
:auto_complete => true
20+
},
21+
:no_label => true, :id => 'only-issue-notes' %>
22+
<%= wikitoolbar_for 'only-issue-notes', preview_issue_path(:project_id => @project, :issue_id => @issue) %>
2323

24-
<% if @issue.safe_attribute? 'private_notes' %>
25-
<%= f.check_box :private_notes, :no_label => true %> <label for="issue_private_notes"><%= l(:field_private_notes) %></label>
26-
<% end %>
24+
<% if @issue.safe_attribute? 'private_notes' %>
25+
<%= f.check_box :private_notes, :no_label => true %> <label for="issue_private_notes"><%= l(:field_private_notes) %></label>
26+
<% end %>
2727

28-
<%= call_hook(:view_issues_edit_notes_bottom, { :issue => @issue, :notes => @notes, :form => f }) %>
29-
</fieldset>
28+
<%= call_hook(:view_issues_edit_notes_bottom, { :issue => @issue, :notes => @notes, :form => f }) %>
29+
</fieldset>
30+
</div>
3031

32+
<%= submit_tag l(:button_submit) %>
3133
<% end %>
32-
</div>
33-
34-
<%= submit_tag l(:button_submit) %>
3534
<% end %>

app/views/issues/_edit.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
<%= submit_tag l(:button_submit) %>
7575
<%= link_to(
7676
l(:button_cancel), issue_path(id: @issue.id),
77-
:onclick => params[:action] == 'show' ? "$('#update').hide(); $('#issue-notes-form').show(); return false;" : ''
77+
:onclick => params[:action] == 'show' ? "$('#update').hide(); if($('#issue-notes-form').length) {$('#issue-notes-form').show();}; return false;" : ''
7878
) %>
7979
<%= hidden_field_tag 'prev_issue_id', @prev_issue_id if @prev_issue_id %>
8080
<%= hidden_field_tag 'next_issue_id', @next_issue_id if @next_issue_id %>

0 commit comments

Comments
 (0)