Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ransome
sleek
Commits
1e1beaa3
Commit
1e1beaa3
authored
Jun 04, 2021
by
ransome1
Browse files
Fixed add/edit window mix up, added undo and redo for MacOS
parent
3ae947ec
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/js/form.mjs
View file @
1e1beaa3
...
...
@@ -226,6 +226,8 @@ function setDueDate(days) {
}
function
show
(
todo
,
templated
)
{
try
{
// remove any previously set data-item attributes
modalForm
.
removeAttribute
(
"
data-item
"
);
// adjust size of recurrence picker input field
if
(
userData
.
useTextarea
)
toggleInputSize
(
"
input
"
);
// in case the more toggle menu is open we close it
...
...
@@ -266,7 +268,6 @@ function show(todo, templated) {
modalTitle
.
innerHTML
=
translations
.
editTodo
;
btnItemStatus
.
classList
.
add
(
"
is-active
"
);
}
//btnItemStatus.classList.add("is-active");
// only show the complete button on open items
if
(
todo
.
complete
===
false
)
{
btnItemStatus
.
innerHTML
=
translations
.
done
;
...
...
@@ -309,7 +310,7 @@ function submitForm() {
try
{
// check if there is an input in the text field, otherwise indicate it to the user
// input value and data item are the same, nothing has changed, nothing will be written
if
(
modalForm
.
getAttribute
(
"
data-item
"
)
===
modalForm
.
elements
[
0
].
value
)
{
if
(
modalForm
.
getAttribute
(
"
data-item
"
)
===
modalForm
.
elements
[
0
].
value
)
{
// close and reset any modal
resetModal
().
then
(
function
(
result
)
{
console
.
log
(
result
);
...
...
@@ -318,7 +319,7 @@ function submitForm() {
});
return
Promise
.
resolve
(
"
Info: Nothing has changed, won't write anything.
"
);
// Edit todo
}
else
if
(
modalForm
.
getAttribute
(
"
data-item
"
)
!=
null
)
{
}
else
if
(
modalForm
.
getAttribute
(
"
data-item
"
))
{
// get index of todo
const
index
=
items
.
objects
.
map
(
function
(
item
)
{
return
item
.
toString
();
}).
indexOf
(
modalForm
.
getAttribute
(
"
data-item
"
));
// create a todo.txt object
...
...
src/main.js
View file @
1e1beaa3
...
...
@@ -408,17 +408,20 @@ const createWindow = async function() {
{
label
:
translations
.
edit
,
submenu
:
[
{
role
:
"
undo
"
,
accelerator
:
"
CmdOrCtrl+Z
"
},
{
role
:
"
redo
"
,
accelerator
:
"
CmdOrCtrl+Shift+Z
"
},
{
type
:
"
separator
"
},
{
label
:
translations
.
cut
,
accelerator
:
"
CmdOrCtrl+X
"
,
selector
:
"
cut:
"
},
{
label
:
translations
.
copy
,
accelerator
:
"
CmdOrCtrl+C
"
,
selector
:
"
copy:
"
},
{
label
:
translations
.
paste
,
accelerator
:
"
CmdOrCtrl+V
"
,
selector
:
"
paste:
"
},
{
role
:
"
selectAll
"
,
accelerator
:
"
CmdOrCtrl+A
"
},
{
type
:
"
separator
"
},
{
label
:
translations
.
settings
,
click
:
function
()
{
mainWindow
.
webContents
.
send
(
"
triggerFunction
"
,
"
showContent
"
,
[
"
modalSettings
"
]);
}
},
{
type
:
"
separator
"
},
{
label
:
translations
.
cut
,
accelerator
:
"
CmdOrCtrl+X
"
,
selector
:
"
cut:
"
},
{
label
:
translations
.
copy
,
accelerator
:
"
CmdOrCtrl+C
"
,
selector
:
"
copy:
"
},
{
label
:
translations
.
paste
,
accelerator
:
"
CmdOrCtrl+V
"
,
selector
:
"
paste:
"
},
{
role
:
"
selectAll
"
,
accelerator
:
"
CmdOrCtrl+A
"
}
}
]},
{
label
:
translations
.
todos
,
...
...
@@ -708,7 +711,7 @@ app
if
(
appData
.
channel
===
"
AppImage
"
)
autoUpdater
.
checkForUpdatesAndNotify
();
})
.
on
(
"
window-all-closed
"
,
()
=>
{
if
(
appData
.
os
!==
"
mac
"
)
app
.
quit
()
if
(
process
.
platform
!==
"
darwin
"
)
app
.
quit
()
})
.
on
(
"
activate
"
,
()
=>
{
if
(
BrowserWindow
.
getAllWindows
().
length
===
0
)
createWindow
()
...
...
src/render.js
View file @
1e1beaa3
...
...
@@ -657,7 +657,12 @@ function registerKeyboardShortcuts() {
modal
.
forEach
(
function
(
element
)
{
element
.
addEventListener
(
"
keydown
"
,
function
(
event
)
{
if
(
event
.
key
===
"
Escape
"
&&
!
autoCompleteContainer
.
classList
.
contains
(
"
is-active
"
))
{
this
.
classList
.
remove
(
"
is-active
"
);
//this.classList.remove("is-active");
resetModal
(
this
).
then
(
function
(
result
)
{
console
.
log
(
result
);
}).
catch
(
function
(
error
)
{
handleError
(
error
);
});
}
});
});
...
...
@@ -693,26 +698,27 @@ function resetFilters() {
return
Promise
.
reject
(
error
);
}
}
function
resetModal
()
{
function
resetModal
(
modal
)
{
try
{
if
(
modal
)
{
// remove is-active from modal
modal
.
classList
.
remove
(
"
is-active
"
);
// remove any previously set data-item attributes
modal
.
removeAttribute
(
"
data-item
"
);
}
// reset priority setting
priorityPicker
.
selectedIndex
=
0
;
// if recurrence picker was open it is now being closed
//
recurrencePickerContainer.classList.remove("is-active");
recurrencePickerContainer
.
classList
.
remove
(
"
is-active
"
);
// clear previous recurrence selection
//
recurrencePickerInput.value = null;
recurrencePickerInput
.
value
=
null
;
// if file chooser was open it is now being closed
modalChangeFile
.
classList
.
remove
(
"
is-active
"
);
// hide suggestion box if it was open
autoCompleteContainer
.
classList
.
remove
(
"
is-active
"
);
// remove focus from suggestion container
autoCompleteContainer
.
blur
();
// defines when the composed filter is being filled with content and when it is emptied
//let startComposing = false;
// in case a category will be selected from suggestion box we need to remove the category from input value that has been written already
//let autoCompleteValue = "";
// + or @
//let autoCompletePrefix = "";
// close
modalForm
.
classList
.
remove
(
"
is-active
"
);
// remove the data item as we don't need it anymore
modalForm
.
removeAttribute
(
"
data-item
"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment