##// END OF EJS Templates
comments: improved comments form layout....
marcink -
r1281:71c01ca9 default
parent child Browse files
Show More
@@ -911,7 +911,6 b' input.filediff-collapse-state {'
911 911
912 912 .inline-comments {
913 913 border-radius: @border-radius;
914 background: @grey6;
915 914 .comment {
916 915 margin: 0;
917 916 border-radius: @border-radius;
@@ -194,7 +194,6 b' form.comment-form {'
194 194 .comment-inline-form .comment-block-ta,
195 195 .comment-form .comment-block-ta,
196 196 .comment-form .preview-box {
197 border: @border-thickness solid @grey5;
198 197 .border-radius(@border-radius);
199 198 .box-sizing(border-box);
200 199 background-color: white;
@@ -259,6 +258,7 b' form.comment-form {'
259 258
260 259 .comment-footer {
261 260 margin-bottom: 110px;
261 margin-top: 10px;
262 262 }
263 263 }
264 264
@@ -276,11 +276,9 b' form.comment-form {'
276 276 }
277 277
278 278 .preview-box {
279 padding: 10px;
280 min-height: 100px;
279 min-height: 105px;
281 280 margin-bottom: 15px;
282 281 background-color: white;
283 border: @border-thickness solid #ccc;
284 282 .border-radius(@border-radius);
285 283 .box-sizing(border-box);
286 284 }
@@ -299,7 +297,7 b' form.comment-form {'
299 297 // Inline Comment Form
300 298 .injected_diff .comment-inline-form,
301 299 .comment-inline-form {
302 background-color: @grey6;
300 background-color: white;
303 301 margin-top: 10px;
304 302 margin-bottom: 20px;
305 303 }
@@ -337,9 +335,73 b' form.comment-form {'
337 335 margin: 0px;
338 336 }
339 337
338 .comment-inline-form .comment-footer {
339 margin: 10px 0px 0px 0px;
340 }
341
340 342 .hide-inline-form-button {
341 343 margin-left: 5px;
342 344 }
343 345 .comment-button .hide-inline-form {
344 346 background: white;
345 347 }
348
349 .comment-area {
350 padding: 8px 12px;
351 border: 1px solid @grey5;
352 .border-radius(@border-radius);
353 }
354
355 .comment-area-header .nav-links {
356 display: flex;
357 flex-flow: row wrap;
358 -webkit-flex-flow: row wrap;
359 width: 100%;
360 }
361
362 .comment-area-footer {
363 display: flex;
364 }
365
366 .comment-footer .toolbar {
367
368 }
369
370 .nav-links {
371 padding: 0;
372 margin: 0;
373 list-style: none;
374 height: auto;
375 border-bottom: 1px solid @grey5;
376 }
377 .nav-links li {
378 display: inline-block;
379 }
380 .nav-links li:before {
381 content: "";
382 }
383 .nav-links li a.disabled {
384 cursor: not-allowed;
385 }
386
387 .nav-links li.active a {
388 border-bottom: 2px solid @rcblue;
389 color: #000;
390 font-weight: 600;
391 }
392 .nav-links li a {
393 display: inline-block;
394 padding: 0px 10px 5px 10px;
395 margin-bottom: -1px;
396 font-size: 14px;
397 line-height: 28px;
398 color: #8f8f8f;
399 border-bottom: 2px solid transparent;
400 }
401
402 .toolbar-text {
403 float: left;
404 margin: -5px 0px 0px 0px;
405 font-size: 12px;
406 }
407
@@ -216,10 +216,10 b' var CommentForm = (function() {'
216 216 content = content || '';
217 217
218 218 $(this.editContainer).show();
219 $(this.editButton).hide();
219 $(this.editButton).parent().addClass('active');
220 220
221 221 $(this.previewContainer).hide();
222 $(this.previewButton).show();
222 $(this.previewButton).parent().removeClass('active');
223 223
224 224 this.setActionButtonsDisabled(true);
225 225 self.cm.setValue(content);
@@ -292,9 +292,9 b' var CommentForm = (function() {'
292 292 $(self.previewBoxSelector).html(o);
293 293 $(self.previewBoxSelector).removeClass('unloaded');
294 294
295 // swap buttons
296 $(self.previewButton).hide();
297 $(self.editButton).show();
295 // swap buttons, making preview active
296 $(self.previewButton).parent().addClass('active');
297 $(self.editButton).parent().removeClass('active');
298 298
299 299 // unlock buttons
300 300 self.setActionButtonsDisabled(false);
@@ -344,9 +344,10 b' var CommentForm = (function() {'
344 344 $(this.editButton).on('click', function(e) {
345 345 e.preventDefault();
346 346
347 $(self.previewButton).show();
347 $(self.previewButton).parent().removeClass('active');
348 348 $(self.previewContainer).hide();
349 $(self.editButton).hide();
349
350 $(self.editButton).parent().addClass('active');
350 351 $(self.editContainer).show();
351 352
352 353 });
@@ -370,6 +371,7 b' var CommentForm = (function() {'
370 371
371 372 $(self.previewBoxSelector).addClass('unloaded');
372 373 $(self.previewBoxSelector).html(_gettext('Loading ...'));
374
373 375 $(self.editContainer).hide();
374 376 $(self.previewContainer).show();
375 377
@@ -378,8 +380,11 b' var CommentForm = (function() {'
378 380 self.resetCommentFormState(text)
379 381 };
380 382 self.submitAjaxPOST(
381 self.previewUrl, postData, self.previewSuccessCallback, previewFailCallback);
383 self.previewUrl, postData, self.previewSuccessCallback,
384 previewFailCallback);
382 385
386 $(self.previewButton).parent().addClass('active');
387 $(self.editButton).parent().removeClass('active');
383 388 });
384 389
385 390 $(this.submitForm).submit(function(e) {
@@ -606,7 +611,9 b' var CommentsController = function() { /*'
606 611 setTimeout(function() {
607 612 // callbacks
608 613 if (cm !== undefined) {
614 cm.setOption('placeholder', _gettext('Leave a comment on line {0}.').format(lineno));
609 615 cm.focus();
616 cm.refresh();
610 617 }
611 618 }, 10);
612 619
@@ -131,36 +131,50 b''
131 131 </div>
132 132 %endif
133 133 <div class="comments">
134 %if c.rhodecode_user.username != h.DEFAULT_USER:
134 <%
135 if is_pull_request:
136 placeholder = _('Leave a comment on this Pull Request.')
137 elif is_compare:
138 placeholder = _('Leave a comment on all commits in this range.')
139 else:
140 placeholder = _('Leave a comment on this Commit.')
141 %>
142 % if c.rhodecode_user.username != h.DEFAULT_USER:
135 143 <div class="comment-form ac">
136 144 ${h.secure_form(post_url, id_=form_id)}
137 <div id="edit-container" class="clearfix">
138 <div class="comment-title pull-left">
139 %if is_pull_request:
140 ${(_('Create a comment on this Pull Request.'))}
141 %elif is_compare:
142 ${(_('Create comments on this Commit range.'))}
143 %else:
144 ${(_('Create a comment on this Commit.'))}
145 %endif
145 <div class="comment-area">
146 <div class="comment-area-header">
147 <ul class="nav-links clearfix">
148 <li class="active">
149 <a href="#edit-btn" tabindex="-1" id="edit-btn">${_('Write')}</a>
150 </li>
151 <li class="">
152 <a href="#preview-btn" tabindex="-1" id="preview-btn">${_('Preview')}</a>
153 </li>
154 </ul>
146 155 </div>
147 <div class="comment-help pull-right">
148 ${(_('Comments parsed using %s syntax with %s support.') % (
149 ('<a href="%s">%s</a>' % (h.url('%s_help' % c.visual.default_renderer), c.visual.default_renderer.upper())),
150 ('<span class="tooltip" title="%s">@mention</span>' % _('Use @username inside this text to send notification to this RhodeCode user'))
151 )
152 )|n
153 }
156
157 <div class="comment-area-write" style="display: block;">
158 <div id="edit-container">
159 <textarea id="text" name="text" class="comment-block-ta ac-input"></textarea>
160 </div>
161 <div id="preview-container" class="clearfix" style="display: none;">
162 <div id="preview-box" class="preview-box"></div>
163 </div>
154 164 </div>
155 <div style="clear: both"></div>
156 ${h.textarea('text', class_="comment-block-ta")}
157 </div>
158 165
159 <div id="preview-container" class="clearfix" style="display: none;">
160 <div class="comment-title">
161 ${_('Comment preview')}
166 <div class="comment-area-footer">
167 <div class="toolbar">
168 <div class="toolbar-text">
169 ${(_('Comments parsed using %s syntax with %s support.') % (
170 ('<a href="%s">%s</a>' % (h.url('%s_help' % c.visual.default_renderer), c.visual.default_renderer.upper())),
171 ('<span class="tooltip" title="%s">@mention</span>' % _('Use @username inside this text to send notification to this RhodeCode user'))
172 )
173 )|n
174 }
175 </div>
176 </div>
162 177 </div>
163 <div id="preview-box" class="preview-box"></div>
164 178 </div>
165 179
166 180 <div id="comment_form_extras">
@@ -185,15 +199,54 b''
185 199 </div>
186 200 %endif
187 201 <div class="action-buttons">
188 <button id="preview-btn" class="btn btn-secondary">${_('Preview')}</button>
189 <button id="edit-btn" class="btn btn-secondary" style="display:none;">${_('Edit')}</button>
190 202 <div class="comment-button">${h.submit('save', _('Comment'), class_="btn btn-success comment-button-input")}</div>
191 203 </div>
192 204 </div>
193 205 ${h.end_form()}
194 206 </div>
195 %endif
207 % else:
208 <div class="comment-form ac">
209
210 <div class="comment-area">
211 <div class="comment-area-header">
212 <ul class="nav-links clearfix">
213 <li class="active">
214 <a class="disabled" href="#edit-btn" disabled="disabled" onclick="return false">${_('Write')}</a>
215 </li>
216 <li class="">
217 <a class="disabled" href="#preview-btn" disabled="disabled" onclick="return false">${_('Preview')}</a>
218 </li>
219 </ul>
220 </div>
221
222 <div class="comment-area-write" style="display: block;">
223 <div id="edit-container">
224 <div style="padding: 40px 0">
225 ${_('You need to be logged in to leave comments.')}
226 <a href="${h.route_path('login', _query={'came_from': h.url.current()})}">${_('Login now')}</a>
227 </div>
228 </div>
229 <div id="preview-container" class="clearfix" style="display: none;">
230 <div id="preview-box" class="preview-box"></div>
231 </div>
232 </div>
233
234 <div class="comment-area-footer">
235 <div class="toolbar">
236 <div class="toolbar-text">
237 </div>
238 </div>
239 </div>
240 </div>
241
242 <div class="comment-footer">
243 </div>
244
245 </div>
246 % endif
247
196 248 </div>
249
197 250 <script>
198 251 // init active elements of commentForm
199 252 var commitId = templateContext.commit_data.commit_id;
@@ -203,6 +256,8 b''
203 256 var mainCommentForm = new CommentForm(
204 257 "#${form_id}", commitId, pullRequestId, lineNo, true);
205 258
259 mainCommentForm.cm.setOption('placeholder', "${placeholder}");
260
206 261 mainCommentForm.initStatusChangeSelector();
207 262 bindToggleButtons();
208 263 </script>
@@ -89,7 +89,7 b''
89 89
90 90 </div> <!-- end summary -->
91 91
92 <div id="changeset_compare_view_content">
92 <div id="changeset_compare_view_content">
93 93 <div class="pull-left">
94 94 <div class="btn-group">
95 95 <a
@@ -52,41 +52,52 b" return h.url('', **new_args)"
52 52 </div>
53 53 <div class="js-template" id="cb-comment-inline-form-template">
54 54 <div class="comment-inline-form ac">
55
55 56 %if c.rhodecode_user.username != h.DEFAULT_USER:
56 57 ${h.form('#', method='get')}
57 <div id="edit-container_{1}" class="clearfix">
58 <div class="comment-title pull-left">
59 ${_('Create a comment on line {1}.')}
60 </div>
61 <div class="comment-help pull-right">
62 ${(_('Comments parsed using %s syntax with %s support.') % (
63 ('<a href="%s">%s</a>' % (h.url('%s_help' % c.visual.default_renderer), c.visual.default_renderer.upper())),
64 ('<span class="tooltip" title="%s">@mention</span>' % _('Use @username inside this text to send notification to this RhodeCode user'))
65 )
66 )|n
67 }
68 </div>
69 <div style="clear: both"></div>
70 <textarea id="text_{1}" name="text" class="comment-block-ta ac-input"></textarea>
58 <div class="comment-area">
59 <div class="comment-area-header">
60 <ul class="nav-links clearfix">
61 <li class="active">
62 <a href="#edit-btn" tabindex="-1" id="edit-btn_{1}">${_('Write')}</a>
63 </li>
64 <li class="">
65 <a href="#preview-btn" tabindex="-1" id="preview-btn_{1}">${_('Preview')}</a>
66 </li>
67 </ul>
68 </div>
69
70 <div class="comment-area-write" style="display: block;">
71 <div id="edit-container_{1}">
72 <textarea id="text_{1}" name="text" class="comment-block-ta ac-input"></textarea>
73 </div>
74 <div id="preview-container_{1}" class="clearfix" style="display: none;">
75 <div id="preview-box_{1}" class="preview-box"></div>
76 </div>
77 </div>
78
79 <div class="comment-area-footer">
80 <div class="toolbar">
81 <div class="toolbar-text">
82 ${(_('Comments parsed using %s syntax with %s support.') % (
83 ('<a href="%s">%s</a>' % (h.url('%s_help' % c.visual.default_renderer), c.visual.default_renderer.upper())),
84 ('<span class="tooltip" title="%s">@mention</span>' % _('Use @username inside this text to send notification to this RhodeCode user'))
85 )
86 )|n
87 }
88 </div>
89 </div>
90 </div>
71 91 </div>
72 <div id="preview-container_{1}" class="clearfix" style="display: none;">
73 <div class="comment-help">
74 ${_('Comment preview')}
75 </div>
76 <div id="preview-box_{1}" class="preview-box"></div>
77 </div>
92
78 93 <div class="comment-footer">
79 94 <div class="action-buttons">
80 95 <input type="hidden" name="f_path" value="{0}">
81 96 <input type="hidden" name="line" value="{1}">
82 <button id="preview-btn_{1}" class="btn btn-secondary">${_('Preview')}</button>
83 <button id="edit-btn_{1}" class="btn btn-secondary" style="display: none;">${_('Edit')}</button>
84 ${h.submit('save', _('Comment'), class_='btn btn-success save-inline-form')}
85 </div>
86 <div class="comment-button">
87 <button type="button" class="cb-comment-cancel" onclick="return Rhodecode.comments.cancelComment(this);">
88 ${_('Cancel')}
89 </button>
97 <button type="button" class="cb-comment-cancel" onclick="return Rhodecode.comments.cancelComment(this);">
98 ${_('Cancel')}
99 </button>
100 ${h.submit('save', _('Comment'), class_='btn btn-success save-inline-form')}
90 101 </div>
91 102 ${h.end_form()}
92 103 </div>
@@ -94,7 +105,7 b" return h.url('', **new_args)"
94 105 ${h.form('', class_='inline-form comment-form-login', method='get')}
95 106 <div class="pull-left">
96 107 <div class="comment-help pull-right">
97 ${_('You need to be logged in to comment.')} <a href="${h.route_path('login', _query={'came_from': h.url.current()})}">${_('Login now')}</a>
108 ${_('You need to be logged in to leave comments.')} <a href="${h.route_path('login', _query={'came_from': h.url.current()})}">${_('Login now')}</a>
98 109 </div>
99 110 </div>
100 111 <div class="comment-button pull-right">
@@ -120,6 +131,7 b' collapse_all = len(diffset.files) > coll'
120 131 }
121 132 </style>
122 133 %endif
134
123 135 %if ruler_at_chars:
124 136 <style>
125 137 .diff table.cb .cb-content:after {
@@ -134,6 +146,7 b' collapse_all = len(diffset.files) > coll'
134 146 left: ${ruler_at_chars + 5}ch;
135 147 </style>
136 148 %endif
149
137 150 <div class="diffset ${disable_new_comments and 'diffset-comments-disabled'}">
138 151 <div class="diffset-heading ${diffset.limited_diff and 'diffset-heading-warning' or ''}">
139 152 %if commit:
@@ -26,10 +26,10 b''
26 26 </%def>
27 27
28 28 <%def name="main()">
29 <script type="text/javascript">
30 // set fake commitId on this commit-range page
31 templateContext.commit_data.commit_id = "${h.EmptyCommit().raw_id}";
32 </script>
29 <script type="text/javascript">
30 // set fake commitId on this commit-range page
31 templateContext.commit_data.commit_id = "${h.EmptyCommit().raw_id}";
32 </script>
33 33
34 34 <div class="box">
35 35 <div class="title">
@@ -153,16 +153,78 b''
153 153 </div>
154 154 </%doc>
155 155
156 ## commit status form
157 <div class="fieldset" id="compare_changeset_status" style="display: none; margin-bottom: -80px;">
158 <div class="left-label">
159 ${_('Commit status')}:
160 </div>
161 <div class="right-content">
162 <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
163 ## main comment form and it status
164 <%
165 def revs(_revs):
166 form_inputs = []
167 for cs in _revs:
168 tmpl = '<input type="hidden" data-commit-id="%(cid)s" name="commit_ids" value="%(cid)s">' % {'cid': cs.raw_id}
169 form_inputs.append(tmpl)
170 return form_inputs
171 %>
172 <div>
173 ${comment.comments(h.url('changeset_comment', repo_name=c.repo_name, revision='0'*16), None, is_compare=True, form_extras=revs(c.commit_ranges))}
174 <script type="text/javascript">
175
176 mainCommentForm.setHandleFormSubmit(function(o) {
177 var text = mainCommentForm.cm.getValue();
178 var status = mainCommentForm.getCommentStatus();
179
180 if (text === "" && !status) {
181 return;
182 }
183
184 // we can pick which commits we want to make the comment by
185 // selecting them via click on preview pane, this will alter the hidden inputs
186 var cherryPicked = $('#changeset_compare_view_content .compare_select.hl').length > 0;
187
188 var commitIds = [];
189 $('#changeset_compare_view_content .compare_select').each(function(el) {
190 var commitId = this.id.replace('row-', '');
191 if ($(this).hasClass('hl') || !cherryPicked) {
192 $("input[data-commit-id='{0}']".format(commitId)).val(commitId)
193 commitIds.push(commitId);
194 } else {
195 $("input[data-commit-id='{0}']".format(commitId)).val('')
196 }
197 });
198
199 mainCommentForm.setActionButtonsDisabled(true);
200 mainCommentForm.cm.setOption("readOnly", true);
201 var postData = {
202 'text': text,
203 'changeset_status': status,
204 'commit_ids': commitIds,
205 'csrf_token': CSRF_TOKEN
206 };
207
208 var submitSuccessCallback = function(o) {
209 location.reload(true);
210 };
211 var submitFailCallback = function(){
212 mainCommentForm.resetCommentFormState(text)
213 };
214 mainCommentForm.submitAjaxPOST(
215 mainCommentForm.submitUrl, postData, submitSuccessCallback, submitFailCallback);
216 });
217 </script>
218 </div>
219 </div>
220 </div>
221
156 222 </div> <!-- end summary-detail -->
157
158 223 </div> <!-- end summary -->
159 224
160
161 <div class="table">
162
163 ## use JS script to load it quickly before potentially large diffs render long time
164 ## this prevents from situation when large diffs block rendering of select2 fields
165 <script type="text/javascript">
225 ## use JS script to load it quickly before potentially large diffs render long time
226 ## this prevents from situation when large diffs block rendering of select2 fields
227 <script type="text/javascript">
166 228
167 229 var cache = {};
168 230
@@ -277,69 +339,13 b''
277 339 $('#compare_changeset_status').toggle();
278 340 });
279 341
280 </script>
281
282 ## changeset status form
283 <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
284 ## main comment form and it status
285 <%
286 def revs(_revs):
287 form_inputs = []
288 for cs in _revs:
289 tmpl = '<input type="hidden" data-commit-id="%(cid)s" name="commit_ids" value="%(cid)s">' % {'cid': cs.raw_id}
290 form_inputs.append(tmpl)
291 return form_inputs
292 %>
293 <div id="compare_changeset_status" style="display: none;">
294 ${comment.comments(h.url('changeset_comment', repo_name=c.repo_name, revision='0'*16), None, is_compare=True, form_extras=revs(c.commit_ranges))}
295 <script type="text/javascript">
296
297 mainCommentForm.setHandleFormSubmit(function(o) {
298 var text = mainCommentForm.cm.getValue();
299 var status = mainCommentForm.getCommentStatus();
300
301 if (text === "" && !status) {
302 return;
303 }
304
305 // we can pick which commits we want to make the comment by
306 // selecting them via click on preview pane, this will alter the hidden inputs
307 var cherryPicked = $('#changeset_compare_view_content .compare_select.hl').length > 0;
342 </script>
308 343
309 var commitIds = [];
310 $('#changeset_compare_view_content .compare_select').each(function(el) {
311 var commitId = this.id.replace('row-', '');
312 if ($(this).hasClass('hl') || !cherryPicked) {
313 $("input[data-commit-id='{0}']".format(commitId)).val(commitId)
314 commitIds.push(commitId);
315 } else {
316 $("input[data-commit-id='{0}']".format(commitId)).val('')
317 }
318 });
344 ## table diff data
345 <div class="table">
319 346
320 mainCommentForm.setActionButtonsDisabled(true);
321 mainCommentForm.cm.setOption("readOnly", true);
322 var postData = {
323 'text': text,
324 'changeset_status': status,
325 'commit_ids': commitIds,
326 'csrf_token': CSRF_TOKEN
327 };
328 347
329 var submitSuccessCallback = function(o) {
330 location.reload(true);
331 };
332 var submitFailCallback = function(){
333 mainCommentForm.resetCommentFormState(text)
334 };
335 mainCommentForm.submitAjaxPOST(
336 mainCommentForm.submitUrl, postData, submitSuccessCallback, submitFailCallback);
337 });
338 </script>
339
340 </div>
341
342 %if not c.compare_home:
348 % if not c.compare_home:
343 349 <div id="changeset_compare_view_content">
344 350 <div class="pull-left">
345 351 <div class="btn-group">
@@ -363,8 +369,9 b''
363 369 ${cbdiffs.render_diffset_menu()}
364 370 ${cbdiffs.render_diffset(c.diffset)}
365 371 </div>
366 %endif
372 % endif
373
367 374 </div>
368 375 </div>
369 </div>
370 </%def>
376
377 </%def> No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now