From bf6e51ea0a3cf8b3db77380a369a8b8a05701da9 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms Date: Fri, 5 Jul 2024 07:49:31 +0000 Subject: convert consultation creator to new data-vue-app mechanism, fixes #4367 Closes #4367 Merge request studip/studip!3167 --- app/controllers/consultation/admin.php | 44 +++++++++++++++++++++++++++------ app/views/consultation/admin/create.php | 36 --------------------------- 2 files changed, 36 insertions(+), 44 deletions(-) delete mode 100644 app/views/consultation/admin/create.php diff --git a/app/controllers/consultation/admin.php b/app/controllers/consultation/admin.php index 13451d2..3d2be46 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 34385b5..0000000 --- a/app/views/consultation/admin/create.php +++ /dev/null @@ -1,36 +0,0 @@ - $values) { - $input[$key] = array_map( - fn($item) => ['id' => $item->id, 'label' => $item instanceof Statusgruppen ? $item->getName() : $item->getFullName()], - $values - ); - } - - return json_encode($input); -} - -?> -
-- cgit v1.0