|
|
@ -1,16 +1,20 @@
|
|
|
|
//TOOLS
|
|
|
|
//TOOLS
|
|
|
|
import ApiUtils, {
|
|
|
|
import FipamoAPI, {
|
|
|
|
REQUEST_TYPE_POST,
|
|
|
|
REQUEST_TYPE_POST,
|
|
|
|
CONTENT_TYPE_FORM,
|
|
|
|
CONTENT_TYPE_FORM,
|
|
|
|
CONTENT_TYPE_JSON
|
|
|
|
CONTENT_TYPE_JSON,
|
|
|
|
} from '../utils/APIUtils';
|
|
|
|
API_NEW_PAGE,
|
|
|
|
|
|
|
|
API_EDIT_PAGE,
|
|
|
|
|
|
|
|
API_DELETE_PAGE,
|
|
|
|
|
|
|
|
API_IMAGE_UPLOAD
|
|
|
|
|
|
|
|
} from '../../libraries/FipamoAPI';
|
|
|
|
import * as DataEvent from '../events/DataEvent';
|
|
|
|
import * as DataEvent from '../events/DataEvent';
|
|
|
|
import PageActions from '../actions/PageActions';
|
|
|
|
import PageActions from '../actions/PageActions';
|
|
|
|
import * as EditorEvent from '../events/EditorEvent';
|
|
|
|
import * as EditorEvent from '../events/EditorEvent';
|
|
|
|
//import TinyDatePicker from 'tiny-date-picker';
|
|
|
|
//import TinyDatePicker from 'tiny-date-picker';
|
|
|
|
import TextEditor from '../ui/TextEditor';
|
|
|
|
import TextEditor from '../ui/TextEditor';
|
|
|
|
import Notfications from '../ui/Notifications';
|
|
|
|
import Notfications from '../ui/Notifications';
|
|
|
|
const api = new ApiUtils();
|
|
|
|
const api = new FipamoAPI();
|
|
|
|
const notify = new Notfications();
|
|
|
|
const notify = new Notfications();
|
|
|
|
export default class PostEditor {
|
|
|
|
export default class PostEditor {
|
|
|
|
//--------------------------
|
|
|
|
//--------------------------
|
|
|
@ -23,7 +27,6 @@ export default class PostEditor {
|
|
|
|
this.postID = null;
|
|
|
|
this.postID = null;
|
|
|
|
this.postUUID = null;
|
|
|
|
this.postUUID = null;
|
|
|
|
this.postLayout = null;
|
|
|
|
this.postLayout = null;
|
|
|
|
api.authStatus();
|
|
|
|
|
|
|
|
if (document.getElementById('post-edit-index').getAttribute('data-index')) {
|
|
|
|
if (document.getElementById('post-edit-index').getAttribute('data-index')) {
|
|
|
|
this.postID = document.getElementById('post-edit-index').getAttribute('data-index');
|
|
|
|
this.postID = document.getElementById('post-edit-index').getAttribute('data-index');
|
|
|
|
this.postUUID = document.getElementById('post-edit-index').getAttribute('data-uuid');
|
|
|
|
this.postUUID = document.getElementById('post-edit-index').getAttribute('data-uuid');
|
|
|
@ -131,9 +134,7 @@ export default class PostEditor {
|
|
|
|
case EditorEvent.EDITOR_SAVE:
|
|
|
|
case EditorEvent.EDITOR_SAVE:
|
|
|
|
case EditorEvent.EDITOR_UPDATE:
|
|
|
|
case EditorEvent.EDITOR_UPDATE:
|
|
|
|
var apiUrl = '';
|
|
|
|
var apiUrl = '';
|
|
|
|
e === EditorEvent.EDITOR_SAVE
|
|
|
|
e === EditorEvent.EDITOR_SAVE ? (apiUrl = API_NEW_PAGE) : (apiUrl = API_EDIT_PAGE);
|
|
|
|
? (apiUrl = '/api/v1/page/write/new')
|
|
|
|
|
|
|
|
: (apiUrl = '/api/v1/page/write');
|
|
|
|
|
|
|
|
new PageActions()
|
|
|
|
new PageActions()
|
|
|
|
.collectInfo(document.getElementById('featured-image-upload').files[0])
|
|
|
|
.collectInfo(document.getElementById('featured-image-upload').files[0])
|
|
|
|
|
|
|
|
|
|
|
@ -174,7 +175,7 @@ export default class PostEditor {
|
|
|
|
if (confirm("AYE! You know you're deleting this post, right?")) {
|
|
|
|
if (confirm("AYE! You know you're deleting this post, right?")) {
|
|
|
|
let id = { id: this.postUUID };
|
|
|
|
let id = { id: this.postUUID };
|
|
|
|
api.request(
|
|
|
|
api.request(
|
|
|
|
'/api/v1/page/delete',
|
|
|
|
API_DELETE_PAGE,
|
|
|
|
DataEvent.API_PAGE_DELETE,
|
|
|
|
DataEvent.API_PAGE_DELETE,
|
|
|
|
REQUEST_TYPE_POST,
|
|
|
|
REQUEST_TYPE_POST,
|
|
|
|
CONTENT_TYPE_JSON,
|
|
|
|
CONTENT_TYPE_JSON,
|
|
|
@ -238,7 +239,7 @@ export default class PostEditor {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handleImageUpload(type, files) {
|
|
|
|
handleImageUpload(type, files) {
|
|
|
|
let url = '/api/v1/page/add-post-image';
|
|
|
|
let url = API_IMAGE_UPLOAD;
|
|
|
|
let eventType = DataEvent.API_IMAGES_UPLOAD;
|
|
|
|
let eventType = DataEvent.API_IMAGES_UPLOAD;
|
|
|
|
let self = this;
|
|
|
|
let self = this;
|
|
|
|
var imageData = new FormData();
|
|
|
|
var imageData = new FormData();
|
|
|
|