Skip to content

Commit

Permalink
addded authored date and settings tab
Browse files Browse the repository at this point in the history
  • Loading branch information
wachterjohannes committed Aug 16, 2016
1 parent 4e0882a commit f43f34d
Show file tree
Hide file tree
Showing 13 changed files with 353 additions and 7 deletions.
9 changes: 8 additions & 1 deletion Admin/ArticleContententNavigationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ public function getNavigationItems(array $options = [])
$excerpt->setComponent('articles/edit/excerpt@suluarticle');
$excerpt->setDisplay(['edit']);

return [$details, $seo, $excerpt];
$settings = new ContentNavigationItem('content-navigation.contents.settings');
$settings->setId('settings');
$settings->setPosition(40);
$settings->setAction('settings');
$settings->setComponent('articles/edit/settings@suluarticle');
$settings->setDisplay(['edit']);

return [$details, $seo, $excerpt, $settings];
}
}
3 changes: 3 additions & 0 deletions Controller/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,9 @@ private function persistDocument($data, $document, $locale)
]
);
$form->submit($data, false);
if (array_key_exists('authored', $data)) {
$document->setAuthored(new \DateTime($data['authored']));
}

if (!$form->isValid()) {
throw new InvalidFormException($form);
Expand Down
31 changes: 31 additions & 0 deletions Document/ArticleDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ class ArticleDocument implements
*/
protected $published;

/**
* Timestamp of authoring (can be set by user).
*
* @var \DateTime
*/
protected $authored;

public function __construct()
{
$this->structure = new Structure();
Expand Down Expand Up @@ -399,4 +406,28 @@ public function getPublished()
{
return $this->published;
}

/**
* Set authored date-time.
*
* @param \DateTime $authored
*
* @return $this
*/
public function setAuthored($authored)
{
$this->authored = $authored;

return $this;
}

/**
* Returns date-time of authoring this article.
*
* @return \DateTime
*/
public function getAuthored()
{
return $this->authored;
}
}
31 changes: 31 additions & 0 deletions Document/ArticleOngrDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ class ArticleOngrDocument
*/
protected $seo;

/**
* @var \DateTime
*
* @Property(type="date")
*/
protected $authored;

/**
* @param string $uuid
*/
Expand Down Expand Up @@ -340,4 +347,28 @@ public function setSeo($seo)

return $this;
}

/**
* Returns authored.
*
* @return \DateTime
*/
public function getAuthored()
{
return $this->authored;
}

/**
* Set authored date.
*
* @param \DateTime $authored
*
* @return $this
*/
public function setAuthored(\DateTime $authored = null)
{
$this->authored = $authored;

return $this;
}
}
1 change: 1 addition & 0 deletions Document/Index/ArticleIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public function index(ArticleDocument $document)
$article->setTitle($document->getTitle());
$article->setChanged($document->getChanged());
$article->setCreated($document->getCreated());
$article->setAuthored($document->getAuthored());
$article->setChanger($this->userManager->getFullNameByUserId($document->getChanger()));
$article->setCreator($this->userManager->getFullNameByUserId($document->getCreator()));
$article->setType($this->getType($structure->getStructure()));
Expand Down
7 changes: 7 additions & 0 deletions Document/Subscriber/ArticleSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,5 +207,12 @@ public function handleMetadataLoad(MetadataLoadEvent $event)
'property' => 'routePath',
]
);
$metadata->addFieldMapping(
'authored',
[
'encoding' => 'system_localized',
'property' => 'authored',
]
);
}
}
1 change: 1 addition & 0 deletions Resources/config/serializer/Document.ArticleDocument.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<property name="changed" type="DateTime" groups="defaultPage"/>

<property name="published" type="DateTime" groups="defaultPage,smallPage"/>
<property name="authored" type="DateTime" groups="defaultPage,smallPage"/>
<property name="extensions" type="Sulu\Component\Content\Document\Extension\ExtensionContainer" serialized-name="ext" groups="defaultPage,preview"/>
</class>
</serializer>
39 changes: 39 additions & 0 deletions Resources/public/dist/components/articles/edit/settings/form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<form id="settings-form" class="grid">
<div class="grid-row">
<div class="grid-col-6 form-group">
<label for="authored"><%= translations.authored %></label>

<div id="authored"
data-mapper-property="authored"
data-aura-component="input@husky"
data-aura-skin="date"
data-aura-instance-name="authored"
data-aura-input-id="authored"
data-type="husky-input"
data-form="true"
class="trigger-save-button"/>
</div>
</div>

<div class="grid-row section m-top-40" id="changelog-container" style="display: none;">
<h2 class="divider m-bottom-20" title="Shadow Section">
<%= translations.changelog %>
</h2>

<div class="grid">
<div class="grid-row">
<div class="grid-col-2"><%= translations.changed %></div>
<div class="grid-col-10" id="changed">
<span class="name">...</span> (<span class="date">...</span>)
</div>
</div>

<div class="grid-row">
<div class="grid-col-2"><%= translations.created %></div>
<div class="grid-col-10" id="created">
<span class="name">...</span> (<span class="date">...</span>)
</div>
</div>
</div>
</div>
</form>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions Resources/public/js/components/articles/edit/settings/form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<form id="settings-form" class="grid">
<div class="grid-row">
<div class="grid-col-6 form-group">
<label for="authored"><%= translations.authored %></label>

<div id="authored"
data-mapper-property="authored"
data-aura-component="input@husky"
data-aura-skin="date"
data-aura-instance-name="authored"
data-aura-input-id="authored"
data-type="husky-input"
data-form="true"
class="trigger-save-button"/>
</div>
</div>

<div class="grid-row section m-top-40" id="changelog-container" style="display: none;">
<h2 class="divider m-bottom-20" title="Shadow Section">
<%= translations.changelog %>
</h2>

<div class="grid">
<div class="grid-row">
<div class="grid-col-2"><%= translations.changed %></div>
<div class="grid-col-10" id="changed">
<span class="name">...</span> (<span class="date">...</span>)
</div>
</div>

<div class="grid-row">
<div class="grid-col-2"><%= translations.created %></div>
<div class="grid-col-10" id="created">
<span class="name">...</span> (<span class="date">...</span>)
</div>
</div>
</div>
</div>
</form>
Loading

0 comments on commit f43f34d

Please sign in to comment.