Fix service navigation button sorted in wrong order when editing service
This commit is contained in:
parent
03f275e6e8
commit
05acd44e98
@ -212,13 +212,15 @@ ipcRenderer.on('data', (event, appData, iconSets, actualSelectedService, emptyUr
|
|||||||
document.documentElement.style.setProperty('--nav-width', config.bigNavBar ? '64px' : '48px');
|
document.documentElement.style.setProperty('--nav-width', config.bigNavBar ? '64px' : '48px');
|
||||||
});
|
});
|
||||||
|
|
||||||
function removeServiceFeatures(id: number): HTMLElement | null {
|
function removeServiceFeatures(id: number): Element | null {
|
||||||
// Remove nav
|
// Remove nav
|
||||||
const nav = document.querySelector('#service-selector');
|
const nav = document.querySelector('#service-selector');
|
||||||
let oldNavButton: HTMLElement | null = null;
|
let oldNavButton: HTMLElement | null = null;
|
||||||
|
let nextSibling: Element | null = null;
|
||||||
if (nav) {
|
if (nav) {
|
||||||
oldNavButton = nav.querySelector('li:nth-of-type(' + (id + 1) + ')');
|
oldNavButton = nav.querySelector('li:nth-of-type(' + (id + 1) + ')');
|
||||||
if (oldNavButton) {
|
if (oldNavButton) {
|
||||||
|
nextSibling = oldNavButton.nextElementSibling;
|
||||||
nav.removeChild(oldNavButton);
|
nav.removeChild(oldNavButton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -228,19 +230,21 @@ function removeServiceFeatures(id: number): HTMLElement | null {
|
|||||||
document.querySelector('#services')?.removeChild(services[id].view);
|
document.querySelector('#services')?.removeChild(services[id].view);
|
||||||
}
|
}
|
||||||
|
|
||||||
return oldNavButton;
|
return nextSibling;
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcRenderer.on('updateService', (e, id, data) => {
|
ipcRenderer.on('updateService', (e, id, data) => {
|
||||||
if (id === null) {
|
if (id === null) {
|
||||||
|
console.log('Adding new service');
|
||||||
services.push(data);
|
services.push(data);
|
||||||
createService(services.length - 1);
|
createService(services.length - 1);
|
||||||
} else {
|
} else {
|
||||||
const oldNavButton = removeServiceFeatures(id);
|
console.log('Updating existing service', id);
|
||||||
|
const nextSibling = removeServiceFeatures(id);
|
||||||
|
|
||||||
// Create new service
|
// Create new service
|
||||||
services[id] = data;
|
services[id] = data;
|
||||||
createService(id, oldNavButton ? oldNavButton.nextElementSibling : null);
|
createService(id, nextSibling);
|
||||||
if (parseInt(selectedService) === id) {
|
if (parseInt(selectedService) === id) {
|
||||||
setActiveService(id);
|
setActiveService(id);
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ function save() {
|
|||||||
|
|
||||||
ipcRenderer.send('saveService', serviceId, service);
|
ipcRenderer.send('saveService', serviceId, service);
|
||||||
remote.getCurrentWindow().close();
|
remote.getCurrentWindow().close();
|
||||||
};
|
}
|
||||||
|
|
||||||
function isValid() {
|
function isValid() {
|
||||||
if (typeof service.name !== 'string' || service.name.length === 0) {
|
if (typeof service.name !== 'string' || service.name.length === 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user