Fix custom date to display short version on minicard

This commit is contained in:
John R. Supplee 2021-01-19 16:08:16 +02:00
parent 855151a8d1
commit b09d656636
4 changed files with 49 additions and 5 deletions

View file

@ -8,3 +8,7 @@ template(name="dateBadge")
time(datetime="{{showISODate}}")
| {{showDate}}
template(name="dateCustomField")
a(title="{{showTitle}}" class="{{classes}}")
time(datetime="{{showISODate}}")
| {{showDate}}

View file

@ -363,6 +363,33 @@ class CardEndDate extends CardDate {
}
CardEndDate.register('cardEndDate');
class CardCustomFieldDate extends CardDate {
template() {
return 'dateCustomField';
}
onCreated() {
super.onCreated();
const self = this;
self.autorun(() => {
self.date.set(moment(self.data().value));
});
}
classes() {
return 'customfield-date';
}
showTitle() {
return '';
}
events() {
return [];
}
}
CardCustomFieldDate.register('cardCustomFieldDate');
(class extends CardReceivedDate {
showDate() {
return this.date.get().format('l');
@ -387,6 +414,12 @@ CardEndDate.register('cardEndDate');
}
}.register('minicardEndDate'));
(class extends CardCustomFieldDate {
showDate() {
return this.date.get().format('l');
}
}.register('minicardCustomFieldDate'));
class VoteEndDate extends CardDate {
onCreated() {
super.onCreated();

View file

@ -57,3 +57,7 @@
-webkit-font-smoothing: antialiased
margin-right: 0.3em
.customfield-date
display: block
border-radius: 4px
padding: 1px 3px

View file

@ -77,6 +77,9 @@ template(name="minicard")
if $eq definition.type "currency"
+viewer
= formattedCurrencyCustomFieldValue(definition)
else if $eq definition.type "date"
.date
+minicardCustomFieldDate
else
+viewer
= trueValue