From 43c24ba3dcbff77f98751c7def1751a2aa109773 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms Date: Fri, 5 Jul 2024 15:55:01 +0200 Subject: convert OERMaterialEditor to sfc, re #4302 --- app/views/oer/mymaterial/edit.php | 57 ++++ lib/models/OERMaterial.php | 9 +- resources/assets/javascripts/bootstrap/vue.js | 1 + resources/assets/stylesheets/scss/oer.scss | 49 +-- resources/vue/components/OERMaterialEditor.vue | 421 +++++++++++++++++++++++++ 5 files changed, 489 insertions(+), 48 deletions(-) create mode 100644 resources/vue/components/OERMaterialEditor.vue diff --git a/app/views/oer/mymaterial/edit.php b/app/views/oer/mymaterial/edit.php index 12c1676..a0ec187 100644 --- a/app/views/oer/mymaterial/edit.php +++ b/app/views/oer/mymaterial/edit.php @@ -1,3 +1,60 @@ + + + +withProps([ + 'store-url' => $controller->edit($material), + 'material' => [ + ...$material->toArray(), + + 'filesize' => $material->getFilePath() && file_exists($material->getFilePath()) ? filesize($material->getFilePath()) : null, + 'logoUrl' => $material->getLogoURL(), + 'tags' => array_map( + fn($tag) => $tag['name'], + $material->getTopics() + ), + 'users' => $material->users->map(function (OERMaterialUser $user) { + if ($user->external_contact) { + return [ + 'id' => $user->oeruser->id, + 'name' => $user->oeruser->name, + 'avatar' => $user->oeruser->avatar_url, + 'external' => true, + ]; + } + + $u = User::find($user->user_id); + return [ + 'id' => $u->user_id, + 'avatar' => Avatar::getAvatar($u->id)->getURL(Avatar::SMALL), + 'name' => $u ? $u->getFullName() : _('unbekannt'), + 'external' => false, + ]; + }), + ], + 'template' => $template ?? null, + 'tag-search' => (string) $tagsearch, + 'user-search' => (string) $usersearch, + 'licenses-enabled' => !Config::get()->getValue('OER_DISABLE_LICENSE'), + 'licenses' => License::findAndMapBySQL( + function (License $license) { + return [ + 'id' => $license->id, + 'name' => $license->name, + ]; + }, + '1 ORDER BY name' + ), + 'enable-twillo' => Config::get()->getValue('OERCAMPUS_ENABLE_TWILLO') && TwilloConnector::getTwilloUserID(), + ]) ?> +
License::class, 'foreign_key' => 'license_identifier' ]; + + $config['default_values'] = [ + 'license_identifier' => License::findDefault()->id, + ]; + $config['serialized_fields']['structure'] = JSONArrayObject::class; $config['serialized_fields']['data'] = JSONArrayObject::class; + $config['registered_callbacks']['before_store'][] = "cbHashURI"; $config['registered_callbacks']['before_delete'][] = "cbDeleteFile"; + parent::configure($config); } @@ -240,7 +247,7 @@ class OERMaterial extends SimpleORMap $statement = DBManager::get()->prepare(" SELECT oer_tags.* FROM oer_tags - INNER JOIN oer_tags_material ON (oer_tags_material.tag_hash = oer_tags.tag_hash) + JOIN oer_tags_material ON (oer_tags_material.tag_hash = oer_tags.tag_hash) WHERE oer_tags_material.material_id = :material_id ORDER BY oer_tags.name ASC "); diff --git a/resources/assets/javascripts/bootstrap/vue.js b/resources/assets/javascripts/bootstrap/vue.js index ce1aa0d..046636c 100644 --- a/resources/assets/javascripts/bootstrap/vue.js +++ b/resources/assets/javascripts/bootstrap/vue.js @@ -22,6 +22,7 @@ STUDIP.ready(() => { this.$el instanceof Element && this.$el.closest('.studip-dialog') && this.$el.querySelector('[data-dialog-button]') + && this.$el.closest('.studip-dialog') ) { this.$el.closest('.studip-dialog') .querySelector('.ui-dialog-buttonpane') diff --git a/resources/assets/stylesheets/scss/oer.scss b/resources/assets/stylesheets/scss/oer.scss index 45c9361..e25efa3 100644 --- a/resources/assets/stylesheets/scss/oer.scss +++ b/resources/assets/stylesheets/scss/oer.scss @@ -128,53 +128,8 @@ ul.reviews, ol.reviews { max-width: 1000px; } -.oercampus_editmaterial { - .drag-and-drop { - width: 260px; - margin-left: 0px; - height: 60px; - background-position: center 40px; - padding-top: 100px; - } - - .autoren { - &.multiple label { - cursor: pointer; - } - input[type=checkbox] { - display: none; - } - input[type=checkbox]:checked + div { - text-decoration: line-through; - } - .avatar { - display: inline-block; - background-position: center center; - background-repeat: no-repeat; - background-size: 100% 100%; - width: 20px; - min-width: 20px; - height: 20px; - margin-right: 5px; - position: relative; - top: 5px; - } - } - .oer_tags_container { - margin-top: 10px; - } - - .level_labels { - display: flex; - justify-content: space-between; - font-size: 0.8em; - color: var(--black); - margin-top: 20px; - } - -} - -.oercampus_editmaterial, .oer_material_overview { +.oercampus_editmaterial, +.oer_material_overview { article.contentbox { display: inline-block; margin: 0 15px 15px 0; diff --git a/resources/vue/components/OERMaterialEditor.vue b/resources/vue/components/OERMaterialEditor.vue new file mode 100644 index 0000000..6e98ea9 --- /dev/null +++ b/resources/vue/components/OERMaterialEditor.vue @@ -0,0 +1,421 @@ + + + -- cgit v1.0