generated from jric11/baseProject
This commit is contained in:
@@ -5,7 +5,8 @@ final class ClubFormModals {
|
||||
public static function render(string $html): string {
|
||||
$titles=['club'=>'Edit or archive club','member'=>'Add member','invite'=>'Invite members',
|
||||
'season'=>'Add season','charge'=>'Record season dues','payment'=>'Record payment',
|
||||
'adjust'=>'Correct dues','reverse'=>'Reverse incorrect payment','revokeInvitation'=>'Revoke invitation'];
|
||||
'adjust'=>'Correct dues','reverse'=>'Reverse incorrect payment','revokeInvitation'=>'Revoke invitation',
|
||||
'note_add'=>'Add note','note_edit'=>'Edit note','note_delete'=>'Delete note'];
|
||||
$doc=new DOMDocument('1.0','UTF-8');$previous=libxml_use_internal_errors(true);
|
||||
try{$loaded=$doc->loadHTML('<?xml encoding="UTF-8">'.$html,LIBXML_NONET);}
|
||||
finally{libxml_clear_errors();libxml_use_internal_errors($previous);}
|
||||
@@ -20,7 +21,7 @@ final class ClubFormModals {
|
||||
$title=$step==='member'&&!empty($values['membership_serial'])?'Edit membership':$titles[$step];
|
||||
$id='club-action-'.(++$index);$parent=$form->parentNode;
|
||||
$trigger=$doc->createElement('button');$trigger->appendChild($doc->createTextNode($title));
|
||||
foreach(['type'=>'button','class'=>'btn btn-outline-primary me-2 mb-2','data-bs-toggle'=>'modal','data-bs-target'=>'#'.$id,'data-club-step'=>$step] as $key=>$value)$trigger->setAttribute($key,$value);
|
||||
foreach(['type'=>'button','class'=>'btn '.($step==='note_delete'?'btn-outline-danger':'btn-outline-primary').' me-2 mb-2','data-bs-toggle'=>'modal','data-bs-target'=>'#'.$id,'data-club-step'=>$step] as $key=>$value)$trigger->setAttribute($key,$value);
|
||||
$dialog=$doc->createElement('div');
|
||||
foreach(['class'=>'modal fade club-action-modal','id'=>$id,'tabindex'=>'-1','aria-labelledby'=>$id.'-title','aria-hidden'=>'true'] as $key=>$value)$dialog->setAttribute($key,$value);
|
||||
$layout=$dialog->appendChild($doc->createElement('div'));$layout->setAttribute('class','modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable');
|
||||
@@ -31,7 +32,7 @@ final class ClubFormModals {
|
||||
$body=$content->appendChild($doc->createElement('div'));$body->setAttribute('class','modal-body');
|
||||
// Keep the selected row visible in the dialog so financial/member actions are unambiguous.
|
||||
$row=$parent;while($row&&$row!==$main&&!in_array($row->nodeName,['tr','li'],true))$row=$row->parentNode;
|
||||
if($row&&$row!==$main){
|
||||
if($row&&$row!==$main&&!in_array($step,['note_edit','note_delete'],true)){
|
||||
$text=$row->textContent;
|
||||
if($row->nodeName==='tr')$text=implode(' · ',array_map(static fn($cell)=>trim($cell->textContent),array_slice(iterator_to_array($row->getElementsByTagName('td')),0,-1)));
|
||||
$context=$body->appendChild($doc->createElement('p'));$context->setAttribute('class','text-secondary');$context->appendChild($doc->createTextNode(trim(preg_replace('/\s+/u',' ',$text))));
|
||||
|
||||
Reference in New Issue
Block a user