');
- $oP->add('
2.'.Dict::S('DBTools:LostAttachments:Step:AnalyzeResults').'
');
- if(empty($aWrongRecords))
- {
- $oP->add('');
- }
- else
- {
- $oP->add('');
+ if (empty($aWrongRecords)) {
+ $oAlert = AlertUIBlockFactory::MakeForSuccess(Dict::S('DBTools:LostAttachments:Step:AnalyzeResults:None'));
+ $oForm->AddSubBlock($oAlert);
+ } else {
+ // Errors found
+ $oAlert = AlertUIBlockFactory::MakeForFailure(Dict::Format('DBTools:LostAttachments:Step:AnalyzeResults:Some', count($aWrongRecords)));
+ // TODO 3.0 Spacing ?
+ $oAlert->AddCSSClass('mb-5');
+ $oForm->AddSubBlock($oAlert);
+
+ $oPanel = PanelUIBlockFactory::MakeForWarning(Dict::S('DBTools:LostAttachments:Step:AnalyzeResults'));
+ $oPanel->AddCSSClass('ibo-datatable-panel');
+ $oForm->AddSubBlock($oPanel);
// Display errors as table
- $oP->add('
');
- $oP->add(' | '.Dict::S('DBTools:LostAttachments:Step:AnalyzeResults:Item:Filename').' | '.Dict::S('DBTools:LostAttachments:Step:AnalyzeResults:Item:CurrentLocation').' | '.Dict::S('DBTools:LostAttachments:Step:AnalyzeResults:Item:TargetLocation').' |
');
-
- foreach($aWrongRecords as $iIndex => $aWrongRecord)
- {
+ $aColumns = [
+ 'select' => ['label' => ''],
+ 'filename' => ['label' => Dict::S('DBTools:LostAttachments:Step:AnalyzeResults:Item:Filename')],
+ 'location' => ['label' => Dict::S('DBTools:LostAttachments:Step:AnalyzeResults:Item:CurrentLocation')],
+ 'target' => ['label' => Dict::S('DBTools:LostAttachments:Step:AnalyzeResults:Item:TargetLocation')],
+ ];
+ $aRows = [];
+ foreach ($aWrongRecords as $iIndex => $aWrongRecord) {
$sCurrentClass = $aWrongRecord['current_class'];
$sCurrentId = $aWrongRecord['current_id'];
@@ -349,76 +407,79 @@ function DisplayLostAttachments(iTopWebPage &$oP, ApplicationContext &$oAppConte
$sFilename = ''.$aWrongRecord['filename'].'';
- $sRowClass = ($iIndex % 2 === 0) ? 'odd' : 'even'; // (Starts at 0, not 1)
- $oP->add(' | '.$sFilename.' | '.$sRecordToClean.' | '.$sTargetLocation.' |
');
+ $aRows[] = [
+ 'select' => '',
+ 'filename' => $sFilename,
+ 'location' => $sRecordToClean,
+ 'target' => $sTargetLocation,
+ ];
+ // $oP->add(' | '.$sFilename.' | '.$sRecordToClean.' | '.$sTargetLocation.' |
');
}
- $oP->add('
');
- $oP->add('
');
+ $oTable = DataTableUIBlockFactory::MakeForForm('results', $aColumns, $aRows);
+ $oPanel->AddSubBlock($oTable);
+ /** @var \Combodo\iTop\Application\UI\Base\Component\Button\ButtonJS $oButton */
+ $oButton = ButtonUIBlockFactory::MakeForPrimaryAction(Dict::S('DBTools:LostAttachments:Button:Restore'), 'step_name', 'restore', true);
+ // TODO 3.0 Spacing ?
+ $oButton->AddCSSClasses(['mt-5', 'ml-5']);
+ $oButton->SetIsDisabled(true);
+ $oPanel->AddSubBlock($oButton);
+
// JS to handle checkboxes and button
$oP->add_ready_script(
-<<
0 )
+ if( $('.ibo-dbt-lostattachments .dbt-cbx:not(:checked)').length > 0 )
{
- $('.dbt-lostattachments .dbt-toggler-cbx').prop('checked', false);
+ $('.ibo-dbt-lostattachments .dbt-toggler-cbx').prop('checked', false);
}
});
EOF
);
}
- $oP->add(' ');
}
// Step 3: Restore results
- if($bDoRestore)
- {
- $oP->add('');
- $oP->add('
3.'.Dict::S('DBTools:LostAttachments:Step:RestoreResults').'
');
+ if ($bDoRestore) {
+ $oPanel = FieldSetUIBlockFactory::MakeStandard(Dict::S('DBTools:LostAttachments:Step:RestoreResults'));
+ $oForm->AddSubBlock($oPanel);
- $oP->add('');
+ $oAlert = AlertUIBlockFactory::MakeForSuccess(Dict::Format('DBTools:LostAttachments:Step:RestoreResults:Results', $iRestoredItemsCount, $iRecordsToCleanCount));
+ $oPanel->AddSubBlock($oAlert);
- if(!empty($aErrorsReport))
- {
- foreach($aErrorsReport as $sErrorReport)
- {
- $oP->add('');
+ if (!empty($aErrorsReport)) {
+ foreach ($aErrorsReport as $sErrorReport) {
+
+ $oAlert = AlertUIBlockFactory::MakeForFailure($sErrorReport);
+ $oPanel->AddSubBlock($oAlert);
}
}
-
- $oP->add('
');
}
-
- $oP->add($oAppContext->GetForForm());
- $oP->add('