Commits

Marcin Kuzminski committed 58bb350

Don't allow cherry picking changesets from the changelog using checkboxes.
Change pull request text that will indicate opening pull request against checkec changesets

Comments (0)

Files changed (3)

rhodecode/public/css/style.css

 	margin: 0px 0px 0px 3px;
 }
 
+#graph_content #rev_range_clear {
+    float: left;
+    margin: 0px 0px 0px 3px;
+}
+
 #graph_content .container {
 	border-bottom: 1px solid #DDD;
 	height: 56px;

rhodecode/templates/base/root.html

                 'Group':"${_('Group')}",
                 'members':"${_('members')}",
                 'search truncated': "${_('search truncated')}",
-                'no matching files': "${_('no matching files')}"
+                'no matching files': "${_('no matching files')}",
+                'Open new pull request': "${_('Open new pull request')}",
+                'Open new pull request for selected changesets':  "${_('Open new pull request for selected changesets')}",
+                'Show selected changes __S -> __E': "${_('Show selected changes __S -> __E')}",
 
             };
             var _TM = TRANSLATION_MAP;

rhodecode/templates/changelog/changelog.html

 				<div id="graph_content">
                     <div class="info_box" style="clear: both;padding: 10px 6px;vertical-align: right;text-align: right;">
                     <a href="#" class="ui-btn small" id="rev_range_container" style="display:none"></a>
+                    <a href="#" class="ui-btn small" id="rev_range_clear" style="display:none">${_('Clear selection')}</a>
+                    
                     %if c.rhodecode_db_repo.fork:
                         <a title="${_('compare fork with %s' % c.rhodecode_db_repo.fork.repo_name)}" href="${h.url('compare_url',repo_name=c.repo_name,org_ref_type='branch',org_ref='default',other_ref_type='branch',other_ref='default',repo=c.rhodecode_db_repo.fork.repo_name)}" class="ui-btn small">${_('Compare fork')}</a>
                     %endif
                     %if h.is_hg(c.rhodecode_repo):
-                    <a href="${h.url('pullrequest_home',repo_name=c.repo_name)}" class="ui-btn small">${_('Open new pull request')}</a>
+                    <a id="open_new_pr" href="${h.url('pullrequest_home',repo_name=c.repo_name)}" class="ui-btn small">${_('Open new pull request')}</a>
                     %endif
                     </div>
 					<div class="container_header">
                     var checkboxes = YUD.getElementsByClassName('changeset_range');
                     var url_tmpl = "${h.url('changeset_home',repo_name=c.repo_name,revision='__REVRANGE__')}";
                     YUE.on(checkboxes,'click',function(e){
+                    	var clicked_cb = e.currentTarget;
                         var checked_checkboxes = [];
                         for (pos in checkboxes){
                             if(checkboxes[pos].checked){
                                 checked_checkboxes.push(checkboxes[pos]);
                             }
                         }
+
+                        if(checked_checkboxes.length>0){
+                          // modify open pull request to show we have selected cs
+                          YUD.get('open_new_pr').innerHTML = _TM['Open new pull request for selected changesets'];
+                                                  	
+                        }else{
+                          YUD.get('open_new_pr').innerHTML = _TM['Open new pull request'];                        	
+                        }
+                        
                         if(checked_checkboxes.length>1){
                         	var rev_end = checked_checkboxes[0].name;
                         	var rev_start = checked_checkboxes[checked_checkboxes.length-1].name;
 
+                        	// now select all checkboxes in the middle.
+                        	var checked = false;
+                        	for (var i=0; i<checkboxes.length; i++){
+                        		var cb = checkboxes[i];
+                        		var rev = cb.name;
+
+                        		if (rev == rev_end){
+                        			checked = true;
+                        		}
+                                if (checked){
+                                    cb.checked = true;
+                                }
+                                else{
+                                    cb.checked = false;
+                                }
+                        		if (rev == rev_start){
+                                    checked = false;
+                                }
+ 
+                        	}
+                        	
                             var url = url_tmpl.replace('__REVRANGE__',
                             		rev_start+'...'+rev_end);
 
-                        var link = "${_('Show selected changes __S -> __E')}";
-                        link = link.replace('__S',rev_start.substr(0,6));
-                        link = link.replace('__E',rev_end.substr(0,6));
-                        YUD.get('rev_range_container').href = url;
-                        YUD.get('rev_range_container').innerHTML = link;
-                        YUD.setStyle('rev_range_container','display','');
+                            var link = _TM['Show selected changes __S -> __E'];
+                            link = link.replace('__S',rev_start.substr(0,6));
+                            link = link.replace('__E',rev_end.substr(0,6));
+                            YUD.get('rev_range_container').href = url;
+                            YUD.get('rev_range_container').innerHTML = link;
+                            YUD.setStyle('rev_range_container','display','');
+                            YUD.setStyle('rev_range_clear','display','');
+                        
                         }
                         else{
                         	YUD.setStyle('rev_range_container','display','none');
+                        	YUD.setStyle('rev_range_clear','display','none');
                         }
                     });
-
+                    YUE.on('rev_range_clear','click',function(e){
+                        for (var i=0; i<checkboxes.length; i++){
+                            var cb = checkboxes[i];
+                            cb.checked = false;
+                        }
+                        YUE.preventDefault(e);
+                    })
                     var msgs = YUQ('.message');
                     // get first element height
                     var el = YUQ('#graph_content .container')[0];