Skip to content

Commit

Permalink
add show urgent tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
tranchausky committed Dec 29, 2024
1 parent 1e3b064 commit 2657e73
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 6 deletions.
5 changes: 3 additions & 2 deletions links/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,10 @@ <h4>TODO</h4>

</div>
<div class="row">
<div class="col-sm-3"></div>
<div class="col-sm-4 pb-2">
<!-- <div class="col-sm-0"></div> -->
<div class="col-sm-7 pb-2" id="todo-group-sort">
<button onClick="sortTodoPriority(this)" id="sortTodoPriority" class="btn btn-default">Sort Priority<span id="tt-todo-all"></span></button>
<button onClick="setTodoShowImportant(this)" id="setTodoShowImportant" is_today="false" class="btn btn-default">Show Urgent<span id="tt-todo-important"></span></button>
<button onClick="setTodoToday(this)" id="setTodoToday" is_today="false" class="btn btn-default">Mỗi Ngày<span id="tt-todo-moingay"></span></button>
</div>
<div class="col-sm-5 pb-2">
Expand Down
58 changes: 54 additions & 4 deletions links/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,8 @@ $(document).ready(function () {
//updateTodo(allTaskNew[key]['task'], 'completed', key)
updateTodo({status:'completed',task:allTaskNew[key]['task']}, key);
viewTypeTodoNew();
//set remove select
$('#todo-group-sort button.asc').trigger('click');
}
})
$(document.body).on('click', '.list-todo-completed input[type="checkbox"]', function (event) {
Expand Down Expand Up @@ -572,6 +574,9 @@ function changeTodoToTextArea(){
function setTodoToday(at){
$('#sortTodoPriority').attr('is_desc','false');
$('#sortTodoPriority').removeClass('asc');

$('#setTodoShowImportant').removeClass('asc');
$('#setTodoShowImportant').attr('is_desc','false');

//var todaykey = 'dayli';
var isTrue = $(at).attr('is_today');
Expand All @@ -588,9 +593,40 @@ function setTodoToday(at){
}
viewTypeTodoNew();
}
function setTodoShowImportant(at){
// console.log('run')
$('#sortTodoPriority').attr('is_desc','false');
$('#sortTodoPriority').removeClass('asc');
$('#setTodoToday').removeClass('asc');
$('#setTodoToday').attr('is_desc','false');

//var todaykey = 'dayli';
var isTrue = $(at).attr('is_today');
// console.log(isTrue)
if(isTrue!='false'){
// console.log('run 1')
$(at).attr('is_today','false');
$(at).removeClass('asc');
}else{
// console.log(at)
// console.log('run 2')
$(at).attr('is_today','true');
$(at).addClass('asc');
}
viewTodoShowImportant();
}
function viewTodoShowImportant(){
// console.log('run 2')
if($('#setTodoShowImportant').attr('is_today') == "true"){
viewToDoWithType('.list-todo-new .list-group','priority','urgent',allTaskNew);
}else{
//changeSortTodoWithType('.list-todo-new .list-group','priority_desc',allTaskNew);
changeSortTodo('.list-todo-new .list-group','#sort-todo',allTaskNew);
}
}
function viewTypeTodoNew(){
if($('#setTodoToday').attr('is_today') == "true"){
viewToDoWithType('.list-todo-new .list-group','dayli',allTaskNew);
viewToDoWithType('.list-todo-new .list-group','fors','dayli',allTaskNew);
}else{
//changeSortTodoWithType('.list-todo-new .list-group','priority_desc',allTaskNew);
changeSortTodo('.list-todo-new .list-group','#sort-todo',allTaskNew);
Expand All @@ -600,6 +636,10 @@ function viewTypeTodoNew(){
function sortTodoPriority(at){
$('#setTodoToday').attr('is_today','false');
$('#setTodoToday').removeClass('asc');

$('#setTodoShowImportant').removeClass('asc');
$('#setTodoShowImportant').attr('is_desc','false');

var isTrue = $(this).attr('is_desc');
var typesort = 'priority_desc';
if(isTrue!=true){
Expand Down Expand Up @@ -2752,10 +2792,20 @@ function getListTodoNew() {
//buildListTodoNew(newObjectSort)
changeSortTodo('.list-todo-new .list-group','#sort-todo',newObjectSort);
var listObjectNumberCat = countNumberCategory(newObjectSort, 'fors');
var listObjectNumberCatPriority = countNumberCategory(newObjectSort, 'priority');
// console.log(listObjectNumberCat)
// console.log(newObjectSort)
$('#tt-todo-all').html(' ('+Object.keys(newObjectSort).length+')')
$('#tt-todo-moingay').html(' ('+listObjectNumberCat.dayli+')')

$('#tt-todo-moingay').html(' (0)')
if(listObjectNumberCat.dayli !== undefined){
$('#tt-todo-moingay').html(' ('+listObjectNumberCat.dayli+')')
}

$('#tt-todo-important').html(' (0)')
if(listObjectNumberCatPriority.urgent !== undefined){
$('#tt-todo-important').html(' ('+listObjectNumberCatPriority.urgent+')')
}
})
}

Expand Down Expand Up @@ -2789,10 +2839,10 @@ function changeSortTodoWithType(atShow, stypeSort, allObj){
$(atShow).html(str);
}

function viewToDoWithType(atShow, keyfilter, allObj){
function viewToDoWithType(atShow,keycat, keyfilter, allObj){
//var arrSort = stypeSort.split("_");
// console.log(allObj)
var newObjectSort = onlyWithKeyObj(allObj,'fors', keyfilter);
var newObjectSort = onlyWithKeyObj(allObj,keycat, keyfilter);
// console.log(newObjectSort)
var str = buildListTodo(newObjectSort,'todo')
$(atShow).html(str);
Expand Down

0 comments on commit 2657e73

Please sign in to comment.