diff --git a/js/qn-dialogs.js b/js/qn-dialogs.js index c992f39..e075257 100644 --- a/js/qn-dialogs.js +++ b/js/qn-dialogs.js @@ -168,7 +168,7 @@ const QnDialogs = { } }); - input.val(selectedUsers.map(function (value) { return value.name })); + input.val(selectedUsers.map(function (value) { return value.shared_user })); input.trigger("change"); $('.select2-input').on("keyup", function (event) { diff --git a/js/script.js b/js/script.js index cf83664..2b1f9ed 100644 --- a/js/script.js +++ b/js/script.js @@ -206,7 +206,7 @@ View.prototype = { this._editableContent(note.content); this._editablePinned(note.ispinned); this._editableColor(note.color); - this._editableShares(note.shared_with, note.shared_by); + this._editableShares(note.shared_with); this._editableTags(note.tags); this._editableAttachts(note.attachts, !note.is_shared); @@ -226,7 +226,7 @@ View.prototype = { color: this._editableColor(), pinned: this._editablePinned(), tags: this._editableTags(), - shares: this._editableShares() + shared_with: this._editableShares() }; var self = this; this._notes.update(fakeNote).done(function (note) { @@ -514,7 +514,7 @@ View.prototype = { self._editableShares(), function(result, newShares) { if (result === true) { - self._editableShares(newShares, []); + self._editableShares(newShares); } } ); @@ -842,16 +842,16 @@ View.prototype = { }); } }, - _editableShares: function(shared_with, shared_by) { + _editableShares: function(shared_with) { if (shared_with === undefined) { return $("#modal-note-div .slim-share").toArray().map(function (value) { return { id: value.getAttribute('share-id'), - name: value.textContent.trim() + shared_user: value.textContent.trim() }; }); } else { - var html = Handlebars.templates['shares']({ shared_by: shared_by, shared_with: shared_with}); + var html = Handlebars.templates['shares']({shared_with: shared_with}); $("#modal-note-div .note-shares").replaceWith(html); } }, diff --git a/lib/Controller/NoteController.php b/lib/Controller/NoteController.php index 623e96a..3581ecf 100644 --- a/lib/Controller/NoteController.php +++ b/lib/Controller/NoteController.php @@ -111,11 +111,11 @@ class NoteController extends Controller { * @param array $attachts * @param bool $pinned * @param array $tags - * @param array $shares + * @param array $shared_with * @param string $color */ - public function update(int $id, string $title, string $content, array $attachts, bool $pinned, array $tags, array $shares, string $color = "#F7EB96"): JSONResponse { - $note = $this->noteService->update($this->userId, $id, $title, $content, $attachts, $pinned, $tags, $shares, $color); + public function update(int $id, string $title, string $content, array $attachts, bool $pinned, array $tags, array $shared_with, string $color = "#F7EB96"): JSONResponse { + $note = $this->noteService->update($this->userId, $id, $title, $content, $attachts, $pinned, $tags, $shared_with, $color); if (is_null($note)) { return new JSONResponse([], Http::STATUS_NOT_FOUND); } diff --git a/lib/Service/NoteService.php b/lib/Service/NoteService.php index f5c6def..bd8c08c 100644 --- a/lib/Service/NoteService.php +++ b/lib/Service/NoteService.php @@ -260,7 +260,7 @@ class NoteService { foreach ($dbShares as $dbShare) { $delete = true; foreach ($shares as $share) { - if ($dbShare->getSharedUser() === $share['name']) { + if ($dbShare->getSharedUser() === $share['shared_user']) { $delete = false; break; } @@ -272,10 +272,10 @@ class NoteService { // Add new shares foreach ($shares as $share) { - if (!$this->noteShareMapper->existsByNoteAndUser($id, $share['name'])) { + if (!$this->noteShareMapper->existsByNoteAndUser($id, $share['shared_user'])) { $hShare = new NoteShare(); $hShare->setNoteId($id); - $hShare->setSharedUser($share['name']); + $hShare->setSharedUser($share['shared_user']); $this->noteShareMapper->insert($hShare); } }