aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsrichman333 <sarah_n_richman@brown.edu>2023-08-10 11:28:09 -0400
committersrichman333 <sarah_n_richman@brown.edu>2023-08-10 11:28:09 -0400
commita89ba9afe33d973c50c0a66aec73db1e22367913 (patch)
tree1e99866a5bde9af7b0f4d800433e9d6bbe022b2f
parent481a847b1074c9544e947e409b96778ac4d4f852 (diff)
undo/redo for colors + titles
-rw-r--r--src/client/views/nodes/DataVizBox/components/Histogram.tsx9
-rw-r--r--src/client/views/nodes/DataVizBox/components/LineChart.tsx3
-rw-r--r--src/client/views/nodes/DataVizBox/components/PieChart.tsx5
3 files changed, 10 insertions, 7 deletions
diff --git a/src/client/views/nodes/DataVizBox/components/Histogram.tsx b/src/client/views/nodes/DataVizBox/components/Histogram.tsx
index ed663006f..883cc006b 100644
--- a/src/client/views/nodes/DataVizBox/components/Histogram.tsx
+++ b/src/client/views/nodes/DataVizBox/components/Histogram.tsx
@@ -14,6 +14,7 @@ import { FaFillDrip } from "react-icons/fa";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { listSpec } from "../../../../../fields/Schema";
import { scaleCreatorNumerical, yAxisCreator } from "../utils/D3Utils";
+import { undoBatch, undoable } from "../../../../util/UndoManager";
export interface HistogramProps {
rootDoc: Doc;
@@ -426,7 +427,7 @@ export class Histogram extends React.Component<HistogramProps> {
<div className="graph-title">
<EditableText
val={StrCast(this.props.layoutDoc[titleAccessor])}
- setVal={action(val => this.props.layoutDoc[titleAccessor] = val as string)}
+ setVal={undoable (action(val => this.props.layoutDoc[titleAccessor] = val as string), "Change Graph Title")}
color={"black"}
size={Size.LARGE}
fillWidth
@@ -437,7 +438,7 @@ export class Histogram extends React.Component<HistogramProps> {
type={Type.SEC}
icon={<FaFillDrip/>}
selectedColor={StrCast(this.props.layoutDoc.defaultHistogramColor)}
- setSelectedColor={color => this.props.layoutDoc.defaultHistogramColor = color}
+ setSelectedColor={undoable (color => this.props.layoutDoc.defaultHistogramColor = color, "Change Default Bar Color")}
size={Size.XSMALL}
/>
</div>
@@ -451,7 +452,7 @@ export class Histogram extends React.Component<HistogramProps> {
type={Type.SEC}
icon={<FaFillDrip/>}
selectedColor={selectedBarColor? selectedBarColor : this.curBarSelected.attr("fill")}
- setSelectedColor={color => this.changeSelectedColor(color)}
+ setSelectedColor={undoable (color => this.changeSelectedColor(color), "Change Selected Bar Color")}
size={Size.XSMALL}
/>
&nbsp;
@@ -461,7 +462,7 @@ export class Histogram extends React.Component<HistogramProps> {
color={'black'}
type={Type.SEC}
tooltip={'Revert to the default bar color'}
- onClick={action(() => this.eraseSelectedColor())}
+ onClick={undoable (action(() => this.eraseSelectedColor()), "Change Selected Bar Color")}
/>
</div>
: null}
diff --git a/src/client/views/nodes/DataVizBox/components/LineChart.tsx b/src/client/views/nodes/DataVizBox/components/LineChart.tsx
index 053696807..49ef577e4 100644
--- a/src/client/views/nodes/DataVizBox/components/LineChart.tsx
+++ b/src/client/views/nodes/DataVizBox/components/LineChart.tsx
@@ -15,6 +15,7 @@ import { DataVizBox } from '../DataVizBox';
import { createLineGenerator, drawLine, minMaxRange, scaleCreatorNumerical, xAxisCreator, xGrid, yAxisCreator, yGrid } from '../utils/D3Utils';
import './Chart.scss';
import { EditableText, Size } from 'browndash-components';
+import { undoable } from '../../../../util/UndoManager';
export interface DataPoint {
x: number;
@@ -363,7 +364,7 @@ export class LineChart extends React.Component<LineChartProps> {
<div className="graph-title">
<EditableText
val={StrCast(this.props.layoutDoc[titleAccessor])}
- setVal={action(val => this.props.layoutDoc[titleAccessor] = val as string)}
+ setVal={undoable (action(val => this.props.layoutDoc[titleAccessor] = val as string), "Change Graph Title")}
color={"black"}
size={Size.LARGE}
fillWidth
diff --git a/src/client/views/nodes/DataVizBox/components/PieChart.tsx b/src/client/views/nodes/DataVizBox/components/PieChart.tsx
index 6581b6b75..de725209d 100644
--- a/src/client/views/nodes/DataVizBox/components/PieChart.tsx
+++ b/src/client/views/nodes/DataVizBox/components/PieChart.tsx
@@ -12,6 +12,7 @@ import './Chart.scss';
import { ColorPicker, EditableText, Size, Type } from "browndash-components";
import { FaFillDrip } from "react-icons/fa";
import { listSpec } from "../../../../../fields/Schema";
+import { undoable } from "../../../../util/UndoManager";
export interface PieChartProps {
rootDoc: Doc;
@@ -342,7 +343,7 @@ export class PieChart extends React.Component<PieChartProps> {
<div className="graph-title">
<EditableText
val={StrCast(this.props.layoutDoc[titleAccessor])}
- setVal={action(val => this.props.layoutDoc[titleAccessor] = val as string)}
+ setVal={undoable (action(val => this.props.layoutDoc[titleAccessor] = val as string), "Change Graph Title")}
color={"black"}
size={Size.LARGE}
fillWidth
@@ -358,7 +359,7 @@ export class PieChart extends React.Component<PieChartProps> {
type={Type.SEC}
icon={<FaFillDrip/>}
selectedColor={selectedSliceColor? selectedSliceColor : this.curSliceSelected.attr("fill")}
- setSelectedColor={color => this.changeSelectedColor(color)}
+ setSelectedColor={undoable (color => this.changeSelectedColor(color), "Change Selected Slice Color")}
size={Size.XSMALL}
/>
</div>