Files
site/apps/web/public/wesp/js/modules/recipes/recipe-skeleton.js
T

36 lines
1.2 KiB
JavaScript

const LIST_LABELS = {
dispensers: "Загрузка кормораздатчиков",
periods: "Загрузка периодов",
recipes: "Загрузка рейсов",
mill: "Загрузка рецептов",
period: "Загрузка рейсов",
};
/**
* Structural loading — один spinner на список (не 4 копии).
*/
export function buildRecipeRowsSkeletonHtml(variant = "period") {
const label = LIST_LABELS[variant] || LIST_LABELS.period;
return `<div class="zt-loading-list dashboard-list-skeleton" data-skeleton-variant="${variant}" aria-busy="true" aria-label="${label}">
<div class="zt-loading-placeholder">
<div class="zt-spinner" role="status" aria-hidden="true"></div>
<p class="zt-loading-caption">${label}…</p>
</div>
</div>`;
}
export function cloneTemplateOuterHtml(templateId) {
const tpl = document.getElementById(templateId);
const el = tpl?.content?.firstElementChild;
if (!el) return "";
return el.outerHTML;
}
export function cloneTemplateInto(container, templateId) {
const tpl = document.getElementById(templateId);
const el = tpl?.content?.firstElementChild;
if (!el || !container) return false;
container.appendChild(el.cloneNode(true));
return true;
}