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