fixes for nav editing
parent
d7c5fb7a70
commit
b230f3f15d
File diff suppressed because it is too large
Load Diff
@ -1,73 +1,74 @@
|
|||||||
import FipamoAdminAPI, { TASK_SYNC_NAV } from "../../libraries/FipamoAdminAPI";
|
import FipamoAdminAPI, { TASK_SYNC_NAV } from '../../libraries/FipamoAdminAPI';
|
||||||
import NavActions from "../actions/NavActions";
|
import NavActions from '../actions/NavActions';
|
||||||
import * as DataEvent from "../events/DataEvent";
|
import * as DataEvent from '../events/DataEvent';
|
||||||
import Notifications from "../ui/Notifications";
|
import Notifications from '../ui/Notifications';
|
||||||
import Sortable from "sortablejs";
|
import Sortable from 'sortablejs';
|
||||||
const notify = new Notifications();
|
const notify = new Notifications();
|
||||||
|
|
||||||
export default class NavIndex {
|
export default class NavIndex {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// constructor
|
// constructor
|
||||||
//--------------------------
|
//--------------------------
|
||||||
constructor() {
|
constructor() {
|
||||||
this.processing = false;
|
this.processing = false;
|
||||||
this.admin = new FipamoAdminAPI(null);
|
this.admin = new FipamoAdminAPI(null);
|
||||||
this.start();
|
this.start();
|
||||||
}
|
}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// methods
|
// methods
|
||||||
//--------------------------
|
//--------------------------
|
||||||
start() {
|
start() {
|
||||||
let self = this;
|
//grabs elements and makes them sortables
|
||||||
Sortable.create(document.getElementById("nav-pages"), {
|
let self = this;
|
||||||
onUpdate: () => {
|
Sortable.create(document.getElementById('nav-pages'), {
|
||||||
new NavActions().syncMenu().then((data) => {
|
onUpdate: () => {
|
||||||
notify.alert("Updating Menu", null);
|
new NavActions().syncMenu().then(data => {
|
||||||
self.admin.sync(TASK_SYNC_NAV, data).then((r) => {
|
notify.alert('Updating Menu', null);
|
||||||
if (r.type == DataEvent.MENU_UPDATED) {
|
self.admin.sync(TASK_SYNC_NAV, data).then(r => {
|
||||||
notify.alert(r.message, true);
|
if (r.type == DataEvent.MENU_UPDATED) {
|
||||||
} else {
|
notify.alert(r.message, true);
|
||||||
notify.alert(r.message, true);
|
} else {
|
||||||
}
|
notify.alert(r.message, true);
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
var nav = document.querySelectorAll(".nav-btn");
|
});
|
||||||
for (var i = 0, length = nav.length; i < length; i++) {
|
var nav = document.querySelectorAll('.nav-btn');
|
||||||
nav[i].addEventListener("click", (e) => this.handleNavButton(e), false);
|
for (var i = 0, length = nav.length; i < length; i++) {
|
||||||
}
|
nav[i].addEventListener('click', e => this.handleNavButton(e), false);
|
||||||
}
|
}
|
||||||
//--------------------------
|
}
|
||||||
// event handlers
|
//--------------------------
|
||||||
//--------------------------
|
// event handlers
|
||||||
handleNavButton(e) {
|
//--------------------------
|
||||||
if (this.processing) return;
|
handleNavButton(e) {
|
||||||
let id = "";
|
if (this.processing) return;
|
||||||
let self = this;
|
let id = '';
|
||||||
switch (e.target.id) {
|
let self = this;
|
||||||
case "remove-item":
|
switch (e.target.id) {
|
||||||
id = e.target.getAttribute("data-id");
|
case 'remove-item':
|
||||||
new NavActions().removeItem(id);
|
id = e.target.getAttribute('data-id');
|
||||||
new NavActions().syncMenu().then((data) => {
|
new NavActions().removeItem(id);
|
||||||
data.remove = e.target.getAttribute("data-uuid");
|
new NavActions().syncMenu().then(data => {
|
||||||
notify.alert("Editing Menu", null);
|
data.remove = e.target.getAttribute('data-uuid');
|
||||||
self.processing = true;
|
notify.alert('Editing Menu', null);
|
||||||
self.admin.syncNav(data).then((r) => {
|
self.processing = true;
|
||||||
self.processing = false;
|
self.admin.sync(TASK_SYNC_NAV, data).then(r => {
|
||||||
if (r.type == DataEvent.MENU_UPDATED) {
|
self.processing = false;
|
||||||
notify.alert(r.message, true);
|
if (r.type == DataEvent.MENU_UPDATED) {
|
||||||
} else {
|
notify.alert(r.message, true);
|
||||||
notify.alert(r.message, true);
|
} else {
|
||||||
}
|
notify.alert(r.message, true);
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
break;
|
});
|
||||||
case "edit-item":
|
break;
|
||||||
self.processing = false;
|
case 'edit-item':
|
||||||
window.location =
|
self.processing = false;
|
||||||
"/dashboard/page/edit/" + e.target.getAttribute("data-id");
|
window.location =
|
||||||
break;
|
'/dashboard/page/edit/' + e.target.getAttribute('data-id');
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue