Skip to content

Commit

Permalink
Typescript update
Browse files Browse the repository at this point in the history
  • Loading branch information
grassick committed Mar 8, 2022
1 parent e5cb45e commit 3ade64d
Show file tree
Hide file tree
Showing 61 changed files with 559 additions and 547 deletions.
1 change: 0 additions & 1 deletion lib/CalculationsDisplayComponent.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference types="react" />
import { FormDesign } from "./formDesign";
import { Schema } from "mwater-expressions";
import ResponseRow from "./ResponseRow";
Expand Down
21 changes: 13 additions & 8 deletions lib/CalculationsDisplayComponent.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand All @@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Expand All @@ -33,17 +37,17 @@ const react_1 = __importStar(require("react"));
const formUtils_1 = require("./formUtils");
const mwater_expressions_1 = require("mwater-expressions");
/** Displays calculation values for a response. Only displays root level calculations, not roster ones. */
exports.CalculationsDisplayComponent = (props) => {
const [values, setValues] = react_1.useState([]);
const CalculationsDisplayComponent = (props) => {
const [values, setValues] = (0, react_1.useState)([]);
// Create evaluator
const exprEvaluator = react_1.useMemo(() => {
const exprEvaluator = (0, react_1.useMemo)(() => {
return new mwater_expressions_1.PromiseExprEvaluator({
schema: props.schema,
locale: props.locale
});
}, [props.schema, props.locale]);
// Evaluate calculation values
react_1.useEffect(() => {
(0, react_1.useEffect)(() => {
;
(function performCalcs() {
return __awaiter(this, void 0, void 0, function* () {
Expand All @@ -58,10 +62,10 @@ exports.CalculationsDisplayComponent = (props) => {
const renderCalc = (calc, index) => {
return (react_1.default.createElement("tr", { key: calc._id },
react_1.default.createElement("td", { style: { width: "50%" } },
formUtils_1.localizeString(calc.name, props.locale),
(0, formUtils_1.localizeString)(calc.name, props.locale),
calc.desc ? react_1.default.createElement("span", { className: "text-muted" },
" - ",
formUtils_1.localizeString(calc.desc, props.locale)) : null),
(0, formUtils_1.localizeString)(calc.desc, props.locale)) : null),
react_1.default.createElement("td", null, values.length > 0 ? values[index] : null)));
};
return (react_1.default.createElement("table", { className: "table table-bordered table-sm" },
Expand All @@ -71,3 +75,4 @@ exports.CalculationsDisplayComponent = (props) => {
react_1.default.createElement("th", null, "Value"))),
react_1.default.createElement("tbody", null, props.formDesign.calculations.filter((calc) => !calc.roster).map((calc, index) => renderCalc(calc, index)))));
};
exports.CalculationsDisplayComponent = CalculationsDisplayComponent;
8 changes: 6 additions & 2 deletions lib/ConditionsExprCompiler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand All @@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Expand Down
6 changes: 3 additions & 3 deletions lib/CurrentPositionFinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class CurrentPositionFinder {
constructor(options) {
this.locationFinderFound = (pos) => {
// Calculate strength of new position
const newStrength = utils_1.calculateGPSStrength(pos);
const newStrength = (0, utils_1.calculateGPSStrength)(pos);
// If none, do nothing
if (newStrength === "none") {
return;
Expand All @@ -20,7 +20,7 @@ class CurrentPositionFinder {
this.pos = pos;
}
// Start good delay if needed
if (!this.goodDelayInterval && utils_1.calculateGPSStrength(this.pos) === "good") {
if (!this.goodDelayInterval && (0, utils_1.calculateGPSStrength)(this.pos) === "good") {
this.goodDelayLeft = goodDelay;
// Start good delay countdown
this.goodDelayInterval = window.setInterval(() => {
Expand Down Expand Up @@ -109,7 +109,7 @@ class CurrentPositionFinder {
this.pos = null;
}
updateStatus() {
this.strength = utils_1.calculateGPSStrength(this.pos);
this.strength = (0, utils_1.calculateGPSStrength)(this.pos);
const useable = (this.initialDelayLeft <= 0 && ["fair", "poor"].includes(this.strength)) || this.strength === "good";
// Trigger status
this.eventEmitter.emit("status", {
Expand Down
4 changes: 2 additions & 2 deletions lib/CustomTablesetSchemaBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class CustomTablesetSchemaBuilder {
// Create table
schema = schema.addTable(schemaTable);
// Add reverse joins to entities (if not already present)
for (const column of mwater_expressions_1.flattenContents(contents)) {
for (const column of (0, mwater_expressions_1.flattenContents)(contents)) {
if (column.type == "id" && column.idTable.match(/^entities\./)) {
const otherTable = schema.getTable(column.idTable);
if (otherTable) {
Expand All @@ -102,7 +102,7 @@ class CustomTablesetSchemaBuilder {
}
};
if (schema.getColumn(otherTable.id, reverseColumn.id) == null) {
schema = schema.addTable(immer_1.default(otherTable, (draft) => {
schema = schema.addTable((0, immer_1.default)(otherTable, (draft) => {
draft.contents.push(reverseColumn);
}));
}
Expand Down
10 changes: 5 additions & 5 deletions lib/DateTimePickerComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class DateTimePickerComponent extends react_1.default.Component {
if (elem) {
this.control = new tempus_dominus_1.TempusDominus(elem, {
hooks: {
inputFormat: (context, date) => { return date ? moment_1.default(date).format(format) : ""; },
inputFormat: (context, date) => { return date ? (0, moment_1.default)(date).format(format) : ""; },
inputParse: (context, value) => {
const parsedValue = moment_1.default(value, format);
const parsedValue = (0, moment_1.default)(value, format);
if (parsedValue.isValid()) {
return new tempus_dominus_1.DateTime(parsedValue.toDate());
}
Expand Down Expand Up @@ -45,7 +45,7 @@ class DateTimePickerComponent extends react_1.default.Component {
}
});
this.control.subscribe(tempus_dominus_1.Namespace.events.change, e => {
this.props.onChange(e.date ? moment_1.default(e.date) : null);
this.props.onChange(e.date ? (0, moment_1.default)(e.date) : null);
});
}
else {
Expand All @@ -66,7 +66,7 @@ class DateTimePickerComponent extends react_1.default.Component {
return;
}
// If changed
const current = this.control.dates.lastPicked ? moment_1.default(this.control.dates.lastPicked) : null;
const current = this.control.dates.lastPicked ? (0, moment_1.default)(this.control.dates.lastPicked) : null;
if (current && !this.props.date ||
!current && this.props.date ||
(current && this.props.date && !current.isSame(this.props.date))) {
Expand All @@ -82,7 +82,7 @@ class DateTimePickerComponent extends react_1.default.Component {
}
}
render() {
const defaultValue = this.props.date ? moment_1.default(this.props.date).format(this.getFormat()) : "";
const defaultValue = this.props.date ? (0, moment_1.default)(this.props.date).format(this.getFormat()) : "";
return (react_1.default.createElement("div", { className: "input-group", ref: this.inputRef },
react_1.default.createElement("input", { type: "text", className: "form-control", placeholder: this.props.placeholder, defaultValue: defaultValue, ref: c => { this.textRef = c; } }),
react_1.default.createElement("span", { className: "input-group-text" },
Expand Down
10 changes: 7 additions & 3 deletions lib/DefaultValueApplier.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand All @@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Expand Down Expand Up @@ -155,7 +159,7 @@ class DefaultValueApplier {
return new Date().toISOString();
}
else {
return moment_1.default().format("YYYY-MM-DD");
return (0, moment_1.default)().format("YYYY-MM-DD");
}
}
return question.defaultValue;
Expand Down
8 changes: 6 additions & 2 deletions lib/EntitySchemaBuilder.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand All @@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Expand Down
8 changes: 6 additions & 2 deletions lib/FormComponent.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand All @@ -14,7 +18,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Expand Down
Loading

0 comments on commit 3ade64d

Please sign in to comment.