Skip to content

Commit

Permalink
Add versions tab to activity view in article details (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasnatter authored May 27, 2021
1 parent ee39d2e commit 4472c3f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 18 deletions.
55 changes: 43 additions & 12 deletions Admin/ArticleAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Sulu\Bundle\AdminBundle\Admin\Navigation\NavigationItem;
use Sulu\Bundle\AdminBundle\Admin\Navigation\NavigationItemCollection;
use Sulu\Bundle\AdminBundle\Admin\View\DropdownToolbarAction;
use Sulu\Bundle\AdminBundle\Admin\View\ListItemAction;
use Sulu\Bundle\AdminBundle\Admin\View\ToolbarAction;
use Sulu\Bundle\AdminBundle\Admin\View\ViewBuilderFactoryInterface;
use Sulu\Bundle\AdminBundle\Admin\View\ViewCollection;
Expand Down Expand Up @@ -62,7 +63,7 @@ class ArticleAdmin extends Admin

const EDIT_FORM_VIEW_AUTOMATION = 'sulu_article.edit_form.automation';

const EDIT_FORM_VIEW_ACTIVITY_VERSION_TAB = 'sulu_article.edit_form.activity_version_tab';
const EDIT_FORM_VIEW_ACTIVITY = 'sulu_article.edit_form.activity';

/**
* @var ViewBuilderFactoryInterface
Expand Down Expand Up @@ -263,6 +264,7 @@ function(Localization $localization) {
$this->viewBuilderFactory->createResourceTabViewBuilder(static::EDIT_FORM_VIEW . '_' . $typeKey, '/articles/:locale/' . $typeKey . '/:id')
->setResourceKey(ArticleDocument::RESOURCE_KEY)
->addLocales($locales)
->setTitleProperty('title')
->setBackView(static::LIST_VIEW . '_' . $typeKey)
);
$viewCollection->add(
Expand All @@ -283,6 +285,7 @@ function(Localization $localization) {
->setTabTitle('sulu_page.seo')
->setTabCondition('shadowOn == false')
->addToolbarActions($formToolbarActionsWithoutType)
->setTitleVisible(true)
->setParent(static::EDIT_FORM_VIEW . '_' . $typeKey)
);
$viewCollection->add(
Expand All @@ -292,6 +295,7 @@ function(Localization $localization) {
->setTabTitle('sulu_page.excerpt')
->setTabCondition('shadowOn == false')
->addToolbarActions($formToolbarActionsWithoutType)
->setTitleVisible(true)
->setParent(static::EDIT_FORM_VIEW . '_' . $typeKey)
);
$viewCollection->add(
Expand All @@ -301,22 +305,31 @@ function(Localization $localization) {
->setTabTitle('sulu_page.settings')
->setTabPriority(512)
->addToolbarActions($formToolbarActionsWithoutType)
->setTitleVisible(true)
->setParent(static::EDIT_FORM_VIEW . '_' . $typeKey)
);

if (isset($this->kernelBundles['SuluAutomationBundle'])) {
$viewCollection->add(
(new AutomationViewBuilder(static::EDIT_FORM_VIEW_AUTOMATION . '_' . $typeKey, '/automation'))
->setEntityClass(BasePageDocument::class)
->setParent(static::EDIT_FORM_VIEW . '_' . $typeKey)
);
}

if ($this->securityChecker->hasPermission(ActivityAdmin::SECURITY_CONTEXT, PermissionTypes::VIEW)) {
$viewCollection->add(
$this->viewBuilderFactory
->createResourceTabViewBuilder(static::EDIT_FORM_VIEW_ACTIVITY_VERSION_TAB . '_' . $typeKey, '/activity')
->setTitleProperty('title')
->createResourceTabViewBuilder(static::EDIT_FORM_VIEW_ACTIVITY . '_' . $typeKey, '/activity')
->setResourceKey(ArticleDocument::RESOURCE_KEY)
->setTabTitle($this->versioningEnabled ? 'sulu_admin.activity_versions' : 'sulu_admin.activity')
->setTitleProperty('')
->setParent(static::EDIT_FORM_VIEW . '_' . $typeKey)
);

$viewCollection->add(
$this->viewBuilderFactory
->createListViewBuilder(static::EDIT_FORM_VIEW_ACTIVITY_VERSION_TAB . '_' . $typeKey . '.activity', '/activity')
->createListViewBuilder(static::EDIT_FORM_VIEW_ACTIVITY . '_' . $typeKey . '.activity', '/activity')
->setTabTitle('sulu_admin.activity')
->setResourceKey(ActivityInterface::RESOURCE_KEY)
->setListKey('activities')
Expand All @@ -334,16 +347,34 @@ function(Localization $localization) {
->disableFiltering()
->addResourceStorePropertiesToListRequest(['id' => 'resourceId'])
->addRequestParameters(['resourceKey' => ArticleDocument::RESOURCE_KEY])
->setParent(static::EDIT_FORM_VIEW_ACTIVITY_VERSION_TAB . '_' . $typeKey)
->setParent(static::EDIT_FORM_VIEW_ACTIVITY . '_' . $typeKey)
);
}

if (isset($this->kernelBundles['SuluAutomationBundle'])) {
$viewCollection->add(
(new AutomationViewBuilder(static::EDIT_FORM_VIEW_AUTOMATION . '_' . $typeKey, '/automation'))
->setEntityClass(BasePageDocument::class)
->setParent(static::EDIT_FORM_VIEW . '_' . $typeKey)
);
if ($this->versioningEnabled) {
$viewCollection->add(
$this->viewBuilderFactory
->createListViewBuilder(static::EDIT_FORM_VIEW_ACTIVITY . '_' . $typeKey . '.versions', '/versions')
->setTabTitle('sulu_admin.versions')
->setResourceKey('article_versions')
->setListKey('article_versions')
->addListAdapters(['table'])
->addAdapterOptions([
'table' => [
'skin' => 'flat',
],
])
->disableTabGap()
->disableSearching()
->disableSelection()
->disableColumnOptions()
->disableFiltering()
->addRouterAttributesToListRequest(['id', 'webspace'])
->addItemActions([
new ListItemAction('restore_version', ['success_view' => static::EDIT_FORM_VIEW . '_' . $typeKey]),
])
->setParent(static::EDIT_FORM_VIEW_ACTIVITY . '_' . $typeKey)
);
}
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions Resources/config/forms/article_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,6 @@
<title>sulu_page.changelog</title>
</meta>
</property>

<property name="versions" type="settings_versions" onInvalid="ignore">
<params>
<param name="resource_key" type="string" value="article_versions"/>
</params>
</property>
</properties>
</section>
</properties>
Expand Down

0 comments on commit 4472c3f

Please sign in to comment.