|  | 
| 1861 | 1861 |       (db/entity [:block/uuid (:block/uuid result)])))) | 
| 1862 | 1862 | 
 | 
| 1863 | 1863 | (rum/defc views-tab < rum/reactive db-mixins/query | 
| 1864 |  | -  [view-parent current-view {:keys [views data items-count set-view-entity! set-data! set-views! view-feature-type show-items-count? references? opacity]}] | 
| 1865 |  | -  [:div.views | 
| 1866 |  | -   (for [view* views] | 
| 1867 |  | -     (let [view (db/sub-block (:db/id view*)) | 
| 1868 |  | -           current-view? (= (:db/id current-view) (:db/id view))] | 
| 1869 |  | -       (shui/button | 
| 1870 |  | -        {:variant :text | 
| 1871 |  | -         :size :sm | 
| 1872 |  | -         :class (str "text-sm px-0 py-0 h-6 " (when-not current-view? "text-muted-foreground")) | 
| 1873 |  | -         :on-click (fn [e] | 
| 1874 |  | -                     (if (and current-view? (not= (:db/id view) (:db/id view-parent))) | 
| 1875 |  | -                       (shui/popup-show! | 
| 1876 |  | -                        (.-target e) | 
| 1877 |  | -                        (fn [] | 
| 1878 |  | -                          [:<> | 
| 1879 |  | -                           (shui/dropdown-menu-sub | 
| 1880 |  | -                            (shui/dropdown-menu-sub-trigger | 
| 1881 |  | -                             "Rename") | 
| 1882 |  | -                            (shui/dropdown-menu-sub-content | 
| 1883 |  | -                             (when-let [block-container-cp (state/get-component :block/container)] | 
| 1884 |  | -                               (block-container-cp {} view)))) | 
| 1885 |  | -                           (shui/dropdown-menu-item | 
| 1886 |  | -                            {:key "Delete" | 
| 1887 |  | -                             :on-click (fn [] | 
| 1888 |  | -                                         (p/do! | 
| 1889 |  | -                                          (editor-handler/delete-block-aux! view) | 
| 1890 |  | -                                          (let [views' (remove (fn [v] (= (:db/id v) (:db/id view))) views)] | 
| 1891 |  | -                                            (set-views! views') | 
| 1892 |  | -                                            (set-view-entity! (first views')) | 
| 1893 |  | -                                            (shui/popup-hide!))))} | 
| 1894 |  | -                            "Delete")]) | 
| 1895 |  | -                        {:as-dropdown? true | 
| 1896 |  | -                         :dropdown-menu? true | 
| 1897 |  | -                         :align "start" | 
| 1898 |  | -                         :content-props {:onClick shui/popup-hide!}}) | 
| 1899 |  | -                       (do | 
| 1900 |  | -                         (set-view-entity! view) | 
| 1901 |  | -                         (set-data! nil))))} | 
| 1902 |  | -        (when-not references? | 
| 1903 |  | -          (let [display-type (or (:db/ident (get view :logseq.property.view/type)) | 
| 1904 |  | -                                 :logseq.property.view/type.table)] | 
| 1905 |  | -            (when-let [icon (:logseq.property/icon (db/entity display-type))] | 
| 1906 |  | -              (icon-component/icon icon {:color? true | 
| 1907 |  | -                                         :size 15})))) | 
| 1908 |  | -        (let [title (:block/title view)] | 
| 1909 |  | -          (if (= title "") | 
| 1910 |  | -            "New view" | 
| 1911 |  | -            title)) | 
| 1912 |  | -        (when (and current-view? show-items-count? (> items-count 0) (seq data)) | 
| 1913 |  | -          [:span.text-muted-foreground.text-xs | 
| 1914 |  | -           items-count])))) | 
|  | 1864 | +  [view-parent current-view {:keys [views data items-count set-view-entity! set-data! set-views! view-feature-type show-items-count? config references? opacity]}] | 
|  | 1865 | +  (let [refs-total-count (:refs-total-count config)] | 
|  | 1866 | +    [:div.views | 
|  | 1867 | +     (for [view* views] | 
|  | 1868 | +       (let [view (db/sub-block (:db/id view*)) | 
|  | 1869 | +             current-view? (= (:db/id current-view) (:db/id view))] | 
|  | 1870 | +         (shui/button | 
|  | 1871 | +          {:variant :text | 
|  | 1872 | +           :size :sm | 
|  | 1873 | +           :class (str "text-sm px-0 py-0 h-6 " (when-not current-view? "text-muted-foreground")) | 
|  | 1874 | +           :on-click (fn [e] | 
|  | 1875 | +                       (if (and current-view? (not= (:db/id view) (:db/id view-parent))) | 
|  | 1876 | +                         (shui/popup-show! | 
|  | 1877 | +                          (.-target e) | 
|  | 1878 | +                          (fn [] | 
|  | 1879 | +                            [:<> | 
|  | 1880 | +                             (shui/dropdown-menu-sub | 
|  | 1881 | +                              (shui/dropdown-menu-sub-trigger | 
|  | 1882 | +                               "Rename") | 
|  | 1883 | +                              (shui/dropdown-menu-sub-content | 
|  | 1884 | +                               (when-let [block-container-cp (state/get-component :block/container)] | 
|  | 1885 | +                                 (block-container-cp {} view)))) | 
|  | 1886 | +                             (shui/dropdown-menu-item | 
|  | 1887 | +                              {:key "Delete" | 
|  | 1888 | +                               :on-click (fn [] | 
|  | 1889 | +                                           (p/do! | 
|  | 1890 | +                                            (editor-handler/delete-block-aux! view) | 
|  | 1891 | +                                            (let [views' (remove (fn [v] (= (:db/id v) (:db/id view))) views)] | 
|  | 1892 | +                                              (set-views! views') | 
|  | 1893 | +                                              (set-view-entity! (first views')) | 
|  | 1894 | +                                              (shui/popup-hide!))))} | 
|  | 1895 | +                              "Delete")]) | 
|  | 1896 | +                          {:as-dropdown? true | 
|  | 1897 | +                           :dropdown-menu? true | 
|  | 1898 | +                           :align "start" | 
|  | 1899 | +                           :content-props {:onClick shui/popup-hide!}}) | 
|  | 1900 | +                         (do | 
|  | 1901 | +                           (set-view-entity! view) | 
|  | 1902 | +                           (set-data! nil))))} | 
|  | 1903 | +          (when-not references? | 
|  | 1904 | +            (let [display-type (or (:db/ident (get view :logseq.property.view/type)) | 
|  | 1905 | +                                   :logseq.property.view/type.table)] | 
|  | 1906 | +              (when-let [icon (:logseq.property/icon (db/entity display-type))] | 
|  | 1907 | +                (icon-component/icon icon {:color? true | 
|  | 1908 | +                                           :size 15})))) | 
|  | 1909 | +          (let [title (:block/title view)] | 
|  | 1910 | +            (if (= title "") | 
|  | 1911 | +              "New view" | 
|  | 1912 | +              title)) | 
|  | 1913 | +          (when (and current-view? show-items-count? (> items-count 0) (seq data)) | 
|  | 1914 | +            [:span.text-muted-foreground.text-xs | 
|  | 1915 | +             items-count | 
|  | 1916 | +             (when (and refs-total-count | 
|  | 1917 | +                        (> refs-total-count items-count)) | 
|  | 1918 | +               [:span | 
|  | 1919 | +                [:span "/"] | 
|  | 1920 | +                [:span {:title "Total refs count"} refs-total-count]])])))) | 
| 1915 | 1921 | 
 | 
| 1916 |  | -   (shui/button | 
| 1917 |  | -    {:variant :text | 
| 1918 |  | -     :size :sm | 
| 1919 |  | -     :title "Add new view" | 
| 1920 |  | -     :class (str "!px-1 -ml-1 text-muted-foreground hover:text-foreground transition-opacity ease-in duration-300 " opacity) | 
| 1921 |  | -     :on-click (fn [] | 
| 1922 |  | -                 (p/let [view (create-view! view-parent view-feature-type {:auto-triggered? false})] | 
| 1923 |  | -                   (set-views! (concat views [view]))))} | 
| 1924 |  | -    (ui/icon "plus" {:size 15}))]) | 
|  | 1922 | +     (shui/button | 
|  | 1923 | +      {:variant :text | 
|  | 1924 | +       :size :sm | 
|  | 1925 | +       :title "Add new view" | 
|  | 1926 | +       :class (str "!px-1 -ml-1 text-muted-foreground hover:text-foreground transition-opacity ease-in duration-300 " opacity) | 
|  | 1927 | +       :on-click (fn [] | 
|  | 1928 | +                   (p/let [view (create-view! view-parent view-feature-type {:auto-triggered? false})] | 
|  | 1929 | +                     (set-views! (concat views [view]))))} | 
|  | 1930 | +      (ui/icon "plus" {:size 15}))])) | 
| 1925 | 1931 | 
 | 
| 1926 | 1932 | (rum/defc view-head < rum/static | 
| 1927 | 1933 |   [view-parent view-entity table columns input sorting | 
|  | 
0 commit comments