Skip to content
This repository was archived by the owner on Aug 4, 2026. It is now read-only.

fix(part-2): wire register slug→id + auto-fetch index pages - #3

Merged
rubenvdlinde merged 2 commits into
mainfrom
feature/part-2-followup-register-id
May 11, 2026
Merged

fix(part-2): wire register slug→id + auto-fetch index pages#3
rubenvdlinde merged 2 commits into
mainfrom
feature/part-2-followup-register-id

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

Summary

Closes the known follow-up from #2: CnIndexPage now lists the seed data without manual intervention. Three coordinated changes:

1. Backend resolves slug→id

`SettingsService::resolveRegisterIds()` looks up the deskdesk register slug and the floor/desk/booking schema slugs via OpenRegister's RegisterMapper / SchemaMapper, exposing them on `/api/settings` as `registerId`, `registerSlug`, and `schemaIds`. Frontend can register object types with the real numeric id.

2. New IndexPageWrapper for the index pageType

Library default `index` pageType maps straight to CnIndexPage which doesn't fetch. The wrapper:

  • Uses useListView against the configured schema
  • Triggers refresh() in mounted()
  • Imports useObjectStore from src/store/store.js — not from `@conduction/nextcloud-vue` directly (the library's useObjectStore is a separate Pinia store with id `conduction-objects` that has no registered types in this app)

Wired in App.vue:
```js
const pageTypes = { ...defaultPageTypes, index: IndexPageWrapper }

```

3. Bootstrap order in main.js

`initializeStores()` now resolves before `$mount('#content')`. Without this, IndexPageWrapper races the store init and CnIndexPage shows "No items found" on first paint.

Verified

  • `GET /index.php/apps/deskdesk/api/settings` returns the resolved ids:
    ```
    registerId: 925, schemaIds: { floor: 1629, desk: 1630, booking: 1631 }
    ```
  • `/apps/deskdesk/` renders all 4 seed desks in the index table with schema-driven columns (label / floor / zone / equipment / capacity / accessibility). Playwright dump:
    ```
    Showing 4 of 4
    2-West-04 west
    3-Central-Meeting central
    3-East-12 east
    3-East-13 east
    ```

Note on the wrapper

This wrapper is intentionally tiny. Once the library wires the auto-fetch into the default `index` pageType, this file can go away — the manifest is the single source of truth as it should be. The library issue is worth filing as a follow-up so consuming apps stop having to write the same wrapper.

Generated with Claude Code

Part 2 of the DeskDesk tutorial wires the empty Part 1 shell to real
data via OpenRegister + the @conduction/nextcloud-vue manifest renderer.

Schemas (lib/Settings/deskdesk_register.json):
  - floor      label + building + planImage
  - desk       label + floor (relation) + zone + equipment[] + capacity +
               accessibility + photo + notes
  - booking    desk (relation) + user + start + end + purpose + status +
               recurrence
  Plus a components.registers.deskdesk block + 5 desk / 2 floor / 3
  booking seed objects so the app is demoable on first install.

Manifest (src/manifest.json):
  - Three top-level menu entries (Desks / Bookings / Floors), order 10/20/30
  - Pages for index + detail of each schema, dispatched by CnPageRenderer
    by matching $route.name === page.id
  - dependencies: ['openregister'] so CnAppRoot's dependency-check phase
    fires when OpenRegister is missing

Frontend:
  - src/App.vue is now ~10 lines: <CnAppRoot :app-id :manifest />
  - src/router/index.js generates routes from manifest.pages, all pointing
    at CnPageRenderer. No hand-rolled views.
  - Deleted: navigation/MainMenu.vue, views/Dashboard.vue, views/items/*,
    views/settings/UserSettings.vue, views/settings/Settings.vue. Replaced
    by the manifest renderer.
  - src/store/store.js registers all three schemas with the shared object
    store on boot.

Backend:
  - SettingsService::loadConfiguration() now uses
    ConfigurationService::importFromFilePath() with the path resolved
    relative to /var/www/html (\OC::$SERVERROOT). The previous call was
    using the wrong importFromApp() signature.

Known follow-ups (not blockers for the tutorial):
  - The settings API still returns the register *slug* in `register`;
    CnIndexPage's store needs the numeric id. Wire that resolution in a
    follow-up so the index pages list seed data without a manual step.
  - Translation keys (deskdesk.menu.desks etc.) need l10n entries; for
    now they render as raw keys.
Closes the Part 2 known follow-up: CnIndexPage now lists the seed
data without manual intervention.

Three changes, in order of dependency:

1. SettingsService::resolveRegisterIds() resolves the deskdesk register
   slug and the floor / desk / booking schema slugs to numeric ids via
   the OpenRegister mappers, exposing them on /api/settings as
   `registerId`, `registerSlug`, and `schemaIds`. The frontend store
   now uses `config.registerId` instead of the slug fallback.

2. New IndexPageWrapper.vue: a thin manifest-aware wrapper that uses
   useListView() against the configured schema and triggers refresh()
   in mounted(). Registered as the `index` pageType in App.vue via
   the cnPageTypes inject, so every manifest page with
   `type: "index"` auto-fetches. The wrapper imports useObjectStore
   from src/store/store.js (our local store with id 'object') rather
   than the library's default — the library's useObjectStore returns
   a separate Pinia instance with id 'conduction-objects' which has
   no registered types.

3. main.js now awaits initializeStores() before $mount('#content'),
   so the manifest-driven IndexPageWrapper finds the object-store
   types registered when its mounted() hook fires. Without this, the
   wrapper races initializeStores and CnIndexPage shows "No items
   found" on first paint.

Verified locally:
- /api/settings returns { registerId: 925, schemaIds: { floor: 1629,
  desk: 1630, booking: 1631 }, ... }
- /apps/deskdesk/ shows all 4 seed desks in the index table with
  schema-driven columns (label / floor / zone / equipment / capacity
  / accessibility) — confirmed via Playwright (page text:
  "Showing 4 of 4 ... 2-West-04 west ... 3-Central-Meeting central
  ... 3-East-12 east ... 3-East-13 east").
@github-actions

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/deskdesk @ 5328378

Check PHP Vue Security License Tests
lint
phpcs
phpmd
psalm
phpstan
phpmetrics
eslint
stylelint
composer ✅ 100/100
npm
PHPUnit ⏭️
Newman ⏭️
Playwright ⏭️

Quality workflow — 2026-05-10 21:22 UTC

Download the full PDF report from the workflow artifacts.

@rubenvdlinde
rubenvdlinde merged commit 8292998 into main May 11, 2026
31 of 43 checks passed
@rubenvdlinde
rubenvdlinde deleted the feature/part-2-followup-register-id branch May 11, 2026 06:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant