forked from projects/fipamo
more text editor touch ups, fix for page delete option
This commit is contained in:
parent
f1a8ef67bc
commit
7cabb1d1f0
6 changed files with 74 additions and 61 deletions
|
@ -105,6 +105,7 @@ class PagesAPI
|
||||||
case "create":
|
case "create":
|
||||||
case "write":
|
case "write":
|
||||||
$body = $request->getParsedBody();
|
$body = $request->getParsedBody();
|
||||||
|
var_dump($body);
|
||||||
$passed = true;
|
$passed = true;
|
||||||
if (!isset($body["form_token"])) {
|
if (!isset($body["form_token"])) {
|
||||||
$result = [
|
$result = [
|
||||||
|
@ -138,10 +139,7 @@ class PagesAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($passed) {
|
if ($passed) {
|
||||||
$result = (new Book("../content/pages"))->editPage(
|
$result = (new Book())->editPage($task, $request);
|
||||||
$task,
|
|
||||||
$request
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
$result = [
|
$result = [
|
||||||
"message" =>
|
"message" =>
|
||||||
|
|
|
@ -32,8 +32,9 @@ class Book
|
||||||
{
|
{
|
||||||
$content = $this->getContents();
|
$content = $this->getContents();
|
||||||
if ($task == "delete") {
|
if ($task == "delete") {
|
||||||
$parsed = json_decode(file_get_contents("php://input"), true);
|
//$parsed = json_decode(file_get_contents("php://input"), true);
|
||||||
$body = find($content, ["uuid" => $parsed["id"]]);
|
//$body = find($content, ["uuid" => $parsed["id"]]);
|
||||||
|
$body = $request->getParsedBody();
|
||||||
} else {
|
} else {
|
||||||
$body = $request->getParsedBody();
|
$body = $request->getParsedBody();
|
||||||
}
|
}
|
||||||
|
@ -93,13 +94,9 @@ class Book
|
||||||
|
|
||||||
if ($task == "delete") {
|
if ($task == "delete") {
|
||||||
$deleted = "true";
|
$deleted = "true";
|
||||||
$body["menu"] ? ($body["menu"] = "true") : ($body["menu"] = "false");
|
$body["menu"] = "false";
|
||||||
$body["published"]
|
$body["published"] = "false";
|
||||||
? ($body["published"] = "true")
|
$body["featured"] = "false";
|
||||||
: ($body["published"] = "false");
|
|
||||||
$body["featured"]
|
|
||||||
? ($body["featured"] = "true")
|
|
||||||
: ($body["featured"] = "false");
|
|
||||||
} else {
|
} else {
|
||||||
$deleted = isset($page["deleted"]) ? $page["deleted"] : "false";
|
$deleted = isset($page["deleted"]) ? $page["deleted"] : "false";
|
||||||
}
|
}
|
||||||
|
@ -195,7 +192,10 @@ class Book
|
||||||
return $item["deleted"] == true;
|
return $item["deleted"] == true;
|
||||||
});
|
});
|
||||||
|
|
||||||
$all = $content;
|
//$all = $content;
|
||||||
|
$all = filter($content, function ($item) {
|
||||||
|
return $item["deleted"] == false;
|
||||||
|
});
|
||||||
$filter = isset($sort) ? $sort : "all";
|
$filter = isset($sort) ? $sort : "all";
|
||||||
switch ($filter) {
|
switch ($filter) {
|
||||||
case "published":
|
case "published":
|
||||||
|
@ -205,7 +205,7 @@ class Book
|
||||||
$filtered = $deleted;
|
$filtered = $deleted;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$filtered = $content;
|
$filtered = $all;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$numOfPages = ceil(count($filtered) / ($limit + 1));
|
$numOfPages = ceil(count($filtered) / ($limit + 1));
|
||||||
|
|
|
@ -919,7 +919,7 @@ const API_ACCESS_BAD = "apiUseNotAuthorized";
|
||||||
case TASK_PAGE_DELETE:
|
case TASK_PAGE_DELETE:
|
||||||
url = API_DELETE_PAGE;
|
url = API_DELETE_PAGE;
|
||||||
event = TASK_PAGE_DELETE;
|
event = TASK_PAGE_DELETE;
|
||||||
content = CONTENT_TYPE_JSON;
|
content = CONTENT_TYPE_FORM;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -1685,7 +1685,7 @@ class PostEditor {
|
||||||
// event handlers
|
// event handlers
|
||||||
//--------------------------
|
//--------------------------
|
||||||
handlePostOptions(e) {
|
handlePostOptions(e) {
|
||||||
let currentOption;
|
let currentOption = null;
|
||||||
switch(e.target.id){
|
switch(e.target.id){
|
||||||
case "option-page-icon":
|
case "option-page-icon":
|
||||||
case "option-menu-pin":
|
case "option-menu-pin":
|
||||||
|
@ -1700,9 +1700,11 @@ class PostEditor {
|
||||||
currentOption = document.getElementById("option-published");
|
currentOption = document.getElementById("option-published");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (currentOption != null) {
|
||||||
let active = currentOption.getAttribute("data-active");
|
let active = currentOption.getAttribute("data-active");
|
||||||
active == "false" ? currentOption.setAttribute("data-active", "true") : currentOption.setAttribute("data-active", "false");
|
active == "false" ? currentOption.setAttribute("data-active", "true") : currentOption.setAttribute("data-active", "false");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
handleEditorOptions(e1) {
|
handleEditorOptions(e1) {
|
||||||
if (this.processing) return;
|
if (this.processing) return;
|
||||||
let self = this;
|
let self = this;
|
||||||
|
@ -1733,19 +1735,17 @@ class PostEditor {
|
||||||
notify.alert("Index cannot be deleted", false);
|
notify.alert("Index cannot be deleted", false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (confirm("AYE! You know you're deleting this post, right?")) {
|
if (confirm("AYE! You know you're deleting this post, right?")) new _pageActionsDefault.default().collectInfo(document.getElementById("featured-image-upload").files[0]).then((page)=>{
|
||||||
let id = {
|
|
||||||
id: this.postUUID
|
|
||||||
};
|
|
||||||
self.processing = true;
|
self.processing = true;
|
||||||
this.admin.pageActions(_fipamoAdminAPI.TASK_PAGE_DELETE, id).then(()=>{
|
this.admin.pageActions(_fipamoAdminAPI.TASK_PAGE_DELETE, page).then(()=>{
|
||||||
self.processing = false;
|
self.processing = false;
|
||||||
window.location = "/dashboard/pages";
|
window.location = "/dashboard/pages";
|
||||||
}).catch((err)=>{
|
}).catch((err)=>{
|
||||||
self.processing = false;
|
self.processing = false;
|
||||||
notify.alert(err, false);
|
notify.alert(err, false);
|
||||||
});
|
});
|
||||||
}
|
}).catch(()=>{
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case _editorEvent.EDITOR_UPLOAD_POST_IMAGE:
|
case _editorEvent.EDITOR_UPLOAD_POST_IMAGE:
|
||||||
document.getElementById("post-image-upload").click();
|
document.getElementById("post-image-upload").click();
|
||||||
|
@ -1995,6 +1995,7 @@ class TextEditor extends _eventEmitterDefault.default {
|
||||||
case _dataEvent.PAGE_ADDED:
|
case _dataEvent.PAGE_ADDED:
|
||||||
break;
|
break;
|
||||||
case _editorEvent.EDITOR_UPLOAD_POST_IMAGE:
|
case _editorEvent.EDITOR_UPLOAD_POST_IMAGE:
|
||||||
|
{
|
||||||
let len = this.textEditor.value.length;
|
let len = this.textEditor.value.length;
|
||||||
let start = this.textEditor.selectionStart;
|
let start = this.textEditor.selectionStart;
|
||||||
let end = this.textEditor.selectionEnd;
|
let end = this.textEditor.selectionEnd;
|
||||||
|
@ -2004,6 +2005,7 @@ class TextEditor extends _eventEmitterDefault.default {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// event handlers
|
// event handlers
|
||||||
//--------------------------
|
//--------------------------
|
||||||
handleEditorOption(e) {
|
handleEditorOption(e) {
|
||||||
|
@ -2039,10 +2041,12 @@ class TextEditor extends _eventEmitterDefault.default {
|
||||||
this.textEditor.value = this.textEditor.value.substring(0, start) + insert + this.textEditor.value.substring(end, len);
|
this.textEditor.value = this.textEditor.value.substring(0, start) + insert + this.textEditor.value.substring(end, len);
|
||||||
break;
|
break;
|
||||||
case "edit-link":
|
case "edit-link":
|
||||||
|
{
|
||||||
let url = prompt("Let's get that url, boss");
|
let url = prompt("Let's get that url, boss");
|
||||||
let link = url.toLowerCase();
|
let link = url.toLowerCase();
|
||||||
insert = "[" + selectedText + "](" + link + ")";
|
insert = "[" + selectedText + "](" + link + ")";
|
||||||
this.textEditor.value = this.textEditor.value.substring(0, start) + insert + this.textEditor.value.substring(end, len);
|
this.textEditor.value = this.textEditor.value.substring(0, start) + insert + this.textEditor.value.substring(end, len);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "edit-image":
|
case "edit-image":
|
||||||
this.caretPos = _caretPos.position(this.textEditor).pos;
|
this.caretPos = _caretPos.position(this.textEditor).pos;
|
||||||
|
|
|
@ -118,7 +118,7 @@ export default class PostEditor {
|
||||||
// event handlers
|
// event handlers
|
||||||
//--------------------------
|
//--------------------------
|
||||||
handlePostOptions(e) {
|
handlePostOptions(e) {
|
||||||
let currentOption;
|
let currentOption = null;
|
||||||
switch (e.target.id) {
|
switch (e.target.id) {
|
||||||
case "option-page-icon":
|
case "option-page-icon":
|
||||||
case "option-menu-pin":
|
case "option-menu-pin":
|
||||||
|
@ -133,11 +133,13 @@ export default class PostEditor {
|
||||||
currentOption = document.getElementById("option-published");
|
currentOption = document.getElementById("option-published");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (currentOption != null) {
|
||||||
let active = currentOption.getAttribute("data-active");
|
let active = currentOption.getAttribute("data-active");
|
||||||
active == "false"
|
active == "false"
|
||||||
? currentOption.setAttribute("data-active", "true")
|
? currentOption.setAttribute("data-active", "true")
|
||||||
: currentOption.setAttribute("data-active", "false");
|
: currentOption.setAttribute("data-active", "false");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
handleEditorOptions(e) {
|
handleEditorOptions(e) {
|
||||||
if (this.processing) return;
|
if (this.processing) return;
|
||||||
let self = this;
|
let self = this;
|
||||||
|
@ -185,10 +187,14 @@ export default class PostEditor {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
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 };
|
new PageActions()
|
||||||
|
.collectInfo(
|
||||||
|
document.getElementById("featured-image-upload").files[0]
|
||||||
|
)
|
||||||
|
.then((page) => {
|
||||||
self.processing = true;
|
self.processing = true;
|
||||||
this.admin
|
this.admin
|
||||||
.pageActions(TASK_PAGE_DELETE, id)
|
.pageActions(TASK_PAGE_DELETE, page)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
self.processing = false;
|
self.processing = false;
|
||||||
window.location = "/dashboard/pages";
|
window.location = "/dashboard/pages";
|
||||||
|
@ -197,6 +203,8 @@ export default class PostEditor {
|
||||||
self.processing = false;
|
self.processing = false;
|
||||||
notify.alert(err, false);
|
notify.alert(err, false);
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
} else {
|
} else {
|
||||||
// Do nothing!
|
// Do nothing!
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ class TextEditor extends EventEmitter {
|
||||||
case DataEvent.PAGE_ADDED:
|
case DataEvent.PAGE_ADDED:
|
||||||
// do nothing
|
// do nothing
|
||||||
break;
|
break;
|
||||||
case EditorEvent.EDITOR_UPLOAD_POST_IMAGE:
|
case EditorEvent.EDITOR_UPLOAD_POST_IMAGE: {
|
||||||
let len = this.textEditor.value.length;
|
let len = this.textEditor.value.length;
|
||||||
let start = this.textEditor.selectionStart;
|
let start = this.textEditor.selectionStart;
|
||||||
let end = this.textEditor.selectionEnd;
|
let end = this.textEditor.selectionEnd;
|
||||||
|
@ -103,6 +103,7 @@ class TextEditor extends EventEmitter {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// event handlers
|
// event handlers
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
@ -160,6 +161,7 @@ class TextEditor extends EventEmitter {
|
||||||
this.textEditor.value.substring(end, len);
|
this.textEditor.value.substring(end, len);
|
||||||
break;
|
break;
|
||||||
case "edit-link":
|
case "edit-link":
|
||||||
|
{
|
||||||
let url = prompt("Let's get that url, boss");
|
let url = prompt("Let's get that url, boss");
|
||||||
let link = url.toLowerCase();
|
let link = url.toLowerCase();
|
||||||
insert = "[" + selectedText + "](" + link + ")";
|
insert = "[" + selectedText + "](" + link + ")";
|
||||||
|
@ -167,6 +169,7 @@ class TextEditor extends EventEmitter {
|
||||||
this.textEditor.value.substring(0, start) +
|
this.textEditor.value.substring(0, start) +
|
||||||
insert +
|
insert +
|
||||||
this.textEditor.value.substring(end, len);
|
this.textEditor.value.substring(end, len);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "edit-image":
|
case "edit-image":
|
||||||
this.caretPos = position(this.textEditor).pos;
|
this.caretPos = position(this.textEditor).pos;
|
||||||
|
|
|
@ -248,7 +248,7 @@ class FipamoAdminAPI {
|
||||||
case TASK_PAGE_DELETE:
|
case TASK_PAGE_DELETE:
|
||||||
url = API_DELETE_PAGE;
|
url = API_DELETE_PAGE;
|
||||||
event = TASK_PAGE_DELETE;
|
event = TASK_PAGE_DELETE;
|
||||||
content = CONTENT_TYPE_JSON;
|
content = CONTENT_TYPE_FORM;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue