aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/services
diff options
context:
space:
mode:
Diffstat (limited to 'viewer/src/services')
-rw-r--r--viewer/src/services/itemComparators.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/viewer/src/services/itemComparators.ts b/viewer/src/services/itemComparators.ts
index c8fedbe..380c66a 100644
--- a/viewer/src/services/itemComparators.ts
+++ b/viewer/src/services/itemComparators.ts
@@ -16,10 +16,20 @@
16-- You should have received a copy of the GNU Affero General Public License 16-- You should have received a copy of the GNU Affero General Public License
17-- along with this program. If not, see <https://www.gnu.org/licenses/>. 17-- along with this program. If not, see <https://www.gnu.org/licenses/>.
18*/ 18*/
19import { TranslateResult } from "vue-i18n";
20import i18n from "@/plugins/i18n";
19 21
20export type ItemComparator = (left: Gallery.Item, right: Gallery.Item) => number; 22export type ItemComparator = (left: Gallery.Item, right: Gallery.Item) => number;
23export type ItemSort = { name: Gallery.ItemSortStr; text: TranslateResult; fn: ItemComparator };
21 24
22export default class ItemComparators { 25export default class ItemComparators {
26 static readonly DEFAULT = ItemComparators.sortByNameAsc;
27
28 static readonly ITEM_SORTS: ItemSort[] = [
29 { name: "name_asc", text: i18n.t("command.sort.byNameAsc"), fn: ItemComparators.sortByNameAsc },
30 { name: "date_desc", text: i18n.t("command.sort.byDateDesc"), fn: ItemComparators.sortByDateDesc },
31 ];
32
23 static sortByNameAsc(left: Gallery.Item, right: Gallery.Item): number { 33 static sortByNameAsc(left: Gallery.Item, right: Gallery.Item): number {
24 return left.title.localeCompare(right.title); 34 return left.title.localeCompare(right.title);
25 } 35 }