Browse Source

fix: setting form editor

main
Inhji Y. 7 months ago
parent
commit
4f6dcadc49
  1. 1
      assets/css/_forms.scss
  2. 4
      assets/js/app.js
  3. 1
      assets/js/hooks.js
  4. 12
      lib/mirage_web/templates/setting/form.html.eex

1
assets/css/_forms.scss

@ -33,6 +33,7 @@ form {
}
select,
textarea,
input[type=text],
input[type=url],
input[type=email],

4
assets/js/app.js

@ -18,10 +18,10 @@ import {Socket} from "phoenix"
import NProgress from "nprogress"
import {LiveSocket} from "phoenix_live_view"
import TableSort from "tablesort"
import {NoteForm, LinkForm, GotoAnything, onKeydown} from "./hooks"
import {NoteForm, LinkForm, SettingForm, GotoAnything, onKeydown} from "./hooks"
const handledKeys = ["p"]
const Hooks = {NoteForm, LinkForm, GotoAnything}
const Hooks = {NoteForm, LinkForm, SettingForm, GotoAnything}
let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content")
let liveSocket = new LiveSocket("/live", Socket, {

1
assets/js/hooks.js

@ -29,6 +29,7 @@ export const NoteForm = {
}
export const LinkForm = NoteForm
export const SettingForm = NoteForm
export const onKeydown = (e, el) => {
if (e.ctrlKey) e.preventDefault()

12
lib/mirage_web/templates/setting/form.html.eex

@ -1,15 +1,17 @@
<%= form_for @changeset, @action, fn f -> %>
<%= form_for @changeset, @action, [phx_hook: "SettingForm"], fn f -> %>
<%= if @changeset.action do %>
<div class="alert alert-danger">
<p>Oops, something went wrong! Please check the errors below.</p>
</div>
<% end %>
<%= hidden_input f, :name, readonly: true %>
<fieldset>
<%= hidden_input f, :name, readonly: true %>
</fieldset>
<%= hidden_input f, :value, class: "editor-content" %>
<div id="editor"></div>
<%= error_tag f, :value %>
<fieldset phx-update="ignore">
<%= textarea f, :value %>
</fieldset>
<div>
<%= submit "Save" %>

Loading…
Cancel
Save