From a889d0cc8c70431d43a9e46a6cf859f7b490aeb3 Mon Sep 17 00:00:00 2001 From: zeripath Date: Fri, 15 Oct 2021 17:05:33 +0100 Subject: Add buttons to allow loading of incomplete diffs (#16829) This PR adds two buttons to the stats and the end of the diffs list to load the (some of) the remaining incomplete diff sections. Contains #16775 Signed-off-by: Andrew Thornton ## Screenshots ### Show more button at the end of the diff ![Screenshot from 2021-09-04 11-12-37](https://user-images.githubusercontent.com/1824502/132091009-b1f6113e-2c04-4be5-8a04-b8ecea56887b.png) ### Show more button at the end of the diff stats box ![Screenshot from 2021-09-04 11-14-54](https://user-images.githubusercontent.com/1824502/132091063-86da5a6d-6628-4b82-bea9-3655cd9f40f6.png) --- web_src/js/features/diff.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 web_src/js/features/diff.js (limited to 'web_src/js/features') diff --git a/web_src/js/features/diff.js b/web_src/js/features/diff.js new file mode 100644 index 0000000000..ef0aaceeeb --- /dev/null +++ b/web_src/js/features/diff.js @@ -0,0 +1,24 @@ +export function initDiffShowMore() { + $('#diff-files, #diff-file-boxes').on('click', '#diff-show-more-files, #diff-show-more-files-stats', (e) => { + e.preventDefault(); + + if ($(e.target).hasClass('disabled')) { + return; + } + $('#diff-show-more-files, #diff-show-more-files-stats').addClass('disabled'); + + const url = $('#diff-show-more-files, #diff-show-more-files-stats').data('href'); + $.ajax({ + type: 'GET', + url, + }).done((resp) => { + if (!resp || resp.html === '' || resp.empty) { + $('#diff-show-more-files, #diff-show-more-files-stats').removeClass('disabled'); + return; + } + $('#diff-too-many-files-stats').remove(); + $('#diff-files').append($(resp).find('#diff-files li')); + $('#diff-incomplete').replaceWith($(resp).find('#diff-file-boxes').children()); + }); + }); +} -- cgit v1.2.3