MishkaCmsCoreWeb.Live.Admin.Components.TranslationsRefusal (Mishka CMS Core v0.0.5-alpha.4)

Copy Markdown View Source

The alert an admin sees when archiving, or deleting for good, an original edition is refused because its translations are still live — with a button that archives (or deletes for good) those translations at once, after a confirmation naming them.

The admin layout (MishkaCmsCore.Layouts) renders it once, beside the flash messages, so every admin page has it. A table reaches it through MishkaCmsCore.LanguageEditions.on_delete_refused/3, which calls show/2. It shows the refusal's own message at once, then reads the originals and their live translations as the signed-in admin, off the page's process (MishkaCmsCore.LanguageEditions.refusal/3). The button is drawn only when that admin may act on every one of those translations, and pressing it runs MishkaCmsCore.LanguageEditions.take_translations/2 as that admin. It then reads the originals again: one with no live translation left can be deleted now, and one with a translation added in the meantime is shown again with the button for it. When that read crashes, the alert says the button is not coming.

DOM ids: translations-refusal-alert (the alert), translations-refusal-message, translations-refusal-act (the button, its data-confirm naming the translations), translations-refusal-done, translations-refusal-failed and translations-refusal-dismiss.

Summary

Functions

The DOM id, and the component id show/2 updates.

Shows the alert for refused — MishkaCmsCore.LanguageEditions.refused_originals/1 of a failed destroy on resource. Call it from the page's process.

Functions

id()

@spec id() :: String.t()

The DOM id, and the component id show/2 updates.

show(resource, refused)

@spec show(module(), [%{id: String.t(), message: String.t()}]) :: :ok

Shows the alert for refused — MishkaCmsCore.LanguageEditions.refused_originals/1 of a failed destroy on resource. Call it from the page's process.