@@ -2327,8 +2327,8 @@ webui.ChangedFilesView = function(workspaceView, type, label) {
2327
2327
} ) ;
2328
2328
2329
2329
2330
- $ ( '<button class="btn btn-sm btn-danger float-right " id="confirm-staging">' + action . charAt ( 0 ) . toUpperCase ( ) + action . substring ( 1 ) + '</button>' +
2331
- '<button class="btn btn-sm btn-secondary float-right " id="cancel-staging">Cancel</button>' ) . appendTo ( popupContent ) ;
2330
+ $ ( '<button class="btn btn-sm btn-danger" id="confirm-staging">' + action . charAt ( 0 ) . toUpperCase ( ) + action . substring ( 1 ) + '</button>' +
2331
+ '<button class="btn btn-sm btn-secondary" id="cancel-staging">Cancel</button>' ) . appendTo ( popupContent ) ;
2332
2332
$ ( popup ) . modal ( 'show' ) ;
2333
2333
2334
2334
$ ( "#confirm-unavailable-staging" ) . on ( 'click' , '#confirm-staging' , function ( e ) {
@@ -2548,7 +2548,7 @@ webui.NewChangedFilesView = function(workspaceView) {
2548
2548
2549
2549
var checkboxLabel ;
2550
2550
if ( isOtherUserChange ) {
2551
- checkboxLabel = $ ( '<label class="form-check-label file-item-label other-user-label"> </label>' ) . text ( model ) ;
2551
+ checkboxLabel = $ ( '<label class="form-check-label file-item-label other-user-label" data-toggle="tooltip" title="File changed by another user">' + webui . peopleIcon + ' </label>') . append ( model ) ;
2552
2552
} else {
2553
2553
checkboxLabel = $ ( '<label class="form-check-label file-item-label"></label>' ) . text ( model ) ;
2554
2554
}
@@ -2588,7 +2588,7 @@ webui.NewChangedFilesView = function(workspaceView) {
2588
2588
if ( isForCurrentUser ) {
2589
2589
addItemToFileList ( fileList , workingTreeStatus , model , false ) ;
2590
2590
} else {
2591
- addItemToFileList ( fileList , workingTreeStatus , model , true )
2591
+ addItemToFileList ( fileList , workingTreeStatus , model , true ) ;
2592
2592
}
2593
2593
2594
2594
} ) ;
@@ -2617,81 +2617,104 @@ webui.NewChangedFilesView = function(workspaceView) {
2617
2617
} ) ;
2618
2618
$ ( "#commitBtn" ) . off ( "click" ) ;
2619
2619
$ ( "#commitBtn" ) . on ( "click" , function ( ) {
2620
- var commitMessage = $ ( '#commitMsg' ) . val ( ) + "\n" + $ ( "#commitMsgDetail" ) . val ( )
2621
- self . commit ( commitMessage ) ;
2620
+ if ( selectedItemsFromOtherUser . length > 0 ) {
2621
+ self . confirmActionOnOtherUsersChanges ( "commit" ) ;
2622
+ } else {
2623
+ var commitMessage = $ ( '#commitMsg' ) . val ( ) + "\n" + $ ( "#commitMsgDetail" ) . val ( ) ;
2624
+ self . commit ( commitMessage ) ;
2625
+ }
2626
+
2622
2627
} ) ;
2623
2628
2624
2629
$ ( "#discardBtn" ) . off ( "click" ) ;
2625
2630
$ ( "#discardBtn" ) . on ( "click" , function ( ) {
2626
- self . discard ( ) ;
2631
+ if ( selectedItemsFromOtherUser . length > 0 ) {
2632
+ self . confirmActionOnOtherUsersChanges ( "discard" ) ;
2633
+ } else {
2634
+ self . discard ( ) ;
2635
+ }
2627
2636
} ) ;
2628
2637
2629
2638
$ ( "#stashBtn" ) . off ( "click" ) ;
2630
2639
$ ( "#stashBtn" ) . on ( "click" , function ( ) {
2631
- self . stash ( ) ;
2640
+ if ( selectedItemsFromOtherUser . length > 0 ) {
2641
+ self . confirmActionOnOtherUsersChanges ( "stash" ) ;
2642
+ } else {
2643
+ self . stash ( ) ;
2644
+ }
2645
+
2632
2646
} ) ;
2633
2647
} ) ;
2634
2648
} ) ;
2635
2649
}
2636
2650
2637
2651
self . confirmActionOnOtherUsersChanges = function ( action ) {
2638
- function removeWarningModal ( popup ) {
2639
- $ ( popup ) . children ( ".modal-fade" ) . modal ( "hide" ) ;
2640
- $ ( ".modal-backdrop" ) . remove ( ) ;
2641
- $ ( "#confirmAction" ) . remove ( ) ;
2642
- modalOpen = false ;
2643
- }
2644
-
2645
- var popup = $ ( '<div class="modal fade" id="confirmAction" role="dialog" data-backdrop="static">' +
2646
- '<div class="modal-dialog modal-md">' +
2647
- '<div class="modal-content>' +
2648
- '<div class="modal-header">' +
2649
- '<h5 class="modal-title">Confirm ' + action + '</h5>' +
2650
- '<button type="button" class="btn btn-default close" data-dismiss="modal">' +
2651
- webui . largeXIcon +
2652
- '</button>' +
2652
+ function removeWarningModal ( popup ) {
2653
+ $ ( popup ) . children ( ".modal-fade" ) . modal ( "hide" ) ;
2654
+ $ ( ".modal-backdrop" ) . remove ( ) ;
2655
+ $ ( "#confirmAction" ) . remove ( ) ;
2656
+ }
2657
+
2658
+ var popup = $ ( '<div class="modal fade" tab-index="-1" id="confirmAction" role="dialog" data-backdrop="static">' +
2659
+ '<div class="modal-dialog modal-md" role="document">' +
2660
+ '<div class="modal-content">' +
2661
+ '<div class="modal-header">' +
2662
+ '<h5 class="modal-title">Confirm ' + action + '</h5>' +
2663
+ '<button type="button" class="btn btn-default close" data-dismiss="modal">' +
2664
+ webui . largeXIcon +
2665
+ '</button>' +
2666
+ '</div>' +
2667
+ '<div class="modal-body"></div>' +
2668
+ '<div class="modal-footer"></div>' +
2653
2669
'</div>' +
2654
- '<div class="modal-body"></div>' +
2655
2670
'</div>' +
2656
- '</div>' +
2671
+ '</div>' ) [ 0 ] ;
2672
+ $ ( "body" ) . append ( popup ) ;
2673
+ var popupContent = $ ( ".modal-body" , popup ) [ 0 ] ;
2674
+ webui . detachChildren ( popupContent ) ;
2675
+
2676
+
2677
+ $ ( '<div class="row"><div class="col-sm-1">' +
2678
+ webui . warningIcon +
2679
+ '</div>' +
2680
+ '<div class="col-sm-11">The following files were changed by other users. Are you sure you want to ' + action + ' them?</div></div><ul>' ) . appendTo ( popupContent ) ;
2681
+
2682
+ selectedItemsFromOtherUser . forEach ( function ( file ) {
2683
+ $ ( '<li>' + file + '</li>' ) . appendTo ( popupContent ) ;
2684
+ } ) ;
2685
+
2686
+ $ ( '</ul>' ) . appendTo ( popupContent ) ;
2687
+
2688
+ var popupFooter = $ ( ".modal-footer" , popup ) [ 0 ] ;
2689
+ webui . detachChildren ( popupFooter ) ;
2690
+
2657
2691
2658
- '</div>' ) [ 0 ] ;
2659
- $ ( "body" ) . append ( popup ) ;
2660
- var popupContent = $ ( ".modal-body" , popup ) [ 0 ] ;
2661
- webui . detachChildren ( popupContent ) ;
2662
- $ ( '<div class="row"><div class="col-sm-1">' +
2663
- webui . warningIcon +
2664
- '</div>' +
2665
- '<div class="col-sm-11">The following files were changed by other users. Are you sure you want to ' + action + ' them?</div></div><ul>' ) . appendTo ( popupContent ) ;
2666
-
2667
- selectedItemsFromOtherUser . forEach ( function ( file , index ) {
2668
- $ ( '<li>' + file + '</li>' ) . appendTo ( popupContent ) ;
2669
- } ) ;
2670
-
2671
- $ ( '</ul>' ) . appendTo ( popupContent ) ;
2672
-
2673
- $ ( '<button class="btn btn-sm btn-warning float-right" id="confirmActionBtn">' + action . charAt ( 0 ) . toUpperCase ( ) + action . substring ( 1 ) + '</button>' +
2674
- '<button class="btn btn-sm btn-secondary float-right" id="cancelActionBtn">Cancel</button>' ) . appendTo ( popupContent ) ;
2675
-
2676
- $ ( popup ) . modal ( 'show' ) ;
2677
- var modalOpen = true ;
2678
-
2679
- var actionConfirmed = false ;
2680
-
2681
- $ ( '#confirmAction' ) . on ( 'click' , '#confirmActionBtn' , function ( ) {
2682
- actionConfirmed = true ;
2683
- removeWarningModal ( popup ) ;
2684
- } ) ;
2685
-
2686
- $ ( '#confirmAction' ) . find ( '#cancelAction, .close' ) . click ( function ( ) {
2687
- removeWarningModal ( popup ) ;
2688
- } )
2692
+
2693
+ $ ( '<button class="btn btn-sm btn-warning action-btn" id="confirmActionBtn">' + action . charAt ( 0 ) . toUpperCase ( ) + action . substring ( 1 ) + '</button>' +
2694
+ '<button class="btn btn-sm btn-secondary action-btn" id="cancelActionBtn">Cancel</button>' ) . appendTo ( popupFooter ) ;
2695
+
2696
+ $ ( popup ) . modal ( 'show' ) ;
2697
+
2689
2698
2690
- while ( modalOpen ) {
2691
- // spin
2692
- }
2699
+ $ ( '#confirmActionBtn' ) . on ( 'click' , function ( ) {
2700
+ removeWarningModal ( popup ) ;
2701
+ if ( action == "commit" ) {
2702
+ var commitMessage = $ ( '#commitMsg' ) . val ( ) + "\n" + $ ( "#commitMsgDetail" ) . val ( ) ;
2703
+ self . commit ( commitMessage ) ;
2704
+ } else if ( action == "discard" ) {
2705
+ self . discard ( ) ;
2706
+ } else if ( action == "stash" ) {
2707
+ self . stash ( ) ;
2708
+ }
2709
+ } ) ;
2710
+
2711
+ $ ( '#confirmAction' ) . find ( '#cancelAction, .close' ) . click ( function ( ) {
2712
+ removeWarningModal ( popup ) ;
2713
+ } )
2714
+
2715
+
2716
+
2693
2717
2694
- return actionConfirmed ;
2695
2718
}
2696
2719
2697
2720
self . afterFileChecked = function ( element ) {
@@ -2702,11 +2725,11 @@ webui.NewChangedFilesView = function(workspaceView) {
2702
2725
selectedItems . push ( fileName ) ;
2703
2726
}
2704
2727
2705
- if ( element . hasClass ( "other-user" ) && ( selectedItems . indexOf ( fileName ) == - 1 ) ) {
2728
+ if ( $ ( element ) . hasClass ( "other-user" ) && ( selectedItemsFromOtherUser . indexOf ( fileName ) == - 1 ) ) {
2706
2729
selectedItemsFromOtherUser . push ( fileName ) ;
2707
2730
}
2708
2731
2709
- if ( selectedItems . length == Array . from ( fileList . children ) . length ) {
2732
+ if ( selectedItems . length == Array . prototype . slice . call ( fileList . children ) . length ) {
2710
2733
$ ( '#selectAllFiles' ) . prop ( 'checked' , true ) ;
2711
2734
}
2712
2735
} else {
@@ -2715,7 +2738,7 @@ webui.NewChangedFilesView = function(workspaceView) {
2715
2738
selectedItems . splice ( fileIndex , 1 ) ;
2716
2739
}
2717
2740
2718
- if ( element . hasClass ( "other-user" ) && ( selectedItems . indexOf ( fileName ) > - 1 ) ) {
2741
+ if ( $ ( element ) . hasClass ( "other-user" ) && ( selectedItemsFromOtherUser . indexOf ( fileName ) > - 1 ) ) {
2719
2742
selectedItemsFromOtherUser . splice ( selectedItems . indexOf ( fileName ) , 1 ) ;
2720
2743
}
2721
2744
}
@@ -2758,16 +2781,16 @@ webui.NewChangedFilesView = function(workspaceView) {
2758
2781
}
2759
2782
2760
2783
self . selectAll = function ( ) {
2761
- Array . from ( fileList . children ) . forEach ( function ( fileDiv , index ) {
2784
+ Array . prototype . slice . call ( fileList . children ) . forEach ( function ( fileDiv , index ) {
2762
2785
fileDiv . children [ 0 ] . checked = true ;
2763
2786
self . afterFileChecked ( fileDiv . children [ 0 ] ) ;
2764
2787
} ) ;
2765
2788
}
2766
2789
2767
2790
self . deselectAll = function ( ) {
2768
- Array . from ( fileList . children ) . forEach ( function ( fileDiv , index ) {
2791
+ Array . prototype . slice . call ( fileList . children ) . forEach ( function ( fileDiv , index ) {
2769
2792
fileDiv . children [ 0 ] . checked = false ;
2770
- self . afterFileChecked ( fileDiv . children [ 0 ] )
2793
+ self . afterFileChecked ( fileDiv . children [ 0 ] ) ;
2771
2794
} ) ;
2772
2795
}
2773
2796
@@ -2782,11 +2805,6 @@ webui.NewChangedFilesView = function(workspaceView) {
2782
2805
2783
2806
self . stash = function ( ) {
2784
2807
var selectedFilesAsString = selectedItems . join ( " " ) ;
2785
- if ( selectedItemsFromOtherUser . length > 0 ) {
2786
- if ( ! this . confirmActionOnOtherUsersChanges ( "stash" ) ) {
2787
- return
2788
- }
2789
- }
2790
2808
webui . git ( "stash push -- " + selectedFilesAsString , function ( output ) {
2791
2809
webui . showSuccess ( output ) ;
2792
2810
workspaceView . update ( ) ;
@@ -2795,28 +2813,18 @@ webui.NewChangedFilesView = function(workspaceView) {
2795
2813
2796
2814
self . discard = function ( ) {
2797
2815
var selectedFilesAsString = selectedItems . join ( " " ) ;
2798
- if ( selectedItemsFromOtherUser . length > 0 ) {
2799
- if ( ! this . confirmActionOnOtherUsersChanges ( "discard" ) ) {
2800
- return
2801
- }
2802
- }
2803
- webui . git ( "restore -- " + selectedFilesAsString , function ( output ) {
2816
+ webui . git ( "restore -- " + selectedFilesAsString , function ( ) {
2804
2817
workspaceView . update ( ) ;
2805
2818
} ) ;
2806
2819
}
2807
2820
2808
2821
self . commit = function ( message ) {
2809
2822
var selectedFilesAsString = selectedItems . join ( " " ) ;
2810
2823
2811
- if ( selectedItemsFromOtherUser . length > 0 ) {
2812
- if ( ! this . confirmActionOnOtherUsersChanges ( "commit" ) ) {
2813
- return
2814
- }
2815
- }
2816
2824
webui . git ( "add " + selectedFilesAsString ) ;
2817
2825
webui . git ( 'commit -m "' + message + '" -- ' + selectedFilesAsString , function ( output ) {
2818
2826
webui . showSuccess ( output ) ;
2819
- workspaceView . update ( )
2827
+ workspaceView . update ( ) ;
2820
2828
} ) ;
2821
2829
}
2822
2830
0 commit comments