Skip to content

mica-ui: network configuration page (/settings/network) #4610

Open

Description

@ymarcon

Add the Network configuration page to the mica-ui app, reachable from the Settings page (Content section): the edition of the network form with QJsonFormBuilder (from @obiba/quasar-ui-json-form/builder) and the permissions configuration. Reference: the Angular admin page #/admin/network-config (form and permissions tabs; the taxonomy/search tab is out of scope).

Findings

  • The server stores the form as an angular-schema-form pair: EntityConfigService.validateDefinition requires a JSON array and findComplete() concatenates definition-mandatory.json with the custom definition. The builder emits a JSON Forms uischema (object) and there is no reverse converter, so a small server change is needed.
  • Form texts are t(key) tokens resolved server-side (/form?locale=) from the global bundle (/config/i18n/{locale}.json = default + custom); the translator walks any JSON so it is dialect-agnostic. The public pages read the schema titles the same way, so t() wrapping must be preserved on save.
  • The builder makes every text a translation key (website.title, group.1.label...) with its own translations map. Mica's bundle is nested JSON and already holds flat keys such as "website": "Website": a generated website.title would turn website into an object and break t(website) everywhere, so the new keys must be namespaced.
  • CustomTranslationsResource.save(merge=true) discards the merged node (bug); /config/i18n/custom/import?merge=true works and covers every locale in one call.
  • AclPanel.vue / useAcl already manage permissions + accesses (with file and open-access handling); only the help texts are document-specific.

Decisions

  1. Server-side merge of the mandatory part with a hand-written JSON Forms uischema-mandatory.json beside definition-mandatory.json (network only for now, other types when their pages are ported).
  2. Builder-generated keys are namespaced by mica-ui on save (network-form.<key>), keys loaded from the bundle are kept as they are. Revised: the texts of the form are stored with it (translations field of EntityFormDto / EntityConfig, by locale) and resolved before the Mica bundle; the Mica translations are not read nor written by the builder page. A token of a key the form does not translate (legacy form) is kept as a literal and still resolved by the server. The keyPrefix follow-up (Form builder: keyPrefix option for the generated translation keys quasar-json-form#52) is no longer needed for Mica.

Plan

Server (mica-core)

  • EntityConfigService: validateDefinition accepts an object (JSON Forms UI schema) as well as an array
  • EntityConfigService: when the custom definition is an object, the merged definition is VerticalLayout { elements: [ ...mandatory uischema elements, custom ] }; getMandatoryUischemaResourcePath() defaults to uischema-mandatory.json beside the mandatory definition (empty layout when missing)
  • config/network-form/uischema-mandatory.json (Label + _name, _acronym, _description)
  • EntityConfigServiceTest: uischema merge cases; migrated to JUnit 5 (it was JUnit 4 and never ran)

Once the network form is saved from mica-ui, the legacy Angular network edit page can no longer render it (mica-ui has its own).

mica-ui: forms of either dialect

  • stores/forms.ts: the definition is an array or an object
  • useEntityForm: convertAsf → toJsonForms (dialect detected by shape)

mica-ui: form configuration composable

useEntityConfigForm(target):

  • load: GET /config/{target}/form-custom → toJsonForms keeping the t() tokens, strings that are exactly t(key) unwrapped to key (mixed HTML help blocks are left as they are, the server still resolves them at render time); the translations of the keys the form uses come from GET /config/i18n/{lang}.json per configured language
  • save: from the builder model, every slot holding a known key becomes t(key), the keys not loaded from the bundle being prefixed with network-form.; the new or changed translations of the used keys go to PUT /config/i18n/custom/import?merge=true, then PUT /config/{target}/form-custom with the JSON Forms pair; formsStore.clear()
  • vitest coverage of unwrap / wrap / prefix / translations diff

mica-ui: page and components

  • route settings/network → SettingsNetworkPage.vue, Settings page Content item (shown when isNetworkEnabled)
  • Form tab: EntityFormBuilder.vue with QJsonFormBuilder (languages from the configuration), save / cancel, unsaved changes guard on route leave
  • Permissions tab: AclPanel on /config/network/permissions and /config/network/accesses, with file, admin only; new optional permissionHelp / accessHelp props for the global wording
  • i18n en / fr

Verified headlessly against the local Mica: a field added in the builder is saved as a JSON Forms pair (t(network-form.text.title), custom translation network-form.text.title), /form?locale=en merges the mandatory layout and resolves the titles, and the network edit page renders the mandatory fields plus the custom ones.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions