1 <script type="text/javascript">
2 var WorkoutManagementWorkoutTableRows = React.createClass({//Workout Management Table Rows
3 getInitialState: function () {
4 var attrs = JSON.parse(JSON.stringify(this.props.data.attrs));
5 return {workout_name:this.props.data.name,comments:this.props.data.comments,attributes:attrs,view:""};
7 handleValueChange: function(type,event) {
10 this.setState({workout_name:event.target.value});
13 this.setState({comments:event.target.value});
19 sendValues: function () {
23 data: {query_type:'workout_management_edit',id:this.props.data.id,workout_name:this.state.workout_name,attributes:this.state.attributes,comments:this.state.comments},
24 success: function(data){
27 error: function (xhr,status,err) {
28 console.error("WorkoutManagementWorkoutTableRows.php","workout_management_edit",status,err.toString());
32 handleAttrToggle: function (attr) {
33 var attrs = JSON.parse(JSON.stringify(this.state.attributes));
34 attrs[attr]=(attrs[attr]=="No")?"Yes":"No";
35 this.setState({attributes:attrs},function () {
39 deleteToggle: function (type) {
40 this.setState({deletetd:type});
42 deleteEntry: function () {
43 var c = confirm("Are you sure you wish to delete this workout? This will also delete all data of completion of this workout.");
45 this.setState({view:"hidden"},function () {
49 data: {query_type:'workout_management_delete',id:this.props.data.id},
50 success: function(data){
53 error: function (xhr,status,err) {
54 console.error("WorkoutManagementWorkoutTableRows.php","workout_management_delete",status,err.toString());
62 for(var attr in this.state.attributes){
63 cells.push(React.createElement("td",{key:"wm-row-"+this.props.data.id+"-attr-"+attr,onClick:this.handleAttrToggle.bind(this,attr)},
64 React.createElement("span",null,this.state.attributes[attr])
67 return React.createElement("tr",{className:this.props.rowtype+" "+this.state.view},
68 React.createElement("td",{className:"inputok"},
69 React.createElement("input",{className:"workout-management-table-input",value:this.state.workout_name,type:"text",onChange:this.handleValueChange.bind(this,"workout_name"),onBlur:this.sendValues})
72 React.createElement("td",null,
73 React.createElement("span",null,this.props.data['times_done'])
75 React.createElement("td",null,
76 React.createElement("span",null,this.props.data['last_done'])
78 React.createElement("td",{className:"inputok"},
79 React.createElement("textarea",{className:"workout-management-table-comments",value:this.state.comments,onChange:this.handleValueChange.bind(this,"comments"),onBlur:this.sendValues}),
80 React.createElement("div",{className:this.state.deletetd},
81 React.createElement("div",{className:"workout-management-table-delete-container"},
82 React.createElement("i",{className:"fa fa-trash-o",onClick:this.deleteEntry})