Skip to content

Commit e176594

Browse files
committed
added updated group
1 parent 99f2e19 commit e176594

5 files changed

Lines changed: 61 additions & 33 deletions

File tree

‎cache.manifest‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CACHE MANIFEST
2-
# Build: 20160119030716
2+
# Build: 20160119052909
33

44
CACHE:
55
resources/fonts/Dressedless_Three.svg

‎index.html‎

Lines changed: 6 additions & 5 deletions
Large diffs are not rendered by default.

‎static/app/index.html‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,9 @@ <h5>Add GitHub accounts to group your stars and repos</h5>
163163
<header class="card-header hd" role="tab" id="repo_group_hd_{id}">
164164
<a href="#repo_group_list_{id}" data-toggle="collapse" data-parent=".bd" aria-expanded="false" aria-controls="repo_group_list_{id}">{name}</a>
165165
&nbsp;<span class="label label-info label-pill count">{itemCount}</span>
166-
<div class="btn-group btn-group-sm pull-xs-right ctrl">
167-
<button class="btn btn-secondary btn-sm del" data-id="{id}"><i class="fa fa-trash-o"></i></button>
166+
<div class="pull-xs-right ctrl">
167+
<div class="edit" data-id="{id}" data-name="{name}"><i class="fa fa-pencil-square-o"></i></div>
168+
<div class="del" data-id="{id}"><i class="fa fa-trash-o"></i></div>
168169
</div>
169170
<form class="form-inline pull-xs-right search">
170171
<div class="form-group">
@@ -186,7 +187,7 @@ <h5>Add GitHub accounts to group your stars and repos</h5>
186187
</div>
187188
</script>
188189
<script type="text/html" data-template="repoItem">
189-
<article class="card repo-item" data-id="{id}" data-repoid="{originRepoId}" data-name="{full_name}">
190+
<article class="card repo-item" data-id="{id}" data-repoid="{originRepoId}" data-name="{_full_name}">
190191
<div class="card-block">
191192
<header class="repo-item__hd"><h6><a href="{html_url}" target="_blank">{full_name}</a></h6></header>
192193
<section class="repo-item__bd">{description}</section>

‎static/app/resources/css/style.css‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,16 @@ html,body{
231231
.bookmark-modal .repo-group-item>.hd .search{
232232
display: none;
233233
cursor: pointer;
234+
max-width: 70%;
234235
}
235236
.bookmark-modal .repo-group-item[data-id="0"]>.hd .search{
236237
display: block;
237238
}
239+
.bookmark-modal .repo-group-item .hd .ctrl>div{
240+
display: inline-block;
241+
padding-left: .4rem;
242+
cursor: pointer;
243+
}
238244
.bookmark-modal .repo-group-item[data-id="0"]>.hd .ctrl,
239245
.bookmark-modal .repo-group-item[data-id="0"] .dropdown-menu>.dropdown-item:last-child{
240246
display: none;

‎static/app/src/App.js‎

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -473,15 +473,15 @@ $(function () {
473473
.exec().then(function (res) {
474474
curUser = res[0];
475475
callback && callback();
476-
win.trigger('DB:Table.User.onchange', {type: DBEventType.C, result: res});
476+
win.trigger('DB:Table.User.onchange', {type: DBEventType.C});
477477
});
478478
});
479479
}
480480

481481
this.updateSync = function (name) {
482482
DB.update(Tables.User).set(Tables.User.lastSync, new Date()).where(Tables.User.name.eq(name))
483483
.exec().then(function (res) {
484-
win.trigger('DB:Table.User.onchange', {type: DBEventType.U, result: res});
484+
win.trigger('DB:Table.User.onchange', {type: DBEventType.U});
485485
});
486486
}
487487

@@ -495,7 +495,7 @@ $(function () {
495495
.where(Tables.User.id.eq(id))
496496
.exec().then(function (res) {
497497
callback && callback(res);
498-
win.trigger('DB:Table.User.onchange', {type: DBEventType.D, result: res});
498+
win.trigger('DB:Table.User.onchange', {type: DBEventType.D});
499499
});
500500
});
501501
}
@@ -525,7 +525,7 @@ $(function () {
525525
.exec().then(function (rows) {
526526
!rows.length && DB.insertOrReplace().into(Tables.RepoGroup).values([row])
527527
.exec().then(function (res) {
528-
win.trigger('DB:Table.RepoGroup.onchange', {type: DBEventType.C, result: res});
528+
win.trigger('DB:Table.RepoGroup.onchange', {type: DBEventType.C});
529529
});
530530
});
531531
}
@@ -540,9 +540,7 @@ $(function () {
540540
}
541541
ids = ids.length ? ids.join(',') : '';
542542
DB.update(Tables.RepoGroup).set(Tables.RepoGroup.repoIds, ids).where(Tables.RepoGroup.id.eq(id))
543-
.exec().then(function (res) {
544-
win.trigger('DB:Table.RepoGroup.onchange', {type: DBEventType.U, result: res});
545-
});
543+
.exec();
546544
}
547545
});
548546
}
@@ -559,20 +557,24 @@ $(function () {
559557
}
560558
ids = ids.length ? ids.join(',') : '';
561559
DB.update(Tables.RepoGroup).set(Tables.RepoGroup.repoIds, ids).where(Tables.RepoGroup.id.eq(id))
562-
.exec().then(function (res) {
563-
win.trigger('DB:Table.RepoGroup.onchange', {type: DBEventType.U, result: res});
564-
});
560+
.exec();
565561
}
566562
});
567563
}
564+
this.updateName = function (id, name) {
565+
DB.update(Tables.RepoGroup).set(Tables.RepoGroup.name, name).where(Tables.RepoGroup.id.eq(id))
566+
.exec().then(function () {
567+
win.trigger('DB:Table.RepoGroup.onchange', {type: DBEventType.U, fields: 'name'});
568+
});
569+
}
568570

569571
this.delete = function (id, callback) {
570572
DB.delete()
571573
.from(Tables.RepoGroup)
572574
.where(Tables.RepoGroup.id.eq(id))
573575
.exec().then(function (res) {
574576
callback && callback(res);
575-
win.trigger('DB:Table.RepoGroup.onchange', {type: DBEventType.D, result: res});
577+
win.trigger('DB:Table.RepoGroup.onchange', {type: DBEventType.D});
576578
});
577579
}
578580

@@ -627,7 +629,7 @@ $(function () {
627629
.where(Tables.Repo.id.eq(id))
628630
.exec().then(function (res) {
629631
callback && callback(res);
630-
win.trigger('DB:Table.Repo.onchange', {type: DBEventType.D, result: res});
632+
win.trigger('DB:Table.Repo.onchange', {type: DBEventType.D});
631633
});
632634
}
633635

@@ -637,7 +639,7 @@ $(function () {
637639
.where(Tables.Repo.userId.eq(id))
638640
.exec().then(function (res) {
639641
callback && callback(res);
640-
win.trigger('DB:Table.Repo.onchange', {type: DBEventType.D, result: res});
642+
win.trigger('DB:Table.Repo.onchange', {type: DBEventType.D});
641643
});
642644
}
643645

@@ -825,6 +827,7 @@ $(function () {
825827
bookmarkUserModalUserTpl: $('.bookmark-user-modal .user-list script').html(),
826828

827829
bookmarkGroupModal: $('.bookmark-group-modal'),
830+
bookmarkGroupModalInput: $('.bookmark-group-modal input'),
828831

829832
githubCorner: $('.github-corner svg'),
830833
donate: $('.donate'),
@@ -862,12 +865,12 @@ $(function () {
862865

863866
//bookmark
864867
els.win.on('DB:ready', renderBookmarkGroup);
865-
els.win.on('DB:Table.RepoGroup.onchange', function(e,data){
866-
data && data.type!='UPDATED' && renderBookmarkGroup();
867-
});
868+
els.win.on('DB:Table.RepoGroup.onchange', renderBookmarkGroup);
868869
els.bookmarkBtn.on('click', showBookmark);
869870
els.bookmarkModal.on('click', '.add-account', showBookmarkUserModal);
870-
els.bookmarkModal.on('click', '.add-group', showBookmarkGroupModal);
871+
els.bookmarkModal.on('click', '.add-group', function(){
872+
showBookmarkGroupModal();
873+
});
871874
els.bookmarkModalContentHd.on('click', '.submit', function(){
872875
beforeAddBookmarkUser(els.bookmarkModalContentHd);
873876
});
@@ -886,8 +889,11 @@ $(function () {
886889
return false;
887890
}
888891
});
889-
els.bookmarkGroupModal.on('click', '.submit', beforeAddBookmarkGroup);
892+
els.bookmarkGroupModal.on('click', '.submit', beforeEditBookmarkGroup);
890893
els.bookmarkModalContent.on('click', '.repo-group-item>.hd .ctrl .del', beforeDelBookmarkGroup);
894+
els.bookmarkModalContent.on('click', '.repo-group-item>.hd .ctrl .edit', function(){
895+
showBookmarkGroupModal(this.dataset.id,this.dataset.name);
896+
});
891897
els.bookmarkModalContent.on('click', '.dropdown-item', beforeAddRepoToGroup);
892898
els.bookmarkModalContent.on('keyup','.repo-group-item>.hd .search input',renderBookmarkSearchRepos);
893899
els.bookmarkModalContent.on('click','.repo-group-item>.hd .search submit',renderBookmarkSearchRepos);
@@ -933,9 +939,14 @@ $(function () {
933939
els.bookmarkUserModal.modal('show');
934940
}
935941

936-
function showBookmarkGroupModal() {
942+
function showBookmarkGroupModal(id,name) {
937943
hideBookmark();
938944
els.bookmarkGroupModal.modal('show');
945+
if(id){
946+
els.bookmarkGroupModalInput.attr('data-id',id).val(name||'');
947+
}else{
948+
els.bookmarkGroupModalInput.removeAttr('data-id').val('');
949+
}
939950
}
940951

941952
function onLocationHashChanged(e) {
@@ -1085,6 +1096,7 @@ $(function () {
10851096
.replace(/\{id\}/g, repo.id)
10861097
.replace(/\{originRepoId\}/g, repo.originRepoId)
10871098
.replace(/\{full_name\}/g, repo.data.full_name)
1099+
.replace(/\{_full_name\}/g, repo.data.full_name.toLowerCase())
10881100
.replace(/\{description\}/g, repo.data.description||'')
10891101
.replace(/\{html_url\}/g, repo.data.html_url)
10901102
.replace(/\{groupItems\}/g, allGroupHtm)
@@ -1346,7 +1358,7 @@ $(function () {
13461358
var gEl = els.bookmarkModalContent.find('.repo-group-item[data-id="0"]'),
13471359
inputEl = gEl.find('.hd .search input'),
13481360
countEl = gEl.find('.hd .count'),
1349-
val = inputEl.val().trim(),
1361+
val = inputEl.val().trim().toLowerCase(),
13501362
repoEls = gEl.find('.repo-list .repo-item'),
13511363
matchRepoEls = gEl.find('.repo-list .repo-item[data-name*="'+val+'"]'),
13521364
resultRepoEls = val.length?matchRepoEls:repoEls;
@@ -1418,10 +1430,18 @@ $(function () {
14181430
inputEl.val('');
14191431
}
14201432

1421-
function beforeAddBookmarkGroup() {
1422-
els.bookmarkGroupModalInput = els.bookmarkGroupModalInput || els.bookmarkGroupModal.find('input');
1423-
var val = els.bookmarkGroupModal.find('input').val().trim();
1424-
val.length && bookmarkModel.RepoGroupTable.add(val);
1433+
function beforeEditBookmarkGroup() {
1434+
var id = els.bookmarkGroupModalInput.attr('data-id'),
1435+
val = els.bookmarkGroupModalInput.val().trim();
1436+
1437+
if(val.length){
1438+
if(id){
1439+
bookmarkModel.RepoGroupTable.updateName(id,val);
1440+
els.bookmarkGroupModalInput.removeAttr('data-id');
1441+
}else{
1442+
bookmarkModel.RepoGroupTable.add(val);
1443+
}
1444+
}
14251445
els.bookmarkGroupModalInput.val('');
14261446
}
14271447

0 commit comments

Comments
 (0)