Last modified by Super Admin on 2026/04/05 18:59

From version Icon 83.1 Icon
edited by Super Admin
on 2026/03/19 23:49
Change comment: There is no comment for this version
To version Icon 93.1 Icon
edited by Super Admin
on 2026/03/20 10:33
Change comment: There is no comment for this version

Summary

Details

Icon Page properties
Content
... ... @@ -57,7 +57,7 @@
57 57  #set($budgetAllocation = $doc.getValue('budgetAllocation'))
58 58  #set($budgetNote = $doc.getValue('budgetNote'))
59 59  
60 -## --- 校則の見直し ---
60 +## --- 校則・生徒会会則の見直し ---
61 61  #set($ruleReviewStatus = $doc.getValue('ruleReviewStatus'))
62 62  #set($ruleReviewContent = $doc.getValue('ruleReviewContent'))
63 63  #set($ruleReviewProposer = $doc.getValue('ruleReviewProposer'))
... ... @@ -304,7 +304,7 @@
304 304  
305 305  ## --- 編集ボタン(権限があるユーザーのみ表示) ---
306 306  #set($canEditSchool = false)
307 -#if(!$isGuest && ($isViewerAdmin || $isSchoolMember))
307 +#if(!$isGuest && ($isViewerAdmin || $isSchoolMember || $isAlumniOfSchool))
308 308   #set($canEditSchool = true)
309 309  #end
310 310  #if($canEditSchool)
... ... @@ -357,16 +357,12 @@
357 357   #if($schoolDescription && $schoolDescription.trim() != '')
358 358   <div class="free-note" style="margin-top:var(--sp-4);">$!escapetool.xml($schoolDescription)</div>
359 359   #end
360 - #set($infoEditDate = $!doc.getValue('lastInfoEditedDate'))
361 - #set($infoEditBy = $!doc.getValue('lastInfoEditedBy'))
362 - #if($infoEditDate && $infoEditDate != '')
363 - <div class="info-last-updated"><svg class="ico" viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"/></svg> 基本情報の最終更新: $!escapetool.xml($infoEditBy) — $!escapetool.xml($infoEditDate)</div>
364 - #end
360 +
365 365  </div>
366 366  
367 -## --- ② 生徒会基本情報(折りたたみカード) ---
363 +## --- ② 生徒会情報(折りたたみカード) ---
368 368  <div class="school-info-card" id="card-seitokai-info">
369 - <h2 role="button" tabindex="0" aria-expanded="true" onclick="toggleInfoCard('card-seitokai-info')" onkeydown="if(event.key==='Enter'||event.key===' '){event.preventDefault();toggleInfoCard('card-seitokai-info')}"><span><svg class="ico ico-md" viewBox="0 0 24 24"><path d="M3 21h18"/><path d="M5 21V7l7-4 7 4v14"/><path d="M9 21v-4h6v4"/></svg> 生徒会基本情報</span><span class="collapse-toggle"><span class="collapse-label-open">たたむ</span><span class="collapse-label-closed">開く</span> <span class="collapse-arrow">▼</span></span></h2>
365 + <h2 role="button" tabindex="0" aria-expanded="true" onclick="toggleInfoCard('card-seitokai-info')" onkeydown="if(event.key==='Enter'||event.key===' '){event.preventDefault();toggleInfoCard('card-seitokai-info')}"><span><svg class="ico ico-md" viewBox="0 0 24 24"><path d="M3 21h18"/><path d="M5 21V7l7-4 7 4v14"/><path d="M9 21v-4h6v4"/></svg> 生徒会情報</span><span class="collapse-toggle"><span class="collapse-label-open">たたむ</span><span class="collapse-label-closed">開く</span> <span class="collapse-arrow">▼</span></span></h2>
370 370   <div class="seitokai-info-body">
371 371  
372 372   ## --- 生徒会組織 ---
... ... @@ -378,7 +378,7 @@
378 378   #end
379 379   #if($canViewOrgChart)
380 380   <div class="seitokai-subsection">
381 - <h3 class="seitokai-subsection-title"><svg class="ico" viewBox="0 0 24 24"><path d="M3 21h18"/><path d="M5 21V7l7-4 7 4v14"/><path d="M9 21v-4h6v4"/><line x1="9" y1="10" x2="9" y2="10.01"/><line x1="15" y1="10" x2="15" y2="10.01"/><line x1="9" y1="14" x2="9" y2="14.01"/><line x1="15" y1="14" x2="15" y2="14.01"/></svg> 生徒会組織 #if($visibilityOrgChart != 'public')<span class="visibility-badge visibility-${visibilityOrgChart}">#if($visibilityOrgChart == 'school_trusted')<svg class="ico" viewBox="0 0 24 24"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg> 校内承認限定#else<svg class="ico" viewBox="0 0 24 24"><path d="M2 20h20"/><path d="M5 20V10l7-5 7 5v10"/><path d="M9 20v-5h6v5"/></svg> 校内限定#end</span>#end</h3>
377 + <h3 class="seitokai-subsection-title"><svg class="ico" viewBox="0 0 24 24"><path d="M3 21h18"/><path d="M5 21V7l7-4 7 4v14"/><path d="M9 21v-4h6v4"/><line x1="9" y1="10" x2="9" y2="10.01"/><line x1="15" y1="10" x2="15" y2="10.01"/><line x1="9" y1="14" x2="9" y2="14.01"/><line x1="15" y1="14" x2="15" y2="14.01"/></svg> 生徒会組織 #if($visibilityOrgChart != 'public')<span class="visibility-badge visibility-${visibilityOrgChart}">#if($visibilityOrgChart == 'school_trusted')<svg class="ico" viewBox="0 0 24 24"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg> 校内承認・紹介限定#else<svg class="ico" viewBox="0 0 24 24"><path d="M2 20h20"/><path d="M5 20V10l7-5 7 5v10"/><path d="M9 20v-5h6v5"/></svg> 校内限定#end</span>#end</h3>
382 382   <div class="seitokai-subsection-content">
383 383   #if($orgChartImage && $orgChartImage != '')
384 384   <div class="school-org-img-wrap"><img src="$doc.getAttachmentURL($orgChartImage)" alt="組織図" class="org-chart-img" /></div>
... ... @@ -396,12 +396,10 @@
396 396   <div class="seitokai-subsection">
397 397   <h3 class="seitokai-subsection-title"><svg class="ico" viewBox="0 0 24 24"><path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/></svg> 日常の活動</h3>
398 398   <div class="seitokai-subsection-content">
399 - <p class="activity-hint">活動時間多い順に上位3つ</p>
395 + <p class="activity-hint">活動時間多い3つ</p>
400 400   <div class="tag-container">
401 - #set($daIdx = 1)
402 402   #foreach($da in $dailyActivities)
403 - <span class="tag tag-accent">${daIdx}. $!escapetool.xml($da.trim())</span>
404 - #set($daIdx = $daIdx + 1)
398 + <span class="tag tag-accent">$!escapetool.xml($da.trim())</span>
405 405   #end
406 406   </div>
407 407   #if($dailyActivitiesNote && $dailyActivitiesNote.trim() != '')
... ... @@ -458,7 +458,7 @@
458 458   #end
459 459   #if($canViewBudget)
460 460   <div class="seitokai-subsection">
461 - <h3 class="seitokai-subsection-title"><svg class="ico" viewBox="0 0 24 24"><line x1="12" y1="1" x2="12" y2="23"/><path d="M17 5H9.5a3.5 3.5 0 000 7h5a3.5 3.5 0 010 7H6"/></svg> 予算 #if($visibilityBudget != 'public')<span class="visibility-badge visibility-${visibilityBudget}">#if($visibilityBudget == 'school_trusted')<svg class="ico" viewBox="0 0 24 24"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg> 校内承認限定#else<svg class="ico" viewBox="0 0 24 24"><path d="M2 20h20"/><path d="M5 20V10l7-5 7 5v10"/><path d="M9 20v-5h6v5"/></svg> 校内限定#end</span>#end</h3>
455 + <h3 class="seitokai-subsection-title"><svg class="ico" viewBox="0 0 24 24"><line x1="12" y1="1" x2="12" y2="23"/><path d="M17 5H9.5a3.5 3.5 0 000 7h5a3.5 3.5 0 010 7H6"/></svg> 予算 #if($visibilityBudget != 'public')<span class="visibility-badge visibility-${visibilityBudget}">#if($visibilityBudget == 'school_trusted')<svg class="ico" viewBox="0 0 24 24"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg> 校内承認・紹介限定#else<svg class="ico" viewBox="0 0 24 24"><path d="M2 20h20"/><path d="M5 20V10l7-5 7 5v10"/><path d="M9 20v-5h6v5"/></svg> 校内限定#end</span>#end</h3>
462 462   <div class="seitokai-subsection-content">
463 463   #if($budgetProcess && !$budgetProcess.isEmpty())
464 464   <div class="info-row">
... ... @@ -465,8 +465,13 @@
465 465   <span class="info-label">作成過程の生徒関与</span>
466 466   <span class="info-value">
467 467   <div class="selection-display">
468 - #foreach($bp in $budgetProcess)
469 - <span class="selection-item">$!escapetool.xml($bp.trim())</span>
462 + #set($allBpOpts = ["各部・委員会等への予算希望額調査","予算額調整(折衝等)","生徒会予算案の作成","生徒総会での議決","生徒関与なし","その他"])
463 + #foreach($bpOpt in $allBpOpts)
464 + #if($budgetProcess.contains($bpOpt))
465 + <span class="selection-item">$!escapetool.xml($bpOpt)</span>
466 + #else
467 + <span class="selection-item selection-item-off">$!escapetool.xml($bpOpt)</span>
468 + #end
470 470   #end
471 471   </div>
472 472   </span>
... ... @@ -506,7 +506,7 @@
506 506   #end
507 507   #end
508 508  
509 - ## --- 校則の見直し ---
508 + ## --- 校則・生徒会会則の見直し ---
510 510   #if($ruleReviewStatus && $ruleReviewStatus != '')
511 511   #set($canViewRuleReview = true)
512 512   #if($visibilityRuleReview == 'school' && ($isGuest || (!$isViewerAdmin && !$isSchoolMember))) #set($canViewRuleReview = false)
... ... @@ -514,12 +514,13 @@
514 514   #end
515 515   #if($canViewRuleReview)
516 516   <div class="seitokai-subsection">
517 - <h3 class="seitokai-subsection-title"><svg class="ico" viewBox="0 0 24 24"><path d="M16 4h2a2 2 0 012 2v12a2 2 0 01-2 2h-2"/><path d="M8 4H6a2 2 0 00-2 2v12a2 2 0 002 2h2"/><line x1="12" y1="4" x2="12" y2="8"/><line x1="12" y1="16" x2="12" y2="20"/><line x1="8" y1="8" x2="16" y2="8"/><line x1="8" y1="16" x2="16" y2="16"/></svg> 校則の見直し #if($visibilityRuleReview != 'public')<span class="visibility-badge visibility-${visibilityRuleReview}">#if($visibilityRuleReview == 'school_trusted')<svg class="ico" viewBox="0 0 24 24"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg> 校内承認限定#else<svg class="ico" viewBox="0 0 24 24"><path d="M2 20h20"/><path d="M5 20V10l7-5 7 5v10"/><path d="M9 20v-5h6v5"/></svg> 校内限定#end</span>#end</h3>
516 + <h3 class="seitokai-subsection-title"><svg class="ico" viewBox="0 0 24 24"><path d="M16 4h2a2 2 0 012 2v12a2 2 0 01-2 2h-2"/><path d="M8 4H6a2 2 0 00-2 2v12a2 2 0 002 2h2"/><line x1="12" y1="4" x2="12" y2="8"/><line x1="12" y1="16" x2="12" y2="20"/><line x1="8" y1="8" x2="16" y2="8"/><line x1="8" y1="16" x2="16" y2="16"/></svg> 校則・生徒会会則の見直し #if($visibilityRuleReview != 'public')<span class="visibility-badge visibility-${visibilityRuleReview}">#if($visibilityRuleReview == 'school_trusted')<svg class="ico" viewBox="0 0 24 24"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg> 校内承認・紹介限定#else<svg class="ico" viewBox="0 0 24 24"><path d="M2 20h20"/><path d="M5 20V10l7-5 7 5v10"/><path d="M9 20v-5h6v5"/></svg> 校内限定#end</span>#end</h3>
518 518   <div class="seitokai-subsection-content">
519 519   <div class="info-row">
520 520   <span class="info-label">見直しの有無(3年以内)</span>
521 521   <span class="info-value"><span class="tag tag-primary tag-sm">$!escapetool.xml($!ruleReviewStatus)</span></span>
522 522   </div>
522 + #if($ruleReviewStatus != '実施なし')
523 523   #if($ruleReviewContent && !$ruleReviewContent.isEmpty())
524 524   <div class="info-row">
525 525   <span class="info-label">見直しの内容</span>
... ... @@ -556,6 +556,7 @@
556 556   </span>
557 557   </div>
558 558   #end
559 + #end
559 559   #if($ruleReviewSystem && $ruleReviewSystem != '')
560 560   <div class="info-row">
561 561   <span class="info-label">見直しの仕組み</span>
... ... @@ -565,7 +565,7 @@
565 565   </div>
566 566   </div>
567 567   #else
568 - <div class="visibility-restricted-notice"><svg class="ico" viewBox="0 0 24 24"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0110 0v4"/></svg> 校則の見直し情報は #if($visibilityRuleReview == 'school_trusted')校内の承認済み・紹介メンバー#else校内メンバー#end のみ閲覧可能です</div>
569 + <div class="visibility-restricted-notice"><svg class="ico" viewBox="0 0 24 24"><rect x="3" y="11" width="18" height="11" rx="2"/><path d="M7 11V7a5 5 0 0110 0v4"/></svg> 校則・生徒会会則の見直し情報は #if($visibilityRuleReview == 'school_trusted')校内の承認済み・紹介メンバー#else校内メンバー#end のみ閲覧可能です</div>
569 569   #end
570 570   #end
571 571  
... ... @@ -577,7 +577,7 @@
577 577   #end
578 578   #if($canViewChallenges)
579 579   <div class="seitokai-subsection">
580 - <h3 class="seitokai-subsection-title"><svg class="ico" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg> 生徒会の課題意識 #if($visibilityChallenges != 'public')<span class="visibility-badge visibility-${visibilityChallenges}">#if($visibilityChallenges == 'school_trusted')<svg class="ico" viewBox="0 0 24 24"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg> 校内承認限定#else<svg class="ico" viewBox="0 0 24 24"><path d="M2 20h20"/><path d="M5 20V10l7-5 7 5v10"/><path d="M9 20v-5h6v5"/></svg> 校内限定#end</span>#end</h3>
581 + <h3 class="seitokai-subsection-title"><svg class="ico" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg> 生徒会の課題意識 #if($visibilityChallenges != 'public')<span class="visibility-badge visibility-${visibilityChallenges}">#if($visibilityChallenges == 'school_trusted')<svg class="ico" viewBox="0 0 24 24"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg> 校内承認・紹介限定#else<svg class="ico" viewBox="0 0 24 24"><path d="M2 20h20"/><path d="M5 20V10l7-5 7 5v10"/><path d="M9 20v-5h6v5"/></svg> 校内限定#end</span>#end</h3>
581 581   <div class="seitokai-subsection-content">
582 582   <div class="challenge-text">$!escapetool.xml($challenges)</div>
583 583   </div>
... ... @@ -601,6 +601,11 @@
601 601   <tr><th>YouTube</th><td>#if($seitokaiYoutube && $seitokaiYoutube != '')<a href="$!escapetool.xml($seitokaiYoutube)" target="_blank" rel="noopener"><svg class="ico" viewBox="0 0 24 24"><polygon points="5 3 19 12 5 21 5 3"/></svg> YouTubeチャンネル</a>#else<span class="text-placeholder">未登録</span>#end</td></tr>
602 602   <tr><th>その他SNS</th><td>#if($seitokaiOtherSns && $seitokaiOtherSns != '')$!escapetool.xml($seitokaiOtherSns)#else<span class="text-placeholder">未登録</span>#end</td></tr>
603 603   </table>
605 + #set($infoEditDate = $!doc.getValue('lastInfoEditedDate'))
606 + #set($infoEditBy = $!doc.getValue('lastInfoEditedBy'))
607 + #if($infoEditDate && $infoEditDate != '')
608 + <div class="info-last-updated"><svg class="ico" viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"/></svg> 基本情報の最終更新: $!escapetool.xml($infoEditBy) — $!escapetool.xml($infoEditDate)</div>
609 + #end
604 604  </div>
605 605  
606 606  {{/html}}
... ... @@ -958,7 +958,7 @@
958 958   #end
959 959   </div>
960 960   #if($postVis != 'public')
961 - <div class="visibility-badge visibility-${postVis} post-action-mt">#if($postVis == 'school_trusted')<svg class="ico" viewBox="0 0 24 24"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg> 校内承認限定#else<svg class="ico" viewBox="0 0 24 24"><path d="M2 20h20"/><path d="M5 20V10l7-5 7 5v10"/><path d="M9 20v-5h6v5"/></svg> 校内限定#end</div>
967 + <div class="visibility-badge visibility-${postVis} post-action-mt">#if($postVis == 'school_trusted')<svg class="ico" viewBox="0 0 24 24"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg> 校内承認・紹介限定#else<svg class="ico" viewBox="0 0 24 24"><path d="M2 20h20"/><path d="M5 20V10l7-5 7 5v10"/><path d="M9 20v-5h6v5"/></svg> 校内限定#end</div>
962 962   #end
963 963   ## 固定/編集/削除/通報/非表示ボタン(横並び)
964 964   #set($postAuthorRef = $!post.getValue('authorRef'))
... ... @@ -982,7 +982,9 @@
982 982   #end
983 983   #if($showEditDeleteBtn)
984 984   #if($xcontext.user == $postAuthorRef)
985 - <button type="button" class="btn-post-edit" onclick="openEditPost(this, '${doc.fullName}', $postObjNumED, '$!escapetool.javascript($!postContent)')" title="この投稿を編集">
991 + #set($editImages = $!post.getValue('images'))
992 + #set($editFiles = $!post.getValue('files'))
993 + <button type="button" class="btn-post-edit" data-school="${doc.fullName}" data-obj="$postObjNumED" data-content="$!escapetool.xml($!postContent)" data-images="$!escapetool.xml($!editImages)" data-files="$!escapetool.xml($!editFiles)" data-post-type="$!post.getValue('postType')" onclick="openEditPost(this)" title="この投稿を編集">
986 986   <svg class="ico ico-fixed-14" viewBox="0 0 24 24"><path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"/></svg> 編集
987 987   </button>
988 988   #end
... ... @@ -1044,7 +1044,7 @@
1044 1044  
1045 1045   #if($xcontext.user != "XWiki.XWikiGuest")
1046 1046   <div class="thread-add-post">
1047 - #if($isSchoolMember || $isViewerAdmin)
1055 + #if($isSchoolMember || $isAlumniOfSchool || $isViewerAdmin)
1048 1048   <a href="/bin/SeitokaiCode/ActivityPostForm?schoolPage=${doc.fullName}&activityIndex=${actIdx}&schoolCode=$!escapetool.url($schoolCode)&postType=report" class="btn-thread-add">
1049 1049   + 活動報告を追加
1050 1050   </a>
... ... @@ -1215,37 +1215,130 @@
1215 1215  }
1216 1216  
1217 1217  // 投稿の編集(インライン編集フォームを開く)
1218 -function openEditPost(btn, schoolPage, postObjNum, currentContent) {
1226 +function openEditPost(btn) {
1219 1219   var postEl = btn.closest('.thread-post');
1220 1220   if (!postEl) return;
1221 - // 既存の編集フォームがあれば閉じる
1222 1222   var existing = postEl.querySelector('.post-edit-form');
1223 1223   if (existing) { existing.remove(); return; }
1224 1224   var bodyEl = postEl.querySelector('.thread-post-body');
1225 1225   if (!bodyEl) return;
1233 +
1234 + var schoolPage = btn.getAttribute('data-school');
1235 + var postObjNum = btn.getAttribute('data-obj');
1236 + var currentContent = btn.getAttribute('data-content') || '';
1237 + var currentImages = btn.getAttribute('data-images') || '';
1238 + var currentFiles = btn.getAttribute('data-files') || '';
1239 + var postType = btn.getAttribute('data-post-type') || 'report';
1240 +
1226 1226   var form = document.createElement('div');
1227 1227   form.className = 'post-edit-form';
1228 - form.innerHTML = '<textarea id="editContent_' + postObjNum + '">' + currentContent.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;') + '</textarea>' +
1229 - '<div class="post-edit-form-actions">' +
1243 + form.setAttribute('data-school', schoolPage);
1244 + form.setAttribute('data-obj', postObjNum);
1245 +
1246 + var html = '<textarea id="editContent_' + postObjNum + '">' + currentContent.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;') + '</textarea>';
1247 +
1248 + // コメント以外は添付ファイル編集を表示
1249 + if (postType !== 'comment') {
1250 + // 既存画像
1251 + html += '<div class="edit-attachments">';
1252 + if (currentImages.trim()) {
1253 + html += '<div class="edit-attach-section"><span class="edit-attach-label">画像</span>';
1254 + var imgs = currentImages.trim().split('\n');
1255 + for (var i = 0; i < imgs.length; i++) {
1256 + var img = imgs[i].trim();
1257 + if (!img) continue;
1258 + html += '<div class="edit-attach-item" data-name="' + img.replace(/"/g,'&quot;') + '">' +
1259 + '<img src="/xwiki/bin/download/' + schoolPage.replace(/\./g,'/') + '/' + encodeURIComponent(img) + '" class="edit-attach-thumb" />' +
1260 + '<button type="button" class="edit-attach-remove" onclick="removeEditAttach(this)" title="削除">✕</button>' +
1261 + '<input type="hidden" name="keepImages" value="' + img.replace(/"/g,'&quot;') + '" />' +
1262 + '</div>';
1263 + }
1264 + html += '</div>';
1265 + }
1266 + // 既存ファイル
1267 + if (currentFiles.trim()) {
1268 + html += '<div class="edit-attach-section"><span class="edit-attach-label">ファイル</span>';
1269 + var files = currentFiles.trim().split('\n');
1270 + for (var j = 0; j < files.length; j++) {
1271 + var f = files[j].trim();
1272 + if (!f) continue;
1273 + var displayName = f;
1274 + if (/^file_\d{14}_\d+_/.test(f)) displayName = f.replace(/^file_\d{14}_\d+_/, '');
1275 + html += '<div class="edit-attach-item" data-name="' + f.replace(/"/g,'&quot;') + '">' +
1276 + '<span class="edit-attach-fname">' + displayName.replace(/</g,'&lt;').replace(/>/g,'&gt;') + '</span>' +
1277 + '<button type="button" class="edit-attach-remove" onclick="removeEditAttach(this)" title="削除">✕</button>' +
1278 + '<input type="hidden" name="keepFiles" value="' + f.replace(/"/g,'&quot;') + '" />' +
1279 + '</div>';
1280 + }
1281 + html += '</div>';
1282 + }
1283 + // 新規追加
1284 + html += '<div class="edit-attach-add">' +
1285 + '<label class="form-label-sm">画像を追加(最大4枚まで)</label>' +
1286 + '<input type="file" name="editNewImages" accept="image/*" multiple class="form-file-input-sm" />' +
1287 + '<div class="form-hint">JPEG / PNG / GIF / WebP、各5MBまで</div>' +
1288 + '<label class="form-label-sm" style="margin-top:8px;">ファイルを追加(最大2つまで)</label>' +
1289 + '<input type="file" name="editNewFiles" accept=".pdf,.docx,.xlsx,.pptx" multiple class="form-file-input-sm" />' +
1290 + '<div class="form-hint">PDF / Word / Excel / PowerPoint、各10MBまで</div>' +
1291 + '</div>';
1292 + html += '</div>';
1293 + }
1294 +
1295 + html += '<div class="post-edit-form-actions">' +
1230 1230   '<button type="button" class="btn-cancel-edit" onclick="this.closest(\'.post-edit-form\').remove()">キャンセル</button>' +
1231 - '<button type="button" class="btn-save" onclick="saveEditPost(\'' + schoolPage + '\', ' + postObjNum + ')">保存</button>' +
1297 + '<button type="button" class="btn-save" onclick="saveEditPost(this)">保存</button>' +
1232 1232   '</div>';
1299 +
1300 + form.innerHTML = html;
1233 1233   bodyEl.parentNode.insertBefore(form, bodyEl.nextSibling);
1234 1234   form.querySelector('textarea').focus();
1235 1235  }
1236 1236  
1305 +function removeEditAttach(btn) {
1306 + var item = btn.closest('.edit-attach-item');
1307 + if (item) item.remove();
1308 +}
1309 +
1237 1237  // 投稿の編集を保存
1238 -function saveEditPost(schoolPage, postObjNum) {
1239 - var textarea = document.getElementById('editContent_' + postObjNum);
1311 +function saveEditPost(btn) {
1312 + var formEl = btn.closest('.post-edit-form');
1313 + if (!formEl) return;
1314 + var schoolPage = formEl.getAttribute('data-school');
1315 + var postObjNum = formEl.getAttribute('data-obj');
1316 + var textarea = formEl.querySelector('textarea');
1240 1240   if (!textarea) return;
1241 1241   var newContent = textarea.value.trim();
1242 1242   if (!newContent) { alert('投稿内容を入力してください'); return; }
1320 +
1243 1243   var csrfEl = document.querySelector('input[name="form_token"]');
1244 1244   var csrfToken = csrfEl ? csrfEl.value : '';
1323 +
1324 + var fd = new FormData();
1325 + fd.append('schoolPage', schoolPage);
1326 + fd.append('postObj', postObjNum);
1327 + fd.append('newContent', newContent);
1328 + fd.append('form_token', csrfToken);
1329 +
1330 + // 残す画像・ファイル
1331 + formEl.querySelectorAll('input[name="keepImages"]').forEach(function(el) { fd.append('keepImages', el.value); });
1332 + formEl.querySelectorAll('input[name="keepFiles"]').forEach(function(el) { fd.append('keepFiles', el.value); });
1333 +
1334 + // 新規画像
1335 + var newImgInput = formEl.querySelector('input[name="editNewImages"]');
1336 + if (newImgInput && newImgInput.files) {
1337 + for (var i = 0; i < newImgInput.files.length; i++) { fd.append('editNewImages', newImgInput.files[i]); }
1338 + }
1339 + // 新規ファイル
1340 + var newFileInput = formEl.querySelector('input[name="editNewFiles"]');
1341 + if (newFileInput && newFileInput.files) {
1342 + for (var j = 0; j < newFileInput.files.length; j++) { fd.append('editNewFiles', newFileInput.files[j]); }
1343 + }
1344 +
1345 + btn.disabled = true;
1346 + btn.textContent = '保存中...';
1347 +
1245 1245   var xhr = new XMLHttpRequest();
1246 1246   xhr.open('POST', '/bin/get/SeitokaiCode/EditPost?outputSyntax=plain', true);
1247 - xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1248 - var editPostData = 'schoolPage=' + encodeURIComponent(schoolPage) + '&postObj=' + postObjNum + '&newContent=' + encodeURIComponent(newContent) + '&form_token=' + encodeURIComponent(csrfToken);
1249 1249   xhr.onload = function() {
1250 1250   try {
1251 1251   var res = JSON.parse(xhr.responseText);
... ... @@ -1253,12 +1253,13 @@
1253 1253   showToast('投稿を更新しました', 'success');
1254 1254   setTimeout(function() { location.reload(); }, 800);
1255 1255   } else {
1357 + btn.disabled = false; btn.textContent = '保存';
1256 1256   alert('編集に失敗しました: ' + (res.error || ''));
1257 1257   }
1258 - } catch(e) { alert('編集に失敗しました'); }
1360 + } catch(e) { btn.disabled = false; btn.textContent = '保存'; alert('編集に失敗しました'); }
1259 1259   };
1260 - xhr.onerror = function() { alert('通信エラーが発生しました'); };
1261 - xhr.send(editPostData);
1362 + xhr.onerror = function() { btn.disabled = false; btn.textContent = '保存'; alert('通信エラーが発生しました'); };
1363 + xhr.send(fd);
1262 1262  }
1263 1263  
1264 1264  // 投稿の削除(確認ダイアログ付き)