Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Commit

Permalink
#2473 RawWidget should default to getWidgetData but support old `wi…
Browse files Browse the repository at this point in the history
…dgetData` prop too
  • Loading branch information
siemiatj committed Jan 10, 2020
1 parent e1ce1ff commit 2764579
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
21 changes: 16 additions & 5 deletions src/components/widget/RawWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ export class RawWidget extends PureComponent {
constructor(props) {
super(props);

const { widgetData } = props;
const { getWidgetData } = props;
let { widgetData } = props;
widgetData = widgetData || getWidgetData();

let cachedValue = undefined;

if (widgetData && widgetData[0]) {
Expand Down Expand Up @@ -197,7 +200,10 @@ export class RawWidget extends PureComponent {
* @param {*} valueTo
*/
willPatch = (property, value, valueTo) => {
const { widgetData } = this.props;
const { getWidgetData } = this.props;
let { widgetData } = this.props;
widgetData = widgetData || getWidgetData();

const { cachedValue } = this.state;

// if there's no widget value, then nothing could've changed. Unless
Expand Down Expand Up @@ -231,7 +237,7 @@ export class RawWidget extends PureComponent {
* calls the parent method (usually from MasterWidget) if the requirements are met
* (value changed and patching is not in progress). `isForce` will be used for Datepicker
* Datepicker is checking the cached value in datepicker component itself
* and send a patch request only if date is changed
* and send a patch request only if date has changed
* @param {*} property
* @param {*} value
* @param {*} id
Expand Down Expand Up @@ -349,7 +355,6 @@ export class RawWidget extends PureComponent {
windowType,
dataId,
type,
widgetData,
rowId,
tabId,
docId,
Expand All @@ -375,6 +380,9 @@ export class RawWidget extends PureComponent {
timeZone,
filter,
} = this.props;
const { getWidgetData } = this.props;
let { widgetData } = this.props;
widgetData = widgetData || getWidgetData();

let widgetValue = data != null ? data : widgetData[0].value;
const { isEdited } = this.state;
Expand Down Expand Up @@ -1000,7 +1008,6 @@ export class RawWidget extends PureComponent {
fields,
type,
noLabel,
widgetData,
rowId,
isModal,
handlePatch,
Expand All @@ -1018,6 +1025,10 @@ export class RawWidget extends PureComponent {
tooltipToggled,
isEdited,
} = this.state;
const { getWidgetData } = this.props;
let { widgetData } = this.props;
widgetData = widgetData || getWidgetData();

const widgetBody = this.renderWidget();
const { validStatus, warning } = widgetData[0];
const quickInput = subentity === 'quickInput';
Expand Down
12 changes: 11 additions & 1 deletion src/components/widget/RawWidgetHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,17 @@ export function generateMomentObj(value, FORMAT) {
}

export function getClassNames({ icon, forcedPrimary } = {}) {
const { widgetData, gridAlign, type, updated, rowId, isModal } = this.props;
const {
getWidgetData,
gridAlign,
type,
updated,
rowId,
isModal,
} = this.props;
let { widgetData } = this.props;
widgetData = widgetData || getWidgetData();

const { isEdited } = this.state;
const { readonly, value, mandatory, validStatus } = widgetData[0];

Expand Down

0 comments on commit 2764579

Please sign in to comment.