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 : "";
|
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 getModelSettingsSrc = (entry) => {
|
||||||
const meta = entry?.meta || {};
|
const meta = entry?.meta || {};
|
||||||
const candidates = [
|
const candidates = [
|
||||||
|
|
@ -557,9 +574,10 @@ const getCommentSourceForEntry = (entry = getPrimaryModelEntry()) => {
|
||||||
if (!entry) return null;
|
if (!entry) return null;
|
||||||
const meta = entry.meta || {};
|
const meta = entry.meta || {};
|
||||||
const src = getModelSettingsSrc(entry) ||
|
const src = getModelSettingsSrc(entry) ||
|
||||||
normalizeModelSettingsSrc(meta.sourceSrc) ||
|
normalizeCommentSourceSrc(meta.sourceSrc) ||
|
||||||
normalizeModelSettingsSrc(meta.artifactSrc) ||
|
normalizeCommentSourceSrc(meta.artifactSrc) ||
|
||||||
normalizeModelSettingsSrc(entry.src) ||
|
normalizeCommentSourceSrc(meta.settingsSrc) ||
|
||||||
|
normalizeCommentSourceSrc(entry.src) ||
|
||||||
"";
|
"";
|
||||||
const uploadIdentity = extractUploadIdentityFromSrc(src);
|
const uploadIdentity = extractUploadIdentityFromSrc(src);
|
||||||
return {
|
return {
|
||||||
|
|
@ -1296,8 +1314,9 @@ const applyCommentModal = async ({ closeOnSave = false } = {}) => {
|
||||||
const title = commentTitleInput?.value?.trim() || "";
|
const title = commentTitleInput?.value?.trim() || "";
|
||||||
const body = commentBodyInput?.value?.trim() || "";
|
const body = commentBodyInput?.value?.trim() || "";
|
||||||
const replyBody = commentReplyInput?.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;
|
return;
|
||||||
}
|
}
|
||||||
if (commentApplyButton) {
|
if (commentApplyButton) {
|
||||||
|
|
|
||||||
|
|
@ -573,6 +573,6 @@
|
||||||
<input id="fileInput" class="hidden" type="file"
|
<input id="fileInput" class="hidden" type="file"
|
||||||
accept=".xkt,.glb,.gltf,.bim,.las,.laz,.obj,.stl">
|
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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue