Skip to content

Commit

Permalink
feat: UI changes for ACP > Manage > Categories (#10782)
Browse files Browse the repository at this point in the history
* Revert "Revert "feat: cross origin opener policy options (#10710)""

This reverts commit 46050ac.

* Revert "Revert "chore(i18n): fallback strings for new resources: nodebb.admin-settings-advanced""

This reverts commit 9f291c0.

* 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 46050ac.

* Revert "Revert "chore(i18n): fallback strings for new resources: nodebb.admin-settings-advanced""

This reverts commit 9f291c0.

* 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 <julian@nodebb.org>
Co-authored-by: Barış Soner Uşaklı <barisusakli@gmail.com>

* 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](ajaxorg/ace-builds@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] <support@github.com>

* 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ı <barisusakli@gmail.com>
Co-authored-by: Opliko <opliko.reg@protonmail.com>
Co-authored-by: Misty Release Bot <deploy@nodebb.org>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
5 people committed Jul 26, 2022
1 parent 9390368 commit 85128c0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
6 changes: 3 additions & 3 deletions public/less/admin/manage/categories.less
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ div.categories {
}
}
> li {
margin: @acp-base-line 0;
margin: 16px 0 24px 0;

&.placeholder {
border: 1px dashed #2196F3;
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -93,7 +93,7 @@ div.categories {

.category-header {
margin-top: 0;
margin-bottom: @acp-base-line;
margin-bottom: 8px;
}

.description {
Expand Down
3 changes: 0 additions & 3 deletions public/less/admin/vars.less
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
24 changes: 22 additions & 2 deletions public/src/admin/manage/categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

Expand Down Expand Up @@ -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);
}
};
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
Expand Down
3 changes: 1 addition & 2 deletions src/views/admin/partials/categories/category-rows.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="col-md-9">
<div class="clearfix">
<div class="toggle">
<i class="fa fa-minus"></i>
<i class="fa fa-chevron-down"></i>
</div>
<div class="information">
<div class="icon" style="
Expand Down Expand Up @@ -56,5 +56,4 @@
</li>
{{{ end }}}
<!-- END categories -->
<li class="children-placeholder"></li>
</ul>

0 comments on commit 85128c0

Please sign in to comment.