index.js aktualisiert
parent
8ce0dfce1e
commit
4051e01463
35
index.js
35
index.js
|
|
@ -127,7 +127,8 @@ function addAccount(data) {
|
||||||
gadgets: gadgets
|
gadgets: gadgets
|
||||||
});
|
});
|
||||||
|
|
||||||
while (true) {
|
let indexOfNewAccount = -1;
|
||||||
|
while (true) {
|
||||||
var evt = gui.waitEvent(win);
|
var evt = gui.waitEvent(win);
|
||||||
if (!evt) continue;
|
if (!evt) continue;
|
||||||
|
|
||||||
|
|
@ -146,12 +147,15 @@ function addAccount(data) {
|
||||||
entries: []
|
entries: []
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
indexOfNewAccount = data.findIndex( p => p.name == newAccountName);
|
||||||
|
console.log(indexOfNewAccount);
|
||||||
gui.closeWindow(win);
|
gui.closeWindow(win);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return indexOfNewAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
function subWindow(data) {
|
function subWindow(data) {
|
||||||
|
|
@ -338,12 +342,17 @@ function mainWindow(projectData) {
|
||||||
let currentAccountIndex = 0;
|
let currentAccountIndex = 0;
|
||||||
|
|
||||||
let updateView = (accountIndex, data) => {
|
let updateView = (accountIndex, data) => {
|
||||||
|
if (accountIndex!=null) {
|
||||||
|
gui.set(win, cycleId, getAccounts(data));
|
||||||
|
gui.set(win, cycleId, accountIndex);
|
||||||
|
}else {
|
||||||
|
accountIndex = gui.get(win, cycleId);
|
||||||
|
}
|
||||||
gui.set(win, 2, toListViewEntries(data[accountIndex].entries, cols));
|
gui.set(win, 2, toListViewEntries(data[accountIndex].entries, cols));
|
||||||
gui.set(win, 3, getSummation(data[accountIndex].entries).toFixed(2));
|
gui.set(win, 3, getSummation(data[accountIndex].entries).toFixed(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
let doNew = () => {
|
let doNew = () => {
|
||||||
invalidate = true;
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
name: "Current",
|
name: "Current",
|
||||||
|
|
@ -357,7 +366,6 @@ function mainWindow(projectData) {
|
||||||
if (r) {
|
if (r) {
|
||||||
return JSON.parse(fs.readFileSync(r.file));
|
return JSON.parse(fs.readFileSync(r.file));
|
||||||
}
|
}
|
||||||
invalidate = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let doSave = () => {
|
let doSave = () => {
|
||||||
|
|
@ -382,25 +390,28 @@ function mainWindow(projectData) {
|
||||||
if (evt.type === 'menu') {
|
if (evt.type === 'menu') {
|
||||||
if (evt.id === 101) {
|
if (evt.id === 101) {
|
||||||
internalProjectData = doNew();
|
internalProjectData = doNew();
|
||||||
break;
|
updateView(0, internalProjectData);
|
||||||
}
|
}
|
||||||
else if (evt.id === 102) {
|
else if (evt.id === 102) {
|
||||||
internalProjectData = doOpen();
|
internalProjectData = doOpen();
|
||||||
break;
|
updateView(0, internalProjectData);
|
||||||
}
|
}
|
||||||
else if (evt.id === 103) {
|
else if (evt.id === 103) {
|
||||||
doSave();
|
doSave();
|
||||||
}
|
}
|
||||||
else if (evt.id === 104) {
|
else if (evt.id === 104) {
|
||||||
addAccount(internalProjectData);
|
let indexOfNewAccount = addAccount(internalProjectData);
|
||||||
invalidate = true;
|
if (indexOfNewAccount > -1) {
|
||||||
|
currentAccountIndex = indexOfNewAccount;
|
||||||
|
}
|
||||||
|
updateView(currentAccountIndex, internalProjectData);
|
||||||
}
|
}
|
||||||
else if (evt.id === 105) {
|
else if (evt.id === 105) {
|
||||||
if (internalProjectData.length > 1) {
|
if (internalProjectData.length > 1) {
|
||||||
const rValue = closeAccount(internalProjectData, internalProjectData[currentAccountIndex]);
|
const rValue = closeAccount(internalProjectData, internalProjectData[currentAccountIndex]);
|
||||||
if (rValue === -1) {
|
if (rValue === -1) {
|
||||||
internalProjectData.splice(currentAccountIndex, 1);
|
internalProjectData.splice(currentAccountIndex, 1);
|
||||||
invalidate = true;
|
updateView(0, internalProjectData);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
gui.alert("Cannot close last remaining Account");
|
gui.alert("Cannot close last remaining Account");
|
||||||
|
|
@ -417,7 +428,7 @@ function mainWindow(projectData) {
|
||||||
|
|
||||||
if (evt.id === cycleId) {
|
if (evt.id === cycleId) {
|
||||||
currentAccountIndex = evt.code;
|
currentAccountIndex = evt.code;
|
||||||
updateView(currentAccountIndex, internalProjectData);
|
updateView(null, internalProjectData);
|
||||||
} else if (evt.id === listViewId) {
|
} else if (evt.id === listViewId) {
|
||||||
const entry = subWindow(internalProjectData[currentAccountIndex].entries[evt.code]);
|
const entry = subWindow(internalProjectData[currentAccountIndex].entries[evt.code]);
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
|
|
@ -461,7 +472,6 @@ function mainWindow(projectData) {
|
||||||
|
|
||||||
|
|
||||||
gui.closeWindow(win);
|
gui.closeWindow(win);
|
||||||
return internalProjectData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -506,7 +516,4 @@ function mainWindow(projectData) {
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
do {
|
mainWindow(projectData);
|
||||||
projectData = mainWindow(projectData);
|
|
||||||
} while(projectData != null);
|
|
||||||
console.log("bye!");
|
|
||||||
Loading…
Reference in New Issue