You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.2 KiB

  1. package react;
  2. import react.ReactComponent;
  3. import react.ReactMacro.jsx;
  4. import Common;
  5. //datepicker broken if called like this //import react.DateTimeField.*;
  6. //@:jsRequire('react-bootstrap-datetimepicker')
  7. //extern class DateTimeField extends react.ReactComponent {}
  8. /**
  9. * @doc https://github.com/YouCanBookMe/react-datetime
  10. */
  11. @:jsRequire('react-datetime')
  12. extern class DateTime extends react.ReactComponent {}
  13. /**
  14. * ...
  15. * @author fbarbut
  16. */
  17. class ReportHeader extends react.ReactComponentOfState<OrdersReportOptions>
  18. {
  19. public function new()
  20. {
  21. super();
  22. state = {startDate:null, endDate:null, groupBy:null, contracts:[]};
  23. //load fr locale of moment.js
  24. var moment = js.Lib.require('moment');
  25. js.Lib.require('moment/locale/fr');
  26. }
  27. override public function render(){
  28. return jsx('<div className="reportHeader">
  29. <div className="col-md-3">
  30. <div className="input-group">
  31. <span className="input-group-addon">
  32. <span className="glyphicon glyphicon-calendar"></span>
  33. </span>
  34. <DateTime name="startDate_PROUT" onChange={onDateChange} locale="fr" dateFormat="LLLL" />
  35. </div>
  36. </div>
  37. <div className="col-md-3">
  38. <DateTime name="endDate" onChange={onDateChange} inputFormat="YYYY-MM-DD HH:mm:ss" />
  39. </div>
  40. <div className="col-md-3">
  41. <select className="form-control" onChange={onGroupByChange}>
  42. <option value="ByMember">Par adhérent</option>
  43. <option value="ByProduct">Par Produit</option>
  44. </select>
  45. </div>
  46. <div className="col-md-3">
  47. <a className="btn btn-primary">Afficher</a>
  48. </div>
  49. </div>');
  50. }
  51. function onDateChange(e:js.html.Event){
  52. trace("onDateChange");
  53. //var name :String = untyped e.target.name;
  54. //var value :String = untyped e.target.value;
  55. //trace('$name $value');
  56. trace(e);
  57. //e.preventDefault();
  58. }
  59. /**
  60. * @doc https://facebook.github.io/react/docs/forms.html
  61. */
  62. function onGroupByChange(e:js.html.Event){
  63. e.preventDefault();
  64. trace("onGRoupByChange");
  65. var name :String = untyped e.target.name;
  66. var value :String = untyped e.target.value;
  67. if (value == "ByMember"){
  68. state.groupBy = ByMember;
  69. }else{
  70. state.groupBy = ByProduct;
  71. }
  72. trace(state);
  73. setState(state);
  74. }
  75. }