aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/services
diff options
context:
space:
mode:
authorZero~Informatique2020-09-12 22:33:37 +0200
committerG.Fouet2020-09-12 23:19:44 +0200
commitb909ec093591b50950c0de54b2005d471ca28116 (patch)
tree6fe72175022d4e39a44e9270865f611d2e819b05 /viewer/src/services
parent96ed5e6583a7f03d4ea7fa0512e66fffb656cc6e (diff)
downloadldgallery-b909ec093591b50950c0de54b2005d471ca28116.tar.gz
viewer: make default sort order configurable. code review improvements
github: resolves #239
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 }