headmin 0.2.7 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/views/examples/admin.html.erb +1 -1
- data/app/views/headmin/_card.html.erb +3 -1
- data/app/views/headmin/_filters.html.erb +2 -2
- data/app/views/headmin/_pagination.html.erb +2 -4
- data/app/views/headmin/_table.html.erb +9 -3
- data/app/views/headmin/filters/_date.html.erb +5 -3
- data/app/views/headmin/filters/_flatpickr.html.erb +57 -0
- data/app/views/headmin/forms/_base.html.erb +12 -11
- data/app/views/headmin/forms/_blocks.html.erb +1 -1
- data/app/views/headmin/forms/_date.html.erb +24 -12
- data/app/views/headmin/forms/_date_range.html.erb +84 -0
- data/app/views/headmin/forms/_flatpickr.html.erb +55 -0
- data/app/views/headmin/forms/_flatpickr_range.html.erb +61 -0
- data/app/views/headmin/forms/_hidden.html.erb +23 -0
- data/app/views/headmin/forms/_label.html.erb +3 -1
- data/app/views/headmin/forms/_select.html.erb +14 -11
- data/app/views/headmin/forms/_text.html.erb +7 -9
- data/app/views/headmin/layout/_main.html.erb +11 -5
- data/app/views/headmin/table/_actions.html.erb +1 -3
- data/app/views/headmin/table/body/_row.html.erb +14 -6
- data/dist/css/headmin.css +4 -1
- data/dist/js/headmin.js +40 -5
- data/lib/headmin/version.rb +1 -1
- data/src/js/headmin/controllers/date_range_controller.js +34 -0
- data/src/js/headmin/controllers/flatpickr_controller.js +38 -0
- data/src/js/headmin/controllers/repeater_controller.js +0 -1
- data/src/js/headmin/controllers/table_actions_controller.js +7 -37
- data/src/js/headmin/controllers/table_controller.js +23 -3
- data/src/js/headmin/headmin.js +36 -19
- data/src/scss/headmin/form.scss +4 -0
- metadata +10 -3
data/dist/js/headmin.js
CHANGED
@@ -935,6 +935,17 @@ eval("\nif (typeof Object.assign !== \"function\") {\n Object.assign = functi
|
|
935
935
|
|
936
936
|
/***/ }),
|
937
937
|
|
938
|
+
/***/ "./node_modules/flatpickr/dist/l10n/nl.js":
|
939
|
+
/*!************************************************!*\
|
940
|
+
!*** ./node_modules/flatpickr/dist/l10n/nl.js ***!
|
941
|
+
\************************************************/
|
942
|
+
/*! no static exports found */
|
943
|
+
/***/ (function(module, exports, __webpack_require__) {
|
944
|
+
|
945
|
+
eval("(function (global, factory) {\n true ? factory(exports) :\n undefined;\n}(this, (function (exports) { 'use strict';\n\n var fp = typeof window !== \"undefined\" && window.flatpickr !== undefined\n ? window.flatpickr\n : {\n l10ns: {},\n };\n var Dutch = {\n weekdays: {\n shorthand: [\"zo\", \"ma\", \"di\", \"wo\", \"do\", \"vr\", \"za\"],\n longhand: [\n \"zondag\",\n \"maandag\",\n \"dinsdag\",\n \"woensdag\",\n \"donderdag\",\n \"vrijdag\",\n \"zaterdag\",\n ],\n },\n months: {\n shorthand: [\n \"jan\",\n \"feb\",\n \"mrt\",\n \"apr\",\n \"mei\",\n \"jun\",\n \"jul\",\n \"aug\",\n \"sept\",\n \"okt\",\n \"nov\",\n \"dec\",\n ],\n longhand: [\n \"januari\",\n \"februari\",\n \"maart\",\n \"april\",\n \"mei\",\n \"juni\",\n \"juli\",\n \"augustus\",\n \"september\",\n \"oktober\",\n \"november\",\n \"december\",\n ],\n },\n firstDayOfWeek: 1,\n weekAbbreviation: \"wk\",\n rangeSeparator: \" t/m \",\n scrollTitle: \"Scroll voor volgende / vorige\",\n toggleTitle: \"Klik om te wisselen\",\n time_24hr: true,\n ordinal: function (nth) {\n if (nth === 1 || nth === 8 || nth >= 20)\n return \"ste\";\n return \"de\";\n },\n };\n fp.l10ns.nl = Dutch;\n var nl = fp.l10ns;\n\n exports.Dutch = Dutch;\n exports.default = nl;\n\n Object.defineProperty(exports, '__esModule', { value: true });\n\n})));\n\n\n//# sourceURL=webpack:///./node_modules/flatpickr/dist/l10n/nl.js?");
|
946
|
+
|
947
|
+
/***/ }),
|
948
|
+
|
938
949
|
/***/ "./node_modules/sortablejs/modular/sortable.esm.js":
|
939
950
|
/*!*********************************************************!*\
|
940
951
|
!*** ./node_modules/sortablejs/modular/sortable.esm.js ***!
|
@@ -977,7 +988,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _hea
|
|
977
988
|
/*! no static exports found */
|
978
989
|
/***/ (function(module, exports, __webpack_require__) {
|
979
990
|
|
980
|
-
eval("var map = {\n\t\"./blocks_controller.js\": \"./src/js/headmin/controllers/blocks_controller.js\",\n\t\"./filter_controller.js\": \"./src/js/headmin/controllers/filter_controller.js\",\n\t\"./filters_controller.js\": \"./src/js/headmin/controllers/filters_controller.js\",\n\t\"./popup_controller.js\": \"./src/js/headmin/controllers/popup_controller.js\",\n\t\"./repeater_controller.js\": \"./src/js/headmin/controllers/repeater_controller.js\",\n\t\"./table_actions_controller.js\": \"./src/js/headmin/controllers/table_actions_controller.js\",\n\t\"./table_controller.js\": \"./src/js/headmin/controllers/table_controller.js\"\n};\n\n\nfunction webpackContext(req) {\n\tvar id = webpackContextResolve(req);\n\treturn __webpack_require__(id);\n}\nfunction webpackContextResolve(req) {\n\tif(!__webpack_require__.o(map, req)) {\n\t\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\t\te.code = 'MODULE_NOT_FOUND';\n\t\tthrow e;\n\t}\n\treturn map[req];\n}\nwebpackContext.keys = function webpackContextKeys() {\n\treturn Object.keys(map);\n};\nwebpackContext.resolve = webpackContextResolve;\nmodule.exports = webpackContext;\nwebpackContext.id = \"./src/js/headmin/controllers sync recursive \\\\.js$\";\n\n//# sourceURL=webpack:///./src/js/headmin/controllers_sync_\\.js$?");
|
991
|
+
eval("var map = {\n\t\"./blocks_controller.js\": \"./src/js/headmin/controllers/blocks_controller.js\",\n\t\"./date_range_controller.js\": \"./src/js/headmin/controllers/date_range_controller.js\",\n\t\"./filter_controller.js\": \"./src/js/headmin/controllers/filter_controller.js\",\n\t\"./filters_controller.js\": \"./src/js/headmin/controllers/filters_controller.js\",\n\t\"./flatpickr_controller.js\": \"./src/js/headmin/controllers/flatpickr_controller.js\",\n\t\"./popup_controller.js\": \"./src/js/headmin/controllers/popup_controller.js\",\n\t\"./repeater_controller.js\": \"./src/js/headmin/controllers/repeater_controller.js\",\n\t\"./table_actions_controller.js\": \"./src/js/headmin/controllers/table_actions_controller.js\",\n\t\"./table_controller.js\": \"./src/js/headmin/controllers/table_controller.js\"\n};\n\n\nfunction webpackContext(req) {\n\tvar id = webpackContextResolve(req);\n\treturn __webpack_require__(id);\n}\nfunction webpackContextResolve(req) {\n\tif(!__webpack_require__.o(map, req)) {\n\t\tvar e = new Error(\"Cannot find module '\" + req + \"'\");\n\t\te.code = 'MODULE_NOT_FOUND';\n\t\tthrow e;\n\t}\n\treturn map[req];\n}\nwebpackContext.keys = function webpackContextKeys() {\n\treturn Object.keys(map);\n};\nwebpackContext.resolve = webpackContextResolve;\nmodule.exports = webpackContext;\nwebpackContext.id = \"./src/js/headmin/controllers sync recursive \\\\.js$\";\n\n//# sourceURL=webpack:///./src/js/headmin/controllers_sync_\\.js$?");
|
981
992
|
|
982
993
|
/***/ }),
|
983
994
|
|
@@ -993,6 +1004,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) *
|
|
993
1004
|
|
994
1005
|
/***/ }),
|
995
1006
|
|
1007
|
+
/***/ "./src/js/headmin/controllers/date_range_controller.js":
|
1008
|
+
/*!*************************************************************!*\
|
1009
|
+
!*** ./src/js/headmin/controllers/date_range_controller.js ***!
|
1010
|
+
\*************************************************************/
|
1011
|
+
/*! exports provided: default */
|
1012
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
1013
|
+
|
1014
|
+
"use strict";
|
1015
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return _default; });\n/* harmony import */ var _hotwired_stimulus__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @hotwired/stimulus */ \"./node_modules/@hotwired/stimulus/dist/stimulus.js\");\n/* harmony import */ var sortablejs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! sortablejs */ \"./node_modules/sortablejs/modular/sortable.esm.js\");\n/* harmony import */ var _popperjs_core__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @popperjs/core */ \"./node_modules/@popperjs/core/lib/index.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; 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); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _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); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n\nvar _default = /*#__PURE__*/function (_Controller) {\n _inherits(_default, _Controller);\n\n var _super = _createSuper(_default);\n\n function _default() {\n _classCallCheck(this, _default);\n\n return _super.apply(this, arguments);\n }\n\n _createClass(_default, [{\n key: \"update\",\n value: function update(event) {\n var flatpickr = event.target._flatpickr;\n var startDate = flatpickr.selectedDates[0];\n var endDate = flatpickr.selectedDates[1];\n this.setStartDateInputValue(this.formatDate(startDate));\n this.setEndDateInputValue(this.formatDate(endDate));\n }\n }, {\n key: \"setStartDateInputValue\",\n value: function setStartDateInputValue(value) {\n this.startDateInputTarget.value = value;\n }\n }, {\n key: \"setEndDateInputValue\",\n value: function setEndDateInputValue(value) {\n this.endDateInputTarget.value = value;\n }\n }, {\n key: \"formatDate\",\n value: function formatDate(date) {\n if (date instanceof Date) {\n return date.toLocaleDateString('nl-BE', {\n day: '2-digit',\n month: '2-digit',\n year: 'numeric'\n });\n } else {\n return null;\n }\n }\n }], [{\n key: \"targets\",\n get: function get() {\n return [\"dateInput\", \"startDateInput\", \"endDateInput\"];\n }\n }]);\n\n return _default;\n}(_hotwired_stimulus__WEBPACK_IMPORTED_MODULE_0__[\"Controller\"]);\n\n\n\n//# sourceURL=webpack:///./src/js/headmin/controllers/date_range_controller.js?");
|
1016
|
+
|
1017
|
+
/***/ }),
|
1018
|
+
|
996
1019
|
/***/ "./src/js/headmin/controllers/filter_controller.js":
|
997
1020
|
/*!*********************************************************!*\
|
998
1021
|
!*** ./src/js/headmin/controllers/filter_controller.js ***!
|
@@ -1017,6 +1040,18 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) *
|
|
1017
1040
|
|
1018
1041
|
/***/ }),
|
1019
1042
|
|
1043
|
+
/***/ "./src/js/headmin/controllers/flatpickr_controller.js":
|
1044
|
+
/*!************************************************************!*\
|
1045
|
+
!*** ./src/js/headmin/controllers/flatpickr_controller.js ***!
|
1046
|
+
\************************************************************/
|
1047
|
+
/*! exports provided: default */
|
1048
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
1049
|
+
|
1050
|
+
"use strict";
|
1051
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return _default; });\n/* harmony import */ var _hotwired_stimulus__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @hotwired/stimulus */ \"./node_modules/@hotwired/stimulus/dist/stimulus.js\");\n/* harmony import */ var flatpickr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! flatpickr */ \"./node_modules/flatpickr/dist/esm/index.js\");\n/* harmony import */ var flatpickr_dist_l10n_nl_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! flatpickr/dist/l10n/nl.js */ \"./node_modules/flatpickr/dist/l10n/nl.js\");\n/* harmony import */ var flatpickr_dist_l10n_nl_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(flatpickr_dist_l10n_nl_js__WEBPACK_IMPORTED_MODULE_2__);\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; 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); }\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _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); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n\nvar _default = /*#__PURE__*/function (_Controller) {\n _inherits(_default, _Controller);\n\n var _super = _createSuper(_default);\n\n function _default() {\n _classCallCheck(this, _default);\n\n return _super.apply(this, arguments);\n }\n\n _createClass(_default, [{\n key: \"connect\",\n value: function connect() {\n var options = _objectSpread(_objectSpread({}, this.defaultOptions()), this.options());\n\n Object(flatpickr__WEBPACK_IMPORTED_MODULE_1__[\"default\"])(this.inputTarget, options);\n }\n }, {\n key: \"options\",\n value: function options() {\n return JSON.parse(this.inputTarget.getAttribute('data-flatpickr-options'));\n }\n }, {\n key: \"defaultOptions\",\n value: function defaultOptions() {\n return {\n allowInput: true,\n dateFormat: 'd/m/Y',\n locale: this.getLocale(I18n.locale)\n };\n }\n }, {\n key: \"getLocale\",\n value: function getLocale(locale) {\n var locales = this.locales();\n return locales[locale];\n }\n }, {\n key: \"locales\",\n value: function locales() {\n return {\n en: null,\n nl: flatpickr_dist_l10n_nl_js__WEBPACK_IMPORTED_MODULE_2__[\"Dutch\"]\n };\n }\n }], [{\n key: \"targets\",\n get: function get() {\n return [\"input\"];\n }\n }]);\n\n return _default;\n}(_hotwired_stimulus__WEBPACK_IMPORTED_MODULE_0__[\"Controller\"]);\n\n\n\n//# sourceURL=webpack:///./src/js/headmin/controllers/flatpickr_controller.js?");
|
1052
|
+
|
1053
|
+
/***/ }),
|
1054
|
+
|
1020
1055
|
/***/ "./src/js/headmin/controllers/popup_controller.js":
|
1021
1056
|
/*!********************************************************!*\
|
1022
1057
|
!*** ./src/js/headmin/controllers/popup_controller.js ***!
|
@@ -1037,7 +1072,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) *
|
|
1037
1072
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
1038
1073
|
|
1039
1074
|
"use strict";
|
1040
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return _default; });\n/* harmony import */ var _hotwired_stimulus__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @hotwired/stimulus */ \"./node_modules/@hotwired/stimulus/dist/stimulus.js\");\n/* harmony import */ var sortablejs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! sortablejs */ \"./node_modules/sortablejs/modular/sortable.esm.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; 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); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _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); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\nvar _default = /*#__PURE__*/function (_Controller) {\n _inherits(_default, _Controller);\n\n var _super = _createSuper(_default);\n\n function _default() {\n _classCallCheck(this, _default);\n\n return _super.apply(this, arguments);\n }\n\n _createClass(_default, [{\n key: \"connect\",\n value: function connect() {\n var _this = this;\n\n new sortablejs__WEBPACK_IMPORTED_MODULE_1__[\"default\"](this.listTarget, {\n animation: 150,\n ghostClass: 'list-group-item-dark',\n draggable: '.repeater-row',\n handle: '.repeater-row-handle',\n onEnd: function onEnd() {\n _this.resetIndices();\n\n _this.resetPositions();\n }\n });\n this.toggleEmpty();\n }\n }, {\n key: \"resetButtonIndices\",\n value: function resetButtonIndices(event) {\n var row = event.target.closest('.repeater-row');\n var index = this.containsRow(row) ? row.dataset.rowIndex : '';\n this.updatePopupButtonIndices(index);\n }\n }, {\n key: \"containsRow\",\n value: function containsRow(row) {\n return this.rowTargets.includes(row);\n }\n }, {\n key: \"updatePopupButtonIndices\",\n value: function updatePopupButtonIndices(index) {\n var popup = document.querySelector(\"[data-popup-target=\\\"popup\\\"][data-popup-id=\\\"repeater-buttons-\".concat(this.idValue, \"\\\"]\"));\n var buttons = popup.querySelectorAll('a');\n buttons.forEach(function (button) {\n button.dataset.rowIndex = index;\n });\n }\n }, {\n key: \"addRow\",\n value: function addRow(event) {\n event.preventDefault();\n var button = event.target;\n var templateName = button.dataset.templateName;\n var rowIndex = button.dataset.rowIndex; // Prepare html from template\n\n var template = this.getTemplate(templateName);\n var html = this.replaceIdsWithTimestamps(template); // Fallback to last row if no index is set\n\n if (rowIndex) {\n // Insert new row after defined row\n var row = this.rowTargets[rowIndex];\n row.insertAdjacentHTML('afterend', html);\n } else {\n // Insert before footer\n this.footerTarget.insertAdjacentHTML('beforebegin', html);\n } // Dispatch an event\n\n\n document.dispatchEvent(new CustomEvent('headmin:reinit', {\n bubbles: true\n }));\n this.resetIndices();\n this.resetPositions();\n this.toggleEmpty();\n }\n }, {\n key: \"removeRow\",\n value: function removeRow(event) {\n event.preventDefault();\n var row = event.target.closest(\".repeater-row\");\n\n if (row.dataset.newRecord === \"true\") {\n // New records are simply removed from the page\n row.remove();\n } else {\n // Existing records are hidden and flagged for deletion\n row.querySelector(\"input[name*='_destroy']\").value = 1;\n row.style.display = 'none';\n }\n\n this.resetIndices();\n this.resetPositions();\n this.toggleEmpty();\n }\n }, {\n key: \"getTemplate\",\n value: function getTemplate(name) {\n return this.templateTargets.filter(function (template) {\n return template.dataset.templateName === name;\n })[0];\n }\n }, {\n key: \"replaceIdsWithTimestamps\",\n value: function replaceIdsWithTimestamps(template) {\n
|
1075
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return _default; });\n/* harmony import */ var _hotwired_stimulus__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @hotwired/stimulus */ \"./node_modules/@hotwired/stimulus/dist/stimulus.js\");\n/* harmony import */ var sortablejs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! sortablejs */ \"./node_modules/sortablejs/modular/sortable.esm.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; 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); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _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); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\nvar _default = /*#__PURE__*/function (_Controller) {\n _inherits(_default, _Controller);\n\n var _super = _createSuper(_default);\n\n function _default() {\n _classCallCheck(this, _default);\n\n return _super.apply(this, arguments);\n }\n\n _createClass(_default, [{\n key: \"connect\",\n value: function connect() {\n var _this = this;\n\n new sortablejs__WEBPACK_IMPORTED_MODULE_1__[\"default\"](this.listTarget, {\n animation: 150,\n ghostClass: 'list-group-item-dark',\n draggable: '.repeater-row',\n handle: '.repeater-row-handle',\n onEnd: function onEnd() {\n _this.resetIndices();\n\n _this.resetPositions();\n }\n });\n this.toggleEmpty();\n }\n }, {\n key: \"resetButtonIndices\",\n value: function resetButtonIndices(event) {\n var row = event.target.closest('.repeater-row');\n var index = this.containsRow(row) ? row.dataset.rowIndex : '';\n this.updatePopupButtonIndices(index);\n }\n }, {\n key: \"containsRow\",\n value: function containsRow(row) {\n return this.rowTargets.includes(row);\n }\n }, {\n key: \"updatePopupButtonIndices\",\n value: function updatePopupButtonIndices(index) {\n var popup = document.querySelector(\"[data-popup-target=\\\"popup\\\"][data-popup-id=\\\"repeater-buttons-\".concat(this.idValue, \"\\\"]\"));\n var buttons = popup.querySelectorAll('a');\n buttons.forEach(function (button) {\n button.dataset.rowIndex = index;\n });\n }\n }, {\n key: \"addRow\",\n value: function addRow(event) {\n event.preventDefault();\n var button = event.target;\n var templateName = button.dataset.templateName;\n var rowIndex = button.dataset.rowIndex; // Prepare html from template\n\n var template = this.getTemplate(templateName);\n var html = this.replaceIdsWithTimestamps(template); // Fallback to last row if no index is set\n\n if (rowIndex) {\n // Insert new row after defined row\n var row = this.rowTargets[rowIndex];\n row.insertAdjacentHTML('afterend', html);\n } else {\n // Insert before footer\n this.footerTarget.insertAdjacentHTML('beforebegin', html);\n } // Dispatch an event\n\n\n document.dispatchEvent(new CustomEvent('headmin:reinit', {\n bubbles: true\n }));\n this.resetIndices();\n this.resetPositions();\n this.toggleEmpty();\n }\n }, {\n key: \"removeRow\",\n value: function removeRow(event) {\n event.preventDefault();\n var row = event.target.closest(\".repeater-row\");\n\n if (row.dataset.newRecord === \"true\") {\n // New records are simply removed from the page\n row.remove();\n } else {\n // Existing records are hidden and flagged for deletion\n row.querySelector(\"input[name*='_destroy']\").value = 1;\n row.style.display = 'none';\n }\n\n this.resetIndices();\n this.resetPositions();\n this.toggleEmpty();\n }\n }, {\n key: \"getTemplate\",\n value: function getTemplate(name) {\n return this.templateTargets.filter(function (template) {\n return template.dataset.templateName === name;\n })[0];\n }\n }, {\n key: \"replaceIdsWithTimestamps\",\n value: function replaceIdsWithTimestamps(template) {\n var regex = new RegExp(template.dataset.templateIdRegex, \"g\");\n return template.innerHTML.replace(regex, new Date().getTime());\n }\n }, {\n key: \"visibleRowsCount\",\n value: function visibleRowsCount() {\n return this.visibleRows().length;\n }\n }, {\n key: \"visibleRows\",\n value: function visibleRows() {\n var rows = this.rowTargets;\n return rows.filter(function (row) {\n return row.querySelector(\"input[name*='_destroy']\").value !== '1';\n });\n }\n }, {\n key: \"toggleEmpty\",\n value: function toggleEmpty() {\n if (this.visibleRowsCount() > 0) {\n this.emptyTarget.classList.add('invisible');\n } else {\n this.emptyTarget.classList.remove('invisible');\n }\n }\n }, {\n key: \"resetPositions\",\n value: function resetPositions() {\n this.visibleRows().forEach(function (row, index) {\n var positionInput = row.querySelector(\"input[name*='position']\");\n\n if (positionInput) {\n positionInput.value = index;\n }\n });\n }\n }, {\n key: \"resetIndices\",\n value: function resetIndices() {\n this.visibleRows().forEach(function (row, index) {\n row.dataset.rowIndex = index;\n });\n }\n }], [{\n key: \"values\",\n get: function get() {\n return {\n id: String\n };\n }\n }, {\n key: \"targets\",\n get: function get() {\n return [\"repeater\", \"footer\", \"template\", \"row\", \"list\", \"empty\", \"addButton\"];\n }\n }]);\n\n return _default;\n}(_hotwired_stimulus__WEBPACK_IMPORTED_MODULE_0__[\"Controller\"]);\n\n\n\n//# sourceURL=webpack:///./src/js/headmin/controllers/repeater_controller.js?");
|
1041
1076
|
|
1042
1077
|
/***/ }),
|
1043
1078
|
|
@@ -1049,7 +1084,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) *
|
|
1049
1084
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
1050
1085
|
|
1051
1086
|
"use strict";
|
1052
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return _default; });\n/* harmony import */ var _hotwired_stimulus__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @hotwired/stimulus */ \"./node_modules/@hotwired/stimulus/dist/stimulus.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; 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); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _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); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\nvar _default = /*#__PURE__*/function (_Controller) {\n _inherits(_default, _Controller);\n\n var _super = _createSuper(_default);\n\n function _default() {\n _classCallCheck(this, _default);\n\n return _super.apply(this, arguments);\n }\n\n _createClass(_default, [{\n key: \"connect\",\n value: function connect() {\n var _this = this;\n\n this.wrapperTarget.addEventListener('idSelectionChanged', function (event) {\n
|
1087
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return _default; });\n/* harmony import */ var _hotwired_stimulus__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @hotwired/stimulus */ \"./node_modules/@hotwired/stimulus/dist/stimulus.js\");\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; 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); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _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); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\nvar _default = /*#__PURE__*/function (_Controller) {\n _inherits(_default, _Controller);\n\n var _super = _createSuper(_default);\n\n function _default() {\n _classCallCheck(this, _default);\n\n return _super.apply(this, arguments);\n }\n\n _createClass(_default, [{\n key: \"connect\",\n value: function connect() {\n var _this = this;\n\n this.wrapperTarget.addEventListener('idSelectionChanged', function (event) {\n _this.updateIdFields(event.detail.ids);\n\n _this.updateCounter(event.detail.count);\n\n _this.toggleCounter(event.detail.count);\n });\n }\n }, {\n key: \"update\",\n value: function update(event) {\n event.preventDefault();\n this.updateFormAction();\n this.updateFormMethod();\n this.updateButton();\n }\n }, {\n key: \"updateIdFields\",\n value: function updateIdFields(ids) {\n var _this2 = this;\n\n this.removeIds();\n\n if (ids instanceof Array) {\n ids.forEach(function (id) {\n _this2.addId(id);\n });\n } else {\n this.addId('');\n }\n }\n }, {\n key: \"updateCounter\",\n value: function updateCounter(count) {\n var htmlString = '';\n\n switch (count) {\n case 0:\n htmlString = this.counterTarget.getAttribute('data-items-zero');\n break;\n\n case 1:\n htmlString = this.counterTarget.getAttribute('data-items-one');\n break;\n\n default:\n htmlString = this.counterTarget.getAttribute('data-items-other');\n htmlString = htmlString.replace(/<b>[\\s\\S]*?<\\/b>/, \"<b>\".concat(count, \"</b>\"));\n }\n\n this.counterTarget.innerHTML = htmlString;\n }\n }, {\n key: \"toggleCounter\",\n value: function toggleCounter(count) {\n if (count > 0) {\n this.wrapperTarget.classList.remove('d-none');\n } else {\n this.wrapperTarget.classList.add('d-none');\n }\n }\n }, {\n key: \"updateFormAction\",\n value: function updateFormAction() {\n this.formTarget.action = this.selectTarget.value;\n }\n }, {\n key: \"updateFormMethod\",\n value: function updateFormMethod() {\n var option = this.selectedOption();\n this.methodTarget.value = option.dataset.method;\n }\n }, {\n key: \"updateButton\",\n value: function updateButton() {\n var option = this.selectedOption();\n var confirm = option.dataset.confirm;\n\n if (confirm) {\n this.buttonTarget.dataset.confirm = confirm;\n } else {\n this.buttonTarget.removeAttribute('data-confirm');\n }\n\n this.enableButton();\n }\n }, {\n key: \"selectedOption\",\n value: function selectedOption() {\n return this.selectTarget.options[this.selectTarget.selectedIndex];\n }\n }, {\n key: \"enableButton\",\n value: function enableButton() {\n this.buttonTarget.removeAttribute('disabled');\n }\n }, {\n key: \"addId\",\n value: function addId(id) {\n var template = this.idInputTemplateTarget;\n var input = template.innerHTML.replace(/ID/g, id);\n this.formTarget.insertAdjacentHTML('afterbegin', input);\n }\n }, {\n key: \"removeIds\",\n value: function removeIds() {\n var _this3 = this;\n\n this.idTargets.forEach(function (input) {\n _this3.formTarget.removeChild(input);\n });\n }\n }], [{\n key: \"targets\",\n get: function get() {\n return [\"wrapper\", \"form\", \"select\", \"method\", \"button\", \"idInputTemplate\", \"id\", \"counter\"];\n }\n }]);\n\n return _default;\n}(_hotwired_stimulus__WEBPACK_IMPORTED_MODULE_0__[\"Controller\"]);\n\n\n\n//# sourceURL=webpack:///./src/js/headmin/controllers/table_actions_controller.js?");
|
1053
1088
|
|
1054
1089
|
/***/ }),
|
1055
1090
|
|
@@ -1061,7 +1096,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) *
|
|
1061
1096
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
1062
1097
|
|
1063
1098
|
"use strict";
|
1064
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return _default; });\n/* harmony import */ var _hotwired_stimulus__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @hotwired/stimulus */ \"./node_modules/@hotwired/stimulus/dist/stimulus.js\");\n/* harmony import */ var sortablejs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! sortablejs */ \"./node_modules/sortablejs/modular/sortable.esm.js\");\n/* harmony import */ var _rails_ujs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @rails/ujs */ \"./node_modules/@rails/ujs/lib/assets/compiled/rails-ujs.js\");\n/* harmony import */ var _rails_ujs__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_rails_ujs__WEBPACK_IMPORTED_MODULE_2__);\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; 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); }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _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); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n\nvar _default = /*#__PURE__*/function (_Controller) {\n _inherits(_default, _Controller);\n\n var _super = _createSuper(_default);\n\n function _default() {\n _classCallCheck(this, _default);\n\n return _super.apply(this, arguments);\n }\n\n _createClass(_default, [{\n key: \"connect\",\n value: function connect() {\n var _this = this;\n\n new sortablejs__WEBPACK_IMPORTED_MODULE_1__[\"default\"](this.bodyTarget, {\n handle: '.table-drag-sort-handle',\n onEnd: function onEnd(event) {\n _rails_ujs__WEBPACK_IMPORTED_MODULE_2___default.a.ajax({\n url: _this.urlValue,\n type: \"PATCH\",\n data: _this.getIdsDataString()\n });\n }\n });\n }\n }, {\n key: \"getIdsDataString\",\n value: function getIdsDataString() {\n var table = this.tableTarget;\n var data = \"\";\n\n var handles = _toConsumableArray(table.querySelectorAll(\".table-drag-sort-handle\"));\n\n handles.map(function (handle) {\n data += \"ids[]=\".concat(handle.dataset.id, \"&\");\n });\n return data;\n }\n }, {\n key: \"toggleIds\",\n value: function toggleIds(event) {\n var checkbox = event.target;\n this.toggleIdsCheckboxes(checkbox.checked);\n this.toggleIdCheckboxes(checkbox.checked);\n this.updateActions();\n }\n }, {\n key: \"toggleId\",\n value: function toggleId(event) {\n this.toggleIdsCheckboxes(false);\n this.updateActions();\n }\n }, {\n key: \"updateActions\",\n value: function updateActions() {\n this.actionsTarget.dispatchEvent(new CustomEvent('idSelectionChanged', {\n detail: {\n ids: this.ids()\n }\n }));\n }\n }, {\n key: \"ids\",\n value: function ids() {\n if (this.idsCheckboxTarget.checked) {\n return null;\n } else {\n return this.selectedIdCheckboxes().map(function (checkbox) {\n return checkbox.value;\n });\n }\n }\n }, {\n key: \"selectedIdCheckboxes\",\n value: function selectedIdCheckboxes() {\n return this.idCheckboxTargets.filter(function (checkbox) {\n return checkbox.checked;\n });\n }\n }, {\n key: \"toggleIdsCheckboxes\",\n value: function toggleIdsCheckboxes(checked) {\n this.idsCheckboxTargets.forEach(function (checkbox) {\n checkbox.checked = checked;\n });\n }\n }, {\n key: \"toggleIdCheckboxes\",\n value: function toggleIdCheckboxes(checked) {\n this.idCheckboxTargets.forEach(function (checkbox) {\n checkbox.checked = checked;\n });\n }\n }], [{\n key: \"values\",\n get: function get() {\n return {\n url: String\n };\n }\n }, {\n key: \"targets\",\n get: function get() {\n return [\"table\", \"body\", \"actions\", \"idCheckbox\", \"idsCheckbox\"];\n }\n }]);\n\n return _default;\n}(_hotwired_stimulus__WEBPACK_IMPORTED_MODULE_0__[\"Controller\"]);\n\n\n\n//# sourceURL=webpack:///./src/js/headmin/controllers/table_controller.js?");
|
1099
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return _default; });\n/* harmony import */ var _hotwired_stimulus__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @hotwired/stimulus */ \"./node_modules/@hotwired/stimulus/dist/stimulus.js\");\n/* harmony import */ var sortablejs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! sortablejs */ \"./node_modules/sortablejs/modular/sortable.esm.js\");\n/* harmony import */ var _rails_ujs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @rails/ujs */ \"./node_modules/@rails/ujs/lib/assets/compiled/rails-ujs.js\");\n/* harmony import */ var _rails_ujs__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_rails_ujs__WEBPACK_IMPORTED_MODULE_2__);\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; 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); }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\n\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\n\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\n\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _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); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\n\n\n\n\nvar _default = /*#__PURE__*/function (_Controller) {\n _inherits(_default, _Controller);\n\n var _super = _createSuper(_default);\n\n function _default() {\n _classCallCheck(this, _default);\n\n return _super.apply(this, arguments);\n }\n\n _createClass(_default, [{\n key: \"connect\",\n value: function connect() {\n var _this = this;\n\n new sortablejs__WEBPACK_IMPORTED_MODULE_1__[\"default\"](this.bodyTarget, {\n handle: '.table-drag-sort-handle',\n onEnd: function onEnd(event) {\n _rails_ujs__WEBPACK_IMPORTED_MODULE_2___default.a.ajax({\n url: _this.urlValue,\n type: \"PATCH\",\n data: _this.getIdsDataString()\n });\n }\n });\n }\n }, {\n key: \"getIdsDataString\",\n value: function getIdsDataString() {\n var table = this.tableTarget;\n var data = \"\";\n\n var handles = _toConsumableArray(table.querySelectorAll(\".table-drag-sort-handle\"));\n\n handles.map(function (handle) {\n data += \"ids[]=\".concat(handle.dataset.id, \"&\");\n });\n return data;\n }\n }, {\n key: \"toggleIds\",\n value: function toggleIds(event) {\n var checkbox = event.target;\n this.toggleIdsCheckboxes(checkbox.checked);\n this.toggleIdCheckboxes(checkbox.checked);\n this.updateActions();\n }\n }, {\n key: \"toggleId\",\n value: function toggleId(event) {\n this.toggleIdsCheckboxes(false);\n this.updateActions();\n }\n }, {\n key: \"updateActions\",\n value: function updateActions() {\n this.actionsTarget.dispatchEvent(new CustomEvent('idSelectionChanged', {\n detail: {\n ids: this.ids(),\n count: this.selectedIdsCount()\n }\n }));\n }\n }, {\n key: \"selectedIdsCount\",\n value: function selectedIdsCount() {\n if (this.ids() instanceof Array) {\n return this.ids().length;\n } else {\n return this.totalCount();\n }\n }\n }, {\n key: \"totalCount\",\n value: function totalCount() {\n if (this.countValue === 0) {\n return this.rowTargets.length;\n } else {\n return this.countValue;\n }\n }\n }, {\n key: \"ids\",\n value: function ids() {\n if (this.idsCheckboxTarget.checked) {\n return null;\n } else {\n return this.selectedIdCheckboxes().map(function (checkbox) {\n return checkbox.value;\n });\n }\n }\n }, {\n key: \"selectedIdCheckboxes\",\n value: function selectedIdCheckboxes() {\n return this.idCheckboxTargets.filter(function (checkbox) {\n return checkbox.checked;\n });\n }\n }, {\n key: \"toggleIdsCheckboxes\",\n value: function toggleIdsCheckboxes(checked) {\n this.idsCheckboxTargets.forEach(function (checkbox) {\n checkbox.checked = checked;\n });\n }\n }, {\n key: \"toggleIdCheckboxes\",\n value: function toggleIdCheckboxes(checked) {\n this.idCheckboxTargets.forEach(function (checkbox) {\n checkbox.checked = checked;\n });\n }\n }], [{\n key: \"values\",\n get: function get() {\n return {\n url: String,\n count: Number\n };\n }\n }, {\n key: \"targets\",\n get: function get() {\n return [\"table\", \"body\", \"actions\", \"idCheckbox\", \"idsCheckbox\", \"row\"];\n }\n }]);\n\n return _default;\n}(_hotwired_stimulus__WEBPACK_IMPORTED_MODULE_0__[\"Controller\"]);\n\n\n\n//# sourceURL=webpack:///./src/js/headmin/controllers/table_controller.js?");
|
1065
1100
|
|
1066
1101
|
/***/ }),
|
1067
1102
|
|
@@ -1073,7 +1108,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) *
|
|
1073
1108
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
1074
1109
|
|
1075
1110
|
"use strict";
|
1076
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"Headmin\", function() { return Headmin; });\n/* harmony import */ var ckeditor5_build_classic_simple_upload_adapter_image_resize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ckeditor5-build-classic-simple-upload-adapter-image-resize */ \"./node_modules/ckeditor5-build-classic-simple-upload-adapter-image-resize/build/ckeditor.js\");\n/* harmony import */ var ckeditor5_build_classic_simple_upload_adapter_image_resize__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(ckeditor5_build_classic_simple_upload_adapter_image_resize__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var tom_select__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tom-select */ \"./node_modules/tom-select/dist/js/tom-select.complete.js\");\n/* harmony import */ var tom_select__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(tom_select__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var
|
1111
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"Headmin\", function() { return Headmin; });\n/* harmony import */ var ckeditor5_build_classic_simple_upload_adapter_image_resize__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ckeditor5-build-classic-simple-upload-adapter-image-resize */ \"./node_modules/ckeditor5-build-classic-simple-upload-adapter-image-resize/build/ckeditor.js\");\n/* harmony import */ var ckeditor5_build_classic_simple_upload_adapter_image_resize__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(ckeditor5_build_classic_simple_upload_adapter_image_resize__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var tom_select__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tom-select */ \"./node_modules/tom-select/dist/js/tom-select.complete.js\");\n/* harmony import */ var tom_select__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(tom_select__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var bootstrap_dist_js_bootstrap_bundle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! bootstrap/dist/js/bootstrap.bundle */ \"./node_modules/bootstrap/dist/js/bootstrap.bundle.js\");\n/* harmony import */ var bootstrap_dist_js_bootstrap_bundle__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(bootstrap_dist_js_bootstrap_bundle__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _rails_ujs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @rails/ujs */ \"./node_modules/@rails/ujs/lib/assets/compiled/rails-ujs.js\");\n/* harmony import */ var _rails_ujs__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_rails_ujs__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _hotwired_stimulus__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @hotwired/stimulus */ \"./node_modules/@hotwired/stimulus/dist/stimulus.js\");\n/* harmony import */ var _hotwired_stimulus_webpack_helpers__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @hotwired/stimulus-webpack-helpers */ \"./node_modules/@hotwired/stimulus-webpack-helpers/dist/stimulus-webpack-helpers.js\");\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n\n\n\n\n\n\nvar Headmin = /*#__PURE__*/function () {\n function Headmin() {\n _classCallCheck(this, Headmin);\n }\n\n _createClass(Headmin, null, [{\n key: \"start\",\n value: function start() {\n var _this = this;\n\n // Init Rails UJS\n _rails_ujs__WEBPACK_IMPORTED_MODULE_3___default.a.start(); // Set locale\n\n this.setLocale(); // Init Stimulus\n\n var application = _hotwired_stimulus__WEBPACK_IMPORTED_MODULE_4__[\"Application\"].start();\n\n var context = __webpack_require__(\"./src/js/headmin/controllers sync recursive \\\\.js$\");\n\n application.load(Object(_hotwired_stimulus_webpack_helpers__WEBPACK_IMPORTED_MODULE_5__[\"definitionsFromContext\"])(context)); // Init Plugins\n\n this.initPlugins(); // Listen for a headmin:reinit event\n\n document.addEventListener('headmin:reinit', function (e) {\n _this.initPlugins();\n });\n }\n }, {\n key: \"setLocale\",\n value: function setLocale() {\n var locale = document.querySelector('html').getAttribute('lang');\n window.I18n = {};\n I18n.locale = locale || 'en';\n }\n }, {\n key: \"initPlugins\",\n value: function initPlugins() {\n this.initTomSelects();\n this.initToasts();\n this.initPopovers();\n this.initCKEditors();\n this.initRedactorX();\n }\n }, {\n key: \"initRedactorX\",\n value: function initRedactorX() {\n document.querySelectorAll('.redactorx').forEach(function (element) {\n if (typeof RedactorX == 'undefined') {\n console.error(\"RedactorX is a paid module and is not included in Headmin. Please purchase it and import it as a JS module\");\n return false;\n }\n\n var options = JSON.parse(element.getAttribute('data-redactor-options'));\n RedactorX(element, options);\n });\n }\n }, {\n key: \"initCKEditors\",\n value: function initCKEditors() {\n var _this2 = this;\n\n document.querySelectorAll('.ckeditor').forEach(function (element) {\n _this2.initCKEditor(element);\n });\n }\n }, {\n key: \"csrfToken\",\n value: function csrfToken() {\n return document.querySelector('meta[name=\"csrf-token\"]').content;\n }\n }, {\n key: \"initCKEditor\",\n value: function initCKEditor(element) {\n // Check if CKEditor is already initialized\n if (element.nextElementSibling && element.nextElementSibling.classList.contains('ck-editor')) return;\n var defaultToolbarItems = ['heading', '|', 'bold', 'italic', 'bulletedList', 'numberedList', '|', 'outdent', 'indent', '|', 'link', 'imageUpload', 'blockQuote', 'insertTable', 'mediaEmbed', '|', 'undo', 'redo'];\n var requestedToolbarItems = element.dataset.ckeditorToolbar ? JSON.parse(element.dataset.ckeditorToolbar) : undefined;\n var toolbarItems = requestedToolbarItems ? requestedToolbarItems : defaultToolbarItems;\n var uploadPath = element.dataset.ckeditorUploadPath;\n ClassicEditor.create(element, {\n toolbar: {\n items: toolbarItems\n },\n language: 'en',\n image: {\n toolbar: ['imageTextAlternative', 'imageStyle:full', 'imageStyle:side']\n },\n table: {\n contentToolbar: ['tableColumn', 'tableRow', 'mergeTableCells']\n },\n simpleUpload: {\n uploadUrl: uploadPath,\n withCredentials: true,\n headers: {\n 'X-CSRF-TOKEN': this.csrfToken()\n }\n }\n });\n }\n }, {\n key: \"initTomSelects\",\n value: function initTomSelects() {\n var defaultOptions = {\n en: {\n render: {\n option_create: function option_create(data, escape) {\n return '<div class=\"create\">Add <strong>' + escape(data.input) + '</strong>…</div>';\n },\n no_results: function no_results(data, escape) {\n return '<div class=\"no-results\">No results found</div>';\n }\n }\n },\n nl: {\n render: {\n option_create: function option_create(data, escape) {\n return '<div class=\"create\">Voeg <strong>' + escape(data.input) + '</strong> toe …</div>';\n },\n no_results: function no_results(data, escape) {\n return '<div class=\"no-results\">Geen resultaten gevonden</div>';\n }\n }\n }\n };\n document.querySelectorAll('select[multiple]').forEach(function (select) {\n var withTags = select.dataset['tags'] === \"true\";\n var options = {\n create: withTags\n };\n new tom_select__WEBPACK_IMPORTED_MODULE_1___default.a(select, _objectSpread(_objectSpread({}, defaultOptions[I18n.locale]), options));\n });\n }\n }, {\n key: \"initToasts\",\n value: function initToasts() {\n document.querySelectorAll('.toast').forEach(function (toast) {\n new bootstrap_dist_js_bootstrap_bundle__WEBPACK_IMPORTED_MODULE_2___default.a.Toast(toast, {});\n });\n }\n }, {\n key: \"initPopovers\",\n value: function initPopovers() {\n var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle=\"popover\"]'));\n var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {\n return new bootstrap_dist_js_bootstrap_bundle__WEBPACK_IMPORTED_MODULE_2___default.a.Popover(popoverTriggerEl, {\n sanitize: false\n });\n });\n }\n }]);\n\n return Headmin;\n}();\n\n//# sourceURL=webpack:///./src/js/headmin/headmin.js?");
|
1077
1112
|
|
1078
1113
|
/***/ })
|
1079
1114
|
|
data/lib/headmin/version.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
import {Controller} from "@hotwired/stimulus"
|
2
|
+
import Sortable from "sortablejs";
|
3
|
+
import { createPopper } from '@popperjs/core';
|
4
|
+
|
5
|
+
export default class extends Controller {
|
6
|
+
static get targets() {
|
7
|
+
return ["dateInput", "startDateInput", "endDateInput"]
|
8
|
+
}
|
9
|
+
|
10
|
+
update(event) {
|
11
|
+
const flatpickr = event.target._flatpickr
|
12
|
+
const startDate = flatpickr.selectedDates[0]
|
13
|
+
const endDate = flatpickr.selectedDates[1]
|
14
|
+
|
15
|
+
this.setStartDateInputValue(this.formatDate(startDate))
|
16
|
+
this.setEndDateInputValue(this.formatDate(endDate))
|
17
|
+
}
|
18
|
+
|
19
|
+
setStartDateInputValue(value) {
|
20
|
+
this.startDateInputTarget.value = value
|
21
|
+
}
|
22
|
+
|
23
|
+
setEndDateInputValue(value) {
|
24
|
+
this.endDateInputTarget.value = value
|
25
|
+
}
|
26
|
+
|
27
|
+
formatDate(date) {
|
28
|
+
if(date instanceof Date) {
|
29
|
+
return date.toLocaleDateString('nl-BE', {day: '2-digit', month: '2-digit', year: 'numeric'})
|
30
|
+
} else {
|
31
|
+
return null;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import {Controller} from "@hotwired/stimulus"
|
2
|
+
import flatpickr from "flatpickr";
|
3
|
+
import {Dutch} from "flatpickr/dist/l10n/nl.js"
|
4
|
+
|
5
|
+
export default class extends Controller {
|
6
|
+
static get targets() {
|
7
|
+
return ["input"]
|
8
|
+
}
|
9
|
+
|
10
|
+
connect() {
|
11
|
+
const options = {...this.defaultOptions(), ...this.options()}
|
12
|
+
flatpickr(this.inputTarget, options);
|
13
|
+
}
|
14
|
+
|
15
|
+
options() {
|
16
|
+
return JSON.parse(this.inputTarget.getAttribute('data-flatpickr-options'))
|
17
|
+
}
|
18
|
+
|
19
|
+
defaultOptions() {
|
20
|
+
return {
|
21
|
+
allowInput: true,
|
22
|
+
dateFormat: 'd/m/Y',
|
23
|
+
locale: this.getLocale(I18n.locale)
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
getLocale(locale) {
|
28
|
+
const locales = this.locales()
|
29
|
+
return locales[locale]
|
30
|
+
}
|
31
|
+
|
32
|
+
locales() {
|
33
|
+
return {
|
34
|
+
en: null,
|
35
|
+
nl: Dutch
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
@@ -99,7 +99,6 @@ export default class extends Controller {
|
|
99
99
|
}
|
100
100
|
|
101
101
|
replaceIdsWithTimestamps(template) {
|
102
|
-
console.log(template)
|
103
102
|
const regex = new RegExp(template.dataset.templateIdRegex, "g")
|
104
103
|
return template.innerHTML.replace(regex, new Date().getTime())
|
105
104
|
}
|
@@ -1,21 +1,15 @@
|
|
1
1
|
import {Controller} from "@hotwired/stimulus"
|
2
2
|
|
3
3
|
export default class extends Controller {
|
4
|
-
static get values() {
|
5
|
-
return {
|
6
|
-
count: {type: Number, default: 0}
|
7
|
-
}
|
8
|
-
}
|
9
|
-
|
10
4
|
static get targets() {
|
11
5
|
return ["wrapper", "form", "select", "method", "button", "idInputTemplate", "id", "counter"]
|
12
6
|
}
|
13
7
|
|
14
8
|
connect() {
|
15
9
|
this.wrapperTarget.addEventListener('idSelectionChanged', (event) => {
|
16
|
-
|
17
|
-
this.
|
18
|
-
this.
|
10
|
+
this.updateIdFields(event.detail.ids)
|
11
|
+
this.updateCounter(event.detail.count)
|
12
|
+
this.toggleCounter(event.detail.count)
|
19
13
|
})
|
20
14
|
|
21
15
|
}
|
@@ -30,56 +24,32 @@ export default class extends Controller {
|
|
30
24
|
updateIdFields(ids) {
|
31
25
|
this.removeIds()
|
32
26
|
if (ids instanceof Array) {
|
33
|
-
this.countValue = ids.length
|
34
27
|
ids.forEach((id) => {
|
35
28
|
this.addId(id)
|
36
29
|
})
|
37
30
|
} else {
|
38
|
-
this.countValue = Infinity
|
39
31
|
this.addId('')
|
40
32
|
}
|
41
33
|
}
|
42
34
|
|
43
|
-
updateCounter() {
|
35
|
+
updateCounter(count) {
|
44
36
|
let htmlString = ''
|
45
|
-
switch (
|
37
|
+
switch (count) {
|
46
38
|
case 0:
|
47
39
|
htmlString = this.counterTarget.getAttribute('data-items-zero')
|
48
40
|
break;
|
49
41
|
case 1:
|
50
42
|
htmlString = this.counterTarget.getAttribute('data-items-one')
|
51
43
|
break;
|
52
|
-
case Infinity:
|
53
|
-
htmlString = this.counterTarget.getAttribute('data-items-other')
|
54
|
-
htmlString = htmlString.replace(/<b>[\s\S]*?<\/b>/, '<b>' + this.totalCount() + '<\/b>');
|
55
|
-
break;
|
56
44
|
default:
|
57
45
|
htmlString = this.counterTarget.getAttribute('data-items-other')
|
58
|
-
let count = this.countValue === Infinity ? this.totalCount() : this.countValue
|
59
46
|
htmlString = htmlString.replace(/<b>[\s\S]*?<\/b>/, `<b>${count}<\/b>`);
|
60
47
|
}
|
61
48
|
this.counterTarget.innerHTML = htmlString;
|
62
49
|
}
|
63
50
|
|
64
|
-
|
65
|
-
|
66
|
-
}
|
67
|
-
|
68
|
-
updateCountValueWithIds(ids) {
|
69
|
-
if (ids instanceof Array) {
|
70
|
-
this.countValue = ids.length
|
71
|
-
} else {
|
72
|
-
this.countValue = Infinity
|
73
|
-
}
|
74
|
-
}
|
75
|
-
|
76
|
-
countValueChanged() {
|
77
|
-
this.updateCounter()
|
78
|
-
this.toggle()
|
79
|
-
}
|
80
|
-
|
81
|
-
toggle() {
|
82
|
-
if (this.countValue > 0) {
|
51
|
+
toggleCounter(count) {
|
52
|
+
if (count > 0) {
|
83
53
|
this.wrapperTarget.classList.remove('d-none')
|
84
54
|
} else {
|
85
55
|
this.wrapperTarget.classList.add('d-none')
|
@@ -4,11 +4,14 @@ import Rails from "@rails/ujs";
|
|
4
4
|
|
5
5
|
export default class extends Controller {
|
6
6
|
static get values() {
|
7
|
-
return {
|
7
|
+
return {
|
8
|
+
url: String,
|
9
|
+
count: Number
|
10
|
+
}
|
8
11
|
}
|
9
12
|
|
10
13
|
static get targets() {
|
11
|
-
return ["table", "body", "actions", "idCheckbox", "idsCheckbox"]
|
14
|
+
return ["table", "body", "actions", "idCheckbox", "idsCheckbox", "row"]
|
12
15
|
}
|
13
16
|
|
14
17
|
connect() {
|
@@ -52,13 +55,30 @@ export default class extends Controller {
|
|
52
55
|
'idSelectionChanged',
|
53
56
|
{
|
54
57
|
detail: {
|
55
|
-
ids: this.ids()
|
58
|
+
ids: this.ids(),
|
59
|
+
count: this.selectedIdsCount()
|
56
60
|
}
|
57
61
|
}
|
58
62
|
)
|
59
63
|
)
|
60
64
|
}
|
61
65
|
|
66
|
+
selectedIdsCount() {
|
67
|
+
if (this.ids() instanceof Array) {
|
68
|
+
return this.ids().length
|
69
|
+
} else {
|
70
|
+
return this.totalCount()
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
totalCount() {
|
75
|
+
if(this.countValue === 0) {
|
76
|
+
return this.rowTargets.length
|
77
|
+
} else {
|
78
|
+
return this.countValue
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
62
82
|
ids() {
|
63
83
|
if (this.idsCheckboxTarget.checked) {
|
64
84
|
return null
|
data/src/js/headmin/headmin.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import 'ckeditor5-build-classic-simple-upload-adapter-image-resize';
|
2
2
|
import TomSelect from "tom-select";
|
3
|
-
import flatpickr from "flatpickr";
|
4
3
|
import bootstrap from "bootstrap/dist/js/bootstrap.bundle";
|
5
4
|
import Rails from "@rails/ujs";
|
6
5
|
|
@@ -12,6 +11,9 @@ export class Headmin {
|
|
12
11
|
// Init Rails UJS
|
13
12
|
Rails.start()
|
14
13
|
|
14
|
+
// Set locale
|
15
|
+
this.setLocale()
|
16
|
+
|
15
17
|
// Init Stimulus
|
16
18
|
const application = Application.start()
|
17
19
|
const context = require.context("./controllers", true, /\.js$/)
|
@@ -27,9 +29,14 @@ export class Headmin {
|
|
27
29
|
|
28
30
|
}
|
29
31
|
|
32
|
+
static setLocale() {
|
33
|
+
const locale = document.querySelector('html').getAttribute('lang')
|
34
|
+
window.I18n = {}
|
35
|
+
I18n.locale = locale || 'en'
|
36
|
+
}
|
37
|
+
|
30
38
|
static initPlugins() {
|
31
39
|
this.initTomSelects()
|
32
|
-
this.initFlatpickrs()
|
33
40
|
this.initToasts()
|
34
41
|
this.initPopovers()
|
35
42
|
this.initCKEditors()
|
@@ -48,20 +55,6 @@ export class Headmin {
|
|
48
55
|
})
|
49
56
|
}
|
50
57
|
|
51
|
-
static initFlatpickrs() {
|
52
|
-
document.querySelectorAll('.flatpickr').forEach((element) => {
|
53
|
-
this.initFlatpickr(element)
|
54
|
-
})
|
55
|
-
}
|
56
|
-
|
57
|
-
static initFlatpickr(element) {
|
58
|
-
flatpickr(element, {
|
59
|
-
allowInput: true,
|
60
|
-
altInput: true,
|
61
|
-
altFormat: 'd/m/Y',
|
62
|
-
});
|
63
|
-
}
|
64
|
-
|
65
58
|
static initCKEditors() {
|
66
59
|
document.querySelectorAll('.ckeditor').forEach((element) => {
|
67
60
|
this.initCKEditor(element)
|
@@ -119,10 +112,34 @@ export class Headmin {
|
|
119
112
|
}
|
120
113
|
|
121
114
|
static initTomSelects() {
|
115
|
+
const defaultOptions = {
|
116
|
+
en: {
|
117
|
+
render: {
|
118
|
+
option_create: function (data, escape) {
|
119
|
+
return '<div class="create">Add <strong>' + escape(data.input) + '</strong>…</div>';
|
120
|
+
},
|
121
|
+
no_results: function (data, escape) {
|
122
|
+
return '<div class="no-results">No results found</div>';
|
123
|
+
}
|
124
|
+
}
|
125
|
+
},
|
126
|
+
nl: {
|
127
|
+
render: {
|
128
|
+
option_create: function (data, escape) {
|
129
|
+
return '<div class="create">Voeg <strong>' + escape(data.input) + '</strong> toe …</div>';
|
130
|
+
},
|
131
|
+
no_results: function (data, escape) {
|
132
|
+
return '<div class="no-results">Geen resultaten gevonden</div>';
|
133
|
+
}
|
134
|
+
}
|
135
|
+
}
|
136
|
+
}
|
137
|
+
|
122
138
|
document.querySelectorAll('select[multiple]').forEach((select) => {
|
123
|
-
|
124
|
-
|
125
|
-
|
139
|
+
const withTags = select.dataset['tags'] === "true"
|
140
|
+
const options = {create: withTags}
|
141
|
+
|
142
|
+
new TomSelect(select, {...defaultOptions[I18n.locale], ...options});
|
126
143
|
})
|
127
144
|
}
|
128
145
|
|