-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EZP-31345 Added language select when user edit sub items #270
EZP-31345 Added language select when user edit sub items #270
Conversation
|
||
useEffect(() => { | ||
const items = [..._refInstantFilter.current.querySelectorAll(`.${props.itemClass}`)]; | ||
const itemsMap = items.reduce( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why reduce
instead of simply map
?
}, []); | ||
|
||
useEffect(() => { | ||
window.clearTimeout(filterTimeout); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clearTimeout
should go to return function insteaed of here
window.clearTimeout(filterTimeout); | |
useEffect(() => { | |
const filterActionTimeout = window.setTimeout(() => { | |
const results = itemsMap.filter((item) => item.label.includes(filterQuery.toLowerCase())); | |
itemsMap.forEach((item) => item.element.setAttribute('hidden', true)); | |
results.forEach((item) => item.element.removeAttribute('hidden')); | |
}, FILTER_TIMEOUT); | |
return () => { | |
window.clearTimeout(filterActionTimeout); | |
} | |
}, [filterQuery]); |
window.clearTimeout(filterTimeout); | ||
|
||
const filterActionTimeout = window.setTimeout(() => { | ||
const results = itemsMap.filter((item) => item.label.includes(filterQuery.toLowerCase())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can store filterQuery.toLowerCase()
in new variable so that you won't fire toLowerCase with each filter iteration
name="items" | ||
className="form-check-input" | ||
value={item.value} | ||
onChange={(event) => props.handleItemChange(event)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be just onChange={props.handleItemChange}
const languages = this.props.languages.mappings; | ||
const { languageCodes } = this.props.item.content._info.currentVersion; | ||
const label = Translator.trans(/*@Desc("Select language")*/ 'languages.modal.label', {}, 'sub_items'); | ||
const languageItems = languageCodes.reduce( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why reduce
instead of simply map
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const languageItems = languageCodes.reduce( | |
const languageItems = languageCodes.map((item) => ({ | |
label: languages[item].name, | |
value: item, | |
})); |
</div> | ||
</div> | ||
); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary else
} else { | |
} | |
return false; | |
} | |
} |
* @memberof SubItemsModule | ||
*/ | ||
setContentEditLanguagesModalPosition() { | ||
const rightMainMenuNode = document.querySelector(RIGHT_MAIN_MENU_SELECTOR); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could go inside if
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review discussed in private, some changes in the architecture are needed
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const _refInstantFilter = useRef(null); | ||
const [filterQuery, setFilterQuery] = useState(''); | ||
const [itemsMap, setItemsMap] = useState([]); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/modules/sub-items/components/sub-items-list/instant.filter.component.js
Show resolved
Hide resolved
}; | ||
|
||
InstantFilter.propTypes = { | ||
uniqueId: PropTypes.string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not needed anymore. I current implementation there will be only one InstantFilter
and it will always be the same value.
InstantFilter.propTypes = { | ||
uniqueId: PropTypes.string, | ||
items: PropTypes.array, | ||
itemClass: PropTypes.string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this have to be in prop? It can be just regular variable. I don't see a point of overriding this by parent component, or am I missing something.
const LanguageSelector = (props) => { | ||
const className = createCssClassNames({ | ||
'ez-extra-actions': true, | ||
'ez-language-selector': true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'ez-language-selector': true, | |
'c-language-selector': true, |
@@ -105,6 +113,31 @@ export default class TableViewComponent extends Component { | |||
); | |||
} | |||
|
|||
/** | |||
* Set language selector data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Set language selector data | |
* Sets language selector data |
<input | ||
type="text" | ||
className="ez-instant-filter__input form-control" | ||
placeholder="Type to refine" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need translation
8d56eea
to
31ff69d
Compare
Checklist:
$ composer fix-cs
)