Compare commits

...

5 Commits

Author SHA1 Message Date
giovanni hanselius
621359d6f9 Merge pull request #28 from qlik-oss/QPE-634-column-width-fix
[QPE 634] Fix column width
2019-02-27 15:06:04 +01:00
Balazs Gobel
a71f80f8fa minor cleanup 2019-02-27 14:26:27 +01:00
Balazs Gobel
a6cbfcda70 Fix column width issue
- Look at the value format to determine if column is percentage based
2019-02-27 14:25:50 +01:00
giovanni hanselius
de2e9c16ac Merge pull request #25 from qlik-oss/QPE-549-tooltip-design
[QPE 549] Minor adjustments for tooltip
2019-02-27 12:30:42 +01:00
Balazs Gobel
dae192b7af Minor adjustments for tooltip
- Added tooltip for row header
- Better vertical alignment
- Move static styling to css
2019-02-26 15:44:17 +01:00
4 changed files with 127 additions and 114 deletions

View File

@@ -3,64 +3,7 @@ import PropTypes from 'prop-types';
import { ApplyPreMask } from '../masking';
import { addSeparators } from '../utilities';
import Tooltip from '../tooltip/index.jsx';
function formatMeasurementValue (measurement, styling) {
// TODO: measurement.name is a horrible propertyname, it's actually the column header
const isColumnPercentageBased = measurement.parents.measurement.header.substring(0, 1) === '%';
let formattedMeasurementValue = '';
if (isColumnPercentageBased) {
if (isNaN(measurement.value)) {
formattedMeasurementValue = styling.symbolForNulls;
} else {
formattedMeasurementValue = ApplyPreMask('0,00%', measurement.value);
}
} else {
let magnitudeDivider;
switch (measurement.magnitude.toLowerCase()) {
case 'k':
magnitudeDivider = 1000;
break;
case 'm':
magnitudeDivider = 1000000;
break;
default:
magnitudeDivider = 1;
}
const formattingStringWithoutMagnitude = measurement.format.replace(/k|K|m|M/gi, '');
if (isNaN(measurement.value)) {
formattedMeasurementValue = styling.symbolForNulls;
} else {
let preFormatValue = measurement.value;
if (isColumnPercentageBased) {
preFormatValue *= 100;
}
switch (formattingStringWithoutMagnitude) {
case '#.##0':
formattedMeasurementValue = addSeparators((preFormatValue / magnitudeDivider), '.', ',', 0);
break;
case '#,##0':
formattedMeasurementValue = addSeparators((preFormatValue / magnitudeDivider), ',', '.', 0);
break;
default:
formattedMeasurementValue = ApplyPreMask(
formattingStringWithoutMagnitude,
(preFormatValue / magnitudeDivider)
);
break;
}
}
}
return formattedMeasurementValue;
}
function getSemaphoreColors (measurement, semaphoreColors) {
if (measurement.value < semaphoreColors.status.critical) {
return semaphoreColors.statusColors.critical;
}
if (measurement.value < semaphoreColors.status.medium) {
return semaphoreColors.statusColors.medium;
}
return semaphoreColors.statusColors.normal;
}
class DataCell extends React.PureComponent {
constructor (props) {
super(props);
@@ -90,7 +33,7 @@ class DataCell extends React.PureComponent {
styling
} = this.props;
const isColumnPercentageBased = measurement.name.substring(0, 1) === '%';
const isColumnPercentageBased = (/%/).test(measurement.format);
let formattedMeasurementValue = formatMeasurementValue(measurement, styling);
if (styleBuilder.hasComments()) {
formattedMeasurementValue = '.';
@@ -177,3 +120,61 @@ DataCell.propTypes = {
};
export default DataCell;
function formatMeasurementValue (measurement, styling) {
const isColumnPercentageBased = (/%/).test(measurement.format);
let formattedMeasurementValue = '';
if (isColumnPercentageBased) {
if (isNaN(measurement.value)) {
formattedMeasurementValue = styling.symbolForNulls;
} else {
formattedMeasurementValue = ApplyPreMask('0,00%', measurement.value);
}
} else {
let magnitudeDivider;
switch (measurement.magnitude.toLowerCase()) {
case 'k':
magnitudeDivider = 1000;
break;
case 'm':
magnitudeDivider = 1000000;
break;
default:
magnitudeDivider = 1;
}
const formattingStringWithoutMagnitude = measurement.format.replace(/k|K|m|M/gi, '');
if (isNaN(measurement.value)) {
formattedMeasurementValue = styling.symbolForNulls;
} else {
let preFormatValue = measurement.value;
if (isColumnPercentageBased) {
preFormatValue *= 100;
}
switch (formattingStringWithoutMagnitude) {
case '#.##0':
formattedMeasurementValue = addSeparators((preFormatValue / magnitudeDivider), '.', ',', 0);
break;
case '#,##0':
formattedMeasurementValue = addSeparators((preFormatValue / magnitudeDivider), ',', '.', 0);
break;
default:
formattedMeasurementValue = ApplyPreMask(
formattingStringWithoutMagnitude,
(preFormatValue / magnitudeDivider)
);
break;
}
}
}
return formattedMeasurementValue;
}
function getSemaphoreColors (measurement, semaphoreColors) {
if (measurement.value < semaphoreColors.status.critical) {
return semaphoreColors.statusColors.critical;
}
if (measurement.value < semaphoreColors.status.medium) {
return semaphoreColors.statusColors.medium;
}
return semaphoreColors.statusColors.normal;
}

View File

@@ -4,8 +4,7 @@ import PropTypes from 'prop-types';
const HeaderPadding = ({ styleBuilder, styling }) => {
if (styling.usePadding && !styleBuilder.hasCustomFileStyle()) {
const paddingStyle = {
fontFamily: styling.options.fontFamily,
marginLeft: '15px'
fontFamily: styling.options.fontFamily
};
return (
<span style={paddingStyle} />

View File

@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import HeaderPadding from './header-padding.jsx';
import Tooltip from '../tooltip/index.jsx';
class RowHeader extends React.PureComponent {
constructor (props) {
@@ -15,7 +16,9 @@ class RowHeader extends React.PureComponent {
}
render () {
const { entry, rowStyle, styleBuilder, styling } = this.props;
const { entry, rowStyle, styleBuilder, styling, qlik } = this.props;
const inEditState = qlik.inEditState();
return (
<td
className="fdim-cells"
@@ -26,7 +29,12 @@ class RowHeader extends React.PureComponent {
styleBuilder={styleBuilder}
styling={styling}
/>
{entry.displayValue}
<Tooltip
isTooltipActive={!inEditState}
tooltipText={entry.displayValue}
>
{entry.displayValue}
</Tooltip>
</td>
);
}

View File

@@ -24,38 +24,6 @@
z-index: 110;
}
.tooltip-wrapper {
min-width: 25px;
position: fixed;
padding: 5px;
padding-top: 15px;
background-color: #404040;
z-index: 100;
pointer-events: none;
border-radius: 5px;
height: 30px;
width: auto;
opacity: 0.9;
text-align: center;
transform: translate(-50%, -110%);
> p {
color: #fff;
}
}
.tooltip-wrapper::after {
content: "";
position: absolute;
bottom: -10px;
left: 50%;
border-width: 10px 10px 0;
border-style: solid;
border-color: #404040 transparent;
margin-left: -10px;
pointer-events: none;
}
.icon-xls {
text-align: left;
}
@@ -83,6 +51,12 @@
text-overflow: ellipsis;
vertical-align: middle;
cursor: default;
> div {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
.empty {
@@ -102,7 +76,7 @@
text-align: right;
}
/* This is for wrap text in headers */
// This is for wrap text in headers
.wrapclass25 {
width: 100%;
height: 25px;
@@ -133,11 +107,9 @@
width: 100%;
}
/* ***************** */
/* Medium column size */
/* ***************** */
// *****************
// Medium column size
// *****************
.grid-cells {
position: relative;
@@ -156,11 +128,9 @@
._cell(52px);
}
/* ***************** */
/* Small column size */
/* ***************** */
// *****************
// Small column size
// *****************
.grid-cells-s {
._cell(67px);
}
@@ -177,12 +147,9 @@
._cell(52px);
}
/* ***************** */
/* large column size */
/* ***************** */
// *****************
// Large column size
// *****************
.grid-cells-l {
._cell(82px);
}
@@ -199,9 +166,9 @@
._cell(66px);
}
/* END OF GRID CELLS */
// END OF GRID CELLS
/* First Column */
// First Column
.fdim-cells {
min-width: 230px !Important;
max-width: 230px !Important;
@@ -271,6 +238,10 @@
}
}
.row-wrapper .fdim-cells {
padding-left: 12px;
}
.data-table {
height: 100%;
width: calc(100% - 243px);
@@ -294,7 +265,7 @@
// hide scrollbars
.kpi-table .header-wrapper,
.data-table .header-wrapper {
/* stylelint-disable-next-line property-no-unknown */
// stylelint-disable-next-line property-no-unknown
scrollbar-width: none;
-ms-overflow-style: none; // IE 10+
-moz-overflow: -moz-scrollbars-none; // Firefox
@@ -303,4 +274,38 @@
display: none; // Safari and Chrome
}
}
.tooltip-wrapper {
min-width: 25px;
position: fixed;
padding: 5px;
padding-top: 8px;
background-color: #404040;
z-index: 100;
pointer-events: none;
border-radius: 5px;
height: 30px;
width: auto;
opacity: 0.9;
text-align: center;
transform: translate(-50%, -110%);
&::after {
content: "";
position: absolute;
bottom: -10px;
left: 50%;
border-width: 10px 10px 0;
border-style: solid;
border-color: #404040 transparent;
margin-left: -10px;
pointer-events: none;
}
> p {
color: #fff;
}
}
}
/* eslint-enable */