Skip to content
Snippets Groups Projects
Commit bf6e51ea authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

convert consultation creator to new data-vue-app mechanism, fixes #4367

Closes #4367

Merge request studip/studip!3167
parent ac2367fc
No related branches found
No related tags found
No related merge requests found
......@@ -136,28 +136,56 @@ class Consultation_AdminController extends ConsultationController
{
PageLayout::setTitle(_('Neue Terminblöcke anlegen'));
$this->room = '';
$this->responsible = false;
$this->slot_count_threshold = self::SLOT_COUNT_THRESHOLD;
$room = '';
$responsible = false;
// TODO: inst_default?
if ($this->range instanceof User) {
$rooms = $this->range->institute_memberships->pluck('Raum');
$rooms = array_filter($rooms);
$this->room = $rooms ? reset($rooms) : '';
$room = $rooms ? reset($rooms) : '';
} elseif ($this->range instanceof Course) {
$this->room = $this->range->ort;
$room = $this->range->ort;
$block = new ConsultationBlock();
$block->range = $this->range;
$this->responsible = $block->getPossibleResponsibilites();
$responsible = $block->getPossibleResponsibilites();
} elseif ($this->range instanceof Institute) {
$block = new ConsultationBlock();
$block->range = $this->range;
$this->responsible = $block->getPossibleResponsibilites();
$responsible = $block->getPossibleResponsibilites();
}
$this->response->add_header('X-No-Buttons', '');
$convertResponsibilities = function ($input) {
if ($input === false) {
return false;
}
foreach ($input as $key => $values) {
$input[$key] = array_map(
fn($item) => [
'id' => $item->id,
'label' => $item instanceof Statusgruppen ? $item->getName() : $item->getFullName(),
],
$values
);
}
return $input;
};
$this->render_vue_app(
Studip\VueApp::create('ConsultationCreator')
->withProps([
'as-dialog' => Request::isXhr(),
'cancel-url' => $this->indexURL(),
'default-room' => $room,
'range-type' => get_class($this->range),
'slot-count_threshold' => self::SLOT_COUNT_THRESHOLD,
'store-url' => $this->storeURL(),
'with-responsible' => $convertResponsibilities($responsible),
])
);
}
public function store_action()
......
<?php
/**
* @var Consultation_AdminController $controller
* @var Trails\Flash $flash
* @var string|null $room
* @var array $responsible
* @var Range $range
* @var int $slot_count_threshold
*/
$convertResponsibilities = function ($input) {
if ($input === false) {
return json_encode(false);
}
foreach ($input as $key => $values) {
$input[$key] = array_map(
fn($item) => ['id' => $item->id, 'label' => $item instanceof Statusgruppen ? $item->getName() : $item->getFullName()],
$values
);
}
return json_encode($input);
}
?>
<div data-vue-app="<?= htmlReady(json_encode(['components' => ['ConsultationCreator']])) ?>"
is="ConsultationCreator"
cancel-url="<?= $controller->indexURL() ?>"
store-url="<?= $controller->storeURL() ?>"
:with-responsible="<?= htmlReady($convertResponsibilities($responsible)) ?>"
range-type="<?= get_class($range) ?>"
default-room="<?= htmlReady($room) ?>"
:slot-count-threshold="<?= htmlReady($slot_count_threshold) ?>"
:as-dialog="<?= json_encode(Request::isXhr()) ?>"
></div>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment