Skip to content

Commit

Permalink
Import class in view base, adapt behat tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dasistwas committed Sep 5, 2024
1 parent 6045d1b commit c00efe0
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
10 changes: 7 additions & 3 deletions classes/datalynx.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,11 @@ public function set_page($page = 'view', $params = null, $skiplogincheck = false
// Set css body class to add top level category of the dl instance.
$category = core_course_category::get($PAGE->course->category, MUST_EXIST, true);
$categories = explode("/", $category->path);
$bodyclass = "top-cat-{$categories[1]}";
if (isset($categories[1])) {
$bodyclass = "top-cat-{$categories[1]}";
} else {
$bodyclass = "top-cat";
}
$PAGE->add_body_class($bodyclass);

$PAGE->requires->css(
Expand Down Expand Up @@ -788,7 +792,7 @@ public function display() {
*/
public static function get_content_inline(int $datalynxid, int $viewid = 0, ?int $eids = null, array $options = array('tohtml' => true)) {
global $CFG;
require_once($CFG->dirroot . '/mod/datalynx/view/base.php');
require_once($CFG->dirroot . '/mod/datalynx/classes/view/base.php');
$urlparams = new stdClass();
$datalynx = new datalynx($datalynxid);
$urlparams->d = $datalynxid;
Expand All @@ -814,7 +818,7 @@ public static function get_content_inline(int $datalynxid, int $viewid = 0, ?int
'completion' => true, 'comments' => true, 'urlparams' => $urlparams);
$datalynx->set_page('external', $pageparams, $skiplogincheck);
$type = $datalynx->views[$viewid]->type;
require_once($CFG->dirroot . "/mod/datalynx/view/$type/base.php");
require_once($CFG->dirroot . "/mod/datalynx/view/$type/view_class.php");
$viewclass = "datalynxview_$type";
$datalynx->_currentview = $datalynx->get_current_view_from_id($viewid);

Expand Down
3 changes: 2 additions & 1 deletion classes/view/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use datalynx_entries;
use datalynx_filter;
use datalynxfield__rating;
use datalynxfield__status;
use datalynxview_entries_form;
use datalynxview_patterns;
use HTML_QuickForm;
Expand Down Expand Up @@ -1576,7 +1577,7 @@ public function process_entries_data() {
} else {
$this->_editentries = 0;
}
$this->_returntoentriesform = false;
$this->_returntoentriesform = true;
return $processed;
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion rule/ftpsyncfiles/rule_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function trigger(base $event) {
require_once("$CFG->dirroot/mod/datalynx/classes/datalynx.php");
require_once("$CFG->dirroot/mod/datalynx/field/entryauthor/field_class.php");
require_once("$CFG->dirroot/mod/datalynx/entries_class.php");
require_once("$CFG->dirroot/mod/datalynx/view/csv/base.php");
require_once("$CFG->dirroot/mod/datalynx/view/csv/view_class.php");
require_once($CFG->libdir . '/filelib.php');
require_once($CFG->libdir . '/completionlib.php');

Expand Down
4 changes: 2 additions & 2 deletions tests/behat/customfilter_multiselect.feature
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ Feature: Create entry, add multiselect and use customfilter
| multiselect | Select (multiple) | | Opt1,Opt2,Opt3,Opt4,Opt5 | | |

And I add to "Datalynx Test Instance" datalynx the view of "Grid" type with:
| name | Gridview |
| description | Testgrid |
| name | description |
| Gridview | Testgrid |
And I follow "Set as default view"
And I follow "Set as edit view"

Expand Down
3 changes: 2 additions & 1 deletion tests/behat/update_entrieswithfiles.feature
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ Feature: In a datalynx instance create, update, and delete entries
| number | Number | 3 | 2 | | |
| file | File | My file | | 2 | |
And I add to "Datalynx Test Instance" datalynx the view of "Tabular" type with:
| name | Tabular |
| name | description |
| Tabular | Tabular view |
And I follow "Set as default view"
And I follow "Set as edit view"
And I am on "Course 1" course homepage
Expand Down
1 change: 1 addition & 0 deletions view/tabular/view_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public function display(array $options = []): string {
global $PAGE;
$PAGE->requires->js_init_call('M.datalynxview_tabular.init', array(), false,
$this->get_js_module());
return '';
}

private function get_js_module() {
Expand Down

0 comments on commit c00efe0

Please sign in to comment.