From 678b5cc523d8ded4a68e9892937d7e968e9d31e8 Mon Sep 17 00:00:00 2001 From: jordi fita mas Date: Wed, 20 Dec 2023 19:52:14 +0100 Subject: [PATCH] Add user-defined order to campsite types, options, seasons and carousels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I use Sortable, exactly like HTMx’s sorting example does[0]. Had to export the slug or ID of some entries to be able to add it in the hidden input. For forms that use ID instead of slug, had to use an input name other than “id” because otherwise the swap would fail due to bug #1496[1]. It is apparently fixed in a recent version of HTMx, but i did not want to update for fear of behaviour changes. [0]: https://htmx.org/examples/sortable/ [1]: https://github.com/bigskysoftware/htmx/issues/1496 --- .../web/static/sortable@1.15.1.min.js | 3365 +++++++++++++++++ deploy/campsite_type.sql | 3 +- deploy/campsite_type_carousel.sql | 1 + deploy/campsite_type_option.sql | 3 +- deploy/home_carousel.sql | 3 +- deploy/order_campsite_type_carousel.sql | 27 + deploy/order_campsite_type_options.sql | 24 + deploy/order_campsite_types.sql | 24 + deploy/order_home_carousel.sql | 24 + deploy/order_seasons.sql | 24 + deploy/order_services_carousel.sql | 24 + deploy/season.sql | 3 +- deploy/services_carousel.sql | 3 +- pkg/booking/public.go | 3 +- pkg/campsite/types/admin.go | 34 +- pkg/campsite/types/carousel.go | 39 +- pkg/campsite/types/option.go | 43 +- pkg/campsite/types/public.go | 6 +- pkg/carousel/admin.go | 53 +- pkg/database/funcs.go | 20 + pkg/home/admin.go | 2 +- pkg/home/public.go | 1 + pkg/season/admin.go | 46 +- pkg/services/admin.go | 6 +- pkg/template/page.go | 1 + po/ca.po | 298 +- po/es.po | 298 +- po/fr.po | 266 +- revert/order_campsite_type_carousel.sql | 7 + revert/order_campsite_type_options.sql | 7 + revert/order_campsite_types.sql | 7 + revert/order_home_carousel.sql | 7 + revert/order_seasons.sql | 7 + revert/order_services_carousel.sql | 7 + sqitch.plan | 6 + test/campsite_type.sql | 8 +- test/campsite_type_carousel.sql | 8 +- test/campsite_type_option.sql | 8 +- test/home_carousel.sql | 8 +- test/order_campsite_type_carousel.sql | 87 + test/order_campsite_type_options.sql | 76 + test/order_campsite_types.sql | 70 + test/order_home_carousel.sql | 79 + test/order_seasons.sql | 60 + test/order_services_carousel.sql | 79 + test/season.sql | 8 +- test/services_carousel.sql | 9 +- verify/campsite_type.sql | 1 + verify/campsite_type_carousel.sql | 1 + verify/campsite_type_option.sql | 1 + verify/home_carousel.sql | 1 + verify/order_campsite_type_carousel.sql | 7 + verify/order_campsite_type_options.sql | 7 + verify/order_campsite_types.sql | 7 + verify/order_home_carousel.sql | 7 + verify/order_seasons.sql | 7 + verify/order_services_carousel.sql | 7 + verify/season.sql | 1 + verify/services_carousel.sql | 1 + web/static/camper.css | 22 + web/static/camper.js | 20 +- web/static/sortable@1.15.1.min.js | 2 + .../admin/campsite/carousel/index.gohtml | 80 +- .../admin/campsite/option/index.gohtml | 57 +- .../admin/campsite/type/index.gohtml | 85 +- web/templates/admin/home/index.gohtml | 79 +- web/templates/admin/layout.gohtml | 3 +- web/templates/admin/season/index.gohtml | 67 +- web/templates/admin/services/index.gohtml | 79 +- 69 files changed, 5082 insertions(+), 652 deletions(-) create mode 100644 debian/missing-sources/web/static/sortable@1.15.1.min.js create mode 100644 deploy/order_campsite_type_carousel.sql create mode 100644 deploy/order_campsite_type_options.sql create mode 100644 deploy/order_campsite_types.sql create mode 100644 deploy/order_home_carousel.sql create mode 100644 deploy/order_seasons.sql create mode 100644 deploy/order_services_carousel.sql create mode 100644 revert/order_campsite_type_carousel.sql create mode 100644 revert/order_campsite_type_options.sql create mode 100644 revert/order_campsite_types.sql create mode 100644 revert/order_home_carousel.sql create mode 100644 revert/order_seasons.sql create mode 100644 revert/order_services_carousel.sql create mode 100644 test/order_campsite_type_carousel.sql create mode 100644 test/order_campsite_type_options.sql create mode 100644 test/order_campsite_types.sql create mode 100644 test/order_home_carousel.sql create mode 100644 test/order_seasons.sql create mode 100644 test/order_services_carousel.sql create mode 100644 verify/order_campsite_type_carousel.sql create mode 100644 verify/order_campsite_type_options.sql create mode 100644 verify/order_campsite_types.sql create mode 100644 verify/order_home_carousel.sql create mode 100644 verify/order_seasons.sql create mode 100644 verify/order_services_carousel.sql create mode 100644 web/static/sortable@1.15.1.min.js diff --git a/debian/missing-sources/web/static/sortable@1.15.1.min.js b/debian/missing-sources/web/static/sortable@1.15.1.min.js new file mode 100644 index 0000000..41c2d16 --- /dev/null +++ b/debian/missing-sources/web/static/sortable@1.15.1.min.js @@ -0,0 +1,3365 @@ +/**! + * Sortable 1.15.1 + * @author RubaXa + * @author owenm + * @license MIT + */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = global || self, global.Sortable = factory()); +}(this, (function () { 'use strict'; + + function 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; + } + function _objectSpread2(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; + } + function _typeof(obj) { + "@babel/helpers - typeof"; + + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + return _typeof(obj); + } + function _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; + } + function _extends() { + _extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + return target; + }; + return _extends.apply(this, arguments); + } + function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + return target; + } + function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; + var target = _objectWithoutPropertiesLoose(source, excluded); + var key, i; + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + return target; + } + function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); + } + function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); + } + function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); + } + function _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); + } + function _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; + } + function _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."); + } + + var version = "1.15.1"; + + function userAgent(pattern) { + if (typeof window !== 'undefined' && window.navigator) { + return !! /*@__PURE__*/navigator.userAgent.match(pattern); + } + } + var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i); + var Edge = userAgent(/Edge/i); + var FireFox = userAgent(/firefox/i); + var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i); + var IOS = userAgent(/iP(ad|od|hone)/i); + var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i); + + var captureMode = { + capture: false, + passive: false + }; + function on(el, event, fn) { + el.addEventListener(event, fn, !IE11OrLess && captureMode); + } + function off(el, event, fn) { + el.removeEventListener(event, fn, !IE11OrLess && captureMode); + } + function matches( /**HTMLElement*/el, /**String*/selector) { + if (!selector) return; + selector[0] === '>' && (selector = selector.substring(1)); + if (el) { + try { + if (el.matches) { + return el.matches(selector); + } else if (el.msMatchesSelector) { + return el.msMatchesSelector(selector); + } else if (el.webkitMatchesSelector) { + return el.webkitMatchesSelector(selector); + } + } catch (_) { + return false; + } + } + return false; + } + function getParentOrHost(el) { + return el.host && el !== document && el.host.nodeType ? el.host : el.parentNode; + } + function closest( /**HTMLElement*/el, /**String*/selector, /**HTMLElement*/ctx, includeCTX) { + if (el) { + ctx = ctx || document; + do { + if (selector != null && (selector[0] === '>' ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) { + return el; + } + if (el === ctx) break; + /* jshint boss:true */ + } while (el = getParentOrHost(el)); + } + return null; + } + var R_SPACE = /\s+/g; + function toggleClass(el, name, state) { + if (el && name) { + if (el.classList) { + el.classList[state ? 'add' : 'remove'](name); + } else { + var className = (' ' + el.className + ' ').replace(R_SPACE, ' ').replace(' ' + name + ' ', ' '); + el.className = (className + (state ? ' ' + name : '')).replace(R_SPACE, ' '); + } + } + } + function css(el, prop, val) { + var style = el && el.style; + if (style) { + if (val === void 0) { + if (document.defaultView && document.defaultView.getComputedStyle) { + val = document.defaultView.getComputedStyle(el, ''); + } else if (el.currentStyle) { + val = el.currentStyle; + } + return prop === void 0 ? val : val[prop]; + } else { + if (!(prop in style) && prop.indexOf('webkit') === -1) { + prop = '-webkit-' + prop; + } + style[prop] = val + (typeof val === 'string' ? '' : 'px'); + } + } + } + function matrix(el, selfOnly) { + var appliedTransforms = ''; + if (typeof el === 'string') { + appliedTransforms = el; + } else { + do { + var transform = css(el, 'transform'); + if (transform && transform !== 'none') { + appliedTransforms = transform + ' ' + appliedTransforms; + } + /* jshint boss:true */ + } while (!selfOnly && (el = el.parentNode)); + } + var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix; + /*jshint -W056 */ + return matrixFn && new matrixFn(appliedTransforms); + } + function find(ctx, tagName, iterator) { + if (ctx) { + var list = ctx.getElementsByTagName(tagName), + i = 0, + n = list.length; + if (iterator) { + for (; i < n; i++) { + iterator(list[i], i); + } + } + return list; + } + return []; + } + function getWindowScrollingElement() { + var scrollingElement = document.scrollingElement; + if (scrollingElement) { + return scrollingElement; + } else { + return document.documentElement; + } + } + + /** + * Returns the "bounding client rect" of given element + * @param {HTMLElement} el The element whose boundingClientRect is wanted + * @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container + * @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr + * @param {[Boolean]} undoScale Whether the container's scale() should be undone + * @param {[HTMLElement]} container The parent the element will be placed in + * @return {Object} The boundingClientRect of el, with specified adjustments + */ + function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) { + if (!el.getBoundingClientRect && el !== window) return; + var elRect, top, left, bottom, right, height, width; + if (el !== window && el.parentNode && el !== getWindowScrollingElement()) { + elRect = el.getBoundingClientRect(); + top = elRect.top; + left = elRect.left; + bottom = elRect.bottom; + right = elRect.right; + height = elRect.height; + width = elRect.width; + } else { + top = 0; + left = 0; + bottom = window.innerHeight; + right = window.innerWidth; + height = window.innerHeight; + width = window.innerWidth; + } + if ((relativeToContainingBlock || relativeToNonStaticParent) && el !== window) { + // Adjust for translate() + container = container || el.parentNode; + + // solves #1123 (see: https://stackoverflow.com/a/37953806/6088312) + // Not needed on <= IE11 + if (!IE11OrLess) { + do { + if (container && container.getBoundingClientRect && (css(container, 'transform') !== 'none' || relativeToNonStaticParent && css(container, 'position') !== 'static')) { + var containerRect = container.getBoundingClientRect(); + + // Set relative to edges of padding box of container + top -= containerRect.top + parseInt(css(container, 'border-top-width')); + left -= containerRect.left + parseInt(css(container, 'border-left-width')); + bottom = top + elRect.height; + right = left + elRect.width; + break; + } + /* jshint boss:true */ + } while (container = container.parentNode); + } + } + if (undoScale && el !== window) { + // Adjust for scale() + var elMatrix = matrix(container || el), + scaleX = elMatrix && elMatrix.a, + scaleY = elMatrix && elMatrix.d; + if (elMatrix) { + top /= scaleY; + left /= scaleX; + width /= scaleX; + height /= scaleY; + bottom = top + height; + right = left + width; + } + } + return { + top: top, + left: left, + bottom: bottom, + right: right, + width: width, + height: height + }; + } + + /** + * Returns the content rect of the element (bounding rect minus border and padding) + * @param {HTMLElement} el + */ + function getContentRect(el) { + var rect = getRect(el); + var paddingLeft = parseInt(css(el, 'padding-left')), + paddingTop = parseInt(css(el, 'padding-top')), + paddingRight = parseInt(css(el, 'padding-right')), + paddingBottom = parseInt(css(el, 'padding-bottom')); + rect.top += paddingTop + parseInt(css(el, 'border-top-width')); + rect.left += paddingLeft + parseInt(css(el, 'border-left-width')); + // Client Width/Height includes padding only + rect.width = el.clientWidth - paddingLeft - paddingRight; + rect.height = el.clientHeight - paddingTop - paddingBottom; + rect.bottom = rect.top + rect.height; + rect.right = rect.left + rect.width; + return rect; + } + + /** + * Checks if a side of an element is scrolled past a side of its parents + * @param {HTMLElement} el The element who's side being scrolled out of view is in question + * @param {String} elSide Side of the element in question ('top', 'left', 'right', 'bottom') + * @param {String} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom') + * @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element + */ + function isScrolledPast(el, elSide, parentSide) { + var parent = getParentAutoScrollElement(el, true), + elSideVal = getRect(el)[elSide]; + + /* jshint boss:true */ + while (parent) { + var parentSideVal = getRect(parent)[parentSide], + visible = void 0; + if (parentSide === 'top' || parentSide === 'left') { + visible = elSideVal >= parentSideVal; + } else { + visible = elSideVal <= parentSideVal; + } + if (!visible) return parent; + if (parent === getWindowScrollingElement()) break; + parent = getParentAutoScrollElement(parent, false); + } + return false; + } + + /** + * Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible) + * and non-draggable elements + * @param {HTMLElement} el The parent element + * @param {Number} childNum The index of the child + * @param {Object} options Parent Sortable's options + * @return {HTMLElement} The child at index childNum, or null if not found + */ + function getChild(el, childNum, options, includeDragEl) { + var currentChild = 0, + i = 0, + children = el.children; + while (i < children.length) { + if (children[i].style.display !== 'none' && children[i] !== Sortable.ghost && (includeDragEl || children[i] !== Sortable.dragged) && closest(children[i], options.draggable, el, false)) { + if (currentChild === childNum) { + return children[i]; + } + currentChild++; + } + i++; + } + return null; + } + + /** + * Gets the last child in the el, ignoring ghostEl or invisible elements (clones) + * @param {HTMLElement} el Parent element + * @param {selector} selector Any other elements that should be ignored + * @return {HTMLElement} The last child, ignoring ghostEl + */ + function lastChild(el, selector) { + var last = el.lastElementChild; + while (last && (last === Sortable.ghost || css(last, 'display') === 'none' || selector && !matches(last, selector))) { + last = last.previousElementSibling; + } + return last || null; + } + + /** + * Returns the index of an element within its parent for a selected set of + * elements + * @param {HTMLElement} el + * @param {selector} selector + * @return {number} + */ + function index(el, selector) { + var index = 0; + if (!el || !el.parentNode) { + return -1; + } + + /* jshint boss:true */ + while (el = el.previousElementSibling) { + if (el.nodeName.toUpperCase() !== 'TEMPLATE' && el !== Sortable.clone && (!selector || matches(el, selector))) { + index++; + } + } + return index; + } + + /** + * Returns the scroll offset of the given element, added with all the scroll offsets of parent elements. + * The value is returned in real pixels. + * @param {HTMLElement} el + * @return {Array} Offsets in the format of [left, top] + */ + function getRelativeScrollOffset(el) { + var offsetLeft = 0, + offsetTop = 0, + winScroller = getWindowScrollingElement(); + if (el) { + do { + var elMatrix = matrix(el), + scaleX = elMatrix.a, + scaleY = elMatrix.d; + offsetLeft += el.scrollLeft * scaleX; + offsetTop += el.scrollTop * scaleY; + } while (el !== winScroller && (el = el.parentNode)); + } + return [offsetLeft, offsetTop]; + } + + /** + * Returns the index of the object within the given array + * @param {Array} arr Array that may or may not hold the object + * @param {Object} obj An object that has a key-value pair unique to and identical to a key-value pair in the object you want to find + * @return {Number} The index of the object in the array, or -1 + */ + function indexOfObject(arr, obj) { + for (var i in arr) { + if (!arr.hasOwnProperty(i)) continue; + for (var key in obj) { + if (obj.hasOwnProperty(key) && obj[key] === arr[i][key]) return Number(i); + } + } + return -1; + } + function getParentAutoScrollElement(el, includeSelf) { + // skip to window + if (!el || !el.getBoundingClientRect) return getWindowScrollingElement(); + var elem = el; + var gotSelf = false; + do { + // we don't need to get elem css if it isn't even overflowing in the first place (performance) + if (elem.clientWidth < elem.scrollWidth || elem.clientHeight < elem.scrollHeight) { + var elemCSS = css(elem); + if (elem.clientWidth < elem.scrollWidth && (elemCSS.overflowX == 'auto' || elemCSS.overflowX == 'scroll') || elem.clientHeight < elem.scrollHeight && (elemCSS.overflowY == 'auto' || elemCSS.overflowY == 'scroll')) { + if (!elem.getBoundingClientRect || elem === document.body) return getWindowScrollingElement(); + if (gotSelf || includeSelf) return elem; + gotSelf = true; + } + } + /* jshint boss:true */ + } while (elem = elem.parentNode); + return getWindowScrollingElement(); + } + function extend(dst, src) { + if (dst && src) { + for (var key in src) { + if (src.hasOwnProperty(key)) { + dst[key] = src[key]; + } + } + } + return dst; + } + function isRectEqual(rect1, rect2) { + return Math.round(rect1.top) === Math.round(rect2.top) && Math.round(rect1.left) === Math.round(rect2.left) && Math.round(rect1.height) === Math.round(rect2.height) && Math.round(rect1.width) === Math.round(rect2.width); + } + var _throttleTimeout; + function throttle(callback, ms) { + return function () { + if (!_throttleTimeout) { + var args = arguments, + _this = this; + if (args.length === 1) { + callback.call(_this, args[0]); + } else { + callback.apply(_this, args); + } + _throttleTimeout = setTimeout(function () { + _throttleTimeout = void 0; + }, ms); + } + }; + } + function cancelThrottle() { + clearTimeout(_throttleTimeout); + _throttleTimeout = void 0; + } + function scrollBy(el, x, y) { + el.scrollLeft += x; + el.scrollTop += y; + } + function clone(el) { + var Polymer = window.Polymer; + var $ = window.jQuery || window.Zepto; + if (Polymer && Polymer.dom) { + return Polymer.dom(el).cloneNode(true); + } else if ($) { + return $(el).clone(true)[0]; + } else { + return el.cloneNode(true); + } + } + function setRect(el, rect) { + css(el, 'position', 'absolute'); + css(el, 'top', rect.top); + css(el, 'left', rect.left); + css(el, 'width', rect.width); + css(el, 'height', rect.height); + } + function unsetRect(el) { + css(el, 'position', ''); + css(el, 'top', ''); + css(el, 'left', ''); + css(el, 'width', ''); + css(el, 'height', ''); + } + var expando = 'Sortable' + new Date().getTime(); + + function AnimationStateManager() { + var animationStates = [], + animationCallbackId; + return { + captureAnimationState: function captureAnimationState() { + animationStates = []; + if (!this.options.animation) return; + var children = [].slice.call(this.el.children); + children.forEach(function (child) { + if (css(child, 'display') === 'none' || child === Sortable.ghost) return; + animationStates.push({ + target: child, + rect: getRect(child) + }); + var fromRect = _objectSpread2({}, animationStates[animationStates.length - 1].rect); + + // If animating: compensate for current animation + if (child.thisAnimationDuration) { + var childMatrix = matrix(child, true); + if (childMatrix) { + fromRect.top -= childMatrix.f; + fromRect.left -= childMatrix.e; + } + } + child.fromRect = fromRect; + }); + }, + addAnimationState: function addAnimationState(state) { + animationStates.push(state); + }, + removeAnimationState: function removeAnimationState(target) { + animationStates.splice(indexOfObject(animationStates, { + target: target + }), 1); + }, + animateAll: function animateAll(callback) { + var _this = this; + if (!this.options.animation) { + clearTimeout(animationCallbackId); + if (typeof callback === 'function') callback(); + return; + } + var animating = false, + animationTime = 0; + animationStates.forEach(function (state) { + var time = 0, + target = state.target, + fromRect = target.fromRect, + toRect = getRect(target), + prevFromRect = target.prevFromRect, + prevToRect = target.prevToRect, + animatingRect = state.rect, + targetMatrix = matrix(target, true); + if (targetMatrix) { + // Compensate for current animation + toRect.top -= targetMatrix.f; + toRect.left -= targetMatrix.e; + } + target.toRect = toRect; + if (target.thisAnimationDuration) { + // Could also check if animatingRect is between fromRect and toRect + if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) && + // Make sure animatingRect is on line between toRect & fromRect + (animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) { + // If returning to same place as started from animation and on same axis + time = calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options); + } + } + + // if fromRect != toRect: animate + if (!isRectEqual(toRect, fromRect)) { + target.prevFromRect = fromRect; + target.prevToRect = toRect; + if (!time) { + time = _this.options.animation; + } + _this.animate(target, animatingRect, toRect, time); + } + if (time) { + animating = true; + animationTime = Math.max(animationTime, time); + clearTimeout(target.animationResetTimer); + target.animationResetTimer = setTimeout(function () { + target.animationTime = 0; + target.prevFromRect = null; + target.fromRect = null; + target.prevToRect = null; + target.thisAnimationDuration = null; + }, time); + target.thisAnimationDuration = time; + } + }); + clearTimeout(animationCallbackId); + if (!animating) { + if (typeof callback === 'function') callback(); + } else { + animationCallbackId = setTimeout(function () { + if (typeof callback === 'function') callback(); + }, animationTime); + } + animationStates = []; + }, + animate: function animate(target, currentRect, toRect, duration) { + if (duration) { + css(target, 'transition', ''); + css(target, 'transform', ''); + var elMatrix = matrix(this.el), + scaleX = elMatrix && elMatrix.a, + scaleY = elMatrix && elMatrix.d, + translateX = (currentRect.left - toRect.left) / (scaleX || 1), + translateY = (currentRect.top - toRect.top) / (scaleY || 1); + target.animatingX = !!translateX; + target.animatingY = !!translateY; + css(target, 'transform', 'translate3d(' + translateX + 'px,' + translateY + 'px,0)'); + this.forRepaintDummy = repaint(target); // repaint + + css(target, 'transition', 'transform ' + duration + 'ms' + (this.options.easing ? ' ' + this.options.easing : '')); + css(target, 'transform', 'translate3d(0,0,0)'); + typeof target.animated === 'number' && clearTimeout(target.animated); + target.animated = setTimeout(function () { + css(target, 'transition', ''); + css(target, 'transform', ''); + target.animated = false; + target.animatingX = false; + target.animatingY = false; + }, duration); + } + } + }; + } + function repaint(target) { + return target.offsetWidth; + } + function calculateRealTime(animatingRect, fromRect, toRect, options) { + return Math.sqrt(Math.pow(fromRect.top - animatingRect.top, 2) + Math.pow(fromRect.left - animatingRect.left, 2)) / Math.sqrt(Math.pow(fromRect.top - toRect.top, 2) + Math.pow(fromRect.left - toRect.left, 2)) * options.animation; + } + + var plugins = []; + var defaults = { + initializeByDefault: true + }; + var PluginManager = { + mount: function mount(plugin) { + // Set default static properties + for (var option in defaults) { + if (defaults.hasOwnProperty(option) && !(option in plugin)) { + plugin[option] = defaults[option]; + } + } + plugins.forEach(function (p) { + if (p.pluginName === plugin.pluginName) { + throw "Sortable: Cannot mount plugin ".concat(plugin.pluginName, " more than once"); + } + }); + plugins.push(plugin); + }, + pluginEvent: function pluginEvent(eventName, sortable, evt) { + var _this = this; + this.eventCanceled = false; + evt.cancel = function () { + _this.eventCanceled = true; + }; + var eventNameGlobal = eventName + 'Global'; + plugins.forEach(function (plugin) { + if (!sortable[plugin.pluginName]) return; + // Fire global events if it exists in this sortable + if (sortable[plugin.pluginName][eventNameGlobal]) { + sortable[plugin.pluginName][eventNameGlobal](_objectSpread2({ + sortable: sortable + }, evt)); + } + + // Only fire plugin event if plugin is enabled in this sortable, + // and plugin has event defined + if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) { + sortable[plugin.pluginName][eventName](_objectSpread2({ + sortable: sortable + }, evt)); + } + }); + }, + initializePlugins: function initializePlugins(sortable, el, defaults, options) { + plugins.forEach(function (plugin) { + var pluginName = plugin.pluginName; + if (!sortable.options[pluginName] && !plugin.initializeByDefault) return; + var initialized = new plugin(sortable, el, sortable.options); + initialized.sortable = sortable; + initialized.options = sortable.options; + sortable[pluginName] = initialized; + + // Add default options from plugin + _extends(defaults, initialized.defaults); + }); + for (var option in sortable.options) { + if (!sortable.options.hasOwnProperty(option)) continue; + var modified = this.modifyOption(sortable, option, sortable.options[option]); + if (typeof modified !== 'undefined') { + sortable.options[option] = modified; + } + } + }, + getEventProperties: function getEventProperties(name, sortable) { + var eventProperties = {}; + plugins.forEach(function (plugin) { + if (typeof plugin.eventProperties !== 'function') return; + _extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name)); + }); + return eventProperties; + }, + modifyOption: function modifyOption(sortable, name, value) { + var modifiedValue; + plugins.forEach(function (plugin) { + // Plugin must exist on the Sortable + if (!sortable[plugin.pluginName]) return; + + // If static option listener exists for this option, call in the context of the Sortable's instance of this plugin + if (plugin.optionListeners && typeof plugin.optionListeners[name] === 'function') { + modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value); + } + }); + return modifiedValue; + } + }; + + function dispatchEvent(_ref) { + var sortable = _ref.sortable, + rootEl = _ref.rootEl, + name = _ref.name, + targetEl = _ref.targetEl, + cloneEl = _ref.cloneEl, + toEl = _ref.toEl, + fromEl = _ref.fromEl, + oldIndex = _ref.oldIndex, + newIndex = _ref.newIndex, + oldDraggableIndex = _ref.oldDraggableIndex, + newDraggableIndex = _ref.newDraggableIndex, + originalEvent = _ref.originalEvent, + putSortable = _ref.putSortable, + extraEventProperties = _ref.extraEventProperties; + sortable = sortable || rootEl && rootEl[expando]; + if (!sortable) return; + var evt, + options = sortable.options, + onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1); + // Support for new CustomEvent feature + if (window.CustomEvent && !IE11OrLess && !Edge) { + evt = new CustomEvent(name, { + bubbles: true, + cancelable: true + }); + } else { + evt = document.createEvent('Event'); + evt.initEvent(name, true, true); + } + evt.to = toEl || rootEl; + evt.from = fromEl || rootEl; + evt.item = targetEl || rootEl; + evt.clone = cloneEl; + evt.oldIndex = oldIndex; + evt.newIndex = newIndex; + evt.oldDraggableIndex = oldDraggableIndex; + evt.newDraggableIndex = newDraggableIndex; + evt.originalEvent = originalEvent; + evt.pullMode = putSortable ? putSortable.lastPutMode : undefined; + var allEventProperties = _objectSpread2(_objectSpread2({}, extraEventProperties), PluginManager.getEventProperties(name, sortable)); + for (var option in allEventProperties) { + evt[option] = allEventProperties[option]; + } + if (rootEl) { + rootEl.dispatchEvent(evt); + } + if (options[onName]) { + options[onName].call(sortable, evt); + } + } + + var _excluded = ["evt"]; + var pluginEvent = function pluginEvent(eventName, sortable) { + var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, + originalEvent = _ref.evt, + data = _objectWithoutProperties(_ref, _excluded); + PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread2({ + dragEl: dragEl, + parentEl: parentEl, + ghostEl: ghostEl, + rootEl: rootEl, + nextEl: nextEl, + lastDownEl: lastDownEl, + cloneEl: cloneEl, + cloneHidden: cloneHidden, + dragStarted: moved, + putSortable: putSortable, + activeSortable: Sortable.active, + originalEvent: originalEvent, + oldIndex: oldIndex, + oldDraggableIndex: oldDraggableIndex, + newIndex: newIndex, + newDraggableIndex: newDraggableIndex, + hideGhostForTarget: _hideGhostForTarget, + unhideGhostForTarget: _unhideGhostForTarget, + cloneNowHidden: function cloneNowHidden() { + cloneHidden = true; + }, + cloneNowShown: function cloneNowShown() { + cloneHidden = false; + }, + dispatchSortableEvent: function dispatchSortableEvent(name) { + _dispatchEvent({ + sortable: sortable, + name: name, + originalEvent: originalEvent + }); + } + }, data)); + }; + function _dispatchEvent(info) { + dispatchEvent(_objectSpread2({ + putSortable: putSortable, + cloneEl: cloneEl, + targetEl: dragEl, + rootEl: rootEl, + oldIndex: oldIndex, + oldDraggableIndex: oldDraggableIndex, + newIndex: newIndex, + newDraggableIndex: newDraggableIndex + }, info)); + } + var dragEl, + parentEl, + ghostEl, + rootEl, + nextEl, + lastDownEl, + cloneEl, + cloneHidden, + oldIndex, + newIndex, + oldDraggableIndex, + newDraggableIndex, + activeGroup, + putSortable, + awaitingDragStarted = false, + ignoreNextClick = false, + sortables = [], + tapEvt, + touchEvt, + lastDx, + lastDy, + tapDistanceLeft, + tapDistanceTop, + moved, + lastTarget, + lastDirection, + pastFirstInvertThresh = false, + isCircumstantialInvert = false, + targetMoveDistance, + // For positioning ghost absolutely + ghostRelativeParent, + ghostRelativeParentInitialScroll = [], + // (left, top) + + _silent = false, + savedInputChecked = []; + + /** @const */ + var documentExists = typeof document !== 'undefined', + PositionGhostAbsolutely = IOS, + CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float', + // This will not pass for IE9, because IE9 DnD only works on anchors + supportDraggable = documentExists && !ChromeForAndroid && !IOS && 'draggable' in document.createElement('div'), + supportCssPointerEvents = function () { + if (!documentExists) return; + // false when <= IE11 + if (IE11OrLess) { + return false; + } + var el = document.createElement('x'); + el.style.cssText = 'pointer-events:auto'; + return el.style.pointerEvents === 'auto'; + }(), + _detectDirection = function _detectDirection(el, options) { + var elCSS = css(el), + elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth), + child1 = getChild(el, 0, options), + child2 = getChild(el, 1, options), + firstChildCSS = child1 && css(child1), + secondChildCSS = child2 && css(child2), + firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width, + secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child2).width; + if (elCSS.display === 'flex') { + return elCSS.flexDirection === 'column' || elCSS.flexDirection === 'column-reverse' ? 'vertical' : 'horizontal'; + } + if (elCSS.display === 'grid') { + return elCSS.gridTemplateColumns.split(' ').length <= 1 ? 'vertical' : 'horizontal'; + } + if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== 'none') { + var touchingSideChild2 = firstChildCSS["float"] === 'left' ? 'left' : 'right'; + return child2 && (secondChildCSS.clear === 'both' || secondChildCSS.clear === touchingSideChild2) ? 'vertical' : 'horizontal'; + } + return child1 && (firstChildCSS.display === 'block' || firstChildCSS.display === 'flex' || firstChildCSS.display === 'table' || firstChildCSS.display === 'grid' || firstChildWidth >= elWidth && elCSS[CSSFloatProperty] === 'none' || child2 && elCSS[CSSFloatProperty] === 'none' && firstChildWidth + secondChildWidth > elWidth) ? 'vertical' : 'horizontal'; + }, + _dragElInRowColumn = function _dragElInRowColumn(dragRect, targetRect, vertical) { + var dragElS1Opp = vertical ? dragRect.left : dragRect.top, + dragElS2Opp = vertical ? dragRect.right : dragRect.bottom, + dragElOppLength = vertical ? dragRect.width : dragRect.height, + targetS1Opp = vertical ? targetRect.left : targetRect.top, + targetS2Opp = vertical ? targetRect.right : targetRect.bottom, + targetOppLength = vertical ? targetRect.width : targetRect.height; + return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2; + }, + /** + * Detects first nearest empty sortable to X and Y position using emptyInsertThreshold. + * @param {Number} x X position + * @param {Number} y Y position + * @return {HTMLElement} Element of the first found nearest Sortable + */ + _detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) { + var ret; + sortables.some(function (sortable) { + var threshold = sortable[expando].options.emptyInsertThreshold; + if (!threshold || lastChild(sortable)) return; + var rect = getRect(sortable), + insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold, + insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold; + if (insideHorizontally && insideVertically) { + return ret = sortable; + } + }); + return ret; + }, + _prepareGroup = function _prepareGroup(options) { + function toFn(value, pull) { + return function (to, from, dragEl, evt) { + var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name; + if (value == null && (pull || sameGroup)) { + // Default pull value + // Default pull and put value if same group + return true; + } else if (value == null || value === false) { + return false; + } else if (pull && value === 'clone') { + return value; + } else if (typeof value === 'function') { + return toFn(value(to, from, dragEl, evt), pull)(to, from, dragEl, evt); + } else { + var otherGroup = (pull ? to : from).options.group.name; + return value === true || typeof value === 'string' && value === otherGroup || value.join && value.indexOf(otherGroup) > -1; + } + }; + } + var group = {}; + var originalGroup = options.group; + if (!originalGroup || _typeof(originalGroup) != 'object') { + originalGroup = { + name: originalGroup + }; + } + group.name = originalGroup.name; + group.checkPull = toFn(originalGroup.pull, true); + group.checkPut = toFn(originalGroup.put); + group.revertClone = originalGroup.revertClone; + options.group = group; + }, + _hideGhostForTarget = function _hideGhostForTarget() { + if (!supportCssPointerEvents && ghostEl) { + css(ghostEl, 'display', 'none'); + } + }, + _unhideGhostForTarget = function _unhideGhostForTarget() { + if (!supportCssPointerEvents && ghostEl) { + css(ghostEl, 'display', ''); + } + }; + + // #1184 fix - Prevent click event on fallback if dragged but item not changed position + if (documentExists && !ChromeForAndroid) { + document.addEventListener('click', function (evt) { + if (ignoreNextClick) { + evt.preventDefault(); + evt.stopPropagation && evt.stopPropagation(); + evt.stopImmediatePropagation && evt.stopImmediatePropagation(); + ignoreNextClick = false; + return false; + } + }, true); + } + var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent(evt) { + if (dragEl) { + evt = evt.touches ? evt.touches[0] : evt; + var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY); + if (nearest) { + // Create imitation event + var event = {}; + for (var i in evt) { + if (evt.hasOwnProperty(i)) { + event[i] = evt[i]; + } + } + event.target = event.rootEl = nearest; + event.preventDefault = void 0; + event.stopPropagation = void 0; + nearest[expando]._onDragOver(event); + } + } + }; + var _checkOutsideTargetEl = function _checkOutsideTargetEl(evt) { + if (dragEl) { + dragEl.parentNode[expando]._isOutsideThisEl(evt.target); + } + }; + + /** + * @class Sortable + * @param {HTMLElement} el + * @param {Object} [options] + */ + function Sortable(el, options) { + if (!(el && el.nodeType && el.nodeType === 1)) { + throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el)); + } + this.el = el; // root element + this.options = options = _extends({}, options); + + // Export instance + el[expando] = this; + var defaults = { + group: null, + sort: true, + disabled: false, + store: null, + handle: null, + draggable: /^[uo]l$/i.test(el.nodeName) ? '>li' : '>*', + swapThreshold: 1, + // percentage; 0 <= x <= 1 + invertSwap: false, + // invert always + invertedSwapThreshold: null, + // will be set to same as swapThreshold if default + removeCloneOnHide: true, + direction: function direction() { + return _detectDirection(el, this.options); + }, + ghostClass: 'sortable-ghost', + chosenClass: 'sortable-chosen', + dragClass: 'sortable-drag', + ignore: 'a, img', + filter: null, + preventOnFilter: true, + animation: 0, + easing: null, + setData: function setData(dataTransfer, dragEl) { + dataTransfer.setData('Text', dragEl.textContent); + }, + dropBubble: false, + dragoverBubble: false, + dataIdAttr: 'data-id', + delay: 0, + delayOnTouchOnly: false, + touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1, + forceFallback: false, + fallbackClass: 'sortable-fallback', + fallbackOnBody: false, + fallbackTolerance: 0, + fallbackOffset: { + x: 0, + y: 0 + }, + supportPointer: Sortable.supportPointer !== false && 'PointerEvent' in window && !Safari, + emptyInsertThreshold: 5 + }; + PluginManager.initializePlugins(this, el, defaults); + + // Set default options + for (var name in defaults) { + !(name in options) && (options[name] = defaults[name]); + } + _prepareGroup(options); + + // Bind all private methods + for (var fn in this) { + if (fn.charAt(0) === '_' && typeof this[fn] === 'function') { + this[fn] = this[fn].bind(this); + } + } + + // Setup drag mode + this.nativeDraggable = options.forceFallback ? false : supportDraggable; + if (this.nativeDraggable) { + // Touch start threshold cannot be greater than the native dragstart threshold + this.options.touchStartThreshold = 1; + } + + // Bind events + if (options.supportPointer) { + on(el, 'pointerdown', this._onTapStart); + } else { + on(el, 'mousedown', this._onTapStart); + on(el, 'touchstart', this._onTapStart); + } + if (this.nativeDraggable) { + on(el, 'dragover', this); + on(el, 'dragenter', this); + } + sortables.push(this.el); + + // Restore sorting + options.store && options.store.get && this.sort(options.store.get(this) || []); + + // Add animation state manager + _extends(this, AnimationStateManager()); + } + Sortable.prototype = /** @lends Sortable.prototype */{ + constructor: Sortable, + _isOutsideThisEl: function _isOutsideThisEl(target) { + if (!this.el.contains(target) && target !== this.el) { + lastTarget = null; + } + }, + _getDirection: function _getDirection(evt, target) { + return typeof this.options.direction === 'function' ? this.options.direction.call(this, evt, target, dragEl) : this.options.direction; + }, + _onTapStart: function _onTapStart( /** Event|TouchEvent */evt) { + if (!evt.cancelable) return; + var _this = this, + el = this.el, + options = this.options, + preventOnFilter = options.preventOnFilter, + type = evt.type, + touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === 'touch' && evt, + target = (touch || evt).target, + originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target, + filter = options.filter; + _saveInputCheckedState(el); + + // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group. + if (dragEl) { + return; + } + if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) { + return; // only left button and enabled + } + + // cancel dnd if original target is content editable + if (originalTarget.isContentEditable) { + return; + } + + // Safari ignores further event handling after mousedown + if (!this.nativeDraggable && Safari && target && target.tagName.toUpperCase() === 'SELECT') { + return; + } + target = closest(target, options.draggable, el, false); + if (target && target.animated) { + return; + } + if (lastDownEl === target) { + // Ignoring duplicate `down` + return; + } + + // Get the index of the dragged element within its parent + oldIndex = index(target); + oldDraggableIndex = index(target, options.draggable); + + // Check filter + if (typeof filter === 'function') { + if (filter.call(this, evt, target, this)) { + _dispatchEvent({ + sortable: _this, + rootEl: originalTarget, + name: 'filter', + targetEl: target, + toEl: el, + fromEl: el + }); + pluginEvent('filter', _this, { + evt: evt + }); + preventOnFilter && evt.cancelable && evt.preventDefault(); + return; // cancel dnd + } + } else if (filter) { + filter = filter.split(',').some(function (criteria) { + criteria = closest(originalTarget, criteria.trim(), el, false); + if (criteria) { + _dispatchEvent({ + sortable: _this, + rootEl: criteria, + name: 'filter', + targetEl: target, + fromEl: el, + toEl: el + }); + pluginEvent('filter', _this, { + evt: evt + }); + return true; + } + }); + if (filter) { + preventOnFilter && evt.cancelable && evt.preventDefault(); + return; // cancel dnd + } + } + if (options.handle && !closest(originalTarget, options.handle, el, false)) { + return; + } + + // Prepare `dragstart` + this._prepareDragStart(evt, touch, target); + }, + _prepareDragStart: function _prepareDragStart( /** Event */evt, /** Touch */touch, /** HTMLElement */target) { + var _this = this, + el = _this.el, + options = _this.options, + ownerDocument = el.ownerDocument, + dragStartFn; + if (target && !dragEl && target.parentNode === el) { + var dragRect = getRect(target); + rootEl = el; + dragEl = target; + parentEl = dragEl.parentNode; + nextEl = dragEl.nextSibling; + lastDownEl = target; + activeGroup = options.group; + Sortable.dragged = dragEl; + tapEvt = { + target: dragEl, + clientX: (touch || evt).clientX, + clientY: (touch || evt).clientY + }; + tapDistanceLeft = tapEvt.clientX - dragRect.left; + tapDistanceTop = tapEvt.clientY - dragRect.top; + this._lastX = (touch || evt).clientX; + this._lastY = (touch || evt).clientY; + dragEl.style['will-change'] = 'all'; + dragStartFn = function dragStartFn() { + pluginEvent('delayEnded', _this, { + evt: evt + }); + if (Sortable.eventCanceled) { + _this._onDrop(); + return; + } + // Delayed drag has been triggered + // we can re-enable the events: touchmove/mousemove + _this._disableDelayedDragEvents(); + if (!FireFox && _this.nativeDraggable) { + dragEl.draggable = true; + } + + // Bind the events: dragstart/dragend + _this._triggerDragStart(evt, touch); + + // Drag start event + _dispatchEvent({ + sortable: _this, + name: 'choose', + originalEvent: evt + }); + + // Chosen item + toggleClass(dragEl, options.chosenClass, true); + }; + + // Disable "draggable" + options.ignore.split(',').forEach(function (criteria) { + find(dragEl, criteria.trim(), _disableDraggable); + }); + on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent); + on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent); + on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent); + on(ownerDocument, 'mouseup', _this._onDrop); + on(ownerDocument, 'touchend', _this._onDrop); + on(ownerDocument, 'touchcancel', _this._onDrop); + + // Make dragEl draggable (must be before delay for FireFox) + if (FireFox && this.nativeDraggable) { + this.options.touchStartThreshold = 4; + dragEl.draggable = true; + } + pluginEvent('delayStart', this, { + evt: evt + }); + + // Delay is impossible for native DnD in Edge or IE + if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) { + if (Sortable.eventCanceled) { + this._onDrop(); + return; + } + // If the user moves the pointer or let go the click or touch + // before the delay has been reached: + // disable the delayed drag + on(ownerDocument, 'mouseup', _this._disableDelayedDrag); + on(ownerDocument, 'touchend', _this._disableDelayedDrag); + on(ownerDocument, 'touchcancel', _this._disableDelayedDrag); + on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler); + on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler); + options.supportPointer && on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler); + _this._dragStartTimer = setTimeout(dragStartFn, options.delay); + } else { + dragStartFn(); + } + } + }, + _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler( /** TouchEvent|PointerEvent **/e) { + var touch = e.touches ? e.touches[0] : e; + if (Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) >= Math.floor(this.options.touchStartThreshold / (this.nativeDraggable && window.devicePixelRatio || 1))) { + this._disableDelayedDrag(); + } + }, + _disableDelayedDrag: function _disableDelayedDrag() { + dragEl && _disableDraggable(dragEl); + clearTimeout(this._dragStartTimer); + this._disableDelayedDragEvents(); + }, + _disableDelayedDragEvents: function _disableDelayedDragEvents() { + var ownerDocument = this.el.ownerDocument; + off(ownerDocument, 'mouseup', this._disableDelayedDrag); + off(ownerDocument, 'touchend', this._disableDelayedDrag); + off(ownerDocument, 'touchcancel', this._disableDelayedDrag); + off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler); + off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler); + off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler); + }, + _triggerDragStart: function _triggerDragStart( /** Event */evt, /** Touch */touch) { + touch = touch || evt.pointerType == 'touch' && evt; + if (!this.nativeDraggable || touch) { + if (this.options.supportPointer) { + on(document, 'pointermove', this._onTouchMove); + } else if (touch) { + on(document, 'touchmove', this._onTouchMove); + } else { + on(document, 'mousemove', this._onTouchMove); + } + } else { + on(dragEl, 'dragend', this); + on(rootEl, 'dragstart', this._onDragStart); + } + try { + if (document.selection) { + // Timeout neccessary for IE9 + _nextTick(function () { + document.selection.empty(); + }); + } else { + window.getSelection().removeAllRanges(); + } + } catch (err) {} + }, + _dragStarted: function _dragStarted(fallback, evt) { + awaitingDragStarted = false; + if (rootEl && dragEl) { + pluginEvent('dragStarted', this, { + evt: evt + }); + if (this.nativeDraggable) { + on(document, 'dragover', _checkOutsideTargetEl); + } + var options = this.options; + + // Apply effect + !fallback && toggleClass(dragEl, options.dragClass, false); + toggleClass(dragEl, options.ghostClass, true); + Sortable.active = this; + fallback && this._appendGhost(); + + // Drag start event + _dispatchEvent({ + sortable: this, + name: 'start', + originalEvent: evt + }); + } else { + this._nulling(); + } + }, + _emulateDragOver: function _emulateDragOver() { + if (touchEvt) { + this._lastX = touchEvt.clientX; + this._lastY = touchEvt.clientY; + _hideGhostForTarget(); + var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY); + var parent = target; + while (target && target.shadowRoot) { + target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY); + if (target === parent) break; + parent = target; + } + dragEl.parentNode[expando]._isOutsideThisEl(target); + if (parent) { + do { + if (parent[expando]) { + var inserted = void 0; + inserted = parent[expando]._onDragOver({ + clientX: touchEvt.clientX, + clientY: touchEvt.clientY, + target: target, + rootEl: parent + }); + if (inserted && !this.options.dragoverBubble) { + break; + } + } + target = parent; // store last element + } + /* jshint boss:true */ while (parent = parent.parentNode); + } + _unhideGhostForTarget(); + } + }, + _onTouchMove: function _onTouchMove( /**TouchEvent*/evt) { + if (tapEvt) { + var options = this.options, + fallbackTolerance = options.fallbackTolerance, + fallbackOffset = options.fallbackOffset, + touch = evt.touches ? evt.touches[0] : evt, + ghostMatrix = ghostEl && matrix(ghostEl, true), + scaleX = ghostEl && ghostMatrix && ghostMatrix.a, + scaleY = ghostEl && ghostMatrix && ghostMatrix.d, + relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent), + dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1), + dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1); + + // only set the status to dragging, when we are actually dragging + if (!Sortable.active && !awaitingDragStarted) { + if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) { + return; + } + this._onDragStart(evt, true); + } + if (ghostEl) { + if (ghostMatrix) { + ghostMatrix.e += dx - (lastDx || 0); + ghostMatrix.f += dy - (lastDy || 0); + } else { + ghostMatrix = { + a: 1, + b: 0, + c: 0, + d: 1, + e: dx, + f: dy + }; + } + var cssMatrix = "matrix(".concat(ghostMatrix.a, ",").concat(ghostMatrix.b, ",").concat(ghostMatrix.c, ",").concat(ghostMatrix.d, ",").concat(ghostMatrix.e, ",").concat(ghostMatrix.f, ")"); + css(ghostEl, 'webkitTransform', cssMatrix); + css(ghostEl, 'mozTransform', cssMatrix); + css(ghostEl, 'msTransform', cssMatrix); + css(ghostEl, 'transform', cssMatrix); + lastDx = dx; + lastDy = dy; + touchEvt = touch; + } + evt.cancelable && evt.preventDefault(); + } + }, + _appendGhost: function _appendGhost() { + // Bug if using scale(): https://stackoverflow.com/questions/2637058 + // Not being adjusted for + if (!ghostEl) { + var container = this.options.fallbackOnBody ? document.body : rootEl, + rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container), + options = this.options; + + // Position absolutely + if (PositionGhostAbsolutely) { + // Get relatively positioned parent + ghostRelativeParent = container; + while (css(ghostRelativeParent, 'position') === 'static' && css(ghostRelativeParent, 'transform') === 'none' && ghostRelativeParent !== document) { + ghostRelativeParent = ghostRelativeParent.parentNode; + } + if (ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement) { + if (ghostRelativeParent === document) ghostRelativeParent = getWindowScrollingElement(); + rect.top += ghostRelativeParent.scrollTop; + rect.left += ghostRelativeParent.scrollLeft; + } else { + ghostRelativeParent = getWindowScrollingElement(); + } + ghostRelativeParentInitialScroll = getRelativeScrollOffset(ghostRelativeParent); + } + ghostEl = dragEl.cloneNode(true); + toggleClass(ghostEl, options.ghostClass, false); + toggleClass(ghostEl, options.fallbackClass, true); + toggleClass(ghostEl, options.dragClass, true); + css(ghostEl, 'transition', ''); + css(ghostEl, 'transform', ''); + css(ghostEl, 'box-sizing', 'border-box'); + css(ghostEl, 'margin', 0); + css(ghostEl, 'top', rect.top); + css(ghostEl, 'left', rect.left); + css(ghostEl, 'width', rect.width); + css(ghostEl, 'height', rect.height); + css(ghostEl, 'opacity', '0.8'); + css(ghostEl, 'position', PositionGhostAbsolutely ? 'absolute' : 'fixed'); + css(ghostEl, 'zIndex', '100000'); + css(ghostEl, 'pointerEvents', 'none'); + Sortable.ghost = ghostEl; + container.appendChild(ghostEl); + + // Set transform-origin + css(ghostEl, 'transform-origin', tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + '% ' + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + '%'); + } + }, + _onDragStart: function _onDragStart( /**Event*/evt, /**boolean*/fallback) { + var _this = this; + var dataTransfer = evt.dataTransfer; + var options = _this.options; + pluginEvent('dragStart', this, { + evt: evt + }); + if (Sortable.eventCanceled) { + this._onDrop(); + return; + } + pluginEvent('setupClone', this); + if (!Sortable.eventCanceled) { + cloneEl = clone(dragEl); + cloneEl.removeAttribute("id"); + cloneEl.draggable = false; + cloneEl.style['will-change'] = ''; + this._hideClone(); + toggleClass(cloneEl, this.options.chosenClass, false); + Sortable.clone = cloneEl; + } + + // #1143: IFrame support workaround + _this.cloneId = _nextTick(function () { + pluginEvent('clone', _this); + if (Sortable.eventCanceled) return; + if (!_this.options.removeCloneOnHide) { + rootEl.insertBefore(cloneEl, dragEl); + } + _this._hideClone(); + _dispatchEvent({ + sortable: _this, + name: 'clone' + }); + }); + !fallback && toggleClass(dragEl, options.dragClass, true); + + // Set proper drop events + if (fallback) { + ignoreNextClick = true; + _this._loopId = setInterval(_this._emulateDragOver, 50); + } else { + // Undo what was set in _prepareDragStart before drag started + off(document, 'mouseup', _this._onDrop); + off(document, 'touchend', _this._onDrop); + off(document, 'touchcancel', _this._onDrop); + if (dataTransfer) { + dataTransfer.effectAllowed = 'move'; + options.setData && options.setData.call(_this, dataTransfer, dragEl); + } + on(document, 'drop', _this); + + // #1276 fix: + css(dragEl, 'transform', 'translateZ(0)'); + } + awaitingDragStarted = true; + _this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt)); + on(document, 'selectstart', _this); + moved = true; + if (Safari) { + css(document.body, 'user-select', 'none'); + } + }, + // Returns true - if no further action is needed (either inserted or another condition) + _onDragOver: function _onDragOver( /**Event*/evt) { + var el = this.el, + target = evt.target, + dragRect, + targetRect, + revert, + options = this.options, + group = options.group, + activeSortable = Sortable.active, + isOwner = activeGroup === group, + canSort = options.sort, + fromSortable = putSortable || activeSortable, + vertical, + _this = this, + completedFired = false; + if (_silent) return; + function dragOverEvent(name, extra) { + pluginEvent(name, _this, _objectSpread2({ + evt: evt, + isOwner: isOwner, + axis: vertical ? 'vertical' : 'horizontal', + revert: revert, + dragRect: dragRect, + targetRect: targetRect, + canSort: canSort, + fromSortable: fromSortable, + target: target, + completed: completed, + onMove: function onMove(target, after) { + return _onMove(rootEl, el, dragEl, dragRect, target, getRect(target), evt, after); + }, + changed: changed + }, extra)); + } + + // Capture animation state + function capture() { + dragOverEvent('dragOverAnimationCapture'); + _this.captureAnimationState(); + if (_this !== fromSortable) { + fromSortable.captureAnimationState(); + } + } + + // Return invocation when dragEl is inserted (or completed) + function completed(insertion) { + dragOverEvent('dragOverCompleted', { + insertion: insertion + }); + if (insertion) { + // Clones must be hidden before folding animation to capture dragRectAbsolute properly + if (isOwner) { + activeSortable._hideClone(); + } else { + activeSortable._showClone(_this); + } + if (_this !== fromSortable) { + // Set ghost class to new sortable's ghost class + toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false); + toggleClass(dragEl, options.ghostClass, true); + } + if (putSortable !== _this && _this !== Sortable.active) { + putSortable = _this; + } else if (_this === Sortable.active && putSortable) { + putSortable = null; + } + + // Animation + if (fromSortable === _this) { + _this._ignoreWhileAnimating = target; + } + _this.animateAll(function () { + dragOverEvent('dragOverAnimationComplete'); + _this._ignoreWhileAnimating = null; + }); + if (_this !== fromSortable) { + fromSortable.animateAll(); + fromSortable._ignoreWhileAnimating = null; + } + } + + // Null lastTarget if it is not inside a previously swapped element + if (target === dragEl && !dragEl.animated || target === el && !target.animated) { + lastTarget = null; + } + + // no bubbling and not fallback + if (!options.dragoverBubble && !evt.rootEl && target !== document) { + dragEl.parentNode[expando]._isOutsideThisEl(evt.target); + + // Do not detect for empty insert if already inserted + !insertion && nearestEmptyInsertDetectEvent(evt); + } + !options.dragoverBubble && evt.stopPropagation && evt.stopPropagation(); + return completedFired = true; + } + + // Call when dragEl has been inserted + function changed() { + newIndex = index(dragEl); + newDraggableIndex = index(dragEl, options.draggable); + _dispatchEvent({ + sortable: _this, + name: 'change', + toEl: el, + newIndex: newIndex, + newDraggableIndex: newDraggableIndex, + originalEvent: evt + }); + } + if (evt.preventDefault !== void 0) { + evt.cancelable && evt.preventDefault(); + } + target = closest(target, options.draggable, el, true); + dragOverEvent('dragOver'); + if (Sortable.eventCanceled) return completedFired; + if (dragEl.contains(evt.target) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target) { + return completed(false); + } + ignoreNextClick = false; + if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = parentEl !== rootEl) // Reverting item into the original list + : putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt))) { + vertical = this._getDirection(evt, target) === 'vertical'; + dragRect = getRect(dragEl); + dragOverEvent('dragOverValid'); + if (Sortable.eventCanceled) return completedFired; + if (revert) { + parentEl = rootEl; // actualization + capture(); + this._hideClone(); + dragOverEvent('revert'); + if (!Sortable.eventCanceled) { + if (nextEl) { + rootEl.insertBefore(dragEl, nextEl); + } else { + rootEl.appendChild(dragEl); + } + } + return completed(true); + } + var elLastChild = lastChild(el, options.draggable); + if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) { + // Insert to end of list + + // If already at end of list: Do not insert + if (elLastChild === dragEl) { + return completed(false); + } + + // if there is a last element, it is the target + if (elLastChild && el === evt.target) { + target = elLastChild; + } + if (target) { + targetRect = getRect(target); + } + if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) { + capture(); + if (elLastChild && elLastChild.nextSibling) { + // the last draggable element is not the last node + el.insertBefore(dragEl, elLastChild.nextSibling); + } else { + el.appendChild(dragEl); + } + parentEl = el; // actualization + + changed(); + return completed(true); + } + } else if (elLastChild && _ghostIsFirst(evt, vertical, this)) { + // Insert to start of list + var firstChild = getChild(el, 0, options, true); + if (firstChild === dragEl) { + return completed(false); + } + target = firstChild; + targetRect = getRect(target); + if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, false) !== false) { + capture(); + el.insertBefore(dragEl, firstChild); + parentEl = el; // actualization + + changed(); + return completed(true); + } + } else if (target.parentNode === el) { + targetRect = getRect(target); + var direction = 0, + targetBeforeFirstSwap, + differentLevel = dragEl.parentNode !== el, + differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical), + side1 = vertical ? 'top' : 'left', + scrolledPastTop = isScrolledPast(target, 'top', 'top') || isScrolledPast(dragEl, 'top', 'top'), + scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0; + if (lastTarget !== target) { + targetBeforeFirstSwap = targetRect[side1]; + pastFirstInvertThresh = false; + isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel; + } + direction = _getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target); + var sibling; + if (direction !== 0) { + // Check if target is beside dragEl in respective direction (ignoring hidden elements) + var dragIndex = index(dragEl); + do { + dragIndex -= direction; + sibling = parentEl.children[dragIndex]; + } while (sibling && (css(sibling, 'display') === 'none' || sibling === ghostEl)); + } + // If dragEl is already beside target: Do not insert + if (direction === 0 || sibling === target) { + return completed(false); + } + lastTarget = target; + lastDirection = direction; + var nextSibling = target.nextElementSibling, + after = false; + after = direction === 1; + var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after); + if (moveVector !== false) { + if (moveVector === 1 || moveVector === -1) { + after = moveVector === 1; + } + _silent = true; + setTimeout(_unsilent, 30); + capture(); + if (after && !nextSibling) { + el.appendChild(dragEl); + } else { + target.parentNode.insertBefore(dragEl, after ? nextSibling : target); + } + + // Undo chrome's scroll adjustment (has no effect on other browsers) + if (scrolledPastTop) { + scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop); + } + parentEl = dragEl.parentNode; // actualization + + // must be done before animation + if (targetBeforeFirstSwap !== undefined && !isCircumstantialInvert) { + targetMoveDistance = Math.abs(targetBeforeFirstSwap - getRect(target)[side1]); + } + changed(); + return completed(true); + } + } + if (el.contains(dragEl)) { + return completed(false); + } + } + return false; + }, + _ignoreWhileAnimating: null, + _offMoveEvents: function _offMoveEvents() { + off(document, 'mousemove', this._onTouchMove); + off(document, 'touchmove', this._onTouchMove); + off(document, 'pointermove', this._onTouchMove); + off(document, 'dragover', nearestEmptyInsertDetectEvent); + off(document, 'mousemove', nearestEmptyInsertDetectEvent); + off(document, 'touchmove', nearestEmptyInsertDetectEvent); + }, + _offUpEvents: function _offUpEvents() { + var ownerDocument = this.el.ownerDocument; + off(ownerDocument, 'mouseup', this._onDrop); + off(ownerDocument, 'touchend', this._onDrop); + off(ownerDocument, 'pointerup', this._onDrop); + off(ownerDocument, 'touchcancel', this._onDrop); + off(document, 'selectstart', this); + }, + _onDrop: function _onDrop( /**Event*/evt) { + var el = this.el, + options = this.options; + + // Get the index of the dragged element within its parent + newIndex = index(dragEl); + newDraggableIndex = index(dragEl, options.draggable); + pluginEvent('drop', this, { + evt: evt + }); + parentEl = dragEl && dragEl.parentNode; + + // Get again after plugin event + newIndex = index(dragEl); + newDraggableIndex = index(dragEl, options.draggable); + if (Sortable.eventCanceled) { + this._nulling(); + return; + } + awaitingDragStarted = false; + isCircumstantialInvert = false; + pastFirstInvertThresh = false; + clearInterval(this._loopId); + clearTimeout(this._dragStartTimer); + _cancelNextTick(this.cloneId); + _cancelNextTick(this._dragStartId); + + // Unbind events + if (this.nativeDraggable) { + off(document, 'drop', this); + off(el, 'dragstart', this._onDragStart); + } + this._offMoveEvents(); + this._offUpEvents(); + if (Safari) { + css(document.body, 'user-select', ''); + } + css(dragEl, 'transform', ''); + if (evt) { + if (moved) { + evt.cancelable && evt.preventDefault(); + !options.dropBubble && evt.stopPropagation(); + } + ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl); + if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') { + // Remove clone(s) + cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl); + } + if (dragEl) { + if (this.nativeDraggable) { + off(dragEl, 'dragend', this); + } + _disableDraggable(dragEl); + dragEl.style['will-change'] = ''; + + // Remove classes + // ghostClass is added in dragStarted + if (moved && !awaitingDragStarted) { + toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false); + } + toggleClass(dragEl, this.options.chosenClass, false); + + // Drag stop event + _dispatchEvent({ + sortable: this, + name: 'unchoose', + toEl: parentEl, + newIndex: null, + newDraggableIndex: null, + originalEvent: evt + }); + if (rootEl !== parentEl) { + if (newIndex >= 0) { + // Add event + _dispatchEvent({ + rootEl: parentEl, + name: 'add', + toEl: parentEl, + fromEl: rootEl, + originalEvent: evt + }); + + // Remove event + _dispatchEvent({ + sortable: this, + name: 'remove', + toEl: parentEl, + originalEvent: evt + }); + + // drag from one list and drop into another + _dispatchEvent({ + rootEl: parentEl, + name: 'sort', + toEl: parentEl, + fromEl: rootEl, + originalEvent: evt + }); + _dispatchEvent({ + sortable: this, + name: 'sort', + toEl: parentEl, + originalEvent: evt + }); + } + putSortable && putSortable.save(); + } else { + if (newIndex !== oldIndex) { + if (newIndex >= 0) { + // drag & drop within the same list + _dispatchEvent({ + sortable: this, + name: 'update', + toEl: parentEl, + originalEvent: evt + }); + _dispatchEvent({ + sortable: this, + name: 'sort', + toEl: parentEl, + originalEvent: evt + }); + } + } + } + if (Sortable.active) { + /* jshint eqnull:true */ + if (newIndex == null || newIndex === -1) { + newIndex = oldIndex; + newDraggableIndex = oldDraggableIndex; + } + _dispatchEvent({ + sortable: this, + name: 'end', + toEl: parentEl, + originalEvent: evt + }); + + // Save sorting + this.save(); + } + } + } + this._nulling(); + }, + _nulling: function _nulling() { + pluginEvent('nulling', this); + rootEl = dragEl = parentEl = ghostEl = nextEl = cloneEl = lastDownEl = cloneHidden = tapEvt = touchEvt = moved = newIndex = newDraggableIndex = oldIndex = oldDraggableIndex = lastTarget = lastDirection = putSortable = activeGroup = Sortable.dragged = Sortable.ghost = Sortable.clone = Sortable.active = null; + savedInputChecked.forEach(function (el) { + el.checked = true; + }); + savedInputChecked.length = lastDx = lastDy = 0; + }, + handleEvent: function handleEvent( /**Event*/evt) { + switch (evt.type) { + case 'drop': + case 'dragend': + this._onDrop(evt); + break; + case 'dragenter': + case 'dragover': + if (dragEl) { + this._onDragOver(evt); + _globalDragOver(evt); + } + break; + case 'selectstart': + evt.preventDefault(); + break; + } + }, + /** + * Serializes the item into an array of string. + * @returns {String[]} + */ + toArray: function toArray() { + var order = [], + el, + children = this.el.children, + i = 0, + n = children.length, + options = this.options; + for (; i < n; i++) { + el = children[i]; + if (closest(el, options.draggable, this.el, false)) { + order.push(el.getAttribute(options.dataIdAttr) || _generateId(el)); + } + } + return order; + }, + /** + * Sorts the elements according to the array. + * @param {String[]} order order of the items + */ + sort: function sort(order, useAnimation) { + var items = {}, + rootEl = this.el; + this.toArray().forEach(function (id, i) { + var el = rootEl.children[i]; + if (closest(el, this.options.draggable, rootEl, false)) { + items[id] = el; + } + }, this); + useAnimation && this.captureAnimationState(); + order.forEach(function (id) { + if (items[id]) { + rootEl.removeChild(items[id]); + rootEl.appendChild(items[id]); + } + }); + useAnimation && this.animateAll(); + }, + /** + * Save the current sorting + */ + save: function save() { + var store = this.options.store; + store && store.set && store.set(this); + }, + /** + * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree. + * @param {HTMLElement} el + * @param {String} [selector] default: `options.draggable` + * @returns {HTMLElement|null} + */ + closest: function closest$1(el, selector) { + return closest(el, selector || this.options.draggable, this.el, false); + }, + /** + * Set/get option + * @param {string} name + * @param {*} [value] + * @returns {*} + */ + option: function option(name, value) { + var options = this.options; + if (value === void 0) { + return options[name]; + } else { + var modifiedValue = PluginManager.modifyOption(this, name, value); + if (typeof modifiedValue !== 'undefined') { + options[name] = modifiedValue; + } else { + options[name] = value; + } + if (name === 'group') { + _prepareGroup(options); + } + } + }, + /** + * Destroy + */ + destroy: function destroy() { + pluginEvent('destroy', this); + var el = this.el; + el[expando] = null; + off(el, 'mousedown', this._onTapStart); + off(el, 'touchstart', this._onTapStart); + off(el, 'pointerdown', this._onTapStart); + if (this.nativeDraggable) { + off(el, 'dragover', this); + off(el, 'dragenter', this); + } + // Remove draggable attributes + Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) { + el.removeAttribute('draggable'); + }); + this._onDrop(); + this._disableDelayedDragEvents(); + sortables.splice(sortables.indexOf(this.el), 1); + this.el = el = null; + }, + _hideClone: function _hideClone() { + if (!cloneHidden) { + pluginEvent('hideClone', this); + if (Sortable.eventCanceled) return; + css(cloneEl, 'display', 'none'); + if (this.options.removeCloneOnHide && cloneEl.parentNode) { + cloneEl.parentNode.removeChild(cloneEl); + } + cloneHidden = true; + } + }, + _showClone: function _showClone(putSortable) { + if (putSortable.lastPutMode !== 'clone') { + this._hideClone(); + return; + } + if (cloneHidden) { + pluginEvent('showClone', this); + if (Sortable.eventCanceled) return; + + // show clone at dragEl or original position + if (dragEl.parentNode == rootEl && !this.options.group.revertClone) { + rootEl.insertBefore(cloneEl, dragEl); + } else if (nextEl) { + rootEl.insertBefore(cloneEl, nextEl); + } else { + rootEl.appendChild(cloneEl); + } + if (this.options.group.revertClone) { + this.animate(dragEl, cloneEl); + } + css(cloneEl, 'display', ''); + cloneHidden = false; + } + } + }; + function _globalDragOver( /**Event*/evt) { + if (evt.dataTransfer) { + evt.dataTransfer.dropEffect = 'move'; + } + evt.cancelable && evt.preventDefault(); + } + function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) { + var evt, + sortable = fromEl[expando], + onMoveFn = sortable.options.onMove, + retVal; + // Support for new CustomEvent feature + if (window.CustomEvent && !IE11OrLess && !Edge) { + evt = new CustomEvent('move', { + bubbles: true, + cancelable: true + }); + } else { + evt = document.createEvent('Event'); + evt.initEvent('move', true, true); + } + evt.to = toEl; + evt.from = fromEl; + evt.dragged = dragEl; + evt.draggedRect = dragRect; + evt.related = targetEl || toEl; + evt.relatedRect = targetRect || getRect(toEl); + evt.willInsertAfter = willInsertAfter; + evt.originalEvent = originalEvent; + fromEl.dispatchEvent(evt); + if (onMoveFn) { + retVal = onMoveFn.call(sortable, evt, originalEvent); + } + return retVal; + } + function _disableDraggable(el) { + el.draggable = false; + } + function _unsilent() { + _silent = false; + } + function _ghostIsFirst(evt, vertical, sortable) { + var firstElRect = getRect(getChild(sortable.el, 0, sortable.options, true)); + var sortableContentRect = getContentRect(sortable.el); + var spacer = 10; + return vertical ? evt.clientX < sortableContentRect.left - spacer || evt.clientY < firstElRect.top && evt.clientX < firstElRect.right : evt.clientY < sortableContentRect.top - spacer || evt.clientY < firstElRect.bottom && evt.clientX < firstElRect.left; + } + function _ghostIsLast(evt, vertical, sortable) { + var lastElRect = getRect(lastChild(sortable.el, sortable.options.draggable)); + var sortableContentRect = getContentRect(sortable.el); + var spacer = 10; + return vertical ? evt.clientX > sortableContentRect.right + spacer || evt.clientY > lastElRect.bottom && evt.clientX > lastElRect.left : evt.clientY > sortableContentRect.bottom + spacer || evt.clientX > lastElRect.right && evt.clientY > lastElRect.top; + } + function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) { + var mouseOnAxis = vertical ? evt.clientY : evt.clientX, + targetLength = vertical ? targetRect.height : targetRect.width, + targetS1 = vertical ? targetRect.top : targetRect.left, + targetS2 = vertical ? targetRect.bottom : targetRect.right, + invert = false; + if (!invertSwap) { + // Never invert or create dragEl shadow when target movemenet causes mouse to move past the end of regular swapThreshold + if (isLastTarget && targetMoveDistance < targetLength * swapThreshold) { + // multiplied only by swapThreshold because mouse will already be inside target by (1 - threshold) * targetLength / 2 + // check if past first invert threshold on side opposite of lastDirection + if (!pastFirstInvertThresh && (lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2)) { + // past first invert threshold, do not restrict inverted threshold to dragEl shadow + pastFirstInvertThresh = true; + } + if (!pastFirstInvertThresh) { + // dragEl shadow (target move distance shadow) + if (lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance // over dragEl shadow + : mouseOnAxis > targetS2 - targetMoveDistance) { + return -lastDirection; + } + } else { + invert = true; + } + } else { + // Regular + if (mouseOnAxis > targetS1 + targetLength * (1 - swapThreshold) / 2 && mouseOnAxis < targetS2 - targetLength * (1 - swapThreshold) / 2) { + return _getInsertDirection(target); + } + } + } + invert = invert || invertSwap; + if (invert) { + // Invert of regular + if (mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2) { + return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1; + } + } + return 0; + } + + /** + * Gets the direction dragEl must be swapped relative to target in order to make it + * seem that dragEl has been "inserted" into that element's position + * @param {HTMLElement} target The target whose position dragEl is being inserted at + * @return {Number} Direction dragEl must be swapped + */ + function _getInsertDirection(target) { + if (index(dragEl) < index(target)) { + return 1; + } else { + return -1; + } + } + + /** + * Generate id + * @param {HTMLElement} el + * @returns {String} + * @private + */ + function _generateId(el) { + var str = el.tagName + el.className + el.src + el.href + el.textContent, + i = str.length, + sum = 0; + while (i--) { + sum += str.charCodeAt(i); + } + return sum.toString(36); + } + function _saveInputCheckedState(root) { + savedInputChecked.length = 0; + var inputs = root.getElementsByTagName('input'); + var idx = inputs.length; + while (idx--) { + var el = inputs[idx]; + el.checked && savedInputChecked.push(el); + } + } + function _nextTick(fn) { + return setTimeout(fn, 0); + } + function _cancelNextTick(id) { + return clearTimeout(id); + } + + // Fixed #973: + if (documentExists) { + on(document, 'touchmove', function (evt) { + if ((Sortable.active || awaitingDragStarted) && evt.cancelable) { + evt.preventDefault(); + } + }); + } + + // Export utils + Sortable.utils = { + on: on, + off: off, + css: css, + find: find, + is: function is(el, selector) { + return !!closest(el, selector, el, false); + }, + extend: extend, + throttle: throttle, + closest: closest, + toggleClass: toggleClass, + clone: clone, + index: index, + nextTick: _nextTick, + cancelNextTick: _cancelNextTick, + detectDirection: _detectDirection, + getChild: getChild + }; + + /** + * Get the Sortable instance of an element + * @param {HTMLElement} element The element + * @return {Sortable|undefined} The instance of Sortable + */ + Sortable.get = function (element) { + return element[expando]; + }; + + /** + * Mount a plugin to Sortable + * @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted + */ + Sortable.mount = function () { + for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) { + plugins[_key] = arguments[_key]; + } + if (plugins[0].constructor === Array) plugins = plugins[0]; + plugins.forEach(function (plugin) { + if (!plugin.prototype || !plugin.prototype.constructor) { + throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin)); + } + if (plugin.utils) Sortable.utils = _objectSpread2(_objectSpread2({}, Sortable.utils), plugin.utils); + PluginManager.mount(plugin); + }); + }; + + /** + * Create sortable instance + * @param {HTMLElement} el + * @param {Object} [options] + */ + Sortable.create = function (el, options) { + return new Sortable(el, options); + }; + + // Export + Sortable.version = version; + + var autoScrolls = [], + scrollEl, + scrollRootEl, + scrolling = false, + lastAutoScrollX, + lastAutoScrollY, + touchEvt$1, + pointerElemChangedInterval; + function AutoScrollPlugin() { + function AutoScroll() { + this.defaults = { + scroll: true, + forceAutoScrollFallback: false, + scrollSensitivity: 30, + scrollSpeed: 10, + bubbleScroll: true + }; + + // Bind all private methods + for (var fn in this) { + if (fn.charAt(0) === '_' && typeof this[fn] === 'function') { + this[fn] = this[fn].bind(this); + } + } + } + AutoScroll.prototype = { + dragStarted: function dragStarted(_ref) { + var originalEvent = _ref.originalEvent; + if (this.sortable.nativeDraggable) { + on(document, 'dragover', this._handleAutoScroll); + } else { + if (this.options.supportPointer) { + on(document, 'pointermove', this._handleFallbackAutoScroll); + } else if (originalEvent.touches) { + on(document, 'touchmove', this._handleFallbackAutoScroll); + } else { + on(document, 'mousemove', this._handleFallbackAutoScroll); + } + } + }, + dragOverCompleted: function dragOverCompleted(_ref2) { + var originalEvent = _ref2.originalEvent; + // For when bubbling is canceled and using fallback (fallback 'touchmove' always reached) + if (!this.options.dragOverBubble && !originalEvent.rootEl) { + this._handleAutoScroll(originalEvent); + } + }, + drop: function drop() { + if (this.sortable.nativeDraggable) { + off(document, 'dragover', this._handleAutoScroll); + } else { + off(document, 'pointermove', this._handleFallbackAutoScroll); + off(document, 'touchmove', this._handleFallbackAutoScroll); + off(document, 'mousemove', this._handleFallbackAutoScroll); + } + clearPointerElemChangedInterval(); + clearAutoScrolls(); + cancelThrottle(); + }, + nulling: function nulling() { + touchEvt$1 = scrollRootEl = scrollEl = scrolling = pointerElemChangedInterval = lastAutoScrollX = lastAutoScrollY = null; + autoScrolls.length = 0; + }, + _handleFallbackAutoScroll: function _handleFallbackAutoScroll(evt) { + this._handleAutoScroll(evt, true); + }, + _handleAutoScroll: function _handleAutoScroll(evt, fallback) { + var _this = this; + var x = (evt.touches ? evt.touches[0] : evt).clientX, + y = (evt.touches ? evt.touches[0] : evt).clientY, + elem = document.elementFromPoint(x, y); + touchEvt$1 = evt; + + // IE does not seem to have native autoscroll, + // Edge's autoscroll seems too conditional, + // MACOS Safari does not have autoscroll, + // Firefox and Chrome are good + if (fallback || this.options.forceAutoScrollFallback || Edge || IE11OrLess || Safari) { + autoScroll(evt, this.options, elem, fallback); + + // Listener for pointer element change + var ogElemScroller = getParentAutoScrollElement(elem, true); + if (scrolling && (!pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY)) { + pointerElemChangedInterval && clearPointerElemChangedInterval(); + // Detect for pointer elem change, emulating native DnD behaviour + pointerElemChangedInterval = setInterval(function () { + var newElem = getParentAutoScrollElement(document.elementFromPoint(x, y), true); + if (newElem !== ogElemScroller) { + ogElemScroller = newElem; + clearAutoScrolls(); + } + autoScroll(evt, _this.options, newElem, fallback); + }, 10); + lastAutoScrollX = x; + lastAutoScrollY = y; + } + } else { + // if DnD is enabled (and browser has good autoscrolling), first autoscroll will already scroll, so get parent autoscroll of first autoscroll + if (!this.options.bubbleScroll || getParentAutoScrollElement(elem, true) === getWindowScrollingElement()) { + clearAutoScrolls(); + return; + } + autoScroll(evt, this.options, getParentAutoScrollElement(elem, false), false); + } + } + }; + return _extends(AutoScroll, { + pluginName: 'scroll', + initializeByDefault: true + }); + } + function clearAutoScrolls() { + autoScrolls.forEach(function (autoScroll) { + clearInterval(autoScroll.pid); + }); + autoScrolls = []; + } + function clearPointerElemChangedInterval() { + clearInterval(pointerElemChangedInterval); + } + var autoScroll = throttle(function (evt, options, rootEl, isFallback) { + // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521 + if (!options.scroll) return; + var x = (evt.touches ? evt.touches[0] : evt).clientX, + y = (evt.touches ? evt.touches[0] : evt).clientY, + sens = options.scrollSensitivity, + speed = options.scrollSpeed, + winScroller = getWindowScrollingElement(); + var scrollThisInstance = false, + scrollCustomFn; + + // New scroll root, set scrollEl + if (scrollRootEl !== rootEl) { + scrollRootEl = rootEl; + clearAutoScrolls(); + scrollEl = options.scroll; + scrollCustomFn = options.scrollFn; + if (scrollEl === true) { + scrollEl = getParentAutoScrollElement(rootEl, true); + } + } + var layersOut = 0; + var currentParent = scrollEl; + do { + var el = currentParent, + rect = getRect(el), + top = rect.top, + bottom = rect.bottom, + left = rect.left, + right = rect.right, + width = rect.width, + height = rect.height, + canScrollX = void 0, + canScrollY = void 0, + scrollWidth = el.scrollWidth, + scrollHeight = el.scrollHeight, + elCSS = css(el), + scrollPosX = el.scrollLeft, + scrollPosY = el.scrollTop; + if (el === winScroller) { + canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll' || elCSS.overflowX === 'visible'); + canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll' || elCSS.overflowY === 'visible'); + } else { + canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll'); + canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll'); + } + var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX); + var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY); + if (!autoScrolls[layersOut]) { + for (var i = 0; i <= layersOut; i++) { + if (!autoScrolls[i]) { + autoScrolls[i] = {}; + } + } + } + if (autoScrolls[layersOut].vx != vx || autoScrolls[layersOut].vy != vy || autoScrolls[layersOut].el !== el) { + autoScrolls[layersOut].el = el; + autoScrolls[layersOut].vx = vx; + autoScrolls[layersOut].vy = vy; + clearInterval(autoScrolls[layersOut].pid); + if (vx != 0 || vy != 0) { + scrollThisInstance = true; + /* jshint loopfunc:true */ + autoScrolls[layersOut].pid = setInterval(function () { + // emulate drag over during autoscroll (fallback), emulating native DnD behaviour + if (isFallback && this.layer === 0) { + Sortable.active._onTouchMove(touchEvt$1); // To move ghost if it is positioned absolutely + } + var scrollOffsetY = autoScrolls[this.layer].vy ? autoScrolls[this.layer].vy * speed : 0; + var scrollOffsetX = autoScrolls[this.layer].vx ? autoScrolls[this.layer].vx * speed : 0; + if (typeof scrollCustomFn === 'function') { + if (scrollCustomFn.call(Sortable.dragged.parentNode[expando], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[this.layer].el) !== 'continue') { + return; + } + } + scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY); + }.bind({ + layer: layersOut + }), 24); + } + } + layersOut++; + } while (options.bubbleScroll && currentParent !== winScroller && (currentParent = getParentAutoScrollElement(currentParent, false))); + scrolling = scrollThisInstance; // in case another function catches scrolling as false in between when it is not + }, 30); + + var drop = function drop(_ref) { + var originalEvent = _ref.originalEvent, + putSortable = _ref.putSortable, + dragEl = _ref.dragEl, + activeSortable = _ref.activeSortable, + dispatchSortableEvent = _ref.dispatchSortableEvent, + hideGhostForTarget = _ref.hideGhostForTarget, + unhideGhostForTarget = _ref.unhideGhostForTarget; + if (!originalEvent) return; + var toSortable = putSortable || activeSortable; + hideGhostForTarget(); + var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent; + var target = document.elementFromPoint(touch.clientX, touch.clientY); + unhideGhostForTarget(); + if (toSortable && !toSortable.el.contains(target)) { + dispatchSortableEvent('spill'); + this.onSpill({ + dragEl: dragEl, + putSortable: putSortable + }); + } + }; + function Revert() {} + Revert.prototype = { + startIndex: null, + dragStart: function dragStart(_ref2) { + var oldDraggableIndex = _ref2.oldDraggableIndex; + this.startIndex = oldDraggableIndex; + }, + onSpill: function onSpill(_ref3) { + var dragEl = _ref3.dragEl, + putSortable = _ref3.putSortable; + this.sortable.captureAnimationState(); + if (putSortable) { + putSortable.captureAnimationState(); + } + var nextSibling = getChild(this.sortable.el, this.startIndex, this.options); + if (nextSibling) { + this.sortable.el.insertBefore(dragEl, nextSibling); + } else { + this.sortable.el.appendChild(dragEl); + } + this.sortable.animateAll(); + if (putSortable) { + putSortable.animateAll(); + } + }, + drop: drop + }; + _extends(Revert, { + pluginName: 'revertOnSpill' + }); + function Remove() {} + Remove.prototype = { + onSpill: function onSpill(_ref4) { + var dragEl = _ref4.dragEl, + putSortable = _ref4.putSortable; + var parentSortable = putSortable || this.sortable; + parentSortable.captureAnimationState(); + dragEl.parentNode && dragEl.parentNode.removeChild(dragEl); + parentSortable.animateAll(); + }, + drop: drop + }; + _extends(Remove, { + pluginName: 'removeOnSpill' + }); + + var lastSwapEl; + function SwapPlugin() { + function Swap() { + this.defaults = { + swapClass: 'sortable-swap-highlight' + }; + } + Swap.prototype = { + dragStart: function dragStart(_ref) { + var dragEl = _ref.dragEl; + lastSwapEl = dragEl; + }, + dragOverValid: function dragOverValid(_ref2) { + var completed = _ref2.completed, + target = _ref2.target, + onMove = _ref2.onMove, + activeSortable = _ref2.activeSortable, + changed = _ref2.changed, + cancel = _ref2.cancel; + if (!activeSortable.options.swap) return; + var el = this.sortable.el, + options = this.options; + if (target && target !== el) { + var prevSwapEl = lastSwapEl; + if (onMove(target) !== false) { + toggleClass(target, options.swapClass, true); + lastSwapEl = target; + } else { + lastSwapEl = null; + } + if (prevSwapEl && prevSwapEl !== lastSwapEl) { + toggleClass(prevSwapEl, options.swapClass, false); + } + } + changed(); + completed(true); + cancel(); + }, + drop: function drop(_ref3) { + var activeSortable = _ref3.activeSortable, + putSortable = _ref3.putSortable, + dragEl = _ref3.dragEl; + var toSortable = putSortable || this.sortable; + var options = this.options; + lastSwapEl && toggleClass(lastSwapEl, options.swapClass, false); + if (lastSwapEl && (options.swap || putSortable && putSortable.options.swap)) { + if (dragEl !== lastSwapEl) { + toSortable.captureAnimationState(); + if (toSortable !== activeSortable) activeSortable.captureAnimationState(); + swapNodes(dragEl, lastSwapEl); + toSortable.animateAll(); + if (toSortable !== activeSortable) activeSortable.animateAll(); + } + } + }, + nulling: function nulling() { + lastSwapEl = null; + } + }; + return _extends(Swap, { + pluginName: 'swap', + eventProperties: function eventProperties() { + return { + swapItem: lastSwapEl + }; + } + }); + } + function swapNodes(n1, n2) { + var p1 = n1.parentNode, + p2 = n2.parentNode, + i1, + i2; + if (!p1 || !p2 || p1.isEqualNode(n2) || p2.isEqualNode(n1)) return; + i1 = index(n1); + i2 = index(n2); + if (p1.isEqualNode(p2) && i1 < i2) { + i2++; + } + p1.insertBefore(n2, p1.children[i1]); + p2.insertBefore(n1, p2.children[i2]); + } + + var multiDragElements = [], + multiDragClones = [], + lastMultiDragSelect, + // for selection with modifier key down (SHIFT) + multiDragSortable, + initialFolding = false, + // Initial multi-drag fold when drag started + folding = false, + // Folding any other time + dragStarted = false, + dragEl$1, + clonesFromRect, + clonesHidden; + function MultiDragPlugin() { + function MultiDrag(sortable) { + // Bind all private methods + for (var fn in this) { + if (fn.charAt(0) === '_' && typeof this[fn] === 'function') { + this[fn] = this[fn].bind(this); + } + } + if (!sortable.options.avoidImplicitDeselect) { + if (sortable.options.supportPointer) { + on(document, 'pointerup', this._deselectMultiDrag); + } else { + on(document, 'mouseup', this._deselectMultiDrag); + on(document, 'touchend', this._deselectMultiDrag); + } + } + on(document, 'keydown', this._checkKeyDown); + on(document, 'keyup', this._checkKeyUp); + this.defaults = { + selectedClass: 'sortable-selected', + multiDragKey: null, + avoidImplicitDeselect: false, + setData: function setData(dataTransfer, dragEl) { + var data = ''; + if (multiDragElements.length && multiDragSortable === sortable) { + multiDragElements.forEach(function (multiDragElement, i) { + data += (!i ? '' : ', ') + multiDragElement.textContent; + }); + } else { + data = dragEl.textContent; + } + dataTransfer.setData('Text', data); + } + }; + } + MultiDrag.prototype = { + multiDragKeyDown: false, + isMultiDrag: false, + delayStartGlobal: function delayStartGlobal(_ref) { + var dragged = _ref.dragEl; + dragEl$1 = dragged; + }, + delayEnded: function delayEnded() { + this.isMultiDrag = ~multiDragElements.indexOf(dragEl$1); + }, + setupClone: function setupClone(_ref2) { + var sortable = _ref2.sortable, + cancel = _ref2.cancel; + if (!this.isMultiDrag) return; + for (var i = 0; i < multiDragElements.length; i++) { + multiDragClones.push(clone(multiDragElements[i])); + multiDragClones[i].sortableIndex = multiDragElements[i].sortableIndex; + multiDragClones[i].draggable = false; + multiDragClones[i].style['will-change'] = ''; + toggleClass(multiDragClones[i], this.options.selectedClass, false); + multiDragElements[i] === dragEl$1 && toggleClass(multiDragClones[i], this.options.chosenClass, false); + } + sortable._hideClone(); + cancel(); + }, + clone: function clone(_ref3) { + var sortable = _ref3.sortable, + rootEl = _ref3.rootEl, + dispatchSortableEvent = _ref3.dispatchSortableEvent, + cancel = _ref3.cancel; + if (!this.isMultiDrag) return; + if (!this.options.removeCloneOnHide) { + if (multiDragElements.length && multiDragSortable === sortable) { + insertMultiDragClones(true, rootEl); + dispatchSortableEvent('clone'); + cancel(); + } + } + }, + showClone: function showClone(_ref4) { + var cloneNowShown = _ref4.cloneNowShown, + rootEl = _ref4.rootEl, + cancel = _ref4.cancel; + if (!this.isMultiDrag) return; + insertMultiDragClones(false, rootEl); + multiDragClones.forEach(function (clone) { + css(clone, 'display', ''); + }); + cloneNowShown(); + clonesHidden = false; + cancel(); + }, + hideClone: function hideClone(_ref5) { + var _this = this; + var sortable = _ref5.sortable, + cloneNowHidden = _ref5.cloneNowHidden, + cancel = _ref5.cancel; + if (!this.isMultiDrag) return; + multiDragClones.forEach(function (clone) { + css(clone, 'display', 'none'); + if (_this.options.removeCloneOnHide && clone.parentNode) { + clone.parentNode.removeChild(clone); + } + }); + cloneNowHidden(); + clonesHidden = true; + cancel(); + }, + dragStartGlobal: function dragStartGlobal(_ref6) { + var sortable = _ref6.sortable; + if (!this.isMultiDrag && multiDragSortable) { + multiDragSortable.multiDrag._deselectMultiDrag(); + } + multiDragElements.forEach(function (multiDragElement) { + multiDragElement.sortableIndex = index(multiDragElement); + }); + + // Sort multi-drag elements + multiDragElements = multiDragElements.sort(function (a, b) { + return a.sortableIndex - b.sortableIndex; + }); + dragStarted = true; + }, + dragStarted: function dragStarted(_ref7) { + var _this2 = this; + var sortable = _ref7.sortable; + if (!this.isMultiDrag) return; + if (this.options.sort) { + // Capture rects, + // hide multi drag elements (by positioning them absolute), + // set multi drag elements rects to dragRect, + // show multi drag elements, + // animate to rects, + // unset rects & remove from DOM + + sortable.captureAnimationState(); + if (this.options.animation) { + multiDragElements.forEach(function (multiDragElement) { + if (multiDragElement === dragEl$1) return; + css(multiDragElement, 'position', 'absolute'); + }); + var dragRect = getRect(dragEl$1, false, true, true); + multiDragElements.forEach(function (multiDragElement) { + if (multiDragElement === dragEl$1) return; + setRect(multiDragElement, dragRect); + }); + folding = true; + initialFolding = true; + } + } + sortable.animateAll(function () { + folding = false; + initialFolding = false; + if (_this2.options.animation) { + multiDragElements.forEach(function (multiDragElement) { + unsetRect(multiDragElement); + }); + } + + // Remove all auxiliary multidrag items from el, if sorting enabled + if (_this2.options.sort) { + removeMultiDragElements(); + } + }); + }, + dragOver: function dragOver(_ref8) { + var target = _ref8.target, + completed = _ref8.completed, + cancel = _ref8.cancel; + if (folding && ~multiDragElements.indexOf(target)) { + completed(false); + cancel(); + } + }, + revert: function revert(_ref9) { + var fromSortable = _ref9.fromSortable, + rootEl = _ref9.rootEl, + sortable = _ref9.sortable, + dragRect = _ref9.dragRect; + if (multiDragElements.length > 1) { + // Setup unfold animation + multiDragElements.forEach(function (multiDragElement) { + sortable.addAnimationState({ + target: multiDragElement, + rect: folding ? getRect(multiDragElement) : dragRect + }); + unsetRect(multiDragElement); + multiDragElement.fromRect = dragRect; + fromSortable.removeAnimationState(multiDragElement); + }); + folding = false; + insertMultiDragElements(!this.options.removeCloneOnHide, rootEl); + } + }, + dragOverCompleted: function dragOverCompleted(_ref10) { + var sortable = _ref10.sortable, + isOwner = _ref10.isOwner, + insertion = _ref10.insertion, + activeSortable = _ref10.activeSortable, + parentEl = _ref10.parentEl, + putSortable = _ref10.putSortable; + var options = this.options; + if (insertion) { + // Clones must be hidden before folding animation to capture dragRectAbsolute properly + if (isOwner) { + activeSortable._hideClone(); + } + initialFolding = false; + // If leaving sort:false root, or already folding - Fold to new location + if (options.animation && multiDragElements.length > 1 && (folding || !isOwner && !activeSortable.options.sort && !putSortable)) { + // Fold: Set all multi drag elements's rects to dragEl's rect when multi-drag elements are invisible + var dragRectAbsolute = getRect(dragEl$1, false, true, true); + multiDragElements.forEach(function (multiDragElement) { + if (multiDragElement === dragEl$1) return; + setRect(multiDragElement, dragRectAbsolute); + + // Move element(s) to end of parentEl so that it does not interfere with multi-drag clones insertion if they are inserted + // while folding, and so that we can capture them again because old sortable will no longer be fromSortable + parentEl.appendChild(multiDragElement); + }); + folding = true; + } + + // Clones must be shown (and check to remove multi drags) after folding when interfering multiDragElements are moved out + if (!isOwner) { + // Only remove if not folding (folding will remove them anyways) + if (!folding) { + removeMultiDragElements(); + } + if (multiDragElements.length > 1) { + var clonesHiddenBefore = clonesHidden; + activeSortable._showClone(sortable); + + // Unfold animation for clones if showing from hidden + if (activeSortable.options.animation && !clonesHidden && clonesHiddenBefore) { + multiDragClones.forEach(function (clone) { + activeSortable.addAnimationState({ + target: clone, + rect: clonesFromRect + }); + clone.fromRect = clonesFromRect; + clone.thisAnimationDuration = null; + }); + } + } else { + activeSortable._showClone(sortable); + } + } + } + }, + dragOverAnimationCapture: function dragOverAnimationCapture(_ref11) { + var dragRect = _ref11.dragRect, + isOwner = _ref11.isOwner, + activeSortable = _ref11.activeSortable; + multiDragElements.forEach(function (multiDragElement) { + multiDragElement.thisAnimationDuration = null; + }); + if (activeSortable.options.animation && !isOwner && activeSortable.multiDrag.isMultiDrag) { + clonesFromRect = _extends({}, dragRect); + var dragMatrix = matrix(dragEl$1, true); + clonesFromRect.top -= dragMatrix.f; + clonesFromRect.left -= dragMatrix.e; + } + }, + dragOverAnimationComplete: function dragOverAnimationComplete() { + if (folding) { + folding = false; + removeMultiDragElements(); + } + }, + drop: function drop(_ref12) { + var evt = _ref12.originalEvent, + rootEl = _ref12.rootEl, + parentEl = _ref12.parentEl, + sortable = _ref12.sortable, + dispatchSortableEvent = _ref12.dispatchSortableEvent, + oldIndex = _ref12.oldIndex, + putSortable = _ref12.putSortable; + var toSortable = putSortable || this.sortable; + if (!evt) return; + var options = this.options, + children = parentEl.children; + + // Multi-drag selection + if (!dragStarted) { + if (options.multiDragKey && !this.multiDragKeyDown) { + this._deselectMultiDrag(); + } + toggleClass(dragEl$1, options.selectedClass, !~multiDragElements.indexOf(dragEl$1)); + if (!~multiDragElements.indexOf(dragEl$1)) { + multiDragElements.push(dragEl$1); + dispatchEvent({ + sortable: sortable, + rootEl: rootEl, + name: 'select', + targetEl: dragEl$1, + originalEvent: evt + }); + + // Modifier activated, select from last to dragEl + if (evt.shiftKey && lastMultiDragSelect && sortable.el.contains(lastMultiDragSelect)) { + var lastIndex = index(lastMultiDragSelect), + currentIndex = index(dragEl$1); + if (~lastIndex && ~currentIndex && lastIndex !== currentIndex) { + // Must include lastMultiDragSelect (select it), in case modified selection from no selection + // (but previous selection existed) + var n, i; + if (currentIndex > lastIndex) { + i = lastIndex; + n = currentIndex; + } else { + i = currentIndex; + n = lastIndex + 1; + } + for (; i < n; i++) { + if (~multiDragElements.indexOf(children[i])) continue; + toggleClass(children[i], options.selectedClass, true); + multiDragElements.push(children[i]); + dispatchEvent({ + sortable: sortable, + rootEl: rootEl, + name: 'select', + targetEl: children[i], + originalEvent: evt + }); + } + } + } else { + lastMultiDragSelect = dragEl$1; + } + multiDragSortable = toSortable; + } else { + multiDragElements.splice(multiDragElements.indexOf(dragEl$1), 1); + lastMultiDragSelect = null; + dispatchEvent({ + sortable: sortable, + rootEl: rootEl, + name: 'deselect', + targetEl: dragEl$1, + originalEvent: evt + }); + } + } + + // Multi-drag drop + if (dragStarted && this.isMultiDrag) { + folding = false; + // Do not "unfold" after around dragEl if reverted + if ((parentEl[expando].options.sort || parentEl !== rootEl) && multiDragElements.length > 1) { + var dragRect = getRect(dragEl$1), + multiDragIndex = index(dragEl$1, ':not(.' + this.options.selectedClass + ')'); + if (!initialFolding && options.animation) dragEl$1.thisAnimationDuration = null; + toSortable.captureAnimationState(); + if (!initialFolding) { + if (options.animation) { + dragEl$1.fromRect = dragRect; + multiDragElements.forEach(function (multiDragElement) { + multiDragElement.thisAnimationDuration = null; + if (multiDragElement !== dragEl$1) { + var rect = folding ? getRect(multiDragElement) : dragRect; + multiDragElement.fromRect = rect; + + // Prepare unfold animation + toSortable.addAnimationState({ + target: multiDragElement, + rect: rect + }); + } + }); + } + + // Multi drag elements are not necessarily removed from the DOM on drop, so to reinsert + // properly they must all be removed + removeMultiDragElements(); + multiDragElements.forEach(function (multiDragElement) { + if (children[multiDragIndex]) { + parentEl.insertBefore(multiDragElement, children[multiDragIndex]); + } else { + parentEl.appendChild(multiDragElement); + } + multiDragIndex++; + }); + + // If initial folding is done, the elements may have changed position because they are now + // unfolding around dragEl, even though dragEl may not have his index changed, so update event + // must be fired here as Sortable will not. + if (oldIndex === index(dragEl$1)) { + var update = false; + multiDragElements.forEach(function (multiDragElement) { + if (multiDragElement.sortableIndex !== index(multiDragElement)) { + update = true; + return; + } + }); + if (update) { + dispatchSortableEvent('update'); + dispatchSortableEvent('sort'); + } + } + } + + // Must be done after capturing individual rects (scroll bar) + multiDragElements.forEach(function (multiDragElement) { + unsetRect(multiDragElement); + }); + toSortable.animateAll(); + } + multiDragSortable = toSortable; + } + + // Remove clones if necessary + if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') { + multiDragClones.forEach(function (clone) { + clone.parentNode && clone.parentNode.removeChild(clone); + }); + } + }, + nullingGlobal: function nullingGlobal() { + this.isMultiDrag = dragStarted = false; + multiDragClones.length = 0; + }, + destroyGlobal: function destroyGlobal() { + this._deselectMultiDrag(); + off(document, 'pointerup', this._deselectMultiDrag); + off(document, 'mouseup', this._deselectMultiDrag); + off(document, 'touchend', this._deselectMultiDrag); + off(document, 'keydown', this._checkKeyDown); + off(document, 'keyup', this._checkKeyUp); + }, + _deselectMultiDrag: function _deselectMultiDrag(evt) { + if (typeof dragStarted !== "undefined" && dragStarted) return; + + // Only deselect if selection is in this sortable + if (multiDragSortable !== this.sortable) return; + + // Only deselect if target is not item in this sortable + if (evt && closest(evt.target, this.options.draggable, this.sortable.el, false)) return; + + // Only deselect if left click + if (evt && evt.button !== 0) return; + while (multiDragElements.length) { + var el = multiDragElements[0]; + toggleClass(el, this.options.selectedClass, false); + multiDragElements.shift(); + dispatchEvent({ + sortable: this.sortable, + rootEl: this.sortable.el, + name: 'deselect', + targetEl: el, + originalEvent: evt + }); + } + }, + _checkKeyDown: function _checkKeyDown(evt) { + if (evt.key === this.options.multiDragKey) { + this.multiDragKeyDown = true; + } + }, + _checkKeyUp: function _checkKeyUp(evt) { + if (evt.key === this.options.multiDragKey) { + this.multiDragKeyDown = false; + } + } + }; + return _extends(MultiDrag, { + // Static methods & properties + pluginName: 'multiDrag', + utils: { + /** + * Selects the provided multi-drag item + * @param {HTMLElement} el The element to be selected + */ + select: function select(el) { + var sortable = el.parentNode[expando]; + if (!sortable || !sortable.options.multiDrag || ~multiDragElements.indexOf(el)) return; + if (multiDragSortable && multiDragSortable !== sortable) { + multiDragSortable.multiDrag._deselectMultiDrag(); + multiDragSortable = sortable; + } + toggleClass(el, sortable.options.selectedClass, true); + multiDragElements.push(el); + }, + /** + * Deselects the provided multi-drag item + * @param {HTMLElement} el The element to be deselected + */ + deselect: function deselect(el) { + var sortable = el.parentNode[expando], + index = multiDragElements.indexOf(el); + if (!sortable || !sortable.options.multiDrag || !~index) return; + toggleClass(el, sortable.options.selectedClass, false); + multiDragElements.splice(index, 1); + } + }, + eventProperties: function eventProperties() { + var _this3 = this; + var oldIndicies = [], + newIndicies = []; + multiDragElements.forEach(function (multiDragElement) { + oldIndicies.push({ + multiDragElement: multiDragElement, + index: multiDragElement.sortableIndex + }); + + // multiDragElements will already be sorted if folding + var newIndex; + if (folding && multiDragElement !== dragEl$1) { + newIndex = -1; + } else if (folding) { + newIndex = index(multiDragElement, ':not(.' + _this3.options.selectedClass + ')'); + } else { + newIndex = index(multiDragElement); + } + newIndicies.push({ + multiDragElement: multiDragElement, + index: newIndex + }); + }); + return { + items: _toConsumableArray(multiDragElements), + clones: [].concat(multiDragClones), + oldIndicies: oldIndicies, + newIndicies: newIndicies + }; + }, + optionListeners: { + multiDragKey: function multiDragKey(key) { + key = key.toLowerCase(); + if (key === 'ctrl') { + key = 'Control'; + } else if (key.length > 1) { + key = key.charAt(0).toUpperCase() + key.substr(1); + } + return key; + } + } + }); + } + function insertMultiDragElements(clonesInserted, rootEl) { + multiDragElements.forEach(function (multiDragElement, i) { + var target = rootEl.children[multiDragElement.sortableIndex + (clonesInserted ? Number(i) : 0)]; + if (target) { + rootEl.insertBefore(multiDragElement, target); + } else { + rootEl.appendChild(multiDragElement); + } + }); + } + + /** + * Insert multi-drag clones + * @param {[Boolean]} elementsInserted Whether the multi-drag elements are inserted + * @param {HTMLElement} rootEl + */ + function insertMultiDragClones(elementsInserted, rootEl) { + multiDragClones.forEach(function (clone, i) { + var target = rootEl.children[clone.sortableIndex + (elementsInserted ? Number(i) : 0)]; + if (target) { + rootEl.insertBefore(clone, target); + } else { + rootEl.appendChild(clone); + } + }); + } + function removeMultiDragElements() { + multiDragElements.forEach(function (multiDragElement) { + if (multiDragElement === dragEl$1) return; + multiDragElement.parentNode && multiDragElement.parentNode.removeChild(multiDragElement); + }); + } + + Sortable.mount(new AutoScrollPlugin()); + Sortable.mount(Remove, Revert); + + Sortable.mount(new SwapPlugin()); + Sortable.mount(new MultiDragPlugin()); + + return Sortable; + +}))); diff --git a/deploy/campsite_type.sql b/deploy/campsite_type.sql index 47073c5..0c9124e 100644 --- a/deploy/campsite_type.sql +++ b/deploy/campsite_type.sql @@ -21,7 +21,8 @@ create table campsite_type ( description xml not null default ''::xml, max_campers integer not null constraint at_least_one_camper check(max_campers > 0), dogs_allowed boolean not null, - active boolean not null default true + active boolean not null default true, + position integer not null default 2147483647 ); grant select on table campsite_type to guest; diff --git a/deploy/campsite_type_carousel.sql b/deploy/campsite_type_carousel.sql index 4038db7..3474f45 100644 --- a/deploy/campsite_type_carousel.sql +++ b/deploy/campsite_type_carousel.sql @@ -13,6 +13,7 @@ create table campsite_type_carousel ( campsite_type_id integer not null references campsite_type, media_id integer not null references media, caption text not null, + position integer not null default 2147483647, primary key (campsite_type_id, media_id) ); diff --git a/deploy/campsite_type_option.sql b/deploy/campsite_type_option.sql index e3811eb..08f4225 100644 --- a/deploy/campsite_type_option.sql +++ b/deploy/campsite_type_option.sql @@ -12,7 +12,8 @@ create table campsite_type_option ( campsite_type_option_id integer generated by default as identity primary key, campsite_type_id integer not null references campsite_type, name text not null constraint name_not_empty check(length(trim(name)) > 0), - range int4range not null constraint range_not_negative check(lower(range) >= 0) + range int4range not null constraint range_not_negative check(lower(range) >= 0), + position integer not null default 2147483647 ); alter table campsite_type_option enable row level security; diff --git a/deploy/home_carousel.sql b/deploy/home_carousel.sql index 550c2d0..76d1155 100644 --- a/deploy/home_carousel.sql +++ b/deploy/home_carousel.sql @@ -11,7 +11,8 @@ set search_path to camper, public; create table home_carousel ( media_id integer not null references media primary key, - caption text not null + caption text not null, + position integer not null default 2147483647 ); grant select on table home_carousel to guest; diff --git a/deploy/order_campsite_type_carousel.sql b/deploy/order_campsite_type_carousel.sql new file mode 100644 index 0000000..3bb41bf --- /dev/null +++ b/deploy/order_campsite_type_carousel.sql @@ -0,0 +1,27 @@ +-- Deploy camper:order_campsite_type_carousel to pg +-- requires: schema_camper +-- requires: roles +-- requires: campsite_type +-- requires: campsite_type_carousel + +begin; + +set search_path to camper, public; + +create or replace function order_campsite_type_carousel(slug uuid, positions integer[]) returns void as +$$ + update campsite_type_carousel + set position = cast(temp.position as integer) + from unnest(positions) with ordinality as temp(media_id, position) + join campsite_type on campsite_type.slug = order_campsite_type_carousel.slug + where campsite_type_carousel.campsite_type_id = campsite_type.campsite_type_id + and campsite_type_carousel.media_id = temp.media_id + ; +$$ + language sql +; + +revoke execute on function order_campsite_type_carousel(uuid, integer[]) from public; +grant execute on function order_campsite_type_carousel(uuid, integer[]) to admin; + +commit; diff --git a/deploy/order_campsite_type_options.sql b/deploy/order_campsite_type_options.sql new file mode 100644 index 0000000..002b597 --- /dev/null +++ b/deploy/order_campsite_type_options.sql @@ -0,0 +1,24 @@ +-- Deploy camper:order_campsite_type_options to pg +-- requires: schema_camper +-- requires: roles +-- requires: campsite_type_option + +begin; + +set search_path to camper, public; + +create or replace function order_campsite_type_options(positions integer[]) returns void as +$$ + update campsite_type_option + set position = cast(temp.position as integer) + from unnest(positions) with ordinality as temp(option_id, position) + where campsite_type_option_id = temp.option_id + ; +$$ + language sql +; + +revoke execute on function order_campsite_type_options(integer[]) from public; +grant execute on function order_campsite_type_options(integer[]) to admin; + +commit; diff --git a/deploy/order_campsite_types.sql b/deploy/order_campsite_types.sql new file mode 100644 index 0000000..54ce307 --- /dev/null +++ b/deploy/order_campsite_types.sql @@ -0,0 +1,24 @@ +-- Deploy camper:order_campsite_types to pg +-- requires: schema_camper +-- requires: roles +-- requires: campsite_type + +begin; + +set search_path to camper, public; + +create or replace function order_campsite_types(positions uuid[]) returns void as +$$ + update campsite_type + set position = cast(temp.position as integer) + from unnest(positions) with ordinality as temp(slug, position) + where campsite_type.slug = temp.slug + ; +$$ + language sql +; + +revoke execute on function order_campsite_types(uuid[]) from public; +grant execute on function order_campsite_types(uuid[]) to admin; + +commit; diff --git a/deploy/order_home_carousel.sql b/deploy/order_home_carousel.sql new file mode 100644 index 0000000..f7f2e7e --- /dev/null +++ b/deploy/order_home_carousel.sql @@ -0,0 +1,24 @@ +-- Deploy camper:order_home_carousel to pg +-- requires: schema_camper +-- requires: roles +-- requires: home_carousel + +begin; + +set search_path to camper, public; + +create or replace function order_home_carousel(positions integer[]) returns void as +$$ + update home_carousel + set position = cast(temp.position as integer) + from unnest(positions) with ordinality as temp(media_id, position) + where home_carousel.media_id = temp.media_id + ; +$$ + language sql +; + +revoke execute on function order_home_carousel(integer[]) from public; +grant execute on function order_home_carousel(integer[]) to admin; + +commit; diff --git a/deploy/order_seasons.sql b/deploy/order_seasons.sql new file mode 100644 index 0000000..4fd2998 --- /dev/null +++ b/deploy/order_seasons.sql @@ -0,0 +1,24 @@ +-- Deploy camper:order_seasons to pg +-- requires: schema_camper +-- requires: roles +-- requires: season + +begin; + +set search_path to camper, public; + +create or replace function order_seasons(positions uuid[]) returns void as +$$ + update season + set position = cast(temp.position as integer) + from unnest(positions) with ordinality as temp(slug, position) + where season.slug = temp.slug + ; +$$ + language sql +; + +revoke execute on function order_seasons(uuid[]) from public; +grant execute on function order_seasons(uuid[]) to admin; + +commit; diff --git a/deploy/order_services_carousel.sql b/deploy/order_services_carousel.sql new file mode 100644 index 0000000..d8f0d6d --- /dev/null +++ b/deploy/order_services_carousel.sql @@ -0,0 +1,24 @@ +-- Deploy camper:order_services_carousel to pg +-- requires: schema_camper +-- requires: roles +-- requires: services_carousel + +begin; + +set search_path to camper, public; + +create or replace function order_services_carousel(positions integer[]) returns void as +$$ + update services_carousel + set position = cast(temp.position as integer) + from unnest(positions) with ordinality as temp(media_id, position) + where services_carousel.media_id = temp.media_id + ; +$$ + language sql +; + +revoke execute on function order_services_carousel(integer[]) from public; +grant execute on function order_services_carousel(integer[]) to admin; + +commit; diff --git a/deploy/season.sql b/deploy/season.sql index 346a739..884dac6 100644 --- a/deploy/season.sql +++ b/deploy/season.sql @@ -14,7 +14,8 @@ create table season ( slug uuid not null unique default gen_random_uuid(), name text not null constraint name_not_empty check(length(trim(name)) > 0), color integer not null default 0, - active boolean not null default true + active boolean not null default true, + position integer not null default 2147483647 ); grant select on table season to guest; diff --git a/deploy/services_carousel.sql b/deploy/services_carousel.sql index 8e54994..ab90e52 100644 --- a/deploy/services_carousel.sql +++ b/deploy/services_carousel.sql @@ -11,7 +11,8 @@ set search_path to camper, public; create table services_carousel ( media_id integer not null primary key references media, - caption text not null + caption text not null, + position integer not null default 2147483647 ); grant select on table services_carousel to guest; diff --git a/pkg/booking/public.go b/pkg/booking/public.go index db884ec..a5dc9c0 100644 --- a/pkg/booking/public.go +++ b/pkg/booking/public.go @@ -174,7 +174,7 @@ func newBookingForm(ctx context.Context, company *auth.Company, conn *database.C }, CampsiteType: &form.Select{ Name: "campsite_type", - Options: form.MustGetOptions(ctx, conn, "select type.slug, coalesce(i18n.name, type.name) as l10n_name from campsite_type as type left join campsite_type_i18n as i18n on type.campsite_type_id = i18n.campsite_type_id and i18n.lang_tag = $1 where company_id = $2 order by l10n_name", l.Language, company.ID), + Options: form.MustGetOptions(ctx, conn, "select type.slug, coalesce(i18n.name, type.name) as l10n_name from campsite_type as type left join campsite_type_i18n as i18n on type.campsite_type_id = i18n.campsite_type_id and i18n.lang_tag = $1 where company_id = $2 order by position, l10n_name", l.Language, company.ID), }, CampsiteTypeOptions: make(map[string][]*campsiteTypeOption), ArrivalDate: &form.Input{ @@ -204,6 +204,7 @@ func newBookingForm(ctx context.Context, company *auth.Company, conn *database.C join campsite_type using (campsite_type_id) left join campsite_type_option_i18n as i18n on i18n.campsite_type_option_id = option.campsite_type_id and i18n.lang_tag = $1 where company_id = $2 + order by option.position, l10_name `, l.Language, company.ID) if err != nil { panic(err) diff --git a/pkg/campsite/types/admin.go b/pkg/campsite/types/admin.go index 5f98db2..99653c8 100644 --- a/pkg/campsite/types/admin.go +++ b/pkg/campsite/types/admin.go @@ -55,6 +55,13 @@ func (h *AdminHandler) Handler(user *auth.User, company *auth.Company, conn *dat default: httplib.MethodNotAllowed(w, r, http.MethodGet, http.MethodPost) } + case "order": + switch r.Method { + case http.MethodPost: + orderTypes(w, r, user, company, conn) + default: + httplib.MethodNotAllowed(w, r, http.MethodPost) + } default: if !uuid.Valid(head) { http.NotFound(w, r) @@ -157,8 +164,9 @@ func collectTypeEntries(ctx context.Context, company *auth.Company, conn *databa and campsite_type.company_id = $1 group by campsite_type.slug , campsite_type.name + , campsite_type.position , campsite_type.active - order by name + order by position, name `, pgx.QueryResultFormats{pgx.BinaryFormatCode}, company.ID) if err != nil { return nil, err @@ -225,6 +233,30 @@ func editType(w http.ResponseWriter, r *http.Request, user *auth.User, company * }) } +func orderTypes(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company, conn *database.Conn) { + if err := r.ParseForm(); err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + if err := user.VerifyCSRFToken(r); err != nil { + http.Error(w, err.Error(), http.StatusForbidden) + return + } + slugs := r.PostForm["slug"] + if len(slugs) > 0 { + for _, slug := range slugs { + if !uuid.Valid(slug) { + w.WriteHeader(http.StatusUnprocessableEntity) + return + } + } + if err := conn.OrderCampsiteTypes(r.Context(), slugs); err != nil { + panic(err) + } + } + serveTypeIndex(w, r, user, company, conn) +} + func processTypeForm(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company, conn *database.Conn, f *typeForm, act func(ctx context.Context, tx *database.Tx) error) { if err := f.Parse(r); err != nil { http.Error(w, err.Error(), http.StatusBadRequest) diff --git a/pkg/campsite/types/carousel.go b/pkg/campsite/types/carousel.go index 401d9d1..81d8a6b 100644 --- a/pkg/campsite/types/carousel.go +++ b/pkg/campsite/types/carousel.go @@ -44,10 +44,18 @@ func (h *AdminHandler) carouselHandler(user *auth.User, company *auth.Company, c default: httplib.MethodNotAllowed(w, r, http.MethodGet) } + case "order": + switch r.Method { + case http.MethodPost: + orderCarousel(w, r, user, company, conn, typeSlug) + default: + httplib.MethodNotAllowed(w, r, http.MethodGet) + } default: mediaID, err := strconv.Atoi(head) if err != nil { http.NotFound(w, r) + return } f := newSlideForm(typeSlug) if err := f.FillFromDatabase(r.Context(), conn, mediaID); err != nil { @@ -129,6 +137,7 @@ func mustCollectSlides(ctx context.Context, conn *database.Conn, loc *locale.Loc and i18n.media_id = slide.media_id and lang_tag = $1 where campsite_type.slug = $2 + order by slide.position, l10_caption `, loc.Language, typeSlug) if err != nil { panic(err) @@ -166,9 +175,10 @@ func collectSlideEntries(ctx context.Context, conn *database.Conn, typeSlug stri and language.selectable and campsite_type.slug = $1 group by carousel.media_id + , carousel.position , media.path , caption - order by caption + order by carousel.position, caption `, pgx.QueryResultFormats{pgx.BinaryFormatCode}, typeSlug) if err != nil { return nil, err @@ -295,3 +305,30 @@ func (f *slideForm) Valid(ctx context.Context, conn *database.Conn, l *locale.Lo func (f *slideForm) MustRender(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company) { template.MustRenderAdmin(w, r, user, company, "campsite/carousel/form.gohtml", f) } + +func orderCarousel(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company, conn *database.Conn, typeSlug string) { + if err := r.ParseForm(); err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + if err := user.VerifyCSRFToken(r); err != nil { + http.Error(w, err.Error(), http.StatusForbidden) + return + } + input := r.PostForm["media_id"] + if len(input) > 0 { + var ids []int + for _, s := range input { + if id, err := strconv.Atoi(s); err == nil { + ids = append(ids, id) + } else { + http.Error(w, err.Error(), http.StatusUnprocessableEntity) + return + } + } + if err := conn.OrderCampsiteTypeCarousel(r.Context(), typeSlug, ids); err != nil { + panic(err) + } + } + serveCarouselIndex(w, r, user, company, conn, typeSlug) +} diff --git a/pkg/campsite/types/option.go b/pkg/campsite/types/option.go index 886e352..a305fe5 100644 --- a/pkg/campsite/types/option.go +++ b/pkg/campsite/types/option.go @@ -47,6 +47,13 @@ func (h *AdminHandler) optionsHandler(user *auth.User, company *auth.Company, co default: httplib.MethodNotAllowed(w, r, http.MethodGet) } + case "order": + switch r.Method { + case http.MethodPost: + orderOptions(w, r, user, company, conn, typeSlug) + default: + httplib.MethodNotAllowed(w, r, http.MethodPost) + } default: id, err := strconv.Atoi(head) if err != nil { @@ -120,7 +127,8 @@ func serveOptionIndex(w http.ResponseWriter, r *http.Request, user *auth.User, c func collectOptionEntries(ctx context.Context, conn *database.Conn, typeSlug string) ([]*optionEntry, error) { rows, err := conn.Query(ctx, ` - select '/admin/campsites/types/' || campsite_type.slug || '/options/' || campsite_type_option_id + select campsite_type_option_id + , '/admin/campsites/types/' || campsite_type.slug || '/options/' || campsite_type_option_id , option.name , array_agg((lang_tag, endonym, not exists (select 1 from campsite_type_option_i18n as i18n where i18n.campsite_type_option_id = option.campsite_type_option_id and i18n.lang_tag = language.lang_tag)) order by endonym) from campsite_type_option as option @@ -132,8 +140,9 @@ func collectOptionEntries(ctx context.Context, conn *database.Conn, typeSlug str and campsite_type.slug = $1 group by campsite_type_option_id , campsite_type.slug + , option.position , option.name - order by name + order by option.position, option.name `, pgx.QueryResultFormats{pgx.BinaryFormatCode}, typeSlug) if err != nil { return nil, err @@ -144,7 +153,7 @@ func collectOptionEntries(ctx context.Context, conn *database.Conn, typeSlug str for rows.Next() { option := &optionEntry{} var translations database.RecordArray - if err = rows.Scan(&option.URL, &option.Name, &translations); err != nil { + if err = rows.Scan(&option.ID, &option.URL, &option.Name, &translations); err != nil { return nil, err } for _, el := range translations.Elements { @@ -161,6 +170,7 @@ func collectOptionEntries(ctx context.Context, conn *database.Conn, typeSlug str } type optionEntry struct { + ID int URL string Name string Translations []*locale.Translation @@ -366,3 +376,30 @@ func (f *optionForm) Valid(l *locale.Locale) bool { func (f *optionForm) MustRender(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company) { template.MustRenderAdmin(w, r, user, company, "campsite/option/form.gohtml", f) } + +func orderOptions(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company, conn *database.Conn, typeSlug string) { + if err := r.ParseForm(); err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + if err := user.VerifyCSRFToken(r); err != nil { + http.Error(w, err.Error(), http.StatusForbidden) + return + } + input := r.PostForm["option_id"] + if len(input) > 0 { + var ids []int + for _, s := range input { + if id, err := strconv.Atoi(s); err == nil { + ids = append(ids, id) + } else { + http.Error(w, err.Error(), http.StatusUnprocessableEntity) + return + } + } + if err := conn.OrderCampsiteTypeOptions(r.Context(), ids); err != nil { + panic(err) + } + } + serveOptionIndex(w, r, user, company, conn, typeSlug) +} diff --git a/pkg/campsite/types/public.go b/pkg/campsite/types/public.go index b536769..2f84bdd 100644 --- a/pkg/campsite/types/public.go +++ b/pkg/campsite/types/public.go @@ -133,6 +133,7 @@ func collectPrices(ctx context.Context, conn *database.Conn, language language.T , coalesce(cost.min_nights, 1) , to_price(coalesce(cost.cost_per_night, 0) + coalesce(option.cost_per_night, 0)) , option.cost_per_night is not null + , season.position from season left join season_i18n as i18n on season.season_id = i18n.season_id and i18n.lang_tag = $1 left join ( @@ -154,6 +155,8 @@ func collectPrices(ctx context.Context, conn *database.Conn, language language.T , 1 , '' , false + , 2147483647 as position + order by position, l10n_name `, language, slug, locale.PgettextNoop("Closed", "season"), season.UnsetColor) if err != nil { return nil, err @@ -162,7 +165,8 @@ func collectPrices(ctx context.Context, conn *database.Conn, language language.T var prices []*typePrice for rows.Next() { price := &typePrice{} - if err := rows.Scan(&price.SeasonName, &price.SeasonColor, &price.MinNights, &price.PricePerNight, &price.HasOptions); err != nil { + var position int + if err := rows.Scan(&price.SeasonName, &price.SeasonColor, &price.MinNights, &price.PricePerNight, &price.HasOptions, &position); err != nil { return nil, err } prices = append(prices, price) diff --git a/pkg/carousel/admin.go b/pkg/carousel/admin.go index b49616c..687e1d2 100644 --- a/pkg/carousel/admin.go +++ b/pkg/carousel/admin.go @@ -22,14 +22,18 @@ import ( ) type AdminHandler struct { - name string - locales locale.Locales + name string + indexHandler IndexHandler + locales locale.Locales } -func NewAdminHandler(name string, locales locale.Locales) *AdminHandler { +type IndexHandler func(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company, conn *database.Conn) + +func NewAdminHandler(name string, indexHandler IndexHandler, locales locale.Locales) *AdminHandler { return &AdminHandler{ - name: name, - locales: locales, + name: name, + indexHandler: indexHandler, + locales: locales, } } @@ -54,10 +58,18 @@ func (h *AdminHandler) Handler(user *auth.User, company *auth.Company, conn *dat default: httplib.MethodNotAllowed(w, r, http.MethodGet) } + case "order": + switch r.Method { + case http.MethodPost: + h.orderSlides(w, r, user, company, conn) + default: + httplib.MethodNotAllowed(w, r, http.MethodPost) + } default: id, err := strconv.Atoi(head) if err != nil { http.NotFound(w, r) + return } f := newSlideForm(h.name) if err := f.FillFromDatabase(r.Context(), conn, id); err != nil { @@ -106,6 +118,33 @@ func (h *AdminHandler) Handler(user *auth.User, company *auth.Company, conn *dat }) } +func (h *AdminHandler) orderSlides(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company, conn *database.Conn) { + if err := r.ParseForm(); err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + if err := user.VerifyCSRFToken(r); err != nil { + http.Error(w, err.Error(), http.StatusForbidden) + return + } + input := r.PostForm["media_id"] + if len(input) > 0 { + var ids []int + for _, s := range input { + if id, err := strconv.Atoi(s); err == nil { + ids = append(ids, id) + } else { + http.Error(w, err.Error(), http.StatusUnprocessableEntity) + return + } + } + if _, err := conn.Exec(r.Context(), fmt.Sprintf("select order_%[1]s_carousel($1)", h.name), ids); err != nil { + panic(err) + } + } + h.indexHandler(w, r, user, company, conn) +} + type Slide struct { Media string Caption string @@ -119,6 +158,7 @@ func MustCollectSlides(ctx context.Context, company *auth.Company, conn *databas join media using (media_id) left join %[1]s_carousel_i18n as i18n on i18n.media_id = slide.media_id and lang_tag = $1 where media.company_id = $2 + order by slide.position, l10_caption `, carouselName), loc.Language, company.ID) if err != nil { panic(err) @@ -168,8 +208,9 @@ func CollectSlideEntries(ctx context.Context, company *auth.Company, conn *datab and media.company_id = $1 group by media_id , media.path + , position , caption - order by caption + order by position, caption `, carouselName), pgx.QueryResultFormats{pgx.BinaryFormatCode}, company.ID) if err != nil { return nil, err diff --git a/pkg/database/funcs.go b/pkg/database/funcs.go index 015225d..d2ef2dd 100644 --- a/pkg/database/funcs.go +++ b/pkg/database/funcs.go @@ -19,6 +19,11 @@ func (tx *Tx) EditCampsiteType(ctx context.Context, slug string, mediaID int, na return tx.GetText(ctx, "select edit_campsite_type($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)", slug, mediaID, name, spiel, info, facilities, description, maxCampers, dogsAllowed, active) } +func (c *Conn) OrderCampsiteTypes(ctx context.Context, slugs []string) error { + _, err := c.Exec(ctx, "select order_campsite_types($1)", slugs) + return err +} + func (c *Conn) TranslateCampsiteType(ctx context.Context, slug string, langTag language.Tag, name string, spiel string, info string, facilities string, description string) error { _, err := c.Exec(ctx, "select translate_campsite_type($1, $2, $3, $4, $5, $6, $7)", slug, langTag, name, spiel, info, facilities, description) return err @@ -46,6 +51,16 @@ func (c *Conn) TranslateCampsiteTypeOption(ctx context.Context, id int, langTag return err } +func (c *Conn) OrderCampsiteTypeOptions(ctx context.Context, ids []int) error { + _, err := c.Exec(ctx, "select order_campsite_type_options($1)", ids) + return err +} + +func (c *Conn) OrderCampsiteTypeCarousel(ctx context.Context, typeSlug string, media_ids []int) error { + _, err := c.Exec(ctx, "select order_campsite_type_carousel($1, $2)", typeSlug, media_ids) + return err +} + func (c *Conn) AddCampsiteTypeFeature(ctx context.Context, typeSlug string, iconName string, name string) (int, error) { return c.GetInt(ctx, "select add_campsite_type_feature($1, $2, $3)", typeSlug, iconName, name) } @@ -67,3 +82,8 @@ func (c *Conn) SetupRedsys(ctx context.Context, companyID int, merchantCode stri _, err := c.Exec(ctx, "select setup_redsys($1, $2, $3, $4, $5, $6)", companyID, merchantCode, terminalNumber, environment, integration, encryptKeyParam) return err } + +func (c *Conn) OrderSeasons(ctx context.Context, slugs []string) error { + _, err := c.Exec(ctx, "select order_seasons($1)", slugs) + return err +} diff --git a/pkg/home/admin.go b/pkg/home/admin.go index a65381f..ffd5c80 100644 --- a/pkg/home/admin.go +++ b/pkg/home/admin.go @@ -26,7 +26,7 @@ type AdminHandler struct { func NewAdminHandler(locales locale.Locales) *AdminHandler { return &AdminHandler{ locales: locales, - carousel: carousel.NewAdminHandler(carouselName, locales), + carousel: carousel.NewAdminHandler(carouselName, serveHomeIndex, locales), } } diff --git a/pkg/home/public.go b/pkg/home/public.go index a14e7bc..347a3b9 100644 --- a/pkg/home/public.go +++ b/pkg/home/public.go @@ -69,6 +69,7 @@ func mustCollectCampsiteTypes(ctx context.Context, company *auth.Company, conn * join media using (media_id) where campsite_type.company_id = $2 and campsite_type.active + order by position, l10_name `, loc.Language, company.ID) if err != nil { panic(err) diff --git a/pkg/season/admin.go b/pkg/season/admin.go index 26c276e..a968858 100644 --- a/pkg/season/admin.go +++ b/pkg/season/admin.go @@ -61,6 +61,13 @@ func (h *AdminHandler) Handler(user *auth.User, company *auth.Company, conn *dat default: httplib.MethodNotAllowed(w, r, http.MethodGet) } + case "order": + switch r.Method { + case http.MethodPost: + orderSeasons(w, r, user, company, conn) + default: + httplib.MethodNotAllowed(w, r, http.MethodPost) + } case "range": switch r.Method { case http.MethodGet: @@ -158,7 +165,8 @@ func GetCalendarMonth(query url.Values) time.Month { func collectSeasonEntries(ctx context.Context, company *auth.Company, conn *database.Conn) ([]*seasonEntry, error) { rows, err := conn.Query(ctx, ` - select '/admin/seasons/' || season.slug + select season.slug + , '/admin/seasons/' || season.slug , season.name , to_color(color)::text , active @@ -170,10 +178,11 @@ func collectSeasonEntries(ctx context.Context, company *auth.Company, conn *data and language.selectable and season.company_id = $1 group by season.slug + , season.position , season.name , to_color(color)::text , active - order by name`, pgx.QueryResultFormats{pgx.BinaryFormatCode}, company.ID) + order by position, name`, pgx.QueryResultFormats{pgx.BinaryFormatCode}, company.ID) if err != nil { return nil, err } @@ -183,7 +192,7 @@ func collectSeasonEntries(ctx context.Context, company *auth.Company, conn *data for rows.Next() { entry := &seasonEntry{} var translations database.RecordArray - if err = rows.Scan(&entry.URL, &entry.Name, &entry.Color, &entry.Active, &translations); err != nil { + if err = rows.Scan(&entry.Slug, &entry.URL, &entry.Name, &entry.Color, &entry.Active, &translations); err != nil { return nil, err } for _, el := range translations.Elements { @@ -201,6 +210,7 @@ func collectSeasonEntries(ctx context.Context, company *auth.Company, conn *data type seasonEntry struct { ID int + Slug string URL string Name string Color string @@ -404,6 +414,30 @@ func (f *seasonForm) MustRender(w http.ResponseWriter, r *http.Request, user *au template.MustRenderAdmin(w, r, user, company, "season/form.gohtml", f) } +func orderSeasons(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company, conn *database.Conn) { + if err := r.ParseForm(); err != nil { + http.Error(w, err.Error(), http.StatusBadRequest) + return + } + if err := user.VerifyCSRFToken(r); err != nil { + http.Error(w, err.Error(), http.StatusForbidden) + return + } + slugs := r.PostForm["slug"] + if len(slugs) > 0 { + for _, slug := range slugs { + if !uuid.Valid(slug) { + w.WriteHeader(http.StatusUnprocessableEntity) + return + } + } + if err := conn.OrderSeasons(r.Context(), slugs); err != nil { + panic(err) + } + } + serveSeasonIndex(w, r, user, company, conn) +} + func serveSeasonCalendar(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company, conn *database.Conn) { f := newCalendarForm(r.Context(), company, conn) f.MustRender(w, r, user, company, conn, GetCalendarYear(r.URL.Query())) @@ -459,17 +493,17 @@ func mustCollectCalendarSeasons(ctx context.Context, company *auth.Company, conn , $1 as name , to_color($2)::text , true - , 0 as sort + , 0 as position union all select season_id , name , to_color(color)::text , active - , 1 as sort + , position from season where company_id = $3 and active - order by sort, name`, locale.PgettextNoop("Unset", "action"), UnsetColor, company.ID) + order by position, name`, locale.PgettextNoop("Unset", "action"), UnsetColor, company.ID) if err != nil { panic(err) } diff --git a/pkg/services/admin.go b/pkg/services/admin.go index 1ed4d79..0cdbfcb 100644 --- a/pkg/services/admin.go +++ b/pkg/services/admin.go @@ -31,7 +31,7 @@ type AdminHandler struct { func NewAdminHandler(locales locale.Locales) *AdminHandler { return &AdminHandler{ locales: locales, - carousel: carousel.NewAdminHandler(carouselName, locales), + carousel: carousel.NewAdminHandler(carouselName, serveServicesIndex, locales), } } @@ -44,7 +44,7 @@ func (h *AdminHandler) Handler(user *auth.User, company *auth.Company, conn *dat case "": switch r.Method { case http.MethodGet: - serveHomeIndex(w, r, user, company, conn) + serveServicesIndex(w, r, user, company, conn) case http.MethodPost: addService(w, r, user, company, conn) default: @@ -113,7 +113,7 @@ func (h *AdminHandler) Handler(user *auth.User, company *auth.Company, conn *dat }) } -func serveHomeIndex(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company, conn *database.Conn) { +func serveServicesIndex(w http.ResponseWriter, r *http.Request, user *auth.User, company *auth.Company, conn *database.Conn) { slides, err := carousel.CollectSlideEntries(r.Context(), company, conn, carouselName) if err != nil { panic(err) diff --git a/pkg/template/page.go b/pkg/template/page.go index a52f581..fa2896c 100644 --- a/pkg/template/page.go +++ b/pkg/template/page.go @@ -50,6 +50,7 @@ func (p *PublicPage) Setup(r *http.Request, user *auth.User, company *auth.Compa left join campsite_type_i18n as i18n on campsite_type.campsite_type_id = i18n.campsite_type_id and i18n.lang_tag = $1 where company_id = $2 and active + order by position, l10n_name `, user.Locale.Language, company.ID), } diff --git a/po/ca.po b/po/ca.po index d864d2a..e0c5faf 100644 --- a/po/ca.po +++ b/po/ca.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: camper\n" "Report-Msgid-Bugs-To: jordi@tandem.blog\n" -"POT-Creation-Date: 2023-12-13 23:44+0100\n" +"POT-Creation-Date: 2023-12-20 19:48+0100\n" "PO-Revision-Date: 2023-07-22 23:45+0200\n" "Last-Translator: jordi fita mas \n" "Language-Team: Catalan \n" @@ -44,7 +44,7 @@ msgstr "Ha fallat el pagament" #: web/templates/public/services.gohtml:6 #: web/templates/public/services.gohtml:15 #: web/templates/public/layout.gohtml:44 web/templates/public/layout.gohtml:71 -#: web/templates/admin/services/index.gohtml:53 +#: web/templates/admin/services/index.gohtml:66 msgctxt "title" msgid "Services" msgstr "Serveis" @@ -136,7 +136,7 @@ msgid "*Minimum %d nights per stay" msgstr "*Mínim %d nits per estada" #: web/templates/public/campsite/type.gohtml:89 -#: web/templates/admin/season/index.gohtml:48 +#: web/templates/admin/season/index.gohtml:59 msgctxt "title" msgid "Calendar" msgstr "Calendari" @@ -203,61 +203,61 @@ msgctxt "day" msgid "Sun" msgstr "dg" -#: web/templates/public/surroundings.gohtml:13 +#: web/templates/public/surroundings.gohtml:28 msgctxt "title" msgid "What to Do Outside the Campsite?" msgstr "Què fer des del càmping?" -#: web/templates/public/surroundings.gohtml:15 +#: web/templates/public/surroundings.gohtml:31 msgid "Campsite Montagut is an ideal starting point for quiet outings, climbing, swimming in the river and gorges, volcanoes, the Fageda d’en Jordà, cycle tours for all ages…." msgstr "El Càmping Montagut és ideal com a punt de partida d’excursions tranquil·les, escalada, banyar-se en el riu i gorgues, volcans, la Fageda d’en Jordà, sortides amb bicicleta per a tots els nivells…." -#: web/templates/public/surroundings.gohtml:22 +#: web/templates/public/surroundings.gohtml:38 msgid "Get to the Costa Brava and enjoy the beaches, the gastronomy or go kayaking…." msgstr "Arribar fins a la costa brava i gaudir de les platges, la gastronomia o anar amb caiac…." -#: web/templates/public/surroundings.gohtml:31 +#: web/templates/public/surroundings.gohtml:47 msgid "You will also find museums in Olot, Figures, Girona." msgstr "També trobareu museus a Olot, Figueres, Girona." -#: web/templates/public/surroundings.gohtml:32 +#: web/templates/public/surroundings.gohtml:48 msgid "As well as music festivals, dance, theater…." msgstr "Com festivals de música, dansa, teatre…." -#: web/templates/public/surroundings.gohtml:38 +#: web/templates/public/surroundings.gohtml:54 msgctxt "title" msgid "Once at the Campsite, We Can Inform You about What Activities are Available" msgstr "Un cop en el càmping, us podem informar de quines activitats fer" -#: web/templates/public/surroundings.gohtml:41 +#: web/templates/public/surroundings.gohtml:57 msgid "Cycle routes" msgstr "Rutes amb bicicleta" -#: web/templates/public/surroundings.gohtml:42 +#: web/templates/public/surroundings.gohtml:58 msgid "There are many bicycle rental companies in Olot." msgstr "A Olot podeu trobar empreses de lloguer de bicicletes." -#: web/templates/public/surroundings.gohtml:46 +#: web/templates/public/surroundings.gohtml:62 msgid "Routes" msgstr "Rutes" -#: web/templates/public/surroundings.gohtml:47 +#: web/templates/public/surroundings.gohtml:63 msgid "Routes of all kinds, climbing, mountain passes, for all levels." msgstr "Rutes de tota mena, escalada, ports de muntanya, per a tots els nivells." -#: web/templates/public/surroundings.gohtml:51 +#: web/templates/public/surroundings.gohtml:67 msgid "Family outing" msgstr "Excursions familiars" -#: web/templates/public/surroundings.gohtml:52 +#: web/templates/public/surroundings.gohtml:68 msgid "Many outing possibilities, for all ages." msgstr "Múltiples excursions per a totes les edats." -#: web/templates/public/surroundings.gohtml:56 +#: web/templates/public/surroundings.gohtml:72 msgid "Kayak" msgstr "Caiac" -#: web/templates/public/surroundings.gohtml:57 +#: web/templates/public/surroundings.gohtml:73 msgid "There are several points where you can go by kayak, from sections of the Ter river as well as on the coast…." msgstr "Hi ha diversos punts on poder anar amb caiac, des de trams del riu Ter com també a la costa…." @@ -363,18 +363,18 @@ msgid "I have read and I accept the reservation conditions" msgstr "He llegit i accepto les condicions de reserves" #: web/templates/public/layout.gohtml:11 web/templates/public/layout.gohtml:25 -#: web/templates/public/layout.gohtml:96 +#: web/templates/public/layout.gohtml:102 msgid "Campsite Montagut" msgstr "Càmping Montagut" -#: web/templates/public/layout.gohtml:23 web/templates/admin/layout.gohtml:18 +#: web/templates/public/layout.gohtml:23 web/templates/admin/layout.gohtml:19 msgid "Skip to main content" msgstr "Salta al contingut principal" #: web/templates/public/layout.gohtml:35 web/templates/public/layout.gohtml:80 #: web/templates/admin/campsite/index.gohtml:6 #: web/templates/admin/campsite/index.gohtml:12 -#: web/templates/admin/layout.gohtml:43 web/templates/admin/layout.gohtml:74 +#: web/templates/admin/layout.gohtml:44 web/templates/admin/layout.gohtml:75 msgctxt "title" msgid "Campsites" msgstr "Allotjaments" @@ -384,7 +384,7 @@ msgctxt "title" msgid "Sections" msgstr "Apartats" -#: web/templates/public/layout.gohtml:93 +#: web/templates/public/layout.gohtml:99 msgid "RTC #%s" msgstr "Núm. RTC %s" @@ -526,21 +526,21 @@ msgid "Add Feature" msgstr "Afegeix característica" #: web/templates/admin/campsite/feature/index.gohtml:17 -#: web/templates/admin/campsite/option/index.gohtml:17 -#: web/templates/admin/campsite/type/index.gohtml:17 -#: web/templates/admin/season/index.gohtml:18 +#: web/templates/admin/campsite/option/index.gohtml:25 +#: web/templates/admin/campsite/type/index.gohtml:25 +#: web/templates/admin/season/index.gohtml:26 msgctxt "header" msgid "Name" msgstr "Nom" #: web/templates/admin/campsite/feature/index.gohtml:18 -#: web/templates/admin/campsite/carousel/index.gohtml:19 -#: web/templates/admin/campsite/option/index.gohtml:18 -#: web/templates/admin/campsite/type/index.gohtml:18 -#: web/templates/admin/season/index.gohtml:19 -#: web/templates/admin/services/index.gohtml:19 -#: web/templates/admin/services/index.gohtml:60 -#: web/templates/admin/home/index.gohtml:19 +#: web/templates/admin/campsite/carousel/index.gohtml:27 +#: web/templates/admin/campsite/option/index.gohtml:26 +#: web/templates/admin/campsite/type/index.gohtml:26 +#: web/templates/admin/season/index.gohtml:27 +#: web/templates/admin/services/index.gohtml:27 +#: web/templates/admin/services/index.gohtml:73 +#: web/templates/admin/home/index.gohtml:27 msgctxt "header" msgid "Translations" msgstr "Traduccions" @@ -580,45 +580,45 @@ msgctxt "action" msgid "Add slide" msgstr "Afegeix diapositiva" -#: web/templates/admin/campsite/carousel/index.gohtml:17 -#: web/templates/admin/services/index.gohtml:17 -#: web/templates/admin/home/index.gohtml:17 +#: web/templates/admin/campsite/carousel/index.gohtml:25 +#: web/templates/admin/services/index.gohtml:25 +#: web/templates/admin/home/index.gohtml:25 msgctxt "header" msgid "Image" msgstr "Imatge" -#: web/templates/admin/campsite/carousel/index.gohtml:18 -#: web/templates/admin/services/index.gohtml:18 -#: web/templates/admin/home/index.gohtml:18 +#: web/templates/admin/campsite/carousel/index.gohtml:26 +#: web/templates/admin/services/index.gohtml:26 +#: web/templates/admin/home/index.gohtml:26 msgctxt "header" msgid "Caption" msgstr "Llegenda" -#: web/templates/admin/campsite/carousel/index.gohtml:20 -#: web/templates/admin/services/index.gohtml:20 -#: web/templates/admin/services/index.gohtml:61 -#: web/templates/admin/home/index.gohtml:20 +#: web/templates/admin/campsite/carousel/index.gohtml:28 +#: web/templates/admin/services/index.gohtml:28 +#: web/templates/admin/services/index.gohtml:74 +#: web/templates/admin/home/index.gohtml:28 msgctxt "header" msgid "Actions" msgstr "Accions" -#: web/templates/admin/campsite/carousel/index.gohtml:24 -#: web/templates/admin/services/index.gohtml:24 -#: web/templates/admin/home/index.gohtml:24 +#: web/templates/admin/campsite/carousel/index.gohtml:32 +#: web/templates/admin/services/index.gohtml:32 +#: web/templates/admin/home/index.gohtml:32 msgid "Are you sure you wish to delete this slide?" msgstr "Esteu segur de voler esborrar aquesta diapositiva?" -#: web/templates/admin/campsite/carousel/index.gohtml:42 -#: web/templates/admin/services/index.gohtml:42 -#: web/templates/admin/services/index.gohtml:80 -#: web/templates/admin/home/index.gohtml:42 +#: web/templates/admin/campsite/carousel/index.gohtml:55 +#: web/templates/admin/services/index.gohtml:54 +#: web/templates/admin/services/index.gohtml:93 +#: web/templates/admin/home/index.gohtml:54 msgctxt "action" msgid "Delete" msgstr "Esborra" -#: web/templates/admin/campsite/carousel/index.gohtml:50 -#: web/templates/admin/services/index.gohtml:50 -#: web/templates/admin/home/index.gohtml:50 +#: web/templates/admin/campsite/carousel/index.gohtml:64 +#: web/templates/admin/services/index.gohtml:63 +#: web/templates/admin/home/index.gohtml:63 msgid "No slides added yet." msgstr "No s’ha afegit cap diapositiva encara." @@ -699,7 +699,7 @@ msgctxt "action" msgid "Add Option" msgstr "Afegeix opció" -#: web/templates/admin/campsite/option/index.gohtml:39 +#: web/templates/admin/campsite/option/index.gohtml:52 msgid "No campsite type options added yet." msgstr "No s’ha afegit cap opció al tipus d’allotjament encara." @@ -725,14 +725,14 @@ msgid "Type" msgstr "Tipus" #: web/templates/admin/campsite/index.gohtml:28 -#: web/templates/admin/campsite/type/index.gohtml:47 -#: web/templates/admin/season/index.gohtml:39 +#: web/templates/admin/campsite/type/index.gohtml:59 +#: web/templates/admin/season/index.gohtml:49 msgid "Yes" msgstr "Sí" #: web/templates/admin/campsite/index.gohtml:28 -#: web/templates/admin/campsite/type/index.gohtml:47 -#: web/templates/admin/season/index.gohtml:39 +#: web/templates/admin/campsite/type/index.gohtml:59 +#: web/templates/admin/season/index.gohtml:49 msgid "No" msgstr "No" @@ -753,7 +753,7 @@ msgid "New Campsite Type" msgstr "Nou tipus d’allotjament" #: web/templates/admin/campsite/type/form.gohtml:37 -#: web/templates/admin/campsite/type/index.gohtml:22 +#: web/templates/admin/campsite/type/index.gohtml:30 msgctxt "campsite type" msgid "Active" msgstr "Actiu" @@ -801,7 +801,7 @@ msgstr "Descripció" #: web/templates/admin/campsite/type/index.gohtml:6 #: web/templates/admin/campsite/type/index.gohtml:12 -#: web/templates/admin/layout.gohtml:40 +#: web/templates/admin/layout.gohtml:41 msgctxt "title" msgid "Campsite Types" msgstr "Tipus d’allotjaments" @@ -811,37 +811,37 @@ msgctxt "action" msgid "Add Type" msgstr "Afegeix tipus" -#: web/templates/admin/campsite/type/index.gohtml:19 +#: web/templates/admin/campsite/type/index.gohtml:27 msgctxt "header" msgid "Features" msgstr "Característiques" -#: web/templates/admin/campsite/type/index.gohtml:20 +#: web/templates/admin/campsite/type/index.gohtml:28 msgctxt "header" msgid "Options" msgstr "Opcions" -#: web/templates/admin/campsite/type/index.gohtml:21 +#: web/templates/admin/campsite/type/index.gohtml:29 msgctxt "header" msgid "Carousel" msgstr "Carrusel" -#: web/templates/admin/campsite/type/index.gohtml:39 +#: web/templates/admin/campsite/type/index.gohtml:51 msgctxt "action" msgid "Edit Features" msgstr "Edita les característiques" -#: web/templates/admin/campsite/type/index.gohtml:42 +#: web/templates/admin/campsite/type/index.gohtml:54 msgctxt "action" msgid "Edit Options" msgstr "Edita les opcions" -#: web/templates/admin/campsite/type/index.gohtml:45 +#: web/templates/admin/campsite/type/index.gohtml:57 msgctxt "action" msgid "Edit Carousel" msgstr "Edita el carrusel" -#: web/templates/admin/campsite/type/index.gohtml:53 +#: web/templates/admin/campsite/type/index.gohtml:66 msgid "No campsite types added yet." msgstr "No s’ha afegit cap tipus d’allotjament encara." @@ -864,7 +864,7 @@ msgid "New Season" msgstr "Nova temporada" #: web/templates/admin/season/form.gohtml:37 -#: web/templates/admin/season/index.gohtml:20 +#: web/templates/admin/season/index.gohtml:28 msgctxt "season" msgid "Active" msgstr "Activa" @@ -876,7 +876,7 @@ msgstr "Color" #: web/templates/admin/season/index.gohtml:6 #: web/templates/admin/season/index.gohtml:12 -#: web/templates/admin/layout.gohtml:46 +#: web/templates/admin/layout.gohtml:47 msgctxt "title" msgid "Seasons" msgstr "Temporades" @@ -886,12 +886,12 @@ msgctxt "action" msgid "Add Season" msgstr "Afegeix temporada" -#: web/templates/admin/season/index.gohtml:17 +#: web/templates/admin/season/index.gohtml:25 msgctxt "header" msgid "Color" msgstr "Color" -#: web/templates/admin/season/index.gohtml:45 +#: web/templates/admin/season/index.gohtml:56 msgid "No seasons added yet." msgstr "No s’ha afegit cap temporada encara." @@ -908,7 +908,7 @@ msgid "Cancel" msgstr "Canceŀla" #: web/templates/admin/payment.gohtml:6 web/templates/admin/payment.gohtml:12 -#: web/templates/admin/layout.gohtml:37 +#: web/templates/admin/layout.gohtml:38 msgctxt "title" msgid "Payment Settings" msgstr "Paràmetres de pagament" @@ -950,7 +950,7 @@ msgid "Save changes" msgstr "Desa els canvis" #: web/templates/admin/dashboard.gohtml:6 -#: web/templates/admin/dashboard.gohtml:10 web/templates/admin/layout.gohtml:71 +#: web/templates/admin/dashboard.gohtml:10 web/templates/admin/layout.gohtml:72 msgctxt "title" msgid "Dashboard" msgstr "Tauler" @@ -983,7 +983,7 @@ msgid "New Service" msgstr "Nou servei" #: web/templates/admin/services/index.gohtml:6 -#: web/templates/admin/layout.gohtml:55 +#: web/templates/admin/layout.gohtml:56 msgctxt "title" msgid "Services Page" msgstr "Pàgina de serveis" @@ -994,21 +994,21 @@ msgctxt "title" msgid "Carousel" msgstr "Carrusel" -#: web/templates/admin/services/index.gohtml:54 +#: web/templates/admin/services/index.gohtml:67 msgctxt "action" msgid "Add service" msgstr "Afegeix servei" -#: web/templates/admin/services/index.gohtml:59 +#: web/templates/admin/services/index.gohtml:72 msgctxt "header" msgid "Service" msgstr "Servei" -#: web/templates/admin/services/index.gohtml:65 +#: web/templates/admin/services/index.gohtml:78 msgid "Are you sure you wish to delete this service?" msgstr "Esteu segur de voler esborrar aquest servei?" -#: web/templates/admin/services/index.gohtml:88 +#: web/templates/admin/services/index.gohtml:101 msgid "No services added yet." msgstr "No s’ha afegit cap servei encara." @@ -1019,7 +1019,7 @@ msgid "Translate Service to %s" msgstr "Traducció del servei a %s" #: web/templates/admin/profile.gohtml:6 web/templates/admin/profile.gohtml:12 -#: web/templates/admin/layout.gohtml:30 +#: web/templates/admin/layout.gohtml:31 msgctxt "title" msgid "Profile" msgstr "Perfil" @@ -1111,29 +1111,29 @@ msgctxt "input" msgid "Legal Disclaimer" msgstr "Nota legal" -#: web/templates/admin/layout.gohtml:26 +#: web/templates/admin/layout.gohtml:27 msgctxt "title" msgid "User Menu" msgstr "Menú d’usuari" -#: web/templates/admin/layout.gohtml:34 +#: web/templates/admin/layout.gohtml:35 msgctxt "title" msgid "Company Settings" msgstr "Paràmetres de l’empresa" -#: web/templates/admin/layout.gohtml:49 +#: web/templates/admin/layout.gohtml:50 #: web/templates/admin/media/index.gohtml:6 #: web/templates/admin/media/index.gohtml:11 msgctxt "title" msgid "Media" msgstr "Mèdia" -#: web/templates/admin/layout.gohtml:52 web/templates/admin/home/index.gohtml:6 +#: web/templates/admin/layout.gohtml:53 web/templates/admin/home/index.gohtml:6 msgctxt "title" msgid "Home Page" msgstr "Pàgina d’inici" -#: web/templates/admin/layout.gohtml:60 +#: web/templates/admin/layout.gohtml:61 msgctxt "action" msgid "Logout" msgstr "Surt" @@ -1203,31 +1203,31 @@ msgctxt "title" msgid "Upload Media" msgstr "Pujada de mèdia" -#: pkg/carousel/admin.go:233 pkg/campsite/types/carousel.go:232 +#: pkg/carousel/admin.go:274 pkg/campsite/types/carousel.go:242 msgctxt "input" msgid "Slide image" msgstr "Imatge de la diapositiva" -#: pkg/carousel/admin.go:234 pkg/campsite/types/carousel.go:233 +#: pkg/carousel/admin.go:275 pkg/campsite/types/carousel.go:243 msgctxt "action" msgid "Set slide image" msgstr "Estableix la imatge de la diapositiva" -#: pkg/carousel/admin.go:286 pkg/campsite/types/carousel.go:287 +#: pkg/carousel/admin.go:327 pkg/campsite/types/carousel.go:297 msgid "Slide image can not be empty." msgstr "No podeu deixar la imatge de la diapositiva en blanc." -#: pkg/carousel/admin.go:287 pkg/campsite/types/carousel.go:288 +#: pkg/carousel/admin.go:328 pkg/campsite/types/carousel.go:298 msgid "Slide image must be an image media type." msgstr "La imatge de la diapositiva ha de ser un mèdia de tipus imatge." #: pkg/app/login.go:56 pkg/app/user.go:246 pkg/company/admin.go:210 -#: pkg/booking/public.go:265 +#: pkg/booking/public.go:269 msgid "Email can not be empty." msgstr "No podeu deixar el correu-e en blanc." #: pkg/app/login.go:57 pkg/app/user.go:247 pkg/company/admin.go:211 -#: pkg/booking/public.go:266 +#: pkg/booking/public.go:270 msgid "This email is not valid. It should be like name@domain.com." msgstr "Aquest correu-e no és vàlid. Hauria de ser similar a nom@domini.com." @@ -1246,9 +1246,9 @@ msgstr "Automàtic" #: pkg/app/user.go:249 pkg/campsite/types/l10n.go:87 #: pkg/campsite/types/l10n.go:144 pkg/campsite/types/l10n.go:268 -#: pkg/campsite/types/option.go:340 pkg/campsite/types/feature.go:243 -#: pkg/campsite/types/admin.go:415 pkg/season/l10n.go:69 -#: pkg/season/admin.go:394 pkg/services/l10n.go:73 pkg/services/admin.go:266 +#: pkg/campsite/types/option.go:350 pkg/campsite/types/feature.go:243 +#: pkg/campsite/types/admin.go:447 pkg/season/l10n.go:69 +#: pkg/season/admin.go:404 pkg/services/l10n.go:73 pkg/services/admin.go:266 msgid "Name can not be empty." msgstr "No podeu deixar el nom en blanc." @@ -1268,44 +1268,44 @@ msgstr "El fitxer has de ser una imatge PNG o JPEG vàlida." msgid "Access forbidden" msgstr "Accés prohibit" -#: pkg/campsite/types/option.go:341 pkg/campsite/types/feature.go:244 -#: pkg/campsite/types/admin.go:416 +#: pkg/campsite/types/option.go:351 pkg/campsite/types/feature.go:244 +#: pkg/campsite/types/admin.go:448 msgid "Name must have at least one letter." msgstr "El nom ha de tenir com a mínim una lletra." -#: pkg/campsite/types/option.go:344 +#: pkg/campsite/types/option.go:354 msgid "Minimum can not be empty." msgstr "No podeu deixar el mínim en blanc." -#: pkg/campsite/types/option.go:345 +#: pkg/campsite/types/option.go:355 msgid "Minimum must be an integer number." msgstr "El valor del mínim ha de ser un número enter." -#: pkg/campsite/types/option.go:347 +#: pkg/campsite/types/option.go:357 msgid "Minimum must be zero or greater." msgstr "El valor del mínim ha de ser com a mínim zero." -#: pkg/campsite/types/option.go:350 +#: pkg/campsite/types/option.go:360 msgid "Maximum can not be empty." msgstr "No podeu deixar el màxim en blanc." -#: pkg/campsite/types/option.go:351 +#: pkg/campsite/types/option.go:361 msgid "Maximum must be an integer number." msgstr "El valor del màxim ha de ser un número enter." -#: pkg/campsite/types/option.go:353 +#: pkg/campsite/types/option.go:363 msgid "Maximum must be equal or greater than minimum." msgstr "El valor del màxim ha de ser igual o superir al del mínim." -#: pkg/campsite/types/option.go:357 pkg/campsite/types/admin.go:429 +#: pkg/campsite/types/option.go:367 pkg/campsite/types/admin.go:461 msgid "Price per night can not be empty." msgstr "No podeu deixar el preu per nit en blanc." -#: pkg/campsite/types/option.go:358 pkg/campsite/types/admin.go:430 +#: pkg/campsite/types/option.go:368 pkg/campsite/types/admin.go:462 msgid "Price per night must be a decimal number." msgstr "El preu per nit ha de ser un número decimal." -#: pkg/campsite/types/option.go:359 pkg/campsite/types/admin.go:431 +#: pkg/campsite/types/option.go:369 pkg/campsite/types/admin.go:463 msgid "Price per night must be zero or greater." msgstr "El preu per nit ha de ser com a mínim zero." @@ -1313,54 +1313,54 @@ msgstr "El preu per nit ha de ser com a mínim zero." msgid "Selected icon is not valid." msgstr "La icona escollida no és vàlida." -#: pkg/campsite/types/admin.go:291 +#: pkg/campsite/types/admin.go:323 msgctxt "input" msgid "Cover image" msgstr "Imatge de portada" -#: pkg/campsite/types/admin.go:292 +#: pkg/campsite/types/admin.go:324 msgctxt "action" msgid "Set campsite type cover" msgstr "Estableix la portada del tipus d’allotjament" -#: pkg/campsite/types/admin.go:418 +#: pkg/campsite/types/admin.go:450 msgid "Cover image can not be empty." msgstr "No podeu deixar la imatge de portada en blanc." -#: pkg/campsite/types/admin.go:419 +#: pkg/campsite/types/admin.go:451 msgid "Cover image must be an image media type." msgstr "La imatge de portada ha de ser un mèdia de tipus imatge." -#: pkg/campsite/types/admin.go:423 +#: pkg/campsite/types/admin.go:455 msgid "Maximum number of campers can not be empty." msgstr "No podeu deixar el número màxim de persones en blanc." -#: pkg/campsite/types/admin.go:424 +#: pkg/campsite/types/admin.go:456 msgid "Maximum number of campers must be an integer number." msgstr "El número màxim de persones ha de ser enter." -#: pkg/campsite/types/admin.go:425 +#: pkg/campsite/types/admin.go:457 msgid "Maximum number of campers must be one or greater." msgstr "El número màxim de persones no pot ser zero." -#: pkg/campsite/types/admin.go:434 +#: pkg/campsite/types/admin.go:466 msgid "Minimum number of nights can not be empty." msgstr "No podeu deixar el número mínim de nits en blanc." -#: pkg/campsite/types/admin.go:435 +#: pkg/campsite/types/admin.go:467 msgid "Minimum number of nights must be an integer." msgstr "El número mínim de nits ha de ser enter." -#: pkg/campsite/types/admin.go:436 +#: pkg/campsite/types/admin.go:468 msgid "Minimum number of nights must be one or greater." msgstr "El número mínim de nits no pot ser zero." -#: pkg/campsite/types/public.go:157 +#: pkg/campsite/types/public.go:160 msgctxt "season" msgid "Closed" msgstr "Tancat" -#: pkg/campsite/admin.go:226 pkg/booking/public.go:274 +#: pkg/campsite/admin.go:226 pkg/booking/public.go:278 msgid "Selected campsite type is not valid." msgstr "El tipus d’allotjament escollit no és vàlid." @@ -1368,96 +1368,96 @@ msgstr "El tipus d’allotjament escollit no és vàlid." msgid "Label can not be empty." msgstr "No podeu deixar l’etiqueta en blanc." -#: pkg/season/admin.go:212 +#: pkg/season/admin.go:222 msgctxt "month" msgid "January" msgstr "gener" -#: pkg/season/admin.go:213 +#: pkg/season/admin.go:223 msgctxt "month" msgid "February" msgstr "febrer" -#: pkg/season/admin.go:214 +#: pkg/season/admin.go:224 msgctxt "month" msgid "March" msgstr "març" -#: pkg/season/admin.go:215 +#: pkg/season/admin.go:225 msgctxt "month" msgid "April" msgstr "abril" -#: pkg/season/admin.go:216 +#: pkg/season/admin.go:226 msgctxt "month" msgid "May" msgstr "maig" -#: pkg/season/admin.go:217 +#: pkg/season/admin.go:227 msgctxt "month" msgid "June" msgstr "juny" -#: pkg/season/admin.go:218 +#: pkg/season/admin.go:228 msgctxt "month" msgid "July" msgstr "juliol" -#: pkg/season/admin.go:219 +#: pkg/season/admin.go:229 msgctxt "month" msgid "August" msgstr "agost" -#: pkg/season/admin.go:220 +#: pkg/season/admin.go:230 msgctxt "month" msgid "September" msgstr "setembre" -#: pkg/season/admin.go:221 +#: pkg/season/admin.go:231 msgctxt "month" msgid "October" msgstr "octubre" -#: pkg/season/admin.go:222 +#: pkg/season/admin.go:232 msgctxt "month" msgid "November" msgstr "novembre" -#: pkg/season/admin.go:223 +#: pkg/season/admin.go:233 msgctxt "month" msgid "December" msgstr "desembre" -#: pkg/season/admin.go:395 +#: pkg/season/admin.go:405 msgid "Color can not be empty." msgstr "No podeu deixar el color en blanc." -#: pkg/season/admin.go:396 +#: pkg/season/admin.go:406 msgid "This color is not valid. It must be like #123abc." msgstr "Aquest color no és vàlid. Hauria de ser similar a #123abc." -#: pkg/season/admin.go:472 +#: pkg/season/admin.go:506 msgctxt "action" msgid "Unset" msgstr "Desassigna" -#: pkg/season/admin.go:503 +#: pkg/season/admin.go:537 msgid "Start date can not be empty." msgstr "No podeu deixar la data d’inici en blanc." -#: pkg/season/admin.go:504 +#: pkg/season/admin.go:538 msgid "Start date must be a valid date." msgstr "La data d’inici ha de ser una data vàlida." -#: pkg/season/admin.go:506 +#: pkg/season/admin.go:540 msgid "End date can not be empty." msgstr "No podeu deixar la data de fi en blanc." -#: pkg/season/admin.go:507 +#: pkg/season/admin.go:541 msgid "End date must be a valid date." msgstr "La data de fi ha de ser una data vàlida." -#: pkg/company/admin.go:193 pkg/booking/public.go:252 +#: pkg/company/admin.go:193 pkg/booking/public.go:256 msgid "Selected country is not valid." msgstr "El país escollit no és vàlid." @@ -1477,11 +1477,11 @@ msgstr "No podeu deixar el NIF en blanc." msgid "This VAT number is not valid." msgstr "Aquest NIF no és vàlid." -#: pkg/company/admin.go:205 pkg/booking/public.go:268 +#: pkg/company/admin.go:205 pkg/booking/public.go:272 msgid "Phone can not be empty." msgstr "No podeu deixar el telèfon en blanc." -#: pkg/company/admin.go:206 pkg/booking/public.go:269 +#: pkg/company/admin.go:206 pkg/booking/public.go:273 msgid "This phone number is not valid." msgstr "Aquest número de telèfon no és vàlid." @@ -1505,7 +1505,7 @@ msgstr "No podeu deixar la província en blanc." msgid "Postal code can not be empty." msgstr "No podeu deixar el codi postal en blanc." -#: pkg/company/admin.go:220 pkg/booking/public.go:261 +#: pkg/company/admin.go:220 pkg/booking/public.go:265 msgid "This postal code is not valid." msgstr "Aquest codi postal no és vàlid." @@ -1585,54 +1585,54 @@ msgstr "La integració escollida no és vàlida." msgid "The merchant key is not valid." msgstr "Aquesta clau del comerç no és vàlid." -#: pkg/booking/public.go:256 +#: pkg/booking/public.go:260 msgid "Full name can not be empty." msgstr "No podeu deixar el nom i els cognoms en blanc." -#: pkg/booking/public.go:257 +#: pkg/booking/public.go:261 msgid "Full name must have at least one letter." msgstr "El nom i els cognoms han de tenir com a mínim una lletra." -#: pkg/booking/public.go:275 +#: pkg/booking/public.go:279 msgid "Arrival date can not be empty" msgstr "No podeu deixar la data d’arribada en blanc." -#: pkg/booking/public.go:276 +#: pkg/booking/public.go:280 msgid "Arrival date must be a valid date." msgstr "La data d’arribada ha de ser una data vàlida." -#: pkg/booking/public.go:280 +#: pkg/booking/public.go:284 msgid "Departure date can not be empty" msgstr "No podeu deixar la data de sortida en blanc." -#: pkg/booking/public.go:281 +#: pkg/booking/public.go:285 msgid "Departure date must be a valid date." msgstr "La data de sortida ha de ser una data vàlida." -#: pkg/booking/public.go:282 +#: pkg/booking/public.go:286 msgid "The departure date must be after the arrival date." msgstr "La data de sortida ha de ser posterior a la d’arribada." -#: pkg/booking/public.go:285 +#: pkg/booking/public.go:289 msgid "It is mandatory to agree to the reservation conditions." msgstr "És obligatori acceptar les condicions de reserves." -#: pkg/booking/public.go:288 +#: pkg/booking/public.go:292 #, c-format msgid "%s can not be empty" msgstr "No podeu deixar %s en blanc." -#: pkg/booking/public.go:289 +#: pkg/booking/public.go:293 #, c-format msgid "%s must be an integer." msgstr "%s ha de ser un número enter." -#: pkg/booking/public.go:290 +#: pkg/booking/public.go:294 #, c-format msgid "%s must be %d or greater." msgstr "El valor de %s ha de ser com a mínim %d." -#: pkg/booking/public.go:291 +#: pkg/booking/public.go:295 #, c-format msgid "%s must be at most %d." msgstr "El valor de %s ha de ser com a màxim %d." diff --git a/po/es.po b/po/es.po index ab59916..7bafbf7 100644 --- a/po/es.po +++ b/po/es.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: camper\n" "Report-Msgid-Bugs-To: jordi@tandem.blog\n" -"POT-Creation-Date: 2023-12-13 23:44+0100\n" +"POT-Creation-Date: 2023-12-20 19:48+0100\n" "PO-Revision-Date: 2023-07-22 23:46+0200\n" "Last-Translator: jordi fita mas \n" "Language-Team: Spanish \n" @@ -44,7 +44,7 @@ msgstr "Pago fallido" #: web/templates/public/services.gohtml:6 #: web/templates/public/services.gohtml:15 #: web/templates/public/layout.gohtml:44 web/templates/public/layout.gohtml:71 -#: web/templates/admin/services/index.gohtml:53 +#: web/templates/admin/services/index.gohtml:66 msgctxt "title" msgid "Services" msgstr "Servicios" @@ -136,7 +136,7 @@ msgid "*Minimum %d nights per stay" msgstr "*Mínimo %d noches por estancia" #: web/templates/public/campsite/type.gohtml:89 -#: web/templates/admin/season/index.gohtml:48 +#: web/templates/admin/season/index.gohtml:59 msgctxt "title" msgid "Calendar" msgstr "Calendario" @@ -203,61 +203,61 @@ msgctxt "day" msgid "Sun" msgstr "do" -#: web/templates/public/surroundings.gohtml:13 +#: web/templates/public/surroundings.gohtml:28 msgctxt "title" msgid "What to Do Outside the Campsite?" msgstr "¿Qué hacer desde el camping?" -#: web/templates/public/surroundings.gohtml:15 +#: web/templates/public/surroundings.gohtml:31 msgid "Campsite Montagut is an ideal starting point for quiet outings, climbing, swimming in the river and gorges, volcanoes, the Fageda d’en Jordà, cycle tours for all ages…." msgstr "El Camping Montagut es ideal como punto de salida de excursiones tranquilas, escalada, bañarse en el río y piletones, volcanes, la Fageda d’en Jordà, salidas en bicicleta para todos los niveles…." -#: web/templates/public/surroundings.gohtml:22 +#: web/templates/public/surroundings.gohtml:38 msgid "Get to the Costa Brava and enjoy the beaches, the gastronomy or go kayaking…." msgstr "Llegar hasta la Costa Brava y disfrutar de las playas, la gastronomía o ir en kayak…." -#: web/templates/public/surroundings.gohtml:31 +#: web/templates/public/surroundings.gohtml:47 msgid "You will also find museums in Olot, Figures, Girona." msgstr "También encontraréis museos en Olot, Figueres, Girona." -#: web/templates/public/surroundings.gohtml:32 +#: web/templates/public/surroundings.gohtml:48 msgid "As well as music festivals, dance, theater…." msgstr "Como festivales de música, danza, teatro…." -#: web/templates/public/surroundings.gohtml:38 +#: web/templates/public/surroundings.gohtml:54 msgctxt "title" msgid "Once at the Campsite, We Can Inform You about What Activities are Available" msgstr "Una vez en el camping, os podemos informar de qué actividades hacer" -#: web/templates/public/surroundings.gohtml:41 +#: web/templates/public/surroundings.gohtml:57 msgid "Cycle routes" msgstr "Rutas en bicicleta" -#: web/templates/public/surroundings.gohtml:42 +#: web/templates/public/surroundings.gohtml:58 msgid "There are many bicycle rental companies in Olot." msgstr "A Olot podéis encontrar empresas de alquiler de bicicletas." -#: web/templates/public/surroundings.gohtml:46 +#: web/templates/public/surroundings.gohtml:62 msgid "Routes" msgstr "Rutas" -#: web/templates/public/surroundings.gohtml:47 +#: web/templates/public/surroundings.gohtml:63 msgid "Routes of all kinds, climbing, mountain passes, for all levels." msgstr "Rutas de todo tipo, escalada, puertos de montaña, para todos los niveles." -#: web/templates/public/surroundings.gohtml:51 +#: web/templates/public/surroundings.gohtml:67 msgid "Family outing" msgstr "Excusiones familiares" -#: web/templates/public/surroundings.gohtml:52 +#: web/templates/public/surroundings.gohtml:68 msgid "Many outing possibilities, for all ages." msgstr "Múltiples excursiones para todas las edades." -#: web/templates/public/surroundings.gohtml:56 +#: web/templates/public/surroundings.gohtml:72 msgid "Kayak" msgstr "Kayak" -#: web/templates/public/surroundings.gohtml:57 +#: web/templates/public/surroundings.gohtml:73 msgid "There are several points where you can go by kayak, from sections of the Ter river as well as on the coast…." msgstr "Hay diversos puntos dónde podéis ir en kayak, desde tramos del río Ter como también en la costa…." @@ -363,18 +363,18 @@ msgid "I have read and I accept the reservation conditions" msgstr "He leído y acepto las condiciones de reserva" #: web/templates/public/layout.gohtml:11 web/templates/public/layout.gohtml:25 -#: web/templates/public/layout.gohtml:96 +#: web/templates/public/layout.gohtml:102 msgid "Campsite Montagut" msgstr "Camping Montagut" -#: web/templates/public/layout.gohtml:23 web/templates/admin/layout.gohtml:18 +#: web/templates/public/layout.gohtml:23 web/templates/admin/layout.gohtml:19 msgid "Skip to main content" msgstr "Saltar al contenido principal" #: web/templates/public/layout.gohtml:35 web/templates/public/layout.gohtml:80 #: web/templates/admin/campsite/index.gohtml:6 #: web/templates/admin/campsite/index.gohtml:12 -#: web/templates/admin/layout.gohtml:43 web/templates/admin/layout.gohtml:74 +#: web/templates/admin/layout.gohtml:44 web/templates/admin/layout.gohtml:75 msgctxt "title" msgid "Campsites" msgstr "Alojamientos" @@ -384,7 +384,7 @@ msgctxt "title" msgid "Sections" msgstr "Apartados" -#: web/templates/public/layout.gohtml:93 +#: web/templates/public/layout.gohtml:99 msgid "RTC #%s" msgstr " RTC %s" @@ -526,21 +526,21 @@ msgid "Add Feature" msgstr "Añadir características" #: web/templates/admin/campsite/feature/index.gohtml:17 -#: web/templates/admin/campsite/option/index.gohtml:17 -#: web/templates/admin/campsite/type/index.gohtml:17 -#: web/templates/admin/season/index.gohtml:18 +#: web/templates/admin/campsite/option/index.gohtml:25 +#: web/templates/admin/campsite/type/index.gohtml:25 +#: web/templates/admin/season/index.gohtml:26 msgctxt "header" msgid "Name" msgstr "Nombre" #: web/templates/admin/campsite/feature/index.gohtml:18 -#: web/templates/admin/campsite/carousel/index.gohtml:19 -#: web/templates/admin/campsite/option/index.gohtml:18 -#: web/templates/admin/campsite/type/index.gohtml:18 -#: web/templates/admin/season/index.gohtml:19 -#: web/templates/admin/services/index.gohtml:19 -#: web/templates/admin/services/index.gohtml:60 -#: web/templates/admin/home/index.gohtml:19 +#: web/templates/admin/campsite/carousel/index.gohtml:27 +#: web/templates/admin/campsite/option/index.gohtml:26 +#: web/templates/admin/campsite/type/index.gohtml:26 +#: web/templates/admin/season/index.gohtml:27 +#: web/templates/admin/services/index.gohtml:27 +#: web/templates/admin/services/index.gohtml:73 +#: web/templates/admin/home/index.gohtml:27 msgctxt "header" msgid "Translations" msgstr "Traducciones" @@ -580,45 +580,45 @@ msgctxt "action" msgid "Add slide" msgstr "Añadir diapositiva" -#: web/templates/admin/campsite/carousel/index.gohtml:17 -#: web/templates/admin/services/index.gohtml:17 -#: web/templates/admin/home/index.gohtml:17 +#: web/templates/admin/campsite/carousel/index.gohtml:25 +#: web/templates/admin/services/index.gohtml:25 +#: web/templates/admin/home/index.gohtml:25 msgctxt "header" msgid "Image" msgstr "Imagen" -#: web/templates/admin/campsite/carousel/index.gohtml:18 -#: web/templates/admin/services/index.gohtml:18 -#: web/templates/admin/home/index.gohtml:18 +#: web/templates/admin/campsite/carousel/index.gohtml:26 +#: web/templates/admin/services/index.gohtml:26 +#: web/templates/admin/home/index.gohtml:26 msgctxt "header" msgid "Caption" msgstr "Leyenda" -#: web/templates/admin/campsite/carousel/index.gohtml:20 -#: web/templates/admin/services/index.gohtml:20 -#: web/templates/admin/services/index.gohtml:61 -#: web/templates/admin/home/index.gohtml:20 +#: web/templates/admin/campsite/carousel/index.gohtml:28 +#: web/templates/admin/services/index.gohtml:28 +#: web/templates/admin/services/index.gohtml:74 +#: web/templates/admin/home/index.gohtml:28 msgctxt "header" msgid "Actions" msgstr "Acciones" -#: web/templates/admin/campsite/carousel/index.gohtml:24 -#: web/templates/admin/services/index.gohtml:24 -#: web/templates/admin/home/index.gohtml:24 +#: web/templates/admin/campsite/carousel/index.gohtml:32 +#: web/templates/admin/services/index.gohtml:32 +#: web/templates/admin/home/index.gohtml:32 msgid "Are you sure you wish to delete this slide?" msgstr "¿Estáis seguro de querer borrar esta diapositiva?" -#: web/templates/admin/campsite/carousel/index.gohtml:42 -#: web/templates/admin/services/index.gohtml:42 -#: web/templates/admin/services/index.gohtml:80 -#: web/templates/admin/home/index.gohtml:42 +#: web/templates/admin/campsite/carousel/index.gohtml:55 +#: web/templates/admin/services/index.gohtml:54 +#: web/templates/admin/services/index.gohtml:93 +#: web/templates/admin/home/index.gohtml:54 msgctxt "action" msgid "Delete" msgstr "Borrar" -#: web/templates/admin/campsite/carousel/index.gohtml:50 -#: web/templates/admin/services/index.gohtml:50 -#: web/templates/admin/home/index.gohtml:50 +#: web/templates/admin/campsite/carousel/index.gohtml:64 +#: web/templates/admin/services/index.gohtml:63 +#: web/templates/admin/home/index.gohtml:63 msgid "No slides added yet." msgstr "No se ha añadido ninguna diapositiva todavía." @@ -699,7 +699,7 @@ msgctxt "action" msgid "Add Option" msgstr "Añadir opción" -#: web/templates/admin/campsite/option/index.gohtml:39 +#: web/templates/admin/campsite/option/index.gohtml:52 msgid "No campsite type options added yet." msgstr "No se ha añadido ninguna opció al tipo de alojamiento todavía." @@ -725,14 +725,14 @@ msgid "Type" msgstr "Tipo" #: web/templates/admin/campsite/index.gohtml:28 -#: web/templates/admin/campsite/type/index.gohtml:47 -#: web/templates/admin/season/index.gohtml:39 +#: web/templates/admin/campsite/type/index.gohtml:59 +#: web/templates/admin/season/index.gohtml:49 msgid "Yes" msgstr "Sí" #: web/templates/admin/campsite/index.gohtml:28 -#: web/templates/admin/campsite/type/index.gohtml:47 -#: web/templates/admin/season/index.gohtml:39 +#: web/templates/admin/campsite/type/index.gohtml:59 +#: web/templates/admin/season/index.gohtml:49 msgid "No" msgstr "No" @@ -753,7 +753,7 @@ msgid "New Campsite Type" msgstr "Nuevo tipo de alojamiento" #: web/templates/admin/campsite/type/form.gohtml:37 -#: web/templates/admin/campsite/type/index.gohtml:22 +#: web/templates/admin/campsite/type/index.gohtml:30 msgctxt "campsite type" msgid "Active" msgstr "Activo" @@ -801,7 +801,7 @@ msgstr "Descripción" #: web/templates/admin/campsite/type/index.gohtml:6 #: web/templates/admin/campsite/type/index.gohtml:12 -#: web/templates/admin/layout.gohtml:40 +#: web/templates/admin/layout.gohtml:41 msgctxt "title" msgid "Campsite Types" msgstr "Tipos de alojamientos" @@ -811,37 +811,37 @@ msgctxt "action" msgid "Add Type" msgstr "Añadir tipo" -#: web/templates/admin/campsite/type/index.gohtml:19 +#: web/templates/admin/campsite/type/index.gohtml:27 msgctxt "header" msgid "Features" msgstr "Características" -#: web/templates/admin/campsite/type/index.gohtml:20 +#: web/templates/admin/campsite/type/index.gohtml:28 msgctxt "header" msgid "Options" msgstr "Opciones" -#: web/templates/admin/campsite/type/index.gohtml:21 +#: web/templates/admin/campsite/type/index.gohtml:29 msgctxt "header" msgid "Carousel" msgstr "Carrusel" -#: web/templates/admin/campsite/type/index.gohtml:39 +#: web/templates/admin/campsite/type/index.gohtml:51 msgctxt "action" msgid "Edit Features" msgstr "Editar las características" -#: web/templates/admin/campsite/type/index.gohtml:42 +#: web/templates/admin/campsite/type/index.gohtml:54 msgctxt "action" msgid "Edit Options" msgstr "Editar opciones" -#: web/templates/admin/campsite/type/index.gohtml:45 +#: web/templates/admin/campsite/type/index.gohtml:57 msgctxt "action" msgid "Edit Carousel" msgstr "Editar el carrusel" -#: web/templates/admin/campsite/type/index.gohtml:53 +#: web/templates/admin/campsite/type/index.gohtml:66 msgid "No campsite types added yet." msgstr "No se ha añadido ningún tipo de alojamiento todavía." @@ -864,7 +864,7 @@ msgid "New Season" msgstr "Nueva temporada" #: web/templates/admin/season/form.gohtml:37 -#: web/templates/admin/season/index.gohtml:20 +#: web/templates/admin/season/index.gohtml:28 msgctxt "season" msgid "Active" msgstr "Activa" @@ -876,7 +876,7 @@ msgstr "Color" #: web/templates/admin/season/index.gohtml:6 #: web/templates/admin/season/index.gohtml:12 -#: web/templates/admin/layout.gohtml:46 +#: web/templates/admin/layout.gohtml:47 msgctxt "title" msgid "Seasons" msgstr "Temporadas" @@ -886,12 +886,12 @@ msgctxt "action" msgid "Add Season" msgstr "Añadir temporada" -#: web/templates/admin/season/index.gohtml:17 +#: web/templates/admin/season/index.gohtml:25 msgctxt "header" msgid "Color" msgstr "Color" -#: web/templates/admin/season/index.gohtml:45 +#: web/templates/admin/season/index.gohtml:56 msgid "No seasons added yet." msgstr "No se ha añadido ninguna temporada todavía." @@ -908,7 +908,7 @@ msgid "Cancel" msgstr "Cancelar" #: web/templates/admin/payment.gohtml:6 web/templates/admin/payment.gohtml:12 -#: web/templates/admin/layout.gohtml:37 +#: web/templates/admin/layout.gohtml:38 msgctxt "title" msgid "Payment Settings" msgstr "Parámetros de pago" @@ -950,7 +950,7 @@ msgid "Save changes" msgstr "Guardar los cambios" #: web/templates/admin/dashboard.gohtml:6 -#: web/templates/admin/dashboard.gohtml:10 web/templates/admin/layout.gohtml:71 +#: web/templates/admin/dashboard.gohtml:10 web/templates/admin/layout.gohtml:72 msgctxt "title" msgid "Dashboard" msgstr "Panel" @@ -983,7 +983,7 @@ msgid "New Service" msgstr "Nuevo servicio" #: web/templates/admin/services/index.gohtml:6 -#: web/templates/admin/layout.gohtml:55 +#: web/templates/admin/layout.gohtml:56 msgctxt "title" msgid "Services Page" msgstr "Página de servicios" @@ -994,21 +994,21 @@ msgctxt "title" msgid "Carousel" msgstr "Carrusel" -#: web/templates/admin/services/index.gohtml:54 +#: web/templates/admin/services/index.gohtml:67 msgctxt "action" msgid "Add service" msgstr "Añadir servicio" -#: web/templates/admin/services/index.gohtml:59 +#: web/templates/admin/services/index.gohtml:72 msgctxt "header" msgid "Service" msgstr "Servicio" -#: web/templates/admin/services/index.gohtml:65 +#: web/templates/admin/services/index.gohtml:78 msgid "Are you sure you wish to delete this service?" msgstr "¿Estáis seguro de querer borrar este servicio?" -#: web/templates/admin/services/index.gohtml:88 +#: web/templates/admin/services/index.gohtml:101 msgid "No services added yet." msgstr "No se ha añadido ningún servicio todavía." @@ -1019,7 +1019,7 @@ msgid "Translate Service to %s" msgstr "Traducción del servicio a %s" #: web/templates/admin/profile.gohtml:6 web/templates/admin/profile.gohtml:12 -#: web/templates/admin/layout.gohtml:30 +#: web/templates/admin/layout.gohtml:31 msgctxt "title" msgid "Profile" msgstr "Perfil" @@ -1111,29 +1111,29 @@ msgctxt "input" msgid "Legal Disclaimer" msgstr "Nota legal" -#: web/templates/admin/layout.gohtml:26 +#: web/templates/admin/layout.gohtml:27 msgctxt "title" msgid "User Menu" msgstr "Menú de usuario" -#: web/templates/admin/layout.gohtml:34 +#: web/templates/admin/layout.gohtml:35 msgctxt "title" msgid "Company Settings" msgstr "Parámetros de la empresa" -#: web/templates/admin/layout.gohtml:49 +#: web/templates/admin/layout.gohtml:50 #: web/templates/admin/media/index.gohtml:6 #: web/templates/admin/media/index.gohtml:11 msgctxt "title" msgid "Media" msgstr "Medios" -#: web/templates/admin/layout.gohtml:52 web/templates/admin/home/index.gohtml:6 +#: web/templates/admin/layout.gohtml:53 web/templates/admin/home/index.gohtml:6 msgctxt "title" msgid "Home Page" msgstr "Página de inicio" -#: web/templates/admin/layout.gohtml:60 +#: web/templates/admin/layout.gohtml:61 msgctxt "action" msgid "Logout" msgstr "Salir" @@ -1203,31 +1203,31 @@ msgctxt "title" msgid "Upload Media" msgstr "Subida de medio" -#: pkg/carousel/admin.go:233 pkg/campsite/types/carousel.go:232 +#: pkg/carousel/admin.go:274 pkg/campsite/types/carousel.go:242 msgctxt "input" msgid "Slide image" msgstr "Imagen de la diapositiva" -#: pkg/carousel/admin.go:234 pkg/campsite/types/carousel.go:233 +#: pkg/carousel/admin.go:275 pkg/campsite/types/carousel.go:243 msgctxt "action" msgid "Set slide image" msgstr "Establecer la imagen de la diapositiva" -#: pkg/carousel/admin.go:286 pkg/campsite/types/carousel.go:287 +#: pkg/carousel/admin.go:327 pkg/campsite/types/carousel.go:297 msgid "Slide image can not be empty." msgstr "No podéis dejar la imagen de la diapositiva en blanco." -#: pkg/carousel/admin.go:287 pkg/campsite/types/carousel.go:288 +#: pkg/carousel/admin.go:328 pkg/campsite/types/carousel.go:298 msgid "Slide image must be an image media type." msgstr "La imagen de la diapositiva tiene que ser un medio de tipo imagen." #: pkg/app/login.go:56 pkg/app/user.go:246 pkg/company/admin.go:210 -#: pkg/booking/public.go:265 +#: pkg/booking/public.go:269 msgid "Email can not be empty." msgstr "No podéis dejar el correo-e en blanco." #: pkg/app/login.go:57 pkg/app/user.go:247 pkg/company/admin.go:211 -#: pkg/booking/public.go:266 +#: pkg/booking/public.go:270 msgid "This email is not valid. It should be like name@domain.com." msgstr "Este correo-e no es válido. Tiene que ser parecido a nombre@dominio.com." @@ -1246,9 +1246,9 @@ msgstr "Automático" #: pkg/app/user.go:249 pkg/campsite/types/l10n.go:87 #: pkg/campsite/types/l10n.go:144 pkg/campsite/types/l10n.go:268 -#: pkg/campsite/types/option.go:340 pkg/campsite/types/feature.go:243 -#: pkg/campsite/types/admin.go:415 pkg/season/l10n.go:69 -#: pkg/season/admin.go:394 pkg/services/l10n.go:73 pkg/services/admin.go:266 +#: pkg/campsite/types/option.go:350 pkg/campsite/types/feature.go:243 +#: pkg/campsite/types/admin.go:447 pkg/season/l10n.go:69 +#: pkg/season/admin.go:404 pkg/services/l10n.go:73 pkg/services/admin.go:266 msgid "Name can not be empty." msgstr "No podéis dejar el nombre en blanco." @@ -1268,44 +1268,44 @@ msgstr "El archivo tiene que ser una imagen PNG o JPEG válida." msgid "Access forbidden" msgstr "Acceso prohibido" -#: pkg/campsite/types/option.go:341 pkg/campsite/types/feature.go:244 -#: pkg/campsite/types/admin.go:416 +#: pkg/campsite/types/option.go:351 pkg/campsite/types/feature.go:244 +#: pkg/campsite/types/admin.go:448 msgid "Name must have at least one letter." msgstr "El nombre tiene que tener como mínimo una letra." -#: pkg/campsite/types/option.go:344 +#: pkg/campsite/types/option.go:354 msgid "Minimum can not be empty." msgstr "No podéis dejar el mínimo en blanco." -#: pkg/campsite/types/option.go:345 +#: pkg/campsite/types/option.go:355 msgid "Minimum must be an integer number." msgstr "El valor de mínimo tiene que ser un número entero." -#: pkg/campsite/types/option.go:347 +#: pkg/campsite/types/option.go:357 msgid "Minimum must be zero or greater." msgstr "El valor de mínimo tiene que ser como mínimo cero." -#: pkg/campsite/types/option.go:350 +#: pkg/campsite/types/option.go:360 msgid "Maximum can not be empty." msgstr "No podéis dejar el máxmimo en blanco." -#: pkg/campsite/types/option.go:351 +#: pkg/campsite/types/option.go:361 msgid "Maximum must be an integer number." msgstr "El valor del máximo tiene que ser un número entero." -#: pkg/campsite/types/option.go:353 +#: pkg/campsite/types/option.go:363 msgid "Maximum must be equal or greater than minimum." msgstr "El valor del máximo tiene que ser igual o mayor al del mínimo." -#: pkg/campsite/types/option.go:357 pkg/campsite/types/admin.go:429 +#: pkg/campsite/types/option.go:367 pkg/campsite/types/admin.go:461 msgid "Price per night can not be empty." msgstr "No podéis dejar el precio por noche en blanco." -#: pkg/campsite/types/option.go:358 pkg/campsite/types/admin.go:430 +#: pkg/campsite/types/option.go:368 pkg/campsite/types/admin.go:462 msgid "Price per night must be a decimal number." msgstr "El precio por noche tien que ser un número decimal." -#: pkg/campsite/types/option.go:359 pkg/campsite/types/admin.go:431 +#: pkg/campsite/types/option.go:369 pkg/campsite/types/admin.go:463 msgid "Price per night must be zero or greater." msgstr "El precio por noche tiene que ser como mínimo cero." @@ -1313,54 +1313,54 @@ msgstr "El precio por noche tiene que ser como mínimo cero." msgid "Selected icon is not valid." msgstr "El icono escogido no es válido." -#: pkg/campsite/types/admin.go:291 +#: pkg/campsite/types/admin.go:323 msgctxt "input" msgid "Cover image" msgstr "Imagen de portada" -#: pkg/campsite/types/admin.go:292 +#: pkg/campsite/types/admin.go:324 msgctxt "action" msgid "Set campsite type cover" msgstr "Establecer la portada del tipo de alojamiento" -#: pkg/campsite/types/admin.go:418 +#: pkg/campsite/types/admin.go:450 msgid "Cover image can not be empty." msgstr "No podéis dejar la imagen de portada en blanco." -#: pkg/campsite/types/admin.go:419 +#: pkg/campsite/types/admin.go:451 msgid "Cover image must be an image media type." msgstr "La imagen de portada tiene que ser un medio de tipo imagen." -#: pkg/campsite/types/admin.go:423 +#: pkg/campsite/types/admin.go:455 msgid "Maximum number of campers can not be empty." msgstr "No podéis dejar el número máximo de personas en blanco." -#: pkg/campsite/types/admin.go:424 +#: pkg/campsite/types/admin.go:456 msgid "Maximum number of campers must be an integer number." msgstr "El número máximo de personas tiene que ser entero." -#: pkg/campsite/types/admin.go:425 +#: pkg/campsite/types/admin.go:457 msgid "Maximum number of campers must be one or greater." msgstr "El número máximo de personas no puede ser cero." -#: pkg/campsite/types/admin.go:434 +#: pkg/campsite/types/admin.go:466 msgid "Minimum number of nights can not be empty." msgstr "No podéis dejar el número mínimo de noches en blanco." -#: pkg/campsite/types/admin.go:435 +#: pkg/campsite/types/admin.go:467 msgid "Minimum number of nights must be an integer." msgstr "El número mínimo de noches tiene que ser entero." -#: pkg/campsite/types/admin.go:436 +#: pkg/campsite/types/admin.go:468 msgid "Minimum number of nights must be one or greater." msgstr "El número mínimo de noches no puede ser cero." -#: pkg/campsite/types/public.go:157 +#: pkg/campsite/types/public.go:160 msgctxt "season" msgid "Closed" msgstr "Cerrado" -#: pkg/campsite/admin.go:226 pkg/booking/public.go:274 +#: pkg/campsite/admin.go:226 pkg/booking/public.go:278 msgid "Selected campsite type is not valid." msgstr "El tipo de alojamiento escogido no es válido." @@ -1368,96 +1368,96 @@ msgstr "El tipo de alojamiento escogido no es válido." msgid "Label can not be empty." msgstr "No podéis dejar la etiqueta en blanco." -#: pkg/season/admin.go:212 +#: pkg/season/admin.go:222 msgctxt "month" msgid "January" msgstr "enero" -#: pkg/season/admin.go:213 +#: pkg/season/admin.go:223 msgctxt "month" msgid "February" msgstr "febrero" -#: pkg/season/admin.go:214 +#: pkg/season/admin.go:224 msgctxt "month" msgid "March" msgstr "marzo" -#: pkg/season/admin.go:215 +#: pkg/season/admin.go:225 msgctxt "month" msgid "April" msgstr "abril" -#: pkg/season/admin.go:216 +#: pkg/season/admin.go:226 msgctxt "month" msgid "May" msgstr "mayo" -#: pkg/season/admin.go:217 +#: pkg/season/admin.go:227 msgctxt "month" msgid "June" msgstr "junio" -#: pkg/season/admin.go:218 +#: pkg/season/admin.go:228 msgctxt "month" msgid "July" msgstr "julio" -#: pkg/season/admin.go:219 +#: pkg/season/admin.go:229 msgctxt "month" msgid "August" msgstr "agosto" -#: pkg/season/admin.go:220 +#: pkg/season/admin.go:230 msgctxt "month" msgid "September" msgstr "septiembre" -#: pkg/season/admin.go:221 +#: pkg/season/admin.go:231 msgctxt "month" msgid "October" msgstr "octubre" -#: pkg/season/admin.go:222 +#: pkg/season/admin.go:232 msgctxt "month" msgid "November" msgstr "noviembre" -#: pkg/season/admin.go:223 +#: pkg/season/admin.go:233 msgctxt "month" msgid "December" msgstr "diciembre" -#: pkg/season/admin.go:395 +#: pkg/season/admin.go:405 msgid "Color can not be empty." msgstr "No podéis dejar el color en blanco." -#: pkg/season/admin.go:396 +#: pkg/season/admin.go:406 msgid "This color is not valid. It must be like #123abc." msgstr "Este color no es válido. Tiene que ser parecido a #123abc." -#: pkg/season/admin.go:472 +#: pkg/season/admin.go:506 msgctxt "action" msgid "Unset" msgstr "Desasignar" -#: pkg/season/admin.go:503 +#: pkg/season/admin.go:537 msgid "Start date can not be empty." msgstr "No podéis dejar la fecha de inicio en blanco." -#: pkg/season/admin.go:504 +#: pkg/season/admin.go:538 msgid "Start date must be a valid date." msgstr "La fecha de inicio tiene que ser una fecha válida." -#: pkg/season/admin.go:506 +#: pkg/season/admin.go:540 msgid "End date can not be empty." msgstr "No podéis dejar la fecha final en blanco." -#: pkg/season/admin.go:507 +#: pkg/season/admin.go:541 msgid "End date must be a valid date." msgstr "La fecha final tiene que ser una fecha válida." -#: pkg/company/admin.go:193 pkg/booking/public.go:252 +#: pkg/company/admin.go:193 pkg/booking/public.go:256 msgid "Selected country is not valid." msgstr "El país escogido no es válido." @@ -1477,11 +1477,11 @@ msgstr "No podéis dejar el NIF en blanco." msgid "This VAT number is not valid." msgstr "Este NIF no es válido." -#: pkg/company/admin.go:205 pkg/booking/public.go:268 +#: pkg/company/admin.go:205 pkg/booking/public.go:272 msgid "Phone can not be empty." msgstr "No podéis dejar el teléfono en blanco." -#: pkg/company/admin.go:206 pkg/booking/public.go:269 +#: pkg/company/admin.go:206 pkg/booking/public.go:273 msgid "This phone number is not valid." msgstr "Este teléfono no es válido." @@ -1505,7 +1505,7 @@ msgstr "No podéis dejar la provincia en blanco." msgid "Postal code can not be empty." msgstr "No podéis dejar el código postal en blanco." -#: pkg/company/admin.go:220 pkg/booking/public.go:261 +#: pkg/company/admin.go:220 pkg/booking/public.go:265 msgid "This postal code is not valid." msgstr "Este código postal no es válido." @@ -1585,54 +1585,54 @@ msgstr "La integración escogida no es válida." msgid "The merchant key is not valid." msgstr "Esta clave del comercio no es válida." -#: pkg/booking/public.go:256 +#: pkg/booking/public.go:260 msgid "Full name can not be empty." msgstr "No podéis dejar el nombre y los apellidos en blanco." -#: pkg/booking/public.go:257 +#: pkg/booking/public.go:261 msgid "Full name must have at least one letter." msgstr "El nombre y los apellidos tienen que tener como mínimo una letra." -#: pkg/booking/public.go:275 +#: pkg/booking/public.go:279 msgid "Arrival date can not be empty" msgstr "No podéis dejar la fecha de llegada en blanco." -#: pkg/booking/public.go:276 +#: pkg/booking/public.go:280 msgid "Arrival date must be a valid date." msgstr "La fecha de llegada tiene que ser una fecha válida." -#: pkg/booking/public.go:280 +#: pkg/booking/public.go:284 msgid "Departure date can not be empty" msgstr "No podéis dejar la fecha de partida en blanco." -#: pkg/booking/public.go:281 +#: pkg/booking/public.go:285 msgid "Departure date must be a valid date." msgstr "La fecha de partida tiene que ser una fecha válida." -#: pkg/booking/public.go:282 +#: pkg/booking/public.go:286 msgid "The departure date must be after the arrival date." msgstr "La fecha de partida tiene que ser posterior a la de llegada." -#: pkg/booking/public.go:285 +#: pkg/booking/public.go:289 msgid "It is mandatory to agree to the reservation conditions." msgstr "Es obligatorio aceptar las condiciones de reserva." -#: pkg/booking/public.go:288 +#: pkg/booking/public.go:292 #, c-format msgid "%s can not be empty" msgstr "No podéis dejar %s en blanco." -#: pkg/booking/public.go:289 +#: pkg/booking/public.go:293 #, c-format msgid "%s must be an integer." msgstr "%s tiene que ser un número entero." -#: pkg/booking/public.go:290 +#: pkg/booking/public.go:294 #, c-format msgid "%s must be %d or greater." msgstr "%s tiene que ser como mínimo %d." -#: pkg/booking/public.go:291 +#: pkg/booking/public.go:295 #, c-format msgid "%s must be at most %d." msgstr "%s tiene que ser como máximo %d" diff --git a/po/fr.po b/po/fr.po index 38db51d..4bba578 100644 --- a/po/fr.po +++ b/po/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: camper\n" "Report-Msgid-Bugs-To: jordi@tandem.blog\n" -"POT-Creation-Date: 2023-12-20 15:04+0100\n" +"POT-Creation-Date: 2023-12-20 19:48+0100\n" "PO-Revision-Date: 2023-12-20 10:13+0100\n" "Last-Translator: Oriol Carbonell \n" "Language-Team: French \n" @@ -45,7 +45,7 @@ msgstr "Le paiement a échoué" #: web/templates/public/services.gohtml:6 #: web/templates/public/services.gohtml:15 #: web/templates/public/layout.gohtml:44 web/templates/public/layout.gohtml:71 -#: web/templates/admin/services/index.gohtml:53 +#: web/templates/admin/services/index.gohtml:66 msgctxt "title" msgid "Services" msgstr "Services" @@ -137,7 +137,7 @@ msgid "*Minimum %d nights per stay" msgstr "*Minimum %d nuits par séjour" #: web/templates/public/campsite/type.gohtml:89 -#: web/templates/admin/season/index.gohtml:48 +#: web/templates/admin/season/index.gohtml:59 msgctxt "title" msgid "Calendar" msgstr "Calendrier" @@ -368,14 +368,14 @@ msgstr "J’ai lu et j’accepte les conditions de réservation" msgid "Campsite Montagut" msgstr "Camping Montagut" -#: web/templates/public/layout.gohtml:23 web/templates/admin/layout.gohtml:18 +#: web/templates/public/layout.gohtml:23 web/templates/admin/layout.gohtml:19 msgid "Skip to main content" msgstr "Passer au contenu principal" #: web/templates/public/layout.gohtml:35 web/templates/public/layout.gohtml:80 #: web/templates/admin/campsite/index.gohtml:6 #: web/templates/admin/campsite/index.gohtml:12 -#: web/templates/admin/layout.gohtml:43 web/templates/admin/layout.gohtml:74 +#: web/templates/admin/layout.gohtml:44 web/templates/admin/layout.gohtml:75 msgctxt "title" msgid "Campsites" msgstr "Camping" @@ -527,21 +527,21 @@ msgid "Add Feature" msgstr "Ajouter une fonctionnalité" #: web/templates/admin/campsite/feature/index.gohtml:17 -#: web/templates/admin/campsite/option/index.gohtml:17 -#: web/templates/admin/campsite/type/index.gohtml:17 -#: web/templates/admin/season/index.gohtml:18 +#: web/templates/admin/campsite/option/index.gohtml:25 +#: web/templates/admin/campsite/type/index.gohtml:25 +#: web/templates/admin/season/index.gohtml:26 msgctxt "header" msgid "Name" msgstr "Nom" #: web/templates/admin/campsite/feature/index.gohtml:18 -#: web/templates/admin/campsite/carousel/index.gohtml:19 -#: web/templates/admin/campsite/option/index.gohtml:18 -#: web/templates/admin/campsite/type/index.gohtml:18 -#: web/templates/admin/season/index.gohtml:19 -#: web/templates/admin/services/index.gohtml:19 -#: web/templates/admin/services/index.gohtml:60 -#: web/templates/admin/home/index.gohtml:19 +#: web/templates/admin/campsite/carousel/index.gohtml:27 +#: web/templates/admin/campsite/option/index.gohtml:26 +#: web/templates/admin/campsite/type/index.gohtml:26 +#: web/templates/admin/season/index.gohtml:27 +#: web/templates/admin/services/index.gohtml:27 +#: web/templates/admin/services/index.gohtml:73 +#: web/templates/admin/home/index.gohtml:27 msgctxt "header" msgid "Translations" msgstr "Traductions" @@ -581,45 +581,45 @@ msgctxt "action" msgid "Add slide" msgstr "Ajouter la diapositive" -#: web/templates/admin/campsite/carousel/index.gohtml:17 -#: web/templates/admin/services/index.gohtml:17 -#: web/templates/admin/home/index.gohtml:17 +#: web/templates/admin/campsite/carousel/index.gohtml:25 +#: web/templates/admin/services/index.gohtml:25 +#: web/templates/admin/home/index.gohtml:25 msgctxt "header" msgid "Image" msgstr "Image" -#: web/templates/admin/campsite/carousel/index.gohtml:18 -#: web/templates/admin/services/index.gohtml:18 -#: web/templates/admin/home/index.gohtml:18 +#: web/templates/admin/campsite/carousel/index.gohtml:26 +#: web/templates/admin/services/index.gohtml:26 +#: web/templates/admin/home/index.gohtml:26 msgctxt "header" msgid "Caption" msgstr "Légende" -#: web/templates/admin/campsite/carousel/index.gohtml:20 -#: web/templates/admin/services/index.gohtml:20 -#: web/templates/admin/services/index.gohtml:61 -#: web/templates/admin/home/index.gohtml:20 +#: web/templates/admin/campsite/carousel/index.gohtml:28 +#: web/templates/admin/services/index.gohtml:28 +#: web/templates/admin/services/index.gohtml:74 +#: web/templates/admin/home/index.gohtml:28 msgctxt "header" msgid "Actions" msgstr "Actions" -#: web/templates/admin/campsite/carousel/index.gohtml:24 -#: web/templates/admin/services/index.gohtml:24 -#: web/templates/admin/home/index.gohtml:24 +#: web/templates/admin/campsite/carousel/index.gohtml:32 +#: web/templates/admin/services/index.gohtml:32 +#: web/templates/admin/home/index.gohtml:32 msgid "Are you sure you wish to delete this slide?" msgstr "Êtes-vous sûr de vouloir supprimer cette diapositive ?" -#: web/templates/admin/campsite/carousel/index.gohtml:42 -#: web/templates/admin/services/index.gohtml:42 -#: web/templates/admin/services/index.gohtml:80 -#: web/templates/admin/home/index.gohtml:42 +#: web/templates/admin/campsite/carousel/index.gohtml:55 +#: web/templates/admin/services/index.gohtml:54 +#: web/templates/admin/services/index.gohtml:93 +#: web/templates/admin/home/index.gohtml:54 msgctxt "action" msgid "Delete" msgstr "Supprimer" -#: web/templates/admin/campsite/carousel/index.gohtml:50 -#: web/templates/admin/services/index.gohtml:50 -#: web/templates/admin/home/index.gohtml:50 +#: web/templates/admin/campsite/carousel/index.gohtml:64 +#: web/templates/admin/services/index.gohtml:63 +#: web/templates/admin/home/index.gohtml:63 msgid "No slides added yet." msgstr "Aucune diapositive n’a encore été ajoutée." @@ -700,7 +700,7 @@ msgctxt "action" msgid "Add Option" msgstr "Ajouter une option" -#: web/templates/admin/campsite/option/index.gohtml:39 +#: web/templates/admin/campsite/option/index.gohtml:52 msgid "No campsite type options added yet." msgstr "Aucune option de type de camping n’a encore été ajoutée." @@ -726,14 +726,14 @@ msgid "Type" msgstr "Type" #: web/templates/admin/campsite/index.gohtml:28 -#: web/templates/admin/campsite/type/index.gohtml:47 -#: web/templates/admin/season/index.gohtml:39 +#: web/templates/admin/campsite/type/index.gohtml:59 +#: web/templates/admin/season/index.gohtml:49 msgid "Yes" msgstr "Oui" #: web/templates/admin/campsite/index.gohtml:28 -#: web/templates/admin/campsite/type/index.gohtml:47 -#: web/templates/admin/season/index.gohtml:39 +#: web/templates/admin/campsite/type/index.gohtml:59 +#: web/templates/admin/season/index.gohtml:49 msgid "No" msgstr "Non" @@ -754,7 +754,7 @@ msgid "New Campsite Type" msgstr "Nouveau type d’emplacement de camping" #: web/templates/admin/campsite/type/form.gohtml:37 -#: web/templates/admin/campsite/type/index.gohtml:22 +#: web/templates/admin/campsite/type/index.gohtml:30 msgctxt "campsite type" msgid "Active" msgstr "Actif" @@ -802,7 +802,7 @@ msgstr "Description" #: web/templates/admin/campsite/type/index.gohtml:6 #: web/templates/admin/campsite/type/index.gohtml:12 -#: web/templates/admin/layout.gohtml:40 +#: web/templates/admin/layout.gohtml:41 msgctxt "title" msgid "Campsite Types" msgstr "Types d’emplacements de camping" @@ -812,37 +812,37 @@ msgctxt "action" msgid "Add Type" msgstr "Ajouter un type" -#: web/templates/admin/campsite/type/index.gohtml:19 +#: web/templates/admin/campsite/type/index.gohtml:27 msgctxt "header" msgid "Features" msgstr "Caractéristiques" -#: web/templates/admin/campsite/type/index.gohtml:20 +#: web/templates/admin/campsite/type/index.gohtml:28 msgctxt "header" msgid "Options" msgstr "Options" -#: web/templates/admin/campsite/type/index.gohtml:21 +#: web/templates/admin/campsite/type/index.gohtml:29 msgctxt "header" msgid "Carousel" msgstr "Carrousel" -#: web/templates/admin/campsite/type/index.gohtml:39 +#: web/templates/admin/campsite/type/index.gohtml:51 msgctxt "action" msgid "Edit Features" msgstr "Edit Caractéristiques" -#: web/templates/admin/campsite/type/index.gohtml:42 +#: web/templates/admin/campsite/type/index.gohtml:54 msgctxt "action" msgid "Edit Options" msgstr "Modifier les options" -#: web/templates/admin/campsite/type/index.gohtml:45 +#: web/templates/admin/campsite/type/index.gohtml:57 msgctxt "action" msgid "Edit Carousel" msgstr "Modifier le carrousel" -#: web/templates/admin/campsite/type/index.gohtml:53 +#: web/templates/admin/campsite/type/index.gohtml:66 msgid "No campsite types added yet." msgstr "Aucun type d’emplacement n’a encore été ajouté." @@ -865,7 +865,7 @@ msgid "New Season" msgstr "Nouvelle saison" #: web/templates/admin/season/form.gohtml:37 -#: web/templates/admin/season/index.gohtml:20 +#: web/templates/admin/season/index.gohtml:28 msgctxt "season" msgid "Active" msgstr "Actif" @@ -877,7 +877,7 @@ msgstr "Couleur" #: web/templates/admin/season/index.gohtml:6 #: web/templates/admin/season/index.gohtml:12 -#: web/templates/admin/layout.gohtml:46 +#: web/templates/admin/layout.gohtml:47 msgctxt "title" msgid "Seasons" msgstr "Saisons" @@ -887,12 +887,12 @@ msgctxt "action" msgid "Add Season" msgstr "Ajouter une saison" -#: web/templates/admin/season/index.gohtml:17 +#: web/templates/admin/season/index.gohtml:25 msgctxt "header" msgid "Color" msgstr "Couleur" -#: web/templates/admin/season/index.gohtml:45 +#: web/templates/admin/season/index.gohtml:56 msgid "No seasons added yet." msgstr "Aucune saison n’a encore été ajoutée." @@ -909,7 +909,7 @@ msgid "Cancel" msgstr "Annuler" #: web/templates/admin/payment.gohtml:6 web/templates/admin/payment.gohtml:12 -#: web/templates/admin/layout.gohtml:37 +#: web/templates/admin/layout.gohtml:38 msgctxt "title" msgid "Payment Settings" msgstr "Paramètres de paiement" @@ -951,7 +951,7 @@ msgid "Save changes" msgstr "Enregistrer les changements" #: web/templates/admin/dashboard.gohtml:6 -#: web/templates/admin/dashboard.gohtml:10 web/templates/admin/layout.gohtml:71 +#: web/templates/admin/dashboard.gohtml:10 web/templates/admin/layout.gohtml:72 msgctxt "title" msgid "Dashboard" msgstr "Tableau de bord" @@ -984,7 +984,7 @@ msgid "New Service" msgstr "Nouveau service" #: web/templates/admin/services/index.gohtml:6 -#: web/templates/admin/layout.gohtml:55 +#: web/templates/admin/layout.gohtml:56 msgctxt "title" msgid "Services Page" msgstr "La page des services" @@ -995,21 +995,21 @@ msgctxt "title" msgid "Carousel" msgstr "Carrousel" -#: web/templates/admin/services/index.gohtml:54 +#: web/templates/admin/services/index.gohtml:67 msgctxt "action" msgid "Add service" msgstr "Ajouter un service" -#: web/templates/admin/services/index.gohtml:59 +#: web/templates/admin/services/index.gohtml:72 msgctxt "header" msgid "Service" msgstr "Service" -#: web/templates/admin/services/index.gohtml:65 +#: web/templates/admin/services/index.gohtml:78 msgid "Are you sure you wish to delete this service?" msgstr "Êtes-vous sûr de vouloir supprimer ce service ?" -#: web/templates/admin/services/index.gohtml:88 +#: web/templates/admin/services/index.gohtml:101 msgid "No services added yet." msgstr "Aucun service n’a encore été ajouté." @@ -1020,7 +1020,7 @@ msgid "Translate Service to %s" msgstr "Traduire le service en %s" #: web/templates/admin/profile.gohtml:6 web/templates/admin/profile.gohtml:12 -#: web/templates/admin/layout.gohtml:30 +#: web/templates/admin/layout.gohtml:31 msgctxt "title" msgid "Profile" msgstr "Profil" @@ -1112,29 +1112,29 @@ msgctxt "input" msgid "Legal Disclaimer" msgstr "Avertissement juridique" -#: web/templates/admin/layout.gohtml:26 +#: web/templates/admin/layout.gohtml:27 msgctxt "title" msgid "User Menu" msgstr "Menu utilisateur" -#: web/templates/admin/layout.gohtml:34 +#: web/templates/admin/layout.gohtml:35 msgctxt "title" msgid "Company Settings" msgstr "Paramètres de l'entreprise" -#: web/templates/admin/layout.gohtml:49 +#: web/templates/admin/layout.gohtml:50 #: web/templates/admin/media/index.gohtml:6 #: web/templates/admin/media/index.gohtml:11 msgctxt "title" msgid "Media" msgstr "Média" -#: web/templates/admin/layout.gohtml:52 web/templates/admin/home/index.gohtml:6 +#: web/templates/admin/layout.gohtml:53 web/templates/admin/home/index.gohtml:6 msgctxt "title" msgid "Home Page" msgstr "Page d'accueil" -#: web/templates/admin/layout.gohtml:60 +#: web/templates/admin/layout.gohtml:61 msgctxt "action" msgid "Logout" msgstr "Déconnexion" @@ -1204,31 +1204,31 @@ msgctxt "title" msgid "Upload Media" msgstr "Envoyer un fichier" -#: pkg/carousel/admin.go:234 pkg/campsite/types/carousel.go:233 +#: pkg/carousel/admin.go:274 pkg/campsite/types/carousel.go:242 msgctxt "input" msgid "Slide image" msgstr "Image du diaporama" -#: pkg/carousel/admin.go:235 pkg/campsite/types/carousel.go:234 +#: pkg/carousel/admin.go:275 pkg/campsite/types/carousel.go:243 msgctxt "action" msgid "Set slide image" msgstr "Définir l’image de la diapositive" -#: pkg/carousel/admin.go:287 pkg/campsite/types/carousel.go:288 +#: pkg/carousel/admin.go:327 pkg/campsite/types/carousel.go:297 msgid "Slide image can not be empty." msgstr "L’image de la diapositive ne peut pas être vide." -#: pkg/carousel/admin.go:288 pkg/campsite/types/carousel.go:289 +#: pkg/carousel/admin.go:328 pkg/campsite/types/carousel.go:298 msgid "Slide image must be an image media type." msgstr "L’image de la diapositive doit être de type média d’image." #: pkg/app/login.go:56 pkg/app/user.go:246 pkg/company/admin.go:210 -#: pkg/booking/public.go:265 +#: pkg/booking/public.go:269 msgid "Email can not be empty." msgstr "L’e-mail ne peut pas être vide." #: pkg/app/login.go:57 pkg/app/user.go:247 pkg/company/admin.go:211 -#: pkg/booking/public.go:266 +#: pkg/booking/public.go:270 msgid "This email is not valid. It should be like name@domain.com." msgstr "Cette adresse e-mail n’est pas valide. Il devrait en être name@domain.com." @@ -1247,9 +1247,9 @@ msgstr "Automatique" #: pkg/app/user.go:249 pkg/campsite/types/l10n.go:87 #: pkg/campsite/types/l10n.go:144 pkg/campsite/types/l10n.go:268 -#: pkg/campsite/types/option.go:341 pkg/campsite/types/feature.go:243 -#: pkg/campsite/types/admin.go:416 pkg/season/l10n.go:69 -#: pkg/season/admin.go:395 pkg/services/l10n.go:73 pkg/services/admin.go:266 +#: pkg/campsite/types/option.go:350 pkg/campsite/types/feature.go:243 +#: pkg/campsite/types/admin.go:447 pkg/season/l10n.go:69 +#: pkg/season/admin.go:404 pkg/services/l10n.go:73 pkg/services/admin.go:266 msgid "Name can not be empty." msgstr "Le nom ne peut pas être laissé vide." @@ -1269,44 +1269,44 @@ msgstr "Le fichier doit être une image PNG ou JPEG valide." msgid "Access forbidden" msgstr "Accès interdit" -#: pkg/campsite/types/option.go:342 pkg/campsite/types/feature.go:244 -#: pkg/campsite/types/admin.go:417 +#: pkg/campsite/types/option.go:351 pkg/campsite/types/feature.go:244 +#: pkg/campsite/types/admin.go:448 msgid "Name must have at least one letter." msgstr "Le nom doit comporter au moins une lettre." -#: pkg/campsite/types/option.go:345 +#: pkg/campsite/types/option.go:354 msgid "Minimum can not be empty." msgstr "Le minimum ne peut pas être vide." -#: pkg/campsite/types/option.go:346 +#: pkg/campsite/types/option.go:355 msgid "Minimum must be an integer number." msgstr "Le minimum doit être un nombre entier." -#: pkg/campsite/types/option.go:348 +#: pkg/campsite/types/option.go:357 msgid "Minimum must be zero or greater." msgstr "Le minimum doit être égal ou supérieur à zéro." -#: pkg/campsite/types/option.go:351 +#: pkg/campsite/types/option.go:360 msgid "Maximum can not be empty." msgstr "Le maximum ne peut pas être vide." -#: pkg/campsite/types/option.go:352 +#: pkg/campsite/types/option.go:361 msgid "Maximum must be an integer number." msgstr "Le maximum doit être un nombre entier." -#: pkg/campsite/types/option.go:354 +#: pkg/campsite/types/option.go:363 msgid "Maximum must be equal or greater than minimum." msgstr "Le maximum doit être égal ou supérieur au minimum." -#: pkg/campsite/types/option.go:358 pkg/campsite/types/admin.go:430 +#: pkg/campsite/types/option.go:367 pkg/campsite/types/admin.go:461 msgid "Price per night can not be empty." msgstr "Le prix par nuit ne peut pas être vide." -#: pkg/campsite/types/option.go:359 pkg/campsite/types/admin.go:431 +#: pkg/campsite/types/option.go:368 pkg/campsite/types/admin.go:462 msgid "Price per night must be a decimal number." msgstr "Le prix par nuit doit être un nombre décimal." -#: pkg/campsite/types/option.go:360 pkg/campsite/types/admin.go:432 +#: pkg/campsite/types/option.go:369 pkg/campsite/types/admin.go:463 msgid "Price per night must be zero or greater." msgstr "Le prix par nuit doit être égal ou supérieur." @@ -1314,54 +1314,54 @@ msgstr "Le prix par nuit doit être égal ou supérieur." msgid "Selected icon is not valid." msgstr "L’icône sélectionnée n’est pas valide." -#: pkg/campsite/types/admin.go:292 +#: pkg/campsite/types/admin.go:323 msgctxt "input" msgid "Cover image" msgstr "Image de couverture" -#: pkg/campsite/types/admin.go:293 +#: pkg/campsite/types/admin.go:324 msgctxt "action" msgid "Set campsite type cover" msgstr "Définir une couverture type camping" -#: pkg/campsite/types/admin.go:419 +#: pkg/campsite/types/admin.go:450 msgid "Cover image can not be empty." msgstr "L’image de couverture ne peut pas être vide." -#: pkg/campsite/types/admin.go:420 +#: pkg/campsite/types/admin.go:451 msgid "Cover image must be an image media type." msgstr "L’image de couverture doit être de type média d’image." -#: pkg/campsite/types/admin.go:424 +#: pkg/campsite/types/admin.go:455 msgid "Maximum number of campers can not be empty." msgstr "Le nombre maximum de campeurs ne peut pas être vide." -#: pkg/campsite/types/admin.go:425 +#: pkg/campsite/types/admin.go:456 msgid "Maximum number of campers must be an integer number." msgstr "Le nombre maximum de campeurs doit être un nombre entier." -#: pkg/campsite/types/admin.go:426 +#: pkg/campsite/types/admin.go:457 msgid "Maximum number of campers must be one or greater." msgstr "Le nombre maximum de campeurs doit être égal ou supérieur à un campeur." -#: pkg/campsite/types/admin.go:435 +#: pkg/campsite/types/admin.go:466 msgid "Minimum number of nights can not be empty." msgstr "Le nombre minimum de nuits ne peut pas être vide." -#: pkg/campsite/types/admin.go:436 +#: pkg/campsite/types/admin.go:467 msgid "Minimum number of nights must be an integer." msgstr "Le nombre minimum de nuits doit être un entier." -#: pkg/campsite/types/admin.go:437 +#: pkg/campsite/types/admin.go:468 msgid "Minimum number of nights must be one or greater." msgstr "Le nombre minimum de nuits doit être supérieur ou égal à une nuit." -#: pkg/campsite/types/public.go:157 +#: pkg/campsite/types/public.go:160 msgctxt "season" msgid "Closed" msgstr "Fermé" -#: pkg/campsite/admin.go:226 pkg/booking/public.go:274 +#: pkg/campsite/admin.go:226 pkg/booking/public.go:278 msgid "Selected campsite type is not valid." msgstr "Le type d’emplacement sélectionné n’est pas valide." @@ -1369,96 +1369,96 @@ msgstr "Le type d’emplacement sélectionné n’est pas valide." msgid "Label can not be empty." msgstr "L'étiquette ne peut pas être vide." -#: pkg/season/admin.go:213 +#: pkg/season/admin.go:222 msgctxt "month" msgid "January" msgstr "Janvier" -#: pkg/season/admin.go:214 +#: pkg/season/admin.go:223 msgctxt "month" msgid "February" msgstr "Février" -#: pkg/season/admin.go:215 +#: pkg/season/admin.go:224 msgctxt "month" msgid "March" msgstr "Mars" -#: pkg/season/admin.go:216 +#: pkg/season/admin.go:225 msgctxt "month" msgid "April" msgstr "Avril" -#: pkg/season/admin.go:217 +#: pkg/season/admin.go:226 msgctxt "month" msgid "May" msgstr "Mai" -#: pkg/season/admin.go:218 +#: pkg/season/admin.go:227 msgctxt "month" msgid "June" msgstr "Juin" -#: pkg/season/admin.go:219 +#: pkg/season/admin.go:228 msgctxt "month" msgid "July" msgstr "Juillet" -#: pkg/season/admin.go:220 +#: pkg/season/admin.go:229 msgctxt "month" msgid "August" msgstr "Août" -#: pkg/season/admin.go:221 +#: pkg/season/admin.go:230 msgctxt "month" msgid "September" msgstr "Septembre" -#: pkg/season/admin.go:222 +#: pkg/season/admin.go:231 msgctxt "month" msgid "October" msgstr "Octobre" -#: pkg/season/admin.go:223 +#: pkg/season/admin.go:232 msgctxt "month" msgid "November" msgstr "Novembre" -#: pkg/season/admin.go:224 +#: pkg/season/admin.go:233 msgctxt "month" msgid "December" msgstr "Décembre" -#: pkg/season/admin.go:396 +#: pkg/season/admin.go:405 msgid "Color can not be empty." msgstr "La couleur ne peut pas être vide." -#: pkg/season/admin.go:397 +#: pkg/season/admin.go:406 msgid "This color is not valid. It must be like #123abc." msgstr "Cette couleur n’est pas valide. Il doit être comme #123abc." -#: pkg/season/admin.go:473 +#: pkg/season/admin.go:506 msgctxt "action" msgid "Unset" msgstr "Unset" -#: pkg/season/admin.go:504 +#: pkg/season/admin.go:537 msgid "Start date can not be empty." msgstr "La date de début ne peut pas être vide." -#: pkg/season/admin.go:505 +#: pkg/season/admin.go:538 msgid "Start date must be a valid date." msgstr "La date de début doit être une date valide." -#: pkg/season/admin.go:507 +#: pkg/season/admin.go:540 msgid "End date can not be empty." msgstr "La date de fin ne peut pas être vide." -#: pkg/season/admin.go:508 +#: pkg/season/admin.go:541 msgid "End date must be a valid date." msgstr "La date de fin doit être une date valide." -#: pkg/company/admin.go:193 pkg/booking/public.go:252 +#: pkg/company/admin.go:193 pkg/booking/public.go:256 msgid "Selected country is not valid." msgstr "Le pays sélectionné n’est pas valide." @@ -1478,11 +1478,11 @@ msgstr "Le numéro de TVA ne peut pas être vide." msgid "This VAT number is not valid." msgstr "Ce numéro de TVA n’est pas valide." -#: pkg/company/admin.go:205 pkg/booking/public.go:268 +#: pkg/company/admin.go:205 pkg/booking/public.go:272 msgid "Phone can not be empty." msgstr "Le téléphone ne peut pas être vide." -#: pkg/company/admin.go:206 pkg/booking/public.go:269 +#: pkg/company/admin.go:206 pkg/booking/public.go:273 msgid "This phone number is not valid." msgstr "Ce numéro de téléphone n’est pas valide." @@ -1506,7 +1506,7 @@ msgstr "La province ne peut pas être vide." msgid "Postal code can not be empty." msgstr "Le code postal ne peut pas être vide." -#: pkg/company/admin.go:220 pkg/booking/public.go:261 +#: pkg/company/admin.go:220 pkg/booking/public.go:265 msgid "This postal code is not valid." msgstr "Ce code postal n’est pas valide." @@ -1586,54 +1586,54 @@ msgstr "L’intégration sélectionnée n’est pas valide." msgid "The merchant key is not valid." msgstr "La clé marchand n’est pas valide." -#: pkg/booking/public.go:256 +#: pkg/booking/public.go:260 msgid "Full name can not be empty." msgstr "Le nom complet ne peut pas être vide." -#: pkg/booking/public.go:257 +#: pkg/booking/public.go:261 msgid "Full name must have at least one letter." msgstr "Le nom complet doit comporter au moins une lettre." -#: pkg/booking/public.go:275 +#: pkg/booking/public.go:279 msgid "Arrival date can not be empty" msgstr "La date d’arrivée ne peut pas être vide" -#: pkg/booking/public.go:276 +#: pkg/booking/public.go:280 msgid "Arrival date must be a valid date." msgstr "La date d’arrivée doit être une date valide." -#: pkg/booking/public.go:280 +#: pkg/booking/public.go:284 msgid "Departure date can not be empty" msgstr "La date de départ ne peut pas être vide" -#: pkg/booking/public.go:281 +#: pkg/booking/public.go:285 msgid "Departure date must be a valid date." msgstr "La date de départ doit être une date valide." -#: pkg/booking/public.go:282 +#: pkg/booking/public.go:286 msgid "The departure date must be after the arrival date." msgstr "La date de départ doit être postérieure à la date d’arrivée." -#: pkg/booking/public.go:285 +#: pkg/booking/public.go:289 msgid "It is mandatory to agree to the reservation conditions." msgstr "Il est obligatoire d’accepter les conditions de réservation." -#: pkg/booking/public.go:288 +#: pkg/booking/public.go:292 #, c-format msgid "%s can not be empty" msgstr "%s ne peut pas être vide" -#: pkg/booking/public.go:289 +#: pkg/booking/public.go:293 #, c-format msgid "%s must be an integer." msgstr "%s doit être un entier." -#: pkg/booking/public.go:290 +#: pkg/booking/public.go:294 #, c-format msgid "%s must be %d or greater." msgstr "%s doit être %d ou plus." -#: pkg/booking/public.go:291 +#: pkg/booking/public.go:295 #, c-format msgid "%s must be at most %d." msgstr "%s doit être tout au plus %d." diff --git a/revert/order_campsite_type_carousel.sql b/revert/order_campsite_type_carousel.sql new file mode 100644 index 0000000..e0c9b46 --- /dev/null +++ b/revert/order_campsite_type_carousel.sql @@ -0,0 +1,7 @@ +-- Revert camper:order_campsite_type_carousel from pg + +begin; + +drop function if exists camper.order_campsite_type_carousel(uuid, integer[]); + +commit; diff --git a/revert/order_campsite_type_options.sql b/revert/order_campsite_type_options.sql new file mode 100644 index 0000000..05cdbd1 --- /dev/null +++ b/revert/order_campsite_type_options.sql @@ -0,0 +1,7 @@ +-- Revert camper:order_campsite_type_options from pg + +begin; + +drop function if exists camper.order_campsite_type_options(integer[]); + +commit; diff --git a/revert/order_campsite_types.sql b/revert/order_campsite_types.sql new file mode 100644 index 0000000..0316aef --- /dev/null +++ b/revert/order_campsite_types.sql @@ -0,0 +1,7 @@ +-- Revert camper:order_campsite_types from pg + +begin; + +drop function if exists camper.order_campsite_types(uuid[]); + +commit; diff --git a/revert/order_home_carousel.sql b/revert/order_home_carousel.sql new file mode 100644 index 0000000..193c897 --- /dev/null +++ b/revert/order_home_carousel.sql @@ -0,0 +1,7 @@ +-- Revert camper:order_home_carousel from pg + +begin; + +drop function if exists camper.order_home_carousel(integer[]); + +commit; diff --git a/revert/order_seasons.sql b/revert/order_seasons.sql new file mode 100644 index 0000000..87baa22 --- /dev/null +++ b/revert/order_seasons.sql @@ -0,0 +1,7 @@ +-- Revert camper:order_seasons from pg + +begin; + +drop function if exists camper.order_seasons(uuid[]); + +commit; diff --git a/revert/order_services_carousel.sql b/revert/order_services_carousel.sql new file mode 100644 index 0000000..3bacfef --- /dev/null +++ b/revert/order_services_carousel.sql @@ -0,0 +1,7 @@ +-- Revert camper:order_services_carousel from pg + +begin; + +drop function if exists camper.order_services_carousel(integer[]); + +commit; diff --git a/sqitch.plan b/sqitch.plan index c7c1b7c..aa6b070 100644 --- a/sqitch.plan +++ b/sqitch.plan @@ -119,3 +119,9 @@ zero_pad [roles schema_camper] 2023-10-26T19:57:00Z jordi fita mas # Add function to encrypt data with Redsys’ encrypt key encode_base64url [roles schema_camper] 2023-10-26T21:00:47Z jordi fita mas # Add function to encode bytea the so-called base64url redsys_sign_request [roles extension_pgcrypto schema_camper encode_base64url redsys_encrypt redsys_request redsys_signed_request company currency language] 2023-10-26T21:12:01Z jordi fita mas # Add the function that signs Redsys requests +order_campsite_types [schema_camper roles campsite_type] 2023-12-20T15:56:34Z jordi fita mas # Add function to order campsite types +order_seasons [schema_camper roles season] 2023-12-20T16:56:54Z jordi fita mas # Add function to order seasons +order_campsite_type_options [schema_camper roles campsite_type_option] 2023-12-20T17:25:09Z jordi fita mas # Add function to order campsite type options +order_campsite_type_carousel [schema_camper roles campsite_type campsite_type_carousel] 2023-12-20T17:59:54Z jordi fita mas # Add function to order campsite type carousel +order_home_carousel [schema_camper roles home_carousel] 2023-12-20T18:30:12Z jordi fita mas # Add function to order home carousel +order_services_carousel [schema_camper roles services_carousel] 2023-12-20T18:39:18Z jordi fita mas # Add function to order services carousel diff --git a/test/campsite_type.sql b/test/campsite_type.sql index 9917a02..6dd9575 100644 --- a/test/campsite_type.sql +++ b/test/campsite_type.sql @@ -5,7 +5,7 @@ reset client_min_messages; begin; -select plan(77); +select plan(82); set search_path to camper, public; @@ -88,6 +88,12 @@ select col_not_null('campsite_type', 'active'); select col_has_default('campsite_type', 'active'); select col_default_is('campsite_type', 'active', 'true'); +select has_column('campsite_type', 'position'); +select col_type_is('campsite_type', 'position', 'integer'); +select col_not_null('campsite_type', 'position'); +select col_has_default('campsite_type', 'position'); +select col_default_is('campsite_type', 'position', '2147483647'); + set client_min_messages to warning; truncate campsite_type cascade; diff --git a/test/campsite_type_carousel.sql b/test/campsite_type_carousel.sql index cb695ee..1b9f24b 100644 --- a/test/campsite_type_carousel.sql +++ b/test/campsite_type_carousel.sql @@ -5,7 +5,7 @@ reset client_min_messages; begin; -select plan(40); +select plan(45); set search_path to camper, public; @@ -36,6 +36,12 @@ select col_type_is('campsite_type_carousel', 'caption', 'text'); select col_not_null('campsite_type_carousel', 'caption'); select col_hasnt_default('campsite_type_carousel', 'caption'); +select has_column('campsite_type_carousel', 'position'); +select col_type_is('campsite_type_carousel', 'position', 'integer'); +select col_not_null('campsite_type_carousel', 'position'); +select col_has_default('campsite_type_carousel', 'position'); +select col_default_is('campsite_type_carousel', 'position', '2147483647'); + set client_min_messages to warning; truncate campsite_type_carousel cascade; diff --git a/test/campsite_type_option.sql b/test/campsite_type_option.sql index 22cf0f9..57ba290 100644 --- a/test/campsite_type_option.sql +++ b/test/campsite_type_option.sql @@ -5,7 +5,7 @@ reset client_min_messages; begin; -select plan(40); +select plan(45); set search_path to camper, public; @@ -39,6 +39,12 @@ select col_type_is('campsite_type_option', 'range', 'int4range'); select col_not_null('campsite_type_option', 'range'); select col_hasnt_default('campsite_type_option', 'range'); +select has_column('campsite_type_option', 'position'); +select col_type_is('campsite_type_option', 'position', 'integer'); +select col_not_null('campsite_type_option', 'position'); +select col_has_default('campsite_type_option', 'position'); +select col_default_is('campsite_type_option', 'position', '2147483647'); + set client_min_messages to warning; truncate campsite_type_option cascade; diff --git a/test/home_carousel.sql b/test/home_carousel.sql index 25524d3..fccd78f 100644 --- a/test/home_carousel.sql +++ b/test/home_carousel.sql @@ -5,7 +5,7 @@ reset client_min_messages; begin; -select plan(30); +select plan(35); set search_path to camper, public; @@ -29,6 +29,12 @@ select col_type_is('home_carousel', 'caption', 'text'); select col_not_null('home_carousel', 'caption'); select col_hasnt_default('home_carousel', 'caption'); +select has_column('home_carousel', 'position'); +select col_type_is('home_carousel', 'position', 'integer'); +select col_not_null('home_carousel', 'position'); +select col_has_default('home_carousel', 'position'); +select col_default_is('home_carousel', 'position', '2147483647'); + set client_min_messages to warning; truncate home_carousel cascade; truncate media cascade; diff --git a/test/order_campsite_type_carousel.sql b/test/order_campsite_type_carousel.sql new file mode 100644 index 0000000..de654b0 --- /dev/null +++ b/test/order_campsite_type_carousel.sql @@ -0,0 +1,87 @@ +-- Test order_campsite_type_carousel +set client_min_messages to warning; +create extension if not exists pgtap; +reset client_min_messages; + +begin; + +select plan(11); + +set search_path to camper, public; + +select has_function('camper', 'order_campsite_type_carousel', array['uuid', 'integer[]']); +select function_lang_is('camper', 'order_campsite_type_carousel', array['uuid', 'integer[]'], 'sql'); +select function_returns('camper', 'order_campsite_type_carousel', array['uuid', 'integer[]'], 'void'); +select isnt_definer('camper', 'order_campsite_type_carousel', array['uuid', 'integer[]']); +select volatility_is('camper', 'order_campsite_type_carousel', array['uuid', 'integer[]'], 'volatile'); +select function_privs_are('camper', 'order_campsite_type_carousel', array ['uuid', 'integer[]'], 'guest', array[]::text[]); +select function_privs_are('camper', 'order_campsite_type_carousel', array ['uuid', 'integer[]'], 'employee', array[]::text[]); +select function_privs_are('camper', 'order_campsite_type_carousel', array ['uuid', 'integer[]'], 'admin', array['EXECUTE']); +select function_privs_are('camper', 'order_campsite_type_carousel', array ['uuid', 'integer[]'], 'authenticator', array[]::text[]); + + +set client_min_messages to warning; +truncate campsite_type_carousel_i18n cascade; +truncate campsite_type_carousel cascade; +truncate campsite_type cascade; +truncate media cascade; +truncate media_content cascade; +truncate company cascade; +reset client_min_messages; + + +insert into company (company_id, business_name, vatin, trade_name, phone, email, web, address, city, province, postal_code, rtc_number, country_code, currency_code, default_lang_tag) +values (1, 'Company 2', 'XX123', '', '555-555-555', 'a@a', '', '', '', '', '', '', 'ES', 'EUR', 'ca') +; + +insert into media_content (media_type, bytes) +values ('image/x-xpixmap', 'static char *s[]={"1 1 1 1","a c #ffffff","a"};') + , ('image/x-xpixmap', 'static char *s[]={"1 1 1 1","a c #ff00ff","a"};') + , ('image/x-xpixmap', 'static char *s[]={"1 1 1 1","a c #ffff00","a"};') + , ('text/plain', 'hello, world!') + , ('image/svg+xml', '') +; + +insert into media (media_id, company_id, original_filename, content_hash) +values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) + , (3, 1, 'cover3.xpm', sha256('static char *s[]={"1 1 1 1","a c #ff00ff","a"};')) + , (4, 1, 'cover4.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffff00","a"};')) + , (5, 1, 'text.txt', sha256('hello, world!')) + , (6, 1, 'image.svg', sha256('')) +; + +insert into campsite_type (campsite_type_id, company_id, slug, media_id, name, description, max_campers, dogs_allowed, active) +values (10, 1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'Type A', '

A

', 5, false, true) + , (11, 1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 3, 'Type B', '

B

', 4, true, false) +; + +insert into campsite_type_carousel (campsite_type_id, media_id, caption) +values (10, 4, 'A caption') + , (11, 2, '1') + , (11, 3, '2') + , (11, 4, '3') + , (11, 5, '4') + , (11, 6, '5') +; + +select lives_ok( + $$ select order_campsite_type_carousel('9b6370f7-f941-46f2-bc6e-de455675bd0a', '{4,6,5,2,3}') $$, + 'Should be able to sort campsite type slides using their ID' +); + +select bag_eq( + $$ select campsite_type_id, media_id, position from campsite_type_carousel $$, + $$ values (10, 4, 2147483647) + , (11, 4, 1) + , (11, 6, 2) + , (11, 5, 3) + , (11, 2, 4) + , (11, 3, 5) + $$, + 'Should have sorted all campsite type slides.' +); + +select * +from finish(); + +rollback; diff --git a/test/order_campsite_type_options.sql b/test/order_campsite_type_options.sql new file mode 100644 index 0000000..8663923 --- /dev/null +++ b/test/order_campsite_type_options.sql @@ -0,0 +1,76 @@ +-- Test order_campsite_type_options +set client_min_messages to warning; +create extension if not exists pgtap; +reset client_min_messages; + +begin; + +select plan(11); + +set search_path to camper, public; + +select has_function('camper', 'order_campsite_type_options', array['integer[]']); +select function_lang_is('camper', 'order_campsite_type_options', array['integer[]'], 'sql'); +select function_returns('camper', 'order_campsite_type_options', array['integer[]'], 'void'); +select isnt_definer('camper', 'order_campsite_type_options', array['integer[]']); +select volatility_is('camper', 'order_campsite_type_options', array['integer[]'], 'volatile'); +select function_privs_are('camper', 'order_campsite_type_options', array ['integer[]'], 'guest', array[]::text[]); +select function_privs_are('camper', 'order_campsite_type_options', array ['integer[]'], 'employee', array[]::text[]); +select function_privs_are('camper', 'order_campsite_type_options', array ['integer[]'], 'admin', array['EXECUTE']); +select function_privs_are('camper', 'order_campsite_type_options', array ['integer[]'], 'authenticator', array[]::text[]); + + +set client_min_messages to warning; +truncate campsite_type_option_i18n cascade; +truncate campsite_type_option cascade; +truncate campsite_type cascade; +truncate media cascade; +truncate media_content cascade; +truncate company cascade; +reset client_min_messages; + + +insert into company (company_id, business_name, vatin, trade_name, phone, email, web, address, city, province, postal_code, rtc_number, country_code, currency_code, default_lang_tag) +values (1, 'Company 2', 'XX123', '', '555-555-555', 'a@a', '', '', '', '', '', '', 'ES', 'EUR', 'ca') +; + +insert into media_content (media_type, bytes) +values ('image/x-xpixmap', 'static char *s[]={"1 1 1 1","a c #ffffff","a"};') +; + +insert into media (media_id, company_id, original_filename, content_hash) +values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) +; + +insert into campsite_type (campsite_type_id, company_id, media_id, name, description, active, dogs_allowed, max_campers) +values (3, 1, 2, 'Type A', '

A

', true, false, 4) +; + +insert into campsite_type_option (campsite_type_option_id, campsite_type_id, name, range) +values (4, 3, '1', '[0, 10]') + , (5, 3, '2', '[0, 10]') + , (6, 3, '3', '[0, 10]') + , (7, 3, '4', '[0, 10]') + , (8, 3, '5', '[0, 10]') +; + +select lives_ok( + $$ select order_campsite_type_options('{6,8,7,4,5}') $$, + 'Should be able to sort campsite type options using their ID' +); + +select bag_eq( + $$ select campsite_type_option_id, position from campsite_type_option $$, + $$ values (6, 1) + , (8, 2) + , (7, 3) + , (4, 4) + , (5, 5) + $$, + 'Should have sorted all campsite type options.' +); + +select * +from finish(); + +rollback; diff --git a/test/order_campsite_types.sql b/test/order_campsite_types.sql new file mode 100644 index 0000000..a438323 --- /dev/null +++ b/test/order_campsite_types.sql @@ -0,0 +1,70 @@ +-- Test order_campsite_types +set client_min_messages to warning; +create extension if not exists pgtap; +reset client_min_messages; + +begin; + +select plan(11); + +set search_path to camper, public; + +select has_function('camper', 'order_campsite_types', array['uuid[]']); +select function_lang_is('camper', 'order_campsite_types', array['uuid[]'], 'sql'); +select function_returns('camper', 'order_campsite_types', array['uuid[]'], 'void'); +select isnt_definer('camper', 'order_campsite_types', array['uuid[]']); +select volatility_is('camper', 'order_campsite_types', array['uuid[]'], 'volatile'); +select function_privs_are('camper', 'order_campsite_types', array ['uuid[]'], 'guest', array[]::text[]); +select function_privs_are('camper', 'order_campsite_types', array ['uuid[]'], 'employee', array[]::text[]); +select function_privs_are('camper', 'order_campsite_types', array ['uuid[]'], 'admin', array['EXECUTE']); +select function_privs_are('camper', 'order_campsite_types', array ['uuid[]'], 'authenticator', array[]::text[]); + + +set client_min_messages to warning; +truncate campsite_type cascade; +truncate media cascade; +truncate media_content cascade; +truncate company cascade; +reset client_min_messages; + + +insert into company (company_id, business_name, vatin, trade_name, phone, email, web, address, city, province, postal_code, rtc_number, country_code, currency_code, default_lang_tag) +values (1, 'Company 2', 'XX123', '', '555-555-555', 'a@a', '', '', '', '', '', '', 'ES', 'EUR', 'ca') +; + +insert into media_content (media_type, bytes) +values ('image/x-xpixmap', 'static char *s[]={"1 1 1 1","a c #ffffff","a"};') +; + +insert into media (media_id, company_id, original_filename, content_hash) +values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) +; + +insert into campsite_type (company_id, slug, media_id, name, spiel, info, facilities, description, max_campers, dogs_allowed, active) +values (1, '87452b88-b48f-48d3-bb6c-0296de64164e', 2, 'A', '', '', '', '', 5, false, true) + , (1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 2, 'B', '', '', '', '', 5, false, true) + , (1, 'b33cfbc9-fbcc-4aac-8335-e5f94ea7e6b2', 2, 'C', '', '', '', '', 5, false, true) + , (1, '8c4465ec-a690-43d7-854b-7fcd35fccb1c', 2, 'D', '', '', '', '', 5, false, true) + , (1, 'd28c30fb-57ac-4243-a8c3-ad1a26637f5a', 2, 'E', '', '', '', '', 5, false, true) +; + +select lives_ok( + $$ select order_campsite_types('{b33cfbc9-fbcc-4aac-8335-e5f94ea7e6b2,d28c30fb-57ac-4243-a8c3-ad1a26637f5a,8c4465ec-a690-43d7-854b-7fcd35fccb1c,87452b88-b48f-48d3-bb6c-0296de64164e,9b6370f7-f941-46f2-bc6e-de455675bd0a}') $$, + 'Should be able to sort campsite types using their UUID' +); + +select bag_eq( + $$ select slug::text, position from campsite_type $$, + $$ values ('b33cfbc9-fbcc-4aac-8335-e5f94ea7e6b2', 1) + , ('d28c30fb-57ac-4243-a8c3-ad1a26637f5a', 2) + , ('8c4465ec-a690-43d7-854b-7fcd35fccb1c', 3) + , ('87452b88-b48f-48d3-bb6c-0296de64164e', 4) + , ('9b6370f7-f941-46f2-bc6e-de455675bd0a', 5) + $$, + 'Should have sorted all campsite types.' +); + +select * +from finish(); + +rollback; diff --git a/test/order_home_carousel.sql b/test/order_home_carousel.sql new file mode 100644 index 0000000..abcf6a2 --- /dev/null +++ b/test/order_home_carousel.sql @@ -0,0 +1,79 @@ +-- Test order_home_carousel +set client_min_messages to warning; +create extension if not exists pgtap; +reset client_min_messages; + +begin; + +select plan(11); + +set search_path to camper, public; + +select has_function('camper', 'order_home_carousel', array['integer[]']); +select function_lang_is('camper', 'order_home_carousel', array['integer[]'], 'sql'); +select function_returns('camper', 'order_home_carousel', array['integer[]'], 'void'); +select isnt_definer('camper', 'order_home_carousel', array['integer[]']); +select volatility_is('camper', 'order_home_carousel', array['integer[]'], 'volatile'); +select function_privs_are('camper', 'order_home_carousel', array ['integer[]'], 'guest', array[]::text[]); +select function_privs_are('camper', 'order_home_carousel', array ['integer[]'], 'employee', array[]::text[]); +select function_privs_are('camper', 'order_home_carousel', array ['integer[]'], 'admin', array['EXECUTE']); +select function_privs_are('camper', 'order_home_carousel', array ['integer[]'], 'authenticator', array[]::text[]); + + +set client_min_messages to warning; +truncate home_carousel_i18n cascade; +truncate home_carousel cascade; +truncate media cascade; +truncate media_content cascade; +truncate company cascade; +reset client_min_messages; + +insert into company (company_id, business_name, vatin, trade_name, phone, email, web, address, city, province, postal_code, rtc_number, country_code, currency_code, default_lang_tag) +values (1, 'Company 2', 'XX123', '', '555-555-555', 'a@a', '', '', '', '', '', '', 'ES', 'EUR', 'ca') +; + +insert into media_content (media_type, bytes) +values ('image/x-xpixmap', 'static char *s[]={"1 1 1 1","a c #ffffff","a"};') + , ('image/x-xpixmap', 'static char *s[]={"1 1 1 1","a c #ff00ff","a"};') + , ('image/x-xpixmap', 'static char *s[]={"1 1 1 1","a c #ffff00","a"};') + , ('text/plain', 'hello, world!') + , ('image/svg+xml', '') +; + +insert into media (media_id, company_id, original_filename, content_hash) +values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) + , (3, 1, 'cover3.xpm', sha256('static char *s[]={"1 1 1 1","a c #ff00ff","a"};')) + , (4, 1, 'cover4.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffff00","a"};')) + , (5, 1, 'text.txt', sha256('hello, world!')) + , (6, 1, 'image.svg', sha256('')) +; + +insert into home_carousel (media_id, caption) +values (2, '1') + , (3, '2') + , (4, '3') + , (5, '4') + , (6, '5') +; + +select lives_ok( + $$ select order_home_carousel('{4,6,5,2,3}') $$, + 'Should be able to sort home slides using their ID' +); + +select bag_eq( + $$ select media_id, position from home_carousel $$, + $$ values (4, 1) + , (6, 2) + , (5, 3) + , (2, 4) + , (3, 5) + $$, + 'Should have sorted all home slides.' +); + + +select * +from finish(); + +rollback; diff --git a/test/order_seasons.sql b/test/order_seasons.sql new file mode 100644 index 0000000..90e5991 --- /dev/null +++ b/test/order_seasons.sql @@ -0,0 +1,60 @@ +-- Test order_seasons +set client_min_messages to warning; +create extension if not exists pgtap; +reset client_min_messages; + +begin; + +select plan(11); + +set search_path to camper, public; + +select has_function('camper', 'order_seasons', array['uuid[]']); +select function_lang_is('camper', 'order_seasons', array['uuid[]'], 'sql'); +select function_returns('camper', 'order_seasons', array['uuid[]'], 'void'); +select isnt_definer('camper', 'order_seasons', array['uuid[]']); +select volatility_is('camper', 'order_seasons', array['uuid[]'], 'volatile'); +select function_privs_are('camper', 'order_seasons', array ['uuid[]'], 'guest', array[]::text[]); +select function_privs_are('camper', 'order_seasons', array ['uuid[]'], 'employee', array[]::text[]); +select function_privs_are('camper', 'order_seasons', array ['uuid[]'], 'admin', array['EXECUTE']); +select function_privs_are('camper', 'order_seasons', array ['uuid[]'], 'authenticator', array[]::text[]); + + +set client_min_messages to warning; +truncate season cascade; +truncate company cascade; +reset client_min_messages; + + +insert into company (company_id, business_name, vatin, trade_name, phone, email, web, address, city, province, postal_code, rtc_number, country_code, currency_code, default_lang_tag) +values (1, 'Company 2', 'XX123', '', '555-555-555', 'a@a', '', '', '', '', '', '', 'ES', 'EUR', 'ca') +; + +insert into season (company_id, slug, name, color, active) +values (1, '87452b88-b48f-48d3-bb6c-0296de64164e', 'A', to_integer('#232323'), true) + , (1, '9b6370f7-f941-46f2-bc6e-de455675bd0a', 'B', to_integer('#323232'), true) + , (1, 'b33cfbc9-fbcc-4aac-8335-e5f94ea7e6b2', 'C', to_integer('#323232'), true) + , (1, '8c4465ec-a690-43d7-854b-7fcd35fccb1c', 'D', to_integer('#323232'), true) + , (1, 'd28c30fb-57ac-4243-a8c3-ad1a26637f5a', 'E', to_integer('#323232'), true) +; + +select lives_ok( + $$ select order_seasons('{b33cfbc9-fbcc-4aac-8335-e5f94ea7e6b2,d28c30fb-57ac-4243-a8c3-ad1a26637f5a,8c4465ec-a690-43d7-854b-7fcd35fccb1c,87452b88-b48f-48d3-bb6c-0296de64164e,9b6370f7-f941-46f2-bc6e-de455675bd0a}') $$, + 'Should be able to sort seasons using their UUID' +); + +select bag_eq( + $$ select slug::text, position from season $$, + $$ values ('b33cfbc9-fbcc-4aac-8335-e5f94ea7e6b2', 1) + , ('d28c30fb-57ac-4243-a8c3-ad1a26637f5a', 2) + , ('8c4465ec-a690-43d7-854b-7fcd35fccb1c', 3) + , ('87452b88-b48f-48d3-bb6c-0296de64164e', 4) + , ('9b6370f7-f941-46f2-bc6e-de455675bd0a', 5) + $$, + 'Should have sorted all campsite types.' +); + +select * +from finish(); + +rollback; diff --git a/test/order_services_carousel.sql b/test/order_services_carousel.sql new file mode 100644 index 0000000..5d9ac49 --- /dev/null +++ b/test/order_services_carousel.sql @@ -0,0 +1,79 @@ +-- Test order_services_carousel +set client_min_messages to warning; +create extension if not exists pgtap; +reset client_min_messages; + +begin; + +select plan(11); + +set search_path to camper, public; + +select has_function('camper', 'order_services_carousel', array['integer[]']); +select function_lang_is('camper', 'order_services_carousel', array['integer[]'], 'sql'); +select function_returns('camper', 'order_services_carousel', array['integer[]'], 'void'); +select isnt_definer('camper', 'order_services_carousel', array['integer[]']); +select volatility_is('camper', 'order_services_carousel', array['integer[]'], 'volatile'); +select function_privs_are('camper', 'order_services_carousel', array ['integer[]'], 'guest', array[]::text[]); +select function_privs_are('camper', 'order_services_carousel', array ['integer[]'], 'employee', array[]::text[]); +select function_privs_are('camper', 'order_services_carousel', array ['integer[]'], 'admin', array['EXECUTE']); +select function_privs_are('camper', 'order_services_carousel', array ['integer[]'], 'authenticator', array[]::text[]); + + +set client_min_messages to warning; +truncate services_carousel_i18n cascade; +truncate services_carousel cascade; +truncate media cascade; +truncate media_content cascade; +truncate company cascade; +reset client_min_messages; + +insert into company (company_id, business_name, vatin, trade_name, phone, email, web, address, city, province, postal_code, rtc_number, country_code, currency_code, default_lang_tag) +values (1, 'Company 2', 'XX123', '', '555-555-555', 'a@a', '', '', '', '', '', '', 'ES', 'EUR', 'ca') +; + +insert into media_content (media_type, bytes) +values ('image/x-xpixmap', 'static char *s[]={"1 1 1 1","a c #ffffff","a"};') + , ('image/x-xpixmap', 'static char *s[]={"1 1 1 1","a c #ff00ff","a"};') + , ('image/x-xpixmap', 'static char *s[]={"1 1 1 1","a c #ffff00","a"};') + , ('text/plain', 'hello, world!') + , ('image/svg+xml', '') +; + +insert into media (media_id, company_id, original_filename, content_hash) +values (2, 1, 'cover2.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffffff","a"};')) + , (3, 1, 'cover3.xpm', sha256('static char *s[]={"1 1 1 1","a c #ff00ff","a"};')) + , (4, 1, 'cover4.xpm', sha256('static char *s[]={"1 1 1 1","a c #ffff00","a"};')) + , (5, 1, 'text.txt', sha256('hello, world!')) + , (6, 1, 'image.svg', sha256('')) +; + +insert into services_carousel (media_id, caption) +values (2, '1') + , (3, '2') + , (4, '3') + , (5, '4') + , (6, '5') +; + +select lives_ok( + $$ select order_services_carousel('{4,6,5,2,3}') $$, + 'Should be able to sort services slides using their ID' +); + +select bag_eq( + $$ select media_id, position from services_carousel $$, + $$ values (4, 1) + , (6, 2) + , (5, 3) + , (2, 4) + , (3, 5) + $$, + 'Should have sorted all services slides.' +); + + +select * +from finish(); + +rollback; diff --git a/test/season.sql b/test/season.sql index b483ca8..57041ac 100644 --- a/test/season.sql +++ b/test/season.sql @@ -5,7 +5,7 @@ reset client_min_messages; begin; -select plan(51); +select plan(56); set search_path to camper, public; @@ -53,6 +53,12 @@ select col_not_null('season', 'active'); select col_has_default('season', 'active'); select col_default_is('season', 'active', 'true'); +select has_column('season', 'position'); +select col_type_is('season', 'position', 'integer'); +select col_not_null('season', 'position'); +select col_has_default('season', 'position'); +select col_default_is('season', 'position', '2147483647'); + set client_min_messages to warning; truncate season cascade; diff --git a/test/services_carousel.sql b/test/services_carousel.sql index e18a198..6216ba5 100644 --- a/test/services_carousel.sql +++ b/test/services_carousel.sql @@ -5,7 +5,7 @@ reset client_min_messages; begin; -select plan(30); +select plan(35); set search_path to camper, public; @@ -29,6 +29,13 @@ select col_type_is('services_carousel', 'caption', 'text'); select col_not_null('services_carousel', 'caption'); select col_hasnt_default('services_carousel', 'caption'); +select has_column('services_carousel', 'position'); +select col_type_is('services_carousel', 'position', 'integer'); +select col_not_null('services_carousel', 'position'); +select col_has_default('services_carousel', 'position'); +select col_default_is('services_carousel', 'position', '2147483647'); + + set client_min_messages to warning; truncate services_carousel cascade; truncate media cascade; diff --git a/verify/campsite_type.sql b/verify/campsite_type.sql index 592eec4..8fad98b 100644 --- a/verify/campsite_type.sql +++ b/verify/campsite_type.sql @@ -14,6 +14,7 @@ select campsite_type_id , max_campers , dogs_allowed , active + , position from camper.campsite_type where false; diff --git a/verify/campsite_type_carousel.sql b/verify/campsite_type_carousel.sql index e99c574..9afc1cb 100644 --- a/verify/campsite_type_carousel.sql +++ b/verify/campsite_type_carousel.sql @@ -5,6 +5,7 @@ begin; select campsite_type_id , media_id , caption + , position from camper.campsite_type_carousel where false; diff --git a/verify/campsite_type_option.sql b/verify/campsite_type_option.sql index 15fb9e7..7672f00 100644 --- a/verify/campsite_type_option.sql +++ b/verify/campsite_type_option.sql @@ -6,6 +6,7 @@ select campsite_type_option_id , campsite_type_id , name , range + , position from camper.campsite_type_option where false; diff --git a/verify/home_carousel.sql b/verify/home_carousel.sql index 2a8efc4..1023f6c 100644 --- a/verify/home_carousel.sql +++ b/verify/home_carousel.sql @@ -4,6 +4,7 @@ begin; select media_id , caption + , position from camper.home_carousel where false; diff --git a/verify/order_campsite_type_carousel.sql b/verify/order_campsite_type_carousel.sql new file mode 100644 index 0000000..9035cf0 --- /dev/null +++ b/verify/order_campsite_type_carousel.sql @@ -0,0 +1,7 @@ +-- Verify camper:order_campsite_type_carousel on pg + +begin; + +select has_function_privilege('camper.order_campsite_type_carousel(uuid, integer[])', 'execute'); + +rollback; diff --git a/verify/order_campsite_type_options.sql b/verify/order_campsite_type_options.sql new file mode 100644 index 0000000..547f5d8 --- /dev/null +++ b/verify/order_campsite_type_options.sql @@ -0,0 +1,7 @@ +-- Verify camper:order_campsite_type_options on pg + +begin; + +select has_function_privilege('camper.order_campsite_type_options(integer[])', 'execute'); + +rollback; diff --git a/verify/order_campsite_types.sql b/verify/order_campsite_types.sql new file mode 100644 index 0000000..3ec238a --- /dev/null +++ b/verify/order_campsite_types.sql @@ -0,0 +1,7 @@ +-- Verify camper:order_campsite_types on pg + +begin; + +select has_function_privilege('camper.order_campsite_types(uuid[])', 'execute'); + +rollback; diff --git a/verify/order_home_carousel.sql b/verify/order_home_carousel.sql new file mode 100644 index 0000000..8ab8a14 --- /dev/null +++ b/verify/order_home_carousel.sql @@ -0,0 +1,7 @@ +-- Verify camper:order_home_carousel on pg + +begin; + +select has_function_privilege('camper.order_home_carousel(integer[])', 'execute'); + +rollback; diff --git a/verify/order_seasons.sql b/verify/order_seasons.sql new file mode 100644 index 0000000..8824bf9 --- /dev/null +++ b/verify/order_seasons.sql @@ -0,0 +1,7 @@ +-- Verify camper:order_seasons on pg + +begin; + +select has_function_privilege('camper.order_seasons(uuid[])', 'execute'); + +rollback; diff --git a/verify/order_services_carousel.sql b/verify/order_services_carousel.sql new file mode 100644 index 0000000..05330ad --- /dev/null +++ b/verify/order_services_carousel.sql @@ -0,0 +1,7 @@ +-- Verify camper:order_services_carousel on pg + +begin; + +select has_function_privilege('camper.order_services_carousel(integer[])', 'execute'); + +rollback; diff --git a/verify/season.sql b/verify/season.sql index b492e2e..3a621d8 100644 --- a/verify/season.sql +++ b/verify/season.sql @@ -8,6 +8,7 @@ select season_id , name , color , active + , position from camper.season where false; diff --git a/verify/services_carousel.sql b/verify/services_carousel.sql index 4fe85fa..243cfb7 100644 --- a/verify/services_carousel.sql +++ b/verify/services_carousel.sql @@ -4,6 +4,7 @@ begin; select media_id , caption + , position from camper.services_carousel where false; diff --git a/web/static/camper.css b/web/static/camper.css index 4418d6b..a3e5daa 100644 --- a/web/static/camper.css +++ b/web/static/camper.css @@ -599,6 +599,28 @@ textarea { content: "✕"; } +.sortable tbody tr td:first-child { + display: flex; +} + +#slide-index img { + width: 192px; + aspect-ratio: 4 / 3; + object-fit: cover; +} + +.sortable .handle { + display: inline-block; + width: 1.5em; + aspect-ratio: 1; + cursor: grab; + background: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"%3E%3Crect width="256" height="256" fill="none"/%3E%3Ccircle cx="92" cy="60" r="12"/%3E%3Ccircle cx="164" cy="60" r="12"/%3E%3Ccircle cx="92" cy="128" r="12"/%3E%3Ccircle cx="164" cy="128" r="12"/%3E%3Ccircle cx="92" cy="196" r="12"/%3E%3Ccircle cx="164" cy="196" r="12"/%3E%3C/svg%3E') left center no-repeat; +} + +.sortable-ghost { + background-color: #aaa; +} + /* snack bar */ #snackbar [role="alert"] { cursor: pointer; diff --git a/web/static/camper.js b/web/static/camper.js index 13cb409..3d96608 100644 --- a/web/static/camper.js +++ b/web/static/camper.js @@ -179,7 +179,6 @@ export function setupCalendar(calendar) { const dialog = calendar.querySelector('dialog'); const clear = function () { - console.log('yolo'); startDate.value = endDate.value = ""; days.forEach((e) => e.removeAttribute('aria-checked')); } @@ -229,3 +228,22 @@ htmx.onLoad((target) => { } }) +htmx.onLoad((content) => { + const sortables = Array.from(content.querySelectorAll('.sortable table tbody')); + for (const sortable of sortables) { + const sortableInstance = new Sortable(sortable, { + animation: 150, + draggable: '>tr', + handle: '.handle', + onMove: (evt) => evt.related.className.indexOf('htmx-indicator') === -1, + onEnd: function () { + this.option('disabled', true); + }, + }); + + sortable.addEventListener('htmx:afterSwap', function () { + sortableInstance.option('disabled', false); + }); + } +}) + diff --git a/web/static/sortable@1.15.1.min.js b/web/static/sortable@1.15.1.min.js new file mode 100644 index 0000000..1a9f199 --- /dev/null +++ b/web/static/sortable@1.15.1.min.js @@ -0,0 +1,2 @@ +/*! Sortable 1.15.1 - MIT | git://github.com/SortableJS/Sortable.git */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Sortable=e()}(this,function(){"use strict";function e(e,t){var n,o=Object.keys(e);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),o.push.apply(o,n)),o}function N(o){for(var t=1;tt.length)&&(e=t.length);for(var n=0,o=new Array(e);n"===e[0]&&(e=e.substring(1)),t))try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch(t){return}}function P(t,e,n,o){if(t){n=n||document;do{if(null!=e&&(">"!==e[0]||t.parentNode===n)&&f(t,e)||o&&t===n)return t}while(t!==n&&(t=(i=t).host&&i!==document&&i.host.nodeType?i.host:i.parentNode))}var i;return null}var g,m=/\s+/g;function k(t,e,n){var o;t&&e&&(t.classList?t.classList[n?"add":"remove"](e):(o=(" "+t.className+" ").replace(m," ").replace(" "+e+" "," "),t.className=(o+(n?" "+e:"")).replace(m," ")))}function R(t,e,n){var o=t&&t.style;if(o){if(void 0===n)return document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(n=t.currentStyle),void 0===e?n:n[e];o[e=!(e in o||-1!==e.indexOf("webkit"))?"-webkit-"+e:e]=n+("string"==typeof n?"":"px")}}function v(t,e){var n="";if("string"==typeof t)n=t;else do{var o=R(t,"transform")}while(o&&"none"!==o&&(n=o+" "+n),!e&&(t=t.parentNode));var i=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return i&&new i(n)}function b(t,e,n){if(t){var o=t.getElementsByTagName(e),i=0,r=o.length;if(n)for(;i=n.left-e&&i<=n.right+e,e=r>=n.top-e&&r<=n.bottom+e;return o&&e?a=t:void 0}}),a);if(e){var n,o={};for(n in t)t.hasOwnProperty(n)&&(o[n]=t[n]);o.target=o.rootEl=e,o.preventDefault=void 0,o.stopPropagation=void 0,e[W]._onDragOver(o)}}var i,r,a}function Bt(t){V&&V.parentNode[W]._isOutsideThisEl(t.target)}function Ft(t,e){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(t));this.el=t,this.options=e=a({},e),t[W]=this;var n,o,i={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(t.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return Pt(t,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(t,e){t.setData("Text",e.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:!1!==Ft.supportPointer&&"PointerEvent"in window&&!u,emptyInsertThreshold:5};for(n in K.initializePlugins(this,t,i),i)n in e||(e[n]=i[n]);for(o in kt(e),this)"_"===o.charAt(0)&&"function"==typeof this[o]&&(this[o]=this[o].bind(this));this.nativeDraggable=!e.forceFallback&&It,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?h(t,"pointerdown",this._onTapStart):(h(t,"mousedown",this._onTapStart),h(t,"touchstart",this._onTapStart)),this.nativeDraggable&&(h(t,"dragover",this),h(t,"dragenter",this)),Dt.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),a(this,x())}function jt(t,e,n,o,i,r,a,l){var s,c,u=t[W],d=u.options.onMove;return!window.CustomEvent||y||w?(s=document.createEvent("Event")).initEvent("move",!0,!0):s=new CustomEvent("move",{bubbles:!0,cancelable:!0}),s.to=e,s.from=t,s.dragged=n,s.draggedRect=o,s.related=i||e,s.relatedRect=r||X(e),s.willInsertAfter=l,s.originalEvent=a,t.dispatchEvent(s),c=d?d.call(u,s,a):c}function Ht(t){t.draggable=!1}function Lt(){Tt=!1}function Wt(t){return setTimeout(t,0)}function Kt(t){return clearTimeout(t)}Ft.prototype={constructor:Ft,_isOutsideThisEl:function(t){this.el.contains(t)||t===this.el||(mt=null)},_getDirection:function(t,e){return"function"==typeof this.options.direction?this.options.direction.call(this,t,e,V):this.options.direction},_onTapStart:function(e){if(e.cancelable){var n=this,o=this.el,t=this.options,i=t.preventOnFilter,r=e.type,a=e.touches&&e.touches[0]||e.pointerType&&"touch"===e.pointerType&&e,l=(a||e).target,s=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,c=t.filter;if(!function(t){xt.length=0;var e=t.getElementsByTagName("input"),n=e.length;for(;n--;){var o=e[n];o.checked&&xt.push(o)}}(o),!V&&!(/mousedown|pointerdown/.test(r)&&0!==e.button||t.disabled)&&!s.isContentEditable&&(this.nativeDraggable||!u||!l||"SELECT"!==l.tagName.toUpperCase())&&!((l=P(l,t.draggable,o,!1))&&l.animated||tt===l)){if(ot=H(l),rt=H(l,t.draggable),"function"==typeof c){if(c.call(this,e,l,this))return q({sortable:n,rootEl:s,name:"filter",targetEl:l,toEl:o,fromEl:o}),G("filter",n,{evt:e}),void(i&&e.cancelable&&e.preventDefault())}else if(c=c&&c.split(",").some(function(t){if(t=P(s,t.trim(),o,!1))return q({sortable:n,rootEl:t,name:"filter",targetEl:l,fromEl:o,toEl:o}),G("filter",n,{evt:e}),!0}))return void(i&&e.cancelable&&e.preventDefault());t.handle&&!P(s,t.handle,o,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(t,e,n){var o,i=this,r=i.el,a=i.options,l=r.ownerDocument;n&&!V&&n.parentNode===r&&(o=X(n),Q=r,Z=(V=n).parentNode,J=V.nextSibling,tt=n,lt=a.group,ct={target:Ft.dragged=V,clientX:(e||t).clientX,clientY:(e||t).clientY},pt=ct.clientX-o.left,ft=ct.clientY-o.top,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,V.style["will-change"]="all",o=function(){G("delayEnded",i,{evt:t}),Ft.eventCanceled?i._onDrop():(i._disableDelayedDragEvents(),!s&&i.nativeDraggable&&(V.draggable=!0),i._triggerDragStart(t,e),q({sortable:i,name:"choose",originalEvent:t}),k(V,a.chosenClass,!0))},a.ignore.split(",").forEach(function(t){b(V,t.trim(),Ht)}),h(l,"dragover",Yt),h(l,"mousemove",Yt),h(l,"touchmove",Yt),h(l,"mouseup",i._onDrop),h(l,"touchend",i._onDrop),h(l,"touchcancel",i._onDrop),s&&this.nativeDraggable&&(this.options.touchStartThreshold=4,V.draggable=!0),G("delayStart",this,{evt:t}),!a.delay||a.delayOnTouchOnly&&!e||this.nativeDraggable&&(w||y)?o():Ft.eventCanceled?this._onDrop():(h(l,"mouseup",i._disableDelayedDrag),h(l,"touchend",i._disableDelayedDrag),h(l,"touchcancel",i._disableDelayedDrag),h(l,"mousemove",i._delayedDragTouchMoveHandler),h(l,"touchmove",i._delayedDragTouchMoveHandler),a.supportPointer&&h(l,"pointermove",i._delayedDragTouchMoveHandler),i._dragStartTimer=setTimeout(o,a.delay)))},_delayedDragTouchMoveHandler:function(t){t=t.touches?t.touches[0]:t;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){V&&Ht(V),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;p(t,"mouseup",this._disableDelayedDrag),p(t,"touchend",this._disableDelayedDrag),p(t,"touchcancel",this._disableDelayedDrag),p(t,"mousemove",this._delayedDragTouchMoveHandler),p(t,"touchmove",this._delayedDragTouchMoveHandler),p(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||"touch"==t.pointerType&&t,!this.nativeDraggable||e?this.options.supportPointer?h(document,"pointermove",this._onTouchMove):h(document,e?"touchmove":"mousemove",this._onTouchMove):(h(V,"dragend",this),h(Q,"dragstart",this._onDragStart));try{document.selection?Wt(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch(t){}},_dragStarted:function(t,e){var n;wt=!1,Q&&V?(G("dragStarted",this,{evt:e}),this.nativeDraggable&&h(document,"dragover",Bt),n=this.options,t||k(V,n.dragClass,!1),k(V,n.ghostClass,!0),Ft.active=this,t&&this._appendGhost(),q({sortable:this,name:"start",originalEvent:e})):this._nulling()},_emulateDragOver:function(){if(ut){this._lastX=ut.clientX,this._lastY=ut.clientY,Rt();for(var t=document.elementFromPoint(ut.clientX,ut.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(ut.clientX,ut.clientY))!==e;)e=t;if(V.parentNode[W]._isOutsideThisEl(t),e)do{if(e[W])if(e[W]._onDragOver({clientX:ut.clientX,clientY:ut.clientY,target:t,rootEl:e})&&!this.options.dragoverBubble)break}while(e=(t=e).parentNode);Xt()}},_onTouchMove:function(t){if(ct){var e=this.options,n=e.fallbackTolerance,o=e.fallbackOffset,i=t.touches?t.touches[0]:t,r=$&&v($,!0),a=$&&r&&r.a,l=$&&r&&r.d,e=At&&yt&&E(yt),a=(i.clientX-ct.clientX+o.x)/(a||1)+(e?e[0]-Ct[0]:0)/(a||1),l=(i.clientY-ct.clientY+o.y)/(l||1)+(e?e[1]-Ct[1]:0)/(l||1);if(!Ft.active&&!wt){if(n&&Math.max(Math.abs(i.clientX-this._lastX),Math.abs(i.clientY-this._lastY))D.right+10||S.clientY>x.bottom&&S.clientX>x.left:S.clientY>D.bottom+10||S.clientX>x.right&&S.clientY>x.top)||m.animated)){if(m&&(t=n,e=r,C=X(F((_=this).el,0,_.options,!0)),_=Y(_.el),e?t.clientX<_.left-10||t.clientY{{( pgettext "Campsite Type Carousel" "title" )}} {{( pgettext "Add slide" "action" )}} {{ if .Slides -}} - - - - - - - - - - - {{ $confirm := (gettext "Are you sure you wish to delete this slide?")}} - {{ range $slide := .Slides -}} + + {{ CSRFInput }} +
{{( pgettext "Image" "header" )}}{{( pgettext "Caption" "header" )}}{{( pgettext "Translations" "header" )}}{{( pgettext "Actions" "header" )}}
+ - - - - + + + + - {{- end }} - -
{{ .Caption }} - {{ range .Translations }} - {{ .Endonym }} - {{ end }} - - - - - {{( pgettext "Image" "header" )}}{{( pgettext "Caption" "header" )}}{{( pgettext "Translations" "header" )}}{{( pgettext "Actions" "header" )}}
+ + + {{ $confirm := (gettext "Are you sure you wish to delete this slide?")}} + {{ range $slide := .Slides -}} + + + + + + + {{ .Caption }} + + {{ range .Translations }} + {{ .Endonym }} + {{ end }} + + +
+ +
+ + + {{- end }} + + + {{ else -}}

{{( gettext "No slides added yet." )}}

{{- end }} diff --git a/web/templates/admin/campsite/option/index.gohtml b/web/templates/admin/campsite/option/index.gohtml index ed758c7..8317c5c 100644 --- a/web/templates/admin/campsite/option/index.gohtml +++ b/web/templates/admin/campsite/option/index.gohtml @@ -11,30 +11,43 @@ {{( pgettext "Add Option" "action" )}}

{{( pgettext "Campsite Type Options" "title" )}}

{{ if .Options -}} - - - - - - - - - {{ range .Options -}} + + {{ CSRFInput }} +
{{( pgettext "Name" "header" )}}{{( pgettext "Translations" "header" )}}
+ - - + + - {{- end }} - -
{{ .Name }} - {{ range .Translations }} - {{ .Endonym }} - {{ end }} - {{( pgettext "Name" "header" )}}{{( pgettext "Translations" "header" )}}
+ + + {{ range .Options -}} + + + + + {{ .Name }} + + + {{ range .Translations }} + {{ .Endonym }} + {{ end }} + + + {{- end }} + + + {{ else -}}

{{( gettext "No campsite type options added yet." )}}

{{- end }} diff --git a/web/templates/admin/campsite/type/index.gohtml b/web/templates/admin/campsite/type/index.gohtml index 96f676d..bbde5f8 100644 --- a/web/templates/admin/campsite/type/index.gohtml +++ b/web/templates/admin/campsite/type/index.gohtml @@ -11,44 +11,57 @@ {{( pgettext "Add Type" "action" )}}

{{( pgettext "Campsite Types" "title" )}}

{{ if .Types -}} - - - - - - - - - - - - - {{ range $type := .Types -}} + + {{ CSRFInput }} +
{{( pgettext "Name" "header" )}}{{( pgettext "Translations" "header" )}}{{( pgettext "Features" "header" )}}{{( pgettext "Options" "header" )}}{{( pgettext "Carousel" "header" )}}{{( pgettext "Active" "campsite type" )}}
+ - - - - - - + + + + + + - {{- end }} - -
{{ .Name }} - {{ range .Translations }} - {{ .Endonym }} - {{ end }} - - {{( pgettext "Edit Features" "action" )}} - - {{( pgettext "Edit Options" "action" )}} - - {{( pgettext "Edit Carousel" "action" )}} - {{ if .Active }}{{( gettext "Yes" )}}{{ else }}{{( gettext "No" )}}{{ end }}{{( pgettext "Name" "header" )}}{{( pgettext "Translations" "header" )}}{{( pgettext "Features" "header" )}}{{( pgettext "Options" "header" )}}{{( pgettext "Carousel" "header" )}}{{( pgettext "Active" "campsite type" )}}
+ + + {{ range $type := .Types -}} + + + + + {{ .Name }} + + + {{ range .Translations }} + {{ .Endonym }} + {{ end }} + + + {{( pgettext "Edit Features" "action" )}} + + + {{( pgettext "Edit Options" "action" )}} + + + {{( pgettext "Edit Carousel" "action" )}} + + {{ if .Active }}{{( gettext "Yes" )}}{{ else }}{{( gettext "No" )}}{{ end }} + + {{- end }} + + + {{ else -}}

{{( gettext "No campsite types added yet." )}}

{{- end }} diff --git a/web/templates/admin/home/index.gohtml b/web/templates/admin/home/index.gohtml index f8759c6..54f0ae1 100644 --- a/web/templates/admin/home/index.gohtml +++ b/web/templates/admin/home/index.gohtml @@ -11,41 +11,54 @@

{{( pgettext "Carousel" "title" )}}

{{( pgettext "Add slide" "action" )}} {{ if .Slides -}} - - - - - - - - - - - {{ $confirm := (gettext "Are you sure you wish to delete this slide?")}} - {{ range $slide := .Slides -}} + + {{ CSRFInput }} +
{{( pgettext "Image" "header" )}}{{( pgettext "Caption" "header" )}}{{( pgettext "Translations" "header" )}}{{( pgettext "Actions" "header" )}}
+ - - - - + + + + - {{- end }} - -
{{ .Caption }} - {{ range .Translations }} - {{ .Endonym }} - {{ end }} - - - - - {{( pgettext "Image" "header" )}}{{( pgettext "Caption" "header" )}}{{( pgettext "Translations" "header" )}}{{( pgettext "Actions" "header" )}}
+ + + {{ $confirm := (gettext "Are you sure you wish to delete this slide?")}} + {{ range $slide := .Slides -}} + + + + + + + {{ .Caption }} + + {{ range .Translations }} + {{ .Endonym }} + {{ end }} + + +
+ +
+ + + {{- end }} + + + {{ else -}}

{{( gettext "No slides added yet." )}}

{{- end }} diff --git a/web/templates/admin/layout.gohtml b/web/templates/admin/layout.gohtml index 4eeba73..781e86c 100644 --- a/web/templates/admin/layout.gohtml +++ b/web/templates/admin/layout.gohtml @@ -10,8 +10,9 @@ {{ template "title" . }} — Camper - + + {{ block "head" . }}{{ end }} diff --git a/web/templates/admin/season/index.gohtml b/web/templates/admin/season/index.gohtml index 660e0fd..e1c191e 100644 --- a/web/templates/admin/season/index.gohtml +++ b/web/templates/admin/season/index.gohtml @@ -11,36 +11,47 @@ {{( pgettext "Add Season" "action" )}}

{{( pgettext "Seasons" "title" )}}

{{ if .Seasons -}} - - - - - - - - - - - {{ range .Seasons -}} + + {{ CSRFInput }} +
{{( pgettext "Color" "header" )}}{{( pgettext "Name" "header" )}}{{( pgettext "Translations" "header" )}}{{( pgettext "Active" "season" )}}
+ - - - - + + + + - {{- end }} - -
- - - - {{ .Name }} - {{ range .Translations }} - {{ .Endonym }} - {{ end }} - {{ if .Active }}{{( gettext "Yes" )}}{{ else }}{{( gettext "No" )}}{{ end }}{{( pgettext "Color" "header" )}}{{( pgettext "Name" "header" )}}{{( pgettext "Translations" "header" )}}{{( pgettext "Active" "season" )}}
+ + + {{ range .Seasons -}} + + + + + + + + + {{ .Name }} + + {{ range .Translations }} + {{ .Endonym }} + {{ end }} + + {{ if .Active }}{{( gettext "Yes" )}}{{ else }}{{( gettext "No" )}}{{ end }} + + {{- end }} + + + {{ else -}}

{{( gettext "No seasons added yet." )}}

{{- end }} diff --git a/web/templates/admin/services/index.gohtml b/web/templates/admin/services/index.gohtml index 70f2dbd..aa7dd9d 100644 --- a/web/templates/admin/services/index.gohtml +++ b/web/templates/admin/services/index.gohtml @@ -11,41 +11,54 @@

{{( pgettext "Carousel" "title" )}}

{{( pgettext "Add slide" "action" )}} {{ if .Slides -}} - - - - - - - - - - - {{ $confirm := ( gettext "Are you sure you wish to delete this slide?" )}} - {{ range $slide := .Slides -}} + + {{ CSRFInput }} +
{{( pgettext "Image" "header" )}}{{( pgettext "Caption" "header" )}}{{( pgettext "Translations" "header" )}}{{( pgettext "Actions" "header" )}}
+ - - - - + + + + - {{- end }} - -
{{ .Caption }} - {{ range .Translations }} - {{ .Endonym }} - {{ end }} - - - - - {{( pgettext "Image" "header" )}}{{( pgettext "Caption" "header" )}}{{( pgettext "Translations" "header" )}}{{( pgettext "Actions" "header" )}}
+ + + {{ $confirm := ( gettext "Are you sure you wish to delete this slide?" )}} + {{ range $slide := .Slides -}} + + + + + + + {{ .Caption }} + + {{ range .Translations }} + {{ .Endonym }} + {{ end }} + + +
+ +
+ + + {{- end }} + + + {{ else -}}

{{( gettext "No slides added yet." )}}

{{- end }}