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