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 () {
20 serverRequest({query_type:'workout_management_edit',id:this.props.data.id,workout_name:this.state.workout_name,attributes:this.state.attributes,comments:this.state.comments})
21 .then(function(data) {
24 .catch(function(error) {
25 console.error("WorkoutManagementWorkoutTableRows.php","workout_management_edit",error);
28 handleAttrToggle: function (attr) {
29 var attrs = JSON.parse(JSON.stringify(this.state.attributes));
30 attrs[attr]=(attrs[attr]=="No")?"Yes":"No";
31 this.setState({attributes:attrs},function () {
35 deleteToggle: function (type) {
36 this.setState({deletetd:type});
38 deleteEntry: function () {
39 var c = confirm("Are you sure you wish to delete this workout? This will also delete all data of completion of this workout.");
41 this.setState({view:"hidden"},function () {
42 serverRequest({query_type:'workout_management_delete',id:this.props.data.id})
43 .then(function(data) {
46 .catch(function(error) {
47 console.error("WorkoutManagementWorkoutTableRows.php","workout_management_delete",error);
54 for(var attr in this.state.attributes){
55 cells.push(React.createElement("td",{key:"wm-row-"+this.props.data.id+"-attr-"+attr,onClick:this.handleAttrToggle.bind(this,attr)},
56 React.createElement("span",null,this.state.attributes[attr])
59 return React.createElement("tr",{className:this.props.rowtype+" "+this.state.view},
60 React.createElement("td",{className:"inputok"},
61 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})
64 React.createElement("td",null,
65 React.createElement("span",null,this.props.data['times_done'])
67 React.createElement("td",null,
68 React.createElement("span",null,this.props.data['last_done'])
70 React.createElement("td",{className:"inputok"},
71 React.createElement("textarea",{className:"workout-management-table-comments",value:this.state.comments,onChange:this.handleValueChange.bind(this,"comments"),onBlur:this.sendValues}),
72 React.createElement("div",{className:this.state.deletetd},
73 React.createElement("div",{className:"workout-management-table-delete-container"},
74 React.createElement("i",{className:"fa fa-trash-o",onClick:this.deleteEntry})