mirror of
https://github.com/owncloud/bookmarks.git
synced 2025-02-02 02:52:10 +01:00
Merge pull request #173 from owncloud/bookmarklet-tags-and-overwrite
[bookmarklet] Reintroduce tags and fix editing existing entries
This commit is contained in:
commit
d5e896e6a4
@ -48,11 +48,19 @@ class WebViewController extends Controller {
|
|||||||
public function bookmarklet($url = "", $title = "") {
|
public function bookmarklet($url = "", $title = "") {
|
||||||
$bookmarkExists = Bookmarks::bookmarkExists($url, $this->userId, $this->db);
|
$bookmarkExists = Bookmarks::bookmarkExists($url, $this->userId, $this->db);
|
||||||
$description = "";
|
$description = "";
|
||||||
if ($bookmarkExists != false){
|
$tags = [];
|
||||||
|
if ($bookmarkExists !== false){
|
||||||
$bookmark = Bookmarks::findUniqueBookmark($bookmarkExists, $this->userId, $this->db);
|
$bookmark = Bookmarks::findUniqueBookmark($bookmarkExists, $this->userId, $this->db);
|
||||||
$description = $bookmark['description'];
|
$description = $bookmark['description'];
|
||||||
|
$tags = $bookmark['tags'];
|
||||||
}
|
}
|
||||||
$params = array('url' => $url, 'title' => $title, 'description' => $description, 'bookmarkExists' => $bookmarkExists);
|
$params = array(
|
||||||
|
'url' => $url,
|
||||||
|
'title' => $title,
|
||||||
|
'description' => $description,
|
||||||
|
'bookmarkExists'=> $bookmarkExists,
|
||||||
|
'tags' => $tags
|
||||||
|
);
|
||||||
return new TemplateResponse('bookmarks', 'addBookmarklet', $params); // templates/main.php
|
return new TemplateResponse('bookmarks', 'addBookmarklet', $params); // templates/main.php
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,14 +22,28 @@ function updateLoadingAnimation() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function () {
|
$(document).ready(function () {
|
||||||
$(".submit").click(function () {
|
$(".submit").click(function () {
|
||||||
increaseAjaxCallCount();
|
increaseAjaxCallCount();
|
||||||
|
|
||||||
|
var endpoint = 'bookmark';
|
||||||
|
var method = 'POST';
|
||||||
|
var id = '';
|
||||||
|
if($('#bookmarkID').length > 0) {
|
||||||
|
endpoint += '/'+ $('#bookmarkID').val();
|
||||||
|
method = 'PUT';
|
||||||
|
id = '&record_id=' + $('#bookmarkID').val();
|
||||||
|
}
|
||||||
|
|
||||||
|
var tags = '';
|
||||||
|
$('.tagit-choice .tagit-label').each(function() {
|
||||||
|
tags += '&item[tags][]='+$(this).text();
|
||||||
|
});
|
||||||
var dataString = 'url=' + $("input#url").val() + '&description=' +
|
var dataString = 'url=' + $("input#url").val() + '&description=' +
|
||||||
$("textarea#description").val() + '&title=' + $("input#title").val();
|
$("textarea#description").val() + '&title=' + $("input#title").val() + tags + id;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: method,
|
||||||
url: "bookmark",
|
url: endpoint,
|
||||||
data: dataString,
|
data: dataString,
|
||||||
complete: function () {
|
complete: function () {
|
||||||
decreaseAjaxCallCount();
|
decreaseAjaxCallCount();
|
||||||
@ -48,6 +62,14 @@ $(function () {
|
|||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$.get('tag', function (data) {
|
||||||
|
$('.tags').tagit({
|
||||||
|
allowSpaces: true,
|
||||||
|
availableTags: data,
|
||||||
|
placeholderText: t('bookmark', 'Tags')
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function closeWindow() {
|
function closeWindow() {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
OCP\Util::addscript('bookmarks', '3rdparty/tag-it');
|
||||||
OCP\Util::addscript('bookmarks', 'bookmarklet');
|
OCP\Util::addscript('bookmarks', 'bookmarklet');
|
||||||
OCP\Util::addStyle('bookmarks', 'bookmarks');
|
OCP\Util::addStyle('bookmarks', 'bookmarks');
|
||||||
|
OCP\Util::addStyle('bookmarks', '3rdparty/jquery.tagit');
|
||||||
|
|
||||||
$bookmarkExists = $_['bookmarkExists'];
|
$bookmarkExists = $_['bookmarkExists'];
|
||||||
?>
|
?>
|
||||||
@ -12,7 +14,7 @@ $bookmarkExists = $_['bookmarkExists'];
|
|||||||
<span style="display: inline; float: right"><div id="add_form_loading" style="margin: 3px;"><img src="<?php print_unescaped(OCP\image_path("bookmarks", "loading.gif")); ?>"> </div></span>
|
<span style="display: inline; float: right"><div id="add_form_loading" style="margin: 3px;"><img src="<?php print_unescaped(OCP\image_path("bookmarks", "loading.gif")); ?>"> </div></span>
|
||||||
|
|
||||||
<div style="color: red; clear: both; visibility: <?php
|
<div style="color: red; clear: both; visibility: <?php
|
||||||
if ($bookmarkExists == false) {
|
if ($bookmarkExists === false) {
|
||||||
print_unescaped('hidden');
|
print_unescaped('hidden');
|
||||||
}
|
}
|
||||||
?>">
|
?>">
|
||||||
@ -24,6 +26,9 @@ $bookmarkExists = $_['bookmarkExists'];
|
|||||||
<fieldset class="bm_desc">
|
<fieldset class="bm_desc">
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
|
<?php if($bookmarkExists !== false) { ?>
|
||||||
|
<input id="bookmarkID" type="hidden" class="hidden" value="<?php p($bookmarkExists); ?>" />
|
||||||
|
<?php } ?>
|
||||||
<input id="title" type="text" name="title" class="title" value="<?php p($_['title']); ?>"
|
<input id="title" type="text" name="title" class="title" value="<?php p($_['title']); ?>"
|
||||||
placeholder="<?php p($l->t('The title of the page')); ?>" />
|
placeholder="<?php p($l->t('The title of the page')); ?>" />
|
||||||
</li>
|
</li>
|
||||||
@ -34,10 +39,10 @@ $bookmarkExists = $_['bookmarkExists'];
|
|||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<ul class="tags" >
|
<ul id="tags" class="tags" >
|
||||||
<?php foreach ($_['bookmark']['tags'] as $tag): ?>
|
<?php foreach ($_['tags'] as $tag): ?>
|
||||||
<li><?php p($tag); ?></li>
|
<li><?php p($tag); ?></li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user