From 9a30da1a443e17ac54e10c553b0a5aaa30f8dea1 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Mon, 26 Sep 2022 00:22:38 +0100 Subject: [PATCH] refactor update-nav-menu in nera package. The function now loops through the values passes to it and sets the 'enable-nav-menu- column in the database for the currently selected page in the loop. --- src/nera.lisp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/nera.lisp b/src/nera.lisp index 4e2e45c..62829d8 100644 --- a/src/nera.lisp +++ b/src/nera.lisp @@ -225,12 +225,14 @@ (setf (site-settings::site-name-of settings-to-update) name) (mito:save-dao settings-to-update)))) -(defun update-nav-menu (page-slug value) - "Updates the `ENABLE-NAV-MENU' property in `PAGES' database." - (with-connection (db) - (let ((page-to-update (mito:find-dao 'page :slug page-slug))) - (setf (pages::enable-nav-menu-p page-to-update) value) - (mito:save-dao page-to-update)))) +(defun update-nav-menu (selected-pages) + "Updates the `ENABLE-NAV-MENU' property in `PAGE' database." + (loop for page in selected-pages + do (with-connection (db) + (let ((page-to-update (mito:find-dao 'page :slug (car page)))) + (setf (pages::enable-nav-menu-p page-to-update) + (utils:checkbox-to-bool (cdr page))) + (mito:save-dao page-to-update))))) (defun nav-menu-slugs () (with-connection (db)