2a9de0dc4243d0c30a22aedd3a7299a97095e7c6

Author: gwoo

Date: 2009-04-16 22:45:21 -0700

updating tickets views

diff --git a/controllers/tickets_controller.php b/controllers/tickets_controller.php index 1798167..8b4e6ed 100755 --- a/controllers/tickets_controller.php +++ b/controllers/tickets_controller.php @@ -23,11 +23,13 @@ class TicketsController extends AppController { var $paginate = array('order' => array('Ticket.number' => 'desc')); function _toNamedArgs($keys) { + $named = array(); foreach ($keys as $key) { if (!empty($this->params['url'][$key])) { - $thie->passedArgs[$key] = $this->params['named'][$key] = join(',', $this->params['url'][$key]); + $this->passedArgs[$key] = $named[$key] = join(',', $this->params['url'][$key]); + } elseif (!empty($this->passedArgs[$key])) { + $this->passedArgs[$key] = $this->params['named'][$key] = null; } - } return $this->params['named']; } @@ -53,7 +55,7 @@ class TicketsController extends AppController { $conditions = array_merge($conditions, (array)$this->postConditions($this->data, '=', 'AND', true)); $this->pageTitle = 'Tickets/Status/'; - $current = null; + $current = $status = $type = $user = null; $isDefault = empty($this->passedArgs); @@ -63,19 +65,24 @@ class TicketsController extends AppController { } if (!empty($this->passedArgs['status'])) { + $status = $this->passedArgs['status']; $current = $this->passedArgs['status']; $conditions['Ticket.status'] = $current; - } + if ($status == 'approved') { + $this->paginate['order'] = 'Ticket.priority ASC'; + } + } if (!empty($this->passedArgs['user'])) { + $user = $this->passedArgs['user']; $current = $this->passedArgs['user']; $conditions['Owner.username'] = $this->passedArgs['user']; $this->pageTitle = 'Tickets/User/'; } - if (!empty($this->passedArgs['type']) && $this->passedArgs['type'] == 'all') { - unset($this->passedArgs['type']); + if (!empty($this->passedArgs['type']) && $this->passedArgs['type'] != 'all') { + $type = $this->passedArgs['type']; } /* if (!empty($this->Project->current['fork'])) { @@ -92,7 +99,7 @@ class TicketsController extends AppController { $tickets = $this->paginate('Ticket', $conditions); $this->Session->write('Ticket.back', '/' . $this->params['url']['url']); - $this->set(compact('current', 'tickets')); + $this->set(compact('current', 'status', 'type', 'user', 'tickets')); $this->_ticketInfo(false); } diff --git a/views/tickets/index.ctp b/views/tickets/index.ctp index 33e1eb3..2dbd8e4 100755 --- a/views/tickets/index.ctp +++ b/views/tickets/index.ctp @@ -1,8 +1,8 @@ <h2> <?php __( Inflector::humanize($current) . - (!empty($this->params['named']['user']) ? "'s" : '') . ' ' . - (!empty($this->params['named']['type']) ? $this->params['named']['type'] : '') + (!empty($user) ? "'s" : '') . ' ' . + (!empty($type) ? join(',', array_map('ucwords', explode(',', $type))) : '') ) ?> <?php __('Tickets') ?> </h2> @@ -30,7 +30,7 @@ <?php $active = null; -if (empty($this->passedArgs['type']) && empty($this->passedArgs['user'])) { +if (!$type && !$user) { $active = array('class' => 'active'); } $links = array( @@ -41,7 +41,7 @@ $links = array( if (!empty($CurrentUser->username)) { $active = null; - if (!empty($this->passedArgs['user']) && $CurrentUser->username == $this->passedArgs['user']) { + if ($CurrentUser->username == $user) { $active = array('class' => 'active'); } $links[] = $html->link(__('mine', true), array_merge($this->passedArgs, array( @@ -49,13 +49,13 @@ if (!empty($CurrentUser->username)) { )), $active); } -foreach ($statuses as $status) { +foreach ($statuses as $state) { $active = null; - if (!empty($this->passedArgs['status']) && $status == $this->passedArgs['status']) { + if ($status == $state) { $active = array('class' => 'active'); } - $links[] = $html->link(__($status, true), array_merge($this->passedArgs, array( - 'status' => $status + $links[] = $html->link(__($state, true), array_merge($this->passedArgs, array( + 'status' => $state )), $active); } echo join(' | ', $links); @@ -78,26 +78,30 @@ if ($this->params['paging']['Ticket']['page'] > 0) { <table class="smooth" cellpadding="0" cellspacing="0"> <tr> <th><?php echo $paginator->sort('#', 'number'); ?></th> - <th><?php echo $paginator->sort(__('Version', true), 'version_id'); ?></th> <th><?php echo $paginator->sort(__('Type', true), 'type'); ?></th> <th><?php echo $paginator->sort(__('Priority', true), 'priority'); ?></th> - <th><?php echo $paginator->sort(__('Reporter', true), 'reporter'); ?></th> - <th><?php echo $paginator->sort(__('Owner', true), 'owner'); ?></th> - <?php if(empty($this->passedArgs['status'])): ?> + <?php if($status != 'closed'): ?> + <th><?php echo $paginator->sort(__('Reporter', true), 'reporter'); ?></th> + <?php endif; ?> + <?php if($status != 'pending'): ?> + <th><?php echo $paginator->sort(__('Owner', true), 'owner'); ?></th> + <?php endif; ?> + <?php if(!$status): ?> <th><?php echo $paginator->sort(__('Status', true),'status');?></th> <?php endif; ?> - <?php if(!empty($this->passedArgs['status']) && $this->passedArgs['status'] == 'closed'): ?> + <?php if($status == 'closed'): ?> <th><?php echo $paginator->sort(__('Resolution', true), 'resolution');?></th> <?php endif; ?> <th class="left"><?php echo $paginator->sort(__('Title',true), 'title');?></th> + <th><?php echo $paginator->sort(__('Version', true), 'version_id'); ?></th> <th><?php echo $paginator->sort(__('Created', true), 'created');?></th> </tr> <?php $i = 0; foreach ($tickets as $ticket): $class = null; - if ($i++ % 2 == 0) { - $class = ' class="altrow"'; + if (++$i % 2 == 0) { + $class = ' class="zebra"'; } ?> <tr<?php echo $class;?>> @@ -108,27 +112,23 @@ foreach ($tickets as $ticket): ); ?> </td> - <td><?php - if (!empty($ticket['Version']['title'])): - echo $html->link($ticket['Version']['title'], array( - 'controller' => 'versions', 'action' => 'view', $ticket['Version']['id'] - )); - endif; ?> - </td> - <td><?php echo $ticket['Ticket']['type']; ?></td> <td><?php echo $ticket['Ticket']['priority']; ?></td> - <td><?php echo $ticket['Reporter']['username']; ?></td> + <?php if($status != 'closed'): ?> + <td><?php echo $ticket['Reporter']['username']; ?></td> + <?php endif; ?> - <td><?php echo $ticket['Owner']['username']; ?></td> + <?php if($status != 'pending'): ?> + <td><?php echo $ticket['Owner']['username']; ?></td> + <?php endif; ?> - <?php if (empty($this->passedArgs['status'])): ?> + <?php if (!$status): ?> <td><?php echo $ticket['Ticket']['status']; ?></td> <?php endif; ?> - <?php if(!empty($this->passedArgs['status']) && $this->passedArgs['status'] == 'closed'): ?> + <?php if($status == 'closed'): ?> <td><?php echo $ticket['Ticket']['resolution'];?></td> <?php endif; ?> @@ -138,6 +138,15 @@ foreach ($tickets as $ticket): array('controller'=> 'tickets', 'action'=>'view', $ticket['Ticket']['number']) ); ?> </td> + + <td><?php + if (!empty($ticket['Version']['title'])): + echo $html->link($ticket['Version']['title'], array( + 'controller' => 'versions', 'action' => 'view', $ticket['Version']['id'] + )); + endif; ?> + </td> + <td nowrap> <?php echo $time->format('m.d.y', $ticket['Ticket']['created']); ?> </td> diff --git a/views/tickets/view.ctp b/views/tickets/view.ctp index 4a2d6e8..419be13 100755 --- a/views/tickets/view.ctp +++ b/views/tickets/view.ctp @@ -27,12 +27,9 @@ $(document).ready(function(){ $(".close").click(function() { $("#modify").hide(); $(".comments").show(); - $("#TicketComment").after($("fieldset.prop")); + $("fieldset.comments > legend").after($("fieldset.prop")); }); - $(".wiki-text").each(function () { - $(this).html(converter.makeHtml(jQuery.trim($(this).text()))) - }); }); '; $javascript->codeBlock($script, array('inline' => false)); @@ -64,7 +61,7 @@ if ($session->check('Ticket.back')) { </div> <span class="date"> - <?php echo $time->timeAgoInWords($ticket['Ticket']['created'], 'm-d-y');?> + <?php echo $time->timeAgoInWords($ticket['Ticket']['created'], 'm.d.y');?> </span> <span class="reporter"> @@ -92,16 +89,20 @@ if ($session->check('Ticket.back')) { <?php __('Modify Ticket');?> <em>(<a href="#" class="close">close</a>)</em> </legend> - <fieldset class="options"> - <?php - echo $form->input('owner', array('empty' => true)); - echo $form->input('type'); - echo $form->input('priority'); - if (!empty($versions)) { - echo $form->input('version_id'); - } - ?> - </fieldset> + <?php if ($ticket['Ticket']['status'] == 'closed'):?> + <fieldset class="options"> + <?php + if (!empty($owners)) { + echo $form->input('owner', array('empty' => true)); + } + echo $form->input('type'); + echo $form->input('priority'); + if (!empty($versions)) { + echo $form->input('version_id'); + } + ?> + </fieldset> + <?php endif; ?> <?php echo $form->input('title',array('label'=> __('Title',true))); echo $form->input('description',array('label'=> __('Description',true))); @@ -135,7 +136,7 @@ if ($session->check('Ticket.back')) { } ?> <span class="date"> - <?php echo $time->timeAgoInWords($comment['created'], 'm-d-y');?> + <?php echo $time->timeAgoInWords($comment['created'], 'm.d.y');?> </span> <span class="user"> by <?php echo $comment['User']['username'];?> @@ -181,8 +182,24 @@ if ($session->check('Ticket.back')) { <fieldset class="comments main"> <legend> - <?php __('Comment');?> + <?php __('Update Ticket');?> </legend> + + <?php if ($ticket['Ticket']['status'] != 'closed'):?> + <fieldset class="options prop"> + <?php + if (!empty($owners)) { + echo $form->input('owner', array('empty' => true)); + } + echo $form->input('type'); + echo $form->input('priority'); + if (!empty($versions)) { + echo $form->input('version_id'); + } + ?> + </fieldset> + <?php endif; ?> + <fieldset class="options"> <?php if ($ticket['Ticket']['status'] == 'closed') { @@ -192,11 +209,16 @@ if ($session->check('Ticket.back')) { echo $form->label('event', __('reopen', true)); } else if (!empty($canUpdate)) { echo $form->input('event', array( - 'label'=> __('Action', true), 'empty' => true, + 'label'=> __('Change status', true), 'empty' => true, )); if (in_array($ticket['Ticket']['status'], array('pending', 'approved', 'in progress'))) { echo $form->input('resolution', array( - 'label'=> __('Or close with', true), 'empty' => true, + 'label'=> __('Or close as', true), 'empty' => true, + )); + } + if (!empty($owners)) { + echo $form->input('owner', array( + 'label'=> __('Set owner to', true), 'empty' => true )); } }