Fixed Add Instrument functionality broken due to JS modularisation
This commit is contained in:
parent
42cffe2fae
commit
abc64d16a2
@ -207,20 +207,28 @@
|
|||||||
</script>
|
</script>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import {
|
import {
|
||||||
|
addInstrument,
|
||||||
createSharesTable,
|
createSharesTable,
|
||||||
|
createSharesTableRow,
|
||||||
getInstruments,
|
getInstruments,
|
||||||
redrawAllSharesCharts,
|
redrawAllSharesCharts,
|
||||||
refreshHistoryChart,
|
refreshHistoryChart,
|
||||||
|
searchForYahooInstrument,
|
||||||
|
selectSearchResult,
|
||||||
showModalDialog_AddInstrument,
|
showModalDialog_AddInstrument,
|
||||||
showModalDialog_AddHolding,
|
showModalDialog_AddHolding,
|
||||||
showModalDialog_FullScreenChart,
|
showModalDialog_FullScreenChart,
|
||||||
showModalDialog_SoldHolding
|
showModalDialog_SoldHolding
|
||||||
} from "./scripts/SharePrices.js";
|
} from "./scripts/SharePrices.js";
|
||||||
importedFunctions = {
|
importedFunctions = {
|
||||||
|
addInstrument: addInstrument,
|
||||||
createSharesTable: createSharesTable,
|
createSharesTable: createSharesTable,
|
||||||
|
createSharesTableRow: createSharesTableRow,
|
||||||
getInstruments: getInstruments,
|
getInstruments: getInstruments,
|
||||||
redrawAllSharesCharts: redrawAllSharesCharts,
|
redrawAllSharesCharts: redrawAllSharesCharts,
|
||||||
refreshHistoryChart: refreshHistoryChart,
|
refreshHistoryChart: refreshHistoryChart,
|
||||||
|
searchForYahooInstrument: searchForYahooInstrument,
|
||||||
|
selectSearchResult: selectSearchResult,
|
||||||
showModalDialog_AddInstrument: showModalDialog_AddInstrument,
|
showModalDialog_AddInstrument: showModalDialog_AddInstrument,
|
||||||
showModalDialog_AddHolding: showModalDialog_AddHolding,
|
showModalDialog_AddHolding: showModalDialog_AddHolding,
|
||||||
showModalDialog_FullScreenChart: showModalDialog_FullScreenChart,
|
showModalDialog_FullScreenChart: showModalDialog_FullScreenChart,
|
||||||
|
@ -382,7 +382,7 @@ export function createSharesTable() {
|
|||||||
logError({ MSG: "Error in createSharesTable", err: err });
|
logError({ MSG: "Error in createSharesTable", err: err });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
function createSharesTableRow(instrument) {
|
export function createSharesTableRow(instrument) {
|
||||||
function getHoldingsTable(Instrument) {
|
function getHoldingsTable(Instrument) {
|
||||||
if (Instrument.Holdings.length > 0) {
|
if (Instrument.Holdings.length > 0) {
|
||||||
let totalUnits = 0;
|
let totalUnits = 0;
|
||||||
@ -1498,7 +1498,7 @@ export function showModalDialog_AddInstrument() {
|
|||||||
|
|
||||||
$("#modalTitle").html("Add Instrument");
|
$("#modalTitle").html("Add Instrument");
|
||||||
|
|
||||||
let content = '<div>Search text: <input type="text" oninput="searchForYahooInstrument(this.value)"/></div><br>' +
|
let content = '<div>Search text: <input type="text" oninput="importedFunctions.searchForYahooInstrument(this.value)"/></div><br>' +
|
||||||
'<div id="addInstrumentSearchResults"></div>';
|
'<div id="addInstrumentSearchResults"></div>';
|
||||||
$("#modalContentDiv").html(content);
|
$("#modalContentDiv").html(content);
|
||||||
|
|
||||||
@ -1515,7 +1515,7 @@ export function showModalDialog_AddInstrument() {
|
|||||||
//Display the dialog
|
//Display the dialog
|
||||||
modal.style.display = "block";
|
modal.style.display = "block";
|
||||||
}
|
}
|
||||||
function searchForYahooInstrument(searchString) {
|
export function searchForYahooInstrument(searchString) {
|
||||||
if (searchString.length > 1) {
|
if (searchString.length > 1) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@ -1530,7 +1530,7 @@ function searchForYahooInstrument(searchString) {
|
|||||||
results = '<table class="instrumentSearchResults"><tr><th>Symbol</th><th>Name</th><th>Exchange</th><th>Type</th></tr>';
|
results = '<table class="instrumentSearchResults"><tr><th>Symbol</th><th>Name</th><th>Exchange</th><th>Type</th></tr>';
|
||||||
for (let x = 0; x < instrumentSearchResults.length; x++) {
|
for (let x = 0; x < instrumentSearchResults.length; x++) {
|
||||||
let q = instrumentSearchResults[x];
|
let q = instrumentSearchResults[x];
|
||||||
results += '<tr id="searchResult' + x.toString() + '" onclick="selectSearchResult(' + x.toString() + ')"><td>' + q.symbol + '</td>' +
|
results += '<tr id="searchResult' + x.toString() + '" onclick="importedFunctions.selectSearchResult(' + x.toString() + ')"><td>' + q.symbol + '</td>' +
|
||||||
'<td>' + (q.longname ? q.longname : q.shortname) + '</td>' +
|
'<td>' + (q.longname ? q.longname : q.shortname) + '</td>' +
|
||||||
'<td>' + q.exchange + '</td>' +
|
'<td>' + q.exchange + '</td>' +
|
||||||
'<td>' + q.typeDisp + '</td>' +
|
'<td>' + q.typeDisp + '</td>' +
|
||||||
@ -1544,7 +1544,7 @@ function searchForYahooInstrument(searchString) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function selectSearchResult(index) {
|
export function selectSearchResult(index) {
|
||||||
for (let x = 0; x < instrumentSearchResults.length; x++) {
|
for (let x = 0; x < instrumentSearchResults.length; x++) {
|
||||||
if (x == index) {
|
if (x == index) {
|
||||||
$("#searchResult" + x.toString()).addClass('selectedSearchResult');
|
$("#searchResult" + x.toString()).addClass('selectedSearchResult');
|
||||||
@ -1552,9 +1552,9 @@ function selectSearchResult(index) {
|
|||||||
$("#searchResult" + x.toString()).removeClass('selectedSearchResult');
|
$("#searchResult" + x.toString()).removeClass('selectedSearchResult');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$("#addInstrumentOKButton").removeClass("ok-button-disabled").addClass("ok-button").unbind().click(function () { $("#modalDialog").css("display", "none"); addInstrument(index) });
|
$("#addInstrumentOKButton").removeClass("ok-button-disabled").addClass("ok-button").unbind().click(function () { $("#modalDialog").css("display", "none"); importedFunctions.addInstrument(index) });
|
||||||
}
|
}
|
||||||
function addInstrument(index) {
|
export function addInstrument(index) {
|
||||||
let i = instrumentSearchResults[index];
|
let i = instrumentSearchResults[index];
|
||||||
console.info("Add instrument: " + JSON.stringify(i));
|
console.info("Add instrument: " + JSON.stringify(i));
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
Loading…
Reference in New Issue
Block a user