Minor - Fix behat test, format code

pull/3432/head
Julio Montoya 5 years ago
parent 57eded82c0
commit 6dca6a1a19
  1. 4
      assets/vue/views/documents/UpdateFile.vue
  2. 74
      src/CoreBundle/Repository/ResourceRepository.php
  3. 2
      tests/behat/features/toolForum.feature

@ -1,7 +1,7 @@
<template>
<div>
<DocumentsForm
v-if="item"
v-if="!isLoading"
ref="updateForm"
:values="item"
:errors="violations"
@ -14,7 +14,7 @@
/>
<Toolbar
v-if="item"
v-if="!isLoading"
:handle-submit="onSendForm"
:handle-reset="resetForm"
:handle-delete="del"

@ -888,6 +888,43 @@ abstract class ResourceRepository extends ServiceEntityRepository
return $this->getAuthorizationChecker()->isGranted($subject, $resource->getResourceNode());
}
/**
* Changes the visibility of the children that matches the exact same link.
*/
public function copyVisibilityToChildren(ResourceNode $resourceNode, ResourceLink $link): bool
{
$children = $resourceNode->getChildren();
if (0 === $children->count()) {
return false;
}
$em = $this->getEntityManager();
/** @var ResourceNode $child */
foreach ($children as $child) {
if ($child->getChildren()->count() > 0) {
$this->copyVisibilityToChildren($child, $link);
}
$links = $child->getResourceLinks();
foreach ($links as $linkItem) {
if ($linkItem->getUser() === $link->getUser() &&
$linkItem->getSession() === $link->getSession() &&
$linkItem->getCourse() === $link->getCourse() &&
$linkItem->getUserGroup() === $link->getUserGroup()
) {
$linkItem->setVisibility($link->getVisibility());
$em->persist($linkItem);
}
}
}
$em->flush();
return true;
}
private function setLinkVisibility(AbstractResource $resource, int $visibility, bool $recursive = true): bool
{
$resourceNode = $resource->getResourceNode();
@ -941,41 +978,4 @@ abstract class ResourceRepository extends ServiceEntityRepository
return true;
}
/**
* Changes the visibility of the children that matches the exact same link.
*/
public function copyVisibilityToChildren(ResourceNode $resourceNode, ResourceLink $link): bool
{
$children = $resourceNode->getChildren();
if (0 === $children->count()) {
return false;
}
$em = $this->getEntityManager();
/** @var ResourceNode $child */
foreach ($children as $child) {
if ($child->getChildren()->count() > 0) {
$this->copyVisibilityToChildren($child, $link);
}
$links = $child->getResourceLinks();
foreach ($links as $linkItem) {
if ($linkItem->getUser() === $link->getUser() &&
$linkItem->getSession() === $link->getSession() &&
$linkItem->getCourse() === $link->getCourse() &&
$linkItem->getUserGroup() === $link->getUserGroup()
) {
$linkItem->setVisibility($link->getVisibility());
$em->persist($linkItem);
}
}
}
$em->flush();
return true;
}
}

@ -31,6 +31,7 @@ Feature: Forum tool
| post_title | Thread One |
And I fill in ckeditor field "post_text" with "This is a the first thread in a forum for test"
And I press "SubmitPost"
And wait for the page to be loaded
Then I should see "The new thread has been added"
Scenario: Reply to forum message
@ -50,6 +51,7 @@ Feature: Forum tool
Then I follow "Thread One"
Then I follow "Delete"
And I confirm the popup
And wait for the page to be loaded
Then I should see "Thread deleted"
# This test is commented because to quote a message is necessary load HTML code inside of textarea.

Loading…
Cancel
Save