Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ransome
sleek
Commits
842be9dc
Commit
842be9dc
authored
Jul 07, 2021
by
ransome1
Browse files
Added custom file env, fixed jumping auto insert
parent
df82f911
Changes
4
Hide whitespace changes
Inline
Side-by-side
package.json
View file @
842be9dc
{
"name"
:
"sleek"
,
"productName"
:
"sleek"
,
"version"
:
"1.0.
8
"
,
"version"
:
"1.0.
9-rc.1
"
,
"description"
:
"Todo app based on todo.txt for Linux, Windows and MacOS, free and open-source"
,
"synopsis"
:
"Todo app based on todo.txt for Linux, Windows and MacOS, free and open-source"
,
"category"
:
"ProjectManagement"
,
...
...
src/js/filters.mjs
View file @
842be9dc
...
...
@@ -192,7 +192,10 @@ function generateFilterData(autoCompleteCategory, autoCompleteValue, autoComplet
categories
=
[
"
priority
"
,
"
contexts
"
,
"
projects
"
];
}
categories
.
forEach
((
category
)
=>
{
console
.
log
(
category
);
// TODO build empty container shells here
//console.log(category);
// array to collect all the available filters in the data
let
filters
=
new
Array
();
let
filterArray
;
...
...
@@ -457,8 +460,14 @@ function generateFilterButtons(category, autoCompleteValue, autoCompletePrefix,
// add filter to input
todoFiltersItem
.
addEventListener
(
"
click
"
,
(
event
)
=>
{
if
(
autoCompletePrefix
&&
autoCompleteValue
)
{
// remove composed filter first, then add selected filter
document
.
getElementById
(
"
modalFormInput
"
).
value
=
document
.
getElementById
(
"
modalFormInput
"
).
value
.
replace
(
autoCompletePrefix
+
autoCompleteValue
,
autoCompletePrefix
+
todoFiltersItem
.
getAttribute
(
"
data-filter
"
)
+
"
"
);
// remove composed filter first
let
newValue
=
document
.
getElementById
(
"
modalFormInput
"
).
value
.
slice
(
0
,
caretPosition
-
autoCompleteValue
.
length
)
+
document
.
getElementById
(
"
modalFormInput
"
).
value
.
slice
(
caretPosition
);
// split string into single characters
newValue
=
newValue
.
split
(
""
);
//then add selected filter at index
newValue
.
splice
(
caretPosition
-
autoCompleteValue
.
length
,
0
,
todoFiltersItem
.
getAttribute
(
"
data-filter
"
));
// join back from single characters to string
document
.
getElementById
(
"
modalFormInput
"
).
value
=
newValue
.
join
(
""
);
}
else
if
(
autoCompletePrefix
)
{
// add button data value to the exact caret position
document
.
getElementById
(
"
modalFormInput
"
).
value
=
[
document
.
getElementById
(
"
modalFormInput
"
).
value
.
slice
(
0
,
caretPosition
),
todoFiltersItem
.
getAttribute
(
'
data-filter
'
),
document
.
getElementById
(
"
modalFormInput
"
).
value
.
slice
(
caretPosition
)].
join
(
''
)
+
"
"
;
...
...
src/js/form.mjs
View file @
842be9dc
...
...
@@ -170,7 +170,6 @@ function positionAutoCompleteContainer() {
autoCompleteContainer
.
style
.
left
=
modalFormInputPosition
.
left
+
"
px
"
;
}
function
modalFormInputEvent
(
event
)
{
//if(event.key==="Enter") return false;
positionAutoCompleteContainer
();
resizeInput
(
document
.
getElementById
(
"
modalFormInput
"
));
let
autoCompleteValue
=
""
;
...
...
@@ -411,7 +410,7 @@ function submitForm() {
// jump to index, remove 1 item there and add the value from the input at that position
items
.
objects
.
splice
(
index
,
1
,
todo
);
// Add todo
}
else
if
(
modalForm
.
getAttribute
(
"
data-item
"
)
==
null
&&
document
.
getElementById
(
"
modalFormInput
"
).
value
!=
""
)
{
}
else
if
(
!
modalForm
.
getAttribute
(
"
data-item
"
)
&&
document
.
getElementById
(
"
modalFormInput
"
).
value
!=
""
)
{
// in case there hasn't been a passed data item, we just push the input value as a new item into the array
// replace new lines with spaces (https://stackoverflow.com/a/34936253)
let
todo
=
new
TodoTxtItem
(
document
.
getElementById
(
"
modalFormInput
"
).
value
.
replaceAll
(
/
[\r\n]
+/g
,
String
.
fromCharCode
(
16
)),
[
new
SugarDueExtension
(),
new
HiddenExtension
(),
new
RecExtension
()
]);
...
...
@@ -482,8 +481,6 @@ function toggleInputSize(type) {
newInputElement
.
id
=
"
modalFormInput
"
;
newInputElement
.
setAttribute
(
"
tabindex
"
,
0
);
newInputElement
.
setAttribute
(
"
class
"
,
"
input is-medium
"
);
//newInputElement.value = document.getElementById("modalFormInput").value.replaceAll(String.fromCharCode(16)," ");
//newInputElement.setAttribute("placeholder", translations.formTodoInputPlaceholder);
// replace old element with the new one
document
.
getElementById
(
"
modalFormInput
"
).
replaceWith
(
newInputElement
);
// replace special char with line break before passing it to textarea
...
...
src/main.js
View file @
842be9dc
...
...
@@ -173,33 +173,29 @@ const createWindow = async function() {
// skip persisted files and go with ENV if set
if
(
process
.
env
.
SLEEK_CUSTOM_FILE
&&
fs
.
existsSync
(
process
.
env
.
SLEEK_CUSTOM_FILE
))
{
file
=
process
.
env
.
SLEEK_CUSTOM_FILE
;
// regular process
}
// use the loop to check if the new path is already in the user data
let
fileFound
=
false
;
if
(
userData
.
data
.
files
)
{
userData
.
data
.
files
.
forEach
(
function
(
element
)
{
// if path is found it is set active
if
(
element
[
1
]
===
file
)
{
element
[
0
]
=
1
fileFound
=
true
;
// if this entry is not equal to the new path it is set 0
}
else
{
element
[
0
]
=
0
;
}
});
}
else
{
// use the loop to check if the new path is already in the user data
let
fileFound
=
false
;
if
(
userData
.
data
.
files
)
{
userData
.
data
.
files
.
forEach
(
function
(
element
)
{
// if path is found it is set active
if
(
element
[
1
]
===
file
)
{
element
[
0
]
=
1
fileFound
=
true
;
// if this entry is not equal to the new path it is set 0
}
else
{
element
[
0
]
=
0
;
}
});
}
else
{
userData
.
data
.
files
=
new
Array
;
}
// only push new path if it is not already in the user data
if
((
!
fileFound
||
!
userData
.
data
.
files
)
&&
file
)
userData
.
data
.
files
.
push
([
1
,
file
]);
userData
.
set
(
"
files
"
,
userData
.
data
.
files
);
userData
.
data
.
file
=
file
;
userData
.
set
(
"
file
"
,
file
);
userData
.
data
.
files
=
new
Array
;
}
console
.
log
(
file
);
// only push new path if it is not already in the user data
if
((
!
fileFound
||
!
userData
.
data
.
files
)
&&
file
)
userData
.
data
.
files
.
push
([
1
,
file
]);
userData
.
set
(
"
files
"
,
userData
.
data
.
files
);
userData
.
data
.
file
=
file
;
userData
.
set
(
"
file
"
,
file
);
// TODO describe
if
(
fileWatcher
)
fileWatcher
.
close
();
fileWatcher
=
chokidar
.
watch
(
file
);
fileWatcher
...
...
Write
Preview
Markdown
is supported
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