AjaxFieldForDataTable.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\Core\UI\Widget\Others;
  3. use \ThurData\Servers\KerioEmail\Core\UI\Builder\BaseContainer;
  4. use \ThurData\Servers\KerioEmail\Core\UI\ResponseTemplates;
  5. /**
  6. * AjaxFieldForDataTable - a field that will load its content after creation
  7. *
  8. * @autor ThurData <info@thrudata.ch>
  9. */
  10. class AjaxFieldForDataTable extends BaseContainer implements \ThurData\Servers\KerioEmail\Core\UI\Interfaces\AjaxElementInterface
  11. {
  12. protected $id = 'ajaxFieldForDataTable';
  13. protected $name = 'ajaxFieldForDataTable';
  14. protected $vueComponent = true;
  15. protected $defaultVueComponentName = 'dt-ajax-field';
  16. protected $asyncLoading = true;
  17. protected $ajaxData = null;
  18. public function changeAsyncLoading($load = true)
  19. {
  20. $this->asyncLoading = (bool)$load;
  21. }
  22. public function getAsyncLoaging()
  23. {
  24. return $this->asyncLoading;
  25. }
  26. public function setAjaxData($ajaxData = null)
  27. {
  28. $this->ajaxData = $ajaxData;
  29. return $this;
  30. }
  31. public function getAjaxData()
  32. {
  33. return $this->ajaxData;
  34. }
  35. public function prepareAjaxData()
  36. {
  37. //to be overwritten
  38. //set here $this->ajaxData value
  39. }
  40. public function returnAjaxData()
  41. {
  42. $this->prepareAjaxData();
  43. return (new ResponseTemplates\RawDataJsonResponse(['ajaxData' => $this->ajaxData]))
  44. ->setCallBackFunction($this->callBackFunction)->setRefreshTargetIds($this->refreshActionIds);
  45. }
  46. }