CrudService.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _react = _interopRequireDefault(require("react"));
  7. var _modularityFront = _interopRequireDefault(require("modularity-front"));
  8. var _Repository = _interopRequireDefault(require("./Repository"));
  9. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  11. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  15. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  16. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  17. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  18. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  19. var _Modularity$ModuleUti = _modularityFront.default.ModuleUtilities,
  20. RendererInput = _Modularity$ModuleUti.RendererInput,
  21. OutputLink = _Modularity$ModuleUti.OutputLink;
  22. var CrudService =
  23. /*#__PURE__*/
  24. function (_Modularity$Service) {
  25. _inherits(CrudService, _Modularity$Service);
  26. function CrudService(props) {
  27. var _this;
  28. _classCallCheck(this, CrudService);
  29. _this = _possibleConstructorReturn(this, _getPrototypeOf(CrudService).call(this, props));
  30. _this.Table.onUpdate(function () {
  31. return _this.updateService();
  32. });
  33. _this.Token.onUpdate(function () {
  34. return _this.updateService();
  35. });
  36. _this.Filters.onUpdate(function (value) {
  37. console.log(value, _this.Filters.value);
  38. _this.updateService();
  39. });
  40. _this.updateService();
  41. return _this;
  42. }
  43. _createClass(CrudService, [{
  44. key: "updateService",
  45. value: function updateService() {
  46. if (this.Table.value) {
  47. console.log("F", this.Filters.value);
  48. var service = new _Repository.default(this.Table.value, this.Token.value, this.Filters.value);
  49. this.Service.set(service);
  50. }
  51. }
  52. }, {
  53. key: "render",
  54. value: function render() {
  55. return _react.default.createElement("div", null, this.__renderID(), _react.default.createElement("div", {
  56. className: "col s12"
  57. }, this.__factoryInput(this.Token)), _react.default.createElement("div", {
  58. className: "col s12"
  59. }, this.__factoryInput(this.Table)), _react.default.createElement("div", {
  60. className: "col s12"
  61. }, this.__factoryInput(this.Filters)), _react.default.createElement("div", {
  62. className: "col s12"
  63. }, _react.default.createElement(OutputLink, {
  64. output: this.Service
  65. })));
  66. }
  67. }]);
  68. return CrudService;
  69. }(_modularityFront.default.Service);
  70. CrudService.Outputs = {
  71. Service: {}
  72. };
  73. CrudService.Inputs = {
  74. Table: {
  75. type: _modularityFront.default.Module.Types.Text,
  76. defaultValue: "products"
  77. },
  78. Filters: {
  79. type: _modularityFront.default.Module.Types.Link
  80. },
  81. Token: {
  82. type: _modularityFront.default.Module.Types.Text,
  83. defaultValue: "123123"
  84. }
  85. };
  86. CrudService.Category = "Services";
  87. var _default = CrudService;
  88. exports.default = _default;