diff --git a/docs/PLUGIN-LAB-PRINTEDPARTS.md b/docs/PLUGIN-LAB-PRINTEDPARTS.md index 6e53376..44116ba 100644 --- a/docs/PLUGIN-LAB-PRINTEDPARTS.md +++ b/docs/PLUGIN-LAB-PRINTEDPARTS.md @@ -306,6 +306,20 @@ CONTRACT ADDITION, because the mailer was not on the plugin surface: crossing, no re-fire while below, rearm after restock (see `test_lowstock_alert_fires_on_crossing_only`). +## Stage 12 (extension) - the admin settings page + +A get_settings_cards card needs a PAGE to link, which is why stage 9 deferred +it. The page is ordinary: +1. `frontend/src/views/settings/PrintedPartsSettings.vue` - load the four + keys via `settingsApi.list({category: 'printedparts'})`, save each with + `settingsApi.update(key, value)` (admin-gated server-side). +2. Route in the PLUGIN's router file with path `settings/printedparts` + + `requiresAuth, requiresAdmin, plugin` meta - the router shell + automatically nests any `settings/...` path under the two-pane settings + rail. +3. `get_settings_cards` on the plugin pointing at `/settings/printedparts` - + the card appears in the rail's catalog while the plugin is enabled. + --- ## Where each pattern lives (cheat sheet) diff --git a/frontend/src/router/routes/printedparts.js b/frontend/src/router/routes/printedparts.js index 4646e0c..f769ad3 100644 --- a/frontend/src/router/routes/printedparts.js +++ b/frontend/src/router/routes/printedparts.js @@ -31,5 +31,11 @@ export default [ name: 'printedparts-edit', component: () => import('../../views/printedparts/PrintedItemForm.vue'), meta: { requiresAuth: true, plugin: 'printedparts' } + }, + { + path: 'settings/printedparts', + name: 'settings-printedparts', + component: () => import('../../views/settings/PrintedPartsSettings.vue'), + meta: { requiresAuth: true, requiresAdmin: true, plugin: 'printedparts' } } ] diff --git a/frontend/src/views/settings/PrintedPartsSettings.vue b/frontend/src/views/settings/PrintedPartsSettings.vue new file mode 100644 index 0000000..605d40a --- /dev/null +++ b/frontend/src/views/settings/PrintedPartsSettings.vue @@ -0,0 +1,109 @@ + + + + + diff --git a/plugins/printedparts/plugin.py b/plugins/printedparts/plugin.py index 9224713..ee7cd3e 100644 --- a/plugins/printedparts/plugin.py +++ b/plugins/printedparts/plugin.py @@ -62,6 +62,19 @@ class PrintedpartsPlugin(BasePlugin): 'printedparts'), ] + def get_settings_cards(self) -> List[dict]: + return [ + { + 'group': '3D Printed Parts', + 'to': '/settings/printedparts', + 'icon': 'box', + 'title': '3D Parts Settings', + 'description': 'Item code prefix, default threshold, kiosk ' + 'badge policy, low-stock alert recipients', + 'position': 47, + }, + ] + def get_reports(self) -> List[dict]: return [ {