popojargo commented on a change in pull request #1103: Customize style of the
results list
URL: https://github.com/apache/couchdb-fauxton/pull/1103#discussion_r231279192
##########
File path: app/addons/documents/components/results-options.js
##########
@@ -0,0 +1,96 @@
+
+import React from 'react';
+import PropTypes from 'prop-types';
+import Components from '../../components/react-components';
+import Constants from '../constants';
+
+const { MenuDropDown } = Components;
+
+export default class ResultsOptions extends React.Component {
+ static defaultProps = {
+ showDensity: true,
+ showFontSize: true
+ };
+ static propTypes = {
+ resultsStyle: PropTypes.object.isRequired,
+ updateStyle: PropTypes.func.isRequired,
+ showDensity: PropTypes.bool,
+ showFontSize: PropTypes.bool
+ };
+
+ constructor(props) {
+ super(props);
+ this.toggleTextOverflow = this.toggleTextOverflow.bind(this);
+ this.setFontSize = this.setFontSize.bind(this);
+ }
+
+ toggleTextOverflow() {
+ if (this.props.resultsStyle.textOverflow ===
Constants.INDEX_RESULTS_STYLE.TEXT_OVERFLOW_FULL) {
+ this.props.updateStyle({
+ textOverflow: Constants.INDEX_RESULTS_STYLE.TEXT_OVERFLOW_TRUNCATED
+ });
+ } else {
+ this.props.updateStyle({
+ textOverflow: Constants.INDEX_RESULTS_STYLE.TEXT_OVERFLOW_FULL
+ });
+ }
+ }
+
+ setFontSize(size) {
+ this.props.updateStyle({
+ fontSize: size
+ });
+ }
+
+ getDensitySection() {
+ const densityItems = [{
+ title: 'Show full values',
+ onClick: this.toggleTextOverflow
+ }];
+ if (this.props.resultsStyle.textOverflow ===
Constants.INDEX_RESULTS_STYLE.TEXT_OVERFLOW_FULL) {
Review comment:
I think you should define the title before creating the densityItem. It's
more error prone if you mutate the array at a certain index after its creation.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services