@@ -28,8 +28,6 @@ module.exports = function(T, t, api) {
28
28
events : {
29
29
'click [tab="<t>"]' : M ( 'ui<T>Tab' ) ,
30
30
'click .js-<t>.js-goto-page' : M ( 'ui<T>GotoPage' ) ,
31
- 'click .js-<t>.js-goto-next' : M ( 'ui<T>NextPage' ) ,
32
- 'click .js-<t>.js-goto-prev' : M ( 'ui<T>PrevPage' ) ,
33
31
'click .js-<t>.js-sortby-title' : M ( 'ui<T>SortByTitle' ) ,
34
32
'click .js-<t>.js-sortby-updated_at' : M ( 'ui<T>SortByUpdated' ) ,
35
33
'click .js-<t>[perpage]' : M ( 'ui<T>PerPage' ) ,
@@ -245,11 +243,9 @@ module.exports = function(T, t, api) {
245
243
object_ids . push ( this . $ ( row ) . attr ( 'id' ) ) ;
246
244
} ) ;
247
245
var project = this . store ( txProject . key ) ,
248
- sourceLocale = this . getSourceLocale ( project ) ,
249
246
data = this . store ( zdApi . key ) ,
250
247
obj = this [ M ( 'calcResourceName<T>' ) ] ( data ) ,
251
- entry , resource , txResourceName , completedLocales ,
252
- zdLocale , translation , zd_locales ;
248
+ entry , resource , txResourceName , completedLocales ;
253
249
254
250
var objects = _ . filter ( obj [ m ( '<t>' ) ] , function ( o ) {
255
251
return object_ids . indexOf ( o . resource_name ) !== - 1 ;
@@ -258,19 +254,14 @@ module.exports = function(T, t, api) {
258
254
io . opResetAll ( ) ;
259
255
this . loadSyncPage = this [ M ( 'ui<T>DownloadComplete' ) ] ;
260
256
261
- zd_locales = io . getLocales ( ) ;
262
257
for ( var i = 0 ; i < objects . length ; i ++ ) {
263
258
entry = objects [ i ] ;
264
259
txResourceName = entry . resource_name ;
265
260
resource = this . store ( txResource . key + txResourceName ) ;
266
261
completedLocales = this . completedLanguages ( resource ) ;
267
262
268
263
for ( var ii = 0 ; ii < completedLocales . length ; ii ++ ) { // iterate through list of locales
269
- translation = this . store ( txResource . key + txResourceName + completedLocales [ ii ] ) ;
270
- if ( typeof translation . content === 'string' ) {
271
- zdLocale = syncUtil . txLocaletoZd ( completedLocales [ ii ] , zd_locales ) ;
272
- this [ M ( 'zdUpsert<T>Translation' ) ] ( translation . content , entry , zdLocale ) ;
273
- }
264
+ this . asyncGetTxResource ( txResourceName , completedLocales [ ii ] , entry . id ) ;
274
265
}
275
266
}
276
267
} ,
@@ -514,34 +505,30 @@ module.exports = function(T, t, api) {
514
505
this . notifyWarning ( 'Some Transifex resources could not be loaded. Please refresh to try again.' ) ;
515
506
}
516
507
this . $ ( m ( '.js-<t>.js-select-all' ) ) . prop ( 'disabled' , false ) ;
517
- this . loadSyncPage = this [ M ( 'ui<T>LanguageComplete' ) ] ;
518
- this [ M ( 'syncCompletedLanguages<T>' ) ] ( ) ;
508
+ this [ M ( 'ui<T>LanguageComplete' ) ] ( ) ;
519
509
} ,
510
+
520
511
'ui<T>LanguageComplete' : function ( ) {
521
512
logger . debug ( M ( 'ui<T>LanguageComplete' ) ) ;
513
+
522
514
var data = this [ M ( 'calcResourceName<T>' ) ] ( this . store ( zdApi . key ) ) ,
523
- num = data [ t ] . length ,
524
515
numLanguages = 0 ,
525
516
resourceName = '' ,
526
- resource = { } ,
527
- languageArray = [ ] ,
528
- resourceLanguage = { } ;
529
- for ( var i = 0 ; i < num ; i ++ ) {
517
+ resource = { } ;
518
+
519
+ for ( var i = 0 ; i < data [ t ] . length ; i ++ ) {
530
520
resourceName = data [ t ] [ i ] . resource_name ;
531
521
resource = this . store ( txResource . key + resourceName ) ;
532
522
//TODO depends on resource typeness
533
523
if ( typeof resource !== 'number' ) {
534
- languageArray = this . completedLanguages ( resource ) ;
535
- numLanguages = languageArray . length ;
536
- for ( var ii = 0 ; ii < numLanguages ; ii ++ ) {
537
- resourceLanguage = this . store ( txResource . key + resourceName + languageArray [ ii ] ) ;
538
- if ( resourceLanguage ) {
539
- this . $ ( '#' + resourceName ) . addClass ( 'js-can-download' ) ;
540
- }
524
+ numLanguages = this . completedLanguages ( resource ) . length ;
525
+ if ( numLanguages ) {
526
+ this . $ ( '#' + resourceName ) . addClass ( 'js-can-download' ) ;
541
527
}
542
528
}
543
529
}
544
530
} ,
531
+
545
532
'ui<T>GotoPage' : function ( event ) {
546
533
if ( event ) event . preventDefault ( ) ;
547
534
if ( this . processing ) return ;
@@ -565,54 +552,7 @@ module.exports = function(T, t, api) {
565
552
} ) ;
566
553
this . loadSyncPage = this [ M ( 'ui<T>Init' ) ] ;
567
554
} ,
568
- 'ui<T>NextPage' : function ( event ) {
569
- if ( event ) event . preventDefault ( ) ;
570
- if ( this . processing ) return ;
571
-
572
- logger . debug ( M ( 'ui<T>NextPage' ) ) ;
573
- var page = this . $ ( event . target ) . attr ( "data-current-page" ) ,
574
- nextPage = parseInt ( page , 10 ) + 1 ,
575
- sorting = io . getSorting ( ) ,
576
- query = io . getQuery ( ) ;
577
- factory . currentpage = nextPage ;
578
- this [ M ( 'asyncGetZd<T>Full' ) ] (
579
- factory . currentpage , sorting . sortby ,
580
- sorting . sortdirection , sorting . perpage , query
581
- ) ;
582
- this . switchTo ( 'loading_page' , {
583
- page : t ,
584
- page_articles : t == 'articles' ,
585
- page_categories : t == 'categories' ,
586
- page_sections : t == 'sections' ,
587
- page_dynamic_content : t == 'dynamic' ,
588
- query_term : query ,
589
- } ) ;
590
- this . loadSyncPage = this [ M ( 'ui<T>Init' ) ] ;
591
- } ,
592
- 'ui<T>PrevPage' : function ( event ) {
593
- if ( event ) event . preventDefault ( ) ;
594
- if ( this . processing ) return ;
595
555
596
- logger . debug ( M ( 'ui<T>PrevPage' ) ) ;
597
- var page = this . $ ( event . target ) . attr ( "data-current-page" ) ,
598
- prevPage = parseInt ( page , 10 ) - 1 ,
599
- sorting = io . getSorting ( ) ,
600
- query = io . getQuery ( ) ;
601
- factory . currentpage = prevPage ;
602
- this [ M ( 'asyncGetZd<T>Full' ) ] (
603
- factory . currentpage , sorting . sortby ,
604
- sorting . sortdirection , sorting . perpage , query
605
- ) ;
606
- this . switchTo ( 'loading_page' , {
607
- page : t ,
608
- page_articles : t == 'articles' ,
609
- page_categories : t == 'categories' ,
610
- page_sections : t == 'sections' ,
611
- page_dynamic_content : t == 'dynamic' ,
612
- query_term : query ,
613
- } ) ;
614
- this . loadSyncPage = this [ M ( 'ui<T>Init' ) ] ;
615
- } ,
616
556
'ui<T>BrandTab' : function ( event ) {
617
557
var brand ;
618
558
if ( event && event . preventDefault ) {
@@ -688,6 +628,7 @@ module.exports = function(T, t, api) {
688
628
this . $ ( '[data-locale]' ) . removeClass ( 'u-color-systemError u-color-systemWarning' ) . addClass ( 'u-color-secondary' ) ;
689
629
this . $ ( m ( '.js-<t>[data-resource]' ) ) . removeClass ( 'o-status is-error is-warning is-success' ) . addClass ( 'o-interactive-list__item' ) ;
690
630
} ,
631
+
691
632
'end<T>Process' : function ( ) {
692
633
this . processing = false ;
693
634
this . $ ( m ( '.js-<t>.js-refresh' ) ) . removeClass ( 'is-disabled' ) ;
@@ -698,6 +639,7 @@ module.exports = function(T, t, api) {
698
639
prop ( 'checked' , false ) ;
699
640
this [ M ( 'ui<T>UpdateButtons' ) ] ( ) ;
700
641
} ,
642
+
701
643
'sync<T>Translations' : function ( ) {
702
644
logger . debug ( M ( 'sync<T>Translations started' ) ) ;
703
645
var data = this . store ( zdApi . key ) ,
@@ -711,6 +653,7 @@ module.exports = function(T, t, api) {
711
653
}
712
654
}
713
655
} ,
656
+
714
657
'syncResourceStats<T>' : function ( ) {
715
658
logger . debug ( M ( 'syncResourceStats<T> started' ) ) ;
716
659
var data = this . store ( zdApi . key ) ,
@@ -724,30 +667,7 @@ module.exports = function(T, t, api) {
724
667
}
725
668
}
726
669
} ,
727
- 'syncCompletedLanguages<T>' : function ( ) {
728
- // Requires txProject, zdApis, and ResourceStats
729
- logger . debug ( M ( 'syncCompletedLanguages<T> started' ) ) ;
730
- // Local function vars
731
- var data = this [ M ( 'calcResourceName<T>' ) ] ( this . store ( zdApi . key ) ) ,
732
- num = data [ t ] . length ,
733
- numLanguages = 0 ,
734
- resourceName = '' ,
735
- resource = { } ,
736
- languageArray = [ ] ;
737
- for ( var i = 0 ; i < num ; i ++ ) {
738
- resourceName = data [ t ] [ i ] . resource_name ;
739
- resource = this . store ( txResource . key + resourceName ) ;
740
- //TODO depends on resource typeness, fast n loose
741
- if ( typeof resource == 'object' ) {
742
- languageArray = this . completedLanguages ( resource ) ;
743
- numLanguages = languageArray . length ;
744
- for ( var ii = 0 ; ii < numLanguages ; ii ++ ) {
745
- // Side effect: make api calls and load resources
746
- this . asyncGetTxResource ( resourceName , languageArray [ ii ] ) ;
747
- }
748
- }
749
- }
750
- } ,
670
+
751
671
'buildSyncPage<T>Data' : function ( ) {
752
672
var data = this . store ( zdApi . key ) ,
753
673
entries = this [ M ( 'calcResourceName<T>' ) ] ( data ) ,
@@ -798,13 +718,16 @@ module.exports = function(T, t, api) {
798
718
ret = _ . extend ( ret , {
799
719
page_prev_enabled : this . isFewer ( data , currentPage ) ,
800
720
page_next_enabled : this . isMore ( data , currentPage ) ,
801
- current_page : this . getCurrentPage ( data ) ,
721
+ current_page : currentPage ,
722
+ prev_page : currentPage - 1 ,
723
+ next_page : currentPage + 1 ,
802
724
pagination_visible : paginationVisible ,
803
725
pages : this . getPages ( data )
804
726
} ) ;
805
727
}
806
728
return ret ;
807
729
} ,
730
+
808
731
'handleSearch<T>' : function ( ) {
809
732
if ( t != 'articles' ) {
810
733
this . $ ( '.js-search' ) . addClass ( "u-display-none" ) ;
0 commit comments