mirror of
https://github.com/JanGross/quicknotes.git
synced 2025-11-30 23:37:16 +01:00
Use display name of users to share dialog and notes. See issue #49
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* @copyright 2019-2020 Matias De lellis <mati86dl@gmail.com>
|
||||
* @copyright 2019-2022 Matias De lellis <mati86dl@gmail.com>
|
||||
*
|
||||
* @author 2019 Matias De lellis <mati86dl@gmail.com>
|
||||
*
|
||||
@@ -159,7 +159,7 @@ const QnDialogs = {
|
||||
var data = [];
|
||||
availableUsers.forEach(function (item, index) {
|
||||
// Select2 expect id, text.
|
||||
data.push({id: item, text: item});
|
||||
data.push({id: item[0], text: item[1]});
|
||||
});
|
||||
return data;
|
||||
},
|
||||
@@ -168,7 +168,7 @@ const QnDialogs = {
|
||||
}
|
||||
});
|
||||
|
||||
input.val(selectedUsers.map(function (value) { return value.shared_user }));
|
||||
input.val(selectedUsers.map(function (value) { return value.id }));
|
||||
input.trigger("change");
|
||||
|
||||
$('.select2-input').on("keyup", function (event) {
|
||||
@@ -208,7 +208,9 @@ const QnDialogs = {
|
||||
// Quicknotes shares expect id, shared_user
|
||||
newUsers = input.select2("data");
|
||||
newUsers.forEach(function (item) {
|
||||
item['shared_user'] = item.text;
|
||||
item['shared_user'] = item.id;
|
||||
item['display_name'] = item.text;
|
||||
|
||||
users.push(item);
|
||||
});
|
||||
callback(true, users);
|
||||
|
||||
14
js/script.js
14
js/script.js
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* @copyright 2016-2020 Matias De lellis <mati86dl@gmail.com>
|
||||
* @copyright 2016-2022 Matias De lellis <mati86dl@gmail.com>
|
||||
*
|
||||
* @author 2016 Matias De lellis <mati86dl@gmail.com>
|
||||
*
|
||||
@@ -169,10 +169,10 @@ Notes.prototype = {
|
||||
}).done(function (shares) {
|
||||
var users = [];
|
||||
$.each(shares.ocs.data.exact.users, function(index, user) {
|
||||
users.push(user.value.shareWith);
|
||||
users.push([user.value.shareWith, user.label]);
|
||||
});
|
||||
$.each(shares.ocs.data.users, function(index, user) {
|
||||
users.push(user.value.shareWith);
|
||||
users.push([user.value.shareWith, user.label]);
|
||||
});
|
||||
self._usersSharing = users;
|
||||
}).fail(function () {
|
||||
@@ -233,6 +233,7 @@ View.prototype = {
|
||||
tags: this._editableTags(),
|
||||
sharedWith: this._editableShares()
|
||||
};
|
||||
|
||||
var self = this;
|
||||
this._notes.update(fakeNote).done(function (note) {
|
||||
// Create an new note and replace in grid.
|
||||
@@ -530,6 +531,12 @@ View.prototype = {
|
||||
$('#modal-note-div #tag-button').trigger( "click");
|
||||
});
|
||||
|
||||
// Handle shares on modal
|
||||
$('#modal-note-div').on("click", ".slim-share", function (event) {
|
||||
event.stopPropagation();
|
||||
$('#modal-note-div #share-button').trigger( "click");
|
||||
});
|
||||
|
||||
// handle tags button.
|
||||
$('#modal-note-div').on("click", "#share-button", function (event) {
|
||||
event.stopPropagation();
|
||||
@@ -545,6 +552,7 @@ View.prototype = {
|
||||
);
|
||||
});
|
||||
|
||||
// handle color button.
|
||||
$('#modal-note-div').on("click", "#color-button", function (event) {
|
||||
event.stopPropagation();
|
||||
self._colorPick.toggle();
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
</div>
|
||||
<div class='note-shares'>
|
||||
{{#each sharedWith}}
|
||||
<div class="icon-user slim-share" share-id="{{ shared_user }}" title="Shared with {{ shared_user }}">{{{ shared_user }}}</div>
|
||||
<div class="icon-user slim-share" share-id="{{ shared_user }}" title="Shared with {{ display_name }}">{{{ display_name }}}</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
<div class='note-tags'>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<div class='note-body'>
|
||||
<div>
|
||||
{{#if sharedBy}}
|
||||
<div class="icon-header-note icon-share" title="{{tSB sharedBy.0.user_id}}"></div>
|
||||
<div class="icon-header-note icon-share" title="{{tSB sharedBy.0.display_name}}"></div>
|
||||
<div class="icon-header-note icon-delete hide-header-icon icon-delete-note" title="{{t "quicknotes" "Leave this shared note"}}"></div>
|
||||
{{else}}
|
||||
{{#if isPinned}}
|
||||
@@ -34,7 +34,7 @@
|
||||
</div>
|
||||
<div class='note-shares'>
|
||||
{{#each sharedWith}}
|
||||
<div class="icon-user slim-share" share-id="{{ shared_user }}" title="{{tSW shared_user}}">{{{ shared_user }}}</div>
|
||||
<div class="icon-user slim-share" share-id="{{ shared_user }}" title="{{tSW display_name}}">{{{ display_name }}}</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
<div class='note-tags'>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div class='note-shares'>
|
||||
{{#each sharedWith}}
|
||||
<div class="icon-user slim-share" share-id="{{ shared_user }}" title="{{tSW shared_user}}">{{{ shared_user }}}</div>
|
||||
<div class="icon-user slim-share" share-id="{{ shared_user }}" title="{{tSW display_name}}">{{{ display_name }}}</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
Reference in New Issue
Block a user