mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-01 15:09:51 +00:00
Fixed attachment error handling, Allowed all link types
Related to #812
This commit is contained in:
parent
019b8196ad
commit
a1ecdcacba
3 changed files with 12 additions and 6 deletions
app
resources/assets/js/vues
|
@ -31,6 +31,9 @@ class Attachment extends Ownable
|
||||||
*/
|
*/
|
||||||
public function getUrl()
|
public function getUrl()
|
||||||
{
|
{
|
||||||
|
if ($this->external && strpos($this->path, 'http') !== 0) {
|
||||||
|
return $this->path;
|
||||||
|
}
|
||||||
return baseUrl('/attachments/' . $this->id);
|
return baseUrl('/attachments/' . $this->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ class AttachmentController extends Controller
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'uploaded_to' => 'required|integer|exists:pages,id',
|
'uploaded_to' => 'required|integer|exists:pages,id',
|
||||||
'name' => 'required|string|min:1|max:255',
|
'name' => 'required|string|min:1|max:255',
|
||||||
'link' => 'url|min:1|max:255'
|
'link' => 'string|min:1|max:255'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$pageId = $request->get('uploaded_to');
|
$pageId = $request->get('uploaded_to');
|
||||||
|
@ -131,7 +131,7 @@ class AttachmentController extends Controller
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'uploaded_to' => 'required|integer|exists:pages,id',
|
'uploaded_to' => 'required|integer|exists:pages,id',
|
||||||
'name' => 'required|string|min:1|max:255',
|
'name' => 'required|string|min:1|max:255',
|
||||||
'link' => 'required|url|min:1|max:255'
|
'link' => 'required|string|min:1|max:255'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$pageId = $request->get('uploaded_to');
|
$pageId = $request->get('uploaded_to');
|
||||||
|
@ -184,6 +184,7 @@ class AttachmentController extends Controller
|
||||||
* @param $attachmentId
|
* @param $attachmentId
|
||||||
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Symfony\Component\HttpFoundation\Response
|
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Symfony\Component\HttpFoundation\Response
|
||||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||||
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
public function get($attachmentId)
|
public function get($attachmentId)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,6 +31,9 @@ let methods = {
|
||||||
},
|
},
|
||||||
|
|
||||||
getFileUrl(file) {
|
getFileUrl(file) {
|
||||||
|
if (file.external && file.path.indexOf('http') !== 0) {
|
||||||
|
return file.path;
|
||||||
|
}
|
||||||
return window.baseUrl(`/attachments/${file.id}`);
|
return window.baseUrl(`/attachments/${file.id}`);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -79,10 +82,8 @@ let methods = {
|
||||||
},
|
},
|
||||||
|
|
||||||
checkValidationErrors(groupName, err) {
|
checkValidationErrors(groupName, err) {
|
||||||
console.error(err);
|
if (typeof err.response.data === "undefined" && typeof err.response.data === "undefined") return;
|
||||||
if (typeof err.response.data === "undefined" && typeof err.response.data.validation === "undefined") return;
|
this.errors[groupName] = err.response.data;
|
||||||
this.errors[groupName] = err.response.data.validation;
|
|
||||||
console.log(this.errors[groupName]);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getUploadUrl(file) {
|
getUploadUrl(file) {
|
||||||
|
@ -97,6 +98,7 @@ let methods = {
|
||||||
|
|
||||||
attachNewLink(file) {
|
attachNewLink(file) {
|
||||||
file.uploaded_to = this.pageId;
|
file.uploaded_to = this.pageId;
|
||||||
|
this.errors.link = {};
|
||||||
this.$http.post(window.baseUrl('/attachments/link'), file).then(resp => {
|
this.$http.post(window.baseUrl('/attachments/link'), file).then(resp => {
|
||||||
this.files.push(resp.data);
|
this.files.push(resp.data);
|
||||||
this.file = this.newFile();
|
this.file = this.newFile();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue