Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ LB_RESOURCE_CONTACT_IS_USER=false
# Tablet View Options
##########################################

# Allows to make reservations in the tablet view (true/false)
LB_TABLET_VIEW_ALLOW_RESERVATIONS=true

# Allow guest users to make reservations in tablet view (true/false)
LB_TABLET_VIEW_ALLOW_GUEST_RESERVATIONS=false

Expand Down
6 changes: 4 additions & 2 deletions Pages/ResourceDisplayPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public function __construct()
new TermsOfServiceRepository()
);

$this->Set('AllowReservations', Configuration::Instance()->GetKey(ConfigKeys::TABLET_VIEW_ALLOW_RESERVATIONS, new BooleanConverter()));
$this->Set('AllowAutocomplete', Configuration::Instance()->GetKey(ConfigKeys::TABLET_VIEW_AUTO_SUGGEST_EMAILS, new BooleanConverter()));
$this->Set('ShouldLogout', false);
}
Expand Down Expand Up @@ -243,7 +244,7 @@ public function GetStartDate()
$parsedDate = $this->GetQuerystring(QueryStringKeys::START_DATE);
if (!empty($parsedDate)) {
$startDate = Date::Parse($parsedDate, $userTimezone);
}else{
} else {
$startDate = Date::Now()->ToTimezone($userTimezone);
}
return $startDate;
Expand Down Expand Up @@ -290,7 +291,8 @@ public function DisplayResourceShell()
if ($futureDays == 0) {
$futureDays = 1;
}
$this->Set('MaxFutureDate', Date::Now()->AddDays($futureDays-1));
$this->Set('MinDate', Date::Now());
$this->Set('MaxFutureDate', Date::Now()->AddDays($futureDays - 1));
$this->Display('ResourceDisplay/resource-display-shell.tpl');
}

Expand Down
29 changes: 16 additions & 13 deletions Presenters/ResourceDisplayPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ public function DisplayResource($resourcePublicId, $startDate)

$layout = $this->scheduleRepository->GetLayout($scheduleId, new ScheduleLayoutFactory($timezone));
$slots = $layout->GetLayout($now, true);
if(!empty($startDate)){
if (!empty($startDate)) {
$reservationDate = $startDate;
}else{
} else {
$reservationDate = $now;
if ($slots[count($slots) - 1]->EndDate()->LessThanOrEqual($now)) {
$now = $now->AddDays(1)->GetDate();
Expand Down Expand Up @@ -234,6 +234,15 @@ public function DisplayResource($resourcePublicId, $startDate)

public function Reserve()
{
if (!Configuration::Instance()->GetKey(ConfigKeys::TABLET_VIEW_ALLOW_RESERVATIONS)) {
$resultCollector = new ReservationResultCollector();
$resultCollector->SetSaveSuccessfulMessage(false);
$resultCollector->SetErrors(['Reservations are disabled in tablet view']);

$this->page->SetReservationSaveResults(false, $resultCollector);
return;
}

$timezone = $this->page->GetTimezone();
$resourceId = $this->page->GetResourceId();
$email = $this->page->GetEmail();
Expand All @@ -245,15 +254,15 @@ public function Reserve()
if ($maxFutureDays == 0) {
$maxFutureDays = 1;
}
$maxDate = Date::Now()->ToTimezone($timezone)->AddDays($maxFutureDays+1)->GetDate();
$maxDate = Date::Now()->ToTimezone($timezone)->AddDays($maxFutureDays + 1)->GetDate();

$resultCollector = new ReservationResultCollector();

if ($date->GetBegin()->GreaterThan($maxDate)) {
$resultCollector->SetSaveSuccessfulMessage(false);
$resultCollector->SetErrors(["Unauthorized"]);
$success = false;
}else{
} else {

$userSession = $this->guestUserService->CreateOrLoad($email);
$resource = $this->resourceRepository->LoadById($resourceId);
Expand Down Expand Up @@ -380,23 +389,17 @@ public function SetWarnings($warnings)
/**
* @param array|string[] $messages
*/
public function SetRetryMessages($messages)
{
}
public function SetRetryMessages($messages) {}

/**
* @param bool $canBeRetried
*/
public function SetCanBeRetried($canBeRetried)
{
}
public function SetCanBeRetried($canBeRetried) {}

/**
* @param ReservationRetryParameter[] $retryParameters
*/
public function SetRetryParameters($retryParameters)
{
}
public function SetRetryParameters($retryParameters) {}

/**
* @return ReservationRetryParameter[]
Expand Down
24 changes: 1 addition & 23 deletions Web/scripts/resourceDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,9 @@ function ResourceDisplay(opts) {

elements.placeholder.on('click', '#reservePopup', function (e) {
pauseRefresh();
//showPopup();
});

elements.placeholder.on('click', '#reserveCancel', function (e) {
//hidePopup();
resumeRefresh();
refreshResource();
});
Expand All @@ -101,7 +99,6 @@ function ResourceDisplay(opts) {
var validationErrors = $('#validationErrors');
if (data.success) {
validationErrors.find('ul').empty().addClass('d-none');
//hidePopup();
resumeRefresh();
refreshResource();
$('#reservation-box').modal('hide');
Expand Down Expand Up @@ -147,34 +144,17 @@ function ResourceDisplay(opts) {
$(this).removeClass('hilite');
});

elements.startDate.on('change', function () {
elements.rawStartDate.on('change', function () {
showWait();
refreshResource(hideWait);
});

var beginIndex = 0;

function showPopup() {
/*$('#reservation-box-wrapper').show();
var reservationBox = $('#reservation-box');
reservationBox.show();
var offsetFromTop = ($('body').height() - reservationBox.height()) / 2;
reservationBox.css(
{ top: offsetFromTop + 'px' }
);

$('#emailAddress').focus();*/
}

function pauseRefresh() {
_refreshEnabled = false;
}

function hidePopup() {
// $('#reservation-box').hide();
// $('#reservation-box-wrapper').hide();
}

function resumeRefresh() {
_refreshEnabled = true;
}
Expand All @@ -197,8 +177,6 @@ function ResourceDisplay(opts) {
}
elements.placeholder.html(data);

//$('#resource-display').height($('body').height());

var formCheckin = $('#formCheckin');
formCheckin.unbind('submit');

Expand Down
3 changes: 3 additions & 0 deletions config/config.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,9 @@
##########################################

'tablet.view' => [
# Allow users to make reservations in the tablet view (true/false)
'allow.reservations' => true,

# Allow guest users to make reservations in tablet view (true/false)
'allow.guest.reservations' => false,

Expand Down
8 changes: 8 additions & 0 deletions lib/Config/ConfigKeys.php
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,14 @@ class ConfigKeys
];

// Tablet View Options
public const TABLET_VIEW_ALLOW_RESERVATIONS = [
'key' => 'tablet.view.allow.reservations',
'type' => 'boolean',
'default' => true,
'label' => 'Allows reservations',
'description' => 'Allows users to make reservations in the tablet view',
'section' => 'tablet.view'
];

# previously TABLET_VIEW_ALLOW_GUESTS
public const TABLET_VIEW_ALLOW_GUEST_RESERVATIONS = [
Expand Down
3 changes: 2 additions & 1 deletion tests/TestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function setUp(): void
$this->fakeEmailService = new FakeEmailService();
$this->fakeConfig = new FakeConfig();
$this->fakeConfig->SetKey(ConfigKeys::DEFAULT_TIMEZONE, 'America/Chicago');
$this->fakeConfig->SetKey(ConfigKeys::TABLET_VIEW_ALLOW_RESERVATIONS, true);

$this->fakeResources = new FakeResources();
$this->fakeUser = $this->fakeServer->UserSession;
Expand Down Expand Up @@ -88,7 +89,7 @@ protected function captureErrorLog(callable $testFunction, bool $displayLogs = f
if (ini_set('error_log', $tempLogFile) === false) {
throw new \RuntimeException("Failed to set error_log to temporary file: $tempLogFile");
}

try {
// Execute the test function
$testFunction();
Expand Down
Loading