feat(asset): animate asset detail drawer
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{% extends "erp_base.html" %}
|
||||
{% set force_sidebar_collapsed = true %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/asset.css?v=20261006b">{% endblock %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/asset.css?v=20261006c">{% endblock %}
|
||||
{% block content %}
|
||||
<div id="asset-app" class="am-workspace" data-csrf="{{ csrf_token }}" data-configured="{{ 'true' if configured else 'false' }}" data-can-delete="{{ 'true' if can_delete else 'false' }}">
|
||||
<aside class="am-nav" aria-label="자산관리 탐색">
|
||||
@@ -67,4 +67,4 @@
|
||||
<dialog id="am-photo" class="am-dialog" aria-labelledby="am-photo-title"><div class="am-dialog-head"><h2 id="am-photo-title">자산 사진 등록</h2><button type="button" class="am-close" data-close="am-photo" aria-label="사진 등록 닫기">×</button></div><form id="am-photo-form" class="am-form"><p class="am-form-hint">JPG · PNG · WebP, 파일당 8 MB 이하 · 자산당 최대 10장. 촬영 위치 정보는 제거해 보관합니다.</p><label>사진 선택<input id="am-photo-file" type="file" accept="image/jpeg,image/png,image/webp" required></label><div class="am-form-error" role="alert" hidden></div><div class="am-dialog-footer"><button type="button" class="erp-btn erp-btn-outline" data-close="am-photo">취소</button><button type="submit" class="erp-btn erp-btn-primary">사진 저장</button></div></form></dialog>
|
||||
<dialog id="am-delete" class="am-dialog" aria-labelledby="am-delete-title"><div class="am-dialog-head"><h2 id="am-delete-title">자산 삭제</h2><button type="button" class="am-close" data-close="am-delete" aria-label="삭제 창 닫기">×</button></div><form id="am-delete-form" class="am-form"><p class="am-warning" id="am-delete-hint"></p><p class="am-form-hint">자산대장과 현황에서 제외됩니다. 사진·보고서·처리 이력은 보존됩니다.</p><label>삭제할 자산번호 확인<input id="am-delete-confirm" required autocomplete="off"></label><label>삭제 사유<textarea id="am-delete-note" required maxlength="2000" rows="3"></textarea></label><div class="am-form-error" role="alert" hidden></div><div class="am-dialog-footer"><button type="button" class="erp-btn erp-btn-outline" data-close="am-delete">취소</button><button type="submit" class="erp-btn am-danger">자산 삭제</button></div></form></dialog>
|
||||
{% endblock %}
|
||||
{% block scripts %}<script id="am-config" type="application/json">{{ {"categories":categories,"statuses":statuses}|tojson }}</script><script src="/static/asset.js?v=20261006b" defer></script>{% endblock %}
|
||||
{% block scripts %}<script id="am-config" type="application/json">{{ {"categories":categories,"statuses":statuses}|tojson }}</script><script src="/static/asset.js?v=20261006c" defer></script>{% endblock %}
|
||||
|
||||
@@ -683,11 +683,21 @@
|
||||
max-height: 100dvh;
|
||||
border-radius: 14px 0 0 14px;
|
||||
overflow: auto;
|
||||
will-change: transform;
|
||||
}
|
||||
.am-drawer.am-closing {
|
||||
pointer-events: none;
|
||||
}
|
||||
.am-dialog::backdrop,
|
||||
.am-drawer::backdrop {
|
||||
background: #0004;
|
||||
}
|
||||
.am-drawer::backdrop {
|
||||
transition: background-color 220ms ease;
|
||||
}
|
||||
.am-drawer.am-closing::backdrop {
|
||||
background: #0000;
|
||||
}
|
||||
body:has(dialog[open]) {
|
||||
overflow: hidden;
|
||||
}
|
||||
@@ -1352,4 +1362,7 @@ body:has(dialog[open]) {
|
||||
.am-kpi {
|
||||
transition: none;
|
||||
}
|
||||
.am-drawer::backdrop {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
||||
+81
-3
@@ -304,19 +304,71 @@
|
||||
await loadDashboard();
|
||||
await loadList();
|
||||
}
|
||||
let drawerAnimation = null;
|
||||
let drawerMotionId = 0;
|
||||
function moveDrawer(opening) {
|
||||
const drawer = $("am-detail"),
|
||||
motionId = ++drawerMotionId;
|
||||
// 진행 중인 위치에서 방향을 바꾸므로 빠른 열기·닫기에도 패널이 튀지 않습니다.
|
||||
const from =
|
||||
drawerAnimation || !opening
|
||||
? getComputedStyle(drawer).transform
|
||||
: "translateX(100%)";
|
||||
drawerAnimation?.cancel();
|
||||
drawerAnimation = null;
|
||||
drawer.classList.toggle("am-closing", !opening);
|
||||
const finish = () => {
|
||||
if (motionId !== drawerMotionId) return;
|
||||
if (!opening) drawer.close();
|
||||
drawer.classList.remove("am-closing");
|
||||
drawerAnimation?.cancel();
|
||||
drawerAnimation = null;
|
||||
};
|
||||
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
const animation = drawer.animate(
|
||||
[
|
||||
{ transform: from },
|
||||
{ transform: opening ? "translateX(0)" : "translateX(100%)" },
|
||||
],
|
||||
{
|
||||
duration: opening ? 280 : 220,
|
||||
easing: opening
|
||||
? "cubic-bezier(.22,1,.36,1)"
|
||||
: "cubic-bezier(.4,0,1,1)",
|
||||
fill: "both",
|
||||
},
|
||||
);
|
||||
animation.id = "asset-drawer";
|
||||
drawerAnimation = animation;
|
||||
animation.finished.then(finish, () => {});
|
||||
}
|
||||
function show(id) {
|
||||
$(id).showModal();
|
||||
const dialog = $(id);
|
||||
if (id === "am-detail") {
|
||||
if (!dialog.open) {
|
||||
dialog.showModal();
|
||||
moveDrawer(true);
|
||||
} else if (dialog.classList.contains("am-closing")) moveDrawer(true);
|
||||
return;
|
||||
}
|
||||
if (!dialog.open) dialog.showModal();
|
||||
}
|
||||
function close(id) {
|
||||
// 저장 중에는 창을 닫거나 다시 제출해서 요청을 겹치지 않게 합니다.
|
||||
if ($(id).querySelector('form[data-busy="true"]')) return;
|
||||
if (id === "am-detail") {
|
||||
if (!$(id).open || $(id).classList.contains("am-closing")) return;
|
||||
++state.detailSeq;
|
||||
state.detail = null;
|
||||
syncURL();
|
||||
moveDrawer(false);
|
||||
return;
|
||||
}
|
||||
if (id === "am-upload") ++state.previewSeq;
|
||||
$(id).close();
|
||||
if (id === "am-detail") syncURL();
|
||||
}
|
||||
function info(label, value, wide = false) {
|
||||
return `<div class="am-info-field${wide ? " am-wide" : ""}"><span>${esc(label)}</span><strong>${esc(value || "—")}</strong></div>`;
|
||||
@@ -410,7 +462,7 @@
|
||||
const seq = ++state.detailSeq;
|
||||
state.tab = tab;
|
||||
state.reportView = null;
|
||||
if (!$("am-detail").open) show("am-detail");
|
||||
show("am-detail");
|
||||
$("am-detail-title").textContent = "자산 정보";
|
||||
$("am-detail-tag").textContent = "불러오는 중";
|
||||
$("am-detail-content").innerHTML =
|
||||
@@ -979,6 +1031,8 @@
|
||||
document.addEventListener("click", (event) => {
|
||||
const button = event.target.closest("button,a");
|
||||
if (!button) return;
|
||||
// 닫히는 동안 키보드로 이전 패널의 처리 버튼을 실행하지 않게 합니다.
|
||||
if (button.closest("#am-detail.am-closing")) return;
|
||||
if (button.dataset.close) {
|
||||
close(button.dataset.close);
|
||||
return;
|
||||
@@ -1102,6 +1156,30 @@
|
||||
event.preventDefault();
|
||||
close(id);
|
||||
});
|
||||
// 바깥에서 누르고 놓은 경우만 닫습니다. 패널 안에서 바깥으로 드래그하면 유지합니다.
|
||||
let drawerBackdropPressed = false;
|
||||
const outsideDrawer = (event) => {
|
||||
const drawer = $("am-detail"),
|
||||
rect = drawer.getBoundingClientRect();
|
||||
return (
|
||||
event.target === drawer &&
|
||||
(event.clientX < rect.left ||
|
||||
event.clientX >= rect.right ||
|
||||
event.clientY < rect.top ||
|
||||
event.clientY >= rect.bottom)
|
||||
);
|
||||
};
|
||||
$("am-detail").addEventListener("pointerdown", (event) => {
|
||||
drawerBackdropPressed = event.button === 0 && outsideDrawer(event);
|
||||
});
|
||||
$("am-detail").addEventListener("pointerup", (event) => {
|
||||
const dismiss = drawerBackdropPressed && outsideDrawer(event);
|
||||
drawerBackdropPressed = false;
|
||||
if (dismiss) close("am-detail");
|
||||
});
|
||||
$("am-detail").addEventListener("pointercancel", () => {
|
||||
drawerBackdropPressed = false;
|
||||
});
|
||||
$("am-filters").addEventListener("submit", (event) => {
|
||||
event.preventDefault();
|
||||
state.page = 1;
|
||||
|
||||
Reference in New Issue
Block a user