|
|
|
@ -35024,9 +35024,8 @@ function () {
|
|
|
|
|
_createClass(PostActions, [{
|
|
|
|
|
key: "update",
|
|
|
|
|
value: function update(id, data, files, lastKey) {
|
|
|
|
|
var _this = this;
|
|
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
var newID = null;
|
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
|
var txt = document.createElement("textarea");
|
|
|
|
|
txt.innerHTML = document.getElementById('edit-post-text').innerHTML;
|
|
|
|
@ -35063,13 +35062,13 @@ function () {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data.feature = "/content/blog-images/" + _this.dateUtils.getDate('year', new Date()) + "/" + _this.dateUtils.getDate('month', new Date()) + "/" + file.name;
|
|
|
|
|
data.feature = "/content/blog-images/" + self.dateUtils.getDate('year', new Date()) + "/" + self.dateUtils.getDate('month', new Date()) + "/" + file.name;
|
|
|
|
|
}
|
|
|
|
|
} else {//data.feature = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (id == null) {
|
|
|
|
|
_this.db.postList.put({
|
|
|
|
|
self.db.postList.put({
|
|
|
|
|
id: lastKey + 1,
|
|
|
|
|
post: {
|
|
|
|
|
uuid: uuidv4(),
|
|
|
|
@ -35086,46 +35085,51 @@ function () {
|
|
|
|
|
author: "user"
|
|
|
|
|
}
|
|
|
|
|
}).then(function (fresh) {
|
|
|
|
|
self.db.postList.toArray(function (array) {
|
|
|
|
|
self.dataUtils.request('/api/post/sync', DataEvent.POSTS_SYNCED, _DataUtils.REQUEST_TYPE_POST, _DataUtils.CONTENT_TYPE_JSON, array).then(function (response) {
|
|
|
|
|
var bounce = {
|
|
|
|
|
message: response,
|
|
|
|
|
newPost: fresh
|
|
|
|
|
};
|
|
|
|
|
resolve({
|
|
|
|
|
bounce: bounce
|
|
|
|
|
});
|
|
|
|
|
}).catch(function (err) {
|
|
|
|
|
reject({
|
|
|
|
|
err: err
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
newID = fresh;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
_this.db.postList.update(Number(id), {
|
|
|
|
|
self.db.postList.update(Number(id), {
|
|
|
|
|
post: data
|
|
|
|
|
}).then(function (updated) {
|
|
|
|
|
self.db.postList.toArray(function (array) {
|
|
|
|
|
self.dataUtils.request('/api/post/sync', DataEvent.POSTS_SYNCED, _DataUtils.REQUEST_TYPE_POST, _DataUtils.CONTENT_TYPE_JSON, array).then(function (response) {
|
|
|
|
|
resolve({
|
|
|
|
|
response: response
|
|
|
|
|
});
|
|
|
|
|
}).catch(function (err) {
|
|
|
|
|
reject({
|
|
|
|
|
err: err
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}); //(updated) ? resolve("UPDATED") : reject("NOT UPDATED");
|
|
|
|
|
});
|
|
|
|
|
}).then(function (updated) {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.db.postList.toArray(function (array) {
|
|
|
|
|
self.sync(array, newID).then(function (response) {
|
|
|
|
|
resolve({
|
|
|
|
|
response: response
|
|
|
|
|
});
|
|
|
|
|
}).catch(function (err) {
|
|
|
|
|
reject({
|
|
|
|
|
err: err
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
key: "sync",
|
|
|
|
|
value: function sync(db, newPostId) {
|
|
|
|
|
var self = this;
|
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
|
self.dataUtils.request('/api/post/sync', DataEvent.POSTS_SYNCED, _DataUtils.REQUEST_TYPE_POST, _DataUtils.CONTENT_TYPE_JSON, db).then(function (response) {
|
|
|
|
|
var bounce = {
|
|
|
|
|
message: response,
|
|
|
|
|
newPost: newPostId
|
|
|
|
|
};
|
|
|
|
|
resolve({
|
|
|
|
|
bounce: bounce
|
|
|
|
|
});
|
|
|
|
|
}).catch(function (err) {
|
|
|
|
|
reject({
|
|
|
|
|
err: err
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
key: "deletePost",
|
|
|
|
|
value: function deletePost() {
|
|
|
|
|
var self = this;
|
|
|
|
|
var postID = document.getElementById('edit-update').getAttribute('data-id');
|
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
|
self.dataUtils.request("/api/post/delete/" + postID, DataEvent.POST_DELETED, _DataUtils.REQUEST_TYPE_POST, _DataUtils.CONTENT_TYPE_FORM).then(function (response) {
|
|
|
|
|
resolve({
|
|
|
|
@ -35136,7 +35140,7 @@ function () {
|
|
|
|
|
err: err
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}); //this.dataUtils.re
|
|
|
|
|
});
|
|
|
|
|
} //--------------------------
|
|
|
|
|
// event handlers
|
|
|
|
|
//--------------------------
|
|
|
|
@ -37156,9 +37160,7 @@ function () {
|
|
|
|
|
|
|
|
|
|
_classCallCheck(this, PostEditor);
|
|
|
|
|
|
|
|
|
|
//reframe('iframe');
|
|
|
|
|
var self = this;
|
|
|
|
|
this.uploadFiles;
|
|
|
|
|
this.anim = new _Animate.default();
|
|
|
|
|
this.dataUtils = new _DataUtils.default();
|
|
|
|
|
this.dateUtils = new _DateUtils.default();
|
|
|
|
@ -37291,7 +37293,7 @@ function () {
|
|
|
|
|
postList: 'id, post'
|
|
|
|
|
});
|
|
|
|
|
setTimeout(function (f) {
|
|
|
|
|
freshDB.postList.get(Number(response.bounce.newPost)).then(function (obj) {
|
|
|
|
|
freshDB.postList.get(Number(response.response.bounce.newPost)).then(function (obj) {
|
|
|
|
|
window.location = "/@/dashboard/posts/edit/" + obj.post.slug;
|
|
|
|
|
});
|
|
|
|
|
}, 200);
|
|
|
|
@ -37302,6 +37304,7 @@ function () {
|
|
|
|
|
|
|
|
|
|
case EditorEvent.EDITOR_UPDATE:
|
|
|
|
|
new _PostActions.default().update(this.postID, this.post, PostEditor.uploadFiles, this.postFinalKey).then(function (response) {
|
|
|
|
|
//console.log(response.response.bounce.newPost);
|
|
|
|
|
_this3.editor.notify(DataEvent.POST_UPDATED, _this3.postID);
|
|
|
|
|
}).catch(function (err) {
|
|
|
|
|
console.log("ERROR", err);
|
|
|
|
@ -37312,7 +37315,7 @@ function () {
|
|
|
|
|
if (confirm('Aye! You know you\'re deleting this post, right?')) {
|
|
|
|
|
new _PostActions.default().deletePost().then(function (response) {
|
|
|
|
|
var note = JSON.parse(response['response']['request'].response);
|
|
|
|
|
window.location = "/@/dashboard/posts/"; //console.log(note);
|
|
|
|
|
window.location = "/@/dashboard/posts/";
|
|
|
|
|
}).catch(function (err) {
|
|
|
|
|
console.log(err);
|
|
|
|
|
});
|
|
|
|
@ -37400,82 +37403,6 @@ function () {
|
|
|
|
|
console.log(err);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
key: "handleFeatureImageAdd",
|
|
|
|
|
value: function handleFeatureImageAdd(e) {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
var self = this;
|
|
|
|
|
var postData = new FormData();
|
|
|
|
|
var files = e.target.files;
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < files.length; i++) {
|
|
|
|
|
var file = files[i]; // Check the file type.
|
|
|
|
|
|
|
|
|
|
if (!file.type.match('image.*')) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
postData.append('feature_image', file, file.name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.dataUtils.request("/api/post/add-feature-image", DataEvent.FEATURE_IMAGE_ADDED, _DataUtils.REQUEST_TYPE_POST, _DataUtils.CONTENT_TYPE_FORM, postData).then(function (response) {//self.editor.notify(EditorEvent.EDITOR_UPLOAD_POST_IMAGE, JSON.parse(response.request['response']).url);
|
|
|
|
|
}).catch(function (err) {
|
|
|
|
|
console.log(err);
|
|
|
|
|
});
|
|
|
|
|
PostEditor.uploadFiles = e.target.files;
|
|
|
|
|
|
|
|
|
|
for (var i = 0, f; f = PostEditor.uploadFiles[i]; i++) {
|
|
|
|
|
// Only process image files.
|
|
|
|
|
if (!f.type.match('image.*')) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var reader = new FileReader(); // Closure to capture the file information.
|
|
|
|
|
|
|
|
|
|
reader.onload = function (theFile) {
|
|
|
|
|
return function (f) {
|
|
|
|
|
// Render thumbnail.
|
|
|
|
|
var image = document.createElement('img');
|
|
|
|
|
image.src = f.target.result;
|
|
|
|
|
image.title = escape(theFile.name);
|
|
|
|
|
var span = document.createElement('div');
|
|
|
|
|
span.innerHTML = ['<img src="', f.target.result, '" title="', escape(theFile.name), '"/>'].join(''); //document.getElementById('featured-image-drop').insertBefore(span, null);
|
|
|
|
|
|
|
|
|
|
document.getElementById('featured-image-drop').innerHTML = '';
|
|
|
|
|
document.getElementById('featured-image-drop').appendChild(image);
|
|
|
|
|
};
|
|
|
|
|
}(f); // Read in the image file as a data URL.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reader.readAsDataURL(f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
key: "handlePostImageAdd",
|
|
|
|
|
value: function handlePostImageAdd(e) {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
var self = this;
|
|
|
|
|
var postData = new FormData();
|
|
|
|
|
var files = e.target.files;
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < files.length; i++) {
|
|
|
|
|
var file = files[i]; // Check the file type.
|
|
|
|
|
|
|
|
|
|
if (!file.type.match('image.*')) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
postData.append('post_image', file, file.name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.dataUtils.request("/api/post/add-post-image", DataEvent.POST_IMAGE_ADDED, _DataUtils.REQUEST_TYPE_POST, _DataUtils.CONTENT_TYPE_FORM, postData).then(function (response) {
|
|
|
|
|
self.editor.notify(EditorEvent.EDITOR_UPLOAD_POST_IMAGE, JSON.parse(response.request['response']).url);
|
|
|
|
|
}).catch(function (err) {
|
|
|
|
|
console.log(err);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}]);
|
|
|
|
|
|
|
|
|
|
return PostEditor;
|
|
|
|
|