@@ -559,7 +559,7 @@ $(function () {
559559 }
560560 ids = ids . length ? ids . join ( ',' ) : '' ;
561561 DB . update ( Tables . RepoGroup ) . set ( Tables . RepoGroup . repoIds , ids ) . where ( Tables . RepoGroup . id . eq ( id ) )
562- . exec ( ) . then ( function ( ) {
562+ . exec ( ) . then ( function ( res ) {
563563 win . trigger ( 'DB:Table.RepoGroup.onchange' , { type : DBEventType . U , result : res } ) ;
564564 } ) ;
565565 }
@@ -668,6 +668,7 @@ $(function () {
668668 }
669669 this . resetPage = function ( ) {
670670 page = 1 ;
671+ mainData = [ ] ;
671672 }
672673 this . request = function ( callback ) {
673674 $ . ajax ( {
@@ -699,6 +700,7 @@ $(function () {
699700 }
700701 this . resetPage = function ( ) {
701702 page = 1 ;
703+ mainData = [ ] ;
702704 }
703705 this . request = function ( callback ) {
704706 $ . ajax ( {
@@ -860,7 +862,9 @@ $(function () {
860862
861863 //bookmark
862864 els . win . on ( 'DB:ready' , renderBookmarkGroup ) ;
863- els . win . on ( 'DB:Table.RepoGroup.onchange' , renderBookmarkGroup ) ;
865+ els . win . on ( 'DB:Table.RepoGroup.onchange' , function ( e , data ) {
866+ data && data . type != 'UPDATED' && renderBookmarkGroup ( ) ;
867+ } ) ;
864868 els . bookmarkBtn . on ( 'click' , showBookmark ) ;
865869 els . bookmarkModal . on ( 'click' , '.add-account' , showBookmarkUserModal ) ;
866870 els . bookmarkModal . on ( 'click' , '.add-group' , showBookmarkGroupModal ) ;
@@ -1393,17 +1397,32 @@ $(function () {
13931397
13941398 function beforeAddRepoToGroup ( ) {
13951399 var el = $ ( this ) ,
1396- gId = el . attr ( 'data-id' ) ,
1400+ targetGroupId = el . attr ( 'data-id' ) ,
13971401 repoEl = el . parents ( '.repo-item' ) ,
13981402 repoId = repoEl . attr ( 'data-repoid' ) ,
13991403 curGroupEl = el . parents ( '.repo-group-item' ) ,
1400- curGroupId = curGroupEl . attr ( 'data-id' ) ;
1404+ curGroupId = curGroupEl . attr ( 'data-id' ) ,
1405+ curGroupElCountEl = curGroupEl . find ( '.hd>.count' ) ,
1406+ curGoupCountNum = parseInt ( curGroupElCountEl . html ( ) ) ,
1407+ targetGoupEl = curGroupEl . siblings ( '.repo-group-item[data-id="' + targetGroupId + '"]' ) ,
1408+ targetGoupCountEl = targetGoupEl . find ( '.hd>.count' ) ,
1409+ targetGoupCountNum = parseInt ( targetGoupCountEl . html ( ) ) ,
1410+ targetGroupHasRepo = targetGoupEl . find ( '.repo-item[data-repoid="' + repoId + '"]' ) . length ;
14011411
14021412 els . lastEditBookmarkRepoGroupId = curGroupId ;
1403- if ( gId != undefined && gId != 0 ) {
1404- bookmarkModel . RepoGroupTable . addRopoId ( gId , repoId ) ;
1413+ if ( targetGroupId != undefined && targetGroupId != 0 ) {
1414+ bookmarkModel . RepoGroupTable . addRopoId ( targetGroupId , repoId ) ;
1415+
1416+ if ( ! targetGroupHasRepo ) {
1417+ targetGoupCountEl . html ( ++ targetGoupCountNum ) ;
1418+ targetGoupEl . find ( '.repo-list' ) . append ( repoEl . clone ( ) ) ;
1419+ }
1420+
14051421 } else if ( curGroupId != 0 ) {
14061422 bookmarkModel . RepoGroupTable . removeRopoId ( curGroupId , repoId ) ;
1423+
1424+ curGroupElCountEl . html ( -- curGoupCountNum ) ;
1425+ repoEl . remove ( ) ;
14071426 }
14081427 }
14091428
0 commit comments