PageSourceSearch

https://cdn.infourok.ru/assets/rewards/controllers/rewards/job-selection_controller-DxXyI9j.js

js infourok.ru collected 2026-09-24 08:53:57 UTC 9,767 bytes, 230 lines download raw bytes

1/// <reference path="../../../../../../../global.d.ts" />
2/// <reference path="../../../../../../../iu.d.ts" />
3function _assert_this_initialized(self) {
4    if (self === void 0) {
5        throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
6    }
7    return self;
8}
9function _class_call_check(instance, Constructor) {
10    if (!(instance instanceof Constructor)) {
11        throw new TypeError("Cannot call a class as a function");
12    }
13}
14function _defineProperties(target, props) {
15    for(var i = 0; i < props.length; i++){
16        var descriptor = props[i];
17        descriptor.enumerable = descriptor.enumerable || false;
18        descriptor.configurable = true;
19        if ("value" in descriptor) descriptor.writable = true;
20        Object.defineProperty(target, descriptor.key, descriptor);
21    }
22}
23function _create_class(Constructor, protoProps, staticProps) {
24    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
25    if (staticProps) _defineProperties(Constructor, staticProps);
26    return Constructor;
27}
28function _define_property(obj, key, value) {
29    if (key in obj) {
30        Object.defineProperty(obj, key, {
31            value: value,
32            enumerable: true,
33            configurable: true,
34            writable: true
35        });
36    } else {
37        obj[key] = value;
38    }
39    return obj;
40}
41function _get_prototype_of(o) {
42    _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
43        return o.__proto__ || Object.getPrototypeOf(o);
44    };
45    return _get_prototype_of(o);
46}
47function _inherits(subClass, superClass) {
48    if (typeof superClass !== "function" && superClass !== null) {
49        throw new TypeError("Super expression must either be null or a function");
50    }
51    subClass.prototype = Object.create(superClass && superClass.prototype, {
52        constructor: {
53            value: subClass,
54            writable: true,
55            configurable: true
56        }
57    });
58    if (superClass) _set_prototype_of(subClass, superClass);
59}
60function _possible_constructor_return(self, call) {
61    if (call && (_type_of(call) === "object" || typeof call === "function")) {
62        return call;
63    }
64    return _assert_this_initialized(self);
65}
66function _set_prototype_of(o, p) {
67    _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
68        o.__proto__ = p;
69        return o;
70    };
71    return _set_prototype_of(o, p);
72}
73function _type_of(obj) {
74    "@swc/helpers - typeof";
75    return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
76}
77function _is_native_reflect_construct() {
78    if (typeof Reflect === "undefined" || !Reflect.construct) return false;
79    if (Reflect.construct.sham) return false;
80    if (typeof Proxy === "function") return true;
81    try {
82        Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
83        return true;
84    } catch (e) {
85        return false;
86    }
87}
88function _create_super(Derived) {
89    var hasNativeReflectConstruct = _is_native_reflect_construct();
90    return function _createSuperInternal() {
91        var Super = _get_prototype_of(Derived), result;
92        if (hasNativeReflectConstruct) {
93            var NewTarget = _get_prototype_of(this).constructor;
94            result = Reflect.construct(Super, arguments, NewTarget);
95        } else {
96            result = Super.apply(this, arguments);
97        }
98        return _possible_constructor_return(this, result);
99    };
100}
101import { Controller } from "@hotwired/stimulus";
102var _class = /*#__PURE__*/ function(Controller) {
103    "use strict";
104    _inherits(_class, Controller);
105    var _super = _create_super(_class);
106    function _class() {
107        _class_call_check(this, _class);
108        var _this;
109        _this = _super.apply(this, arguments);
110        _define_property(_assert_this_initialized(_this), "selectionWorkPlace", function(event) {
111            event === null || event === void 0 ? void 0 : event.preventDefault();
112            window.renderSchoolMap({
113                event: event,
114                ignoreValidation: false,
115                setSchoolOnChoose: true,
116                select: function(id, name, response) {
117                    if (!response.error) {
118                        _this.schoolIdValue = id;
119                        _this.schoolNameValue = name;
120                        _this.schoolNameTarget.value = name;
121                    }
122                }
123            });
124        });
125        _define_property(_assert_this_initialized(_this), "checkBoxChange", function(evt) {
126            var description = _this.descriptionTextTarget;
127            if (evt.target.checked) {
128                description.textContent = "На Ваших наградных документах будет указано место работы:";
129                _this.selectionWorkPlaceButtonTarget.classList.add("job-selection__change-button--hide");
130                _this.schoolNameTarget.disabled = false;
131                _this.schoolNameTarget.placeholder = "Введите название компании";
132                _this.schoolNameTarget.value = Number(_this.schoolIdValue) > 0 ? "" : _this.schoolNameValue;
133            } else {
134                _this.showErrorMessage();
135                _this.selectionWorkPlaceButtonTarget.classList.remove("job-selection__change-button--hide");
136                _this.saveWorkPlaceButtonTarget.classList.remove("job-selection__save-button--active");
137                description.textContent = "На Ваших наградных документах будет указано образовательное учреждение:";
138                _this.schoolNameTarget.placeholder = Number(_this.schoolIdValue) > 0 ? _this.schoolNameValue : "Образовательное учреждение (ОУ) не указано";
139                _this.schoolNameTarget.value = _this.schoolIdValue === "-1" ? "" : _this.schoolNameValue;
140                _this.schoolNameTarget.disabled = true;
141            }
142        });
143        _define_property(_assert_this_initialized(_this), "schoolNameInputWatcher", function() {
144            if (!_this.hasSchoolNameTarget) return;
145            var oldValue = _this.schoolNameTarget.value;
146            _this.schoolNameTarget.addEventListener("input", function(event) {
147                event.preventDefault();
148                if (_this.schoolNameTarget.value !== oldValue) {
149                    _this.saveWorkPlaceButtonTarget.classList.add("job-selection__save-button--active");
150                } else {
151                    _this.saveWorkPlaceButtonTarget.classList.remove("job-selection__save-button--active");
152                }
153                _this.showErrorMessage();
154            });
155        });
156        _define_property(_assert_this_initialized(_this), "preventSubmit", function(event) {
157            event.preventDefault();
158            event.stopPropagation();
159        });
160        _define_property(_assert_this_initialized(_this), "onClickEnter", function(event) {
161            event.preventDefault();
162            event.stopPropagation();
163            if (_this.saveWorkPlaceButtonTarget.classList.contains("job-selection__save-button--active")) {
164                _this.saveWorkPlace();
165            }
166        });
167        return _this;
168    }
169    _create_class(_class, [
170        {
171            key: "connect",
172            value: function connect() {
173                this.schoolNameInputWatcher();
174            }
175        },
176        {
177            key: "saveWorkPlace",
178            value: function saveWorkPlace() {
179                var _this = this;
180                iu.ajax({
181                    target: this.saveWorkPlaceButtonTarget
182                }, "/ajax/setSchoolText", {
183                    "UserData[id_school]": "-1",
184                    "UserData[workplace]": this.schoolNameTarget.value.trim()
185                }, function(response) {
186                    if (response.error) {
187                        var error = response.error;
188                        if (error.msg) {
189                            _this.showErrorMessage(error.msg);
190                        }
191                    } else {
192                        _this.showErrorMessage();
193                        _this.schoolIdValue = "-1";
194                        _this.saveWorkPlaceButtonTarget.classList.remove("job-selection__save-button--active");
195                        _this.schoolNameValue = _this.schoolNameTarget.value.trim();
196                        _this.schoolNameTarget.value = _this.schoolNameValue;
197                    }
198                });
199            }
200        },
201        {
202            key: "showErrorMessage",
203            value: function showErrorMessage(text) {
204                var iuInput = this.schoolNameTarget.closest(".iu-input");
205                if (text) {
206                    iuInput === null || iuInput === void 0 ? void 0 : iuInput.classList.add("iu-input--error");
207                    this.errorMsgTarget.classList.add("job-selection__error-msg--error");
208                    this.errorMsgTarget.textContent = text;
209                } else {
210                    iuInput === null || iuInput === void 0 ? void 0 : iuInput.classList.remove("iu-input--error");
211                    this.errorMsgTarget.classList.remove("job-selection__error-msg--error");
212                    this.errorMsgTarget.textContent = "";
213                }
214            }
215        }
216    ]);
217    return _class;
218}(Controller);
219_define_property(_class, "values", {
220    schoolId: String,
221    schoolName: String
222});
223_define_property(_class, "targets", [
224    "schoolName",
225    "errorMsg",
226    "descriptionText",
227    "selectionWorkPlaceButton",
228    "saveWorkPlaceButton"
229]);
230/* stimulusFetch: 'lazy' */ export { _class as default };

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.