webxdc/checklist
15
2
Fork
You've already forked checklist
3

fix and improve item editing #36

Merged
r10s merged 7 commits from improve-item-edit into master 2023年09月14日 12:03:23 +02:00
Owner
Copy link

see commit messages for details

closes #12
closes #31
closes #34

see commit messages for details closes #12 closes #31 closes #34
r10s changed title from (削除) send updates only if text was really edited (削除ここまで) to fix and improve item editing 2023年09月13日 23:44:30 +02:00
clear text -> update deletes an item, two clicks.
(if 'X' would directly delete the item,
that can be easily lead to mis-clicks as the button is close to the
'update' button - sure, there can be other solutions
(confirmation, swipe, delete-placement - but that one is quite simple
and does the trick)
main.css Outdated
@ -71,1 +71,4 @@
.AppListClearButton {
border-right: none;
border-radius: 0 !important;
Owner
Copy link

I think increasing selector specificity is usually better than !important

I think increasing selector specificity is usually better than `!important`
Author
Owner
Copy link

it is. however, for tiny things, well, don't make me think :)

it is. however, for tiny things, well, don't make me think :)
main.js Outdated
@ -66,7 +66,12 @@ const mod = {
// INTERFACE
InterfaceEdit (index) {
if (document.getElementsByClassName('AppUpdate').length > 0) {
Owner
Copy link

I think it's worth adding a comment here or making a named var. Also the commit message says ; this does not work?

I think it's worth adding a comment here or making a named var. Also the commit message says `; this does not work`?
Author
Owner
Copy link

i am not a fan of too many comments that easily get outdated (comments tend to not being updated by subsequent coders :)

but i changes the code so the gist get a bit clearer.

i am not a fan of too many comments that easily get outdated (comments tend to not being updated by subsequent coders :) but i changes the code so the gist get a bit clearer.
r10s marked this conversation as resolved
main.js Outdated
@ -78,2 +83,3 @@
form.innerHTML = `
<input class="AppListItemUpdateField AppListItemField" type="text" value="${ item.text }" autofocus />
<input class="AppListItemUpdateField AppListItemField" type="text" value="${ oldText }" autofocus />
<input class="AppListClearButton AppListItemButton" type="button" value="X" onclick="AppBehaviour.ControlDelete(${ index })" />
Owner
Copy link

A hard-coded index looks fragile, but alright, good enough.

A hard-coded index looks fragile, but alright, good enough.
main.js Outdated
@ -82,3 +88,3 @@
event.preventDefault();
const response = document.querySelector(`#${ item.guid }-form .AppListItemUpdateField`).value;
const newText = document.querySelector(`#${ item.guid }-form .AppListItemUpdateField`).value.trim();
Owner
Copy link

The trim() is now inconsistent with ControlCreate(). So if you create an item with spaces at the end, then edit it without changing anything, an update will be sent.

Lines 144 to 158 in 52a6953
const titleText = document.getElementById('AppHeading').innerText;
webxdc.sendUpdate({
payload: { changes: [] },
document: titleText,
}, `New title: ${titleText}`);
document.getElementById('AppSaveTitleButton').style.display = 'none';
},
ControlExport () {
webxdc.sendToChat({
// Markdown-style
text:
document.getElementById('AppHeading').innerText + '\n\n' +
The `trim()` is now inconsistent with `ControlCreate()`. So if you create an item with spaces at the end, then edit it without changing anything, an update will be sent. https://codeberg.org/webxdc/checklist/src/commit/52a69536d60e0ab0a5db025e0c5c2cd7ed2332ad/main.js#L144-L158
Author
Owner
Copy link

yip, ControlCreate should trim as well, i add a commit

yip, ControlCreate should trim as well, i add a commit
r10s marked this conversation as resolved
r10s force-pushed improve-item-edit from 4432ec7d3b to c313bd5021 2023年09月14日 12:02:37 +02:00 Compare
Author
Owner
Copy link

i go for a trashbin in the last commit, i think, the PR is good enough for now, we can iterate as needed

i go for a trashbin in the last commit, i think, the PR is good enough for now, we can iterate as needed
r10s deleted branch improve-item-edit 2023年09月14日 12:03:26 +02:00
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
webxdc/checklist!36
Reference in a new issue
webxdc/checklist
No description provided.
Delete branch "improve-item-edit"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?