Node.js based forum software built for the modern web
feat: re-jigger 'add category' button to allow addition of remote category to main index
Julian Lam75639c86bd53
diff --git a/public/language/en-GB/admin/manage/categories.json b/public/language/en-GB/admin/manage/categories.jsonindex f51152f22d..378421f30c 100644--- a/public/language/en-GB/admin/manage/categories.json+++ b/public/language/en-GB/admin/manage/categories.json@@ -1,6 +1,8 @@{"manage-categories": "Manage Categories","add-category": "Add category",+ "add-local-category": "Add Local category",+ "add-remote-category": "Add Remote category","jump-to": "Jump to...","settings": "Category Settings","edit-category": "Edit Category",@@ -103,6 +105,8 @@"alert.create-success": "Category successfully created!","alert.none-active": "You have no active categories.","alert.create": "Create a Category",+ "alert.add": "Add a Category",+ "alert.add-help": "Remote categories can be added to the categories listing by specifying their handle.<br /><br /><strong>Note</strong> — The remote category may not reflect all topics published unless at least one local user tracks/watches it.","alert.confirm-purge": "<p class=\"lead\">Do you really want to purge this category \"%1\"?</p><h5><strong class=\"text-danger\">Warning!</strong> All topics and posts in this category will be purged!</h5> <p class=\"help-block\">Purging a category will remove all topics and posts, and delete the category from the database. If you want to remove a category <em>temporarily</em>, you'll want to \"disable\" the category instead.</p>","alert.purge-success": "Category purged!","alert.copy-success": "Settings Copied!",diff --git a/public/src/admin/manage/categories.js b/public/src/admin/manage/categories.jsindex 7342d0c1de..c25e44670c 100644--- a/public/src/admin/manage/categories.js+++ b/public/src/admin/manage/categories.js@@ -27,6 +27,7 @@ define('admin/manage/categories', [Categories.render(ajaxify.data.categoriesTree);$('button[data-action="create"]').on('click', Categories.throwCreateModal);+ $('button[data-action="add"]').on('click', Categories.throwAddModal);// Enable/Disable toggle events$('.categories').on('click', '.category-tools [data-action="toggle"]', function () {@@ -151,6 +152,30 @@ define('admin/manage/categories', [});};+ Categories.throwAddModal = function () {+ Benchpress.render('admin/partials/categories/add', {}).then(function (html) {+ const modal = bootbox.dialog({+ title: '[[admin/manage/categories:alert.add]]',+ message: html,+ buttons: {+ save: {+ label: '[[global:save]]',+ className: 'btn-primary',+ callback: submit,+ },+ },+ });++ function submit() {+ // const formData = modal.find('form').serializeObject();+ modal.modal('hide');+ return false;+ }++ modal.find('form').on('submit', submit);+ });+ };+Categories.create = function (payload) {api.post('/categories', payload, function (err, data) {if (err) {diff --git a/src/views/admin/manage/categories.tpl b/src/views/admin/manage/categories.tplindex bed5850325..243936577e 100644--- a/src/views/admin/manage/categories.tpl+++ b/src/views/admin/manage/categories.tpl@@ -8,7 +8,16 @@<!-- IMPORT admin/partials/category/selector-dropdown-right.tpl -->- <button data-action="create" class="btn btn-primary btn-sm btn btn-primary btn-sm fw-semibold ff-secondary text-center text-nowrap">[[admin/manage/categories:add-category]]</button>+ <div class="btn-group" role="group">+ <button class="btn btn-primary btn-sm btn btn-primary btn-sm fw-semibold ff-secondary text-center text-nowrap dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">+ [[admin/manage/categories:add-category]]+ <i class="fa fa-caret-down"></i>+ </button>+ <ul class="dropdown-menu">+ <li><button class="btn-link dropdown-item" href="#" data-action="create">[[admin/manage/categories:add-local-category]]</button></li>+ <li><button class="btn-link dropdown-item" href="#" data-action="add">[[admin/manage/categories:add-remote-category]]</button></li>+ </ul>+ </div></div></div><div class="text-sm {{{if !breadcrumbs.length }}}hidden{{{ end }}}"><!-- IMPORT admin/partials/breadcrumbs.tpl --></div>