@hperchec/scorpion-ui-template-default
Version:
Scorpion UI - Default template
1,693 lines (1,592 loc) • 192 kB
JavaScript
/*!
* Scorpion UI v0.0.6 - Default template
* @author [Hervé Perchec](http://herve-perchec.fr)
* Released under the GPLv3 License.
*/
import VueTailwind$1 from 'vue-tailwind';
import Icon from 'vue-awesome/components/Icon';
import 'vue-awesome/icons/brands/discord';
import 'vue-awesome/icons/brands/facebook';
import 'vue-awesome/icons/brands/twitter';
import 'vue-awesome/icons/envelope';
import 'vue-awesome/icons/external-link-alt';
import 'vue-awesome/icons/sort-up';
import 'vue-awesome/icons/sort-down';
import 'tailwindcss/base.css';
import 'tailwindcss/components.css';
import 'tailwindcss/utilities.css';
import 'animate-sass/_animate.scss';
import { utils, Core } from '@hperchec/scorpion-ui';
import __vue_normalize__ from '@hperchec/scorpion-ui/shared/rollup/plugins/vue/lib/runtime/component-normalizer.js';
import { mapActions } from 'vuex';
import Ripple from 'vue-ripple-directive';
import { TAlert as TAlert$1, TButton as TButton$1, TDropdown as TDropdown$1, TInput as TInput$1, TModal as TModal$1, TRadio as TRadio$1, TRichSelect as TRichSelect$1, TTextarea as TTextarea$1, TToggle as TToggle$1 } from 'vue-tailwind/dist/components';
import resolveTailwindConfig from 'tailwindcss/resolveConfig';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _typeof$1(obj) {
"@babel/helpers - typeof";
return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
}, _typeof$1(obj);
}
var regeneratorRuntime$1 = {exports: {}};
var _typeof = {exports: {}};
(function (module) {
function _typeof(obj) {
"@babel/helpers - typeof";
return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
}
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
})(_typeof);
(function (module) {
var _typeof$1 = _typeof.exports["default"];
function _regeneratorRuntime() {
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
return exports;
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
var exports = {},
Op = Object.prototype,
hasOwn = Op.hasOwnProperty,
defineProperty = Object.defineProperty || function (obj, key, desc) {
obj[key] = desc.value;
},
$Symbol = "function" == typeof Symbol ? Symbol : {},
iteratorSymbol = $Symbol.iterator || "@@iterator",
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
function define(obj, key, value) {
return Object.defineProperty(obj, key, {
value: value,
enumerable: !0,
configurable: !0,
writable: !0
}), obj[key];
}
try {
define({}, "");
} catch (err) {
define = function define(obj, key, value) {
return obj[key] = value;
};
}
function wrap(innerFn, outerFn, self, tryLocsList) {
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
generator = Object.create(protoGenerator.prototype),
context = new Context(tryLocsList || []);
return defineProperty(generator, "_invoke", {
value: makeInvokeMethod(innerFn, self, context)
}), generator;
}
function tryCatch(fn, obj, arg) {
try {
return {
type: "normal",
arg: fn.call(obj, arg)
};
} catch (err) {
return {
type: "throw",
arg: err
};
}
}
exports.wrap = wrap;
var ContinueSentinel = {};
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}
var IteratorPrototype = {};
define(IteratorPrototype, iteratorSymbol, function () {
return this;
});
var getProto = Object.getPrototypeOf,
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
function defineIteratorMethods(prototype) {
["next", "throw", "return"].forEach(function (method) {
define(prototype, method, function (arg) {
return this._invoke(method, arg);
});
});
}
function AsyncIterator(generator, PromiseImpl) {
function invoke(method, arg, resolve, reject) {
var record = tryCatch(generator[method], generator, arg);
if ("throw" !== record.type) {
var result = record.arg,
value = result.value;
return value && "object" == _typeof$1(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
invoke("next", value, resolve, reject);
}, function (err) {
invoke("throw", err, resolve, reject);
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
result.value = unwrapped, resolve(result);
}, function (error) {
return invoke("throw", error, resolve, reject);
});
}
reject(record.arg);
}
var previousPromise;
defineProperty(this, "_invoke", {
value: function value(method, arg) {
function callInvokeWithMethodAndArg() {
return new PromiseImpl(function (resolve, reject) {
invoke(method, arg, resolve, reject);
});
}
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
}
});
}
function makeInvokeMethod(innerFn, self, context) {
var state = "suspendedStart";
return function (method, arg) {
if ("executing" === state) throw new Error("Generator is already running");
if ("completed" === state) {
if ("throw" === method) throw arg;
return doneResult();
}
for (context.method = method, context.arg = arg;;) {
var delegate = context.delegate;
if (delegate) {
var delegateResult = maybeInvokeDelegate(delegate, context);
if (delegateResult) {
if (delegateResult === ContinueSentinel) continue;
return delegateResult;
}
}
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
if ("suspendedStart" === state) throw state = "completed", context.arg;
context.dispatchException(context.arg);
} else "return" === context.method && context.abrupt("return", context.arg);
state = "executing";
var record = tryCatch(innerFn, self, context);
if ("normal" === record.type) {
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
return {
value: record.arg,
done: context.done
};
}
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
}
};
}
function maybeInvokeDelegate(delegate, context) {
var methodName = context.method,
method = delegate.iterator[methodName];
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
var record = tryCatch(method, delegate.iterator, context.arg);
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
var info = record.arg;
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
}
function pushTryEntry(locs) {
var entry = {
tryLoc: locs[0]
};
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
}
function resetTryEntry(entry) {
var record = entry.completion || {};
record.type = "normal", delete record.arg, entry.completion = record;
}
function Context(tryLocsList) {
this.tryEntries = [{
tryLoc: "root"
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
}
function values(iterable) {
if (iterable) {
var iteratorMethod = iterable[iteratorSymbol];
if (iteratorMethod) return iteratorMethod.call(iterable);
if ("function" == typeof iterable.next) return iterable;
if (!isNaN(iterable.length)) {
var i = -1,
next = function next() {
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
return next.value = undefined, next.done = !0, next;
};
return next.next = next;
}
}
return {
next: doneResult
};
}
function doneResult() {
return {
value: undefined,
done: !0
};
}
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
value: GeneratorFunctionPrototype,
configurable: !0
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
value: GeneratorFunction,
configurable: !0
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
var ctor = "function" == typeof genFun && genFun.constructor;
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
}, exports.mark = function (genFun) {
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
}, exports.awrap = function (arg) {
return {
__await: arg
};
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
return this;
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
void 0 === PromiseImpl && (PromiseImpl = Promise);
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
return result.done ? result.value : iter.next();
});
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
return this;
}), define(Gp, "toString", function () {
return "[object Generator]";
}), exports.keys = function (val) {
var object = Object(val),
keys = [];
for (var key in object) keys.push(key);
return keys.reverse(), function next() {
for (; keys.length;) {
var key = keys.pop();
if (key in object) return next.value = key, next.done = !1, next;
}
return next.done = !0, next;
};
}, exports.values = values, Context.prototype = {
constructor: Context,
reset: function reset(skipTempReset) {
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
},
stop: function stop() {
this.done = !0;
var rootRecord = this.tryEntries[0].completion;
if ("throw" === rootRecord.type) throw rootRecord.arg;
return this.rval;
},
dispatchException: function dispatchException(exception) {
if (this.done) throw exception;
var context = this;
function handle(loc, caught) {
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
}
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i],
record = entry.completion;
if ("root" === entry.tryLoc) return handle("end");
if (entry.tryLoc <= this.prev) {
var hasCatch = hasOwn.call(entry, "catchLoc"),
hasFinally = hasOwn.call(entry, "finallyLoc");
if (hasCatch && hasFinally) {
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
} else if (hasCatch) {
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
} else {
if (!hasFinally) throw new Error("try statement without catch or finally");
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
}
}
}
},
abrupt: function abrupt(type, arg) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
var finallyEntry = entry;
break;
}
}
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
var record = finallyEntry ? finallyEntry.completion : {};
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
},
complete: function complete(record, afterLoc) {
if ("throw" === record.type) throw record.arg;
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
},
finish: function finish(finallyLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
}
},
"catch": function _catch(tryLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc === tryLoc) {
var record = entry.completion;
if ("throw" === record.type) {
var thrown = record.arg;
resetTryEntry(entry);
}
return thrown;
}
}
throw new Error("illegal catch attempt");
},
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
return this.delegate = {
iterator: values(iterable),
resultName: resultName,
nextLoc: nextLoc
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
}
}, exports;
}
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
})(regeneratorRuntime$1);
// TODO(Babel 8): Remove this file.
var runtime = regeneratorRuntime$1.exports();
var regenerator = runtime;
// Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
try {
regeneratorRuntime = runtime;
} catch (accidentalStrictMode) {
if ((typeof globalThis === "undefined" ? "undefined" : _typeof$1(globalThis)) === "object") {
globalThis.regeneratorRuntime = runtime;
} else {
Function("r", "regeneratorRuntime = r")(runtime);
}
}
var THEMES = {
LIGHT: {
PRIMARY: "#3B68CF",
SECONDARY: "#36393F",
TERTIARY: "#202225",
ACTION: "#3B68CF",
SUCCESS: "#6AFF9D",
WARNING: "#FF275B",
ERROR: "#FF275B",
INFO: "#5450F4",
TEXT_PRIMARY: "#000000",
TEXT_SECONDARY: "#101010",
ALABASTER: "#FAFAFA",
WHITE_SMOKE: "#F5F5F5"
},
DARK: {
PRIMARY: "#3B68CF",
SECONDARY: "#36393F",
TERTIARY: "#202225",
ACTION: "#3B68CF",
SUCCESS: "#6AFF9D",
WARNING: "#FF275B",
ERROR: "#FF275B",
INFO: "#5450F4",
TEXT_PRIMARY: "#FAFAFA",
TEXT_SECONDARY: "#F0F0F0",
TUNA: "#36393F",
DARK_JUNGLE: "#202225"
}
};
var BREAKPOINTS = {
"2XL": 1536,
XL: 1280,
LG: 1024,
MD: 768,
SM: 640
};
var MODALS = {
Z_INDEX_BASE: 500
};
var globals = {
THEMES: THEMES,
BREAKPOINTS: BREAKPOINTS,
MODALS: MODALS
};
var config = {
/**
* Globals
*/
globals: globals,
/**
* System
*/
system: {
/**
* Default theme
* @type {string}
* @default 'auto'
* @description Can be 'light', 'dark', 'auto', or any app theme identifier (kebabcase).
* See also ->
*/
defaultTheme: 'auto',
// 'light', 'dark' or 'auto'
/**
* Fallback theme
* @type {string}
* @default 'light''
* @description Fallback theme (!! Cannot be 'auto' !!)
* (based on available themes defined in the globals.config.json file)
*/
fallbackTheme: 'light' // '<theme>' (in kebab-case format)
},
/**
* Authentication
*/
auth: {
/**
* oAuth access token identifier (in browser LocalStorage)
* @default 'app_access_token'
* @type {string}
*/
accessTokenKey: 'app_access_token',
/**
* oAuth refresh token identifier (in browser LocalStorage)
* @default 'app_refresh_token'
* @type {string}
*/
refreshTokenKey: 'app_refresh_token'
},
/**
* Tailwind
*/
tailwind: {
/**
* Tailwind configuration file
* See also tailwind documentation (https://v2.tailwindcss.com/docs/configuration)
* @type {Object}
* @default undefined
*/
config: undefined
}
};
//
//
//
//
//
//
//
//
//
//
//
//
/**
* Root app component
*/
var script$d = {
name: 'App'
// components: {
// // ...
// },
// loadComponents () {
// return {
// Layout: Core.context.vue.components.layouts.Layout
// }
// }
};
/* script */
const __vue_script__$d = script$d;
/* template */
var __vue_render__$d = function() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c("div", { attrs: { id: "_app" } }, [_c("router-view")], 1)
};
var __vue_staticRenderFns__$d = [];
__vue_render__$d._withStripped = true;
/* style */
const __vue_inject_styles__$d = undefined;
/* scoped */
const __vue_scope_id__$d = undefined;
/* module identifier */
const __vue_module_identifier__$d = undefined;
/* functional template */
const __vue_is_functional_template__$d = false;
/* style inject */
/* style inject SSR */
var App = __vue_normalize__(
{ render: __vue_render__$d, staticRenderFns: __vue_staticRenderFns__$d },
__vue_inject_styles__$d,
__vue_script__$d,
__vue_scope_id__$d,
__vue_is_functional_template__$d,
__vue_module_identifier__$d,
undefined,
undefined
);
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
var script$c = {
name: 'Layout'
};
/* script */
const __vue_script__$c = script$c;
/* template */
var __vue_render__$c = function() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c(
"div",
{ attrs: { id: "_layout" } },
[_c("div", [_vm._v("Ceci est la navbar")]), _vm._v(" "), _vm._t("default")],
2
)
};
var __vue_staticRenderFns__$c = [];
__vue_render__$c._withStripped = true;
/* style */
const __vue_inject_styles__$c = undefined;
/* scoped */
const __vue_scope_id__$c = undefined;
/* module identifier */
const __vue_module_identifier__$c = undefined;
/* functional template */
const __vue_is_functional_template__$c = false;
/* style inject */
/* style inject SSR */
var Layout = __vue_normalize__(
{ render: __vue_render__$c, staticRenderFns: __vue_staticRenderFns__$c },
__vue_inject_styles__$c,
__vue_script__$c,
__vue_scope_id__$c,
__vue_is_functional_template__$c,
__vue_module_identifier__$c,
undefined,
undefined
);
var layouts = {
Layout: Layout
};
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
/**
* Page component
*/
var script$b = {
name: 'Page'
};
/* script */
const __vue_script__$b = script$b;
/* template */
var __vue_render__$b = function() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c(
"div",
{ attrs: { id: "_page" } },
[
_c("Layout", {
scopedSlots: _vm._u(
[
{
key: "default",
fn: function() {
return [_vm._t("default")]
},
proxy: true
}
],
null,
true
)
})
],
1
)
};
var __vue_staticRenderFns__$b = [];
__vue_render__$b._withStripped = true;
/* style */
const __vue_inject_styles__$b = undefined;
/* scoped */
const __vue_scope_id__$b = undefined;
/* module identifier */
const __vue_module_identifier__$b = undefined;
/* functional template */
const __vue_is_functional_template__$b = false;
/* style inject */
/* style inject SSR */
var Page = __vue_normalize__(
{ render: __vue_render__$b, staticRenderFns: __vue_staticRenderFns__$b },
__vue_inject_styles__$b,
__vue_script__$b,
__vue_scope_id__$b,
__vue_is_functional_template__$b,
__vue_module_identifier__$b,
undefined,
undefined
);
var commons = {
layouts: layouts,
Page: Page
};
// tools
var isDef = utils.isDef,
isNull$2 = utils.isNull;
/**
* BaseForm component
*/
var BaseForm = {
name: 'BaseForm',
data: function data() {
return {
form: {
fields: {},
globalError: null
}
};
},
computed: {
/**
* isFormValid: define if form is valid
*/
isFormValid: function isFormValid() {
for (var field in this.form.fields) {
var computedFieldIsValidName = this.$h.camelize('is_' + field + '_valid');
if (!this[computedFieldIsValidName]) return false; // Break
}
return true;
},
/**
* hasChanged method: define if a field has changed
* @returns {Boolean}
*/
hasChanged: function hasChanged() {
for (var field in this.form.fields) {
var computedFieldChangedName = this.$h.camelize(field + '_changed');
// If '<field>Changed' computed returns true
if (this[computedFieldChangedName]) return true; // Break
}
return false;
}
},
methods: {
/**
* Is form field in error
*
* @param {string} field - The field name
* @returns {boolean}
*/
isFieldInError: function isFieldInError(field) {
return Boolean(this.form.fields[field].errors);
},
/**
* Get form field error message
*
* @param {string} field - The field name
* @returns {string}
*/
getFieldErrorMessage: function getFieldErrorMessage(field) {
var message = '';
var fieldOptions = this.$options.form.fields[field];
if (isDef(this.form.fields[field])) {
var fieldErrors = this.form.fields[field].errors;
if (!isNull$2(fieldErrors)) {
// Get first error
// Does field have 'failed.ruleToErrorCode' map property defined ?
if (isDef(fieldOptions.failed) && isDef(fieldOptions.failed.ruleToErrorCode)) {
var rules = Object.keys(fieldOptions.failed.ruleToErrorCode);
for (var _i = 0, _rules = rules; _i < _rules.length; _i++) {
var rule = _rules[_i];
var errorCode = fieldOptions.failed.ruleToErrorCode[rule];
// If rule found in field errors keys
if (Object.keys(fieldErrors).indexOf(rule) !== -1) {
message = this.$t("errors.".concat(errorCode));
break;
}
}
} else {
message = this.$t('errors.e0051'); // This field is invalid
}
}
} else {
this.$root.log('warning', "Warning! Component extending BaseForm: getFieldErrorMessage() method: field '".concat(field, "' doesn't exist. Returns empty string..."), {
prod: false
});
}
return message;
},
/**
* Set fields errors & form global error
*
* @param {Object} response - The error response returned by the server
* @returns {void}
*/
setFormErrors: function setFormErrors(response) {
// const parsedResponse = parseErrorResponse(response)
var parsedResponse = response;
// If error => 'e0050' ('A field is invalid')
if (parsedResponse.errorCode === 'e0050' && isDef(parsedResponse.payload.fields)) {
// Set errors for each field
for (var field in parsedResponse.payload.fields) {
this.form.fields[field].errors = parsedResponse.payload.fields[field];
}
}
// Form global error
this.form.globalError = this.$t("errors.".concat(parsedResponse.errorCode));
},
/**
* Reset errors
*
* @returns {void}
*/
resetErrors: function resetErrors() {
for (var field in this.form.fields) {
this.form.fields[field].errors = null;
}
this.form.globalError = null;
},
/**
* Reset form with default values
* @returns {void}
*/
resetForm: function resetForm() {
// Loop on each field and set default value (defined in this.$options.form)
for (var field in this.form.fields) {
this.form.fields[field].value = this.$options.form.fields[field]["default"].call(this);
}
}
},
beforeCreate: function beforeCreate() {
var _this = this;
// Get data
var dataOptions = this.$options.data();
// Get computed
var computedOptions = this.$options.computed;
// Check if form option is defined
var formOptions = this.$options.form;
if (!formOptions) {
this.$root.log('error', 'Component extending BaseForm must have \'form\' option.');
} else {
// Get form.fields
if (!formOptions.fields) {
this.$root.log('error', 'Component extending BaseForm: no field properties found in \'form.fields\' option.');
} else {
var _loop = function _loop(field) {
/**
* default
*/
// Check if 'default' property is set
var fieldDefault = formOptions.fields[field]["default"];
// Error if state not defined
if (!isDef(fieldDefault)) _this.$root.log('error', "Component extending BaseForm: field '".concat(field, "' must have 'default' value."));
/**
* Add field to data
*/
dataOptions.form.fields[field] = {
value: null,
// hydrate value at "created" hook, see below
errors: null
};
/**
* value
*/
// Create name of computed for value
var computedFieldValueName = _this.$h.camelize(field + '_value');
// Assign computed
computedOptions[computedFieldValueName] = {
get: function get() {
return this.form.fields[field].value;
},
set: function set(value) {
this.form.fields[field].value = value;
}
};
/**
* changed
*/
// Create name of computed for changed status
var computedFieldChangedName = _this.$h.camelize(field + '_changed');
// Assign computed
computedOptions[computedFieldChangedName] = function () {
if (this.$options.form.fields[field].changed) {
return this.$options.form.fields[field].changed.call(this);
}
return this[computedFieldValueName] !== this.$options.form.fields[field]["default"].call(this);
};
/**
* state
*/
// Check if 'state' property is set
var fieldState = formOptions.fields[field].state;
// Create name of computed for state
var computedFieldStateName = _this.$h.camelize(field + '_state');
// Prepare computed
var stateComputed = null;
// Warning if state not defined
if (!isDef(fieldState)) {
_this.$root.log('warning', "Warning! Component extending BaseForm: field '".concat(field, "' doesn't have 'state' property. Generate '").concat(computedFieldStateName, "' default computed (returns true)."), {
prod: false
});
// Default returning true
stateComputed = function stateComputed() {
return true;
};
} else {
// Else: field defined state function
stateComputed = fieldState;
}
// Assign computed
computedOptions[computedFieldStateName] = stateComputed;
/**
* isValid
*/
// Check if 'isValid' property is set
var fieldIsValid = formOptions.fields[field].isValid;
// Create name of computed for isValid
var computedFieldIsValidName = _this.$h.camelize('is_' + field + '_valid');
// Prepare computed
var isValidComputed = null;
if (!isDef(fieldIsValid)) {
_this.$root.log('warning', "Warning! Component extending BaseForm: field '".concat(field, "' doesn't have 'isValid' property. Generate '").concat(computedFieldIsValidName, "' default computed (returns true)."), {
prod: false
});
isValidComputed = function isValidComputed() {
return true;
};
} else {
// Else: field defined isValid function
isValidComputed = fieldIsValid;
}
computedOptions[computedFieldIsValidName] = isValidComputed;
};
// Loop on each field
for (var field in formOptions.fields) {
_loop(field);
}
}
}
// Assign data
this.$options.data = function () {
return dataOptions;
};
// Get computed
this.$options.computed = computedOptions;
},
created: function created() {
this.resetForm(); // Setup form first time
}
};
//
const { validateEmail } = utils;
/**
* ForgotPasswordForm component
*/
var script$a = {
name: 'ForgotPasswordForm',
extends: BaseForm,
// 'form' option (see src/components/commons/form/BaseForm)
form: {
fields: {
/**
* email
*/
email: {
// Default: generate 'emailValue' & 'emailChanged'
default: function () {
return ''
},
// Generate: 'emailState'
state: function () {
return !this.isFieldInError('email') // No errors ?
? this.emailValue.length > 0 // Filled ?
? this.isEmailValid // Valid ?
: true
: false // else -> errors
},
// Generate: 'isEmailValid'
isValid: function () {
return validateEmail(this.emailValue)
}
}
}
},
methods: {
// Map actions from 'Users' store module
...mapActions('Users', [
'forgotPassword'
]),
/**
* Handle click on 'confirm' submit button.
*
* @param {Object} evt - The event payload
* @returns {void}
*/
async handleOk (evt) {
// Prevent click
evt.preventDefault();
// Reset errors before
this.resetErrors();
// Wait for forgotPassword function
const forgotPasswordResponse = await this.forgotPassword({
email: this.emailValue
});
// If passed
if (!(forgotPasswordResponse instanceof Error)) {
// Emit 'email-sent' event
this.$emit('email-sent');
// Else parse server error
} else {
this.setFormErrors(forgotPasswordResponse); // Set form errors from response
}
}
}
};
/* script */
const __vue_script__$a = script$a;
/* template */
var __vue_render__$a = function() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c(
"form",
{ staticClass: "w-full", attrs: { id: "forgot-password-form" } },
[
_vm.form.globalError
? _c(
"t-alert",
{ staticClass: "mb-8", attrs: { variant: "error", show: "" } },
[
_c("p", { staticClass: "text-error" }, [
_vm._v(_vm._s(_vm.form.globalError))
])
]
)
: _vm._e(),
_vm._v(" "),
_c("Input", {
staticClass: "mb-4",
attrs: {
name: "email",
variant: _vm.emailState ? "primary" : "error",
state: _vm.emailState,
label: _vm.$h.capitalize(_vm.$t("user.email")),
placeholder: _vm.$h.capitalize(_vm.$t("user.email")),
error: _vm.getFieldErrorMessage("email"),
fluid: ""
},
model: {
value: _vm.emailValue,
callback: function($$v) {
_vm.emailValue = $$v;
},
expression: "emailValue"
}
}),
_vm._v(" "),
_c(
"Button",
{
attrs: { variant: "action", disabled: !_vm.isFormValid, fluid: "" },
nativeOn: {
click: function($event) {
return _vm.handleOk.apply(null, arguments)
}
}
},
[
_vm._v(
"\n " +
_vm._s(_vm._f("capitalize")(_vm.$t("global.confirm"))) +
"\n "
)
]
)
],
1
)
};
var __vue_staticRenderFns__$a = [];
__vue_render__$a._withStripped = true;
/* style */
const __vue_inject_styles__$a = undefined;
/* scoped */
const __vue_scope_id__$a = undefined;
/* module identifier */
const __vue_module_identifier__$a = undefined;
/* functional template */
const __vue_is_functional_template__$a = false;
/* style inject */
/* style inject SSR */
var ForgotPasswordForm = __vue_normalize__(
{ render: __vue_render__$a, staticRenderFns: __vue_staticRenderFns__$a },
__vue_inject_styles__$a,
__vue_script__$a,
__vue_scope_id__$a,
__vue_is_functional_template__$a,
__vue_module_identifier__$a,
undefined,
undefined
);
//
/**
* ForgotPassword component
*/
var script$9 = {
name: 'ForgotPassword',
components: {
ForgotPasswordForm
},
data () {
return {
emailSent: false
}
}
};
/* script */
const __vue_script__$9 = script$9;
/* template */
var __vue_render__$9 = function() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c(
"div",
{
staticClass:
"xl:w-1/4 lg:w-1/3 md:w-2/5 sm:w-1/2 w-full mx-auto py-16 px-4"
},
[
_c("h1", { staticClass: "text-center" }, [
_vm._v(
_vm._s(_vm._f("capitalize")(_vm.$t("views.ForgotPassword.title")))
)
]),
_vm._v(" "),
_c(
"div",
[
!_vm.emailSent
? _c("ForgotPasswordForm", {
on: {
"email-sent": function($event) {
_vm.emailSent = true;
}
}
})
: _c("div", [
_c(
"div",
{ staticClass: "text-center mb-4" },
[
_c("v-icon", {
staticClass: "text-action",
attrs: { name: "paper-plane", scale: "5" }
})
],
1
),
_vm._v(" "),
_c("p", [_vm._v(_vm._s(_vm.$t("user.resetPasswordEmailSent")))])
])
],
1
)
]
)
};
var __vue_staticRenderFns__$9 = [];
__vue_render__$9._withStripped = true;
/* style */
const __vue_inject_styles__$9 = undefined;
/* scoped */
const __vue_scope_id__$9 = undefined;
/* module identifier */
const __vue_module_identifier__$9 = undefined;
/* functional template */
const __vue_is_functional_template__$9 = false;
/* style inject */
/* style inject SSR */
var Index$8 = __vue_normalize__(
{ render: __vue_render__$9, staticRenderFns: __vue_staticRenderFns__$9 },
__vue_inject_styles__$9,
__vue_script__$9,
__vue_scope_id__$9,
__vue_is_functional_template__$9,
__vue_module_identifier__$9,
undefined,
undefined
);
var forgotPassword = {
ForgotPasswordForm: ForgotPasswordForm,
Index: Index$8
};
//
/**
* Home page component
*/
var script$8 = {
applyMixins () {
return [
Core.context.vue.mixins.RouteComponentMixin
]
}
};
/* script */
const __vue_script__$8 = script$8;
/* template */
var __vue_render__$8 = function() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c(
"Page",
[
_c(
"h1",
[_c("v-icon", { attrs: { name: "times" } }), _vm._v(" Title!")],
1
),
_vm._v(" "),
_c("ScorpionLogo", { attrs: { id: "_logo" } }),
_vm._v(" "),
_c(
"i18n",
{
staticClass: "text-center mt-6 pb-4",
attrs: { path: "views.Home.subTitle1", tag: "h1" }
},
[
_c("span", { staticClass: "_font-vice-city-sans" }, [
_vm._v(_vm._s(_vm.GLOBALS.__APP_NAME__))
])
]
),
_vm._v(" "),
_c(
"Button",
{ staticClass: "mx-auto", attrs: { variant: "primary", to: "/about" } },
[_vm._v("\n " + _vm._s(_vm.$t("views.Home.aboutButton")) + "\n ")]
)
],
1
)
};
var __vue_staticRenderFns__$8 = [];
__vue_render__$8._withStripped = true;
/* style */
const __vue_inject_styles__$8 = undefined;
/* scoped */
const __vue_scope_id__$8 = undefined;
/* module identifier */
const __vue_module_identifier__$8 = undefined;
/* functional template */
const __vue_is_functional_template__$8 = false;
/* style inject */
/* style inject SSR */
var Index$7 = __vue_normalize__(
{ render: __vue_render__$8, staticRenderFns: __vue_staticRenderFns__$8 },
__vue_inject_styles__$8,
__vue_script__$8,
__vue_scope_id__$8,
__vue_is_functional_template__$8,
__vue_module_identifier__$8,
undefined,
undefined
);
var home = {
Index: Index$7
};
//
/**
* Login page component
*/
var script$7 = {
computed: {
/**
* Defines if we need to display a message that indicates the route need authentication (private route)
* @return {boolean}
*/
showNeedAuthMessage: function () {
// If the query param 'redirect' is set, user comes from location that needs auth
return Boolean(this.query.redirect)
}
},
applyMixins () {
return [
Core.context.vue.mixins.RouteComponentMixin
]
},
bindComponents () {
return {
LoginForm: Core.context.vue.components.public.views.login.LoginForm
}
}
};
/* script */
const __vue_script__$7 = script$7;
/* template */
var __vue_render__$7 = function() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c(
"Page",
[
_c("h1", { staticClass: "text-center mb-4" }, [
_vm._v(_vm._s(_vm._f("capitalize")(_vm.$t("user.signIn"))))
]),
_vm._v(" "),
_vm.showNeedAuthMessage
? _c("t-alert", { staticClass: "mb-8", attrs: { show: "" } }, [
_c("p", { staticClass: "text-warning" }, [
_vm._v(
_vm._s(_vm._f("capitalize")(_vm.$t("global.pageRequiresAuth")))
)
])
])
: _vm._e(),
_vm._v(" "),
_c(
"div",
[
_c("LoginForm", { staticClass: "mb-4" }),
_vm._v(" "),
_c("Link", { attrs: { to: "/sign-up" } }, [
_vm._v(_vm._s(_vm._f("capitalize")(_vm.$t("user.signUp"))))
])
],
1
)
],
1
)
};
var __vue_staticRenderFns__$7 = [];
__vue_render__$7._withStripped = true;
/* style */
const __vue_inject_styles__$7 = undefined;
/* scoped */
const __vue_scope_id__$7 = undefined;
/* module identifier */
const __vue_module_identifier__$7 = undefined;
/* functional template */
const __vue_is_functional_template__$7 = false;
/* style inject */
/* style inject SSR */
var Index$6 = __vue_normalize__(
{ render: __vue_render__$7, staticRenderFns: __vue_staticRenderFns__$7 },
__vue_inject_styles__$7,
__vue_script__$7,
__vue_scope_id__$7,
__vue_is_functional_template__$7,
__vue_module_identifier__$7,
undefined,
undefined
);
//
/**
* Login component
*/
var script$6 = {
name: 'Login',
applyMixins () {
return [
Core.context.vue.components.commons.form.BaseForm
]
},
// 'form' option (see src/components/commons/form/BaseForm)
form: {
fields: {
/**
* email
*/
email: {
// Default: generate 'emailValue' & 'emailChanged'
default: function () {
return ''
},
// Generate: 'isEmailValid'
isValid: function () {
return this.emailValue.length > 0
}
},
/**
* password
*/
password: {
// Default: generate 'passwordValue' & 'passwordChanged'
default: function () {
return ''
},
// Generate: 'isPasswordValid'
isValid: function () {
return this.passwordValue.length > 0
}
}
}
},
methods: {
/**
* Handle click on 'login' submit button.
*
* Call 'auth' module login method ([auth module](../modules/auth)).
* @param {Object} evt - The event payload
* @returns {void}
*/
async handleOk (evt) {
// Prevent click
evt.preventDefault();
// Reset errors before
this.resetErrors();
// Reset loginFailedMessage
this.loginFailedMessage = false;
// Wait for login function
const loginResponse = await this.$root.auth.login({
data: {
email: this.emailValue,
password: this.passwordValue
}
});
// If passed
if (!(loginResponse instanceof Error)) {
// Go to redirect or home
const to = this.$route.query.redirect ? `/#${this.$route.query.redirect}` : '/';
window.location = to;
// Else parse server error
} else {
this.setFormErrors(loginResponse); // Set form errors from response
}
}
}
};
/* script */
const __vue_script__$6 = script$6;
/* template */
var __vue_render__$6 = function() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c(
"form",
{ staticClass: "w-full", attrs: { id: "login-form" } },
[
_vm.form.globalError
? _c(
"t-alert",
{ staticClass: "mb-8", attrs: { variant: "error", show: "" } },
[
_c("p", { staticClass: "text-error" }, [
_vm._v(_vm._s(_vm.form.globalError))
])
]
)
: _vm._e(),
_vm._v(" "),
_c("Input", {
attrs: {
name: "email",
variant: _vm.emailState ? "primary" : "error",
state: _vm.emailState,
label: _vm.$h.capitalize(_vm.$t("user.email")),
placeholder: _vm.$h.capitalize(_vm.$t("user.email")),
error: _vm.getFieldErrorMessage("email"),
fluid: ""
},
model: {
value: _vm.emailValue,
callback: function($$v) {
_vm.emailValue = $$v;
},
expression: "emailValue"
}
}),
_vm._v(" "),
_c("InputPassword", {
attrs: {
name: "password",
variant: _vm.passwordState ? "primary" : "error",
state: _vm.passwordState,
placeholder: _vm.$h.capitalize(_vm.$t("user.password")),
label: _vm.$h.capitalize(_vm.$t("user.password")),
fluid: ""
},
model: {
value: _vm.passwordValue,
callback: function($$v) {
_vm.passwordValue = $$v;
},
expression: "passwordValue"
}
}),
_vm._v(" "),
_c(
"p",
{ staticClass: "mb-4" },
[
_c(
"Link",
{ staticClass: "text-sm", attrs: { to: "/forgot-password" } },
[_vm._v(_vm._s(_vm.$t("user.forgotPassword")))]
)
],
1
),
_vm._v(" "),
_c(
"Button",
{
attrs: { variant: "primary", disabled: !_vm.isFormValid, fluid: "" },
nativeOn: {
click: function($event) {
return _vm.handleOk.apply(null, arguments)
}
}
},
[
_vm._v(
"\n " +
_vm._s(_vm._f("capitalize")(_vm.$t("user.login"))) +
"\n "
)
]
)
],
1
)
};
var __vue_staticRenderFns__$6 = [];
__vue_render__$6._withStripped = true;
/* style */
const __vue_inject_styles__$6 = undefined;
/* scoped */
const __vue_scope_id__$6 = undefined;
/* module identifier */
const __vue_module_identifier__$6 = undefined;
/* functional template */
const __vue_is_functional_template__$6 = false;
/* style inject */
/* style inject SSR */
var LoginForm = __vue_normalize__(
{ render: __vue_render__$6, staticRenderFns: __vue_staticRenderFns__$6 },
__vue_inject_styles__$6,
__vue_script__$6,
__vue_scope_id__$6,
__vue_is_functional_template__$6,
__vue_module_identifier__$6,
undefined,
undefined
);
var login$1 = {
Index: Index$6,
LoginForm: LoginForm
};
//
/**
* Login page component
*/
var script$5 = {
applyMixins () {
return [
Core.context.vue.mixins.RouteComponentMixin
]
}
};
/* script */
const __vue_script__$5 = script$5;
/* template */
var __vue_render__$5 = function() {
var _vm = this;
var _h = _vm.$createElement;
var _c = _vm._self._c || _h;
return _c("Page", [
_c(
"div",
{
staticClass:
"xl:w-1/3 lg:w-1/2 md:w-1/2 sm:w-1/2 w-full mx-auto py-16 px-4"
},
[
_c("h1", { staticClass: "text-center mb-8" }, [_vm._v("404 :(")]),
_vm._v(" "),
_c("h2", { staticClass: "text-center" }, [
_vm._v(_vm._s(_vm._f("capitalize")(_vm.$t("global.pageNotFound"))))
])
]
)
])
};
var __vue_staticRenderFns__$5 = [];
__vue_render__$5._withStripped = true;
/* style */
const __vue_inject_styles__$5 = undefined;
/* scoped */
const __vue_scope_id__$5 = undefined;
/* module identifier */
const __vue_module_identifier__$5 = undefined;
/* functional template */
const __vue_is_functional_template__$5 = false;
/* style inject */
/* style inject SSR */
var Index$5 = __vue_normalize__(
{ render: __vue_render__$5, staticRenderFns: __vue_staticRenderFns__$5 },
__vu