Details

      Description

      Roles currently are not versioned, like they were in legacy. There is no draft feature, this is required for policy CRUD and edit cancelling. The functionality must be added in the API before it can be implemented in platformui.

      Legacy separates between `new` and `temporary` roles. Both are a kind of draft. New roles are created with `is_new` = 1. Temporary roles are created from new roles, and have `version` set to role ID. This indicates that for any temporary role there will always exist a non-temporary counterpart (version = 0), but it will not be considered "published" until `is_new` is 0. It also means that when version != 0, version is unique across all roles.

        Issue Links

          Activity

          Hide
          Gunnstein Lye added a comment - - edited

          Role names don't have to be unique in legacy, but in new stack they must be. This contradicts legacy eZRole::fetchByName(), which assumes uniqueness.

          Show
          Gunnstein Lye added a comment - - edited Role names don't have to be unique in legacy, but in new stack they must be. This contradicts legacy eZRole::fetchByName(), which assumes uniqueness.
          Show
          Gunnstein Lye added a comment - - edited Work in progress: https://github.com/ezsystems/ezpublish-kernel/pull/1376 https://github.com/ezsystems/PlatformUIBundle/pull/300 https://github.com/ezsystems/repository-forms/pull/41
          Show
          Gunnstein Lye added a comment - - edited Merged in master: https://github.com/ezsystems/ezpublish-kernel/commit/285a54f942a707ec07d12d8c05f8b7531ccff0ba https://github.com/ezsystems/PlatformUIBundle/commit/e4d2113babb1fce2b0a4504a8b78a3bbda230856 https://github.com/ezsystems/repository-forms/commit/cc768d46cafd77b898e8330d096d7e2df16085cb
          Hide
          Paulo Nunes (Inactive) added a comment - - edited

          Hi,
          Having already a role "Test12", when i try to create a new role, set is name as "Test12" and then hit the "cancel" button, the following notification is displayed:

          Argument '$roleUpdateStruct' is invalid: Role '22' with the specified identifier 'teste12' already exists 
          

          Show
          Paulo Nunes (Inactive) added a comment - - edited Hi, Having already a role "Test12", when i try to create a new role, set is name as "Test12" and then hit the "cancel" button, the following notification is displayed: Argument '$roleUpdateStruct' is invalid: Role '22' with the specified identifier 'teste12' already exists
          Hide
          Gunnstein Lye added a comment -

          Paulo Nunes Confirmed, and the patch below fixes it. But it looks a bit hackish, what do you think [~jerome.vieilledent@ez.no]?

          diff --git a/lib/Form/Processor/RoleFormProcessor.php b/lib/Form/Processor/RoleFormProcessor.php
          index 4b8cd71..050bfed 100644
          --- a/lib/Form/Processor/RoleFormProcessor.php
          +++ b/lib/Form/Processor/RoleFormProcessor.php
          @@ -37,10 +37,12 @@ class RoleFormProcessor implements EventSubscriberInterface
           
               public function processDefaultAction(FormActionEvent $event)
               {
          -        /** @var \EzSystems\RepositoryForms\Data\RoleData $roleData */
          -        $roleData = $event->getData();
          -        $roleDraft = $roleData->roleDraft;
          -        $this->roleService->updateRoleDraft($roleDraft, $roleData);
          +        if ($event->getClickedButton() !== 'removeDraft') {
          +            /** @var \EzSystems\RepositoryForms\Data\RoleData $roleData */
          +            $roleData = $event->getData();
          +            $roleDraft = $roleData->roleDraft;
          +            $this->roleService->updateRoleDraft($roleDraft, $roleData);
          +        }
               }
           
               public function processSaveRole(FormActionEvent $event)
          

          Show
          Gunnstein Lye added a comment - Paulo Nunes Confirmed, and the patch below fixes it. But it looks a bit hackish, what do you think [~jerome.vieilledent@ez.no] ? diff --git a/lib/Form/Processor/RoleFormProcessor.php b/lib/Form/Processor/RoleFormProcessor.php index 4b8cd71..050bfed 100644 --- a/lib/Form/Processor/RoleFormProcessor.php +++ b/lib/Form/Processor/RoleFormProcessor.php @@ -37,10 +37,12 @@ class RoleFormProcessor implements EventSubscriberInterface   public function processDefaultAction(FormActionEvent $event) { - /** @var \EzSystems\RepositoryForms\Data\RoleData $roleData */ - $roleData = $event->getData(); - $roleDraft = $roleData->roleDraft; - $this->roleService->updateRoleDraft($roleDraft, $roleData); + if ($event->getClickedButton() !== 'removeDraft') { + /** @var \EzSystems\RepositoryForms\Data\RoleData $roleData */ + $roleData = $event->getData(); + $roleDraft = $roleData->roleDraft; + $this->roleService->updateRoleDraft($roleDraft, $roleData); + } }   public function processSaveRole(FormActionEvent $event)
          Hide
          Jérôme Vieilledent (Inactive) added a comment -

          It's already what we do for ContentType editing.
          But prefer, like in ContentTypeFormProcessor, a return ASAP pattern (if clicked button is removeDraft, return).

          Show
          Jérôme Vieilledent (Inactive) added a comment - It's already what we do for ContentType editing . But prefer, like in ContentTypeFormProcessor , a return ASAP pattern (if clicked button is removeDraft , return).
          Show
          Gunnstein Lye added a comment - Great, that's easy then. Paulo Nunes : Fixed in https://github.com/ezsystems/repository-forms/commit/dbcac3310fcfbd5116c65c6d35abceebd6bcad84
          Hide
          Paulo Nunes (Inactive) added a comment -

          Gunnstein Lye: . Thank you for the feedback.

          Show
          Paulo Nunes (Inactive) added a comment - Gunnstein Lye : . Thank you for the feedback.
          Hide
          Paulo Nunes (Inactive) added a comment -

          QA Approved

          Show
          Paulo Nunes (Inactive) added a comment - QA Approved

            People

            • Assignee:
              Unassigned
              Reporter:
              Gunnstein Lye
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 weeks, 2 days, 7 hours, 35 minutes
                3w 2d 7h 35m