|
|
|
@ -1,10 +1,10 @@
|
|
|
|
|
//TOOLS
|
|
|
|
|
import DataUtils, { REQUEST_TYPE_POST, CONTENT_TYPE_FORM } from '../../../src/com/utils/DataUtils';
|
|
|
|
|
import * as DataEvent from '../../../src/com/events/DataEvent';
|
|
|
|
|
import PostActions from '../actions/PostActions';
|
|
|
|
|
import * as EditorEvent from '../../../src/com/events/EditorEvent';
|
|
|
|
|
import DataUtils, { REQUEST_TYPE_POST, CONTENT_TYPE_FORM } from '../utils/DataUtils';
|
|
|
|
|
import * as DataEvent from '../events/DataEvent';
|
|
|
|
|
import PageActions from '../actions/PageActions';
|
|
|
|
|
import * as EditorEvent from '../events/EditorEvent';
|
|
|
|
|
import TinyDatePicker from 'tiny-date-picker';
|
|
|
|
|
import TextEditor from '../../../src/com/ui/TextEditor';
|
|
|
|
|
import TextEditor from '../ui/TextEditor';
|
|
|
|
|
const data = new DataUtils();
|
|
|
|
|
export default class PostEditor {
|
|
|
|
|
//TODO - FIX POST FEATURE URLS IN DB
|
|
|
|
@ -117,7 +117,7 @@ export default class PostEditor {
|
|
|
|
|
let self = this;
|
|
|
|
|
switch (e) {
|
|
|
|
|
case EditorEvent.EDITOR_SAVE:
|
|
|
|
|
new PostActions()
|
|
|
|
|
new PageActions()
|
|
|
|
|
.update(this.postID, this.post, PostEditor.uploadFiles, FINAL_KEY)
|
|
|
|
|
.then(response => {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
@ -131,40 +131,28 @@ export default class PostEditor {
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
case EditorEvent.EDITOR_UPDATE:
|
|
|
|
|
var pageData = new FormData();
|
|
|
|
|
pageData.append('name', 'HAMMOCK LANSING');
|
|
|
|
|
var image = document.getElementById('featured-image-upload').files[0];
|
|
|
|
|
if (image != null || image != undefined) {
|
|
|
|
|
pageData.append('feature_image', image, image.name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data.request(
|
|
|
|
|
'/api/v1/page/write',
|
|
|
|
|
DataEvent.API_PAGE_WRITE,
|
|
|
|
|
REQUEST_TYPE_POST,
|
|
|
|
|
CONTENT_TYPE_FORM,
|
|
|
|
|
pageData
|
|
|
|
|
)
|
|
|
|
|
.then(r => {
|
|
|
|
|
console.log('RESPONSE', r);
|
|
|
|
|
})
|
|
|
|
|
.catch(err => {
|
|
|
|
|
console.log('ERROR', err);
|
|
|
|
|
});
|
|
|
|
|
/**
|
|
|
|
|
new PostActions()
|
|
|
|
|
.update(this.postID, this.post, PostEditor.uploadFiles, FINAL_KEY)
|
|
|
|
|
.then(() => {
|
|
|
|
|
this.editor.notify(DataEvent.POST_UPDATED, this.postID);
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
//console.log("ERRORZ", err)
|
|
|
|
|
new PageActions()
|
|
|
|
|
.collectInfo(document.getElementById('featured-image-upload').files[0])
|
|
|
|
|
.then(page => {
|
|
|
|
|
data.request(
|
|
|
|
|
'/api/v1/page/write',
|
|
|
|
|
DataEvent.API_PAGE_WRITE,
|
|
|
|
|
REQUEST_TYPE_POST,
|
|
|
|
|
CONTENT_TYPE_FORM,
|
|
|
|
|
page
|
|
|
|
|
)
|
|
|
|
|
.then(response => {
|
|
|
|
|
let r = JSON.parse(response.request['response']);
|
|
|
|
|
console.log('RESPONSE', r.message);
|
|
|
|
|
})
|
|
|
|
|
.catch(err => {
|
|
|
|
|
console.log('ERROR', err);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
*/
|
|
|
|
|
break;
|
|
|
|
|
case EditorEvent.EDITOR_DELETE:
|
|
|
|
|
if (confirm("Aye! You know you're deleting this post, right?")) {
|
|
|
|
|
new PostActions()
|
|
|
|
|
new PageActions()
|
|
|
|
|
.deletePost(this.postID, this.post)
|
|
|
|
|
.then(() => {
|
|
|
|
|
setTimeout(() => {
|