Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Зуев Егор
/
wiki.dev
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Authored by
Dan Brown
2015-12-28 15:58:13 +0000
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Commit
4db692309b5e1de8eec0e4af8366e388fefd8449
4db69230
1 parent
98d9d8d7
Standardized vue component http access and fixed some small bugs
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
46 deletions
app/Http/Controllers/PageController.php
app/Repos/PageRepo.php
package.json
resources/assets/js/components/image-manager.vue
resources/assets/js/components/image-picker.vue
app/Http/Controllers/PageController.php
View file @
4db6923
...
...
@@ -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
());
...
...
app/Repos/PageRepo.php
View file @
4db6923
...
...
@@ -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
);
...
...
package.json
View file @
4db6923
...
...
@@ -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"
...
...
resources/assets/js/components/image-manager.vue
View file @
4db6923
...
...
@@ -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
;
}
});
}
...
...
resources/assets/js/components/image-picker.vue
View file @
4db6923
...
...
@@ -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);
});
}
}
...
...
Please
register
or
sign in
to post a comment