@@ -786,28 +786,62 @@ function initRepository() {
786
786
$issueTitle . toggle ( ) ;
787
787
$ ( '.not-in-edit' ) . toggle ( ) ;
788
788
$ ( '#edit-title-input' ) . toggle ( ) ;
789
+ $ ( '#pull-desc' ) . toggle ( ) ;
790
+ $ ( '#pull-desc-edit' ) . toggle ( ) ;
789
791
$ ( '.in-edit' ) . toggle ( ) ;
790
792
$editInput . focus ( ) ;
791
793
return false ;
792
794
} ;
795
+
796
+ var changeBranchSelect = function ( ) {
797
+ var selectionTextField = $ ( '#pull-target-branch' ) ;
798
+
799
+ var baseName = selectionTextField . data ( 'basename' ) ;
800
+ var branchNameNew = $ ( this ) . data ( 'branch' ) ;
801
+ var branchNameOld = selectionTextField . data ( 'branch' ) ;
802
+
803
+ // Replace branch name to keep translation from HTML template
804
+ selectionTextField . html ( selectionTextField . html ( ) . replace ( baseName + ':' + branchNameOld , baseName + ':' + branchNameNew ) ) ;
805
+ selectionTextField . data ( 'branch' , branchNameNew ) ; // update branch name in setting
806
+ } ;
807
+ $ ( '#branch-select > .item' ) . click ( changeBranchSelect ) ;
808
+
793
809
$ ( '#edit-title' ) . click ( editTitleToggle ) ;
794
810
$ ( '#cancel-edit-title' ) . click ( editTitleToggle ) ;
795
811
$ ( '#save-edit-title' ) . click ( editTitleToggle ) . click ( function ( ) {
796
- if ( $editInput . val ( ) . length == 0 ||
797
- $editInput . val ( ) == $issueTitle . text ( ) ) {
812
+
813
+ var pullrequest_targetbranch_change = function ( update_url ) {
814
+ var target_branch = $ ( '#pull-target-branch' ) . data ( 'branch' ) ;
815
+ if ( target_branch === $ ( '#branch_target' ) . text ( ) ) {
816
+ $editInput . val ( $issueTitle . text ( ) ) ;
817
+ return false ;
818
+ }
819
+ $ . post ( update_url , {
820
+ "_csrf" : csrf ,
821
+ "target_branch" : target_branch
822
+ } ,
823
+ function ( data ) {
824
+ $ ( '#branch_target' ) . text ( data . base_branch ) ;
825
+ reload ( ) ;
826
+ } ) ;
827
+ } ;
828
+
829
+ var pullrequest_target_update_url = $ ( this ) . data ( 'target-update-url' ) ;
830
+ if ( $editInput . val ( ) . length === 0 ||
831
+ $editInput . val ( ) === $issueTitle . text ( ) ) {
798
832
$editInput . val ( $issueTitle . text ( ) ) ;
799
- return false ;
833
+ pullrequest_targetbranch_change ( pullrequest_target_update_url ) ;
834
+ } else {
835
+ $ . post ( $ ( this ) . data ( 'update-url' ) , {
836
+ "_csrf" : csrf ,
837
+ "title" : $editInput . val ( )
838
+ } ,
839
+ function ( data ) {
840
+ $editInput . val ( data . title ) ;
841
+ $issueTitle . text ( data . title ) ;
842
+ pullrequest_targetbranch_change ( pullrequest_target_update_url ) ;
843
+ } ) ;
800
844
}
801
-
802
- $ . post ( $ ( this ) . data ( 'update-url' ) , {
803
- "_csrf" : csrf ,
804
- "title" : $editInput . val ( )
805
- } ,
806
- function ( data ) {
807
- $editInput . val ( data . title ) ;
808
- $issueTitle . text ( data . title ) ;
809
- reload ( ) ;
810
- } ) ;
811
845
return false ;
812
846
} ) ;
813
847
0 commit comments