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