MishkaCmsCoreWeb.Live.Admin.Components.TranslationGroup (Mishka CMS Core v0.0.1)

Copy Markdown View Source

One word in every language — the body of the admin Translations modal and of the visual editor's Translations sheet alike. A chip per language with its translation, or "Missing", beside it, and Gervaz's MishkaCmsCore.Runtime.Translation form for the one picked.

Both pages keep the group in :translation_group and move it only through these, so the two cannot drift apart:

  • open/2 — a row's Translate: the key of that row, the first missing language picked
  • pick/2 — a click on a language
  • saved/1 — after the form saves: read again, and on to the next missing language
  • add_language/2 — the word in one more language, published on its site first if need be
  • close/1

The picker sends "translation_pick" to the page with the row's id, and the add row "translation_add_language" with the typed language.

Summary

Functions

Adds language to the open word — see Translations.add_language/4 for who may, and for the master's bounds — and picks the new language's row. A refusal is a flash, the word unchanged.

Closes the open key.

Opens the key the row id belongs to, the first language still missing picked.

Picks the language row id, if it is one of the open key's.

Reads the open key again after a save, and picks the next language still missing after the one just saved — or keeps it, when none is.

The key's languages and the form for the picked one — or, for a word the reader may not write, its value to read.

Functions

add_language(socket, language)

Adds language to the open word — see Translations.add_language/4 for who may, and for the master's bounds — and picks the new language's row. A refusal is a flash, the word unchanged.

close(socket)

Closes the open key.

open(socket, id)

Opens the key the row id belongs to, the first language still missing picked.

pick(socket, id)

Picks the language row id, if it is one of the open key's.

saved(socket)

Reads the open key again after a save, and picks the next language still missing after the one just saved — or keeps it, when none is.

translation_group(assigns)

The key's languages and the form for the picked one — or, for a word the reader may not write, its value to read.

Attributes

  • id (:string) (required)
  • group (:map) (required)
  • current_user (:any) (required)