diff --git a/config/routes/routes.js b/config/routes/routes.js index e127c75..2735947 100644 --- a/config/routes/routes.js +++ b/config/routes/routes.js @@ -189,13 +189,15 @@ function controlPanelItemsRoute(req, res) { }); } -function controlPanelCategoriesRoute(req, res) { +async function controlPanelCategoriesRoute(req, res, db) { + const categories = await db.collection('categories').find({}).toArray(); res.render('admin/categories', { name: req.user.name, email: req.user.email, title: 'Digital-Store | Категории', host: req.headers.host, pageName: ['Категории', 'categories'], + categoriesCount: categories.length }); } @@ -305,7 +307,7 @@ module.exports = function (server, db) { server.get('/product/:id', (req, res) => onePageItemRoute(req, res, db)); server.get('/control-panel', checkAuthenticated, (req, res) => controlPanelRoute(req, res)); server.get('/control-panel/items', checkAuthenticated, (req, res) => controlPanelItemsRoute(req, res)); - server.get('/control-panel/categories', checkAuthenticated, (req, res) => controlPanelCategoriesRoute(req, res)); + server.get('/control-panel/categories', checkAuthenticated, (req, res) => controlPanelCategoriesRoute(req, res, db)); server.get('/control-panel/content', checkAuthenticated, (req, res) => controlPanelContentRoute(req, res)); server.get('/control-panel/administrators', checkAuthenticated, (req, res) => controlPanelAdministratorsRoute(req, res)); server.get('/control-panel/database', checkAuthenticated, (req, res) => controlPanelDatabaseRoute(req, res)); diff --git a/dist/views/admin/assets/templates/modals/edit_category.pug b/dist/views/admin/assets/templates/modals/edit_category.pug index 2b66747..ce038cc 100644 --- a/dist/views/admin/assets/templates/modals/edit_category.pug +++ b/dist/views/admin/assets/templates/modals/edit_category.pug @@ -24,7 +24,7 @@ input(type="text" name="type" required) label Тип аккаунтов .input-field.img - select(name="img" id="img" required) + select(name="img" required) option(value="" disabled selected) | Выберите иконку label(for="img") Иконка diff --git a/dist/views/admin/categories.pug b/dist/views/admin/categories.pug index abee923..6e061f4 100644 --- a/dist/views/admin/categories.pug +++ b/dist/views/admin/categories.pug @@ -12,7 +12,7 @@ body.has-fixed-sidenav .card-content span.card-title Кол-во категорий .divider - h3#categoriesCount 0 + h3#categoriesCount #{categoriesCount} .col.s12 #categories.card .card-content @@ -24,7 +24,7 @@ body.has-fixed-sidenav input(id="title" name="title" type="text" required) label(for="title") Название категории #img.input-field.col.l6.s12 - select(name="img" id="img" required) + select(name="img" required) option(value="" disabled selected) | Выберите иконку label(for="img") Иконка diff --git a/src/admin/components/categories.component.js b/src/admin/components/categories.component.js index 9e23b62..de56778 100644 --- a/src/admin/components/categories.component.js +++ b/src/admin/components/categories.component.js @@ -26,11 +26,9 @@ export class CategoriesComponent extends Component { async init() { const categories = await apiService.getCategories(); const icons = await apiService.getIcons(); - const icons_html = renderIcons(icons); const html = renderCategories(categories); - document.querySelector('#categoriesCount').textContent = categories.length; this.$editSelect.insertAdjacentHTML('beforeend', html); this.$deleteSelect.insertAdjacentHTML('beforeend', html); this.$iconsSelect.insertAdjacentHTML('beforeend', icons_html);