|
79 | 79 | (set-loading? false))))
|
80 | 80 | [])
|
81 | 81 |
|
82 |
| - (if loading? |
83 |
| - (ui/skeleton) |
84 |
| - (views/view {:config config |
85 |
| - :data data |
86 |
| - :set-data! set-data! |
87 |
| - :view-parent class |
88 |
| - :view-identity :class-objects |
89 |
| - :columns columns |
90 |
| - :add-new-object! (fn [{:keys [properties]}] |
91 |
| - (if (= :logseq.class/Asset (:db/ident class)) |
92 |
| - (shui/dialog-open! |
93 |
| - (fn [] |
94 |
| - [:div.flex.flex-col.gap-2 |
95 |
| - [:div.font-medium "Add assets"] |
96 |
| - (filepicker/picker |
97 |
| - {:on-change (fn [_e files] |
98 |
| - (p/do! |
99 |
| - (editor-handler/upload-asset! nil files :markdown editor-handler/*asset-uploading? true) |
100 |
| - (set-data! (get-class-objects class)) |
101 |
| - (shui/dialog-close!)))})])) |
102 |
| - (add-new-class-object! class set-data! properties))) |
103 |
| - :show-add-property? true |
104 |
| - :add-property! (fn [] |
105 |
| - (state/pub-event! [:editor/new-property {:block class |
106 |
| - :class-schema? true}])) |
107 |
| - :on-delete-rows (fn [table selected-rows] |
| 82 | + (views/view {:config config |
| 83 | + :data data |
| 84 | + :set-data! set-data! |
| 85 | + :view-parent class |
| 86 | + :view-identity :class-objects |
| 87 | + :columns columns |
| 88 | + :add-new-object! (fn [{:keys [properties]}] |
| 89 | + (if (= :logseq.class/Asset (:db/ident class)) |
| 90 | + (shui/dialog-open! |
| 91 | + (fn [] |
| 92 | + [:div.flex.flex-col.gap-2 |
| 93 | + [:div.font-medium "Add assets"] |
| 94 | + (filepicker/picker |
| 95 | + {:on-change (fn [_e files] |
| 96 | + (p/do! |
| 97 | + (editor-handler/upload-asset! nil files :markdown editor-handler/*asset-uploading? true) |
| 98 | + (set-data! (get-class-objects class)) |
| 99 | + (shui/dialog-close!)))})])) |
| 100 | + (add-new-class-object! class set-data! properties))) |
| 101 | + :show-add-property? true |
| 102 | + :add-property! (fn [] |
| 103 | + (state/pub-event! [:editor/new-property {:block class |
| 104 | + :class-schema? true}])) |
| 105 | + :on-delete-rows (fn [table selected-rows] |
108 | 106 | ;; Built-in objects must not be deleted e.g. Tag, Property and Root
|
109 |
| - (let [pages (->> selected-rows (filter ldb/page?) (remove :logseq.property/built-in?)) |
110 |
| - blocks (->> selected-rows (remove ldb/page?) (remove :logseq.property/built-in?))] |
111 |
| - (p/do! |
112 |
| - (when-let [f (get-in table [:data-fns :set-row-selection!])] |
113 |
| - (f {})) |
114 |
| - (ui-outliner-tx/transact! |
115 |
| - {:outliner-op :delete-blocks} |
116 |
| - (when (seq blocks) |
117 |
| - (outliner-op/delete-blocks! blocks nil)) |
118 |
| - (let [page-ids (map :db/id pages) |
119 |
| - tx-data (map (fn [pid] [:db/retract pid :block/tags (:db/id class)]) page-ids)] |
120 |
| - (when (seq tx-data) |
121 |
| - (outliner-op/transact! tx-data {:outliner-op :save-block})))) |
122 |
| - (set-data! (get-class-objects class)))))})))) |
| 107 | + (let [pages (->> selected-rows (filter ldb/page?) (remove :logseq.property/built-in?)) |
| 108 | + blocks (->> selected-rows (remove ldb/page?) (remove :logseq.property/built-in?))] |
| 109 | + (p/do! |
| 110 | + (when-let [f (get-in table [:data-fns :set-row-selection!])] |
| 111 | + (f {})) |
| 112 | + (ui-outliner-tx/transact! |
| 113 | + {:outliner-op :delete-blocks} |
| 114 | + (when (seq blocks) |
| 115 | + (outliner-op/delete-blocks! blocks nil)) |
| 116 | + (let [page-ids (map :db/id pages) |
| 117 | + tx-data (map (fn [pid] [:db/retract pid :block/tags (:db/id class)]) page-ids)] |
| 118 | + (when (seq tx-data) |
| 119 | + (outliner-op/transact! tx-data {:outliner-op :save-block})))) |
| 120 | + (set-data! (get-class-objects class)))))}))) |
123 | 121 |
|
124 | 122 | (rum/defcs class-objects < rum/reactive db-mixins/query mixins/container-id
|
125 | 123 | [state class {:keys [current-page? sidebar?]}]
|
|
167 | 165 | (set-loading? false)))
|
168 | 166 | [])
|
169 | 167 |
|
170 |
| - (when (false? loading?) |
171 |
| - (views/view {:config config |
172 |
| - :data data |
173 |
| - :view-parent property |
174 |
| - :view-identity :property-objects |
175 |
| - :set-data! set-data! |
176 |
| - :columns columns |
177 |
| - :add-new-object! (fn [{:keys [properties]}] |
178 |
| - (add-new-property-object! property set-data! properties)) |
179 |
| - ;; TODO: Add support for adding column |
180 |
| - :show-add-property? false |
181 |
| - ;; Relationships with built-in properties must not be deleted e.g. built-in? or parent |
182 |
| - :on-delete-rows (when-not (:logseq.property/built-in? property) |
183 |
| - (fn [table selected-rows] |
184 |
| - (let [pages (->> selected-rows (filter ldb/page?) (remove :logseq.property/built-in?)) |
185 |
| - blocks (->> selected-rows (remove ldb/page?) (remove :logseq.property/built-in?))] |
186 |
| - (p/do! |
187 |
| - (set-data! (get-property-related-objects (state/get-current-repo) property)) |
188 |
| - (when-let [f (get-in table [:data-fns :set-row-selection!])] |
189 |
| - (f {})) |
190 |
| - (ui-outliner-tx/transact! |
191 |
| - {:outliner-op :delete-blocks} |
192 |
| - (when (seq blocks) |
193 |
| - (outliner-op/delete-blocks! blocks nil)) |
194 |
| - (let [page-ids (map :db/id pages) |
195 |
| - tx-data (map (fn [pid] [:db/retract pid (:db/ident property)]) page-ids)] |
196 |
| - (when (seq tx-data) |
197 |
| - (outliner-op/transact! tx-data {:outliner-op :save-block}))))))))})))) |
| 168 | + (views/view {:config config |
| 169 | + :data data |
| 170 | + :view-parent property |
| 171 | + :view-identity :property-objects |
| 172 | + :set-data! set-data! |
| 173 | + :columns columns |
| 174 | + :add-new-object! (fn [{:keys [properties]}] |
| 175 | + (add-new-property-object! property set-data! properties)) |
| 176 | + ;; TODO: Add support for adding column |
| 177 | + :show-add-property? false |
| 178 | + ;; Relationships with built-in properties must not be deleted e.g. built-in? or parent |
| 179 | + :on-delete-rows (when-not (:logseq.property/built-in? property) |
| 180 | + (fn [table selected-rows] |
| 181 | + (let [pages (->> selected-rows (filter ldb/page?) (remove :logseq.property/built-in?)) |
| 182 | + blocks (->> selected-rows (remove ldb/page?) (remove :logseq.property/built-in?))] |
| 183 | + (p/do! |
| 184 | + (set-data! (get-property-related-objects (state/get-current-repo) property)) |
| 185 | + (when-let [f (get-in table [:data-fns :set-row-selection!])] |
| 186 | + (f {})) |
| 187 | + (ui-outliner-tx/transact! |
| 188 | + {:outliner-op :delete-blocks} |
| 189 | + (when (seq blocks) |
| 190 | + (outliner-op/delete-blocks! blocks nil)) |
| 191 | + (let [page-ids (map :db/id pages) |
| 192 | + tx-data (map (fn [pid] [:db/retract pid (:db/ident property)]) page-ids)] |
| 193 | + (when (seq tx-data) |
| 194 | + (outliner-op/transact! tx-data {:outliner-op :save-block}))))))))}))) |
198 | 195 |
|
199 | 196 | ;; Show all nodes containing the given property
|
200 | 197 | (rum/defcs property-related-objects < rum/reactive db-mixins/query mixins/container-id
|
|
0 commit comments