##// END OF EJS Templates
pull requests: fix issue when close button was inactive even if status...
marcink -
r4055:9314f264 default
parent child Browse files
Show More
@@ -1,245 +1,251 b''
1 ## -*- coding: utf-8 -*-
1 ## -*- coding: utf-8 -*-
2 ## usage:
2 ## usage:
3 ## <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
3 ## <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
4 ## ${comment.comment_block(co)}
4 ## ${comment.comment_block(co)}
5 ##
5 ##
6 <%def name="comment_block(co)">
6 <%def name="comment_block(co)">
7 <div class="comment" id="comment-${co.comment_id}" line="${co.line_no}">
7 <div class="comment" id="comment-${co.comment_id}" line="${co.line_no}">
8 <div class="comment-wrapp">
8 <div class="comment-wrapp">
9 <div class="meta">
9 <div class="meta">
10 <div style="float:left"> <img src="${h.gravatar_url(co.author.email, 20)}" /> </div>
10 <div style="float:left"> <img src="${h.gravatar_url(co.author.email, 20)}" /> </div>
11 <div class="user">
11 <div class="user">
12 ${co.author.username}
12 ${co.author.username}
13 </div>
13 </div>
14 <div class="date">
14 <div class="date">
15 ${h.age(co.modified_at)}
15 ${h.age(co.modified_at)}
16 </div>
16 </div>
17
17
18 <div style="float:left;padding:4px 0px 0px 5px">
18 <div style="float:left;padding:4px 0px 0px 5px">
19 <span class="">
19 <span class="">
20 %if co.pull_request:
20 %if co.pull_request:
21 <a href="${h.url('pullrequest_show',repo_name=co.pull_request.other_repo.repo_name,pull_request_id=co.pull_request.pull_request_id)}">
21 <a href="${h.url('pullrequest_show',repo_name=co.pull_request.other_repo.repo_name,pull_request_id=co.pull_request.pull_request_id)}">
22 %if co.status_change:
22 %if co.status_change:
23 ${_('Vote on pull request #%s') % co.pull_request.pull_request_id}:
23 ${_('Vote on pull request #%s') % co.pull_request.pull_request_id}:
24 %else:
24 %else:
25 ${_('Comment on pull request #%s') % co.pull_request.pull_request_id}
25 ${_('Comment on pull request #%s') % co.pull_request.pull_request_id}
26 %endif
26 %endif
27 </a>
27 </a>
28 %else:
28 %else:
29 %if co.status_change:
29 %if co.status_change:
30 ${_('Status change on changeset')}:
30 ${_('Status change on changeset')}:
31 %else:
31 %else:
32 ${_('Comment on changeset')}
32 ${_('Comment on changeset')}
33 %endif
33 %endif
34 %endif
34 %endif
35 </span>
35 </span>
36 </div>
36 </div>
37
37
38 %if co.status_change:
38 %if co.status_change:
39 <div style="float:left" class="changeset-status-container">
39 <div style="float:left" class="changeset-status-container">
40 <div style="float:left;padding:10px 2px 0px 2px"></div>
40 <div style="float:left;padding:10px 2px 0px 2px"></div>
41 <div title="${_('Changeset status')}" class="changeset-status-lbl"> ${co.status_change[0].status_lbl}</div>
41 <div title="${_('Changeset status')}" class="changeset-status-lbl"> ${co.status_change[0].status_lbl}</div>
42 <div class="changeset-status-ico"><img src="${h.url(str('/images/icons/flag_status_%s.png' % co.status_change[0].status))}" /></div>
42 <div class="changeset-status-ico"><img src="${h.url(str('/images/icons/flag_status_%s.png' % co.status_change[0].status))}" /></div>
43 </div>
43 </div>
44 %endif
44 %endif
45
45
46 <a class="permalink" href="#comment-${co.comment_id}">&para;</a>
46 <a class="permalink" href="#comment-${co.comment_id}">&para;</a>
47 %if h.HasPermissionAny('hg.admin', 'repository.admin')() or co.author.user_id == c.rhodecode_user.user_id:
47 %if h.HasPermissionAny('hg.admin', 'repository.admin')() or co.author.user_id == c.rhodecode_user.user_id:
48 <div onClick="deleteComment(${co.comment_id})" class="buttons delete-comment ui-btn small">${_('Delete')}</div>
48 <div onClick="deleteComment(${co.comment_id})" class="buttons delete-comment ui-btn small">${_('Delete')}</div>
49 %endif
49 %endif
50 </div>
50 </div>
51 <div class="text">
51 <div class="text">
52 ${h.rst_w_mentions(co.text)|n}
52 ${h.rst_w_mentions(co.text)|n}
53 </div>
53 </div>
54 </div>
54 </div>
55 </div>
55 </div>
56 </%def>
56 </%def>
57
57
58
58
59 <%def name="comment_inline_form()">
59 <%def name="comment_inline_form()">
60 <div id='comment-inline-form-template' style="display:none">
60 <div id='comment-inline-form-template' style="display:none">
61 <div class="comment-inline-form ac">
61 <div class="comment-inline-form ac">
62 %if c.rhodecode_user.username != 'default':
62 %if c.rhodecode_user.username != 'default':
63 <div class="overlay"><div class="overlay-text">${_('Submitting...')}</div></div>
63 <div class="overlay"><div class="overlay-text">${_('Submitting...')}</div></div>
64 ${h.form('#', class_='inline-form')}
64 ${h.form('#', class_='inline-form')}
65 <div id="edit-container_{1}" class="clearfix">
65 <div id="edit-container_{1}" class="clearfix">
66 <div class="comment-help">${_('Commenting on line {1}.')}
66 <div class="comment-help">${_('Commenting on line {1}.')}
67 ${(_('Comments parsed using %s syntax with %s support.') % (
67 ${(_('Comments parsed using %s syntax with %s support.') % (
68 ('<a href="%s">RST</a>' % h.url('rst_help')),
68 ('<a href="%s">RST</a>' % h.url('rst_help')),
69 ('<span style="color:#003367" class="tooltip" title="%s">@mention</span>' % _('Use @username inside this text to send notification to this RhodeCode user'))
69 ('<span style="color:#003367" class="tooltip" title="%s">@mention</span>' % _('Use @username inside this text to send notification to this RhodeCode user'))
70 )
70 )
71 )|n
71 )|n
72 }
72 }
73 <div id="preview-btn_{1}" class="preview-btn ui-btn small">${_('Preview')}</div>
73 <div id="preview-btn_{1}" class="preview-btn ui-btn small">${_('Preview')}</div>
74 </div>
74 </div>
75 <div class="mentions-container" id="mentions_container_{1}"></div>
75 <div class="mentions-container" id="mentions_container_{1}"></div>
76 <textarea id="text_{1}" name="text" class="comment-block-ta yui-ac-input"></textarea>
76 <textarea id="text_{1}" name="text" class="comment-block-ta yui-ac-input"></textarea>
77 </div>
77 </div>
78 <div id="preview-container_{1}" class="clearfix" style="display:none">
78 <div id="preview-container_{1}" class="clearfix" style="display:none">
79 <div class="comment-help">
79 <div class="comment-help">
80 ${_('Comment preview')}
80 ${_('Comment preview')}
81 <div id="edit-btn_{1}" class="edit-btn ui-btn small">${_('Edit')}</div>
81 <div id="edit-btn_{1}" class="edit-btn ui-btn small">${_('Edit')}</div>
82 </div>
82 </div>
83 <div id="preview-box_{1}" class="preview-box"></div>
83 <div id="preview-box_{1}" class="preview-box"></div>
84 </div>
84 </div>
85 <div class="comment-button">
85 <div class="comment-button">
86 <input type="hidden" name="f_path" value="{0}">
86 <input type="hidden" name="f_path" value="{0}">
87 <input type="hidden" name="line" value="{1}">
87 <input type="hidden" name="line" value="{1}">
88 ${h.submit('save', _('Comment'), class_='ui-btn save-inline-form')}
88 ${h.submit('save', _('Comment'), class_='ui-btn save-inline-form')}
89 ${h.reset('hide-inline-form', _('Cancel'), class_='ui-btn hide-inline-form')}
89 ${h.reset('hide-inline-form', _('Cancel'), class_='ui-btn hide-inline-form')}
90 </div>
90 </div>
91 ${h.end_form()}
91 ${h.end_form()}
92 %else:
92 %else:
93 ${h.form('')}
93 ${h.form('')}
94 <div class="clearfix">
94 <div class="clearfix">
95 <div class="comment-help">
95 <div class="comment-help">
96 ${_('You need to be logged in to comment.')} <a href="${h.url('login_home',came_from=h.url.current())}">${_('Login now')}</a>
96 ${_('You need to be logged in to comment.')} <a href="${h.url('login_home',came_from=h.url.current())}">${_('Login now')}</a>
97 </div>
97 </div>
98 </div>
98 </div>
99 <div class="comment-button">
99 <div class="comment-button">
100 ${h.reset('hide-inline-form', _('Hide'), class_='ui-btn hide-inline-form')}
100 ${h.reset('hide-inline-form', _('Hide'), class_='ui-btn hide-inline-form')}
101 </div>
101 </div>
102 ${h.end_form()}
102 ${h.end_form()}
103 %endif
103 %endif
104 </div>
104 </div>
105 </div>
105 </div>
106 </%def>
106 </%def>
107
107
108
108
109 ## generates inlines taken from c.comments var
109 ## generates inlines taken from c.comments var
110 <%def name="inlines()">
110 <%def name="inlines()">
111 <div class="comments-number">${ungettext("%d comment", "%d comments", len(c.comments)) % len(c.comments)} ${ungettext("(%d inline)", "(%d inline)", c.inline_cnt) % c.inline_cnt}</div>
111 <div class="comments-number">${ungettext("%d comment", "%d comments", len(c.comments)) % len(c.comments)} ${ungettext("(%d inline)", "(%d inline)", c.inline_cnt) % c.inline_cnt}</div>
112 %for path, lines in c.inline_comments:
112 %for path, lines in c.inline_comments:
113 % for line,comments in lines.iteritems():
113 % for line,comments in lines.iteritems():
114 <div style="display:none" class="inline-comment-placeholder" path="${path}" target_id="${h.safeid(h.safe_unicode(path))}">
114 <div style="display:none" class="inline-comment-placeholder" path="${path}" target_id="${h.safeid(h.safe_unicode(path))}">
115 %for co in comments:
115 %for co in comments:
116 ${comment_block(co)}
116 ${comment_block(co)}
117 %endfor
117 %endfor
118 </div>
118 </div>
119 %endfor
119 %endfor
120 %endfor
120 %endfor
121
121
122 </%def>
122 </%def>
123
123
124 ## generate inline comments and the main ones
124 ## generate inline comments and the main ones
125 <%def name="generate_comments(include_pr=False)">
125 <%def name="generate_comments(include_pr=False)">
126 <div class="comments">
126 <div class="comments">
127 <div id="inline-comments-container">
127 <div id="inline-comments-container">
128 ## generate inlines for this changeset
128 ## generate inlines for this changeset
129 ${inlines()}
129 ${inlines()}
130 </div>
130 </div>
131
131
132 %for co in c.comments:
132 %for co in c.comments:
133 <div id="comment-tr-${co.comment_id}">
133 <div id="comment-tr-${co.comment_id}">
134 ## only render comments that are not from pull request, or from
134 ## only render comments that are not from pull request, or from
135 ## pull request and a status change
135 ## pull request and a status change
136 %if not co.pull_request or (co.pull_request and co.status_change) or include_pr:
136 %if not co.pull_request or (co.pull_request and co.status_change) or include_pr:
137 ${comment_block(co)}
137 ${comment_block(co)}
138 %endif
138 %endif
139 </div>
139 </div>
140 %endfor
140 %endfor
141 </div>
141 </div>
142 </%def>
142 </%def>
143
143
144 ## MAIN COMMENT FORM
144 ## MAIN COMMENT FORM
145 <%def name="comments(post_url, cur_status, is_pr=False, change_status=True)">
145 <%def name="comments(post_url, cur_status, is_pr=False, change_status=True)">
146
146
147 <div class="comments">
147 <div class="comments">
148 %if c.rhodecode_user.username != 'default':
148 %if c.rhodecode_user.username != 'default':
149 <div class="comment-form ac">
149 <div class="comment-form ac">
150 ${h.form(post_url)}
150 ${h.form(post_url)}
151 <div id="edit-container" class="clearfix">
151 <div id="edit-container" class="clearfix">
152 <div class="comment-help">
152 <div class="comment-help">
153 ${(_('Comments parsed using %s syntax with %s support.') % (('<a href="%s">RST</a>' % h.url('rst_help')),
153 ${(_('Comments parsed using %s syntax with %s support.') % (('<a href="%s">RST</a>' % h.url('rst_help')),
154 '<span style="color:#003367" class="tooltip" title="%s">@mention</span>' %
154 '<span style="color:#003367" class="tooltip" title="%s">@mention</span>' %
155 _('Use @username inside this text to send notification to this RhodeCode user')))|n}
155 _('Use @username inside this text to send notification to this RhodeCode user')))|n}
156 %if change_status:
156 %if change_status:
157 | <a id="show_changeset_link" onClick="change_status_show();">
157 | <a id="show_changeset_link" onClick="change_status_show();">
158 %if is_pr:
158 %if is_pr:
159 ${_('Vote for pull request status')}
159 ${_('Vote for pull request status')}
160 %else:
160 %else:
161 ${_('Change changeset status')}
161 ${_('Change changeset status')}
162 %endif
162 %endif
163 </a>
163 </a>
164 <input id="show_changeset_status_box" type="checkbox" name="change_changeset_status" style="display: none;" />
164 <input id="show_changeset_status_box" type="checkbox" name="change_changeset_status" style="display: none;" />
165 %endif
165 %endif
166 <div id="preview-btn" class="preview-btn ui-btn small">${_('Preview')}</div>
166 <div id="preview-btn" class="preview-btn ui-btn small">${_('Preview')}</div>
167 </div>
167 </div>
168 %if change_status:
168 %if change_status:
169 <div id="status_block_container" class="status-block" style="display:none">
169 <div id="status_block_container" class="status-block" style="display:none">
170 %for status,lbl in c.changeset_statuses:
170 %for status,lbl in c.changeset_statuses:
171 <div class="">
171 <div class="">
172 <img src="${h.url('/images/icons/flag_status_%s.png' % status)}" /> <input ${'checked="checked"' if status == cur_status else ''}" type="radio" class="status_change_radio" name="changeset_status" id="${status}" value="${status}">
172 <img src="${h.url('/images/icons/flag_status_%s.png' % status)}" /> <input ${'checked="checked"' if status == cur_status else ''}" type="radio" class="status_change_radio" name="changeset_status" id="${status}" value="${status}">
173 <label for="${status}">${lbl}</label>
173 <label for="${status}">${lbl}</label>
174 </div>
174 </div>
175 %endfor
175 %endfor
176 %if is_pr and change_status:
176 %if is_pr and change_status:
177 <input id="save_close" type="checkbox" name="save_close" disabled="${'1' if cur_status in ['not_reviewed','under_review'] else ''}">
177 <input id="save_close" type="checkbox" name="save_close" disabled="${'1' if cur_status in ['not_reviewed','under_review'] else ''}">
178 <label id="save_close_label" for="save_close" class="${'disabled' if cur_status in ['not_reviewed','under_review'] else ''}">${_("Close (when approved or rejected)")}</label>
178 <label id="save_close_label" for="save_close" class="${'disabled' if cur_status in ['not_reviewed','under_review'] else ''}">${_("Close (when approved or rejected)")}</label>
179 %endif
179 %endif
180 </div>
180 </div>
181 %endif
181 %endif
182 <div class="mentions-container" id="mentions_container"></div>
182 <div class="mentions-container" id="mentions_container"></div>
183 ${h.textarea('text', class_="comment-block-ta")}
183 ${h.textarea('text', class_="comment-block-ta")}
184 </div>
184 </div>
185
185
186 <div id="preview-container" class="clearfix" style="display:none">
186 <div id="preview-container" class="clearfix" style="display:none">
187 <div class="comment-help">
187 <div class="comment-help">
188 ${_('Comment preview')}
188 ${_('Comment preview')}
189 <div id="edit-btn" class="edit-btn ui-btn small">${_('Edit')}</div>
189 <div id="edit-btn" class="edit-btn ui-btn small">${_('Edit')}</div>
190 </div>
190 </div>
191 <div id="preview-box" class="preview-box"></div>
191 <div id="preview-box" class="preview-box"></div>
192 </div>
192 </div>
193
193
194 <div class="comment-button">
194 <div class="comment-button">
195 ${h.submit('save', _('Comment'), class_="ui-btn large")}
195 ${h.submit('save', _('Comment'), class_="ui-btn large")}
196 </div>
196 </div>
197 ${h.end_form()}
197 ${h.end_form()}
198 </div>
198 </div>
199 %endif
199 %endif
200 </div>
200 </div>
201 <script>
201 <script>
202 var change_status_show = function(){
202 var change_status_show = function(){
203 var show = ! YUD.get('show_changeset_status_box').checked;
203 var show = ! YUD.get('show_changeset_status_box').checked;
204 YUD.get('show_changeset_status_box').checked = show;
204 YUD.get('show_changeset_status_box').checked = show;
205 YUD.setStyle('status_block_container', 'display', show?'':'none');
205 YUD.setStyle('status_block_container', 'display', show?'':'none');
206 };
206 };
207
207
208 YUE.onDOMReady(function () {
208 YUE.onDOMReady(function () {
209 MentionsAutoComplete('text', 'mentions_container', _USERS_AC_DATA, _GROUPS_AC_DATA);
209 MentionsAutoComplete('text', 'mentions_container', _USERS_AC_DATA, _GROUPS_AC_DATA);
210
210
211 YUE.on(YUQ('.status_change_radio'), 'change',function(e){
211 var set_close_button_state = function(cur_val){
212 var val = e.currentTarget.value;
212 if (cur_val == 'approved' || cur_val == 'rejected') {
213 if (val == 'approved' || val == 'rejected') {
214 YUD.removeClass('save_close_label', 'disabled');
213 YUD.removeClass('save_close_label', 'disabled');
215 YUD.get('save_close').disabled = false;
214 YUD.get('save_close').disabled = false;
216 }else{
215 }else{
217 YUD.addClass('save_close_label', 'disabled');
216 YUD.addClass('save_close_label', 'disabled');
218 YUD.get('save_close').disabled = true;
217 YUD.get('save_close').disabled = true;
219 }
218 }
219 }
220 YUE.on(YUQ('.status_change_radio'), 'change',function(e){
221 var val = e.currentTarget.value;
222 set_close_button_state(val)
220 })
223 })
224 // if currect checked status is approved or rejected we should unlock the close button
225 var cur_val = YUQ('.status_change_radio[checked]')[0].value;
226 set_close_button_state(cur_val)
221 YUE.on('preview-btn', 'click', function(e){
227 YUE.on('preview-btn', 'click', function(e){
222 var _text = YUD.get('text').value;
228 var _text = YUD.get('text').value;
223 if(!_text){
229 if(!_text){
224 return
230 return
225 }
231 }
226 var post_data = {'text': _text};
232 var post_data = {'text': _text};
227 YUD.addClass('preview-box', 'unloaded');
233 YUD.addClass('preview-box', 'unloaded');
228 YUD.get('preview-box').innerHTML = _TM['Loading ...'];
234 YUD.get('preview-box').innerHTML = _TM['Loading ...'];
229 YUD.setStyle('edit-container', 'display', 'none');
235 YUD.setStyle('edit-container', 'display', 'none');
230 YUD.setStyle('preview-container', 'display', '');
236 YUD.setStyle('preview-container', 'display', '');
231
237
232 var url = pyroutes.url('changeset_comment_preview', {'repo_name': '${c.repo_name}'});
238 var url = pyroutes.url('changeset_comment_preview', {'repo_name': '${c.repo_name}'});
233 ajaxPOST(url,post_data,function(o){
239 ajaxPOST(url,post_data,function(o){
234 YUD.get('preview-box').innerHTML = o.responseText;
240 YUD.get('preview-box').innerHTML = o.responseText;
235 YUD.removeClass('preview-box', 'unloaded');
241 YUD.removeClass('preview-box', 'unloaded');
236 })
242 })
237 })
243 })
238 YUE.on('edit-btn', 'click', function(e){
244 YUE.on('edit-btn', 'click', function(e){
239 YUD.setStyle('edit-container', 'display', '');
245 YUD.setStyle('edit-container', 'display', '');
240 YUD.setStyle('preview-container', 'display', 'none');
246 YUD.setStyle('preview-container', 'display', 'none');
241 })
247 })
242
248
243 });
249 });
244 </script>
250 </script>
245 </%def>
251 </%def>
General Comments 0
You need to be logged in to leave comments. Login now