~pepe/neil

6190d4361926544c83d863ba6c769b7ba3237724 — Josef Pospíšil a month ago c5be743
Fix pin on porject page
M neil/watch/tasks.janet => neil/watch/tasks.janet +14 -9
@@ 161,8 161,8 @@
    @{:task t :running (running-task brush)
      :project (load brush (t :project))}))

(defn pin-form [{:params {:id i}}]
  (pin-form/render :id i))
(defn pin-form [{:params {:id i} :query-string qs}]
  (pin-form/render :id i :project (= qs "project")))

(defn pin [req]
  (def {:params {:id id :time t}


@@ 170,6 170,7 @@
        :query-string qs} req)
  (define-brush)
  (def task (load brush id))
  (def project (string/find "project" qs))
  (unless (= t "cancel")
    (merge-into task
                (stamp)


@@ 184,10 185,11 @@
    (html-success-resp
      (capout
        (line/render-dict
          @{:task (if (= qs "project")
          @{:task (if project
                    (task-for-project task nil)
                    (let [project (load brush (task :project))]
                      (task-with-project-name (project :name) task)))
            :project-list project
            :running (running-task brush)})))
    (see-other (resolve :tasks/detail :id id))))



@@ 196,15 198,17 @@
              :query-string qs}]
  (define-brush)
  (def task (load brush id))
  (def project (= qs "project"))
  (merge-into task (stamp) {:pin false})
  (if hx
    (html-success-resp
      (capout
        (line/render-dict
          @{:task (if (= qs "project")
          @{:task (if project
                    (task-for-project task nil)
                    (let [project (load brush (task :project))]
                      (task-with-project-name (project :name) task)))
            :project-list project
            :running (running-task brush)})))
    (see-other (resolve :tasks/detail :id id))))



@@ 239,6 243,11 @@
    "/:id/edit" (-> edit caprender html-get)
    "/save" (-> save dry caprender urlenc-post html-success)
    "/:id/detail" (-> detail set-lists html-get)
    "/:id/pin/:time" (-> pin dry
                         (guard-methods "GET")
                         auth/check-session)
    "/:id/unpin" (-> unpin dry (guard-methods "GET")
                     auth/check-session)
    "/all/:state" (-> list caprender html-get)
    "/:task-id/work-intervals/:work-interval-id/edit"
    (-> work-intervals/edit caprender html-get)


@@ 246,8 255,4 @@
    (-> work-intervals/remove dry caprender html-get)
    "/:task-id/work-intervals/:work-interval-id"
    (-> work-intervals/save
        caprender dry urlenc-post html-success)
    "/:id/pin/:time" (-> pin dry (guard-methods "GET")
                         auth/check-session)
    "/:id/unpin" (-> unpin dry (guard-methods "GET")
                     auth/check-session)})
        caprender dry urlenc-post html-success)})

M neil/watch/utils.janet => neil/watch/utils.janet +8 -3
@@ 222,9 222,14 @@
           :_ (. "on htmx:afterRequest transition opacity to 0
                           on htmx:beforeOnLoad remove #task-" id)}))

(defn hx-pin-link [id time]
  (def url
    (resolve :tasks/pin :id id :time time))

(defn pin-route [id time &opt project]
  (cond->
    (resolve :tasks/pin :id id :time time)
    project (. "?project")))

(defn hx-pin-link [id time &opt project]
  (def url (pin-route id time project))
  (def lide (. "#" (. "task-" id)))
  (plink time
         @{:hx-get url

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

M templates/projects/detail.temple => templates/projects/detail.temple +2 -1
@@ 11,7 11,8 @@ $}
(def {:project p :running r} args)
(put args :show true)
%}
<vstack align-x="center" class="project">
<vstack class="project">
  <h2>project detail</h2>
	<hstack spacing="l">
    <vstack>
      {- (head/render-dict args) -}

M templates/tasks/pin-form.temple => templates/tasks/pin-form.temple +8 -8
@@ 1,7 1,7 @@
{$ (use /neil/watch/utils) $}
{%  
(def id (args :id)) 
(def url (resolve :tasks/pin :id id :time "exact"))
(def id (args :id))
(def p (args :project))
%}
<script type="text/hyperscript">
	def enableSet()


@@ 15,21 15,21 @@
</script>
<vstack class="pin-form" align-x="center" >
  <hstack align-x="right" class="cancel">
  	{{ (hx-pin-link id :cancel) }}
  	{{ (hx-pin-link id :cancel p) }}
  </hstack>
  <strong>!pin</strong>
	<hstack class="two-btns">
    {{ (hx-pin-link id :today) }}
    {{ (hx-pin-link id :tomorrow) }}
    {{ (hx-pin-link id :today p) }}
    {{ (hx-pin-link id :tomorrow p) }}
	</hstack>
	<divider></divider>
  <small>start of the next</small>
	<hstack class="two-btns">
    {{ (hx-pin-link id :week) }}
    {{ (hx-pin-link id :month) }}
    {{ (hx-pin-link id :week p) }}
    {{ (hx-pin-link id :month p) }}
	</hstack>
	<divider></divider>
	<form hx-get={{ url }} hx-target="#task-{{ id}}">
	<form hx-get={{ (pin-route id "exact" p) }} hx-target="#task-{{ id}}">
		<vstack>
  		<label>
        <input id="date" name="date" alt="exact date" type="date"