代码之家  ›  专栏  ›  技术社区  ›  aggtr

cakephp 3.6.14:在表格中为每一行显示时间计数器

  •  0
  • aggtr  · 技术社区  · 6 年前

    我正在构建任务管理器应用程序。我有一个表,每行代表一个特定用户的任务。每行/任务有3个操作:开始、暂停、停止。我想为每一行显示一个计时器,它将由这些操作触发。

    这是到现在为止的表,我如何使用这些操作更新timer列和启动/暂停/停止计时器?

    <div class="container">
            <table cellpadding="0" cellspacing="0">
                <tr>
                    <th scope="col">Priority</th>
                    <th scope="col">Name</th>
                    <th scope="col">Instructions</th>
                    <th scope="col">Progress</th>
                    <th scope="col">Status</th>
                    <th scope="col">Minutes Running</th>
                    <th scope="col" class="actions"><?= __('Actions') ?></th>
                </tr>
                <tbody class="row_position">
                <?php
    
    
                foreach ($user->tasks_to as $task) { ?>
                    <tr  id="<?php echo $task['id'] ?>">
                        <td><?php echo $task->priority ?></td>
                        <td><?php echo $task->name ?></td>
                        <td><?php echo $task->instructions ?></td>
                        <td><?php echo $task->progress ?></td> 
                        <td><?php echo $task->project_status->status ?></td> 
                        <td><?php echo $this->Session->flash('timer') ?> </td>
                        <td class="actions">
                            <?php if(!$is_admin){echo $this->Html->link(__('Start'), ['controller' => 'Tasks', 'action' => 'start', $task->id]);} ?>
                            <?php if(!$is_admin){echo $this->Html->link(__('Pause'), ['controller' => 'Tasks', 'action' => 'pause', $task->id]); }?>
                            <?php if(!$is_admin){echo $this->Html->link(__('Stop'), ['controller' => 'Tasks', 'action' => 'stop', $task->id]); }?>
                            <?php if($is_admin){echo $this->Html->link(__('View'), ['controller' => 'Tasks', 'action' => 'view', $task->id]);} ?>
                            <?php if($is_admin){echo $this->Html->link(__('Edit'), ['controller' => 'Tasks', 'action' => 'edit', $task->id]);} ?>
                            <?php if($is_admin){echo $this->Form->postLink(__('Delete'), ['controller' => 'Tasks', 'action' => 'delete', $task->id], ['confirm' => __('Are you sure you want to delete # {0}?', $task->id)]);} ?>
                </td>
                    </tr>
                <?php } ?>
                </tbody>
            </table>
    

    这是在控制器视图函数中:

    $this->Session->setFlash('10:23:23(Live timer counting seconds)', 'default', array(), 'timer');
    
    0 回复  |  直到 6 年前