cleaned up post controller. much nice. wow smoother

This commit is contained in:
Ro 2018-11-27 13:48:02 -05:00
parent a7239a3027
commit c2b5d9a56c
10 changed files with 169 additions and 300 deletions

View file

@ -1,6 +1,7 @@
var express = require('express'); var express = require('express');
import DateUtils from '../../tools/utilities/DateUtils'; import DateUtils from '../../tools/utilities/DateUtils';
import StringUtils from '../../tools/utilities/StringUtils'; import StringUtils from '../../tools/utilities/StringUtils';
import * as DataEvent from '../../tools/events/DataEvent';
import RightsManager, import RightsManager,
{ {
TASK_CREATE, TASK_CREATE,
@ -157,7 +158,7 @@ router.post('/add-post-image', function(req, res, next)
var postImage = req.files[0].path; var postImage = req.files[0].path;
return res.json( return res.json(
{ {
message: "post image added", message: DataEvent.POST_IMAGE_ADDED,
url: postImage.substr(7, postImage.length) url: postImage.substr(7, postImage.length)
}); });
} }
@ -200,7 +201,7 @@ router.post('/add-feature-image', function(req, res, next)
var postImage = req.files[0].path; var postImage = req.files[0].path;
return res.json( return res.json(
{ {
message: "post image added", message: DataEvent.FEATURE_IMAGE_ADDED,
url: postImage.substr(7, postImage.length) url: postImage.substr(7, postImage.length)
}); });
} }

View file

@ -108,7 +108,6 @@ router.get('/edit/:id', function(req, res)
} }
}).then(item => }).then(item =>
{ {
console.log("**ITEM***", item);
let featured = 'null'; let featured = 'null';
if(item.post.feature != null || item.post.feature != '') if(item.post.feature != null || item.post.feature != '')
featured = item.post.feature.substr(8, item.post.feature.length); featured = item.post.feature.substr(8, item.post.feature.length);

View file

@ -2276,8 +2276,8 @@ select {
color: #b2cce5; color: #b2cce5;
padding: 5px; padding: 5px;
} }
#post-edit-index #post-edit-index-wrapper #post-header #post-meta #featured-click, #post-edit-index #post-edit-index-wrapper #post-header #post-meta #featured-image-upload,
#post-edit-index #post-edit-index-wrapper #post-header #post-meta #post-image { #post-edit-index #post-edit-index-wrapper #post-header #post-meta #post-image-upload {
display: none; display: none;
} }
#post-edit-index #post-edit-index-wrapper #post-feature { #post-edit-index #post-edit-index-wrapper #post-feature {
@ -2306,11 +2306,11 @@ select {
position: absolute; position: absolute;
margin: 20px; margin: 20px;
} }
#post-edit-index #post-edit-index-wrapper #post-feature #featured-new-image-btn #new-upload-link { #post-edit-index #post-edit-index-wrapper #post-feature #featured-new-image-btn #new-feature-upload {
padding-top: 4px; padding-top: 4px;
background: #f2f1ef; background: #f2f1ef;
} }
#post-edit-index #post-edit-index-wrapper #post-feature #featured-new-image-btn #new-upload-link svg { #post-edit-index #post-edit-index-wrapper #post-feature #featured-new-image-btn #new-feature-upload svg {
fill: #fc6399; fill: #fc6399;
} }
#post-edit-index #post-edit-index-wrapper #edit-post { #post-edit-index #post-edit-index-wrapper #edit-post {

File diff suppressed because one or more lines are too long

View file

@ -35100,7 +35100,7 @@ function () {
err: err err: err
}); });
}); });
}); //(updated) ? resolve("UPDATED") : reject("NOT UPDATED"); });
}); });
} else { } else {
_this.db.postList.update(Number(id), { _this.db.postList.update(Number(id), {
@ -35121,100 +35121,6 @@ function () {
} }
}); });
} }
}, {
key: "sync",
value: function sync(files) {
var self = this;
return new Promise(function (resolve, reject) {
var syncData = new FormData();
var postList = '';
for (var i = 0; i < files.length; i++) {
var file = files[i]; // Check the file type.
if (!file.type.match('image.*')) {
continue;
} // Add the file to the request.
syncData.append('feature_image', file, file.name);
}
var fipamoPosts = new _dexie.default("fipamo_posts");
fipamoPosts.version(1).stores({
postList: 'id,post'
});
fipamoPosts.postList.toArray(function (array) {
self.dataUtils.request('/api/post/sync', DataEvent.POSTS_SYNCED, _DataUtils.REQUEST_TYPE_POST, _DataUtils.CONTENT_TYPE_JSON, array).then(function (response) {
resolve({
response: response
});
}).catch(function (err) {
reject({
err: err
});
}); //console.log("LIST", postList);
});
});
}
}, {
key: "submitPost",
value: function submitPost(edit, uploadFiles) {
var self = this;
return new Promise(function (resolve, reject) {
//collect form data
//if(!this.validateForm())
var postData = new FormData(); //let projectImages = document.getElementById('projectImages');
//var fileSelect = projectImages;
var files = uploadFiles;
for (var i = 0; i < files.length; i++) {
var file = files[i]; // Check the file type.
if (!file.type.match('image.*')) {
continue;
} // Add the file to the request.
postData.append('feature_image', file, file.name);
} //var category = document.getElementById("content_category");
//let project_form = document.forms.namedItem("folio-project");
var txt = document.createElement("textarea");
txt.innerHTML = document.getElementById('edit-post-text').innerHTML;
postData.append("title", document.getElementById('post_title').value);
postData.append('slug', new _StringUtils.default().cleanString(document.getElementById('post_title').value));
postData.append("post_plaintext", txt.value);
postData.append("origin_date", document.getElementById('post-date').value);
postData.append("tags", document.getElementById('post_tags').value);
postData.append("status_page", document.getElementById('option-page').getAttribute('data-active'));
postData.append("status_feature", document.getElementById('option-feature').getAttribute('data-active'));
postData.append("status_published", document.getElementById('option-published').getAttribute('data-active'));
var postURL;
var postEventType;
if (edit) {
var postID = document.getElementById('edit-update').getAttribute('data-id');
postURL = "/api/post/update/" + postID;
postEventType = DataEvent.POST_UPDATED;
} else {
postURL = "/api/post/add";
postEventType = DataEvent.POST_ADDED;
}
self.dataUtils.request(postURL, postEventType, _DataUtils.REQUEST_TYPE_POST, _DataUtils.CONTENT_TYPE_FORM, postData).then(function (response) {
resolve({
response: response
});
}).catch(function (err) {
reject({
err: err
});
});
});
}
}, { }, {
key: "deletePost", key: "deletePost",
value: function deletePost() { value: function deletePost() {
@ -37287,8 +37193,8 @@ function () {
this.editor.addListener(EditorEvent.EDITOR_SAVE, function (f) { this.editor.addListener(EditorEvent.EDITOR_SAVE, function (f) {
return _this.handleEditorOptions(EditorEvent.EDITOR_SAVE); return _this.handleEditorOptions(EditorEvent.EDITOR_SAVE);
}, false); }, false);
document.getElementById('post-image').addEventListener('change', function (e) { document.getElementById('post-image-upload').addEventListener('change', function (e) {
return _this.handlePostImageAdd(e); self.handleImageUpload(e.target.id, e.target.files);
}, false); }, false);
(0, _tinyDatePicker.default)(document.getElementById('post-date'), { (0, _tinyDatePicker.default)(document.getElementById('post-date'), {
mode: 'dp-below', mode: 'dp-below',
@ -37323,15 +37229,15 @@ function () {
var self = this; var self = this;
if (document.getElementById('featured-image-drop')) { if (document.getElementById('featured-image-drop')) {
document.getElementById('featured-image-drop').addEventListener('dragover', this.handleDragOver, false); document.getElementById('featured-image-drop').addEventListener('dragover', this.handleImageActions, false);
document.getElementById('featured-image-drop').addEventListener('drop', this.handleDrop, false); document.getElementById('featured-image-drop').addEventListener('drop', this.handleImageActions, false);
document.getElementById('featured-click').addEventListener('change', function (e) { document.getElementById('featured-image-upload').addEventListener('change', function (e) {
return _this2.handleFeatureImageAdd(e); return _this2.handleImageActions(e);
}, false); }, false);
if (document.getElementById('new-upload-link')) { if (document.getElementById('new-feature-upload')) {
document.getElementById('new-upload-link').addEventListener('click', function (e) { document.getElementById('new-feature-upload').addEventListener('click', function (e) {
document.getElementById('featured-click').click(); document.getElementById('featured-image-upload').click();
}); });
} }
@ -37380,7 +37286,6 @@ function () {
switch (e) { switch (e) {
case EditorEvent.EDITOR_SAVE: case EditorEvent.EDITOR_SAVE:
new _PostActions.default().update(this.postID, this.post, PostEditor.uploadFiles, this.postFinalKey).then(function (response) { new _PostActions.default().update(this.postID, this.post, PostEditor.uploadFiles, this.postFinalKey).then(function (response) {
//console.log(response.bounce.newPost);
var freshDB = new _dexie.default("fipamo_posts"); var freshDB = new _dexie.default("fipamo_posts");
freshDB.version(1).stores({ freshDB.version(1).stores({
postList: 'id, post' postList: 'id, post'
@ -37389,7 +37294,7 @@ function () {
freshDB.postList.get(Number(response.bounce.newPost)).then(function (obj) { freshDB.postList.get(Number(response.bounce.newPost)).then(function (obj) {
window.location = "/@/dashboard/posts/edit/" + obj.post.slug; window.location = "/@/dashboard/posts/edit/" + obj.post.slug;
}); });
}, 200); //this.editor.notify(DataEvent.POST_UPDATED, this.postID); }, 200);
}).catch(function (err) { }).catch(function (err) {
console.log("ERROR", err); console.log("ERROR", err);
}); });
@ -37417,23 +37322,26 @@ function () {
break; break;
case EditorEvent.EDITOR_UPLOAD_POST_IMAGE: case EditorEvent.EDITOR_UPLOAD_POST_IMAGE:
document.getElementById('post-image').click(); document.getElementById('post-image-upload').click();
break; break;
} }
} }
}, { }, {
key: "handleDragOver", key: "handleImageActions",
value: function handleDragOver(e) { value: function handleImageActions(e) {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
var self = this;
switch (e.type) {
case "dragover":
e.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy. e.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
}
}, { break;
key: "handleDrop",
value: function handleDrop(e) { case "change":
e.stopPropagation(); case "drop":
e.preventDefault(); e.type == "drop" ? PostEditor.uploadFiles = e.dataTransfer.files : PostEditor.uploadFiles = e.target.files;
PostEditor.uploadFiles = e.dataTransfer.files; //console.log(MemberArea.uploadFiles.length);
for (var i = 0, f; f = PostEditor.uploadFiles[i]; i++) { for (var i = 0, f; f = PostEditor.uploadFiles[i]; i++) {
// Only process image files. // Only process image files.
@ -37446,17 +37354,51 @@ function () {
reader.onload = function (theFile) { reader.onload = function (theFile) {
return function (f) { return function (f) {
// Render thumbnail. // Render thumbnail.
var span = document.createElement('span'); var image = document.createElement('img');
image.src = f.target.result;
image.title = escape(theFile.name);
var span = document.createElement('div');
span.innerHTML = ['<img src="', f.target.result, '" title="', escape(theFile.name), '"/>'].join(''); //document.getElementById('featured-image-drop').insertBefore(span, null); span.innerHTML = ['<img src="', f.target.result, '" title="', escape(theFile.name), '"/>'].join(''); //document.getElementById('featured-image-drop').insertBefore(span, null);
document.getElementById('featured-image-drop').innerHTML = ''; document.getElementById('featured-image-drop').innerHTML = '';
document.getElementById('featured-image-drop').appendChild(span); document.getElementById('featured-image-drop').appendChild(image);
}; };
}(f); // Read in the image file as a data URL. }(f); // Read in the image file as a data URL.
reader.readAsDataURL(f); reader.readAsDataURL(f);
} }
if (e.target.id == "featured-image-upload") this.handleImageUpload(e.target.id, PostEditor.uploadFiles);
break;
}
}
}, {
key: "handleImageUpload",
value: function handleImageUpload(type, files) {
var url = "";
var eventType = "";
var self = this;
type == "featured-image-upload" ? url = "/api/post/add-feature-image" : url = "/api/post/add-post-image";
type == "featured-image-upload" ? eventType = DataEvent.FEATURE_IMAGE_ADDED : eventType = DataEvent.POST_IMAGE_ADDED;
var imageData = new FormData();
for (var i = 0; i < files.length; i++) {
var file = files[i]; // Check the file type.
if (!file.type.match('image.*')) {
continue;
}
type == "featured-image-upload" ? imageData.append('feature_image', file, file.name) : imageData.append('post_image', file, file.name);
}
this.dataUtils.request(url, eventType, _DataUtils.REQUEST_TYPE_POST, _DataUtils.CONTENT_TYPE_FORM, imageData).then(function (response) {
var r = JSON.parse(response.request['response']);
if (r.message == DataEvent.POST_IMAGE_ADDED) self.editor.notify(EditorEvent.EDITOR_UPLOAD_POST_IMAGE, r.url);
}).catch(function (err) {
console.log(err);
});
} }
}, { }, {
key: "handleFeatureImageAdd", key: "handleFeatureImageAdd",

File diff suppressed because one or more lines are too long

View file

@ -30,8 +30,8 @@ block main-content
else else
#featured-new-image-btn #featured-new-image-btn
button#new-upload-link button#new-feature-upload
svg#new-upload-link(viewBox="0 0 20 20" class="icons") svg#new-feature-upload(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-image-inverted') use(xlink:href='/dash/assets/images/sprite.svg#entypo-image-inverted')
#featured-image-drop #featured-image-drop
img(src=post_feature) img(src=post_feature)
@ -58,8 +58,8 @@ block main-content
textarea(id='post_tags' type='text', name='post_tags' class='form-control', placeholder='tags [comma seperated]', autofocus) textarea(id='post_tags' type='text', name='post_tags' class='form-control', placeholder='tags [comma seperated]', autofocus)
=post_tags =post_tags
include partials/editor include partials/editor
input(id="featured-click" type="file" name="featured-click") input(id="featured-image-upload" type="file" name="featured-image-upload")
input(id="post-image" type="file" name="post-image") input(id="post-image-upload" type="file" name="post-image-upload")
#edit-post #edit-post
#edit-post-wrapper #edit-post-wrapper
pre pre

View file

@ -15,7 +15,7 @@ import sanitize from 'sanitize-html'
import DateUtils from '../../../../../brain/tools/utilities/DateUtils'; import DateUtils from '../../../../../brain/tools/utilities/DateUtils';
var md = require('markdown-it')('commonmark'); var md = require('markdown-it')('commonmark');
var uuidv4 = require('uuid/v4'); var uuidv4 = require('uuid/v4');
class PostActions export default class PostActions
{ {
//-------------------------- //--------------------------
// constructor // constructor
@ -125,7 +125,6 @@ class PostActions
}); });
}) })
}) })
//(updated) ? resolve("UPDATED") : reject("NOT UPDATED");
}); });
} }
else else
@ -158,110 +157,6 @@ class PostActions
} }
}) })
} }
sync(files)
{
let self = this;
return new Promise((resolve, reject) =>
{
var syncData = new FormData();
var postList = '';
for (var i = 0; i < files.length; i++)
{
var file = files[i];
// Check the file type.
if (!file.type.match('image.*'))
{
continue;
}
// Add the file to the request.
syncData.append('feature_image', file, file.name);
}
var fipamoPosts = new Dexie("fipamo_posts");
fipamoPosts.version(1).stores(
{
postList: 'id,post'
});
fipamoPosts.postList.toArray(array =>
{
self.dataUtils.request('/api/post/sync', DataEvent.POSTS_SYNCED, REQUEST_TYPE_POST, CONTENT_TYPE_JSON, array).then((response) =>
{
resolve(
{
response
})
}).catch((err) =>
{
reject(
{
err
});
})
//console.log("LIST", postList);
})
})
}
submitPost(edit, uploadFiles)
{
let self = this;
return new Promise(function(resolve, reject)
{
//collect form data
//if(!this.validateForm())
var postData = new FormData();
//let projectImages = document.getElementById('projectImages');
//var fileSelect = projectImages;
var files = uploadFiles;
for (var i = 0; i < files.length; i++)
{
var file = files[i];
// Check the file type.
if (!file.type.match('image.*'))
{
continue;
}
// Add the file to the request.
postData.append('feature_image', file, file.name);
}
//var category = document.getElementById("content_category");
//let project_form = document.forms.namedItem("folio-project");
var txt = document.createElement("textarea");
txt.innerHTML = document.getElementById('edit-post-text').innerHTML;
postData.append("title", document.getElementById('post_title').value);
postData.append('slug', new StringUtils().cleanString(document.getElementById('post_title').value));
postData.append("post_plaintext", txt.value);
postData.append("origin_date", document.getElementById('post-date').value);
postData.append("tags", document.getElementById('post_tags').value);
postData.append("status_page", document.getElementById('option-page').getAttribute('data-active'));
postData.append("status_feature", document.getElementById('option-feature').getAttribute('data-active'));
postData.append("status_published", document.getElementById('option-published').getAttribute('data-active'));
let postURL;
let postEventType;
if (edit)
{
let postID = document.getElementById('edit-update').getAttribute('data-id');
postURL = "/api/post/update/" + postID;
postEventType = DataEvent.POST_UPDATED;
}
else
{
postURL = "/api/post/add";
postEventType = DataEvent.POST_ADDED;
}
self.dataUtils.request(postURL, postEventType, REQUEST_TYPE_POST, CONTENT_TYPE_FORM, postData).then((response) =>
{
resolve(
{
response
})
}).catch((err) =>
{
reject(
{
err
});
})
});
}
deletePost() deletePost()
{ {
let self = this; let self = this;
@ -288,8 +183,3 @@ class PostActions
// event handlers // event handlers
//-------------------------- //--------------------------
} }
export
{
PostActions as
default
}

View file

@ -54,7 +54,9 @@ export default class PostEditor
this.editor.addListener(EditorEvent.EDITOR_UPLOAD_POST_IMAGE, f => this.handleEditorOptions(EditorEvent.EDITOR_UPLOAD_POST_IMAGE), false) this.editor.addListener(EditorEvent.EDITOR_UPLOAD_POST_IMAGE, f => this.handleEditorOptions(EditorEvent.EDITOR_UPLOAD_POST_IMAGE), false)
this.editor.addListener(EditorEvent.EDITOR_UPDATE, f => this.handleEditorOptions(EditorEvent.EDITOR_UPDATE), false) this.editor.addListener(EditorEvent.EDITOR_UPDATE, f => this.handleEditorOptions(EditorEvent.EDITOR_UPDATE), false)
this.editor.addListener(EditorEvent.EDITOR_SAVE, f => this.handleEditorOptions(EditorEvent.EDITOR_SAVE), false) this.editor.addListener(EditorEvent.EDITOR_SAVE, f => this.handleEditorOptions(EditorEvent.EDITOR_SAVE), false)
document.getElementById('post-image').addEventListener('change', e => this.handlePostImageAdd(e), false); document.getElementById('post-image-upload').addEventListener('change', e => {
self.handleImageUpload(e.target.id, e.target.files);
}, false);
TinyDatePicker(document.getElementById('post-date'), TinyDatePicker(document.getElementById('post-date'),
{ {
mode: 'dp-below', mode: 'dp-below',
@ -84,14 +86,14 @@ export default class PostEditor
let self = this; let self = this;
if (document.getElementById('featured-image-drop')) if (document.getElementById('featured-image-drop'))
{ {
document.getElementById('featured-image-drop').addEventListener('dragover', this.handleDragOver, false); document.getElementById('featured-image-drop').addEventListener('dragover', this.handleImageActions, false);
document.getElementById('featured-image-drop').addEventListener('drop', this.handleDrop, false); document.getElementById('featured-image-drop').addEventListener('drop', this.handleImageActions, false);
document.getElementById('featured-click').addEventListener('change', e => this.handleFeatureImageAdd(e), false); document.getElementById('featured-image-upload').addEventListener('change', e=> this.handleImageActions(e), false);
if (document.getElementById('new-upload-link')) if (document.getElementById('new-feature-upload'))
{ {
document.getElementById('new-upload-link').addEventListener('click', e => document.getElementById('new-feature-upload').addEventListener('click', e =>
{ {
document.getElementById('featured-click').click(); document.getElementById('featured-image-upload').click();
}) })
} }
var optionButtons = document.querySelectorAll('.post-option-btn'); var optionButtons = document.querySelectorAll('.post-option-btn');
@ -132,7 +134,6 @@ export default class PostEditor
case EditorEvent.EDITOR_SAVE: case EditorEvent.EDITOR_SAVE:
new PostActions().update(this.postID, this.post, PostEditor.uploadFiles, this.postFinalKey).then(response => new PostActions().update(this.postID, this.post, PostEditor.uploadFiles, this.postFinalKey).then(response =>
{ {
//console.log(response.bounce.newPost);
let freshDB = new Dexie("fipamo_posts"); let freshDB = new Dexie("fipamo_posts");
freshDB.version(1).stores( freshDB.version(1).stores(
{ {
@ -145,7 +146,6 @@ export default class PostEditor
window.location = "/@/dashboard/posts/edit/" + obj.post.slug; window.location = "/@/dashboard/posts/edit/" + obj.post.slug;
}); });
}, 200); }, 200);
//this.editor.notify(DataEvent.POST_UPDATED, this.postID);
}).catch(err => }).catch(err =>
{ {
console.log("ERROR", err) console.log("ERROR", err)
@ -179,22 +179,23 @@ export default class PostEditor
} }
break; break;
case EditorEvent.EDITOR_UPLOAD_POST_IMAGE: case EditorEvent.EDITOR_UPLOAD_POST_IMAGE:
document.getElementById('post-image').click(); document.getElementById('post-image-upload').click();
break; break;
} }
} }
handleDragOver(e) handleImageActions(e)
{ {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
var self = this;
switch (e.type)
{
case "dragover":
e.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy. e.dataTransfer.dropEffect = 'copy'; // Explicitly show this is a copy.
} break;
handleDrop(e) case "change":
{ case "drop":
e.stopPropagation(); (e.type == "drop") ? PostEditor.uploadFiles = e.dataTransfer.files: PostEditor.uploadFiles = e.target.files;
e.preventDefault();
PostEditor.uploadFiles = e.dataTransfer.files;
//console.log(MemberArea.uploadFiles.length);
for (var i = 0, f; f = PostEditor.uploadFiles[i]; i++) for (var i = 0, f; f = PostEditor.uploadFiles[i]; i++)
{ {
// Only process image files. // Only process image files.
@ -209,19 +210,55 @@ export default class PostEditor
return function(f) return function(f)
{ {
// Render thumbnail. // Render thumbnail.
var span = document.createElement('span'); var image = document.createElement('img');
image.src = f.target.result;
image.title = escape(theFile.name);
var span = document.createElement('div');
span.innerHTML = ['<img src="', span.innerHTML = ['<img src="',
f.target.result, '" title="', f.target.result, '" title="',
escape(theFile.name), '"/>' escape(theFile.name), '"/>'
].join(''); ].join('');
//document.getElementById('featured-image-drop').insertBefore(span, null); //document.getElementById('featured-image-drop').insertBefore(span, null);
document.getElementById('featured-image-drop').innerHTML = ''; document.getElementById('featured-image-drop').innerHTML = '';
document.getElementById('featured-image-drop').appendChild(span); document.getElementById('featured-image-drop').appendChild(image);
}; };
})(f); })(f);
// 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") this.handleImageUpload(e.target.id, PostEditor.uploadFiles);
break;
}
}
handleImageUpload(type, files)
{
let url = ""
let eventType = "";
let self = this;
(type == "featured-image-upload") ? url = "/api/post/add-feature-image" : url = "/api/post/add-post-image";
(type == "featured-image-upload") ? eventType = DataEvent.FEATURE_IMAGE_ADDED : eventType = DataEvent.POST_IMAGE_ADDED
var imageData = new FormData();
for (var i = 0; i < files.length; i++)
{
var file = files[i];
// Check the file type.
if (!file.type.match('image.*'))
{
continue;
}
(type == "featured-image-upload") ? 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).then((response) =>
{
let r = JSON.parse(response.request['response']);
if(r.message == DataEvent.POST_IMAGE_ADDED)
self.editor.notify(EditorEvent.EDITOR_UPLOAD_POST_IMAGE, r.url);
}).catch((err) =>
{
console.log(err)
})
} }
handleFeatureImageAdd(e) handleFeatureImageAdd(e)
{ {

View file

@ -140,7 +140,7 @@
color $secondary color $secondary
padding 5px padding 5px
#featured-click, #post-image #featured-image-upload, #post-image-upload
display none display none
#post-feature #post-feature
@ -169,7 +169,7 @@
position absolute position absolute
margin 20px margin 20px
#new-upload-link #new-feature-upload
padding-top 4px padding-top 4px
background $white background $white