|
|
|
@ -5,6 +5,7 @@ import PostActions from '../actions/PostActions';
|
|
|
|
|
import * as EditorEvent from '../../../src/com/events/EditorEvent';
|
|
|
|
|
import TinyDatePicker from 'tiny-date-picker';
|
|
|
|
|
import TextEditor from '../../../src/com/ui/TextEditor';
|
|
|
|
|
const data = new DataUtils();
|
|
|
|
|
export default class PostEditor {
|
|
|
|
|
//TODO - FIX POST FEATURE URLS IN DB
|
|
|
|
|
|
|
|
|
@ -130,6 +131,27 @@ 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(() => {
|
|
|
|
@ -138,6 +160,7 @@ export default class PostEditor {
|
|
|
|
|
.catch(() => {
|
|
|
|
|
//console.log("ERRORZ", err)
|
|
|
|
|
});
|
|
|
|
|
*/
|
|
|
|
|
break;
|
|
|
|
|
case EditorEvent.EDITOR_DELETE:
|
|
|
|
|
if (confirm("Aye! You know you're deleting this post, right?")) {
|
|
|
|
@ -198,9 +221,11 @@ export default class PostEditor {
|
|
|
|
|
// Read in the image file as a data URL.
|
|
|
|
|
reader.readAsDataURL(f);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
if (e.target.id == 'featured-image-upload')
|
|
|
|
|
this.handleImageUpload(e.target.id, PostEditor.uploadFiles);
|
|
|
|
|
break;
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
handleImageUpload(type, files) {
|
|
|
|
@ -224,8 +249,7 @@ export default class PostEditor {
|
|
|
|
|
? imageData.append('feature_image', file, file.name)
|
|
|
|
|
: imageData.append('post_image', file, file.name);
|
|
|
|
|
}
|
|
|
|
|
this.dataUtils
|
|
|
|
|
.request(url, eventType, REQUEST_TYPE_POST, CONTENT_TYPE_FORM, imageData)
|
|
|
|
|
data.request(url, eventType, REQUEST_TYPE_POST, CONTENT_TYPE_FORM, imageData)
|
|
|
|
|
.then(response => {
|
|
|
|
|
let r = JSON.parse(response.request['response']);
|
|
|
|
|
if (r.message == DataEvent.POST_IMAGE_ADDED)
|
|
|
|
|