frontend admin refakctorálás
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
import { defineComponent, ref, computed, unref, useSSRContext } from 'vue';
|
||||
import { ssrRenderAttrs, ssrInterpolate, ssrIncludeBooleanAttr, ssrRenderList, ssrRenderClass, ssrRenderAttr, ssrRenderStyle } from 'vue/server-renderer';
|
||||
import { a as useI18n } from './server.mjs';
|
||||
import { _ as _export_sfc } from './_plugin-vue_export-helper-1tPrXgE0.mjs';
|
||||
import '../nitro/nitro.mjs';
|
||||
import 'node:http';
|
||||
import 'node:https';
|
||||
import 'node:events';
|
||||
import 'node:buffer';
|
||||
import 'node:fs';
|
||||
import 'node:path';
|
||||
import 'node:crypto';
|
||||
import 'vue-router';
|
||||
import 'node:url';
|
||||
import 'pinia';
|
||||
import '../routes/renderer.mjs';
|
||||
import 'vue-bundle-renderer/runtime';
|
||||
import 'unhead/server';
|
||||
import 'devalue';
|
||||
import 'unhead/utils';
|
||||
import 'unhead/plugins';
|
||||
|
||||
const _sfc_main = /* @__PURE__ */ defineComponent({
|
||||
__name: "validation-rules",
|
||||
__ssrInlineRender: true,
|
||||
setup(__props) {
|
||||
const { t } = useI18n();
|
||||
const loading = ref(true);
|
||||
const error = ref(false);
|
||||
const saving = ref(false);
|
||||
const formError = ref("");
|
||||
const toast = ref("");
|
||||
const lastSaved = ref("");
|
||||
const rules = ref([]);
|
||||
const originalValues = ref({});
|
||||
const editedValues = ref({});
|
||||
const hasChanges = computed(() => {
|
||||
return Object.keys(editedValues.value).length > 0;
|
||||
});
|
||||
function hasRuleChanged(ruleKey) {
|
||||
return ruleKey in editedValues.value;
|
||||
}
|
||||
function getOriginalValue(ruleKey) {
|
||||
var _a;
|
||||
return (_a = originalValues.value[ruleKey]) != null ? _a : 0;
|
||||
}
|
||||
function getProgressWidth(ruleKey) {
|
||||
var _a, _b;
|
||||
const val = (_b = (_a = editedValues.value[ruleKey]) != null ? _a : originalValues.value[ruleKey]) != null ? _b : 0;
|
||||
return val + "%";
|
||||
}
|
||||
function getValueBadgeClass(val) {
|
||||
if (val >= 80) return "bg-emerald-500/20 text-emerald-400";
|
||||
if (val >= 50) return "bg-amber-500/20 text-amber-400";
|
||||
return "bg-slate-500/20 text-slate-400";
|
||||
}
|
||||
function getProgressBarClass(val) {
|
||||
if (val >= 80) return "bg-emerald-500";
|
||||
if (val >= 50) return "bg-amber-500";
|
||||
return "bg-slate-500";
|
||||
}
|
||||
return (_ctx, _push, _parent, _attrs) => {
|
||||
_push(`<div${ssrRenderAttrs(_attrs)} data-v-7a2ac5d4><div class="mb-8" data-v-7a2ac5d4><h1 class="text-2xl font-bold text-white" data-v-7a2ac5d4>${ssrInterpolate(unref(t)("gamification.validation_rules.title"))}</h1><p class="text-slate-400 mt-1" data-v-7a2ac5d4>${ssrInterpolate(unref(t)("gamification.validation_rules.subtitle"))}</p></div>`);
|
||||
if (unref(loading)) {
|
||||
_push(`<div class="flex items-center justify-center py-20" data-v-7a2ac5d4><div class="text-slate-400 flex items-center gap-3" data-v-7a2ac5d4><svg class="w-5 h-5 animate-spin" fill="none" stroke="currentColor" viewBox="0 0 24 24" data-v-7a2ac5d4><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" data-v-7a2ac5d4></path></svg><span data-v-7a2ac5d4>${ssrInterpolate(unref(t)("gamification.validation_rules.loading"))}</span></div></div>`);
|
||||
} else if (unref(error)) {
|
||||
_push(`<div class="bg-rose-500/10 border border-rose-500/30 rounded-xl p-6 mb-8" data-v-7a2ac5d4><p class="text-rose-400" data-v-7a2ac5d4>${ssrInterpolate(unref(t)("gamification.validation_rules.load_error"))}</p><button class="mt-3 text-sm text-rose-300 hover:text-rose-200 underline" data-v-7a2ac5d4>${ssrInterpolate(unref(t)("gamification.validation_rules.retry"))}</button></div>`);
|
||||
} else {
|
||||
_push(`<!--[--><div class="mb-6 flex items-center justify-between" data-v-7a2ac5d4><div class="flex items-center gap-3" data-v-7a2ac5d4><span class="text-sm text-slate-500" data-v-7a2ac5d4>${ssrInterpolate(unref(t)("gamification.validation_rules.last_saved"))} ${ssrInterpolate(unref(lastSaved) ? unref(lastSaved) : "\u2014")}</span></div><button${ssrIncludeBooleanAttr(unref(saving) || !unref(hasChanges)) ? " disabled" : ""} class="px-4 py-2 bg-emerald-600 hover:bg-emerald-500 disabled:bg-emerald-600/50 text-white rounded-lg text-sm font-medium transition flex items-center gap-2" data-v-7a2ac5d4>`);
|
||||
if (unref(saving)) {
|
||||
_push(`<svg class="w-4 h-4 animate-spin" fill="none" stroke="currentColor" viewBox="0 0 24 24" data-v-7a2ac5d4><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15" data-v-7a2ac5d4></path></svg>`);
|
||||
} else {
|
||||
_push(`<!---->`);
|
||||
}
|
||||
_push(` ${ssrInterpolate(unref(saving) ? unref(t)("gamification.validation_rules.saving") : unref(t)("gamification.validation_rules.save_rules"))}</button></div><div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8" data-v-7a2ac5d4><!--[-->`);
|
||||
ssrRenderList(unref(rules), (rule) => {
|
||||
var _a;
|
||||
_push(`<div class="bg-slate-800 rounded-xl border border-slate-700 p-6" data-v-7a2ac5d4><div class="flex items-start justify-between mb-4" data-v-7a2ac5d4><div data-v-7a2ac5d4><h2 class="text-lg font-semibold text-white font-mono" data-v-7a2ac5d4>${ssrInterpolate(rule.rule_key)}</h2><p class="text-sm text-slate-400 mt-1" data-v-7a2ac5d4>${ssrInterpolate(rule.description)}</p></div><span class="${ssrRenderClass([getValueBadgeClass(rule.rule_value), "text-xs font-medium px-2 py-1 rounded-full"])}" data-v-7a2ac5d4>${ssrInterpolate(rule.rule_value)}</span></div><div class="space-y-3" data-v-7a2ac5d4><div class="flex items-center gap-3" data-v-7a2ac5d4><input${ssrRenderAttr("value", (_a = unref(editedValues)[rule.rule_key]) != null ? _a : rule.rule_value)} type="number" min="0" max="100" class="w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white text-sm text-center focus:outline-none focus:ring-2 focus:ring-indigo-500/50" data-v-7a2ac5d4></div><div class="w-full bg-slate-700 rounded-full h-2 overflow-hidden" data-v-7a2ac5d4><div class="${ssrRenderClass([getProgressBarClass(rule.rule_value), "h-full rounded-full transition-all duration-300"])}" style="${ssrRenderStyle({ width: getProgressWidth(rule.rule_key) + "%" })}" data-v-7a2ac5d4></div></div>`);
|
||||
if (hasRuleChanged(rule.rule_key)) {
|
||||
_push(`<div class="flex items-center gap-1 text-xs" data-v-7a2ac5d4><span class="text-amber-400" data-v-7a2ac5d4>${ssrInterpolate(unref(t)("gamification.validation_rules.changed_from"))} ${ssrInterpolate(getOriginalValue(rule.rule_key))}</span><svg class="w-3 h-3 text-amber-400" fill="none" stroke="currentColor" viewBox="0 0 24 24" data-v-7a2ac5d4><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7l5 5m0 0l-5 5m5-5H6" data-v-7a2ac5d4></path></svg><span class="text-emerald-400" data-v-7a2ac5d4>${ssrInterpolate(unref(editedValues)[rule.rule_key])}</span></div>`);
|
||||
} else {
|
||||
_push(`<!---->`);
|
||||
}
|
||||
_push(`</div></div>`);
|
||||
});
|
||||
_push(`<!--]--></div><div class="bg-slate-800/50 border border-slate-700/50 rounded-xl p-6" data-v-7a2ac5d4><div class="flex items-start gap-3" data-v-7a2ac5d4><svg class="w-5 h-5 text-indigo-400 flex-shrink-0 mt-0.5" fill="none" stroke="currentColor" viewBox="0 0 24 24" data-v-7a2ac5d4><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" data-v-7a2ac5d4></path></svg><div data-v-7a2ac5d4><h3 class="text-sm font-medium text-white mb-1" data-v-7a2ac5d4>${ssrInterpolate(unref(t)("gamification.validation_rules.info_title"))}</h3><p class="text-sm text-slate-400" data-v-7a2ac5d4>${ssrInterpolate(unref(t)("gamification.validation_rules.info_text"))}</p></div></div></div><!--]-->`);
|
||||
}
|
||||
if (unref(formError)) {
|
||||
_push(`<div class="fixed bottom-6 right-6 z-50 bg-rose-600 text-white px-4 py-3 rounded-lg shadow-lg text-sm flex items-center gap-2" data-v-7a2ac5d4><svg class="w-4 h-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" data-v-7a2ac5d4><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" data-v-7a2ac5d4></path></svg> ${ssrInterpolate(unref(formError))}</div>`);
|
||||
} else {
|
||||
_push(`<!---->`);
|
||||
}
|
||||
if (unref(toast)) {
|
||||
_push(`<div class="fixed bottom-6 right-6 z-50 bg-emerald-600 text-white px-4 py-3 rounded-lg shadow-lg text-sm flex items-center gap-2 animate-slide-up" data-v-7a2ac5d4><svg class="w-4 h-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" data-v-7a2ac5d4><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" data-v-7a2ac5d4></path></svg> ${ssrInterpolate(unref(toast))}</div>`);
|
||||
} else {
|
||||
_push(`<!---->`);
|
||||
}
|
||||
_push(`</div>`);
|
||||
};
|
||||
}
|
||||
});
|
||||
const _sfc_setup = _sfc_main.setup;
|
||||
_sfc_main.setup = (props, ctx) => {
|
||||
const ssrContext = useSSRContext();
|
||||
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("pages/gamification/validation-rules.vue");
|
||||
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
|
||||
};
|
||||
const validationRules = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-7a2ac5d4"]]);
|
||||
|
||||
export { validationRules as default };
|
||||
//# sourceMappingURL=validation-rules-CgWl8yP4.mjs.map
|
||||
Reference in New Issue
Block a user