Skip to content

Commit f7fabdf

Browse files
committed
Fix notes not being visible on drafts / revisions
Fixes #4
1 parent cd53dce commit f7fabdf

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.5 - 2021-06-14
2+
### Fixed
3+
- Fix notes not being visible on drafts / revisions (Fixes #4)
4+
15
## 1.0.4 - 2020-12-01
26
### Fixed
37
- Fix `a ? b : c ? d : e` deprecation warning (Fixes #3)

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ether/notes",
33
"description": "A note taking field type for Craft CMS 3",
4-
"version": "1.0.4",
4+
"version": "1.0.5",
55
"type": "craft-plugin",
66
"license": "proprietary",
77
"minimum-stability": "dev",

src/Service.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use craft\elements\User;
1616
use craft\helpers\ArrayHelper;
1717
use craft\helpers\DateTimeHelper;
18+
use craft\helpers\ElementHelper;
1819
use DateTime;
1920
use yii\db\Expression;
2021

@@ -56,6 +57,9 @@ public function delete ($id)
5657

5758
public function getNotesByElement (ElementInterface $element, $translatable = false)
5859
{
60+
if ($element->getIsDraft() || $element->getIsRevision())
61+
$element = ElementHelper::sourceElement($element);
62+
5963
$where = [
6064
'elementId' => $element->id,
6165
];

src/templates/field.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
{% if allowAdding %}
33
{% import "_includes/forms" as forms %}
44

5+
{% if element.isDraft or element.isRevision %}
6+
<small class="notes-small">It looks like you're editing a {{ element.isDraft ? 'draft' : 'revision' }}. Be aware that notes are shared across all versions of an {{ element.className|split('\\')|last }}.</small>
7+
{% endif %}
8+
59
{{ forms.textarea({
610
placeholder: 'Add a note'|t('notes'),
711
class: 'notes-input',

src/web/notes.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
.notes p {
2929
margin-bottom: 0;
3030
}
31-
.notes small {
31+
.notes small,
32+
.notes-small {
3233
color: #9aa5b1;
3334
font-size: 11px;
3435
}

0 commit comments

Comments
 (0)