Enhance search todo

This commit is contained in:
Supan Adit Pratama 2020-06-28 12:29:47 +07:00
parent 6094e4e2f5
commit dc0545b113

View File

@ -263,13 +263,24 @@
}, },
contentType: "application/json", contentType: "application/json",
async: true, async: true,
beforeSend: function () {
$("#todo-list").html("<div style=\"text-align: center;height: 200px;position: relative;\">\n" +
" <i class=\"fa fa-spinner fa-spin\" style=\"position: absolute;top:50%;left:50%;\"></i>\n" +
" </div>");
},
success: function (result) { success: function (result) {
if (result.length !== 0) { if (result.length !== 0) {
$("#todo-list").html(result.map(m => todoComponent(m))); $("#todo-list").html(result.map(m => todoComponent(m)));
} else { } else {
$("#todo-list").html("<div style=\"text-align: center;height: 200px;position: relative;\">\n" + if ($("#search-todo").val() != null && $("#search-todo").val() != "") {
" <p style=\"position: absolute;top:50%;left:50%;color:#777;\"><i class='fa fa-calendar-times-o'></i>&nbsp;Not found or empty</p>\n" + $("#todo-list").html("<div style=\"text-align: center;height: 200px;position: relative;\">\n" +
" </div>"); " <p style=\"position: absolute;top:50%;left:50%;color:#777;\"><i class='fa fa-calendar-times-o'></i>&nbsp;Not found</p>\n" +
" </div>");
} else {
$("#todo-list").html("<div style=\"text-align: center;height: 200px;position: relative;\">\n" +
" <p style=\"position: absolute;top:50%;left:50%;color:#777;\"><i class='fa fa-calendar-times-o'></i>&nbsp;Empty</p>\n" +
" </div>");
}
} }
}, },
error: function (result) { error: function (result) {