From e077c2a24f8c8e0640c184533a8305e16986d028 Mon Sep 17 00:00:00 2001 From: Wenjie SUN Date: Fri, 16 Aug 2024 00:42:56 +0200 Subject: [PATCH] [misc] order figures by updated date if they have the same name --- README.md | 1 - inst/www/js/main.js | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 51b74e0..0a349fe 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ - # ggfigdone: Manage ggplot figures using ggfigdone [![R](https://github.com/wenjie1991/ggfigdone/actions/workflows/r.yml/badge.svg)](https://github.com/wenjie1991/ggfigdone/actions/workflows/r.yml) diff --git a/inst/www/js/main.js b/inst/www/js/main.js index 1f967e4..f601969 100644 --- a/inst/www/js/main.js +++ b/inst/www/js/main.js @@ -22,7 +22,13 @@ function strData() { function orderFigureList() { if (global_figure_order_by == "name") { global_figureList.sort(function (a, b) { - return a.name.localeCompare(b.name); + // If two figures have the same name, + // then the order should be decided by updated date + if (a.name == b.name) { + return a.updated_date.localeCompare(b.updated_date); + } else { + return a.name.localeCompare(b.name); + } }); } else if (global_figure_order_by == "updated_date") { global_figureList.sort(function (a, b) { @@ -567,7 +573,6 @@ $("#btn_order_date").click(function () { initFigureGrid(); }); - // Refresh the figure list by clicking the refresh button $("#btn_refresh").click(function () { global_figureList = getFigureList();