diff --git a/controller/lib/bookmarks.php b/controller/lib/bookmarks.php index bbc59eb5..5af1f6dd 100644 --- a/controller/lib/bookmarks.php +++ b/controller/lib/bookmarks.php @@ -40,15 +40,14 @@ class Bookmarks { * @return Found Tags */ public static function findTags($userId, IDb $db, $filterTags = array(), $offset = 0, $limit = -1) { - $params = array_merge($filterTags, $filterTags); + $params = $filterTags; array_unshift($params, $userId); $not_in = ''; if (!empty($filterTags)) { $exist_clause = " AND exists (select 1 from `*PREFIX*bookmarks_tags` `t2` where `t2`.`bookmark_id` = `t`.`bookmark_id` and `tag` = ?) "; - $not_in = ' AND `tag` not in (' . implode(',', array_fill(0, count($filterTags), '?')) . ')' . - str_repeat($exist_clause, count($filterTags)); + $not_in = str_repeat($exist_clause, count($filterTags)); } $sql = 'SELECT tag, count(*) as nbr from *PREFIX*bookmarks_tags t ' . ' WHERE EXISTS( SELECT 1 from *PREFIX*bookmarks bm where t.bookmark_id = bm.id and user_id = ?) ' . @@ -56,6 +55,7 @@ class Bookmarks { ' GROUP BY `tag` ORDER BY `nbr` DESC '; $query = $db->prepareQuery($sql, $limit, $offset); + $tags = $query->execute($params)->fetchAll(); return $tags; } diff --git a/controller/webviewcontroller.php b/controller/webviewcontroller.php index eaf68950..4cfa7d8b 100644 --- a/controller/webviewcontroller.php +++ b/controller/webviewcontroller.php @@ -38,16 +38,34 @@ class WebViewController extends Controller { */ public function index() { $bookmarkleturl = $this->urlgenerator->getAbsoluteURL('index.php/apps/bookmarks/bookmarklet'); - $params = array('user' => $this->userId, 'bookmarkleturl' => $bookmarkleturl); + $navigationEntries = $this->getNavigationEntries(); + + $params = array( + 'bookmarkleturl' => $bookmarkleturl, + 'navigationEntries' => $navigationEntries, + ); $policy = new ContentSecurityPolicy(); $policy->addAllowedFrameDomain("'self'"); $response = new TemplateResponse('bookmarks', 'main', $params); $response->setContentSecurityPolicy($policy); + return $response; } + protected function getNavigationEntries() { + $l = \OC::$server->getL10N('files'); + $entries = []; + $entries[] = [ + 'id' => 'all', + 'name' => (string) $l->t('All Bookmarks'), + 'class' => 'navigationAllBookmarks' + //'url' => \OC::$server->getURLGenerator()->linkToRoute('bookmarks.bookmark.get_bookmarks'), + ]; + return $entries; + } + /** * @NoAdminRequired * @NoCSRFRequired diff --git a/css/bookmarks.css b/css/bookmarks.css index d8de09f8..89eb8169 100644 --- a/css/bookmarks.css +++ b/css/bookmarks.css @@ -209,29 +209,6 @@ ul.tagit li.tagit-new { cursor: default; } -li.tag_list { - padding-left: 3px; - padding-right: 3px; - overflow: hidden; -} - -li.tag_list a { - display: inline !important; - padding: 5px 11px 5px 11px !important; - border: 1px solid transparent; -} - -li.tag_list li:hover > a { - background: none repeat scroll 0 0 #dee7f8 !important; - border: 1px solid #cad8f3; - border-radius: 6px; -} - -.tag_list em , .share_list em{ - float:right; - display:block; -} - .tags_actions { margin-left: 0.5em; display: inline; @@ -437,3 +414,32 @@ ul.tagit li.tagit-choice .close .text-icon { margin-top: 5px; padding: 0 5px 2px; } + +/* new */ + +#app-navigation li { + transition: max-height 300ms ease 0s; + max-height: 100px; +} +#app-navigation li.edit > a, +#app-navigation li.edit .app-navigation-entry-utils, +#app-navigation li.edit .app-navigation-entry-menu { + display: none; +} +#app-navigation li.edit .app-navigation-entry-edit { + display: inline-block; +} +#app-navigation li .app-navigation-entry-edit { + display: none; +} +#app-navigation li a > span.icon { + margin-top: -3px; +} +#app-navigation li a > span.title { + margin-left: 9px; +} +#app-navigation li.animate-up { + max-height: 0px; + border-bottom: 0; + overflow: hidden; +} diff --git a/js/bookmarks.js b/js/bookmarks.js index 4c2ef22a..a84c09bc 100644 --- a/js/bookmarks.js +++ b/js/bookmarks.js @@ -24,6 +24,8 @@ $(document).ready(function () { onTagFinishRemoved: filterTagsChanged, placeholderText: t('bookmarks', 'Filter by tag') }).tagit('option', 'onTagAdded', filterTagsChanged); + $('.navigationAllBookmarks').click(resetTagFilter); + getBookmarks(); }); @@ -101,9 +103,37 @@ function addFilterTag(event) { $('#tag_filter input').tagit('createTag', $(this).text()); } +function resetTagFilter() { + $('#tag_filter input').tagit('removeAll'); +} + function updateTagsList(tag) { + var selectedTags = $('#tag_filter input').tagit('assignedTags'); + var html = tmpl("tag_tmpl", tag); $('.tag_list').append(html); + $('.tag_list li').each(function(){ + var tagName = $(this).find('a span').text(); + var inArrayResult = $.inArray(tagName, selectedTags); + console.warn(inArrayResult); + console.warn(tagName); + console.log(this); + if(inArrayResult > -1) { + $(this).addClass('active'); + } + }); + + return; + + var $entry = $('.navigationTagTemplate') + .clone(); + $entry + .removeClass('hidden') + .removeClass('navigationTagTemplate') + .addClass('navigationTagEntry'); + $entry.find('a').text(tag.tag); + $entry.find('.count').text(tag.nbr); + $entry.appendTo($('#navigation-list')); } function filterTagsChanged() @@ -134,8 +164,9 @@ function getBookmarks() { } $('.tag_list .tag_edit').click(renameTag); $('.tag_list .tag_delete').click(deleteTag); - $('.tag_list a.tag').click(addFilterTag); + $('.navigationTagEntry a').click(addFilterTag); + $('.with-menu a').bind('click', addFilterTag); } }); diff --git a/templates/js_tpl.php b/templates/js_tpl.php index ce083c04..d6ad0c48 100644 --- a/templates/js_tpl.php +++ b/templates/js_tpl.php @@ -48,17 +48,27 @@ diff --git a/templates/main.php b/templates/main.php index 72bc9d78..18c7dd65 100644 --- a/templates/main.php +++ b/templates/main.php @@ -35,14 +35,26 @@ function bookmarklet($bookmarkleturl) { + + +
"/>
" /> -