Better format ranges on subscription manager page

This commit is contained in:
Alex Ling 2021-03-15 07:12:10 +00:00
parent e03bf32358
commit c6fdbfd9fd
2 changed files with 54 additions and 49 deletions

View File

@ -68,6 +68,15 @@ const component = () => {
.fail((jqXHR, status) => {
alert('danger', `Failed to check subscription. Error: [${jqXHR.status}] ${jqXHR.statusText}`);
});
},
formatRange(min, max) {
if (!isNaN(min) && isNaN(max)) return `${min}`;
if (isNaN(min) && !isNaN(max)) return `${max}`;
if (isNaN(min) && isNaN(max)) return 'All';
if (min === max) return `= ${min}`;
return `${min} - ${max}`;
}
};
};

View File

@ -13,10 +13,8 @@
<th>Manga ID</th>
<th>Language</th>
<th>Group ID</th>
<th>Min Volume</th>
<th>Max Volume</th>
<th>Min Chapter</th>
<th>Max Chapter</th>
<th>Volume Range</th>
<th>Chapter Range</th>
<th>Creator</th>
<th>Last Checked</th>
<th>Created At</th>
@ -32,10 +30,8 @@
<a x-show="sub.group_id" :href="`<%= mangadex_base_url %>/group/${sub.group_id}`" x-text="sub.group_id"></a>
<span x-show="!sub.group_id">All</span>
</td>
<td x-text="sub.min_volume || '0'"></td>
<td x-text="sub.max_volume || '+∞'"></td>
<td x-text="sub.min_chapter || '0'"></td>
<td x-text="sub.max_chapter || '+∞'"></td>
<td x-text="formatRange(sub.min_volume, sub.max_volume)"></td>
<td x-text="formatRange(sub.min_chapter, sub.max_chapter)"></td>
<td x-text="sub.username"></td>
<td x-text="`${moment.unix(sub.last_checked).fromNow()}`"></td>
<td x-text="`${moment.unix(sub.created_at).fromNow()}`"></td>