+
{props.text}
);
}
// Plugins definition
// ---------------------
// ---------------------
class AmountRatesCost extends React.Component {
constructor(props) {
super(props);
this.state={amount : 1, SelectRate : 0 , Rate : this.props.data.Rates[Object.keys(this.props.data.Rates)[0]]};
this.handleAmountChange = this.handleAmountChange.bind(this);
this.handleRateChange = this.handleRateChange.bind(this);
}
handleAmountChange(amount) {
this.setState({amount: amount});
}
handleRateChange(select) {
this.setState({SelectRate: select});
- this.setState({Rate: this.props.data.Rates[select]});
+ this.setState({Rate: this.props.data.Rates[Object.keys(this.props.data.Rates)[select]]});
}
render() {
const Amount = this.state.amount;
const Rate=this.state.Rate;
const Cost=this.makecost(Amount,Rate);
return (
+ unit={this.props.data.AmountUnit} onChange={this.handleAmountChange} tips="Select the desired amount"/>
-
+
{/*
*/}
);
}
makecost(amount,rate) {
if (amount<=this.props.data.AmountFree){
amount=0;
}
var total=amount*rate;
total=tomoney(total);
this.props.onCostChange(this.props.n,total);
return total;
}
}
class CategoryAmountRatesCost extends React.Component {
constructor(props) {
super(props);
this.state={SelectCat : 0, Cat : this.props.data.Cat[Object.keys(this.props.data.Cat)[0]],
amount : 1, SelectRate : 0 , Rate : this.props.data.Rates[Object.keys(this.props.data.Rates)[0]]};
this.handleCatChange = this.handleCatChange.bind(this);
this.handleAmountChange = this.handleAmountChange.bind(this);
this.handleRateChange = this.handleRateChange.bind(this);
// this.handleCostChange = this.handleCostChange.bind(this);
}
handleAmountChange(amount) {
this.setState({amount: amount});
}
handleRateChange(select) {
this.setState({SelectRate: select});
- this.setState({Rate: this.props.data.Rates[select]});
+ this.setState({Rate: this.props.data.Rates[Object.keys(this.props.data.Rates)[select]]});
}
handleCatChange(select) {
this.setState({SelectCat: select});
- this.setState({Cat: this.props.data.Cat[select]});
+ this.setState({Cat: this.props.data.Cat[Object.keys(this.props.data.Cat)[select]]});
}
render() {
const Cat=this.state.Cat;
const Amount = this.state.amount;
const Rate=this.state.Rate;
const Cost=this.makecost(Cat,Amount,Rate);
return (
-
+
+ value={Amount} name={this.props.data.AmountName} unit={this.props.data.AmountUnit} onChange={this.handleAmountChange} />
-
+
{/*
*/}
);
}
makecost(cat,amount,rate) {
if (amount<=this.props.data.AmountFree){
amount=0;
}
var total=cat+amount*rate;
total=tomoney(total);
this.props.onCostChange(this.props.n,total);
return total;
}
}
class CategoryCost extends React.Component {
constructor(props) {
super(props);
this.state={SelectCat : 0, Cat : this.props.data.Cat[Object.keys(this.props.data.Cat)[0]]};
this.handleCatChange = this.handleCatChange.bind(this);
}
handleCatChange(select) {
this.setState({SelectCat: select});
- this.setState({Cat: this.props.data.Cat[select]});
+ this.setState({Cat: this.props.data.Cat[Object.keys(this.props.data.Cat)[select]]});
}
render() {
const Cat=this.state.Cat;
const Cost=this.makecost(Cat);
return (
);
}
makecost(cat) {
var total=cat;
total=tomoney(total);
this.props.onCostChange(this.props.n,total);
return total;
}
}
class NoneSelect extends React.Component {
constructor(props) {
super(props);
}
render() {
const Cost=tomoney(0);
this.props.onCostChange(this.props.n,Cost);
return (
Please select a provider in the list.
);
}
}
// Combine plugins
// ---------------------
// ---------------------
class ProviderPluginsSelector extends React.Component {
constructor(props) {
super(props);
this.handleCostChange = this.handleCostChange.bind(this);
this.handleProviderChange = this.handleProviderChange.bind(this);
- this.handleEnableChange = this.handleEnableChange.bind(this);
+ this.handleCommentChange = this.handleCommentChange.bind(this);
this.handleAddPlugin = this.handleAddPlugin.bind(this);
+
this.state={
selected:0,
keys:this.ProvidersName(props.data),
enabled :true,
n:1,
cost:0,
prevcost:0,
+ comments:"",
};
}
handleCostChange(n,e) {
// console.log("here n : "+n+" e = "+ e);
if(! this.state.enabled){
e=0;
}
if (this.state.prevcost != e ) {
this.setState({cost: e});
this.setState({prevcost: e});
this.props.handleCostChange(n,e);}
}
- handleProviderChange(e){
- const select=this.state.keys.indexOf(e.target.value);
+ handleProviderChange(select){
+
this.setState({selected:select});
}
- handleEnableChange(e){
- this.setState({enabled:e});
+ handleCommentChange(com){
+ this.setState({comments:com});
}
handleAddPlugin(n){
this.props.handleAddPlugin(n);
}
makemenu(data,n){
if (((data.url != '')||(data.url==null))&&(n==0)) {
- return (
);
+ return (
} options={data.url} id="btn-plugin-knowmore" class="btn-primary" tips={"Know more about "+data.name}/>);
}
}
makeinfo(selected,Cdata){
if (selected>0){
return (
{this.state.keys[selected]} : {Cdata.name});
}
+ else {
+ return (
{Cdata.name});
+ }
}
render() {
// console.log("n= "+this.props.n)
const Cmp=this.cmp2string(this.cmpdata(this.state.selected).style);
const Cdata=this.cmpdata(this.state.selected);
const id=this.props.data.name.replace(/\s/g,'')+this.props.n;
const Cost=this.state.cost;
const selected=this.state.selected;
return(
-
+
-
- {/*
-
-
*/}
-
-
-
-
-