mirror of
https://github.com/owncloud/bookmarks.git
synced 2025-02-26 23:54:25 +01:00
sidebar with tags
This commit is contained in:
parent
9a497c28ee
commit
fc5291d3e7
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -48,17 +48,27 @@
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/html" id="tag_tmpl">
|
||||
<li><a href="" class="tag"><&= escapeHTML(tag) &></a>
|
||||
<div class="tags_actions">
|
||||
<span class="tag_delete">
|
||||
<img class="svg" src="<?php print_unescaped(OCP\image_path("", "actions/delete.svg")); ?>"
|
||||
title="<?php p($l->t('Delete')); ?>">
|
||||
</span>
|
||||
<span class="tag_edit">
|
||||
<img class="svg" src="<?php print_unescaped(OCP\image_path("", "actions/rename.svg")); ?>"
|
||||
title="<?php p($l->t('Edit')); ?>">
|
||||
</span>
|
||||
<em><&= nbr &></em>
|
||||
<li class="with-menu">
|
||||
<a href="" class="">
|
||||
<span class="title"><&= escapeHTML(tag) &></span>
|
||||
</a>
|
||||
<div class="app-navigation-entry-utils">
|
||||
<ul>
|
||||
<li class="app-navigation-entry-utils-counter"><&= nbr &></li>
|
||||
<li class="app-navigation-entry-utils-menu-button svg"><button></button></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="app-navigation-entry-menu">
|
||||
<ul>
|
||||
<li><button class="icon-rename svg" title="<?php p($l->t('rename')); ?>"</button></li>
|
||||
<li><button class="icon-delete svg" title="<?php p($l->t('delete')); ?>"></button></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="app-navigation-entry-edit">
|
||||
<form>
|
||||
<input class="edit" type="text" autofocus-on-insert>
|
||||
<input type="submit" value="" class="action icon-checkmark svg">
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
</script>
|
||||
|
@ -35,13 +35,25 @@ function bookmarklet($bookmarkleturl) {
|
||||
<input type="text" id="add_url" value="" placeholder="<?php p($l->t('Address')); ?>"/>
|
||||
<button id="bookmark_add_submit" title="Add" class="icon-add"></button>
|
||||
</form>
|
||||
</li>
|
||||
<?php foreach ($_['navigationEntries'] as $entry) { ?>
|
||||
<li>
|
||||
<a class="<?php p($entry['class']) ?>" href=""><?php p($entry['name']); ?></a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<li>
|
||||
<p id="tag_filter" class="open">
|
||||
<input type="text" value="<?php if(isset($_['req_tag'])) p($_['req_tag']); else ""; ?>"/>
|
||||
|
||||
|
||||
</p>
|
||||
<input type="hidden" id="bookmarkFilterTag" value="<?php if(isset($_['req_tag'])) p($_['req_tag']); else ""; ?>" />
|
||||
<label id="tag_select_label"><?php p($l->t('Filterable Tags')); ?></label>
|
||||
</li>
|
||||
<li class="navigationTagTemplate hidden">
|
||||
<a href=""></a>
|
||||
<span class="utils">
|
||||
<span class="count"></span>
|
||||
</span>
|
||||
</li>
|
||||
<li class="tag_list">
|
||||
</li>
|
||||
|
Loading…
x
Reference in New Issue
Block a user