mirror of
https://github.com/JanGross/quicknotes.git
synced 2025-12-01 07:37:18 +01:00
Can view attachts in shared notes as long also share the files.
This commit is contained in:
@@ -189,7 +189,7 @@ View.prototype = {
|
|||||||
this._editableColor(note.color);
|
this._editableColor(note.color);
|
||||||
this._editableShares(note.shared_with, note.shared_by);
|
this._editableShares(note.shared_with, note.shared_by);
|
||||||
this._editableTags(note.tags);
|
this._editableTags(note.tags);
|
||||||
this._editableAttachts(note.attachts);
|
this._editableAttachts(note.attachts, !note.is_shared);
|
||||||
|
|
||||||
// Create medium div editor.
|
// Create medium div editor.
|
||||||
this._isEditable(!note.is_shared);
|
this._isEditable(!note.is_shared);
|
||||||
@@ -507,7 +507,7 @@ View.prototype = {
|
|||||||
preview_url: OC.generateUrl('core') + '/preview.png?file=' + encodeURI(datapath) + '&x=512&y=512',
|
preview_url: OC.generateUrl('core') + '/preview.png?file=' + encodeURI(datapath) + '&x=512&y=512',
|
||||||
redirect_url: OC.generateUrl('/apps/files/?dir={dir}&scrollto={scrollto}', {dir: fileInfo.path, scrollto: fileInfo.name})
|
redirect_url: OC.generateUrl('/apps/files/?dir={dir}&scrollto={scrollto}', {dir: fileInfo.path, scrollto: fileInfo.name})
|
||||||
});
|
});
|
||||||
self._editableAttachts(attachts);
|
self._editableAttachts(attachts, true);
|
||||||
}).fail(() => {
|
}).fail(() => {
|
||||||
console.log("ERRORRR");
|
console.log("ERRORRR");
|
||||||
});
|
});
|
||||||
@@ -798,7 +798,7 @@ View.prototype = {
|
|||||||
$("#modal-note-div .note-tags").replaceWith(html);
|
$("#modal-note-div .note-tags").replaceWith(html);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_editableAttachts: function(attachts) {
|
_editableAttachts: function(attachts, can_delete) {
|
||||||
if (attachts === undefined) {
|
if (attachts === undefined) {
|
||||||
return $("#modal-note-div .note-attach").toArray().map(function (value) {
|
return $("#modal-note-div .note-attach").toArray().map(function (value) {
|
||||||
return {
|
return {
|
||||||
@@ -808,7 +808,7 @@ View.prototype = {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
var html = Handlebars.templates['attachts']({ attachts: attachts});
|
var html = Handlebars.templates['attachts']({ attachts: attachts, can_delete: can_delete});
|
||||||
$("#modal-note-div .note-attachts").replaceWith(html);
|
$("#modal-note-div .note-attachts").replaceWith(html);
|
||||||
|
|
||||||
lozad('.attach-preview').observe();
|
lozad('.attach-preview').observe();
|
||||||
|
|||||||
@@ -4,7 +4,9 @@
|
|||||||
<a target="_blank" href="{{redirect_url}}">
|
<a target="_blank" href="{{redirect_url}}">
|
||||||
<div class="attach-preview note-attach" attach-file-id="{{file_id}}" data-background-image="{{preview_url}}"/>
|
<div class="attach-preview note-attach" attach-file-id="{{file_id}}" data-background-image="{{preview_url}}"/>
|
||||||
</a>
|
</a>
|
||||||
<div class="attach-remove icon-delete" title="{{t "quicknotes" "Delete attachment"}}"/>
|
{{#if ../can_delete}}
|
||||||
|
<div class="attach-remove icon-delete" title="{{t "quicknotes" "Delete attachment"}}"/>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
@@ -73,8 +73,7 @@ class AttachMapper extends QBMapper {
|
|||||||
* @param string $userId
|
* @param string $userId
|
||||||
* @param int $noteId
|
* @param int $noteId
|
||||||
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
|
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
|
||||||
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
|
* @return Attach[]
|
||||||
* @return Note[]
|
|
||||||
*/
|
*/
|
||||||
public function findFromNote($userId, $noteId) {
|
public function findFromNote($userId, $noteId) {
|
||||||
$qb = $this->db->getQueryBuilder();
|
$qb = $this->db->getQueryBuilder();
|
||||||
@@ -86,4 +85,5 @@ class AttachMapper extends QBMapper {
|
|||||||
);
|
);
|
||||||
return $this->findEntities($qb);
|
return $this->findEntities($qb);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,13 +57,16 @@ class FileService {
|
|||||||
* @param int $fileId file id to show
|
* @param int $fileId file id to show
|
||||||
* @param int $sideSize side lenght to show
|
* @param int $sideSize side lenght to show
|
||||||
*/
|
*/
|
||||||
public function getPreviewUrl(int $fileId, int $sideSize): string {
|
public function getPreviewUrl(int $fileId, int $sideSize): ?string {
|
||||||
$userFolder = $this->rootFolder->getUserFolder($this->userId);
|
$userFolder = $this->rootFolder->getUserFolder($this->userId);
|
||||||
$node = current($userFolder->getById($fileId));
|
$file = current($userFolder->getById($fileId));
|
||||||
$path = $userFolder->getRelativePath($node->getPath());
|
|
||||||
|
if (!($file instanceof File)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->urlGenerator->linkToRouteAbsolute('core.Preview.getPreview', [
|
return $this->urlGenerator->linkToRouteAbsolute('core.Preview.getPreview', [
|
||||||
'file' => $path,
|
'file' => $userFolder->getRelativePath($file->getPath()),
|
||||||
'x' => $sideSize,
|
'x' => $sideSize,
|
||||||
'y' => $sideSize
|
'y' => $sideSize
|
||||||
]);
|
]);
|
||||||
@@ -78,7 +81,7 @@ class FileService {
|
|||||||
$userFolder = $this->rootFolder->getUserFolder($this->userId);
|
$userFolder = $this->rootFolder->getUserFolder($this->userId);
|
||||||
$file = current($userFolder->getById($fileId));
|
$file = current($userFolder->getById($fileId));
|
||||||
|
|
||||||
if(!($file instanceof File)) {
|
if (!($file instanceof File)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -114,12 +114,23 @@ class NoteService {
|
|||||||
|
|
||||||
// Insert attachts to response.
|
// Insert attachts to response.
|
||||||
foreach ($notes as $note) {
|
foreach ($notes as $note) {
|
||||||
$attachts = $this->attachMapper->findFromNote($userId, $note->getId());
|
$rAttachts = [];
|
||||||
|
$attachts = $this->attachMapper->findFromNote($note->getUserId(), $note->getId());
|
||||||
foreach ($attachts as $attach) {
|
foreach ($attachts as $attach) {
|
||||||
$attach->setPreviewUrl($this->fileService->getPreviewUrl($attach->getFileId(), 512));
|
$previewUrl = $this->fileService->getPreviewUrl($attach->getFileId(), 512);
|
||||||
$attach->setRedirectUrl($this->fileService->getRedirectToFileUrl($attach->getFileId()));
|
if (is_null($previewUrl))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$redirectUrl = $this->fileService->getRedirectToFileUrl($attach->getFileId());
|
||||||
|
if (is_null($redirectUrl))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$attach->setPreviewUrl($previewUrl);
|
||||||
|
$attach->setRedirectUrl($redirectUrl);
|
||||||
|
|
||||||
|
$rAttachts[] = $attach;
|
||||||
}
|
}
|
||||||
$note->setAttachts($attachts);
|
$note->setAttachts($rAttachts);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $notes;
|
return $notes;
|
||||||
|
|||||||
Reference in New Issue
Block a user