mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Standardized vue component http access and fixed some small bugs
This commit is contained in:
parent
98d9d8d71b
commit
4db692309b
@ -61,9 +61,7 @@ class PageController extends Controller
|
|||||||
{
|
{
|
||||||
$this->checkPermission('page-create');
|
$this->checkPermission('page-create');
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'name' => 'required|string|max:255',
|
'name' => 'required|string|max:255'
|
||||||
'html' => 'required|string',
|
|
||||||
'parent' => 'integer|exists:pages,id'
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$input = $request->all();
|
$input = $request->all();
|
||||||
@ -121,6 +119,9 @@ class PageController extends Controller
|
|||||||
public function update(Request $request, $bookSlug, $pageSlug)
|
public function update(Request $request, $bookSlug, $pageSlug)
|
||||||
{
|
{
|
||||||
$this->checkPermission('page-update');
|
$this->checkPermission('page-update');
|
||||||
|
$this->validate($request, [
|
||||||
|
'name' => 'required|string|max:255'
|
||||||
|
]);
|
||||||
$book = $this->bookRepo->getBySlug($bookSlug);
|
$book = $this->bookRepo->getBySlug($bookSlug);
|
||||||
$page = $this->pageRepo->getBySlug($pageSlug, $book->id);
|
$page = $this->pageRepo->getBySlug($pageSlug, $book->id);
|
||||||
$this->pageRepo->updatePage($page, $book->id, $request->all());
|
$this->pageRepo->updatePage($page, $book->id, $request->all());
|
||||||
|
@ -120,6 +120,7 @@ class PageRepo
|
|||||||
*/
|
*/
|
||||||
protected function formatHtml($htmlText)
|
protected function formatHtml($htmlText)
|
||||||
{
|
{
|
||||||
|
if($htmlText == '') return $htmlText;
|
||||||
libxml_use_internal_errors(true);
|
libxml_use_internal_errors(true);
|
||||||
$doc = new \DOMDocument();
|
$doc = new \DOMDocument();
|
||||||
$doc->loadHTML($htmlText);
|
$doc->loadHTML($htmlText);
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
"bootstrap-sass": "^3.0.0",
|
"bootstrap-sass": "^3.0.0",
|
||||||
"dropzone": "^4.0.1",
|
"dropzone": "^4.0.1",
|
||||||
"laravel-elixir": "^3.4.0",
|
"laravel-elixir": "^3.4.0",
|
||||||
"vue": "^1.0.4",
|
"vue": "^1.0.13",
|
||||||
"vue-hot-reload-api": "^1.2.1",
|
"vue-hot-reload-api": "^1.2.1",
|
||||||
"vue-resource": "^0.1.16",
|
"vue-resource": "^0.5.1",
|
||||||
"vueify": "^5.0.1",
|
"vueify": "^5.0.1",
|
||||||
"vueify-insert-css": "^1.0.0",
|
"vueify-insert-css": "^1.0.0",
|
||||||
"zeroclipboard": "^2.2.0"
|
"zeroclipboard": "^2.2.0"
|
||||||
|
@ -94,11 +94,11 @@
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
fetchData: function () {
|
fetchData: function () {
|
||||||
var _this = this;
|
var url = '/images/' + this.imageType + '/all/' + this.page;
|
||||||
this.$http.get('/images/' + _this.imageType + '/all/' + _this.page, function (data) {
|
this.$http.get(url).then((response) => {
|
||||||
_this.images = _this.images.concat(data.images);
|
this.images = this.images.concat(response.data.images);
|
||||||
_this.hasMore = data.hasMore;
|
this.hasMore = response.data.hasMore;
|
||||||
_this.page++;
|
this.page++;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -108,16 +108,16 @@
|
|||||||
url: '/images/' + _this.imageType + '/upload',
|
url: '/images/' + _this.imageType + '/upload',
|
||||||
init: function () {
|
init: function () {
|
||||||
var dz = this;
|
var dz = this;
|
||||||
this.on("sending", function (file, xhr, data) {
|
dz.on("sending", function (file, xhr, data) {
|
||||||
data.append("_token", _this.token);
|
data.append("_token", _this.token);
|
||||||
});
|
});
|
||||||
this.on("success", function (file, data) {
|
dz.on("success", function (file, data) {
|
||||||
_this.images.unshift(data);
|
_this.images.unshift(data);
|
||||||
$(file.previewElement).fadeOut(400, function () {
|
$(file.previewElement).fadeOut(400, function () {
|
||||||
dz.removeFile(file);
|
dz.removeFile(file);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
this.on('error', function (file, errorMessage, xhr) {
|
dz.on('error', function (file, errorMessage, xhr) {
|
||||||
if (errorMessage.file) {
|
if (errorMessage.file) {
|
||||||
$(file.previewElement).find('[data-dz-errormessage]').text(errorMessage.file[0]);
|
$(file.previewElement).find('[data-dz-errormessage]').text(errorMessage.file[0]);
|
||||||
}
|
}
|
||||||
@ -149,9 +149,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
selectButtonClick: function () {
|
selectButtonClick: function () {
|
||||||
if (this.callback) {
|
if (this.callback) this.returnCallback(this.selectedImage);
|
||||||
this.returnCallback(this.selectedImage);
|
|
||||||
}
|
|
||||||
this.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -177,17 +175,14 @@
|
|||||||
|
|
||||||
saveImageDetails: function (e) {
|
saveImageDetails: function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var _this = this;
|
this.selectedImage._token = this.token;
|
||||||
_this.selectedImage._token = _this.token;
|
var form = $(this.$els.imageForm);
|
||||||
var form = $(_this.$els.imageForm);
|
var url = '/images/update/' + this.selectedImage.id;
|
||||||
$.ajax('/images/update/' + _this.selectedImage.id, {
|
this.$http.put(url, this.selectedImage).then((response) => {
|
||||||
method: 'PUT',
|
|
||||||
data: _this.selectedImage
|
|
||||||
}).done(function () {
|
|
||||||
form.showSuccess('Image name updated');
|
form.showSuccess('Image name updated');
|
||||||
}).fail(function (jqXHR) {
|
}, (response) => {
|
||||||
form.showFailure(jqXHR.responseJSON);
|
form.showFailure(response.data);
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteImage: function (e) {
|
deleteImage: function (e) {
|
||||||
@ -195,17 +190,15 @@
|
|||||||
var _this = this;
|
var _this = this;
|
||||||
_this.deleteForm.force = _this.dependantPages !== false;
|
_this.deleteForm.force = _this.dependantPages !== false;
|
||||||
_this.deleteForm._token = _this.token;
|
_this.deleteForm._token = _this.token;
|
||||||
$.ajax('/images/' + _this.selectedImage.id, {
|
var url = '/images/' + _this.selectedImage.id;
|
||||||
method: 'DELETE',
|
this.$http.delete(url, this.deleteForm).then((response) => {
|
||||||
data: _this.deleteForm
|
this.images.splice(this.images.indexOf(this.selectedImage), 1);
|
||||||
}).done(function () {
|
this.selectedImage = false;
|
||||||
_this.images.splice(_this.images.indexOf(_this.selectedImage), 1);
|
$(this.$els.imageTitle).showSuccess('Image Deleted');
|
||||||
_this.selectedImage = false;
|
}, (response) => {
|
||||||
$(_this.$els.imageTitle).showSuccess('Image Deleted');
|
|
||||||
}).fail(function (jqXHR, textStatus) {
|
|
||||||
// Pages failure
|
// Pages failure
|
||||||
if (jqXHR.status === 400) {
|
if (response.status === 400) {
|
||||||
_this.dependantPages = jqXHR.responseJSON;
|
_this.dependantPages = response.data;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -65,9 +65,8 @@
|
|||||||
this.value = this.currentId === 'false' ? imageUrl : imageModel.id;
|
this.value = this.currentId === 'false' ? imageUrl : imageModel.id;
|
||||||
},
|
},
|
||||||
showImageManager: function(e) {
|
showImageManager: function(e) {
|
||||||
var _this = this;
|
ImageManager.show((image) => {
|
||||||
ImageManager.show(function(image) {
|
this.updateImageFromModel(image);
|
||||||
_this.updateImageFromModel(image);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
reset: function() {
|
reset: function() {
|
||||||
@ -75,20 +74,20 @@
|
|||||||
},
|
},
|
||||||
remove: function() {
|
remove: function() {
|
||||||
this.image = 'none';
|
this.image = 'none';
|
||||||
|
this.value = 'none';
|
||||||
},
|
},
|
||||||
updateImageFromModel: function(model) {
|
updateImageFromModel: function(model) {
|
||||||
var _this = this;
|
var isResized = this.resizeWidth && this.resizeHeight;
|
||||||
var isResized = _this.resizeWidth && _this.resizeHeight;
|
|
||||||
|
|
||||||
if (!isResized) {
|
if (!isResized) {
|
||||||
_this.setCurrentValue(model, model.url);
|
this.setCurrentValue(model, model.url);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var cropped = _this.resizeCrop ? 'true' : 'false';
|
var cropped = this.resizeCrop ? 'true' : 'false';
|
||||||
var requestString = '/images/thumb/' + model.id + '/' + _this.resizeWidth + '/' + _this.resizeHeight + '/' + cropped;
|
var requestString = '/images/thumb/' + model.id + '/' + this.resizeWidth + '/' + this.resizeHeight + '/' + cropped;
|
||||||
_this.$http.get(requestString, function(data) {
|
this.$http.get(requestString).then((response) => {
|
||||||
_this.setCurrentValue(model, data.url);
|
this.setCurrentValue(model, response.data.url);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user