Parcourir la source

fix: alias delete not working

Tienson Qin il y a 5 ans
Parent
commit
87f31c1b9f

+ 20 - 20
src/main/frontend/components/editor.cljs

@@ -302,21 +302,21 @@
               [:input.form-input.block.w-full.pl-2.sm:text-sm.sm:leading-5
                (merge
                 (cond->
-                    {:key (str "modal-input-" (name id))
-                     :id (str "modal-input-" (name id))
-                     :type (or type "text")
-                     :on-change (fn [e]
-                                  (swap! input-value assoc id (util/evalue e)))
-                     :auto-complete (if (util/chrome?) "chrome-off" "off")}
+                 {:key (str "modal-input-" (name id))
+                  :id (str "modal-input-" (name id))
+                  :type (or type "text")
+                  :on-change (fn [e]
+                               (swap! input-value assoc id (util/evalue e)))
+                  :auto-complete (if (util/chrome?) "chrome-off" "off")}
                   placeholder
                   (assoc :placeholder placeholder))
                 (dissoc input-item :id))]])
            (ui/button
-             "Submit"
-             :on-click
-             (fn [e]
-               (util/stop e)
-               (on-submit command @input-value pos)))])))))
+            "Submit"
+            :on-click
+            (fn [e]
+              (util/stop e)
+              (on-submit command @input-value pos)))])))))
 
 (rum/defc absolute-modal < rum/static
   [cp set-default-width? {:keys [top left]}]
@@ -638,17 +638,17 @@
                         (let [target (.-target e)]
                           (when-not (d/has-class? target "bottom-action")
                             (let [{:keys [on-hide format value block id repo dummy?]} (get-state state)]
-                             (when on-hide
-                               (on-hide value event))
-                             (when
-                                 (or (= event :esc)
-                                     (= event :visibilitychange)
-                                     (and (= event :click)
-                                          (not (editor-handler/in-auto-complete? (gdom/getElement id)))))
-                               (state/clear-edit!))))))
+                              (when on-hide
+                                (on-hide value event))
+                              (when
+                               (or (= event :esc)
+                                   (= event :visibilitychange)
+                                   (and (= event :click)
+                                        (not (editor-handler/in-auto-complete? (gdom/getElement id)))))
+                                (state/clear-edit!))))))
                       :node (gdom/getElement id)
                       ;; :visibilitychange? true
-                      ))
+))
                    100)
 
                   (when-let [element (gdom/getElement id)]

+ 0 - 9
src/main/frontend/components/page.cljs

@@ -354,15 +354,6 @@
                                          :href (str "/file/" (util/url-encode file-path))}
                   file-path]])]
 
-             (when (and repo (not journal?) (not block?))
-               (let [alias (db/get-page-alias-names repo page-name)]
-                 (when (seq alias)
-                   [:div.text-sm.ml-1.mb-4 {:key "page-file"}
-                    [:span.opacity-50 "Alias: "]
-                    (for [item (reverse alias)]
-                      [:a.p-1.ml-1 {:href (str "/page/" (util/encode-str item))}
-                       item])])))
-
              (when (and block? (not sidebar?))
                [:div.mb-4
                 (block/block-parents repo block-id format)])

+ 6 - 1
src/main/frontend/handler/file.cljs

@@ -111,7 +111,12 @@
                            update-status? false}}]
   (let [original-content (db/get-file-no-sub repo path)]
     (if reset?
-      (db/reset-file! repo path content)
+      (do
+        (when-let [page-id (db/get-file-page-id path)]
+          (db/transact! repo
+                        [[:db/retract page-id :page/alias]
+                         [:db/retract page-id :page/tags]]))
+        (db/reset-file! repo path content))
       (db/set-file-content! repo path content))
     (util/p-handle
      (fs/write-file (util/get-repo-dir repo) path content)