diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..8c96536 --- /dev/null +++ b/.babelrc @@ -0,0 +1,5 @@ +{ + "plugins":[ + "@babel/plugin-proposal-class-properties" + ] +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 6c3f9c9..9789606 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,6 @@ COPY . /app/ WORKDIR /app RUN node openimis-config.js RUN . ./modules-installs.txt -RUN yarn install +RUN yarn install --network-timeout 1000000 RUN yarn build RUN yarn global add serve \ No newline at end of file diff --git a/openimis-config.js b/openimis-config.js index 403d67e..193975b 100644 --- a/openimis-config.js +++ b/openimis-config.js @@ -9,7 +9,15 @@ function processLocales(config) { }, {} ); - locales.write(`export const locales = ${JSON.stringify(config['locales'].map((lc) => lc.intl))}\n`); + let filesByLang = config['locales'].reduce( + (fls, lc) => { + lc.languages.forEach((lg) => fls[lg] = lc.fileNames); + return fls + }, + {} + ); + locales.write(`export const locales = ${JSON.stringify(config['locales'].map((lc) => lc.intl))}`); + locales.write(`\nexport const fileNamesByLang = ${JSON.stringify(filesByLang)}`); locales.write(`\nexport default ${JSON.stringify(localeByLang)}`); } @@ -20,15 +28,16 @@ function processModules(config) { var modulesLinks = fs.createWriteStream('./modules-links.txt'); var modulesUnlinks = fs.createWriteStream('./modules-unlinks.txt'); + modulesInstalls.write('yarn add') config['modules'].forEach((module) => { let lib = module.npm.substring(0, module.npm.lastIndexOf('@')); srcModules.write(`import { ${module.name} } from '${lib}';\n`); - modulesInstalls.write(`yarn remove ${lib}\n`); - modulesInstalls.write(`yarn add ${module.npm}\n`); + modulesInstalls.write(` ${module.npm}`); modulesRemoves.write(`yarn remove ${lib}\n`); modulesLinks.write(`yarn link ${lib}\n`); modulesUnlinks.write(`yarn unlink ${lib}\n`); }); + modulesInstalls.write('\n') srcModules.write("\nfunction logicalName(npmName) {\n\t"); srcModules.write("return [...npmName.match(/([^/]*)\\/([^@]*).*/)][2];\n"); srcModules.write("}\n"); diff --git a/openimis.json b/openimis.json index e856305..60a98d4 100644 --- a/openimis.json +++ b/openimis.json @@ -1,45 +1,65 @@ { - "locales": [{"intl": "en-GB", "languages":["en"]}], + "locales": [ + { + "languages": [ + "en", "en-GB" + ], + "intl": "en-GB", + "fileNames": "en" + } + ], "modules": [ { "name": "CoreModule", - "npm": "@openimis/fe-core@0.0.12" + "npm": "@openimis/fe-core@0.0.27" }, { "name": "HomeModule", - "npm": "@openimis/fe-home@0.0.5" - }, + "npm": "@openimis/fe-home@0.0.11" + }, { "name": "LocationModule", - "npm": "@openimis/fe-location@0.0.3" - }, + "npm": "@openimis/fe-location@0.0.11" + }, { "name": "InsureeModule", - "npm": "@openimis/fe-insuree@0.0.8" + "npm": "@openimis/fe-insuree@0.0.17" }, { "name": "MedicalModule", - "npm": "@openimis/fe-medical@0.0.3" - }, + "npm": "@openimis/fe-medical@0.0.10" + }, + { + "name": "MedicalPriceListModule", + "npm": "@openimis/fe-medical_pricelist@0.0.3" + }, + { + "name": "ProductModule", + "npm": "@openimis/fe-product@0.0.5" + }, { "name": "PolicyModule", - "npm": "@openimis/fe-policy@0.0.6" - }, + "npm": "@openimis/fe-policy@0.0.13" + }, { "name": "ClaimModule", - "npm": "@openimis/fe-claim@0.0.8" + "npm": "@openimis/fe-claim@0.0.22" + }, + { + "name": "ClaimBatchModule", + "npm": "@openimis/fe-claim_batch@0.0.6" }, { "name": "AdminModule", - "npm": "@openimis/fe-admin@0.0.9" + "npm": "@openimis/fe-admin@0.0.16" }, { "name": "ToolsModule", - "npm": "@openimis/fe-tools@0.0.7" + "npm": "@openimis/fe-tools@0.0.13" }, { "name": "ProfileModule", - "npm": "@openimis/fe-profile@0.0.7" - } + "npm": "@openimis/fe-profile@0.0.12" + } ] -} +} \ No newline at end of file diff --git a/package.json b/package.json index a4cc066..26e153d 100644 --- a/package.json +++ b/package.json @@ -6,14 +6,19 @@ "homepage": "http://localhost/front", "dependencies": { "@babel/core": "^7.4.4", - "@babel/plugin-proposal-class-properties": "^7.4.4", - "@material-ui/core": "^4.1.2", + "@date-io/core": "^1.3.9", + "@date-io/moment": "^1.3.9", + "@material-ui/core": "^4.3.3", "@material-ui/icons": "^4.2.1", - "@openimis/fe-home": "0.0.2", + "@material-ui/pickers": "^3.2.2", "classnames": "^2.2.6", "express": "^4.16.4", "history": "^4.9.0", - "lodash": "^4.17.11", + "jquery": "^3.4.1", + "lodash": "^4.17.15", + "lodash-uuid": "^0.0.3", + "moment": "^2.24.0", + "nepali-date-picker": "^2.0.1", "prop-types": "^15.5.4", "react": "^16.8.6", "react-autosuggest": "^9.4.3", @@ -51,7 +56,8 @@ ] }, "devDependencies": { - "babel-cli": "^6.26.0", + "@babel/cli": "^7.4.4", + "@babel/plugin-proposal-class-properties": "^7.5.5", "react-app-rewired": "^2.1.3" } } diff --git a/public/index.html b/public/index.html index 83edeef..37ee5e2 100644 --- a/public/index.html +++ b/public/index.html @@ -34,5 +34,8 @@ To begin the development, run `npm start` or `yarn start`. To create a production bundle, use `npm run build` or `yarn build`. --> + + + diff --git a/src/HistoryProvider.js b/src/HistoryProvider.js new file mode 100644 index 0000000..8ba4900 --- /dev/null +++ b/src/HistoryProvider.js @@ -0,0 +1,19 @@ +import { Component, Children } from "react"; +import PropTypes from "prop-types"; + +class HistoryProvider extends Component { + static propTypes = { + history: PropTypes.object.isRequired, + } + static childContextTypes = { + history: PropTypes.object.isRequired, + } + getChildContext() { + const { history } = this.props + return { history } + } + render() { + return Children.only(this.props.children) + } +} +export default HistoryProvider \ No newline at end of file diff --git a/src/LocalesManager.js b/src/LocalesManager.js index 39bb32b..4ab381e 100644 --- a/src/LocalesManager.js +++ b/src/LocalesManager.js @@ -1,5 +1,5 @@ import { addLocaleData } from "react-intl"; -import localeByLang, { locales } from "./locales"; +import localeByLang, { locales, fileNamesByLang } from "./locales"; class LocalesManager { @@ -11,6 +11,10 @@ class LocalesManager { return localeByLang[lang]; } + getFileNameByLang(lang) { + return fileNamesByLang[lang]; + } + } export default LocalesManager; diff --git a/src/ModulesManager.js b/src/ModulesManager.js index ec808dd..fca5eae 100644 --- a/src/ModulesManager.js +++ b/src/ModulesManager.js @@ -8,24 +8,27 @@ class ModulesManager { this.modules = modules(cfg); this.contributionsCache = {}; this.controlsCache = this.buildControlsCache(); - this.componentsCache = this.buildComponentsCache(); + this.refsCache = this.buildRefsCache(); } buildControlsCache() { - let ctrls = {}; + const ctrls = {}; for (var k in this.cfg) { if (!!this.cfg[k].controls) { - this.cfg[k].controls.forEach(c => ctrls[c['fieldName']] = c['usage']); + for (var i in this.cfg[k].controls) { + var c = this.cfg[k].controls[i]; + ctrls[k+'.'+c['field']] = c['usage']; + } } } return ctrls; } - buildComponentsCache() { - return this.getContributions("components") - .reduce((comps, comp) => { - comps[comp.key] = comp.component; - return comps + buildRefsCache() { + return this.getContribs("refs") + .reduce((refs, r) => { + refs[r.key] = r.ref; + return refs }, {}); } @@ -37,19 +40,24 @@ class ModulesManager { return versions; } - skipControl(module, key) { - return this.controlsCache['fe-'+module+"."+key] === "S"; + hideField(module, key) { + return this.controlsCache['fe-'+module+"."+key] & 1; } - getComponent(key) { - return this.componentsCache[key]; + getRef(key) { + return this.refsCache[key]; } - getContributions(key) { + getProjection(key) { + const proj = this.getRef(key); + return !!proj ? `{${proj.join(", ")}}` : ""; + } + + getContribs(key) { if (this.contributionsCache[key]) { return this.contributionsCache[key]; } - let res = this.modules.reduce((contributions, module) => { + const res = this.modules.reduce((contributions, module) => { const contribs = (module || {})[key]; if (contribs) { contributions.push(...contribs); @@ -60,8 +68,8 @@ class ModulesManager { return res; } - getConfiguration(module, key, defaultValue = null) { - let moduleCfg = this.cfg[module] || {}; + getConf(module, key, defaultValue = null) { + const moduleCfg = this.cfg[module] || {}; return moduleCfg[key] !== undefined ? moduleCfg[key] : defaultValue; } } diff --git a/src/helpers/history.js b/src/helpers/history.js new file mode 100644 index 0000000..7bef5c9 --- /dev/null +++ b/src/helpers/history.js @@ -0,0 +1,2 @@ +import { createBrowserHistory } from "history"; +export default createBrowserHistory(); \ No newline at end of file diff --git a/src/helpers/theme.js b/src/helpers/theme.js index c0854b9..8411d70 100644 --- a/src/helpers/theme.js +++ b/src/helpers/theme.js @@ -1,15 +1,17 @@ import { createMuiTheme } from "@material-ui/core"; const theme = createMuiTheme({ - menu: { - variant: 'AppBar', - drawer: { - width: 300, - fontSize: 16, - }, - appBar: { - fontSize: 16, + palette: { + primary: { main: "#006273" }, + secondary: { main: "#fff" }, + error: { main: "#801a00" }, + text: { + primary: "#006273", + secondary: "#006273", // HACK FOR material-table hardcoded toolbar!, + second: "#fff", + error: "#801a00" }, + toggledButton: "#999999", }, typography: { useNextVariants: true, @@ -25,35 +27,95 @@ const theme = createMuiTheme({ color: "grey", }, }, + jrnlDrawer: { + open: { + width: 500, + }, + close: { + width: 80, + }, + iconSize: 24, + }, + menu: { + variant: 'AppBar', + drawer: { + width: 300, + fontSize: 16, + }, + appBar: { + fontSize: 16, + }, + }, paper: { + paper: { + margin: 10, + }, header: { padding: 10, + color: "#006273", }, title: { + padding: 10, fontSize: 24, color: "#006273", }, action: { - padding: 10, + }, divider: { padding: 0, margin: 0, }, + body: { + marginTop: 10, + }, + item: { + padding: 10, + } }, table: { title: { padding: 10, fontWeight: 500, - color: "grey", + color: "#006273", }, header: { color: "#006273", - align: "center", + }, + headerAction: { }, row: { color: "#006273", align: "center", + }, + highlightedRow: { + fontWeight: 500, + align: "center", + }, + highlightedAltRow: { + fontStyle: "italic", + align: "center", + }, + footer: { + color: "#006273", + }, + pager: { + color: "#006273", + }, + }, + form: { + spacing: 10, + }, + formTable: { + table: { + color: "#006273", + }, + actions: { + color: "#006273", + }, + header: { + color: "#006273", + align: "center", } }, dialog: { @@ -65,15 +127,11 @@ const theme = createMuiTheme({ padding: 0, } }, - palette: { - primary: { main: "#006273" }, - secondary: { main: "#fff" }, - error: { main: "#801a00" }, - text: { - primary: "#006273", - secondary: "#fff", - error: "#801a00" - } + fab: { + position: "absolute", + bottom: 20, + right: 8, + zIndex: 2000, }, bigAvatar: { margin: 10, diff --git a/src/index.js b/src/index.js index 7c247a3..d6279e0 100644 --- a/src/index.js +++ b/src/index.js @@ -2,7 +2,10 @@ import React from "react"; import ReactDOM from "react-dom"; import { MuiThemeProvider, LinearProgress } from "@material-ui/core"; import { Provider } from "react-redux"; +import MomentUtils from "@date-io/moment"; +import { MuiPickersUtilsProvider } from "@material-ui/pickers"; import * as serviceWorker from "./serviceWorker"; +import history from './helpers/history'; import theme from "./helpers/theme"; import store from "./helpers/store"; import LocalesManager from "./LocalesManager"; @@ -12,6 +15,7 @@ import { App, FatalError, baseApiUrl, apiHeaders } from "@openimis/fe-core"; import messages_ref from "./translations/ref.json"; import "./index.css"; import logo from "../public/openIMIS.png"; +import HistoryProvider from "./HistoryProvider"; const fatalError = (resp) => { const app = ( @@ -26,25 +30,29 @@ const fatalError = (resp) => { } const bootApp = (cfg) => { - const cfgs = cfg.data.coreModuleConfigurations.reduce((cfgs, c) => { - cfgs[c.module] = { controls: c.controls,...JSON.parse(c.config)}; - return cfgs + const cfgs = cfg.data.coreModuleConfigurations.reduce((cfgs, c) => { + cfgs[c.module] = { controls: c.controls, ...JSON.parse(c.config) }; + return cfgs }, []); const localesManager = new LocalesManager(); const modulesManager = new ModulesManager(cfgs); const reducers = modulesManager - .getContributions('reducers') + .getContribs('reducers') .reduce((reds, red) => { reds[red.key] = red.reducer; return reds }, []); const app = ( - - - + + + + + + + ); @@ -53,9 +61,9 @@ const bootApp = (cfg) => { -let payload = ` +const payload = ` { - coreModuleConfigurations { module, config, controls{fieldName, usage}} + coreModuleConfigurations { module, config, controls{field, usage}} } `; fetch(`${baseApiUrl}/graphql`, diff --git a/src/translations/ref.json b/src/translations/ref.json index 5b2f428..9532188 100644 --- a/src/translations/ref.json +++ b/src/translations/ref.json @@ -1,7 +1,35 @@ { "appName": "openIMIS", "close": "Close", - "apply": "Apply", - "searchCriteria.title": "Search Criteria", - "searchCriteria.dialog.title": "Adapt Search Criteria" + "ok": "Ok", + "cancel": "Cancel", + "currency": "$", + "rowsPerPage": "Rows Per Page", + "ofPages": "of", + "selectAll": "Select All", + "clearSelected": "Clear Selection", + "search.title": "Search Criteria", + "search.apply": "Apply", + "search.dialog.title": "Adapt Search Criteria", + "picker.close": "Close", + "picker.select": "Select", + "noRecord": "No Record To Display", + "row.actions": "Actions", + "row.delete": "Are you sure delete this row?", + "year": "Year", + "year.null": "Any", + "month": "Month", + "month.null": "Any", + "month.1": "January", + "month.2": "February", + "month.3": "March", + "month.4": "April", + "month.5": "May", + "month.6": "June", + "month.7": "Jully", + "month.8": "August", + "month.9": "September", + "month.10": "October", + "month.11": "November", + "month.12": "December" } \ No newline at end of file