Fixed Add Instrument functionality broken due to JS modularisation
This commit is contained in:
parent
42cffe2fae
commit
abc64d16a2
@ -207,20 +207,28 @@
|
||||
</script>
|
||||
<script type="module">
|
||||
import {
|
||||
addInstrument,
|
||||
createSharesTable,
|
||||
createSharesTableRow,
|
||||
getInstruments,
|
||||
redrawAllSharesCharts,
|
||||
refreshHistoryChart,
|
||||
searchForYahooInstrument,
|
||||
selectSearchResult,
|
||||
showModalDialog_AddInstrument,
|
||||
showModalDialog_AddHolding,
|
||||
showModalDialog_FullScreenChart,
|
||||
showModalDialog_SoldHolding
|
||||
} from "./scripts/SharePrices.js";
|
||||
importedFunctions = {
|
||||
addInstrument: addInstrument,
|
||||
createSharesTable: createSharesTable,
|
||||
createSharesTableRow: createSharesTableRow,
|
||||
getInstruments: getInstruments,
|
||||
redrawAllSharesCharts: redrawAllSharesCharts,
|
||||
refreshHistoryChart: refreshHistoryChart,
|
||||
searchForYahooInstrument: searchForYahooInstrument,
|
||||
selectSearchResult: selectSearchResult,
|
||||
showModalDialog_AddInstrument: showModalDialog_AddInstrument,
|
||||
showModalDialog_AddHolding: showModalDialog_AddHolding,
|
||||
showModalDialog_FullScreenChart: showModalDialog_FullScreenChart,
|
||||
|
@ -382,7 +382,7 @@ export function createSharesTable() {
|
||||
logError({ MSG: "Error in createSharesTable", err: err });
|
||||
}
|
||||
};
|
||||
function createSharesTableRow(instrument) {
|
||||
export function createSharesTableRow(instrument) {
|
||||
function getHoldingsTable(Instrument) {
|
||||
if (Instrument.Holdings.length > 0) {
|
||||
let totalUnits = 0;
|
||||
@ -1498,7 +1498,7 @@ export function showModalDialog_AddInstrument() {
|
||||
|
||||
$("#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>';
|
||||
$("#modalContentDiv").html(content);
|
||||
|
||||
@ -1515,7 +1515,7 @@ export function showModalDialog_AddInstrument() {
|
||||
//Display the dialog
|
||||
modal.style.display = "block";
|
||||
}
|
||||
function searchForYahooInstrument(searchString) {
|
||||
export function searchForYahooInstrument(searchString) {
|
||||
if (searchString.length > 1) {
|
||||
$.ajax({
|
||||
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>';
|
||||
for (let x = 0; x < instrumentSearchResults.length; 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.exchange + '</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++) {
|
||||
if (x == index) {
|
||||
$("#searchResult" + x.toString()).addClass('selectedSearchResult');
|
||||
@ -1552,9 +1552,9 @@ function selectSearchResult(index) {
|
||||
$("#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];
|
||||
console.info("Add instrument: " + JSON.stringify(i));
|
||||
$.ajax({
|
||||
|
Loading…
Reference in New Issue
Block a user