4 Commits

  1. 11
      CHANGELOG.md
  2. 23
      assets/js/app.js
  3. 44
      assets/js/hooks.js
  4. 6
      lib/mirage_web/templates/setting/edit.html.eex
  5. 4
      lib/mirage_web/templates/setting/index.html.eex
  6. 2
      lib/mirage_web/templates/setting/show.html.eex
  7. 2
      mix.exs

11
CHANGELOG.md

@ -5,6 +5,17 @@ See [Conventional Commits](Https://conventionalcommits.org) for commit guideline
<!-- changelog -->
## [v0.52.2](https://git.inhji.de/inhji/mirage/compare/v0.52.1...v0.52.2) (2021-02-21)
### Bug Fixes:
* codemirror not loading for settings
* settings html & styles
## [v0.52.1](https://git.inhji.de/inhji/mirage/compare/v0.52.0...v0.52.1) (2021-02-21)

23
assets/js/app.js

@ -18,25 +18,15 @@ import {Socket} from "phoenix"
import NProgress from "nprogress"
import {LiveSocket} from "phoenix_live_view"
import TableSort from "tablesort"
import Hooks from "./hooks"
import {NoteForm, GotoAnything, onKeydown} from "./hooks"
const handledKeys = ["p"]
let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content")
let liveSocket = new LiveSocket("/live", Socket, {
params: {_csrf_token: csrfToken},
hooks: Hooks,
metadata: {
keydown: (e, el) => {
if (handledKeys.includes(e.key) && e.ctrlKey)
e.preventDefault()
return {
key: e.key,
ctrlKey: e.ctrlKey
}
}
}
hooks: {NoteForm, GotoAnything},
metadata: {keydown: onKeydown}
})
// Show progress bar on live navigation and form submits
@ -56,5 +46,12 @@ document.querySelectorAll("table").forEach(table => {
new TableSort(table)
})
if (document.querySelector("#editor")) {
import(/* webpackChunkName: "editor" */ "./editor.js").then(module => {
const initEditor = module.default
initEditor("#editor")
})
}
Prism.highlightAll();

44
assets/js/hooks.js

@ -1,21 +1,29 @@
const Hooks = {}
Hooks.GotoAnything = {
updated() {
if (this.el.classList.contains("open")) {
const input = document.querySelector("#query")
input.focus()
}
}
export const GotoAnything = {
updated() {
if (this.el.classList.contains("open")) {
const input = document.querySelector("#query")
input.focus()
}
}
}
Hooks.NoteForm = {
mounted() {
if (document.querySelector("#editor")) {
import(/* webpackChunkName: "editor" */ "./editor.js").then(module => {
const initEditor = module.default
initEditor("#editor")
})
}
}
export const NoteForm = {
mounted() {
if (document.querySelector("#editor")) {
import(/* webpackChunkName: "editor" */ "./editor.js").then(module => {
const initEditor = module.default
initEditor("#editor")
})
}
}
}
export default Hooks
export const onKeydown = (e, el) => {
if (handledKeys.includes(e.key) && e.ctrlKey)
e.preventDefault()
return {
key: e.key,
ctrlKey: e.ctrlKey
}
}

6
lib/mirage_web/templates/setting/edit.html.eex

@ -1,5 +1,7 @@
<header class="hero">
<h1>Edit Setting <%= @setting.name %></h1>
</div>
</header>
<%= render "form.html", Map.put(assigns, :action, Routes.setting_path(@conn, :update, @setting)) %>
<div class="bg-content width-full">
<%= render "form.html", Map.put(assigns, :action, Routes.setting_path(@conn, :update, @setting)) %>
</div>

4
lib/mirage_web/templates/setting/index.html.eex

@ -1,9 +1,9 @@
<%= render MirageWeb.SharedView, "user_menu.html", assigns %>
<header class="hero">
<h1>Listing Settings</h1>
</header>
<%= render MirageWeb.SharedView, "user_menu.html", assigns %>
<div class="width-full bg-content">
<%= for setting <- @settings do %>
<%= link setting.name, to: Routes.setting_path(@conn, :show, setting), class: "button" %>

2
lib/mirage_web/templates/setting/show.html.eex

@ -1,6 +1,6 @@
<header class="hero">
<h1>Setting '<%= @setting.name %>'</h1>
</div>
</header>
<div class="width-full bg-content">
<div class="content html">

2
mix.exs

@ -1,7 +1,7 @@
defmodule Mirage.MixProject do
use Mix.Project
@version "0.52.1"
@version "0.52.2"
def project do
[

Loading…
Cancel
Save