diff --git a/assets/styles/app.scss b/assets/styles/app.scss index f1349795614fa1f72aa9dded9d17d5c9946574c1..cf6890562c4369911c7a20c0dba3c2043128204c 100644 --- a/assets/styles/app.scss +++ b/assets/styles/app.scss @@ -123,14 +123,20 @@ button[type=submit]{ float: left; color: rgba(255,255,255,.75) !important; line-height: 60px; + margin-bottom: 0; background: -webkit-linear-gradient(top left, #FA772E, #FC4326); -webkit-background-clip: text; -webkit-text-fill-color: transparent; } +.h2 { + margin-bottom: 0; +} + .button-cancel { border: none; border-radius: 3px; + background-color: #5c636a; } .button-cancel:hover { diff --git a/capsule-prototype/create.zip b/capsule-prototype/create.zip index a2a703ea770860eb81d342239f65d7a857384d5a..f135089df67215934ef7b883218c37a4b7999b11 100644 Binary files a/capsule-prototype/create.zip and b/capsule-prototype/create.zip differ diff --git a/capsule-prototype/css/images/icn-menu-mosaic.png b/capsule-prototype/css/images/icn-menu-mosaic.png new file mode 100644 index 0000000000000000000000000000000000000000..8b272e3abf67c16f31c173f1e1683fe1bc423108 Binary files /dev/null and b/capsule-prototype/css/images/icn-menu-mosaic.png differ diff --git a/capsule-prototype/css/online-theme.css b/capsule-prototype/css/online-theme.css index 8c0dbb6e3d7f9637ae94c467eb86a175dc15bf76..d1fc014924ae21f95a567bff81710956f23808cf 100644 --- a/capsule-prototype/css/online-theme.css +++ b/capsule-prototype/css/online-theme.css @@ -19,7 +19,7 @@ html, body { user-select: none; } -#popupSpace, #popupAlertSpace, #popupAddLinkSpace, #popupSettingsSpace { +#popupSpace, #popupAlertSpace, #popupAddLinkSpace, #popupSettingsSpace, #popupMosaicSpace { width: 100%; height: 100%; background: rgba(0,0,0,.25); @@ -271,7 +271,7 @@ html, body { } -#popupAddLinkMessage { +#popupAddLinkMessage, #popupMosaicMessage { font-weight: 100; color: rgba(255,255,255,.75); text-align: center; @@ -301,7 +301,51 @@ html, body { margin: 2vh 0 1.5vh 0; } +#popupMosaic { + background: #243538; + box-shadow: 0 1px 3px rgba(0,0,0,.2) inset; + border: 0; + border-radius: 3px; + color: rgba(255,255,255,.85); + width: 70vw; + display: inline-block; + + font-weight: 200; + font-size: 0.9em; + cursor: pointer; + padding-bottom: 0; + + line-height: 1.2em; + padding: 1.0em 1vw; + + margin: 2vh 0 1.5vh -10vw; + overflow: scroll; + height: 90vh; +} + +.mosaic_category { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); + background: rgba(0,0,0,.15); + grid-auto-rows: 150px; + border-radius: 3px; + padding: 1.0em 1vw; + margin: 2vh 0 1.5vh 0; +} +.mosaic_item img { + /* To correctly align image, regardless of content height: */ + vertical-align: top; + display: inline-block; + /* To horizontally center images and caption */ + text-align: center; + /* The width of the container also implies margin around the images. */ + width: 100px; + margin: 2vh 0 1.5vh 0; +} +.mosaic_item .caption { + display:block; +} @@ -395,9 +439,26 @@ html, body { right: 25.5vw; z-index: 110; } -#closePopupEdit:hover { + +#closePopupMosaic { + width: 40px; + height: 40px; + font-weight: 200; + color: rgba(255,255,255,.25); + font-size: 30px; + text-align: center; + line-height: 40px; + cursor: pointer; + border-radius: 3px; + position: fixed; + top: 2vh; + right: 34vw; + z-index: 110; +} +#closePopupEdit:hover, #closePopupMosaic:hover { color: rgba(255,255,255,.75); } + .popupRightItem { width: 25vw; display: inline-block; @@ -766,6 +827,7 @@ html, body { #left_menu_item_icn_highlight { background:url("images/icn-menu-highlight.png"); } #left_menu_item_icn_search { background:url("images/icn-menu-search.png"); } #left_menu_item_icn_keywords { background:url("images/icn-menu-keywords.png"); } +#left_menu_item_icn_mosaic { background:url("images/icn-menu-mosaic.png"); } #left_menu_item_icn_preview { background:url("images/icn-menu-preview.png"); } #left_menu_item_icn_settings { background:url("images/icn-menu-settings.png"); } diff --git a/capsule-prototype/index.html b/capsule-prototype/index.html index d1fd20f7e1fe630c7a3512afe37b28db07dc8e7b..6a4892c846c6c0a2e4254cee1b7ebbe0d49d48bd 100644 --- a/capsule-prototype/index.html +++ b/capsule-prototype/index.html @@ -112,6 +112,13 @@ </div> </div> </div> + <div id="popupMosaicSpace"> + <div id="popupMosaic"> + <div id="popupMosaicMessage">Notes and documents</div> + <div id="closePopupMosaic">✕</div> + <div id="popupMosaicMosaic"></div> + </div> + </div> <div id="popupSettingsSpace"> <table id="popupSettings"> <tr> @@ -132,8 +139,7 @@ <div class="popupSettingsBtn" id="popupSettingsBtnShare">Share</div> <div class="popupSettingsBtn" id="popupSettingsBtnEmbed">Embed</div> <div class="popupSettingsBtn editmode" id="popupSettingsBtnDownloadXml">Download XML</div> - <div class="popupSettingsBtn editmode" id="popupSettingsBtnDelete">Delete project</div> - <a class="popupSettingsA" href="http://www.memorekall.com" target="_blank">www.memorekall.com</a> + <a class="popupSettingsA" href="http://www.memorekall.com" target="_blank">www.memorekall.com</a> <!-- <input id="popupSettingsShare" type="text" value="http://projects.rekall.com/monprojet" placeHolder=""/> <textarea id="popupSettingsEmbed" type="text"></textarea> @@ -231,6 +237,11 @@ <div class="left_menu_item_title">Add File</div> <div class="left_menu_item_value"></div> </div> + <div class="left_menu_item dropable" id="left_menu_item_open_mosaic" title="Mosaic"> + <div class="left_menu_item_icn" id="left_menu_item_icn_mosaic"></div> + <div class="left_menu_item_title">Open Mosaic</div> + <div class="left_menu_item_value"></div> + </div> </tr></td> </table> <video id="video" class="video-js vjs-default-skin vjs-big-play-centered"> diff --git a/capsule-prototype/js/online-script.js b/capsule-prototype/js/online-script.js index 34f3d2bdad3de974802694b02184d90b8328f83f..dd0c8a263aa2f9d54a841fcdca65c364d08615b7 100644 --- a/capsule-prototype/js/online-script.js +++ b/capsule-prototype/js/online-script.js @@ -356,6 +356,17 @@ function setEditionControls() { addLink(myLink); } }); + + $("#left_menu_item_open_mosaic").click(function(event){ + event.stopPropagation(); + rekall.timeline.pause(); + openMosaic(); + }); + + $("#closePopupMosaic").click(function(event){ + event.stopPropagation(); + closeMosaic(); + }); $("#popupEdit").click(function(event){ @@ -802,6 +813,58 @@ function closeEdit() { $("#popupSpace").hide(); $("#popupEdit").hide(); } + +function openMosaic() { + function getMosaicItem(tagOrDoc) { + let path = Utils.getPreviewPath(tagOrDoc); + let name = tagOrDoc.getMetadata("Rekall->Name"); + let url =''; + if ('undefined' === typeof path) { + let icon = ('rekall/link' === tagOrDoc.getMetadata("Rekall->Type")) ? "link" : "note"; + url = "../shared/css/images/img-"+icon+".png"; + } else { + url = path; + } + let div=$('<div/>').addClass('mosaic_item').on('click', function() {tagOrDoc.openPopupEdit();}); + div.append($('<img/>').attr('src', url)); + div.append($('<span/>').addClass('caption').text(name)); + return div; + } + + $("#popupMosaicSpace").show(); + let container = $('#popupMosaicMosaic'); + container.html(''); + // TODO is there a better way to iterate over tags or documents ? + for ( let [k, v] of Object.entries(rekall.sortings.colors.categories)) { + let category = $('<div/>').addClass('mosaic_category').css('background', getTagGradientColor(v)); + for (let i in v.tags){ + category.append(getMosaicItem(v.tags[i])); + } + container.append(category); + } +} + +function getTagGradientColor(tag) { + var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0; // Opera 8.0+ (UA detection to detect Blink/v8-powered Opera) + var isFirefox = typeof InstallTrigger !== 'undefined'; // Firefox 1.0+ + var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0; // At least Safari 3+: "[object HTMLElementConstructor]" + var isChrome = !!window.chrome && !isOpera; // Chrome 1+ + var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6 + + if(isOpera) { + return "-o-linear-gradient(right bottom, rgba(20,46,51,1) 0%, "+tag.color+" 100%)"; + } + if(isFirefox) { + return "-moz-linear-gradient(right bottom, rgba(20,46,51,1) 0%, "+tag.color+" 100%)"; + } + if((isSafari)||(isChrome)){ + return "-webkit-linear-gradient(right bottom, rgba(20,46,51,1) 0%, "+tag.color+" 100%)"; + } +} + +function closeMosaic() { + $("#popupMosaicSpace").hide(); +} function fillPopupEdit(tag) { @@ -815,17 +878,9 @@ function fillPopupEdit(tag) { $("#popupTC").css("background",tag.color); /*$("#popupType").css("color",tag.color);*/ - var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0; // Opera 8.0+ (UA detection to detect Blink/v8-powered Opera) - var isFirefox = typeof InstallTrigger !== 'undefined'; // Firefox 1.0+ - var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0; // At least Safari 3+: "[object HTMLElementConstructor]" - var isChrome = !!window.chrome && !isOpera; // Chrome 1+ - var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6 - var bgColorLeft = tag.color.replace(/rgb/g, "rgba").replace(/\)/g, ",.35)"); - if(isOpera) bgColorLeft = "-o-linear-gradient(right bottom, rgba(20,46,51,1) 0%, "+tag.color+" 100%)"; - else if(isFirefox) bgColorLeft = "-moz-linear-gradient(right bottom, rgba(20,46,51,1) 0%, "+tag.color+" 100%)"; - else if((isSafari)||(isChrome)) bgColorLeft = "-webkit-linear-gradient(right bottom, rgba(20,46,51,1) 0%, "+tag.color+" 100%)"; + bgColorLeft = getTagGradientColor(tag); $("#popupLeft").css("background",bgColorLeft); @@ -1190,4 +1245,4 @@ $(window).resize(function(e) { } }); $(window).trigger("resize"); - \ No newline at end of file + diff --git a/legacy/create.zip b/legacy/create.zip index a2a703ea770860eb81d342239f65d7a857384d5a..4b2f2211e0693a3b02976ec59b92cf7ce0977b19 100644 Binary files a/legacy/create.zip and b/legacy/create.zip differ diff --git a/migrations/Version20220125084520.php b/migrations/Version20220208141756.php similarity index 93% rename from migrations/Version20220125084520.php rename to migrations/Version20220208141756.php index 6adb95ef2255e6f1db38b11d4f1b5a18be3c9a37..253a647f6f5052d322b0581f39ee9f99f63f89b0 100644 --- a/migrations/Version20220125084520.php +++ b/migrations/Version20220208141756.php @@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration; /** * Auto-generated Migration: Please modify to your needs! */ -final class Version20220125084520 extends AbstractMigration +final class Version20220208141756 extends AbstractMigration { public function getDescription(): string { diff --git a/migrations/Version20220208145209.php b/migrations/Version20220208145209.php new file mode 100644 index 0000000000000000000000000000000000000000..e99fc5d43b23e6ac877eafa57e40568f1fb654c2 --- /dev/null +++ b/migrations/Version20220208145209.php @@ -0,0 +1,36 @@ +<?php + +declare(strict_types=1); + +namespace DoctrineMigrations; + +use Doctrine\DBAL\Schema\Schema; +use Doctrine\Migrations\AbstractMigration; + +/** + * Auto-generated Migration: Please modify to your needs! + */ +final class Version20220208145209 extends AbstractMigration +{ + public function getDescription(): string + { + return ''; + } + + public function up(Schema $schema): void + { + // this up() migration is auto-generated, please modify it to your needs + $this->addSql('CREATE TABLE `group` (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE group_capsule (group_id INT NOT NULL, capsule_id INT NOT NULL, INDEX IDX_4468F58FFE54D947 (group_id), INDEX IDX_4468F58F714704E9 (capsule_id), PRIMARY KEY(group_id, capsule_id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB'); + $this->addSql('ALTER TABLE group_capsule ADD CONSTRAINT FK_4468F58FFE54D947 FOREIGN KEY (group_id) REFERENCES `group` (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE group_capsule ADD CONSTRAINT FK_4468F58F714704E9 FOREIGN KEY (capsule_id) REFERENCES capsule (id) ON DELETE CASCADE'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE group_capsule DROP FOREIGN KEY FK_4468F58FFE54D947'); + $this->addSql('DROP TABLE `group`'); + $this->addSql('DROP TABLE group_capsule'); + } +} diff --git a/src/Builder/CapsuleBuilder.php b/src/Builder/CapsuleBuilder.php old mode 100644 new mode 100755 index b219d3bcab024d36e363d369c50fbf8a9c5f7d95..d3eda494ea0ac71018c4327da6449714a47ebfdd --- a/src/Builder/CapsuleBuilder.php +++ b/src/Builder/CapsuleBuilder.php @@ -3,6 +3,7 @@ namespace App\Builder; use App\Entity\Capsule; +use App\Entity\Group; use App\Entity\User; use App\Helper\ContractHelper; @@ -90,6 +91,12 @@ class CapsuleBuilder return $this; } + public function withGroup(Group $group): CapsuleBuilder + { + $this->capsule->addGroup($group); + return $this; + } + public function createCapsule(): Capsule { $this->createEditionLink(); diff --git a/src/Builder/UserBuilder.php b/src/Builder/UserBuilder.php old mode 100644 new mode 100755 diff --git a/src/Controller/.gitignore b/src/Controller/.gitignore old mode 100644 new mode 100755 diff --git a/src/Controller/CapsuleController.php b/src/Controller/CapsuleController.php old mode 100644 new mode 100755 index dbf0c440a63e0778bbef6ccd949dd8609eb4f226..15fa5a497ef95b2de0768f4ae360dc0c5051197c --- a/src/Controller/CapsuleController.php +++ b/src/Controller/CapsuleController.php @@ -3,13 +3,18 @@ namespace App\Controller; use App\Entity\Capsule; +use App\Entity\Group; use App\Entity\User; use App\Form\DeleteCapsuleFormType; use App\Form\DuplicateCapsuleFormType; +use App\Form\FilterByGroupFormType; use App\Helper\StringHelper; use App\Repository\CapsuleRepository; use App\Builder\CapsuleBuilder; use App\Form\CreateCapsuleFormType; +use App\Repository\GroupRepository; +use ArrayObject; +use Doctrine\ORM\EntityManagerInterface; use Knp\Component\Pager\PaginatorInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Filesystem\Filesystem; @@ -24,13 +29,16 @@ class CapsuleController extends AbstractController { private CapsuleRepository $capsule_repository; private TranslatorInterface $translator; + private EntityManagerInterface $entity_manager; public function __construct( CapsuleRepository $capsule_repository, - TranslatorInterface $translator + TranslatorInterface $translator, + EntityManagerInterface $entity_manager ) { $this->capsule_repository = $capsule_repository; $this->translator = $translator; + $this->entity_manager = $entity_manager; } /** @@ -47,7 +55,22 @@ class CapsuleController extends AbstractController return $this->redirectToRoute('app_logout'); } - $all_capsules = $current_user->getCapsules(); + // get all capsules without any filter + $all_capsules = $current_user->getCapsules()->toArray(); + $form = $this->createGroupFilterForm($current_user); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $group = $form->getData()['name']; + + if (! $group instanceof Group) { + throw new \Exception('Group not found'); + } + + if ($group->getId() !== Group::$ALL_GROUP_ID) { + $all_capsules = $group->getCapsulesIntersection($all_capsules); + } + } $capsules = $paginator->paginate( $all_capsules, @@ -56,6 +79,7 @@ class CapsuleController extends AbstractController ); return $this->render('capsule/index.html.twig', [ + 'filterByGroupForm' => $form->createView(), 'capsules' => $capsules, 'current_user' => $current_user, 'legacy_url' => $this->getParameter('app.legacy_external_prefix') @@ -159,8 +183,7 @@ class CapsuleController extends AbstractController return $this->redirectToRoute('app_logout'); } - $entityManager = $this->getDoctrine()->getManager(); - $capsule = $entityManager->getRepository(Capsule::class)->find($id); + $capsule = $this->capsule_repository->findOneBy(['id' => $id]); if (! $capsule) { throw $this->createNotFoundException( @@ -186,8 +209,8 @@ class CapsuleController extends AbstractController if ($form->isSubmitted() && $form->isValid()) { $current_user->removeCapsule($capsule); $capsule->removeEditor($current_user); - $entityManager->remove($capsule); - $entityManager->flush(); + $this->entity_manager->remove($capsule); + $this->entity_manager->flush(); $this->addFlash( 'success', @@ -224,8 +247,7 @@ class CapsuleController extends AbstractController return $this->redirectToRoute('app_logout'); } - $entityManager = $this->getDoctrine()->getManager(); - $parent_capsule = $entityManager->getRepository(Capsule::class)->find($id); + $parent_capsule = $this->capsule_repository->findOneBy(['id' => $id]); if (! $parent_capsule instanceof Capsule) { throw new \Exception('The retrieved capsule is not an instance of Capsule.'); @@ -285,7 +307,6 @@ class CapsuleController extends AbstractController $password = StringHelper::generateRandomHashedString(); $preview_link = Uuid::v4(); - $entityManager = $this->getDoctrine()->getManager(); $capsule_builder = new CapsuleBuilder(); $capsule = $capsule_builder ->withName($capsule_name) @@ -296,9 +317,30 @@ class CapsuleController extends AbstractController ->withPassword($password) ->createCapsule(); - $entityManager->persist($capsule); - $entityManager->flush(); + $this->entity_manager->persist($capsule); + $this->entity_manager->flush(); return $capsule; } + + private function getDefaultGroup(): Group + { + $noGroup = new Group(); + + // TODO : to be translated + $noGroup->setName($this->translator->trans('groups.filter.no_filter')); + $noGroup->setId(Group::$ALL_GROUP_ID); + + return $noGroup; + } + + private function createGroupFilterForm(User $current_user): FormInterface + { + $groups = new ArrayObject($current_user->getGroups()); + $groups = $groups->getArrayCopy(); + array_unshift($groups, self::getDefaultGroup()); + + + return $this->createForm(FilterByGroupFormType::class, ['groups' => $groups]); + } } diff --git a/src/Controller/CapsuleEditorController.php b/src/Controller/CapsuleEditorController.php old mode 100644 new mode 100755 diff --git a/src/Controller/CapsuleGroupController.php b/src/Controller/CapsuleGroupController.php new file mode 100755 index 0000000000000000000000000000000000000000..6374a92b387d9c23b0eaa63a94429ea36627a617 --- /dev/null +++ b/src/Controller/CapsuleGroupController.php @@ -0,0 +1,250 @@ +<?php + +namespace App\Controller; + +use App\Entity\Capsule; +use App\Entity\Group; +use App\Entity\User; +use App\Form\CreateCapsuleGroupsFormType; +use App\Form\RemoveGroupFormType; +use App\Form\SelectCapsuleGroupsFormType; +use App\Repository\CapsuleRepository; +use App\Repository\GroupRepository; +use Doctrine\Common\Collections\Collection; +use Doctrine\ORM\EntityManagerInterface; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\Form\FormInterface; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Contracts\Translation\TranslatorInterface; +use Symfony\Component\Routing\Annotation\Route; + +class CapsuleGroupController extends AbstractController +{ + private TranslatorInterface $translator; + private CapsuleRepository $capsule_repository; + private EntityManagerInterface $entity_manager; + private GroupRepository $group_repository; + + public function __construct( + TranslatorInterface $translator, + CapsuleRepository $capsule_repository, + EntityManagerInterface $entity_manager, + GroupRepository $group_repository + ) { + $this->translator = $translator; + $this->capsule_repository = $capsule_repository; + $this->entity_manager = $entity_manager; + $this->group_repository = $group_repository; + } + + /** + * @Route("/capsule/{capsule_id}/groups/edit", name="edit_capsule_groups") + */ + public function edit(int $capsule_id, Request $request): Response + { + $current_user = $this->getUser(); + + if (! $current_user instanceof User) { + return $this->redirectToRoute('app_logout'); + } + + $capsule = $this->capsule_repository->findOneBy(['id' => $capsule_id]); + + if (! $capsule instanceof Capsule) { + throw new \Exception("Capsule does not exist"); + } + + $groups = $capsule->getGroups(); + $editor_groups_not_added = $this->getEditorGroupsNotAdded($current_user, $groups); + + $form = $this->createForm(SelectCapsuleGroupsFormType::class, ['groups' => $editor_groups_not_added]); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $groups = $this->addGroups($form, $capsule); + + $groups_names = []; + + foreach ($groups as $group) { + $groups_names[] = $group->getName(); + } + + $this->addFlash( + 'success', + $this->translator->trans( + 'groups.add.success', + [ + 'groups_names' => implode(",", $groups_names), + 'capsule_name' => $capsule->getName() + ] + ) + ); + + return $this->redirectToRoute('edit_capsule_groups', [ + 'capsule_id' => $capsule_id + ]); + } + + return $this->render('capsule/groups/edit.html.twig', [ + 'selectCapsuleGroupsForm' => $form->createView(), + 'capsule' => $capsule, + 'groups' => $groups, + 'existing_groups' => $editor_groups_not_added + ]); + } + + /** + * @Route("capsule/{capsule_id}/groups/create", name="create_group") + */ + public function create(int $capsule_id, Request $request): Response + { + $current_user = $this->getUser(); + + if (! $current_user instanceof User) { + return $this->redirectToRoute('app_logout'); + } + + $capsule = $this->capsule_repository->findOneBy(['id' => $capsule_id]); + + if (! $capsule instanceof Capsule) { + throw new \Exception("Capsule does not exist"); + } + + $form = $this->createForm(CreateCapsuleGroupsFormType::class); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $group = $this->createAGroup($form, $capsule); + + $this->addFlash( + 'success', + $this->translator->trans( + 'groups.create.success', + [ + 'group_name' => $group->getName() + ] + ) + ); + + return $this->redirectToRoute('edit_capsule_groups', [ + 'capsule_id' => $capsule_id + ]); + } + + return $this->render('capsule/groups/create.html.twig', [ + 'createCapsuleGroupsForm' => $form->createView(), + 'capsule' => $capsule + ]); + } + + /** + * @Route("/capsule/{capsule_id}/groups/{group_id}/remove", name="remove_group") + */ + public function remove( + int $capsule_id, + int $group_id, + Request $request + ): Response { + $capsule = $this->capsule_repository->findOneBy(['id' => $capsule_id]); + if (! $capsule instanceof Capsule) { + throw new \Exception('Capsule not found'); + } + + $group = $this->group_repository->findOneBy(['id' => $group_id]); + if (! $group instanceof Group) { + throw new \Exception('Group not found'); + } + + $current_user = $this->getUser(); + if (! $current_user instanceof User) { + return $this->redirectToRoute('app_logout'); + } + + $form = $this->createForm(RemoveGroupFormType::class); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $capsule->removeGroup($group); + $this->entity_manager->persist($capsule); + $this->entity_manager->flush(); + + $this->addFlash( + 'success', + $this->translator->trans( + 'groups.remove.success', + [ + 'group_name' => $group->getName(), + 'capsule_name' => $capsule->getName() + ] + ) + ); + + return $this->redirectToRoute('edit_capsule_groups', [ + 'capsule_id' => $capsule->getId() + ]); + } + + return $this->render('capsule/groups/remove.html.twig', [ + 'removeGroupForm' => $form->createView(), + 'group_name' => $group->getName(), + 'capsule_id' => $capsule_id + ]); + } + + /** + * @return array<Group> + */ + private function addGroups(FormInterface $form, Capsule $capsule): array + { + $groups_data = $form->getData()['name']; + $groups = []; + + foreach ($groups_data as $group_data) { + $group_db = $this->group_repository->findOneBy(['id' => $group_data->getId()]); + + if (! $group_db instanceof Group) { + throw new \Exception('Group not found'); + } + + $groups[] = $group_db; + $capsule->addGroup($group_db); + $this->entity_manager->persist($capsule); + } + + $this->entity_manager->flush(); + + return $groups; + } + + private function createAGroup(FormInterface $form, Capsule $capsule): Group + { + $group_name = $form->get('name')->getData(); + + $group = new Group(); + $group->setName($group_name); + $this->entity_manager->persist($group); + + $capsule->addGroup($group); + $this->entity_manager->persist($capsule); + + $this->entity_manager->flush(); + + return $group; + } + + /** + * @param Collection<Group> $groups + * @return array<Group> + */ + private function getEditorGroupsNotAdded(User $current_user, Collection $groups): array + { + return array_udiff( + $current_user->getGroups(), + $groups->toArray(), + function ($obj_a, $obj_b) { + return $obj_a->getId() - $obj_b->getId(); + } + ); + } +} diff --git a/src/Controller/FallbackController.php b/src/Controller/FallbackController.php old mode 100644 new mode 100755 diff --git a/src/Controller/ProjectController.php b/src/Controller/ProjectController.php old mode 100644 new mode 100755 diff --git a/src/Controller/RegistrationController.php b/src/Controller/RegistrationController.php old mode 100644 new mode 100755 diff --git a/src/Controller/ResetPasswordController.php b/src/Controller/ResetPasswordController.php old mode 100644 new mode 100755 diff --git a/src/Controller/SecurityController.php b/src/Controller/SecurityController.php old mode 100644 new mode 100755 diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php old mode 100644 new mode 100755 diff --git a/src/Curl/CurlHandle.php b/src/Curl/CurlHandle.php old mode 100644 new mode 100755 diff --git a/src/DataFixtures/CapsuleFixtures.php b/src/DataFixtures/CapsuleFixtures.php old mode 100644 new mode 100755 index c95b19e2c784c20fc50b2a0ee689f7d4dba9dc05..3383bf14cd736af0f233736f1c979b2278de283d --- a/src/DataFixtures/CapsuleFixtures.php +++ b/src/DataFixtures/CapsuleFixtures.php @@ -12,7 +12,6 @@ use Symfony\Component\Uid\Uuid; class CapsuleFixtures extends Fixture implements DependentFixtureInterface { - public function load(ObjectManager $manager): void { $user_repository = $manager->getRepository(User::class); diff --git a/src/DataFixtures/GroupFixtures.php b/src/DataFixtures/GroupFixtures.php new file mode 100644 index 0000000000000000000000000000000000000000..82cb6670ce1bb648173cccdbe8d83f4ebed27235 --- /dev/null +++ b/src/DataFixtures/GroupFixtures.php @@ -0,0 +1,26 @@ +<?php + +namespace App\DataFixtures; + +use App\Entity\Group; +use Doctrine\Bundle\FixturesBundle\Fixture; +use Doctrine\Persistence\ObjectManager; + +class GroupFixtures extends Fixture +{ + public function load(ObjectManager $manager): void + { + $group_all = new Group(); + $group_all->setName("All"); + $manager->persist($group_all); + $manager->flush(); + } + + /** @phpstan-ignore-next-line */ + public function getDependencies(): array + { + return [ + CapsuleFixtures::class, + ]; + } +} diff --git a/src/DataFixtures/UserFixtures.php b/src/DataFixtures/UserFixtures.php old mode 100644 new mode 100755 diff --git a/src/Entity/.gitignore b/src/Entity/.gitignore old mode 100644 new mode 100755 diff --git a/src/Entity/Capsule.php b/src/Entity/Capsule.php old mode 100644 new mode 100755 index 08ff123ce5e6625d0200dfc0cfdd0a2760e4d94f..f3e6f715c893e385361331ebfdc6b072d19fb9ac --- a/src/Entity/Capsule.php +++ b/src/Entity/Capsule.php @@ -90,9 +90,16 @@ class Capsule */ private Collection $editors; + /** + * @var Collection<Group> + * @ORM\ManyToMany(targetEntity=Group::class, mappedBy="capsules") + */ + private Collection $groups; + public function __construct() { $this->editors = new ArrayCollection(); + $this->groups = new ArrayCollection(); } public function getId(): int @@ -205,14 +212,13 @@ class Capsule } /** - * @return Collection<User> $editors + * @return Collection<User> */ public function getEditors(): Collection { return $this->editors; } - public function getVideoPreviewImageLink(): ?string { $file_system = new Filesystem(); @@ -231,4 +237,31 @@ class Capsule return 'https://vumbnail.com/' . $video_id . '.jpg'; } + + /** + * @return Collection|Group[] + */ + public function getGroups(): Collection + { + return $this->groups; + } + + public function addGroup(Group $group): self + { + if (!$this->groups->contains($group)) { + $this->groups[] = $group; + $group->addCapsule($this); + } + + return $this; + } + + public function removeGroup(Group $group): self + { + if ($this->groups->removeElement($group)) { + $group->removeCapsule($this); + } + + return $this; + } } diff --git a/src/Entity/Group.php b/src/Entity/Group.php new file mode 100755 index 0000000000000000000000000000000000000000..af8ad780d8377e498ee1a03db3115e2636657e6e --- /dev/null +++ b/src/Entity/Group.php @@ -0,0 +1,115 @@ +<?php + +namespace App\Entity; + +use App\Repository\GroupRepository; +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\Common\Collections\Collection; +use Doctrine\ORM\Mapping as ORM; +use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; + +/** + * @ORM\Entity(repositoryClass=GroupRepository::class) + * @ORM\Table(name="`group`") + * @UniqueEntity(fields={"name"}, message="group.name.unique") + */ +class Group +{ + public static int $ALL_GROUP_ID = -1; + /** + * @ORM\Id + * @ORM\GeneratedValue + * @ORM\Column(type="integer") + */ + private int $id; + + /** + * @ORM\Column(type="string", length=255) + */ + private string $name; + + /** + * @var Collection<Capsule> + * @ORM\ManyToMany(targetEntity=Capsule::class, inversedBy="groups") + */ + private Collection $capsules; + + public function __construct() + { + $this->capsules = new ArrayCollection(); + } + + public function getId(): int + { + return $this->id; + } + + public function setId(int $id): void + { + $this->id = $id; + } + + public function getName(): string + { + return $this->name; + } + + public function setName(string $name): self + { + $this->name = $name; + + return $this; + } + + /** + * @return Collection|Capsule[] + */ + public function getCapsules(): Collection + { + return $this->capsules; + } + + public function addCapsule(Capsule $capsule): self + { + if (!$this->capsules->contains($capsule)) { + $this->capsules[] = $capsule; + $capsule->addGroup($this); + } + + return $this; + } + + /** + * @param array<Capsule> $capsules + */ + public function addCapsules(array $capsules): self + { + foreach ($capsules as $capsule) { + $this->addCapsule($capsule); + } + + return $this; + } + + public function removeCapsule(Capsule $capsule): self + { + $this->capsules->removeElement($capsule); + + return $this; + } + + /** + * @param array<Capsule> $capsules + * @return array<Capsule> + */ + public function getCapsulesIntersection(array $capsules): array + { + return array_uintersect( + $capsules, + $this->getCapsules()->toArray(), + function ($obj_a, $obj_b) { + return $obj_a->getId() - $obj_b->getId(); + } + ); + } +} diff --git a/src/Entity/PendingEditorInvitation.php b/src/Entity/PendingEditorInvitation.php old mode 100644 new mode 100755 diff --git a/src/Entity/ResetPasswordRequest.php b/src/Entity/ResetPasswordRequest.php old mode 100644 new mode 100755 diff --git a/src/Entity/User.php b/src/Entity/User.php old mode 100644 new mode 100755 index fcde46a8ed06432d816aa83069a1036af58d30b0..21bcad23af3a2c2aeb5e0e49c129a8bb663deeca --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -299,4 +299,21 @@ class User implements UserInterface, LegacyPasswordAuthenticatedUserInterface { $this->is_subscribed_news_letter = $is_subscribed_news_letter; } + + /** + * @return array<Group> + */ + public function getGroups(): array + { + $editor_capsules = $this->getCapsules(); + $existing_groups_for_current_editor = []; + foreach ($editor_capsules as $editor_capsule) { + $existing_groups_for_current_editor = array_merge( + $existing_groups_for_current_editor, + $editor_capsule->getGroups()->toArray() + ); + } + + return $existing_groups_for_current_editor; + } } diff --git a/src/Exception/CapsuleNotFoundException.php b/src/Exception/CapsuleNotFoundException.php old mode 100644 new mode 100755 index 5f33efe481c08690ba06ef5f9b797e6135a23335..60db948770eda7d83ef7a47abe9c17b98fba2659 --- a/src/Exception/CapsuleNotFoundException.php +++ b/src/Exception/CapsuleNotFoundException.php @@ -4,5 +4,4 @@ namespace App\Exception; class CapsuleNotFoundException extends \Exception { - } diff --git a/src/Exception/CurlInitFailedException.php b/src/Exception/CurlInitFailedException.php old mode 100644 new mode 100755 diff --git a/src/Exception/ZipArchiveNotOpeningException.php b/src/Exception/ZipArchiveNotOpeningException.php old mode 100644 new mode 100755 diff --git a/src/Form/CapsuleEditorsFormType.php b/src/Form/CapsuleEditorsFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/ChangePasswordFormType.php b/src/Form/ChangePasswordFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/CreateCapsuleFormType.php b/src/Form/CreateCapsuleFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/CreateCapsuleGroupsFormType.php b/src/Form/CreateCapsuleGroupsFormType.php new file mode 100755 index 0000000000000000000000000000000000000000..452885873246bc9cdeab9327a298b26e6b6ebb62 --- /dev/null +++ b/src/Form/CreateCapsuleGroupsFormType.php @@ -0,0 +1,47 @@ +<?php + +namespace App\Form; + +use App\Entity\Group; +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\ButtonType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; +use Symfony\Component\Form\Extension\Core\Type\TextType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\Validator\Constraints\NotBlank; + +class CreateCapsuleGroupsFormType extends AbstractType +{ + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $builder + ->add( + 'name', + TextType::class, + [ + 'constraints' => [new NotBlank(['message' => 'group.name.not_blank'])], + 'label' => 'groups.create.name' + ] + ) + ->add( + 'validate', + SubmitType::class, + ['label' => 'groups.create.validate'] + ) + ->add( + 'go_back', + ButtonType::class, + ['label' => 'groups.create.go_back', + 'attr' => ['class' => 'button-cancel'] + ] + ); + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Group::class, + ]); + } +} diff --git a/src/Form/DeleteCapsuleFormType.php b/src/Form/DeleteCapsuleFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/DuplicateCapsuleFormType.php b/src/Form/DuplicateCapsuleFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/EditPasswordFormType.php b/src/Form/EditPasswordFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/EditUserProfileFormType.php b/src/Form/EditUserProfileFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/EditVideoUrlFormType.php b/src/Form/EditVideoUrlFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/FilterByGroupFormType.php b/src/Form/FilterByGroupFormType.php new file mode 100644 index 0000000000000000000000000000000000000000..7e17f84042e952c6ca6b2c021fb9d3bf2ec0fb1e --- /dev/null +++ b/src/Form/FilterByGroupFormType.php @@ -0,0 +1,42 @@ +<?php + +namespace App\Form; + +use App\Entity\Group; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + +class FilterByGroupFormType extends AbstractType +{ + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $groups = $options['data']['groups']; + + $builder + ->add('name', ChoiceType::class, [ + 'choices' => $groups, + 'choice_translation_domain' => false, + 'label' => false, + 'choice_label' => function (?Group $entity) { + return $entity ? $entity->getName() : ''; + }, + 'choice_value' => 'name', + 'choice_name' => 'name', + 'expanded' => false + ]) + ->add( + 'filter', + SubmitType::class, + ['label' => 'groups.filter.button'] + ); + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([]); + } +} diff --git a/src/Form/RegistrationFormType.php b/src/Form/RegistrationFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/RemoveEditorFormType.php b/src/Form/RemoveEditorFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/RemoveGroupFormType.php b/src/Form/RemoveGroupFormType.php new file mode 100755 index 0000000000000000000000000000000000000000..436405a7f769127a5f751001054b6c3b929c5e7b --- /dev/null +++ b/src/Form/RemoveGroupFormType.php @@ -0,0 +1,37 @@ +<?php + +namespace App\Form; + +use App\Entity\Group; +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\ButtonType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + +class RemoveGroupFormType extends AbstractType +{ + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $builder + ->add( + 'cancel', + ButtonType::class, + ['label' => 'general.cancel_button', + 'attr' => ['class' => 'button-cancel'] + ] + ) + ->add( + 'remove', + SubmitType::class, + ['label' => 'groups.remove.button'] + ); + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Group::class, + ]); + } +} diff --git a/src/Form/ResetPasswordRequestFormType.php b/src/Form/ResetPasswordRequestFormType.php old mode 100644 new mode 100755 diff --git a/src/Form/SelectCapsuleGroupsFormType.php b/src/Form/SelectCapsuleGroupsFormType.php new file mode 100755 index 0000000000000000000000000000000000000000..91ef852542c1fb7b68ba71aafdb36d1da90d9d85 --- /dev/null +++ b/src/Form/SelectCapsuleGroupsFormType.php @@ -0,0 +1,34 @@ +<?php + +namespace App\Form; + +use App\Entity\Group; +use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; +use Symfony\Component\Form\FormBuilderInterface; + +class SelectCapsuleGroupsFormType extends AbstractType +{ + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $groups = $options['data']['groups']; + + $builder + ->add('name', EntityType::class, [ + 'class' => Group::class, + 'choice_label' => 'name', + 'choices' => $groups, + 'multiple' => true, + 'label' => 'groups.choose', + 'choice_value' => function (?Group $entity) { + return $entity ? $entity->getId() : ''; + } + ]) + ->add( + 'validate', + SubmitType::class, + ['label' => 'groups.add.validate'] + ); + } +} diff --git a/src/Helper/ContractHelper.php b/src/Helper/ContractHelper.php old mode 100644 new mode 100755 diff --git a/src/Helper/LegacyHelper.php b/src/Helper/LegacyHelper.php old mode 100644 new mode 100755 diff --git a/src/Helper/StringHelper.php b/src/Helper/StringHelper.php old mode 100644 new mode 100755 diff --git a/src/Kernel.php b/src/Kernel.php old mode 100644 new mode 100755 diff --git a/src/Repository/.gitignore b/src/Repository/.gitignore old mode 100644 new mode 100755 diff --git a/src/Repository/CapsuleRepository.php b/src/Repository/CapsuleRepository.php old mode 100644 new mode 100755 diff --git a/src/Repository/GroupRepository.php b/src/Repository/GroupRepository.php new file mode 100755 index 0000000000000000000000000000000000000000..8f1d8f459c3677cf8b962a7b62b3a1f4bfbc446c --- /dev/null +++ b/src/Repository/GroupRepository.php @@ -0,0 +1,21 @@ +<?php + +namespace App\Repository; + +use App\Entity\Group; +use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; +use Doctrine\Persistence\ManagerRegistry; + +/** + * @method Group|null find($id, $lockMode = null, $lockVersion = null) + * @method Group|null findOneBy(array $criteria, array $orderBy = null) + * @method Group[] findAll() + * @method Group[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + */ +class GroupRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Group::class); + } +} diff --git a/src/Repository/PendingEditorInvitationRepository.php b/src/Repository/PendingEditorInvitationRepository.php old mode 100644 new mode 100755 diff --git a/src/Repository/ResetPasswordRequestRepository.php b/src/Repository/ResetPasswordRequestRepository.php old mode 100644 new mode 100755 diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php old mode 100644 new mode 100755 diff --git a/src/Retriever/ProjectRetriever.php b/src/Retriever/ProjectRetriever.php old mode 100644 new mode 100755 diff --git a/src/Security/AppCustomAuthenticator.php b/src/Security/AppCustomAuthenticator.php old mode 100644 new mode 100755 diff --git a/src/Security/EmailVerifier.php b/src/Security/EmailVerifier.php old mode 100644 new mode 100755 diff --git a/src/Security/UserChecker.php b/src/Security/UserChecker.php old mode 100644 new mode 100755 diff --git a/templates/capsule/groups/create.html.twig b/templates/capsule/groups/create.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..c590d3a25987673defbb2b59eae384c421d504d9 --- /dev/null +++ b/templates/capsule/groups/create.html.twig @@ -0,0 +1,36 @@ +{% extends 'layout.html.twig' %} + +{% block title %} + {{ 'groups.create.title'|trans }} + - + {{ parent() }} +{% endblock %} + +{% block body %} + + <div> + <div class="row w-100 gx-0"> + <div class="row-title-box"> + <h3 class="row-title"> + {{ 'groups.create.title'|trans }} + </h3> + </div> + </div> + + <div class="d-flex flex-column justify-content-center align-items-center"> + {{ form_start(createCapsuleGroupsForm, {'attr': {novalidate: 'novalidate'}}) }} + {{ form_row(createCapsuleGroupsForm.name, {'row_attr': {'class' : 'm-auto mb-4 me-3'}}) }} + + <div class="d-flex flex-column flex-sm-row justify-content-center align-items-center align-items-sm-start"> + {{ form_row(createCapsuleGroupsForm.validate, {'row_attr': {'class' : 'me-sm-3 mb-3'}}) }} + <a href="/capsule/{{ capsule.getId() }}/groups/edit"> + {{ form_row(createCapsuleGroupsForm.go_back) }} + </a> + </div> + + {{ form_end(createCapsuleGroupsForm) }} + </div> + + </div> + +{% endblock %} \ No newline at end of file diff --git a/templates/capsule/groups/edit.html.twig b/templates/capsule/groups/edit.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..6248ac5e488e16f7b67378628dea051165909003 --- /dev/null +++ b/templates/capsule/groups/edit.html.twig @@ -0,0 +1,75 @@ +{% extends 'layout.html.twig' %} + +{% block title %} + {{ 'groups.edit.title'|trans }} + - + {{ parent() }} +{% endblock %} + +{% block body %} + + <div> + <div class="row w-100 gx-0"> + <div class="row-title-box"> + <h3 class="row-title"> + {{ 'groups.edit.title_with_capsule_name'|trans({'%capsule_name%': capsule.getName()}) }} + </h3> + </div> + </div> + + {% for flashWarning in app.flashes('warning') %} + <div class="text-center alert alert-warning col-5 mx-auto my-5 mt-2" role="alert"> + {{ flashWarning }} + </div> + {% endfor %} + + {% for flashSuccess in app.flashes('success') %} + <div class="text-center alert alert-success col-5 mx-auto my-5 mt-2" role="alert"> + {{ flashSuccess }} + </div> + {% endfor %} + + <div class="d-flex flex-md-row flex-column justify-content-center"> + + <div class="d-flex flex-row pe-md-5 pb-3 fw-normal me-0 me-md-5"> + <div class="pe-3 pe-md-4 text-nowrap"> + <h5> + {{ 'groups.list.title'|trans }} + </h5> + <ul class="ps-0"> + {% for group in groups %} + {% if group.getName() != 'All' %} + <li class="text-capitalize text-secondary list-unstyled p-1"> + {{ group.getName() }} + - + <a href="/capsule/{{ capsule.getId() }}/groups/{{ group.getId() }}/remove" class="remove-link"> + {{ 'groups.remove.link'|trans }} + </a> + </li> + {% endif %} + {% endfor %} + </ul> + </div> + </div> + + <div class="d-flex flex-column justify-content-center order-md-2 mb-4 col-sm-8 col-md-6 col-lg-5 col-xl-4"> + <h5 class="mb-5"> + <a href="/capsule/{{ capsule.getId() }}/groups/create" class="list-unstyled"> + {{ 'groups.create.title'|trans }} + </a> + </h5> + + {% if existing_groups is not empty %} + <div class="d-flex flex-column justify-content-center mb-4"> + {{ form_start(selectCapsuleGroupsForm, {'attr': {novalidate: 'novalidate'}}) }} + {{ form_row(selectCapsuleGroupsForm.name, {'row_attr': {'class' : 'm-auto mb-4'}}) }} + {{ form_row(selectCapsuleGroupsForm.validate) }} + {{ form_end(selectCapsuleGroupsForm) }} + </div> + {% endif %} + </div> + + </div> + </div> + +{% endblock %} \ No newline at end of file diff --git a/templates/capsule/groups/remove.html.twig b/templates/capsule/groups/remove.html.twig new file mode 100644 index 0000000000000000000000000000000000000000..9894b62642153b5b19f1e7aaec4e74452ca56f09 --- /dev/null +++ b/templates/capsule/groups/remove.html.twig @@ -0,0 +1,34 @@ +{% extends 'layout.html.twig' %} + +{% block title %} + {{ 'groups.remove.title'|trans }} +{% endblock %} + +{% block body %} + + <div> + <div class="row w-100 gx-0"> + <div class="row-title-box"> + <h3 class="row-title"> + {{ 'groups.remove.title'|trans }} + </h3> + </div> + </div> + + <div class="d-flex flex-column justify-content-center align-items-center"> + + <p class="text-secondary fs-5 mb-5"> + {{ 'groups.remove.text'|trans({'%group_name%': group_name}) }} + </p> + + {{ form_start(removeGroupForm, {'attr': {novalidate: 'novalidate', 'class': 'd-flex flex-row justify-content-center'}}) }} + {{ form_row(removeGroupForm.remove, {'row_attr': {'class' : 'm-auto mb-2 me-3'}}) }} + <a href="/capsule/{{ capsule_id }}/editors"> + {{ form_row(removeGroupForm.cancel, {'row_attr': {'class' : 'm-auto mb-2 bg-secondary rounded ms-3'}}) }} + </a> + {{ form_end(removeGroupForm) }} + </div> + + </div> + +{% endblock %} \ No newline at end of file diff --git a/templates/capsule/index.html.twig b/templates/capsule/index.html.twig index 24c3d22ac50d87f75ee65a19e0f80327b8b69087..b5413a1606ac2ddfe3760a07bc9cebd8b2ddb280 100644 --- a/templates/capsule/index.html.twig +++ b/templates/capsule/index.html.twig @@ -8,11 +8,21 @@ {% block body %} <div class="row gx-0"> - <div class="row-title-box d-flex justify-content-between align-items-center"> + <div class="row-title-box d-flex flex-column flex-lg-row justify-content-between align-items-center"> <h2 class="row-title"> {{ 'capsule.title'|trans }} </h2> - <form class="d-none d-md-flex"> + + {% if app.request.query.get('page')|default(1) == 1 %} + <div class="mb-3 mb-sm-0"> + {{ form_start(filterByGroupForm, {'attr': {novalidate: 'novalidate', 'class': 'd-flex flex-column flex-sm-row mb-0 align-items-center pt-3'}}) }} + {{ form_row(filterByGroupForm.name, {'attr': {'class': ''}}) }} + {{ form_row(filterByGroupForm.filter, {'attr': {'class': 'ms-2'}}) }} + {{ form_end(filterByGroupForm) }} + </div> + {% endif %} + + <form class="d-flex mb-4 mb-lg-0"> <button id="btn-orange" formaction="/create"> + {{ 'capsule.create_capsule'|trans }} </button> @@ -20,12 +30,6 @@ </div> </div> - <form class="d-md-none d-flex justify-content-center align-items-center"> - <button id="btn-orange" formaction="/create"> - + {{ 'capsule.create_capsule'|trans }} - </button> - </form> - {% for flashWarning in app.flashes('warning') %} <div class="text-center alert alert-warning col-5 mx-auto my-5" role="alert"> {{ flashWarning }} @@ -38,11 +42,9 @@ </div> {% endfor %} -</div> - <div class="d-flex flex-column align-items-center mt-4 mb-4"> {% for capsule in capsules %} - <div class="capsule-item pb-4 col-12 col-lg-10 col-xl-8"> + <div class="capsule-item pb-4 col-12 col-sm-11 col-md-10 col-xxl-8"> <div class="d-flex flex-column flex-md-row justify-content-center align-items-center mt-sm-4"> <div class="list-item"> <a href="/capsule/preview/{{ capsule.getLinkPath() }}" class="capsule-title"> @@ -54,7 +56,7 @@ </div> </div> - <div class="d-flex flex-column flex-md-row justify-content-center align-items-center"> + <div class="d-flex flex-column flex-xl-row justify-content-center align-items-center"> <div class="m-4 ratio ratio-16x9"> {% if capsule.getVideoPreviewImageLink() is null %} <img src="{{ asset('build/images/project_not_found.jpg') }}" alt="video preview"> @@ -80,6 +82,14 @@ </a> </div> + + <div class="list-item text-nowrap"> + <a href="{{ path('edit_capsule_groups', { 'capsule_id' : capsule.getId()}) }}" class="links text-decoration-none"> + <i class="fas fa-layer-group m-2"></i> + {{ 'groups.edit.title'|trans({'%capsule_name%': capsule.getName()}) }} + </a> + </div> + <div class="list-item text-nowrap"> <a href="/capsule/duplicate/{{ capsule.getId() }}" class="links text-decoration-none"> <i class="far fa-clone m-2"></i> diff --git a/translations/messages.en.yaml b/translations/messages.en.yaml index ad0f150076247179414da7228ca4caec93ae8a1b..0ca87ae5989f26eb7d394eef75ec64335afba1e0 100644 --- a/translations/messages.en.yaml +++ b/translations/messages.en.yaml @@ -113,4 +113,73 @@ user: change_password: Change password updated_success: The password has been updated edit_profile: Edit my profile - edit_password: Edit my password \ No newline at end of file + edit_password: Edit my password + +editors: + title: Editors + title_name: Editors of capsule %capsule_name% + add_email_address: Add new editor with email address + current_editors_title: Current editors + pending_editors_title: Pending editors + user_not_editor_error: You are not editor of the capsule + add: + pending_editor: + success: The user user_email has been added to pending editor list. + He will receive an email to invite him register on MemoRekall and to inform him he has been added as an editor of this capsule. + already_added: The user user_email has already been added to pending editor list + email: + title: Invitation to edit a MemoRekall capsule + text: You have been added by %user_name% as editor of the capsule "%capsule_name%". + In order to access and edit it, you first need to register on MemoRekall. Please follow this link to + link: https://project.memorekall.com/register/ + link_name: register + user: + success: The user user_email is now an editor of the capsule capsule_name. + He will receive an email to inform him he has been added as an editor of this capsule. + already_added: The user user_email is already an editor of this capsule + email: + title: New capsule on your list + text: You have been add by %user_name% as editor of the capsule "%capsule_name%". + You can now access and edit it. You will find the capsule in your capsule list. + link: Go to capsule edition page + remove: + button: Delete + pending_editor: + title: Remove pending editor + text: Do you really want to remove pending editor %editor_email% ? + link: Remove pending editor + error: Email address pending_editor_email has already been removed from the pending editors list of the capsule capsule_name + success: Email address pending_editor_email has been successfully removed from the pending editor list of the capsule capsule_name + editor: + title: Remove editor + text: Do you really want to remove editor %editor_email% ? + link: Remove editor + success: User editor_email cannot edit anymore the capsule capsule_name + error: You can't remove yourself as editor of your own capsule. + If you want to remove the capsule from your list, go to the capsule list page and click on "delete capsule" + +groups: + list: + title: Capsule groups + edit: + title: Edit capsule groups + title_with_capsule_name: Groups for capsule %capsule_name% + create: + title: Create a new group + success: Group group_name has been created and added to the capsule successfully + name: Choose a new group name + validate: Create a new group + go_back: Go back to capsule groups + add: + success: Group(s) groups_names has/have been added successfully to capsule capsule_name + validate: Add theses groups to the capsule + choose: Please choose one or more groups + remove: + button: Remove group + link: Remove group + text: Do you really want to remove group %group_name% ? + title: Remove group + success: Group group_name removed successfully + filter: + button: Apply group filter + no_filter: Show all \ No newline at end of file diff --git a/translations/messages.fr.yaml b/translations/messages.fr.yaml index 010c565af4ca1105a9d1dc3c38673ad9be6febf9..258d7cec2ef3119f597bbb3e46dd80276a28b0d5 100644 --- a/translations/messages.fr.yaml +++ b/translations/messages.fr.yaml @@ -154,5 +154,31 @@ editors: text: Souhaitez-vous vraiment supprimer l'éditeur %editor_email% ? link: Supprimer l'éditeur success: L'utilisateur editor_email ne peut plus éditer la capsule capsule_name - error: You can't remove yourself as editor of your own capsule. - If you want to remove the capsule from your list, go to the capsule list page and click on "delete capsule" \ No newline at end of file + error: Vous ne pouvez pas vous enlever de la liste des éditeurs de votre propre capsule. + Si vous voulez enlever la capsule de votre liste, allez sur la page qui affiche la liste de vos capsules et cliquer sur "supprimer la capsule" + +groups: + list: + title: Groupes de la capsule + edit: + title: Modifier les groupes + title_with_capsule_name: Groupes de la capsule %capsule_name% + create: + title: Créer un nouveau groupe + success: Le groupe group_name a bien été créé et ajouté à la capsule + name: Choisir un nom de groupe + validate: Créer un nouveau groupe + go_back: Retourner à la liste des groupes + add: + success: Le(s) groupe(s) groups_names a/ont bien été ajouté(s) à la capsule capsule_name + validate: Ajouter ces groupes à la capsule + choose: Veuillez choisir un ou plusieurs groupes + remove: + button: Supprimer le groupe + link: Supprimer le groupe + text: Souhaitez-vous vraiment supprimer le groupe %group_name% ? + title: Supprimer le groupe + success: Le groupe group_name a bien été supprimé + filter: + button: Filtrer par groupe + no_filter: Tout afficher \ No newline at end of file diff --git a/translations/validators.en.yaml b/translations/validators.en.yaml index 2a4c7e79c671ce31e50ed4099f7d3074a7fafabb..3c257dc61aff7460b5b068087352bdaa2c4c599d 100644 --- a/translations/validators.en.yaml +++ b/translations/validators.en.yaml @@ -21,4 +21,9 @@ capsule: not_blank: Please enter a capsule name unique: There is already a capsule with this name video_url: - not_blank: Please enter a video URL \ No newline at end of file + not_blank: Please enter a video URL + +group: + name: + not_blank: Please enter a group name + unique: There is already a group with this name \ No newline at end of file diff --git a/translations/validators.fr.yaml b/translations/validators.fr.yaml index e6aa6050801f11f164ce603c6e01fd58177644a6..3c494abcece23ecd86f7b97c522d46bac1bf9f28 100644 --- a/translations/validators.fr.yaml +++ b/translations/validators.fr.yaml @@ -21,4 +21,9 @@ capsule: not_blank: Veuillez saisir le nom de la capsule unique: Il existe déjà une capsule avec ce nom video_url: - not_blank: Veuillez saisir l'URL de votre vidéo \ No newline at end of file + not_blank: Veuillez saisir l'URL de votre vidéo + +group: + name: + not_blank: Veuillez saisir le nom du groupe + unique: Il existe déjà un groupe avec ce nom \ No newline at end of file