diff --git a/app/controllers/consultation/admin.php b/app/controllers/consultation/admin.php index 13451d2a8a80ecf71658dd33c20211d87c1ef0a5..3d2be46c907adb43d48454afe6987bedbceef70c 100644 --- a/app/controllers/consultation/admin.php +++ b/app/controllers/consultation/admin.php @@ -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() diff --git a/app/views/consultation/admin/create.php b/app/views/consultation/admin/create.php deleted file mode 100644 index 34385b500d21953c4b796baea2454c199a5810cc..0000000000000000000000000000000000000000 --- a/app/views/consultation/admin/create.php +++ /dev/null @@ -1,36 +0,0 @@ -<?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>