mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
MDL-75137 mod_data: Redesign zero state page
Co-authored-by: Ferran Recio <ferran@moodle.com>
This commit is contained in:
parent
cb01747608
commit
8768a7adb9
14 changed files with 527 additions and 20 deletions
|
@ -72,14 +72,6 @@ comment::init();
|
|||
|
||||
require_capability('mod/data:viewentry', $context);
|
||||
|
||||
/// If we have an empty Database then redirect because this page is useless without data
|
||||
if (has_capability('mod/data:managetemplates', $context)) {
|
||||
if (!$DB->record_exists('data_fields', array('dataid'=>$data->id))) { // Brand new database!
|
||||
redirect($CFG->wwwroot.'/mod/data/field.php?d='.$data->id); // Redirect to field entry
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Check further parameters that set browsing preferences
|
||||
if (!isset($SESSION->dataprefs)) {
|
||||
$SESSION->dataprefs = array();
|
||||
|
@ -247,6 +239,15 @@ $groupmode = groups_get_activity_groupmode($cm);
|
|||
$canmanageentries = has_capability('mod/data:manageentries', $context);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if (!$manager->has_fields()) {
|
||||
// It's a brand-new database. There are no fields.
|
||||
$renderer = $PAGE->get_renderer('mod_data');
|
||||
echo $renderer->render_zero_state($manager);
|
||||
echo $OUTPUT->footer();
|
||||
// Don't check the rest of the options. There is no field, there is nothing else to work with.
|
||||
exit;
|
||||
}
|
||||
|
||||
// Detect entries not approved yet and show hint instead of not found error.
|
||||
if ($record and !data_can_view_record($data, $record, $currentgroup, $canmanageentries)) {
|
||||
throw new \moodle_exception('notapproved', 'data');
|
||||
|
@ -385,6 +386,14 @@ if ($showactivity) {
|
|||
data_search_entries($data, $cm, $context, $mode, $currentgroup, $search, $sort, $order, $page, $perpage, $advanced, $search_array, $record);
|
||||
$hasrecords = !empty($records);
|
||||
|
||||
if ($maxcount == 0) {
|
||||
$renderer = $PAGE->get_renderer('mod_data');
|
||||
echo $renderer->render_empty_database($manager);
|
||||
echo $OUTPUT->footer();
|
||||
// There is no entry, so makes no sense to check different views, pagination, etc.
|
||||
exit;
|
||||
}
|
||||
|
||||
$actionbar = new \mod_data\output\action_bar($data->id, $pageurl);
|
||||
echo $actionbar->get_view_action_bar($hasrecords);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue