Fix BIM comment save flow
This commit is contained in:
parent
405113fa4f
commit
b4d66a92c5
|
|
@ -474,6 +474,23 @@ const normalizeModelSettingsSrc = (src) => {
|
|||
return value.startsWith("uploads/") ? value : "";
|
||||
};
|
||||
|
||||
const normalizeCommentSourceSrc = (src) => {
|
||||
if (!src || typeof src !== "string") return "";
|
||||
let value = src.trim();
|
||||
if (!value) return "";
|
||||
try {
|
||||
const parsed = new URL(value, window.location.href);
|
||||
if (parsed.origin === window.location.origin) {
|
||||
value = `${parsed.pathname}${parsed.search || ""}`;
|
||||
} else if (/^https?:/i.test(value)) {
|
||||
value = parsed.href;
|
||||
}
|
||||
} catch (_) {
|
||||
// keep raw value
|
||||
}
|
||||
return value.replace(/^\/+/, "");
|
||||
};
|
||||
|
||||
const getModelSettingsSrc = (entry) => {
|
||||
const meta = entry?.meta || {};
|
||||
const candidates = [
|
||||
|
|
@ -557,9 +574,10 @@ const getCommentSourceForEntry = (entry = getPrimaryModelEntry()) => {
|
|||
if (!entry) return null;
|
||||
const meta = entry.meta || {};
|
||||
const src = getModelSettingsSrc(entry) ||
|
||||
normalizeModelSettingsSrc(meta.sourceSrc) ||
|
||||
normalizeModelSettingsSrc(meta.artifactSrc) ||
|
||||
normalizeModelSettingsSrc(entry.src) ||
|
||||
normalizeCommentSourceSrc(meta.sourceSrc) ||
|
||||
normalizeCommentSourceSrc(meta.artifactSrc) ||
|
||||
normalizeCommentSourceSrc(meta.settingsSrc) ||
|
||||
normalizeCommentSourceSrc(entry.src) ||
|
||||
"";
|
||||
const uploadIdentity = extractUploadIdentityFromSrc(src);
|
||||
return {
|
||||
|
|
@ -1296,8 +1314,9 @@ const applyCommentModal = async ({ closeOnSave = false } = {}) => {
|
|||
const title = commentTitleInput?.value?.trim() || "";
|
||||
const body = commentBodyInput?.value?.trim() || "";
|
||||
const replyBody = commentReplyInput?.value?.trim() || "";
|
||||
if (!title && !body && !replyBody && !commentDraftAttachments.length && !commentReplyAttachments.length && !commentDraftSubitems.length && commentModalMode === "create") {
|
||||
if (commentModalError) commentModalError.textContent = "Добавьте заголовок, описание, комментарий или файл";
|
||||
if (commentModalError) commentModalError.textContent = "";
|
||||
if (commentModalMode === "create" && !commentContextTarget?.worldPos) {
|
||||
if (commentModalError) commentModalError.textContent = "Не выбрана точка комментария";
|
||||
return;
|
||||
}
|
||||
if (commentApplyButton) {
|
||||
|
|
|
|||
|
|
@ -573,6 +573,6 @@
|
|||
<input id="fileInput" class="hidden" type="file"
|
||||
accept=".xkt,.glb,.gltf,.bim,.las,.laz,.obj,.stl">
|
||||
|
||||
<script type="module" src="./dcViewer.js?v=30"></script>
|
||||
<script type="module" src="./dcViewer.js?v=32"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Reference in New Issue