Skip to content

Commit

Permalink
Changed group name save logic
Browse files Browse the repository at this point in the history
  • Loading branch information
KikyTokamuro committed Jan 8, 2023
1 parent c6a1255 commit 573cd95
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion api.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
do (let* ((group-name-sym (string-to-keyword (getf stats ':group)))
(status-sym (string-to-keyword (getf stats ':status)))
(count (getf stats ':count))
(group-origname (substitute #\space #\_ (getf stats ':group))))
(group-origname (getf stats ':group)))
(if (not (getf response group-name-sym))
(setf (getf response group-name-sym) (list :todo 0 :doing 0 :done 0 :origname group-origname)))
(setf (getf (getf response group-name-sym) status-sym) count)))
Expand Down
2 changes: 1 addition & 1 deletion index.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
(:a :href "https://github.com/KikyTokamuro/todolist-cl" :target "_blank"
(version)))
(:div :class "todolist-groups-wrapper"
(:div :class "todolist-group-button" :id "group-all"
(:div :class "todolist-group-button" :group "all"
(:span "all")))
(:div :class "todolist-search-wrapper"
(:input :type "text" :id "search-input" :placeholder "Insert search filter"))
Expand Down
24 changes: 13 additions & 11 deletions static/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class TodolistUI {
data.forEach(i => {
// Draw all groups button
$(".todolist-groups-wrapper")
.append(this.generateGroupElement(i.NAME.toLowerCase()));
.append(this.generateGroupElement(i.NAME));
});

this.selectGroup("all");
Expand Down Expand Up @@ -100,7 +100,9 @@ export class TodolistUI {
*/
createTodo (quill) {
const taskText = quill.root.innerHTML;
const taskGroup = $("#task-group").val().replaceAll(" ", "_");
const taskGroup = $("#task-group").val()
.replace(/[\`,\"\']/g, "_")
.toLowerCase();

if (taskText == "" || taskGroup == "") {
alert("The task or its group cannot be empty");
Expand All @@ -114,10 +116,10 @@ export class TodolistUI {
data.GROUP, data.ID, data.STATUS, data.DATE, data.TEXT
));

if ($(`#group-${taskGroup}`).length == 0) {
if ($(`.todolist-group-button[group="${taskGroup}"]`).length == 0) {
// Append new group
$(".todolist-groups-wrapper").append(this.generateGroupElement(taskGroup));
$(`#group-${taskGroup} span`).click();
$(`.todolist-group-button[group="${taskGroup}"] span`).click();
}

// Close modal
Expand Down Expand Up @@ -210,8 +212,8 @@ export class TodolistUI {
*/
generateGroupElement (taskGroup) {
return `
<div class="todolist-group-button" id="group-${taskGroup}" style="background: rgba(255, 255, 255);">
<span>${taskGroup.replaceAll("_", " ")}</span>
<div class="todolist-group-button" group="${taskGroup}" style="background: rgba(255, 255, 255);">
<span>${taskGroup}</span>
<div class="group-element-delete">
<img src="./static/images/delete.svg">
</div>
Expand Down Expand Up @@ -269,7 +271,7 @@ export class TodolistUI {
*/
selectGroup (group) {
this.unselectAllGroup();
$(`#group-${group}`).css("background", "rgba(0, 0, 0, 0.1)");
$(`.todolist-group-button[group="${group}"]`).css("background", "rgba(0, 0, 0, 0.1)");
this.drawTodos(group);
};

Expand All @@ -280,7 +282,7 @@ export class TodolistUI {
*/
selectGroupClick (event) {
const groupElement = $(event.target).closest(".todolist-group-button");
const group = $(groupElement).attr("id").replace("group-", "");
const group = $(groupElement).attr("group");
this.selectGroup(group);
};

Expand All @@ -291,12 +293,12 @@ export class TodolistUI {
*/
deleteGroup (event) {
const groupElement = $(event.target).closest(".todolist-group-button");
const group = $(groupElement).attr("id").replace("group-", "");
const group = $(groupElement).attr("group");

this.api.deleteGroup(group).done((data) => {
if (data.ERROR == undefined) {
$(`#group-${group}`).remove();
$("#group-all span").click();
$(`.todolist-group-button[group="${group}"]`).remove();
$(`.todolist-group-button[group="all"] span`).click();
} else {
alert(data.ERROR);
}
Expand Down
2 changes: 1 addition & 1 deletion todolist.asd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
:description "Todolist with web UI"
:author "Daniil Archangelsky <kiky.tokamuro@yandex.ru>"
:license "MIT"
:version "2.0.0"
:version "2.0.1"
:serial t
:depends-on (#:hunchentoot #:spinneret #:jonathan #:mito)
:components ((:file "package")
Expand Down

0 comments on commit 573cd95

Please sign in to comment.