From 85128c087e1f76ffe8fd1c092837366784398078 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 26 Jul 2022 14:29:32 -0400 Subject: [PATCH] feat: UI changes for ACP > Manage > Categories (#10782) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Revert "Revert "feat: cross origin opener policy options (#10710)"" This reverts commit 46050ace1a65430fe1b567086727da22afab4f73. * Revert "Revert "chore(i18n): fallback strings for new resources: nodebb.admin-settings-advanced"" This reverts commit 9f291c07d3423a41550b38770620a998b45e5c55. * feat: closes #10719, don't trim children if category is marked section * feat: fire hook to allow plugins to filter the pids returned in a user profile /cc julianlam/nodebb-plugin-support-forum#14 * fix: use `user.hidePrivateData();` more consistently across user retrieval endpoints * fix: better looking placeholder text for ACP search * fix: bug where fallback to forum search was not working due to client-side error * feat: allow plugins to toggle whether IPs are shown in the users CSV export * feat: Allow defining active plugins in config (#10767) * Revert "Revert "feat: cross origin opener policy options (#10710)"" This reverts commit 46050ace1a65430fe1b567086727da22afab4f73. * Revert "Revert "chore(i18n): fallback strings for new resources: nodebb.admin-settings-advanced"" This reverts commit 9f291c07d3423a41550b38770620a998b45e5c55. * feat: closes #10719, don't trim children if category is marked section * feat: fire hook to allow plugins to filter the pids returned in a user profile /cc julianlam/nodebb-plugin-support-forum#14 * fix: use `user.hidePrivateData();` more consistently across user retrieval endpoints * feat: Allow defining active plugins in config resolves #10766 * fix: assign the db result to files properly * test: add tests with plugins in config * feat: better theme change handling * feat: add visual indication that plugins can't be activated * test: correct hooks * test: fix test definitions * test: remove instead of resetting nconf to avoid affecting other tests * test: ... I forgot how nconf worked * fix: remove negation * docs: improve wording of error message * feat: reduce code duplication * style: remove a redundant space * fix: remove unused imports * fix: use nconf instead of requiring config.json * fix: await... * fix: second missed await * fix: move back from getActiveIds to getActive * fix: use paths again? * fix: typo * fix: move require into the function * fix: forgot to change back to getActive * test: getActive returns only id * test: accedently commented out some stuff * feat: added note to top of plugins page if \!canChangeState Co-authored-by: Julian Lam Co-authored-by: Barış Soner Uşaklı * feat: show an informative message when no plugins are found after filtering fixes #10771 * Latest translations and fallbacks * Latest translations and fallbacks * chore(deps): bump ace-builds from 1.7.1 to 1.8.1 in /install Bumps [ace-builds](https://github.com/ajaxorg/ace-builds) from 1.7.1 to 1.8.1. - [Release notes](https://github.com/ajaxorg/ace-builds/releases) - [Changelog](https://github.com/ajaxorg/ace-builds/blob/master/CHANGELOG.md) - [Commits](https://github.com/ajaxorg/ace-builds/compare/v1.7.1...v1.8.1) --- updated-dependencies: - dependency-name: ace-builds dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * fix: swap out icons in ACP > Manage > Categories to more intuitive ones, remove extra placeholder div * fix: hide expando button if no subcategories; remove attempt at establishing common vars, increased spacing between categories in list * fix: buggy expando state on category drag/drop Co-authored-by: Barış Soner Uşaklı Co-authored-by: Opliko Co-authored-by: Misty Release Bot Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- public/less/admin/manage/categories.less | 6 ++--- public/less/admin/vars.less | 3 --- public/src/admin/manage/categories.js | 24 +++++++++++++++++-- .../partials/categories/category-rows.tpl | 3 +-- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/public/less/admin/manage/categories.less b/public/less/admin/manage/categories.less index b925fd64234c..8350b574c895 100644 --- a/public/less/admin/manage/categories.less +++ b/public/less/admin/manage/categories.less @@ -22,7 +22,7 @@ div.categories { } } > li { - margin: @acp-base-line 0; + margin: 16px 0 24px 0; &.placeholder { border: 1px dashed #2196F3; @@ -37,7 +37,7 @@ div.categories { li { min-height: 0; display: inline; - margin: 0 @acp-margin 0 0; + margin: 0 16px 0 0; left: 0; } } @@ -93,7 +93,7 @@ div.categories { .category-header { margin-top: 0; - margin-bottom: @acp-base-line; + margin-bottom: 8px; } .description { diff --git a/public/less/admin/vars.less b/public/less/admin/vars.less index e888af0b9678..dda7ed1fe8d4 100644 --- a/public/less/admin/vars.less +++ b/public/less/admin/vars.less @@ -1,6 +1,3 @@ -@acp-base-line: 8px; -@acp-line-height: @acp-base-line * 6; -@acp-margin: @acp-base-line * 2; // system font family // based on those in [bootstrap@5.0.0-alpha1](https://github.com/twbs/bootstrap/blob/b531bda07cbea2e124194aefe3b8597b3ac2578e/scss/_variables.scss#L386) // and [wordpress admin](https://core.trac.wordpress.org/browser/trunk/src/wp-admin/css/common.css?rev=47835#L220) diff --git a/public/src/admin/manage/categories.js b/public/src/admin/manage/categories.js index 521716c8e491..cae9f782ca75 100644 --- a/public/src/admin/manage/categories.js +++ b/public/src/admin/manage/categories.js @@ -42,7 +42,7 @@ define('admin/manage/categories', [ $('.categories').on('click', '.toggle', function () { const el = $(this); - el.find('i').toggleClass('fa-minus').toggleClass('fa-plus'); + el.find('i').toggleClass('fa-chevron-down').toggleClass('fa-chevron-right'); el.closest('[data-cid]').find('> ul[data-cid]').toggleClass('hidden'); }); @@ -84,7 +84,7 @@ define('admin/manage/categories', [ function toggleAll(expand) { const el = $('.categories .toggle'); - el.find('i').toggleClass('fa-minus', expand).toggleClass('fa-plus', !expand); + el.find('i').toggleClass('fa-chevron-down', expand).toggleClass('fa-chevron-right', !expand); el.closest('[data-cid]').find('> ul[data-cid]').toggleClass('hidden', !expand); } }; @@ -207,6 +207,20 @@ define('admin/manage/categories', [ if (isCategoryUpdate) { modified[cid].parentCid = newCategoryId; + + // Show/hide expand buttons after drag completion + const oldParentCid = parseInt(e.from.getAttribute('data-cid'), 10); + const newParentCid = parseInt(e.to.getAttribute('data-cid'), 10); + if (oldParentCid !== newParentCid) { + document.querySelector(`.categories li[data-cid="${newParentCid}"] .toggle`).classList.toggle('hide', false); + + const children = document.querySelectorAll(`.categories li[data-cid="${oldParentCid}"] ul[data-cid] li[data-cid]`); + if (!children.length) { + document.querySelector(`.categories li[data-cid="${oldParentCid}"] .toggle`).classList.toggle('hide', true); + } + + e.item.dataset.parentCid = newParentCid; + } } newCategoryId = -1; @@ -251,6 +265,12 @@ define('admin/manage/categories', [ }, function (html) { container.append(html); + // Disable expand toggle + if (!categories.length) { + const toggleEl = container.get(0).querySelector('.toggle'); + toggleEl.classList.toggle('hide', true); + } + // Handle and children categories in this level have for (let x = 0, numCategories = categories.length; x < numCategories; x += 1) { renderList(categories[x].children, $('li[data-cid="' + categories[x].cid + '"]'), categories[x]); diff --git a/src/views/admin/partials/categories/category-rows.tpl b/src/views/admin/partials/categories/category-rows.tpl index f138e8c3e55f..7df4bd7c45d5 100644 --- a/src/views/admin/partials/categories/category-rows.tpl +++ b/src/views/admin/partials/categories/category-rows.tpl @@ -5,7 +5,7 @@
- +