@@ -2123,6 +2123,7 @@ webui.WorkspaceView = function(mainView) {
2123
2123
self . workingCopyView . update ( ) ;
2124
2124
self . stagingAreaView . update ( ) ;
2125
2125
self . commitMessageView . update ( ) ;
2126
+ self . newChangedFilesView . update ( ) ;
2126
2127
if ( self . workingCopyView . getSelectedItemsCount ( ) + self . stagingAreaView . getSelectedItemsCount ( ) == 0 ) {
2127
2128
self . diffView . update ( undefined , undefined , undefined , mode ) ;
2128
2129
}
@@ -2205,7 +2206,6 @@ webui.ChangedFilesView = function(workspaceView, type, label) {
2205
2206
}
2206
2207
2207
2208
if ( isForCurrentUser ) {
2208
- console . log ( fileList ) ;
2209
2209
addItemToFileList ( fileList , "" , model ) ;
2210
2210
}
2211
2211
}
@@ -2514,70 +2514,173 @@ webui.NewChangedFilesView = function(workspaceView) {
2514
2514
webui . git ( "status -u --porcelain" , function ( data ) {
2515
2515
$ . get ( "api/uncommitted" , function ( uncommitted ) {
2516
2516
var uncommittedItems = JSON . parse ( uncommitted ) [ "current user's changes" ] ;
2517
+ self . filesCount = 0 ;
2518
+ function addItemToFileList ( fileList , workingTreeStatus , model ) {
2519
+ var formCheck = $ ( '<div class="form-check changes-check"></div>' ) ;
2520
+ formCheck . attr ( "data-filename" , model ) ;
2521
+
2522
+ var checkboxInput = $ ( '<input class="form-check-input changes-checkbox" type="checkbox" value="">' ) ;
2523
+ checkboxInput . attr ( 'id' , model ) ;
2524
+ formCheck . append ( checkboxInput ) ;
2525
+
2526
+ var checkboxLabel = $ ( '<label class="form-check-label file-item-label"></label>' ) . text ( model ) ;
2527
+ checkboxLabel . addClass ( workingTreeStatus ) ;
2528
+ checkboxLabel . attr ( 'for' , model ) ;
2529
+ formCheck . append ( checkboxLabel ) ;
2530
+
2531
+ formCheck . prependTo ( fileList ) [ 0 ] ;
2532
+ // item.model = model;
2533
+ // item.appendChild(document.createTextNode(model));
2534
+ // $(item).click(self.select);
2535
+
2536
+ }
2537
+ webui . splitLines ( data ) . forEach ( function ( line ) {
2538
+ var indexStatus = line [ 0 ] ;
2539
+ var workingTreeStatus = line [ 1 ] ;
2540
+ line = line . substring ( 3 ) ;
2541
+ var splitted = line . split ( " -> " ) ;
2542
+ var model ;
2543
+ if ( splitted . length > 1 ) {
2544
+ model = splitted [ 1 ] ;
2545
+ } else {
2546
+ model = line ;
2547
+ }
2548
+
2549
+
2550
+ ++ self . filesCount ;
2551
+ var isForCurrentUser ;
2552
+ if ( model . indexOf ( " " ) > - 1 ) {
2553
+ isForCurrentUser = ( uncommittedItems . indexOf ( model . substring ( 1 , model . length - 1 ) ) > - 1 ) ;
2554
+ } else {
2555
+ isForCurrentUser = ( uncommittedItems . indexOf ( model ) > - 1 ) ;
2556
+ }
2557
+
2558
+ if ( isForCurrentUser ) {
2559
+ addItemToFileList ( fileList , workingTreeStatus , model ) ;
2560
+ }
2561
+
2562
+ } ) ;
2563
+ $ ( ".changes-checkbox" ) . change ( function ( ) {
2564
+ var fileName = this . id ;
2565
+ var fileIndex = selectedItems . indexOf ( fileName ) ;
2566
+ if ( this . checked ) {
2567
+ if ( fileIndex == - 1 ) {
2568
+ selectedItems . push ( fileName ) ;
2569
+ }
2570
+ } else {
2571
+ $ ( '#selectAllFiles' ) . prop ( 'checked' , false ) ;
2572
+ if ( fileIndex > - 1 ) {
2573
+ selectedItems . splice ( fileIndex , 1 ) ;
2574
+ }
2575
+ }
2576
+ self . updateButtons ( ) ;
2577
+ } ) ;
2517
2578
2518
- } )
2579
+ $ ( "#commitMsg" ) . on ( "input" , function ( ) {
2580
+ self . updateButtons ( ) ;
2581
+ } ) ;
2582
+
2583
+ $ ( '.changes-check' ) . on ( "click" , function ( ) {
2584
+ self . unhighlightPrevious ( ) ;
2585
+ $ ( this ) . addClass ( "diffed-file" ) ;
2586
+ self . fileToDiff = $ ( this ) . attr ( "data-filename" ) ;
2587
+ self . refreshDiff ( ) ;
2588
+
2589
+ } ) ;
2590
+
2591
+ $ ( '#selectAllFiles' ) . on ( "input" , function ( ) {
2592
+ if ( $ ( this ) . checked ) {
2593
+ self . selectAll ( ) ;
2594
+ } else {
2595
+ self . deselectAll ( ) ;
2596
+ }
2597
+ } )
2598
+ } ) ;
2519
2599
} ) ;
2520
2600
}
2521
2601
2602
+ self . handleCheckEvent = function ( file ) {
2603
+ var fileIndex = selectedItems . indexOf ( file ) ;
2604
+ if ( fileIndex > - 1 ) {
2605
+ selectedItems . splice ( fileIndex , 1 ) ;
2606
+ } else {
2607
+ selectedItems . push ( file ) ;
2608
+ }
2609
+ self . updateButtons ( ) ;
2610
+ }
2611
+
2612
+ self . updateButtons = function ( ) {
2613
+ if ( self . getSelectedItemsCount ( ) > 0 ) {
2614
+ $ ( '#stashBtn' ) . prop ( "disabled" , false ) ;
2615
+ $ ( '#discardBtn' ) . prop ( "disabled" , false ) ;
2616
+ if ( ! self . commitMsgEmpty ( ) ) {
2617
+ $ ( '#commitBtn' ) . prop ( "disabled" , false ) ;
2618
+ } else {
2619
+ $ ( '#commitBtn' ) . prop ( "disabled" , true ) ;
2620
+ }
2621
+ } else {
2622
+ $ ( '#stashBtn' ) . prop ( "disabled" , true ) ;
2623
+ $ ( '#discardBtn' ) . prop ( "disabled" , true ) ;
2624
+ $ ( '#commitBtn' ) . prop ( "disabled" , true ) ;
2625
+ }
2626
+
2627
+ }
2628
+
2629
+ self . commitMsgEmpty = function ( ) {
2630
+ return $ ( '#commitMsg' ) . val ( ) . length == 0 ;
2631
+ }
2632
+
2522
2633
self . getSelectedItemsCount = function ( ) {
2523
- return $ ( ".active" , fileList ) . length ;
2634
+ return selectedItems . length ;
2635
+ }
2636
+
2637
+ self . selectAll = function ( ) {
2638
+
2639
+ }
2640
+
2641
+ self . deselectAll = function ( ) {
2642
+
2643
+ }
2644
+
2645
+ self . unhighlightPrevious = function ( ) {
2646
+ $ ( '[data-filename="' + self . fileToDiff + '"]' ) . removeClass ( "diffed-file" ) ;
2647
+ }
2648
+
2649
+ self . refreshDiff = function ( ) {
2650
+ self . fileToDiff ;
2651
+ workspaceView . diffView . update ( "diff" , [ ] , self . fileToDiff , "stage" ) ;
2524
2652
}
2525
2653
2526
2654
self . element = $ (
2527
2655
'<div id="changedFilesContainer" class="container">' +
2528
2656
'<div class="row">' +
2529
2657
'<div class="col-sm-6 file-area">' +
2530
- '<div class="changed-files-list">' +
2531
- '<div class="form-check">' +
2532
- '<input class="form-check-input" type="checkbox" value="" id="defaultCheck1">' +
2533
- '<label class="form-check-label file-item-label" for="defaultCheck1">' +
2534
- 'test check' +
2535
- '</label>' +
2536
- '</div>' +
2537
- '<div class="form-check">' +
2538
- '<input class="form-check-input" type="checkbox" value="" id="defaultCheck2" checked>' +
2539
- '<label class="form-check-label file-item-label" for="defaultCheck2">' +
2540
- 'test check' +
2541
- '</label>' +
2542
- '</div>' +
2543
- '<div class="form-check">' +
2544
- '<input class="form-check-input" type="checkbox" value="" id="defaultCheck3">' +
2545
- '<label class="form-check-label file-item-label" for="defaultCheck3">' +
2546
- 'test check' +
2547
- '</label>' +
2548
- '</div>' +
2549
- '<div class="form-check">' +
2550
- '<input class="form-check-input" type="checkbox" value="" id="defaultCheck4">' +
2551
- '<label class="form-check-label file-item-label" for="defaultCheck4">' +
2552
- 'test check' +
2553
- '</label>' +
2554
- '</div>' +
2555
- '<div class="form-check">' +
2556
- '<input class="form-check-input" type="checkbox" value="" id="defaultCheck5" checked>' +
2557
- '<label class="form-check-label file-item-label" for="defaultCheck5">' +
2558
- 'test check' +
2559
- '</label>' +
2560
- '</div>' +
2658
+ '<div class="form-check select-all">' +
2659
+ '<input class="form-check-input" id="selectAllFiles" type="checkbox" value="">' +
2660
+ '<label class="form-check-label" for="selectAllFiles"> Select All Files </label>' +
2561
2661
'</div>' +
2662
+ '<div class="changed-files-list"></div>' +
2562
2663
'</div>' +
2563
2664
'<div class="commit-area col-sm-6">' +
2564
2665
'<div class="form-group">' +
2565
- '<input type="area" class="form-control" id="commitMsg" placeholder="Enter commit message">' +
2666
+ '<input type="area" class="form-control" id="commitMsg" placeholder="Enter commit message (required, 72 character limit) ">' +
2566
2667
'</div>' +
2567
2668
'<div class="form-group">' +
2568
- '<textarea class="form-control" id="commitMsgDetail" placeholder="Enter commit message details (optional)"></textarea>' +
2669
+ '<textarea class="form-control" id="commitMsgDetail" placeholder="Enter commit details (optional, no character limit )"></textarea>' +
2569
2670
'</div>' +
2570
2671
'<div class="button-group">' +
2571
- '<button type="button" class="btn btn-primary file-action-button"> Commit </button>' +
2572
- '<button type="button" class="btn btn-secondary file-action-button" > Stash </button>' +
2573
- '<button type="button" class="btn btn-danger file-action-button"> Discard </button>' +
2672
+ '<button type="button" class="btn btn-primary file-action-button" id="commitBtn" disabled > Commit </button>' +
2673
+ '<button type="button" class="btn btn-secondary file-action-button" id="stashBtn" disabled > Stash </button>' +
2674
+ '<button type="button" class="btn btn-danger file-action-button" id="discardBtn" disabled > Discard </button>' +
2574
2675
'</div>' +
2575
2676
'</div>' +
2576
2677
'</div>' +
2577
2678
'</div>'
2578
2679
) [ 0 ] ;
2579
2680
var fileListContainer = $ ( ".file-area" , self . element ) [ 0 ] ;
2580
2681
var fileList = $ ( ".changed-files-list" , fileListContainer ) [ 0 ] ;
2682
+ var selectedItems = [ ] ;
2683
+ var fileToDiff ;
2581
2684
}
2582
2685
2583
2686
/*
0 commit comments