Skip to content

Commit

Permalink
Merge branch 'lineup-v4' into sgratzl/drag
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkh committed Apr 16, 2020
2 parents f375324 + e11ed21 commit a471095
Show file tree
Hide file tree
Showing 14 changed files with 261 additions and 72 deletions.
34 changes: 34 additions & 0 deletions cypress/integration/pr292_data_mapping.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {withLineUp, waitReady, LineUpJSType, LineUp} from './utils/lineup';
import {generateData} from './utils/data';
import {openMoreDialog, closeDialog, resetDialog} from './utils/ui';

describe('pr292_data_mapping', () => {
let lineup: LineUp;
let lineUpJS: LineUpJSType;
before(withLineUp((l, document) => {
lineUpJS = l;
const arr = generateData({
number: 1,
string: 0,
date: 0,
cat: 0
});

lineup = lineUpJS.asLineUp(document.body, arr);
waitReady(lineup);
}));

function openDataMappingDialog() {
// open more menu
return openMoreDialog('[data-type=number]', 'data-mapping');
}

it('reset domain value', () => {
openDataMappingDialog().within(() => {
cy.get('input[type=number]:first').invoke('val', '0.2');
resetDialog();
cy.get('input[type=number]:first').should('not.have.value', '0.2');
});
closeDialog('cancel');
});
});
2 changes: 1 addition & 1 deletion src/renderer/DateHistogramCellRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function createFilterContext(col: IDateColumn, context: IRenderContext, domain:
const dialogCtx = {
attachment,
manager: context.dialogManager,
level: 1,
level: context.dialogManager.maxLevel + 1,
idPrefix: context.idPrefix
};
const dialog = new InputDateDialog(dialogCtx, (d) => resolve(d == null ? NaN : shiftFilterDateDay(d.getTime(), type)), {value: isNaN(value) ? null : new Date(value)});
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/HistogramCellRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ function createFilterContext(col: IMapAbleColumn, context: {idPrefix: string, di
const dialogCtx = {
attachment,
manager: context.dialogManager,
level: 1,
level: context.dialogManager.maxLevel + 1,
idPrefix: context.idPrefix
};
const dialog = new InputNumberDialog(dialogCtx, resolve, {
Expand Down
24 changes: 17 additions & 7 deletions src/renderer/histogram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ export function filteredHistTemplate<T>(c: IFilterContext<T>, f: IFilterInfo<T>)
return `
<div class="${cssClass('histogram-min-hint')}" style="width: ${c.percent(f.filterMin)}%"></div>
<div class="${cssClass('histogram-max-hint')}" style="width: ${100 - c.percent(f.filterMax)}%"></div>
<div class="${cssClass('histogram-min')}" data-value="${c.format(f.filterMin)}" style="left: ${c.percent(f.filterMin)}%" title="min filter, drag or shift click to change"></div>
<div class="${cssClass('histogram-max')}" data-value="${c.format(f.filterMax)}" style="right: ${100 - c.percent(f.filterMax)}%" title="max filter, drag or shift click to change"></div>
<div class="${cssClass('histogram-min')}" data-value="${c.format(f.filterMin)}" style="left: ${c.percent(f.filterMin)}%" title="min filter, drag or double click to change"></div>
<div class="${cssClass('histogram-max')}" data-value="${c.format(f.filterMax)}" style="right: ${100 - c.percent(f.filterMax)}%" title="max filter, drag or double click to change"></div>
${filterMissingNumberMarkup(f.filterMissing, 0)}
`;
}
Expand All @@ -126,10 +126,7 @@ export function initFilter<T>(node: HTMLElement, context: IFilterContext<T>) {
context.setFilter(filterMissing.checked, minValue, maxValue);
};

min.onclick = (evt) => {
if (!evt.shiftKey && !evt.ctrlKey) {
return;
}
const minImpl = (evt: MouseEvent) => {
evt.preventDefault();
evt.stopPropagation();

Expand All @@ -144,10 +141,15 @@ export function initFilter<T>(node: HTMLElement, context: IFilterContext<T>) {
});
};

max.onclick = (evt) => {
min.onclick = (evt) => {
if (!evt.shiftKey && !evt.ctrlKey) {
return;
}
minImpl(evt);
};
min.ondblclick = minImpl;

const maxImpl = (evt: MouseEvent) => {
evt.preventDefault();
evt.stopPropagation();

Expand All @@ -162,6 +164,14 @@ export function initFilter<T>(node: HTMLElement, context: IFilterContext<T>) {
});
};

max.onclick = (evt) => {
if (!evt.shiftKey && !evt.ctrlKey) {
return;
}
maxImpl(evt);
};
max.ondblclick = maxImpl;

filterMissing.onchange = () => setFilter();

const options: Partial<IDragHandleOptions> = {
Expand Down
4 changes: 4 additions & 0 deletions src/styles/_dialogs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
float: right;
color: darken($lu_toolbar_color_base, 20%); // slightly darker primary action
}

&[title=Remove] {
color: darken($lu_toolbar_color_base, 20%); // slightly darker primary action
}
}

.#{$lu_css_prefix}-dialog-sub-nested {
Expand Down
64 changes: 52 additions & 12 deletions src/styles/_mappingeditor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
}

div.#{$lu_css_prefix}-dialog-mapper-script {
margin-top: 1em;
display: none;

textarea {
Expand All @@ -30,37 +29,53 @@ div.#{$lu_css_prefix}-dialog-mapper-script {
}
}

.#{$lu_css_prefix}-dialog-mapper-domain,
.#{$lu_css_prefix}-dialog-mapper-range {
transform: translate(0, 24px);
display: flex;
align-items: center;
justify-content: space-between;
margin: 0 14px;
border-bottom: 3px solid $lu_mapping_box;
padding: 0.4em 2px 20px;
text-align: center;
}

.#{$lu_css_prefix}-dialog-mapper-range {
padding: 20px 2px 0.4em;
transform: translate(0, -24px);
border-bottom: none;
border-top: 3px solid $lu_mapping_box;
justify-content: space-around;
}

svg.#{$lu_css_prefix}-dialog-mapper-details {
shape-rendering: geometricprecision;
z-index: 1;
height: 25em * 6 / 10;
background: transparent;

rect {
fill: transparent;
stroke: none;
}

line {
stroke: $lu_mapping_bg;
stroke-width: 1;
stroke: $lu_mapping_handle;
stroke-width: 0.8;
stroke-linejoin: round;
stroke-linecap: round;

&:not([x1]) {

// the horizontal lines
stroke-width: 1.5;
}

&[data-v] {
stroke-opacity: 0.5;
stroke-width: 0.5;
stroke: $lu_toolbar_color_base2;
stroke: $lu_mapping_line;
pointer-events: none;
}
}

circle {
fill: $lu_mapping_circle;
fill: $lu_mapping_handle;
}
}

Expand All @@ -74,9 +89,11 @@ g.#{$lu_css_prefix}-dialog-mapper-mapping {

&.#{$lu_css_prefix}-frozen circle:first-of-type {
cursor: not-allowed;
fill: $lu_mapping_circle !important;
fill: $lu_mapping_handle !important;
transform: scale(0.4);
}

&.#{$lu_css_prefix}-mapping-line-selected,
&:hover {
circle {
fill: $lu_mapping_hover;
Expand All @@ -86,6 +103,29 @@ g.#{$lu_css_prefix}-dialog-mapper-mapping {
stroke: $lu_mapping_hover;
}
}

&.#{$lu_css_prefix}-frozen > .#{$lu_css_prefix}-dialog-mapper-mapping-domain {
display: none;
}
}

.#{$lu_css_prefix}-dialog-mapper-mapping-domain {
pointer-events: none;
font-size: 4px;
}

.#{$lu_css_prefix}-dialog-mapper-mapping-range {
pointer-events: none;
font-size: 4px;
dominant-baseline: hanging;
}

.#{$lu_css_prefix}-dialog-mapper-mapping-right {
text-anchor: end;
}

.#{$lu_css_prefix}-dialog-mapper-mapping-middle {
text-anchor: middle;
}

.#{$lu_css_prefix}-dialog-mapper[data-scale=script] div.#{$lu_css_prefix}-dialog-mapper-script {
Expand Down
7 changes: 4 additions & 3 deletions src/styles/_vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ $lu_missing_dash_color: #c1c1c1 !default;

$lu_axis_color: #c1c1c1 !default;

$lu_mapping_circle: $lu_toolbar_color_base2;
$lu_mapping_hover: $lu_selected_color;
$lu_mapping_bg: $lu_toolbar_color_hover;
$lu_mapping_box: $lu_toolbar_color_base !default;
$lu_mapping_line: $lu_hover_color !default;
$lu_mapping_handle: $lu_toolbar_color_hover !default;
$lu_mapping_hover: $lu_selected_color !default;

$lu_side_panel_bg_color: #f0f0f0 !default;
$lu_side_panel_toolbar_bg: #6d6c6c !default;
Expand Down
1 change: 1 addition & 0 deletions src/styles/engine/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
}

.#{$engine_css_prefix}-footer {

// extra space to the right using a width for easier last column resizing
width: $lu_engine_resize_space;
}
Expand Down
8 changes: 8 additions & 0 deletions src/ui/dialogs/ADialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface IDialogOptions {
eventsEnabled?: boolean;
modifiers?: Popper.Modifiers;
toggleDialog: boolean;
cancelSubDialogs?: boolean;
}

export interface IDialogContext {
Expand All @@ -40,6 +41,7 @@ abstract class ADialog {
popup: false,
placement: 'bottom-start',
toggleDialog: true,
cancelSubDialogs: false,
modifiers: {
}
};
Expand Down Expand Up @@ -160,6 +162,12 @@ abstract class ADialog {
};
}

if (this.options.cancelSubDialogs) {
this.node.addEventListener('click', () => {
this.dialog.manager.removeAboveLevel(this.dialog.level + 1);
});
}

this.dialog.manager.push(this);
}

Expand Down
3 changes: 2 additions & 1 deletion src/ui/dialogs/DateFilterDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ export default class DateFilterDialog extends ADialog {

constructor(private readonly column: DateColumn, dialog: IDialogContext) {
super(dialog, {
livePreview: 'filter'
livePreview: 'filter',
cancelSubDialogs: true,
});
this.before = this.column.getFilter() || noDateFilter();
}
Expand Down
4 changes: 4 additions & 0 deletions src/ui/dialogs/DialogManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ export default class DialogManager extends AEventDispatcher {
return super.on(type, listener);
}

get maxLevel() {
return this.openDialogs.reduce((acc, a) => Math.max(acc, a.level), 0);
}


setHighlight(mask: { left: number, top: number, width: number, height: number }) {
const area = <HTMLElement>this.node.firstElementChild;
Expand Down
Loading

0 comments on commit a471095

Please sign in to comment.