Changes for page 新しい学校ページを作成
Last modified by Super Admin on 2026/03/22 00:39
From version
40.1
edited by XWikiGuest
on 2026/03/22 00:34
on 2026/03/22 00:34
Change comment:
There is no comment for this version
To version
35.1
edited by Super Admin
on 2026/03/18 20:38
on 2026/03/18 20:38
Change comment:
There is no comment for this version
Summary
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. XWikiGuest1 +XWiki.superadmin - Content
-
... ... @@ -25,7 +25,7 @@ 25 25 {{error}}この学校のページは既に存在します。[[既存のページを開く>>$targetPage]]{{/error}} 26 26 #else 27 27 ## 関連校として登録されているかチェック 28 - #set($affQuery = $services.query.hql("select doc.fullName, nameObj.value from XWikiDocument doc, BaseObject bobj, StringProperty obj,StringProperty nameObjwhere bobj.name = doc.fullName and bobj.className = 'SeitokaiCode.SchoolClass' and obj.id.id = bobj.id and obj.id.name = 'affiliatedSchoolCode' and obj.value = :codeand nameObj.id.id = bobj.id and nameObj.id.name = 'affiliatedSchoolName'").bindValue('code', $schoolCode))28 + #set($affQuery = $services.query.hql("select doc.fullName, obj.affiliatedSchoolName from XWikiDocument doc, BaseObject bobj, StringProperty obj where bobj.name = doc.fullName and bobj.className = 'SeitokaiCode.SchoolClass' and obj.id.id = bobj.id and obj.id.name = 'affiliatedSchoolCode' and obj.value = :code").bindValue('code', $schoolCode)) 29 29 #set($affResults = $affQuery.execute()) 30 30 #if($affResults && $affResults.size() > 0) 31 31 #set($affRow = $affResults.get(0)) ... ... @@ -222,20 +222,16 @@ 222 222 .catch(function() { return false; }); 223 223 224 224 // 関連校チェック(他校の関連校として登録されているか確認) 225 - var affiliatedCheck = fetch('$request.contextPath/bin/view/SeitokaiCode/CheckAffiliated?code=' + encodeURIComponent(school.code) + '&outputSyntax=plain') 226 - .then(function(r) { return r.ok ? r.text() : ''; }) 227 - .then(function(t) { 228 - try { 229 - var jsonEnd = t.indexOf('}'); 230 - if (jsonEnd >= 0) return JSON.parse(t.substring(0, jsonEnd + 1)); 231 - } catch(e) {} 232 - return { found: false }; 233 - }) 234 - .catch(function() { return { found: false }; }); 225 + var affCheckUrl = restBase + '/query?q=' + 226 + encodeURIComponent("select doc.fullName, school.affiliatedSchoolName from Document doc, doc.object(SeitokaiCode.SchoolClass) school where school.affiliatedSchoolCode = :code") + 227 + '&type=hql&queryFilters=unique¶meters=code:' + encodeURIComponent(school.code); 228 + var affiliatedCheck = fetch(affCheckUrl, { headers: { 'Accept': 'application/json' } }) 229 + .then(function(r) { return r.ok ? r.json() : []; }) 230 + .catch(function() { return []; }); 235 235 236 236 Promise.all([duplicateCheck, affiliatedCheck]).then(function(results) { 237 237 var isDuplicate = results[0]; 238 - var aff Data= results[1];234 + var affResults = results[1]; 239 239 var affNotice = document.getElementById('affiliatedNotice'); 240 240 241 241 if (isDuplicate) { ... ... @@ -249,10 +249,15 @@ 249 249 } 250 250 251 251 // 関連校として登録されている場合 252 - if (affData && affData.found) { 253 - var linkHref = '$request.contextPath/bin/Schools/' + affData.mainCode + '/'; 248 + if (affResults && affResults.length > 0) { 249 + var mainPageRef = affResults[0]; 250 + var mainCode = ''; 251 + if (typeof mainPageRef === 'string' && mainPageRef.indexOf('Schools.') === 0) { 252 + mainCode = mainPageRef.split('.')[1]; 253 + } 254 + var linkHref = mainCode ? ('$request.contextPath/bin/Schools/' + mainCode + '/') : '#'; 254 254 document.getElementById('affiliatedNoticeText').innerHTML = 255 - ' <a href="' + escapeHtml(linkHref) + '">' + escapeHtml(affData.mainName) + '</a>に中高一貫校の関連校として統合されています。' +256 + '別の学校ページに中高一貫校の関連校として統合されています。' + 256 256 '<a href="' + escapeHtml(linkHref) + '">統合先のページへ移動する →</a>'; 257 257 affNotice.style.display = 'flex'; 258 258 } else {