Skip to content

Commit

Permalink
Merge pull request #13 from openimis/hotfix/OMT-225-EnableClaimExtens…
Browse files Browse the repository at this point in the history
…ions

extension via JSON - v2
  • Loading branch information
xgill committed Jun 25, 2020
2 parents 25a8ec4 + b2b2cd2 commit 482f572
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/components/generics/FormPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ class FormPanel extends Component {

updateAttribute = (attr, v) => this.updateAttributes({ [attr]: v })

updateExts = updates => {
let data = { ...this.state.data };
updates.forEach(update => {
data["ext"][update.attr] = update.v
});
this.props.onEditedChanged(data);
}

updateExt = (attr, v) => this.updateExts([{ attr: [attr], v }])

}

export default FormPanel
4 changes: 4 additions & 0 deletions src/helpers/jsonExt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

export function formatJsonField(json) {
return `"${JSON.stringify(json).replace(/\"/g,'\\"') }"`;
}
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import {
} from './helpers/api';
import withHistory, { historyPush } from "./helpers/history";
import withModulesManager from './helpers/modules';
import { formatJsonField } from './helpers/jsonExt';

const DEFAULT_CONFIG = {
"reducers": [{ key: 'core', reducer: reducer }],
Expand Down Expand Up @@ -72,7 +73,7 @@ export {
formatQuery, formatPageQuery, formatPageQueryWithCount, formatMutation,
dispatchMutationReq, dispatchMutationResp, dispatchMutationErr,
parseData, pageInfo, formatServerError, formatGraphQLError,
formatMessage, formatMessageWithValues, formatDateFromISO, toISODate, formatAmount,
formatMessage, formatMessageWithValues, formatDateFromISO, toISODate, formatAmount, formatJsonField,
App, AutoSuggestion, Contributions, ControlledField, Picker,
Error, FatalError, AlertForwarder,
SelectInput, TextInput, TextAreaInput, AmountInput, FakeInput, YearPicker, MonthPicker,
Expand Down

0 comments on commit 482f572

Please sign in to comment.