123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = void 0;
- var _react = _interopRequireDefault(require("react"));
- var _modularityFront = _interopRequireDefault(require("modularity-front"));
- var _Stepper = _interopRequireDefault(require("@material-ui/core/Stepper"));
- var _Step = _interopRequireDefault(require("@material-ui/core/Step"));
- var _StepLabel = _interopRequireDefault(require("@material-ui/core/StepLabel"));
- var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
- var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
- var _DictionaryService = _interopRequireDefault(require("../Services/DictionaryService"));
- require("./Stepper.css");
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- 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); }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- 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); } }
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
- function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
- function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
- 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); }
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
- var Module = _modularityFront.default.Module;
- var StepperModule =
- /*#__PURE__*/
- function (_Modularity$Module) {
- _inherits(StepperModule, _Modularity$Module);
- function StepperModule(props) {
- var _this;
- _classCallCheck(this, StepperModule);
- _this = _possibleConstructorReturn(this, _getPrototypeOf(StepperModule).call(this, props));
- _this.state = {
- activeStep: 0
- };
- _this.checkUrl();
- _this.RoutingSystem.onRouteChange("StepperModule" + _this.getId(), function () {
- _this.checkUrl();
- });
- return _this;
- }
- _createClass(StepperModule, [{
- key: "checkUrl",
- value: function checkUrl() {
- var _this2 = this;
- var route = this.RoutingSystem.getRoute();
- var steps = this.props.steps;
- var flag = 0;
- steps.map(function (step, index) {
- if (route.url.endsWith(step.url)) {
- // window.history.replaceState({}, '',step.url);
- flag = 1;
- Promise.resolve(step.resolve && step.resolve()).then(function () {
- return _this2.setState({
- activeStep: index
- });
- });
- }
- });
- }
- }, {
- key: "handleNext",
- value: function handleNext() {
- var _this3 = this;
- if (this.props.lock) return;
- var steps = this.props.steps;
- var newStep = this.state.activeStep + 1;
- var nextStep = steps[newStep];
- Promise.resolve(nextStep.resolve && nextStep.resolve()).then(function () {
- _this3.CoreSystem.go(nextStep.url, {});
- _this3.setState(function (state) {
- return {
- activeStep: newStep
- };
- });
- }).then(function () {
- return Promise.resolve(nextStep.postResolve && nextStep.postResolve());
- }).then(function () {
- return _this3.props.onNext && _this3.props.onNext(newStep);
- });
- }
- }, {
- key: "handleBack",
- value: function handleBack() {
- var _this4 = this;
- if (this.props.lock) return;
- var steps = this.props.steps;
- var newStep = this.state.activeStep - 1;
- var prevStep = steps[newStep];
- Promise.resolve(prevStep.resolve && prevStep.resolve()).then(function () {
- _this4.CoreSystem.go(prevStep.url, {});
- _this4.setState(function (state) {
- return {
- activeStep: newStep
- };
- });
- }).then(function () {
- return Promise.resolve(prevStep.postResolve && prevStep.postResolve());
- }).then(function () {
- return _this4.props.onBack && _this4.props.onBack(_this4.state.activeStep - 1);
- });
- }
- }, {
- key: "handleReset",
- value: function handleReset() {
- if (this.props.lock) return;
- this.setState({
- activeStep: 0
- });
- }
- }, {
- key: "render",
- value: function render() {
- var _this5 = this;
- var steps = this.props.steps;
- var activeStep = this.state.activeStep;
- var step_text;
- var step = steps[activeStep];
- return _react.default.createElement("div", {
- className: "stepper_container"
- }, _react.default.createElement(_Stepper.default, {
- className: "row stepper",
- activeStep: activeStep,
- alternativeLabel: true
- }, steps.map(function (label) {
- return _react.default.createElement(_Step.default, {
- key: label.title
- }, _react.default.createElement(_StepLabel.default, null, label.title));
- })), _react.default.createElement("div", {
- className: "step_but"
- }, this.state.activeStep === steps.length ? _react.default.createElement("div", null, _react.default.createElement(_Typography.default, null, _DictionaryService.default.get("All steps completed")), _react.default.createElement(_Button.default, {
- onClick: function onClick() {
- return _this5.handleReset();
- },
- disabled: this.props.lock
- }, _DictionaryService.default.get("Reset"))) : _react.default.createElement("div", null, step.content, _react.default.createElement("div", null, _react.default.createElement(_Button.default, {
- disabled: activeStep === 0 || this.props.lock,
- onClick: function onClick() {
- return _this5.handleBack();
- },
- className: "prev_step_but"
- }, _DictionaryService.default.get("Back")), this.state.activeStep < steps.length - 1 && _react.default.createElement(_Button.default, {
- disabled: this.props.lock,
- variant: "contained",
- color: "primary",
- onClick: function onClick() {
- return _this5.handleNext();
- }
- }, step.button)))), _get(_getPrototypeOf(StepperModule.prototype), "render", this).call(this));
- }
- }]);
- return StepperModule;
- }(_modularityFront.default.Module);
- StepperModule.EditPosition = "center";
- StepperModule.Inputs = {
- Products: {
- type: Module.Types.Object
- },
- Token: {
- type: Module.Types.Text
- }
- };
- StepperModule.Outputs = {
- selectedProduct: {}
- };
- StepperModule.Category = "Sxoinas Packages";
- var _default = StepperModule;
- exports.default = _default;
|