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