Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LFX-1481] Fix display of joined date in member merge dialog for unknown date #2648

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
Joined date
</p>
<p class="text-xs text-gray-900 whitespace-normal">
{{ moment(member.joinedAt).format('YYYY-MM-DD') }}
{{ formatJoinedDate(member.joinedAt) }}
</p>
</article>
<article
Expand Down Expand Up @@ -340,6 +340,13 @@ onMounted(() => {
}, 0);
});

const formatJoinedDate = (date) => {
if (!date || new Date(date).getFullYear() <= 1970) {
return '-';
}
return moment(date).format('YYYY-MM-DD');
};

defineExpose({
more,
});
Expand Down
10 changes: 9 additions & 1 deletion frontend/src/modules/member/member-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,15 @@ const fields = {
'organizations',
'Organizations',
),
joinedAt: new DateTimeField('joinedAt', 'Joined date'),
joinedAt: new DateTimeField('joinedAt', 'Joined date', {
filterable: true,
formatter: (value) => {
if (!value || new Date(value).getFullYear() <= 1970) {
return '-';
}
return moment(value).format('YYYY-MM-DD');
},
}),
bio: new StringField('bio', label('bio')),
location: new StringField(
'location',
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/shared/fields/date-time-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,22 @@ export default class DateTimeField extends GenericField {
this.placeholder = config.placeholder;
this.hint = config.hint;
this.filterable = config.filterable || false;
this.formatter = config.formatter || null;
}

forPresenter(value) {
if (this.formatter) {
return this.formatter(value);
}
return value
? moment(value).format('YYYY-MM-DD HH:mm')
: null;
}

forFilterPreview(value) {
if (this.formatter) {
return this.formatter(value);
}
return value
? moment(value).format('YYYY-MM-DD HH:mm')
: null;
Expand Down
Loading