Skip to content

Commit

Permalink
Merge branch 'develop' into OMT-232_pricelist_filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
xgill authored Aug 6, 2020
2 parents 531fcc6 + 0355c81 commit 7a6d853
Show file tree
Hide file tree
Showing 20 changed files with 2,009 additions and 9,152 deletions.
11 changes: 7 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"presets": [
["env", {
["@babel/preset-env", {
"modules": false
}],
"stage-0",
"react"
["@babel/preset-react"]
],
"plugins": [
"@babel/plugin-transform-runtime",
"@babel/plugin-proposal-class-properties"
]
}
}
50 changes: 50 additions & 0 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Node.js Package

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
- run: yarn install
- run: yarn build

publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
scope: openimis
- run: yarn install
- run: yarn build
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

publish-gpr:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://npm.pkg.github.com/
- run: yarn install
- run: yarn build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
95 changes: 22 additions & 73 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,95 +1,44 @@
{
"name": "@openimis/fe-claim",
"version": "1.1.5",
"version": "1.2.0-rc4",
"license": "AGPL-3.0-only",
"description": "openIMIS Frontend Claim reference module",
"repository": "openimis/openimis-fe-claim_js",
"main": "dist/index.js",
"module": "dist/index.es.js",
"jsnext:main": "dist/index.es.js",
"engines": {
"node": ">=8",
"npm": ">=5"
},
"scripts": {
"test": "cross-env CI=1 react-scripts test --env=jsdom",
"test:watch": "react-scripts test --env=jsdom",
"build": "rollup -c",
"start": "rollup -c -w",
"prepare": "yarn run build",
"predeploy": "cd example && yarn install && yarn run build",
"deploy": "gh-pages -d example/build"
},
"peerDependencies": {
"@material-ui/core": "^4.3.3",
"@material-ui/icons": "^4.2.1",
"@material-ui/pickers": "^3.2.2",
"@openimis/fe-core": ">=1.1.3",
"react-autosuggest": "^9.4.3",
"history": "^4.9.0",
"lodash": "^4.17.15",
"lodash-uuid": "^0.0.3",
"moment": "^2.24.0",
"prop-types": "^15.5.4",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-intl": "^2.9.0",
"react-redux": "^7.0.3",
"react-router": "^5.0.0",
"react-router-dom": "^5.0.0",
"redux": "^4.0.1",
"redux-api-middleware": "^3.0.1",
"redux-thunk": "^2.3.0"
"start": "rollup -c -w"
},
"devDependencies": {
"@material-ui/core": "^4.3.3",
"@material-ui/icons": "^4.2.1",
"@material-ui/pickers": "^3.2.2",
"@openimis/fe-core": ">=1.1.3",
"react-autosuggest": "^9.4.3",
"@svgr/rollup": "^2.4.1",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.5",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"cross-env": "^5.1.4",
"eslint": "^6.5.1",
"eslint-config-standard": "^14.1.0",
"eslint-config-standard-react": "^9.2.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.15.0",
"eslint-plugin-standard": "^4.0.1",
"gh-pages": "^1.2.0",
"history": "^4.9.0",
"lodash": "^4.17.15",
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.6",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.9.6",
"@babel/preset-env": "^7.9.6",
"@babel/preset-react": "^7.9.4",
"@babel/runtime": "^7.9.6",
"@rollup/plugin-babel": "^5.0.0",
"@rollup/plugin-commonjs": "^11.1.0",
"@rollup/plugin-json": "^4.0.3",
"@rollup/plugin-node-resolve": "^7.1.3",
"@rollup/plugin-url": "^5.0.0",
"lodash-uuid": "^0.0.3",
"moment": "^2.24.0",
"prop-types": "^15.5.4",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"moment": "^2.25.3",
"prop-types": "^15.7.2",
"react-autosuggest": "^10.0.2",
"react-intl": "^2.9.0",
"react-redux": "^7.0.3",
"react-router": "^5.0.0",
"react-router-dom": "^5.0.0",
"react-scripts": "^1.1.4",
"redux": "^4.0.1",
"redux-api-middleware": "^3.0.1",
"redux-thunk": "^2.3.0",
"rollup": "^0.64.1",
"rollup-plugin-babel": "^3.0.7",
"rollup-plugin-commonjs": "^9.1.3",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^3.3.0",
"rollup-plugin-peer-deps-external": "^2.2.0",
"rollup-plugin-postcss": "^1.6.2",
"rollup-plugin-url": "^1.4.0"
"react-router-dom": "^5.2.0",
"redux": "^4.0.5",
"redux-api-middleware": "^3.2.1",
"rollup": "^2.10.0"
},
"files": [
"dist"
],
"dependencies": {}
}
}
45 changes: 22 additions & 23 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
import babel from 'rollup-plugin-babel'
import commonjs from 'rollup-plugin-commonjs'
import external from 'rollup-plugin-peer-deps-external'
import postcss from 'rollup-plugin-postcss'
import resolve from 'rollup-plugin-node-resolve'
import url from 'rollup-plugin-url'
import json from 'rollup-plugin-json'
import svgr from '@svgr/rollup'

import babel from '@rollup/plugin-babel'
import json from '@rollup/plugin-json'
import pkg from './package.json'

export default {
input: 'src/index.js',
output: [
{
file: pkg.main,
format: 'cjs',
file: pkg.module,
format: 'es',
sourcemap: true
},
{
file: pkg.module,
format: 'es',
file: 'dist/index.js',
format: 'cjs',
sourcemap: true
}
],
external: [
/^@babel.*/,
/^@date-io\/.*/,
/^@material-ui\/.*/,
/^@openimis.*/,
"classnames",
"clsx",
"history",
/^lodash.*/,
"moment",
"prop-types",
/^react.*/,
/^redux.*/
],
plugins: [
json(),
external(),
postcss({
modules: true
}),
url(),
svgr(),
babel({
exclude: 'node_modules/**',
plugins: [ 'external-helpers' ]
babelHelpers: 'runtime'
}),
resolve(),
commonjs()
]
}
}
27 changes: 17 additions & 10 deletions src/components/AttachmentsDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ class AttachmentsDialog extends Component {
}
this.setState({ claimAttachments, updatedAttachments: new Set() });
} else if (!_.isEqual(prevProps.claim, this.props.claim) && !!this.props.claim && !!this.props.claim.uuid) {
this.setState({ open: true, claimUuid: this.props.claim.uuid, claimAttachments: readOnly ? [] : [{}], updatedAttachments: new Set() },
this.setState((state, props) => ({
open: true,
claimUuid: props.claim.uuid,
claimAttachments: readOnly ? [] : [{}],
updatedAttachments: new Set()
}),
e => {
if (!!this.props.claim && !!this.props.claim.uuid) {
this.props.fetchClaimAttachments(this.props.claim);
Expand All @@ -64,13 +69,13 @@ class AttachmentsDialog extends Component {
} else if (!_.isEqual(_.last(claimAttachments), {})) {
claimAttachments.push({})
}
this.setState(
{
this.setState((state) =>
({
claimAttachments,
updatedAttachments: new Set(),
attachmentToDelete: null,
reset: this.state.reset + 1
}
reset: state.reset + 1
})
)
// called from ClaimForm!
// this.props.journalize(this.props.mutation);
Expand Down Expand Up @@ -104,7 +109,7 @@ class AttachmentsDialog extends Component {
claimAttachments.pop()
this.props.claim.attachments = [...claimAttachments]
claimAttachments.push({})
this.setState({ claimAttachments, reset: this.state.reset + 1 })
this.setState((state) => ({ claimAttachments, reset: state.reset + 1 }))
}
}

Expand Down Expand Up @@ -179,9 +184,11 @@ class AttachmentsDialog extends Component {
}

updateAttachment = (i, key, value) => {
this.state.claimAttachments[i][key] = value;
this.state.updatedAttachments.add(i)
this.setState({ reset: this.state.reset + 1 })
var state = { ...this.state };
state.claimAttachments[i][key] = value;
state.updatedAttachments.add(i);
state.reset = state.reset + 1;
this.setState({ ...state })
}

cannotUpdate = (a, i) => i < this.state.claimAttachments.length - 1 && !!this.state.claimUuid && !a.id
Expand Down Expand Up @@ -212,7 +219,7 @@ class AttachmentsDialog extends Component {
/>),
(a, i) => this.cannotUpdate(a, i) ? this.state.claimAttachments[i].date : (
<PublishedComponent
id="core.DatePicker"
pubRef="core.DatePicker"
onChange={v => this.updateAttachment(i, "date", v)}
value={this.state.claimAttachments[i].date || null}
reset={this.state.reset} />
Expand Down
26 changes: 12 additions & 14 deletions src/components/ClaimChildPanel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component, Fragment } from "react";
import React, { Component } from "react";
import { connect } from "react-redux";
import { injectIntl } from 'react-intl';
import { withTheme, withStyles } from "@material-ui/core/styles";
Expand Down Expand Up @@ -60,9 +60,9 @@ class ClaimChildPanel extends Component {
}
}

_updateData = (idx, attr, v) => {
_updateData = (idx, updates) => {
const data = [...this.state.data];
data[idx][attr] = v;
updates.forEach(update => data[idx][update.attr] = update.v);
if (!this.props.forReview && data.length === (idx + 1)) {
data.push({});
}
Expand All @@ -76,7 +76,7 @@ class ClaimChildPanel extends Component {
}

_onChange = (idx, attr, v) => {
let data = this._updateData(idx, attr, v);
let data = this._updateData(idx, [{ attr, v }]);
this._onEditedChanged(data);
}

Expand All @@ -86,7 +86,7 @@ class ClaimChildPanel extends Component {
}

_onChangeItem = (idx, attr, v) => {
let data = this._updateData(idx, attr, v);
let data = this._updateData(idx, [{ attr, v }]);
if (!v) {
data[idx].priceAsked = null;
data[idx].qtyProvided = null
Expand All @@ -109,7 +109,7 @@ class ClaimChildPanel extends Component {
if (i.status === 1) return null;
return <PublishedComponent
readOnly={true}
id="claim.RejectionReasonPicker"
pubRef="claim.RejectionReasonPicker"
withLabel={false}
value={i.rejectionReason || null}
compact={true}
Expand All @@ -118,12 +118,10 @@ class ClaimChildPanel extends Component {
}

_onChangeApproval = (idx, attr, v) => {
let data = this._updateData(idx, attr, v);
if (v === 2) {
data = this._updateData(idx, 'rejectionReason', -1);
} else {
data = this._updateData(idx, 'rejectionReason', null);
}
let data = this._updateData(idx, [
{ attr, v },
{ attr: 'rejectionReason', v: v === 2 ? -1 : null }
]);
this._onEditedChanged(data);
}

Expand Down Expand Up @@ -164,7 +162,7 @@ class ClaimChildPanel extends Component {
let itemFormatters = [
(i, idx) => <PublishedComponent
readOnly={!!forReview || readOnly}
id={picker} withLabel={false} value={i[type]}
pubRef={picker} withLabel={false} value={i[type]}
filteredOnPriceList={edited.healthFacility[`${this.props.type}sPricelist`].id}
refDate={edited.dateClaimed}
onChange={v => this._onChangeItem(idx, type, v)}
Expand Down Expand Up @@ -233,7 +231,7 @@ class ClaimChildPanel extends Component {
itemFormatters.push(
(i, idx) => <PublishedComponent
readOnly={readOnly}
id="claim.ApprovalStatusPicker"
pubRef="claim.ApprovalStatusPicker"
withNull={false}
withLabel={false}
value={i.status}
Expand Down
Loading

0 comments on commit 7a6d853

Please sign in to comment.