Skip to content

Commit

Permalink
[dashboard/statistics] Reactification
Browse files Browse the repository at this point in the history
Co-authored-by: laemtl <laetitia.fesselier@mail.mcgill.ca>
  • Loading branch information
maltheism and laemtl committed Mar 23, 2023
1 parent 73c9c67 commit b1d1a03
Show file tree
Hide file tree
Showing 20 changed files with 2,152 additions and 671 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
"tabWidth": 2,
"ignoreComments": true
}],
"no-unexpected-multiline": "off",
"no-unused-vars": "warn",
"no-useless-escape": "off",
"no-dupe-keys": "off",
"react/no-direct-mutation-state": "off",
Expand Down
29 changes: 28 additions & 1 deletion modules/dashboard/php/widget.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class Widget implements \LORIS\GUI\Widget
private WidgetContent $_content;
private WidgetDisplayProps $_displayprops;
private ?WidgetDependencies $_dependencies;
private $_template = 'panel.tpl';
private $_template_variables = [];

/**
* Construct a dashboard widget with the specified properties.
Expand All @@ -54,6 +56,30 @@ class Widget implements \LORIS\GUI\Widget
$this->_dependencies = $deps;
}

/**
* The setTemplate - change default smarty template
*
* @param string $template_file The template file to use.
*
* @return void
*/
public function setTemplate(string $template_file)
{
$this->_template = $template_file;
}

/**
* The setTemplateVariables - set additional smarty template variables
*
* @param array $template_variables The template variables to use.
*
* @return void
*/
public function setTemplateVariables(array $template_variables)
{
$this->_template_variables = $template_variables;
}

/**
* Return the size of this widget.
*
Expand Down Expand Up @@ -119,8 +145,9 @@ class Widget implements \LORIS\GUI\Widget
'body' => $this->_content->getBody(),
'footer' => $this->_content->getFooter(),
'menus' => $this->_displayprops->getMenus(),
...$this->_template_variables,
]
);
return $renderer->fetch("panel.tpl");
return $renderer->fetch($this->_template);
}
}
1 change: 1 addition & 0 deletions modules/dashboard/templates/div.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div id='{$id}'>{$body}</div>
9 changes: 6 additions & 3 deletions modules/dashboard/test/DashboardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,14 @@ public function testDashboardRecruitmentView()
$assertText2 = $this->safeFindElement(
WebDriverBy::XPath(
"//*[@id='lorisworkspace']/div[1]".
"/div[2]/div[1]/div/ul/li[2]/a"
"/div[2]/div[1]/div/ul/li[2]/a"
)
)->getText();
$this->assertStringContainsString("View overall recruitment", $assertText1);
$this->assertStringContainsString("View site breakdown", $assertText2);
$this->assertStringContainsString("Recruitment - overall", $assertText1);
$this->assertStringContainsString(
"Recruitment - site breakdown",
$assertText2
);
}

/**
Expand Down
1 change: 1 addition & 0 deletions modules/statistics/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
js/WidgetIndex.js
110 changes: 0 additions & 110 deletions modules/statistics/js/recruitment.js

This file was deleted.

Loading

0 comments on commit b1d1a03

Please # to comment.