prg-editor
Advanced tools
Comparing version 0.1.0 to 0.2.0-alpha.2
@@ -123,5 +123,12 @@ 'use strict'; | ||
value: function componentDidMount() { | ||
this.loadData({}, true); | ||
this.loadData(this.state.params, true); | ||
} | ||
}, { | ||
key: 'componentWillReceiveProps', | ||
value: function componentWillReceiveProps(props) { | ||
if (this.props.params !== props.params) { | ||
this.loadData(props.params); | ||
} | ||
} | ||
}, { | ||
key: 'componentWillUnmount', | ||
@@ -167,3 +174,3 @@ value: function componentWillUnmount() { | ||
if (data !== null) { | ||
this.loadData(); | ||
this.requestDataLoad(); | ||
} | ||
@@ -176,3 +183,3 @@ } | ||
if (data !== null) { | ||
this.loadData(); | ||
this.requestDataLoad(); | ||
} | ||
@@ -189,26 +196,36 @@ } | ||
this.setState({ filterChanged: true }); | ||
this.loadData(Object.assign({}, params, { page: 0 })); | ||
this.requestDataLoad(Object.assign({}, params, { page: 0 })); | ||
} | ||
}, { | ||
key: 'loadData', | ||
value: function loadData() { | ||
key: 'requestDataLoad', | ||
value: function requestDataLoad() { | ||
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var overrideParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
var _this3 = this; | ||
var initial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
var overrideParams = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
var newParams = void 0; | ||
if (overrideParams) { | ||
newParams = params; | ||
} else if (initial) { | ||
newParams = this.state.params; | ||
} else { | ||
newParams = Object.assign({}, this.state.params, params); | ||
} | ||
if (this.props.onParamsChange !== null) { | ||
this.props.onParamsChange(newParams); | ||
} else { | ||
this.loadData(newParams); | ||
} | ||
} | ||
}, { | ||
key: 'loadData', | ||
value: function loadData() { | ||
var _this3 = this; | ||
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var initial = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
if (!initial) { | ||
this.setState({ | ||
loading: true, | ||
params: newParams, | ||
params: params, | ||
data: [], | ||
@@ -219,3 +236,3 @@ nextOffset: 0 | ||
this.resource.getAll(newParams).then(function (data) { | ||
this.resource.getAll(params).then(function (data) { | ||
return _this3.onAjaxSuccess(data); | ||
@@ -234,3 +251,3 @@ }).catch(function (err) { | ||
this.setState({ filterChanged: false }); | ||
this.loadData({ offset: 0, order: order, orderBy: orderBy, limit: this.props.limit }, false, true); | ||
this.requestDataLoad({ offset: 0, order: order, orderBy: orderBy, limit: this.props.limit }, true); | ||
} | ||
@@ -290,3 +307,3 @@ }, { | ||
onTryAgain: function onTryAgain() { | ||
return _this5.loadData(); | ||
return _this5.requestDataLoad(); | ||
} | ||
@@ -310,3 +327,3 @@ }); | ||
onPageChange: function onPageChange(p) { | ||
return _this6.loadData({ offset: p >= 0 ? p * limit : -1 }); | ||
return _this6.requestDataLoad({ offset: p >= 0 ? p * limit : -1 }); | ||
} | ||
@@ -361,3 +378,3 @@ }); | ||
onOrderChange: function onOrderChange(orderBy, order) { | ||
return _this7.loadData({ order: order, orderBy: orderBy }); | ||
return _this7.requestDataLoad({ order: order, orderBy: orderBy }); | ||
} | ||
@@ -394,3 +411,4 @@ }), | ||
limit: _react.PropTypes.number, | ||
disableAdd: _react.PropTypes.bool | ||
disableAdd: _react.PropTypes.bool, | ||
onParamsChange: _react.PropTypes.func | ||
}; | ||
@@ -414,5 +432,6 @@ | ||
disableAdd: false, | ||
limit: 20 | ||
limit: 20, | ||
onParamsChange: null | ||
}; | ||
exports.default = TableEditor; |
{ | ||
"name": "prg-editor", | ||
"version": "0.1.0", | ||
"version": "0.2.0-alpha.2", | ||
"description": "Data Table and Editor for use with Prg-Form", | ||
@@ -5,0 +5,0 @@ "main": "dist/main.js", |
96789
2146