Skip to content

Commit

Permalink
Merge develop into master (#229)
Browse files Browse the repository at this point in the history
- Inslight updates
- New designs
    - Moved admin module to new designs
- Numerous fixes
  • Loading branch information
adam-buckley authored Jan 17, 2024
1 parent 0ed58ef commit 1ac1110
Show file tree
Hide file tree
Showing 146 changed files with 8,997 additions and 15,971 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- Have you made sure the following is correct? -->
## Checklist
- [ ] I'm using the correct PHP Version (7.4 for current, 7.2 for legacy).
- [ ] I'm using the correct PHP Version (8.1 for current, 7.4 for legacy).
- [ ] I've added comments to any new methods I've created or where else relevant.
- [ ] I've replaced magic method usage on DbService classes with the getInstance() static method.
- [ ] I've written any documentation for new features or where else relevant in the docs [repo](https://github.com/2pisoftware/cmfive-docs).
Expand Down
98 changes: 63 additions & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ env:
DB_USERNAME: cmfive_test
DB_PASSWORD: cmfive_test
DB_DATABASE: cmfive_test
PLAYWRIGHT_MODULES: "admin channel form tag report task timelog"

jobs:
# Lint
Expand Down Expand Up @@ -58,7 +59,7 @@ jobs:
- uses: actions/checkout@v3
with:
repository: '2pisoftware/cmfive-boilerplate'
ref: 'master'
ref: 'develop'

# Pre-requisites Prepare Cmfive Environment
- name: Setup cmfive Test Environment
Expand Down Expand Up @@ -107,7 +108,7 @@ jobs:
# Build new layout
- uses: actions/setup-node@v3
with:
node-version: 14
node-version: 18

- name: Build new designs
run: |
Expand All @@ -123,59 +124,84 @@ jobs:
if [ $? -gt 0 ]; then
echo "Admin module tests failed"
fi
# Setup playwright
- name: Setup Playwright
run: |
cd test/playwright
npm ci
npx playwright install --with-deps
# Run Acceptance Tests
- name: "Confirm Codeception setup"
run: |
docker exec nginx-php8.1 bash -c "ls -lah -R /var/www/html/test/Codeception/tests && cat /var/www/html/test/Codeception/*.yml && cat /var/www/html/test/Codeception/tests/*.yml"
# - name: "Run Playwright Module Tests"
# run: |
# export DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306
# sudo chmod 777 -R system/modules/admin/install/migrations/
# cd test/playwright

# for module in $PLAYWRIGHT_MODULES; do
# npm run test:with-retries --module="$module" --platform="chromium" --attempts=3 --reporter="github"
# done

- name: "Run admin module tests"
run: |
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module admin silent; exit \$?"
if [ $? -gt 0 ]; then
echo "Admin module tests failed"
fi
- name: "Run channels module tests"
sudo chmod 777 -R system/modules/admin/install/migrations/
cd test/playwright
npm run build
npm run test --module="admin" --reporter="github"
if [ $? -gt 0 ]; then
echo "Admin module tests failed"
fi
- name: "Run channel module tests"
run: |
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module channels silent; exit \$?"
if [ $? -gt 0 ]; then
echo "Channels module tests failed"
fi
cd test/playwright
npm run build
npm run test --module="channel" --reporter="github"
if [ $? -gt 0 ]; then
echo "Channel module tests failed"
fi
- name: "Run form module tests"
run: |
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module form silent; exit \$?"
if [ $? -gt 0 ]; then
echo "Form module tests failed"
fi
# - name: "Run inbox module tests"
# run: |
# docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module inbox silent; exit \$?"
# if [ $? -gt 0 ]; then
# echo "Inbox module tests failed"
# fi
cd test/playwright
npm run build
npm run test --module="form" --reporter="github"
if [ $? -gt 0 ]; then
echo "Form module tests failed"
fi
- name: "Run report module tests"
run: |
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module report silent; exit \$?"
cd test/playwright
npm run build
npm run test --module="report" --reporter="github"
if [ $? -gt 0 ]; then
echo "Report module tests failed"
fi
- name: "Run tag module tests"
run: |
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module tag silent; exit \$?"
if [ $? -gt 0 ]; then
echo "Tag module tests failed"
fi
cd test/playwright
npm run build
npm run test --module="tag" --reporter="github"
if [ $? -gt 0 ]; then
echo "Tag module tests failed"
fi
- name: "Run task module tests"
run: |
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module task silent; exit \$?"
if [ $? -gt 0 ]; then
echo "Task module tests failed"
fi
cd test/playwright
npm run build
npm run test --module="task" --reporter="github"
if [ $? -gt 0 ]; then
echo "Task module tests failed"
fi
- name: "Run timelog module tests"
run: |
docker exec nginx-php8.1 bash -c "DB_HOST=mysql-8 DB_USERNAME=cmfive_test DB_PASSWORD=cmfive_test DB_DATABASE=cmfive_test DB_PORT=3306 php cmfive.php tests module timelog silent; exit \$?"
if [ $? -gt 0 ]; then
echo "Timelog module tests failed"
fi
cd test/playwright
npm run build
npm run test --module="timelog" --reporter="github"
if [ $? -gt 0 ]; then
echo "Timelog module tests failed"
fi
- name: Stop containers
# the containers should be stopped regardless of
Expand All @@ -192,4 +218,6 @@ jobs:
path: |
test/Codeception/tests/_output/
storage/log/
test/playwright/test-results/
test/playwright/playwright-report/
retention-days: 5
53 changes: 36 additions & 17 deletions system/classes/HtmlBootstrap5.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ public static function buttonGroup(string $content): string
return '<div class="btn-group btn-group-sm" role="group">' . $content . '</div>';
}

public static function dropdownButton($title, $contents, $class)
{
$content = '';
foreach ($contents as $item) {
$content .= '<li>' . $item . '</li>';
}

return '<div class="dropdown">
<button class="' . $class . ' dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">'
. $title .
'</button>
<ul class="dropdown-menu">'
. $content .
'</ul>
</div>';
}

/**
* Creates a complex form where each section can have
* a different number of columns.
Expand All @@ -52,7 +69,7 @@ public static function buttonGroup(string $content): string
* @param <type> $extrabuttons
* @return <type>
*/
public static function multiColForm($data, $action = null, $method = "POST", $submitTitle = "Save", $id = null, $class = null, $extrabuttons = null, $target = "_self", $includeFormTag = true, $validation = null)
public static function multiColForm($data, $action = null, $method = "POST", $submitTitle = "Save", $id = null, $class = null, $extrabuttons = null, $target = "_self", $includeFormTag = true, $validation = null, $displayOverlay = true)
{
if (empty($data)) {
return;
Expand All @@ -64,7 +81,7 @@ public static function multiColForm($data, $action = null, $method = "POST", $su
// If form tag is needed print it
if ($includeFormTag) {
$class .= " col";
$form->id($id)->name($id)->setClass($class)->method($method)->action($action)->target($target);
$form->id($id)->name($id)->setClass($class)->method($method)->action($action)->target($target)->displayOverlay($displayOverlay);

if (in_multiarray("file", $data) || objectPropertyHasValueInMultiArray("\Html\Form\InputField", "type", "file", $data)) {
$form->enctype("multipart/form-data");
Expand Down Expand Up @@ -126,8 +143,8 @@ public static function multiColForm($data, $action = null, $method = "POST", $su
break;
}
if ((property_exists($field, "type") && $field->type !== "hidden") || !property_exists($field, "type")) {
$buffer .= '<div class="col"><label class="' . $label_class . '"' . (property_exists($field, 'id') && !empty($field->id) ? ' for="' . $field->id . '"' : '' ) . '>' . $field->label . ($field->required ? " <small>Required</small>" : "") . "</label>"
. $field->__toString() . '</div>';
$buffer .= '<div class="col"><label class="' . $label_class . '"' . (property_exists($field, 'id') && !empty($field->id) ? ' for="' . $field->id . '"' : '') . '>' . $field->label . ($field->required ? " <small>Required</small>" : "") . "</label>"
. $field->__toString() . '</div>';
} else {
$buffer .= $field->__toString();
}
Expand Down Expand Up @@ -162,7 +179,7 @@ public static function multiColForm($data, $action = null, $method = "POST", $su
// $buffer .= ($type !== "hidden" ? "<div>" : "");

// handle disabled fields
if (substr($name, 0, 1) == '-') {
if (!empty($name) && substr($name, 0, 1) == '-') {
$name = substr($name, 1);
$readonly = " readonly='true' ";
}
Expand All @@ -173,8 +190,8 @@ public static function multiColForm($data, $action = null, $method = "POST", $su
case "email":
case "tel":
$size = !empty($field[4]) ? $field[4] : null;
$buffer .= '<input' . $readonly . ' class="form-control" type="' . $type . '" name="' . $name . '" value="' . htmlspecialchars($value) .
'" size="' . $size . '" id="' . $name . '" ' . $required . " />";
$buffer .= '<input' . $readonly . ' class="form-control" type="' . $type . '" name="' . $name . '" value="' . (empty($value) ? '' : htmlspecialchars($value)) .
'" size="' . $size . '" id="' . $name . '" ' . $required . " />";
break;
case "autocomplete":
$options = !empty($field[4]) ? $field[4] : null;
Expand Down Expand Up @@ -205,14 +222,14 @@ public static function multiColForm($data, $action = null, $method = "POST", $su
$custom_class = $field[6];
}
$buffer .= '<textarea' . $readonly . ' class="form-control" style="width:100%; height: auto; " name="' . $name . '" rows="' . $r . '" cols="' . $c .
'" ' . (!empty($custom_class) ? ($custom_class === true ? "class='ckeditor'" : "class='$custom_class' ") : '') . ' id="' . $name
. '" ' . $required . '>' . $value . '</textarea>';
'" ' . (!empty($custom_class) ? ($custom_class === true ? "class='ckeditor'" : "class='$custom_class' ") : '') . ' id="' . $name
. '" ' . $required . '>' . $value . '</textarea>';
break;
case "select":
$items = !empty($field[4]) ? $field[4] : null;

$default = !empty($field[5]) ? ($field[5] == "null" ? null : $field[5]) : "-- Select --";
$sl_class = !empty($field[6]) ? $field[6] : null;
$sl_class = !empty($field[6]) ? $field[6] : "form-select";
$buffer .= Html::select($name, $items, $value, $sl_class, "width: 100%;", $default, ($readonly ? ' disabled="disabled" ' : null) . ' ' . $required);
break;
case "multiSelect":
Expand All @@ -235,7 +252,7 @@ public static function multiColForm($data, $action = null, $method = "POST", $su
$buffer .= Html::radio($name, $group, $value, $defaultValue, $rd_class) . "&nbsp;" . htmlentities($title);
break;
case "hidden":
$buffer .= '<input type="hidden" name="' . $name . '" value="' . htmlspecialchars($value) . '" id="' . $name . '"/>';
$buffer .= '<input type="hidden" name="' . $name . '" value="' . (empty($value) ? '' : htmlspecialchars($value)) . '" id="' . $name . '"/>';
break;
case "file":
$size = !empty($row[4]) ? $row[4] : null;
Expand Down Expand Up @@ -284,7 +301,7 @@ public static function table($data, $id = null, $class = "tablesorter", $header
$buffer = "";

// Opening tags
$buffer .= "<table class='{$class} d-none d-md-block'>";
$buffer .= "<table class='{$class} d-none d-md-table'>";
if (!empty($header)) {
$buffer .= "<thead><tr>";
if (is_array($header)) {
Expand Down Expand Up @@ -626,7 +643,7 @@ public static function filter($legend, $data, $action = null, $method = "POST",
switch ($type) {
case "text":
case "password":
$buffer .= '<input' . $readonly . ' style="width:100%;" type="' . $type . '" name="' . $name . '" value="' . htmlspecialchars($value) . '" size="' . (!empty($row[4]) ? $row[4] : null) . '" id="' . $name . '"/>';
$buffer .= '<input' . $readonly . ' style="width:100%;" type="' . $type . '" name="' . $name . '" value="' . (empty($value) ? '' : htmlspecialchars($value)) . '" size="' . (!empty($row[4]) ? $row[4] : null) . '" id="' . $name . '"/>';
break;
case "autocomplete":
$minlength = !empty($row[5]) ? $row[5] : null;
Expand Down Expand Up @@ -683,7 +700,7 @@ public static function filter($legend, $data, $action = null, $method = "POST",
$buffer .= Html::radio($name, $group, $value, $defaultValue, $class) . "&nbsp;" . htmlentities($title);
break;
case "hidden":
$hidden .= "<input type=\"hidden\" name=\"" . $name . "\" value=\"" . htmlspecialchars($value) . "\"/>\n";
$hidden .= "<input type=\"hidden\" name=\"" . $name . "\" value=\"" . (empty($value) ? '' : htmlspecialchars($value)) . "\"/>\n";
break;
case "file":
$buffer .= "<input style=\"width:100%;\" type=\"" . $type . "\" name=\"" . $name . "\" size=\"" . $size . "\" id=\"" . $name . "\"/>";
Expand All @@ -695,8 +712,10 @@ public static function filter($legend, $data, $action = null, $method = "POST",

// This is only true when the filter has one element and its a select field
if ($should_autosubmit) {
$buffer .= "<script>$('form" . ($id ? "#" . $id : "") . ' select\').change(function(){this.form.submit()});</script>';
$selector = $id ? "form#" . $id . " select" : "form select";
$buffer .= "<script>document.querySelectorAll('" . $selector . "').forEach(function(select) { select.addEventListener('change', function() { this.form.submit(); }); });</script>";
}

// Filter button (optional... though optional is pointless)
if (!empty($action)) {
$button = new \Html\button();
Expand All @@ -712,7 +731,7 @@ public static function filter($legend, $data, $action = null, $method = "POST",

$buffer .= "</div></label></li>";
}

$buffer .= "</ul>"; // </div>
$buffer .= "\n</fieldset>\n";
$buffer .= $hidden . "</form>\n";
Expand Down Expand Up @@ -757,7 +776,7 @@ public static function pagination($currentpage, $numpages, $pagesize, $totalresu
* @param string $class
* @return string
*/
public static function alertBox($msg, $type = "alert-info", $include_close = true) : string
public static function alertBox($msg, $type = "alert-info", $include_close = true): string
{
if ($type !== "alert-info" && $type !== "alert-warning" && $type !== "alert-danger" && $type !== "alert-success") {
$type = "alert-info";
Expand Down
Loading

0 comments on commit 1ac1110

Please sign in to comment.