Add work deletion functionality and enhance task popup interactions

This commit is contained in:
2025-02-14 16:03:57 +01:00
parent 65b78d49fd
commit 1a05d881d1
8 changed files with 198 additions and 80 deletions

View File

@@ -165,7 +165,8 @@
});
}
function task_popup( task_id ) {
function task_popup( task_id, open_works_time = false ) {
$.ajax({
url: '/tasks/task_popup/',
type: 'POST',
@@ -175,9 +176,11 @@
success: function( response )
{
$( '.task[task_id="' + task_id + '"]' ).removeClass( 'notopened' );
$( '.task_popup' ).empty().append( response ).show();
$( '.task_popup .checklist ul li input.g-checkbox' ).on( 'change', function(e) {
var action_id = $( this ).parents( 'li' ).attr( 'action_id' );
var status = $( this ).is( ':checked' ) ? 1 : 0;
@@ -195,6 +198,9 @@
}
});
});
if ( open_works_time )
$( '.task_popup .task_details' ).addClass( 'open_works_time' );
}
});
}
@@ -762,6 +768,50 @@
checkedVals.join( "," );
reload_tasks( checkedVals );
});
})
$( 'body' ).on( 'click', '.task_work_details ._work_delete', function(e)
{
var work_id = $( this ).attr( 'work_id' );
var task_id = $( this ).attr( 'task_id' );
$.confirm({
title: 'Potwierdź',
content: 'Na pewno chcesz usunąć wybrane zadanie?',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-close',
typeAnimated: true,
animation: 'opacity',
boxWidth: '500px',
useBootstrap: false,
theme: 'material',
buttons: {
confirm: {
text: 'Usuń',
btnClass: 'btn-red',
action: function(){
$.ajax({
type: 'POST',
cache: false,
url: '/tasks/work_delete/',
data: {
work_id: work_id
},
beforeSend: function() { },
success: function( response ) {
task_popup( task_id, true );
}
});
}
},
cancel: {
text: 'Anuluj',
btnClass: 'btn-default',
action: function(){
}
}
}
});
});
})
</script>

View File

@@ -1,8 +1,8 @@
<div class="task_details" task_id="<?= $this -> task['id'];?>">
<a href="#" class="close"><i class="fa fa-times"></i></a>
<div class="title">
<a href="/tasks/task_edit/task_id=<?= $this -> task['id'];?>">
<i class="fa fa-edit"></i>
<a href="/tasks/task_edit/task_id=<?= $this -> task['id'];?>" class="_edit">
<i class="fa fa-pencil"></i>
</a>
<? if ( $this -> user['id'] == 1 ):?>
<a href="#" class="task-delete" task_id="<?= $this -> task['id'];?>">
@@ -110,6 +110,9 @@
<div class="_line">
<div class="_user"><?= \factory\Users::user_details( $task_work['user_id'] )['name'] . ' ' . \factory\Users::user_details( $task_work['user_id'] )['surname'];?></div>
<input type="text" class="form-control task_work_date_start" task_work_id="<?= $task_work['id'];?>" value="<?= $task_work['date_start'];?>"><span>-</span><input type="text" class="form-control task_work_end" task_work_id="<?= $task_work['id'];?>" value="<?= $task_work['date_end'];?>">
<a href="#" class="_work_delete" work_id="<?= $task_work['id'];?>" task_id="<?= $this -> task['id'];?>">
<i class="fa fa-trash"></i>
</a>
</div>
<? endforeach;?>
</div>