fixes
This commit is contained in:
@@ -200,7 +200,13 @@
|
|||||||
(fc/cursor-map
|
(fc/cursor-map
|
||||||
(fn [r]
|
(fn [r]
|
||||||
(let [entry-id (line->id (fc/field-value r))]
|
(let [entry-id (line->id (fc/field-value r))]
|
||||||
(com/data-grid-row {:data-entry-id entry-id}
|
;; A ledger entry spans several rows. Each row knows its own
|
||||||
|
;; entry id and drops itself when any of its siblings' remove
|
||||||
|
;; buttons announces that id. Removing the row removes its
|
||||||
|
;; inputs, so the entry is gone from the next import post.
|
||||||
|
(com/data-grid-row {:data-entry-id entry-id
|
||||||
|
:x-data (hx/json {"entryId" entry-id})
|
||||||
|
"@remove-import-entry.window" "if ($event.detail.entryId === entryId) $el.remove()"}
|
||||||
(com/data-grid-cell {}
|
(com/data-grid-cell {}
|
||||||
(fc/with-field :external-id
|
(fc/with-field :external-id
|
||||||
(com/validated-field
|
(com/validated-field
|
||||||
@@ -281,7 +287,7 @@
|
|||||||
:title (str "Remove ledger entry " entry-id)
|
:title (str "Remove ledger entry " entry-id)
|
||||||
:aria-label (str "Remove ledger entry " entry-id)
|
:aria-label (str "Remove ledger entry " entry-id)
|
||||||
:data-remove-entry-id entry-id
|
:data-remove-entry-id entry-id
|
||||||
"@click.prevent.stop" "removeImportEntryRows($el)"}
|
"@click.prevent.stop" "$dispatch('remove-import-entry', {entryId: entryId})"}
|
||||||
svg/trash)])))))}
|
svg/trash)])))))}
|
||||||
|
|
||||||
[:div.flex.m-4.flex-row-reverse
|
[:div.flex.m-4.flex-row-reverse
|
||||||
@@ -342,19 +348,6 @@
|
|||||||
var r = await c[0].getType('text/plain')
|
var r = await c[0].getType('text/plain')
|
||||||
console.log(r)
|
console.log(r)
|
||||||
return await r.text()
|
return await r.text()
|
||||||
}
|
|
||||||
// Removes every row belonging to the same ledger entry (client-source-id)
|
|
||||||
// as the clicked button. Rows are plain form inputs, so dropping them from
|
|
||||||
// the DOM drops them from the next import post.
|
|
||||||
function removeImportEntryRows(el) {
|
|
||||||
var row = el.closest('tr');
|
|
||||||
if (!row) { return; }
|
|
||||||
var id = row.getAttribute('data-entry-id');
|
|
||||||
var body = row.closest('tbody') || row.parentNode;
|
|
||||||
Array.prototype.slice.call(body.querySelectorAll('tr[data-entry-id]'))
|
|
||||||
.forEach(function (r) {
|
|
||||||
if (r.getAttribute('data-entry-id') === id) { r.remove(); }
|
|
||||||
});
|
|
||||||
}")]
|
}")]
|
||||||
|
|
||||||
(external-import-form* request)
|
(external-import-form* request)
|
||||||
|
|||||||
@@ -652,7 +652,8 @@
|
|||||||
(is (= 2 (count (re-seq #"data-entry-id=\"REMOVE-TEST-manual-ext-a\"" html))))
|
(is (= 2 (count (re-seq #"data-entry-id=\"REMOVE-TEST-manual-ext-a\"" html))))
|
||||||
(is (= 2 (count (re-seq #"data-entry-id=\"REMOVE-TEST-manual-ext-b\"" html))))
|
(is (= 2 (count (re-seq #"data-entry-id=\"REMOVE-TEST-manual-ext-b\"" html))))
|
||||||
(testing "and offers a remove button that drops the whole entry"
|
(testing "and offers a remove button that drops the whole entry"
|
||||||
(is (= 4 (count (re-seq #"removeImportEntryRows\(\$el\)" html))))
|
(is (= 4 (count (re-seq #"\$dispatch\('remove-import-entry'" html))))
|
||||||
|
(is (= 4 (count (re-seq #"remove-import-entry\.window" html))))
|
||||||
(is (= 2 (count (re-seq #"data-remove-entry-id=\"REMOVE-TEST-manual-ext-a\"" html))))
|
(is (= 2 (count (re-seq #"data-remove-entry-id=\"REMOVE-TEST-manual-ext-a\"" html))))
|
||||||
(is (= 2 (count (re-seq #"aria-label=\"Remove ledger entry REMOVE-TEST-manual-ext-a\"" html))))))))
|
(is (= 2 (count (re-seq #"aria-label=\"Remove ledger entry REMOVE-TEST-manual-ext-a\"" html))))))))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user