+ comments={this.state.comments} handleAddPlugin={this.handleAddPlugin} handleRmvPlugin={this.handleRmvPlugin}
+ keys={this.state.keys} show_minus={this.props.show_minus} />
);
}
cmpdata(select){return this.props.data.Data[select];}
cmp2string(str){
switch (str) {
case "AmountRatesCost" : return AmountRatesCost;
case "CategoryCost" : return CategoryCost;
case "CategoryAmountRatesCost" : return CategoryAmountRatesCost;
case "NoneSelect":return NoneSelect;
}
}
ProvidersName(main){
const data = main.Data;
// console.log(data);
var providers=[];
for (var i = 0; i < data.length; i++) {
providers.push(data[i].Provider);
}
return providers;
}
}
function makeinfo(keys,selected,Cdata){
if (selected>0){
return (
{keys[selected]} : {Cdata.name});
}
else {
return (
{Cdata.name});
}
}
class ModuleHeader extends React.Component{
constructor(props) {
super(props);
this.handleAddPlugin = this.handleAddPlugin.bind(this);
+ this.handleRmvPlugin = this.handleRmvPlugin.bind(this);
}
handleAddPlugin(n){
this.props.handleAddPlugin(n);
}
-
+ handleRmvPlugin(n){
+ this.props.handleRmvPlugin(n);
+ }
render() {
+ let minus='';
+ if (this.props.show_minus){
+ minus=
}
+ onClick={this.handleRmvPlugin} n={this.props.n} tips={"Remove this line"}
+ idp={this.props.id} info={this.props.data.Name}/>;
+ }
return(
-
+
+
} onClick={this.handleAddPlugin} n={this.props.n} tips={"Add a new "+this.props.data.Name}/>
+
+ {minus}
+
+
{makeinfo(this.props.keys,this.props.selected,this.props.Cdata,this.props.n)}
{this.props.comments}
);
}
}
class ManagePlugins extends React.Component{
constructor(props) {
super(props);
this.handleCostChange = this.handleCostChange.bind(this);
this.handleAddPlugin = this.handleAddPlugin.bind(this);
- this.handleRemovePlugin = this.handleRemovePlugin.bind(this);
+ this.handleRmvPlugin = this.handleRmvPlugin.bind(this);
+
this.state={
- n:1,
- 'varsum':{}
+ displayed:[],
+ varsum:{}
};
+ this.state.displayed.push(this.randomint());
}
- handleRemovePlugin(key){
- const n=this.state.n+1;
- this.setState({n:n});
+ handleRmvPlugin(n){
+ console.log("remove : "+n);
+ console.log(this.state.displayed);
+
+ $('#'+n.target).modal('hide');
+ var tmp=this.state.displayed;
+ tmp.splice(n.n,1);
+ this.setState({displayed:tmp});
+ console.log(this.state.displayed);
+ this.handleCostChange(n.n,0);
+
}
- handleAddPlugin(key){
- const n=this.state.n+1;
- this.setState({n:n});
+ handleAddPlugin(n){
+ var tmp=this.state.displayed;
+ tmp.splice(n+1,0,this.randomint());
+ this.setState({displayed:tmp});
}
- handleCostChange(name,e) {
- this.state.varsum[name]=e;
+ handleCostChange(n,cost) {
+ console.log("here");
+ this.state.varsum[n]=cost;
this.props.handleCostChange(this.props.n,sum(this.state.varsum));
}
+ randomint(){
+ const tmp=this.state.displayed;
+ var rnd;
+ do {
+ rnd=Math.floor(Math.random() * 100);
+ var cont=false;
+ for (let i = 0; i < tmp.length ; i++) {
+ if (tmp[i]==rnd){
+ cont=true;
+ }
+ }
+ } while(cont);
+ return rnd;
+ }
+ give_id(index){
+ return this.state.displayed[index]
+ }
+ give_n(){
+ const disp=this.state.displayed;
+ // console.log(disp);
+ // var n=0;
+ // for (let i in disp) {
+ // console.log("here");
+ // if (disp[i] == true ){
+ // n++;
+ // }
+ // }
+ // console.log("n= "+n)
+ return disp.length
+ }
+
render() {
- return(
-
- {(index) => }
+ let show_minus = false;
+ if (this.give_n()>1) {
+ show_minus=true;
+ }
+ return(
+
+ {(index) => }
);}
}
class PluginsMain extends React.Component {
constructor(props) {
super(props);
this.handleCostChange = this.handleCostChange.bind(this);
this.state={'varsum':{}};
}
handleCostChange(name,e) {
// console.log("name"+name);
this.state.varsum[name]=e;
this.props.TotalCost(sum(this.state.varsum));
}
render() {
return(
{(index) => }
);
}
}
// ---------------------
// ---------------------
class Main extends React.Component {
constructor(props) {
super(props);
this.handleCostChange = this.handleCostChange.bind(this);
this.state={'total':0,'prevtotal':0};
}
handleCostChange(total) {
// console.log("there total : "+total )
if (this.state.prevtotal != total){
// console.log("updated :"+total);
// console.log("prev :"+this.state.prevtotal);
this.setState({'total':total});
this.setState({'prevtotal':total});
}
}
render() {
return(
);
}
}
// ---------------------
// ---------------------
ReactDOM.render(,document.getElementById('root'));
+$(document).ready(function(){
+ $('[data-toggle="popover"]').popover();
+});
$(function () {
$('[data-toggle="tooltip"]').tooltip()
-})
\ No newline at end of file
+});
+$('.popover-dismiss').popover({
+ trigger: 'focus'
+});
+
+