~pepe/neil

8eee09900a80f7d597d1e02c7c861b3e9570a7a0 — Josef Pospíšil a month ago 6190d43
Refactor shortcuts
M templates/app.temple => templates/app.temple +30 -17
@@ 20,23 20,7 @@ $}
    <link rel="icon" type="image/png" href="/img/favicon.png">
  </head>
  <body id="hero" class="container"
        {% (unless (args :no-menu) %}
          _="on keyup
          		if event.key == 'Escape' then
            		call event.target.blur()
          		else
                if event.target == me then
                  if event.key == 'a' call #query.focus()
                  else if event.key == 'n' call #new-name.focus()
                  else if event.key == 'p' call #new-project.focus()
                  else if event.key == 'o' call #running-note.focus()
                  else if event.key == 'd' set window.location to '/'
                  else if event.key == 'c' set window.location to '{{ (resolve :clients) }}'
                  else if event.key == 'i' set window.location to '{{ (resolve :stats) }}'
                end
              end"
        {% ) %}
        >
        _="on keyup call checkShortcut(event)">
    <header>
      <nav>
        <ul>


@@ 66,6 50,35 @@ $}
      </hstack>
    </footer>
    </vstack>
    {% (unless (args :no-menu) %}
      <script type="text/hyperscript">
        def setQuery(content)
          call #query.focus()
          set #query.value to content
          send results to #actions-form
        end
        def setLocation(loc)
          set window.location to loc
        end
        def checkShortcut(event)
        	set ek to event.key
      		if ek == 'Escape' then
        		call event.target.blur()
      		else
            if event.target == me then
              if ek == 'a' call #query.focus()
              else if ek == 'p' setQuery("@")
              else if ek == 't' setQuery("#")
              else if ek == 'c' setQuery("$")
              else if ek == 'n' call #new-name.focus()
              else if ek == 'o' call #running-note.focus()
              else if ek == 'd' setLocation('/')
              else if ek == 'C' setLocation('{{ (resolve :clients) }}')
              else if ek == 'i' setLocation('{{ (resolve :stats) }}')
            end
        end
      </script>
    {% ) %}
    {% (unless (= (args :path) "/auth") %}
      <script type="text/hyperscript">
        eventsource Events from /events.sse{{ (. "?path=" (args :path))}}

M templates/auth/login.temple => templates/auth/login.temple +1 -1
@@ 1,5 1,5 @@
<vstack class="narrow">
  <h2>Welcome to Neil</h2>
  <h1>Welcome to Neil</h1>
  <form action="/auth" method="POST">
    <input type="password" name="password"/>
    <button>Login</button>

M templates/clients/detail.temple => templates/clients/detail.temple +2 -2
@@ 8,14 8,14 @@ $}
(def c (args :client))
%}
<vstack spacing="l">
	<h2>client detail</h2>
	<h1>client detail</h1>
	<hstack>
    {- (head/render-dict args) -}
    {% (new/render-dict args) %}
	</hstack>
  {% (when (args :projects) %}
    <vstack>
      <h2>Projects ({{ (length (args :projects)) }})</h2>
      <h2>projects ({{ (length (args :projects)) }})</h2>
      {- (list/render-dict args) -}
    </vstack>
  {% ) %}

M templates/clients/list.temple => templates/clients/list.temple +1 -1
@@ 3,7 3,7 @@
(import /templates/clients/new)
$}
<vstack id="clients">
	<h2>Clients</h2>
	<h1>clients list</h1>
	<hstack align-y="top" spacing="xl">
    <list spacing="s">
    {% (loop [c :in (args :clients)] %}

M templates/lists.temple => templates/lists.temple +1 -1
@@ 10,7 10,7 @@ $}

{% (def tab (args :tab)) %}
<vstack id="lists">
	<h2>Clients</h2>
	<h1>clients list</h1>
  {% (cl/render-dict args) %}
	<
  {% (pl/render-dict args) %}

M templates/prefs.temple => templates/prefs.temple +3 -2
@@ 1,6 1,7 @@
{$ (import /templates/auth/change) $}
<vstack id="prefs">
  <h3>security</h3>
  <h1>preferences</h1>
  <h2>security</h2>
  <hstack>
    <vstack>
      <h4>change password</h4>


@@ 11,7 12,7 @@
      <form method="POST" action="/auth/expire"><button>expire</button></form>
    </vstack>
  </hstack>
  <h3>notifications</h3>
  <h2>notifications</h2>
  <script type="text/hyperscript">
    def checkNotifications()
      if Notification.permission == "denied"

M templates/projects/detail.temple => templates/projects/detail.temple +1 -1
@@ 12,7 12,7 @@ $}
(put args :show true)
%}
<vstack class="project">
  <h2>project detail</h2>
  <h1>project detail</h1>
	<hstack spacing="l">
    <vstack>
      {- (head/render-dict args) -}

M templates/tasks/detail.temple => templates/tasks/detail.temple +1 -0
@@ 10,6 10,7 @@ $}
(def worked? (not (empty? (t :work-intervals))))
 %}
<vstack spacing="l" class="task">
	<h1>task detail</h1> 
  <vstack>
    <hstack>
      {- (head/render-dict args) -}

M templates/tasks/new.temple => templates/tasks/new.temple +1 -1
@@ 21,7 21,7 @@
  <form _="on load call enableButtons()" hx-target="#new-task"
        hx-swap="outerHTML">
    <vstack spacing="xs">
    	<h3>New task {- (when r (. " for  @" (p :name))) -}</h3>
    	<h3>new task {- (when r (. " for  @" (p :name))) -}</h3>
      {- (when ll
           (etag "input" {:name "local-list" :value true :type :hidden})) -}
      <label>

M templates/tasks/no-running.temple => templates/tasks/no-running.temple +1 -0
@@ 5,6 5,7 @@
(import /templates/projects/recent)
$}
<vstack spacing="s">
	<h1>dashboard</h1>
  <hstack align-x="center" class="dash-top" spacing="xl">
  {% (worked/render-dict args) (new/render-dict args) %}
  </hstack>

M templates/tasks/today-time.temple => templates/tasks/today-time.temple +2 -2
@@ 1,5 1,5 @@
{$ (use /neil/watch/utils) $}
<h1 id="running-time">
<h3 id="running-time">
  today: {{ (format-interval (args :time)) }}
</h1>
</h3>