mirror of
https://github.com/JanGross/quicknotes.git
synced 2025-12-01 07:37:18 +01:00
added toggle to share button to allow unsharing
This commit is contained in:
@@ -8,7 +8,7 @@ return [
|
|||||||
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
|
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
|
||||||
['name' => 'note_api#preflighted_cors', 'url' => '/api/0.1/{path}',
|
['name' => 'note_api#preflighted_cors', 'url' => '/api/0.1/{path}',
|
||||||
'verb' => 'OPTIONS', 'requirements' => ['path' => '.+']],
|
'verb' => 'OPTIONS', 'requirements' => ['path' => '.+']],
|
||||||
['name' => 'note#get_user_groups_and_users', 'url' => '/api/0.1/getusergroups', 'verb' => 'GET'],
|
['name' => 'note#get_user_groups_and_users_with_share', 'url' => '/api/0.1/getusergroups', 'verb' => 'POST'],
|
||||||
['name' => 'note#add_group_share', 'url' => '/api/0.1/groups/addshare', 'verb' => 'POST'],
|
['name' => 'note#add_group_share', 'url' => '/api/0.1/groups/addshare', 'verb' => 'POST'],
|
||||||
['name' => 'note#remove_group_share', 'url' => '/api/0.1/groups/removeshare', 'verb' => 'POST'],
|
['name' => 'note#remove_group_share', 'url' => '/api/0.1/groups/removeshare', 'verb' => 'POST'],
|
||||||
['name' => 'note#add_user_share', 'url' => '/api/0.1/users/addshare', 'verb' => 'POST'],
|
['name' => 'note#add_user_share', 'url' => '/api/0.1/users/addshare', 'verb' => 'POST'],
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ class NoteController extends Controller {
|
|||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*/
|
*/
|
||||||
public function getUserGroupsAndUsers() {
|
public function getUserGroupsAndUsersWithShare($noteId) {
|
||||||
$userMgr = \OC::$server->getUserManager();
|
$userMgr = \OC::$server->getUserManager();
|
||||||
$grpMgr = \OC::$server->getGroupManager();
|
$grpMgr = \OC::$server->getGroupManager();
|
||||||
$users = array();
|
$users = array();
|
||||||
@@ -224,11 +224,30 @@ class NoteController extends Controller {
|
|||||||
$groups[] = $g->getGID();
|
$groups[] = $g->getGID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$users = array_unique($users);
|
$users = array_unique($users);
|
||||||
if(($i = array_search($this->userId, $users)) !== false) {
|
if(($i = array_search($this->userId, $users)) !== false) {
|
||||||
unset($users[$i]);
|
unset($users[$i]);
|
||||||
}
|
}
|
||||||
$params = array('groups' => $groups, 'users' => $users);
|
$pos_users = array();
|
||||||
|
$pos_groups = array();
|
||||||
|
$shares = $this->notesharemapper->getSharesForNote($noteId);
|
||||||
|
foreach($shares as $s) {
|
||||||
|
$shareType = $s->getSharedUser();
|
||||||
|
if(strlen($shareType) != 0) {
|
||||||
|
if(($i = array_search($shareType, $users)) !== false) {
|
||||||
|
unset($users[$i]);
|
||||||
|
$pos_users[] = $shareType;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$shareType = $s->getSharedGroup();
|
||||||
|
if(($i = array_search($shareType, $groups)) !== false) {
|
||||||
|
unset($groups[$i]);
|
||||||
|
$pos_groups[] = $shareType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$params = array('groups' => $groups, 'users' => $users, 'posGroups' => $pos_groups, 'posUsers' => $pos_users);
|
||||||
return new JSONResponse($params);
|
return new JSONResponse($params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ div[data-placeholder]:not([data-placeholder=""]):empty::before {
|
|||||||
padding-bottom: 5px;
|
padding-bottom: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.selected-share:hover, .unselected-share:hover, .unselected-share span:hover {
|
.selected-share:hover, .unselected-share:hover, .selected-share span:hover, .unselected-share span:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
30
js/script.js
30
js/script.js
@@ -221,13 +221,6 @@ View.prototype = {
|
|||||||
var modalnote = $("#modal-note-div .quicknote");
|
var modalnote = $("#modal-note-div .quicknote");
|
||||||
|
|
||||||
var note = $('.notes-grid [data-id=' + id + ']').parent();
|
var note = $('.notes-grid [data-id=' + id + ']').parent();
|
||||||
if($('.notes-grid [data-id=' + id + ']').hasClass('shareowner')) {
|
|
||||||
$('.save-button #unshare-button').show();
|
|
||||||
$('.save-button #share-button').hide();
|
|
||||||
} else {
|
|
||||||
$('.save-button #unshare-button').hide();
|
|
||||||
$('.save-button #share-button').show();
|
|
||||||
}
|
|
||||||
|
|
||||||
var title = note.find("#title-editable").html();
|
var title = note.find("#title-editable").html();
|
||||||
var content = note.find("#content-editable").html();
|
var content = note.find("#content-editable").html();
|
||||||
@@ -404,10 +397,16 @@ View.prototype = {
|
|||||||
|
|
||||||
// handle share editing notes.
|
// handle share editing notes.
|
||||||
$('#modal-note-div #share-button').click(function (event) {
|
$('#modal-note-div #share-button').click(function (event) {
|
||||||
$.get(OC.generateUrl('/apps/quicknotes/api/0.1/getusergroups'), function(data) {
|
var id = $('.note-active').data('id');
|
||||||
|
var formData = {
|
||||||
|
noteId: id
|
||||||
|
}
|
||||||
|
$.post(OC.generateUrl('/apps/quicknotes/api/0.1/getusergroups'), formData, function(data) {
|
||||||
var shareOptions = $('#note-share-options');
|
var shareOptions = $('#note-share-options');
|
||||||
var groups = data.groups;
|
var groups = data.groups;
|
||||||
var users = data.users;
|
var users = data.users;
|
||||||
|
var pos_groups = data.posGroups;
|
||||||
|
var pos_users = data.posUsers;
|
||||||
var neg = $('#share-neg');
|
var neg = $('#share-neg');
|
||||||
var pos = $('#share-pos');
|
var pos = $('#share-pos');
|
||||||
var sear = $('#share-search');
|
var sear = $('#share-search');
|
||||||
@@ -428,6 +427,21 @@ View.prototype = {
|
|||||||
$(li).hide();
|
$(li).hide();
|
||||||
neg[0].appendChild(li);
|
neg[0].appendChild(li);
|
||||||
}
|
}
|
||||||
|
for(var i=0; i<pos_groups.length; i++) {
|
||||||
|
var li = document.createElement('li');
|
||||||
|
li.appendChild(document.createTextNode(pos_groups[i]));
|
||||||
|
var sp = document.createElement('span');
|
||||||
|
sp.appendChild(document.createTextNode('(group)'));
|
||||||
|
li.className = "selected-share";
|
||||||
|
li.appendChild(sp);
|
||||||
|
pos[0].appendChild(li);
|
||||||
|
}
|
||||||
|
for(var i=0; i<pos_users.length; i++) {
|
||||||
|
var li = document.createElement('li');
|
||||||
|
li.appendChild(document.createTextNode(pos_users[i]));
|
||||||
|
li.className = "selected-share";
|
||||||
|
pos[0].appendChild(li);
|
||||||
|
}
|
||||||
|
|
||||||
$('.unselected-share').click(moveToSelectedShare);
|
$('.unselected-share').click(moveToSelectedShare);
|
||||||
$('.selected-share').click(moveToUnselectedShare);
|
$('.selected-share').click(moveToUnselectedShare);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
<div contenteditable="true" id='content-editable' class='note-content' data-placeholder="No content"></div>
|
<div contenteditable="true" id='content-editable' class='note-content' data-placeholder="No content"></div>
|
||||||
<div class="note-options">
|
<div class="note-options">
|
||||||
<div class="save-button">
|
<div class="save-button">
|
||||||
<button id='unshare-button'><?php p($l->t('Unshare'));?></button>
|
|
||||||
<button id='share-button'><?php p($l->t('Share'));?></button>
|
<button id='share-button'><?php p($l->t('Share'));?></button>
|
||||||
<button id='cancel-button'><?php p($l->t('Cancel')); ?></button>
|
<button id='cancel-button'><?php p($l->t('Cancel')); ?></button>
|
||||||
<button id='save-button'><?php p($l->t('Save')); ?></button>
|
<button id='save-button'><?php p($l->t('Save')); ?></button>
|
||||||
|
|||||||
Reference in New Issue
Block a user