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

Commit

Permalink
#446 Errors indicators - refresh on focus
Browse files Browse the repository at this point in the history
  • Loading branch information
damianprzygodzki committed Mar 3, 2017
1 parent 9a91ae0 commit 6908cac
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/components/widget/DatetimeRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class DatetimeRange extends Component {
<button className={
'btn btn-block text-xs-left btn-meta-outline-secondary ' +
'btn-distance btn-sm input-icon-container input-primary ' +
((mandatory && !startDate && !endDate) ?
((mandatory && !startDate && !endDate) ?
'input-mandatory ' : '') +
((validStatus && !validStatus.valid) ?
'input-error ' : '')
Expand Down
5 changes: 3 additions & 2 deletions src/components/widget/List/RawList.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class RawList extends Component {

render() {
const {
list, rank, readonly, defaultValue, selected, align, updated,
list, rank, readonly, defaultValue, selected, align, updated,
loading, rowId, isModal, tabIndex, disabled, mandatory, validStatus
} = this.props;

Expand All @@ -268,7 +268,8 @@ class RawList extends Component {
(rowId ? 'input-dropdown-container-static ' : '') +
((rowId && !isModal) ? 'input-table ' : '') +
(validStatus &&
!validStatus.valid ? 'input-error ' : '')
!validStatus.valid &&
!isOpen ? 'input-error ' : '')
}
>
<div className={
Expand Down
4 changes: 2 additions & 2 deletions src/components/widget/Lookup/Lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ class Lookup extends Component {
(readonly ? 'input-disabled ' : '') +
(rowId ? 'input-dropdown-container-static ' : '') +
((rowId && !isModal)? 'input-table ' : '') +
(validStatus &&
!validStatus.valid ? 'input-error ' : '')
((validStatus &&
!validStatus.valid) ? 'input-error ' : '')
}
>
<div className={
Expand Down
42 changes: 26 additions & 16 deletions src/components/widget/RawWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class RawWidget extends Component {
if(
JSON.stringify(widgetData[0].value) !== JSON.stringify(value) ||
JSON.stringify(widgetData[0].valueTo) !== JSON.stringify(valueTo) ||
(cachedValue !== null &&
(cachedValue !== null &&
(JSON.stringify(cachedValue) !== JSON.stringify(value)))
){

Expand Down Expand Up @@ -105,12 +105,16 @@ class RawWidget extends Component {
widgetData, disabled, gridAlign, type, updated, rowId, isModal
} = this.props;

const {isEdited} = this.state;

return 'input-block ' +
(icon ? 'input-icon-container ' : '') +
(widgetData[0].readonly || disabled ? 'input-disabled ' : '') +
(widgetData[0].validStatus &&
!widgetData[0].validStatus.valid ? 'input-error ' : '') +
(widgetData[0].mandatory &&
((widgetData[0].validStatus &&
!widgetData[0].validStatus.valid &&
!isEdited) ? 'input-error ' : '') +
(widgetData[0].mandatory &&
widgetData[0].value &&
widgetData[0].value.length === 0 ? 'input-mandatory ' : '') +
(gridAlign ? 'text-xs-' + gridAlign + ' ' : '') +
(type === 'primary' ? 'input-primary ' : 'input-secondary ') +
Expand All @@ -129,7 +133,7 @@ class RawWidget extends Component {
renderWidget = () => {
const {
handleChange, updated, isModal, filterWidget, filterId, id, range,
onHide, handleBackdropLock, subentity, subentityId, tabIndex,
onHide, handleBackdropLock, subentity, subentityId, tabIndex,
dropdownOpenCallback, autoFocus, fullScreen, widgetType, fields,
windowType, dataId, type, widgetData, rowId, tabId, icon, gridAlign,
entity, onShow, disabled, caption, viewId
Expand All @@ -138,7 +142,7 @@ class RawWidget extends Component {
const {isEdited} = this.state;

// TODO: API SHOULD RETURN THE SAME PROPERTIES FOR FILTERS
const widgetField = filterWidget ?
const widgetField = filterWidget ?
fields[0].parameterName : fields[0].field;

switch(widgetType){
Expand All @@ -151,12 +155,12 @@ class RawWidget extends Component {
<DatetimeRange
onChange={(value, valueTo) =>
this.handlePatch(widgetField,
value ?
Moment(value).format(DATE_FORMAT) :
value ?
Moment(value).format(DATE_FORMAT) :
null,
null,
valueTo ?
Moment(valueTo).format(DATE_FORMAT) :
valueTo ?
Moment(valueTo).format(DATE_FORMAT) :
null
)
}
Expand All @@ -183,7 +187,7 @@ class RawWidget extends Component {
tabIndex: fullScreen ? -1 : tabIndex
}}
value={widgetData[0].value}
onChange={(date) =>
onChange={(date) =>
handleChange(widgetField, date)}
patch={(date) => this.handlePatch(
widgetField,
Expand Down Expand Up @@ -477,16 +481,22 @@ class RawWidget extends Component {
<label
className={
'input-switch ' +
(widgetData[0].readonly || disabled ? 'input-disabled ' : '') +
(widgetData[0].mandatory && widgetData[0].value.length === 0 ? 'input-mandatory ' : '') +
(validStatus &&
!validStatus.valid ? 'input-error ' : '') +
(widgetData[0].readonly || disabled ?
'input-disabled ' : '') +
(widgetData[0].mandatory &&
widgetData[0].value.length === 0 ?
'input-mandatory ' : '') +
(widgetData[0].validStatus &&
!widgetData[0].validStatus.valid ?
'input-error ' : '') +
(rowId && !isModal ? 'input-table ' : '')
}
tabIndex={fullScreen ? -1 : tabIndex}
ref={c => this.rawWidget = c}
onKeyDown={e => {e.key === ' ' &&
this.handlePatch(widgetField, !widgetData[0].value, id)
this.handlePatch(
widgetField, !widgetData[0].value, id
)
}}
>
<input
Expand Down

0 comments on commit 6908cac

Please sign in to comment.