Skip to content

Commit

Permalink
skrytí nevyužitých časů v kalendáři
Browse files Browse the repository at this point in the history
* zobrazovani pouze vyuzitych casu

* coding standard fix

* odstraneni scroll time
  • Loading branch information
jan-stanek authored May 17, 2020
1 parent e350e3c commit 20e8bb2
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 11 deletions.
26 changes: 26 additions & 0 deletions app/ApiModule/Dto/Schedule/CalendarConfigDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ class CalendarConfigDto
/** @JMS\Type("string") */
private string $seminarToDate;

/** @JMS\Type("string") */
private string $minTime;

/** @JMS\Type("string") */
private string $maxTime;

/** @JMS\Type("boolean") */
private bool $allowedModifySchedule;

Expand All @@ -45,6 +51,26 @@ public function setSeminarToDate(string $seminarToDate) : void
$this->seminarToDate = $seminarToDate;
}

public function getMinTime() : string
{
return $this->minTime;
}

public function setMinTime(string $minTime) : void
{
$this->minTime = $minTime;
}

public function getMaxTime() : string
{
return $this->maxTime;
}

public function setMaxTime(string $maxTime) : void
{
$this->maxTime = $maxTime;
}

public function isAllowedModifySchedule() : bool
{
return $this->allowedModifySchedule;
Expand Down
12 changes: 3 additions & 9 deletions app/ApiModule/Dto/Schedule/ResponseDto.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ResponseDto
private string $status;

/** @JMS\Type("App\ApiModule\Dto\Schedule\ProgramDetailDto") */
private ProgramDetailDto $program;
private ?ProgramDetailDto $program = null;

public function getMessage() : string
{
Expand All @@ -45,18 +45,12 @@ public function setStatus(string $status) : void
$this->status = $status;
}

/**
* @return mixed
*/
public function getProgram()
public function getProgram() : ?ProgramDetailDto
{
return $this->program;
}

/**
* @param mixed $program
*/
public function setProgram($program) : void
public function setProgram(ProgramDetailDto $program) : void
{
$this->program = $program;
}
Expand Down
28 changes: 28 additions & 0 deletions app/ApiModule/Services/ScheduleService.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,34 @@ public function getCalendarConfig() : CalendarConfigDto
$calendarConfigDto->setAllowedModifySchedule($this->settingsService->getBoolValue(Settings::IS_ALLOWED_MODIFY_SCHEDULE)
&& $this->user->isAllowed(SrsResource::PROGRAM, Permission::MANAGE_SCHEDULE));

/** @var Program[] $programs */
$programs = $this->programRepository->findAll();
if (empty($programs)) {
$minTime = 0;
$maxTime = 24;
} else {
$minTime = 24;
$maxTime = 0;
foreach ($programs as $program) {
$start = (int) $program->getStart()->format('H');
if ($start < $minTime) {
$minTime = $start;
}

$end = (int) $program->getEnd()->format('H');
if ((int) $program->getEnd()->format('i') > 0) {
$end++;
}

if ($end > $maxTime) {
$maxTime = $end;
}
}
}

$calendarConfigDto->setMinTime((string) $minTime);
$calendarConfigDto->setMaxTime((string) $maxTime);

return $calendarConfigDto;
}

Expand Down
13 changes: 12 additions & 1 deletion app/assets/web/schedule/Calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,15 @@
theme-system="bootstrap"
locale="cs"
timeZone="none"
scroll-time="07:00:00"
aspect-ratio="1.85"
header="false"
scheduler-license-key="GPL-My-Project-Is-Open-Source"
:plugins="calendarPlugins"
:views="calendarViews"
:default-view="defaultView"
:valid-range="validRange"
:min-time="minTime"
:max-time="maxTime"
:event-render="eventRender"
:view-skeleton-render="viewSkeletonRender"
:dates-render="datesRender"
Expand Down Expand Up @@ -199,6 +200,16 @@
start: this.config.seminar_from_date,
end: this.config.seminar_to_date
}
},
minTime() {
return {
minutes: this.config.min_time * 60
};
},
maxTime() {
return {
minutes: this.config.max_time * 60
};
}
},
watch: {
Expand Down
4 changes: 3 additions & 1 deletion app/assets/web/schedule/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export default new Vuex.Store({
state: {
config: {
seminar_from_date: "2000-01-01",
seminar_to_date: "2000-01-01"
seminar_to_date: "2000-01-01",
min_time: "0",
max_time: "24"
},
blocks: [],
resources: [],
Expand Down

0 comments on commit 20e8bb2

Please sign in to comment.