Skip to content

Commit

Permalink
Next step: Pass template data via Wunderbyte table (Wunderbyte-GmbH/W…
Browse files Browse the repository at this point in the history
…underbyte-GmbH#233)
  • Loading branch information
ibernhardf committed Nov 26, 2024
1 parent 97ecb3e commit 097e6c2
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 9 deletions.
6 changes: 5 additions & 1 deletion classes/bo_availability/bo_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,11 @@ private static function add_continue_button(
$settings = singleton_service::get_instance_of_booking_option_settings($optionid);
$viewparam = booking::get_value_of_json_by_key($settings->bookingid, 'viewparam');
$turnoffmodals = 0; // By default, we use modals.
if ($viewparam == MOD_BOOKING_VIEW_PARAM_LIST) {
if (
$viewparam == MOD_BOOKING_VIEW_PARAM_LIST
|| $viewparam = MOD_BOOKING_VIEW_PARAM_LIST_IMG_LEFT
|| $viewparam = MOD_BOOKING_VIEW_PARAM_LIST_IMG_RIGHT
) {
// Only if we use list view, we can use inline modals.
// So only in this case, we need to check the config setting.
$turnoffmodals = get_config('booking', 'turnoffmodals');
Expand Down
9 changes: 7 additions & 2 deletions classes/booking_bookit.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,12 @@ public static function render_bookit_template_data(

$viewparam = booking::get_value_of_json_by_key($settings->bookingid, 'viewparam');
$turnoffmodals = 0; // By default, we use modals.
if ($viewparam == MOD_BOOKING_VIEW_PARAM_LIST) {
// Only if we use list view, we can use inline modals.
if (
$viewparam == MOD_BOOKING_VIEW_PARAM_LIST
|| $viewparam == MOD_BOOKING_VIEW_PARAM_LIST_IMG_LEFT
|| $viewparam == MOD_BOOKING_VIEW_PARAM_LIST_IMG_RIGHT
) {
// Only if we use one of the list views, we can use inline modals.
// So only in this case, we need to check the config setting.
$turnoffmodals = get_config('booking', 'turnoffmodals');
}
Expand Down Expand Up @@ -534,6 +538,7 @@ public static function answer_booking_option(string $area, int $itemid, int $sta
// phpcs:ignore Squiz.PHP.CommentedOutCode.Found
/* $cm = get_coursemodule_from_instance('booking', $bookingoption->bookingid); */

// phpcs:ignore moodle.Commenting.TodoComment.MissingInfoInline
// TODO: Find out if the executing user has the right to access this instance.
// This can lead to problems, rights should be checked further up.
// phpcs:ignore Squiz.PHP.CommentedOutCode.Found
Expand Down
1 change: 1 addition & 0 deletions classes/output/col_availableplaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public function __construct($values, booking_option_settings $settings, ?\stdCla
$bookinginformation = array_pop($fullbookinginformation);

// Get maxanswers from cache if exist.
// phpcs:ignore moodle.Commenting.TodoComment.MissingInfoInline
// TODO: how about entire option settings?
$cache = \cache::make('mod_booking', 'bookingoptionsettings');
$cachedoption = $cache->get($settings->id);
Expand Down
19 changes: 19 additions & 0 deletions classes/output/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ class view implements renderable, templatable {
/** @var array $elective */
private $electivemodal = null;

/** @var bool $showheaderimage */
private $showheaderimage = null;

/** @var string $headerimageposition */
private $headerimageposition = null;

/**
* Constructor
*
Expand Down Expand Up @@ -702,6 +708,17 @@ public static function apply_standard_params_for_bookingtable(
case MOD_BOOKING_VIEW_PARAM_CARDS:
self::generate_table_for_cards($wbtable, $optionsfields);
break;
case MOD_BOOKING_VIEW_PARAM_LIST_IMG_LEFT:
$wbtable->set_template_data('showheaderimage', true);
$wbtable->set_template_data('headerimageleft', true);
self::generate_table_for_list($wbtable, $optionsfields);
break;
case MOD_BOOKING_VIEW_PARAM_LIST_IMG_RIGHT:
$wbtable->set_template_data('showheaderimage', true);
$wbtable->set_template_data('headerimageright', true);
self::generate_table_for_list($wbtable, $optionsfields);
break;
case MOD_BOOKING_VIEW_PARAM_LIST:
default:
self::generate_table_for_list($wbtable, $optionsfields);
break;
Expand Down Expand Up @@ -1188,6 +1205,8 @@ public function export_for_template(renderer_base $output) {
'showinvisible' => $this->showinvisible,
'showfieldofstudy' => $this->showfieldofstudy,
'elective' => empty($this->renderelectivetable) ? false : $this->electivemodal,
'showheaderimage' => $this->showheaderimage,
'headerimageposition' => $this->headerimageposition,
];
}
}
2 changes: 2 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
// View params.
define('MOD_BOOKING_VIEW_PARAM_LIST', 0); // List view.
define('MOD_BOOKING_VIEW_PARAM_CARDS', 1); // Cards view.
define('MOD_BOOKING_VIEW_PARAM_LIST_IMG_LEFT', 2); // List view with image on the left.
define('MOD_BOOKING_VIEW_PARAM_LIST_IMG_RIGHT', 3); // List view with image on the right.

// Currently up to 9 different price categories can be set.
define('MOD_BOOKING_MAX_PRICE_CATEGORIES', 9);
Expand Down
4 changes: 3 additions & 1 deletion mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,11 @@ public function definition() {
$mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');

$viewparamoptions = [MOD_BOOKING_VIEW_PARAM_LIST => get_string('viewparam:list', 'mod_booking')];
// Cards view is a PRO feature.
// Additional views like cards view are a PRO feature.
if ($isproversion) {
$viewparamoptions[MOD_BOOKING_VIEW_PARAM_CARDS] = get_string('viewparam:cards', 'mod_booking');
$viewparamoptions[MOD_BOOKING_VIEW_PARAM_LIST_IMG_LEFT] = get_string('viewparam:listimgleft', 'mod_booking');
$viewparamoptions[MOD_BOOKING_VIEW_PARAM_LIST_IMG_RIGHT] = get_string('viewparam:listimgright', 'mod_booking');
}
// Default view param (0...List view, 1...Cards view).
$mform->addElement('select', 'viewparam', get_string('viewparam', 'mod_booking'),
Expand Down
9 changes: 4 additions & 5 deletions templates/table_list_row.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
flex-md-row align-items-center row gx-0" {{#datafields}} data-{{key}}="{{value}}" {{/datafields}}>
<div class="content w-100">
<div class="row mod-booking-row {{rowclasses}} {{rowid}}">
{{#headerimage}}
{{#showheaderimage}}{{#headerimage}}
<div class="mod-booking-view-list-image-container col-md-3">
{{#value}}
<img class="mod-booking-view-list-image rounded-left" src="{{{value}}}" {{#headerimagealt}}alt="{{.}}" title="{{.}}"{{/headerimagealt}}>
Expand All @@ -138,8 +138,7 @@
{{/value}}
</div>
<div class="col-md-9 pt-3 pb-3">
{{/headerimage}}
<div class="row">
<div class="row">{{/headerimage}}{{/showheaderimage}}
<div
{{#rightside}} class="col-md-9" {{/rightside}}
{{^rightside}} class="col-12" {{/rightside}}
Expand Down Expand Up @@ -221,9 +220,9 @@
{{#columnclass}}</div>{{/columnclass}}
{{/rightside}}
</div>
</div>
{{#showheaderimage}}{{#headerimage}}</div>{{/headerimage}}{{/showheaderimage}}
</div>
{{#headerimage}}</div>{{/headerimage}}
{{#showheaderimage}}{{#headerimage}}</div>{{/headerimage}}{{/showheaderimage}}
</div>
</div>
</div>

0 comments on commit 097e6c2

Please sign in to comment.