MINOR Changed ReportAdmin to new ReportAdmin_Content template, viewing available reports as unordered list instead of a tree (they can't be nested anyway)

This commit is contained in:
Ingo Schommer 2011-04-19 18:44:23 +12:00
parent d48f21afc0
commit 1ae9a318af
4 changed files with 33 additions and 104 deletions

View File

@ -21,6 +21,8 @@ class ReportAdmin extends LeftAndMain {
static $template_path = null; // defaults to (project)/templates/email
static $tree_class = 'SS_Report';
public function init() {
parent::init();
@ -32,7 +34,6 @@ class ReportAdmin extends LeftAndMain {
// Always block the HtmlEditorField.js otherwise it will be sent with an ajax request
Requirements::block(SAPPHIRE_DIR . '/javascript/HtmlEditorField.js');
Requirements::javascript(CMS_DIR . '/javascript/ReportAdmin.Tree.js');
}
/**
@ -57,6 +58,12 @@ class ReportAdmin extends LeftAndMain {
return false;
}
function currentPageID() {
$id = parent::currentPageID();
$reports = SS_Report::get_reports('ReportAdmin');
return (isset($reports[$id])) ? $reports[$id] : null;
}
/**
* Return a DataObjectSet of SS_Report subclasses
* that are available for use.
@ -71,74 +78,6 @@ class ReportAdmin extends LeftAndMain {
return $output;
}
/**
* Get EditForm for the class specified in request or in session variable
*
* @return Form
*/
public function EditForm($request = null) {
$className = Session::get('currentPage');
$requestId = $request ? $request->requestVar('ID') : null;
if ( $requestId )
return $this->getEditForm($requestId);
// $className can be null
return $this->getEditForm($className);
}
/**
* Return a Form instance with fields for the
* particular report currently viewed.
*
* @param string $className Class of the report to fetch
* @return Form
*/
public function getEditForm($className = null) {
if (!$className) {
return $form = $this->EmptyForm();
}
if (!class_exists($className)) {
die("$className does not exist");
}
Session::set('currentPage', $className);
$obj = new $className();
if(!$obj->canView()) return Security::permissionFailure($this);
$fields = $obj->getCMSFields();
$idField = new HiddenField('ID');
$idField->setValue($className);
$fields->push($idField);
$actions = new FieldSet();
$form = new Form($this, 'EditForm', $fields, $actions);
return $form;
}
/**
* Get the current report
*
* @return SS_Report
*/
public function CurrentReport() {
$id = isset($_REQUEST['ID']) ? $_REQUEST['ID'] : ($this->getRequest()->latestParam('Action') == 'EditForm') ? Session::get('currentReport') : null;
if($id) {
foreach($this->Reports() as $report) {
if($id == $report->ID()) return $report;
}
}
return false;
}
/**
* Determine if we have reports and need
* to display the "Reports" main menu item
@ -160,8 +99,4 @@ class ReportAdmin extends LeftAndMain {
}
}
?>
?>

View File

@ -0,0 +1,24 @@
<div class="cms-content center" data-layout="{type: 'border'}">
<div class="cms-content-header north">
<h2><% _t('REPORTS','Reports') %></h2>
</div>
<div class="cms-content-tools west">
<ul class="ui-widget-content">
<% control Reports %>
<li id="record-$ID">
<a href="admin/reports/show/$ID" title="$TreeDescription">$TreeTitle</a>
</li>
<% end_control %>
</ul>
</div>
<div class="cms-content-form center ui-widget-content">
$EditForm
</div>
</div>

View File

@ -1,14 +0,0 @@
<% if Reports %>
<ul id="sitetree" class="tree unformatted">
<li id="record-$ID" class="Root">
<a><% _t('REPORTS','Reports') %></a>
<ul>
<% control Reports %>
<li id="record-$ID">
<a href="admin/reports/show/$ID" title="$TreeDescription">$TreeTitle</a>
</li>
<% end_control %>
</ul>
</li>
</ul>
<% end_if %>

View File

@ -1,16 +0,0 @@
<style>
ul.tree a{
background-image: url(cms/images/treeicons/reports-file.png);
}
</style>
<div id="treepanes">
<h3>
<a href="#"><% _t('REPORTS','Reports') %></a>
</h3>
<div id="sitetree" data-url-tree="$Link(getsubtree)" data-url-savetreenode="$Link(savetreenode)" class="jstree jstree-apple">
<% include ReportAdmin_SiteTree %>
</div>
</div>