/
ChartEditorMixin.js
48 lines (41 loc) · 1.09 KB
/
ChartEditorMixin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var React = require("react");
var update = require("react-addons-update");
// Flux actions
var ChartViewActions = require("../../actions/ChartViewActions");
/**
* ### Functions common to chart editors
* @instance
* @memberof editors
*/
var ChartEditorMixin = {
/**
* _handlePropUpdate
* Initiate a flux action that updates a prop, that doesn't require reparsing
* @param k - `chartProp` key
* @param v - `chartProp` value
*/
_handlePropUpdate: function(k, v) {
ChartViewActions.updateChartProp(k, v);
},
/**
* _handlePropAndReparse
* Initiate a flux action that updates a prop and then triggers a reparse
* @param k - `chartProp` key
* @param v - `chartProp` value
*/
_handlePropAndReparse: function(k, v) {
ChartViewActions.updateAndReparse(k, v);
},
/**
* _handleStateUpdate
* Update a key in the editor component's state
* @param k - `this.state` key
* @param v - `this.state` value
*/
_handleStateUpdate: function(k, v) {
var newValue = {};
newValue[k] = v;
this.setState(update(this.state, { $merge: newValue }));
},
};
module.exports = ChartEditorMixin;