[Rt-commit] rt branch, create-action, updated. 25032fbbecd10322bbe8ac65bc9edee83adee802
sartak at bestpractical.com
sartak at bestpractical.com
Tue Sep 1 06:14:50 EDT 2009
The branch, create-action has been updated
via 25032fbbecd10322bbe8ac65bc9edee83adee802 (commit)
from 8c589ddb4493b6be68fb47a538cc81d4e2268a9a (commit)
Summary of changes:
lib/RT/View/Ticket.pm | 205 +---------------------------
lib/RT/View/{Ticket.pm => Ticket/Links.pm} | 3 +-
2 files changed, 5 insertions(+), 203 deletions(-)
copy lib/RT/View/{Ticket.pm => Ticket/Links.pm} (99%)
- Log -----------------------------------------------------------------
commit 25032fbbecd10322bbe8ac65bc9edee83adee802
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Sep 1 06:14:29 2009 -0400
Refactor View::Ticket into View::Ticket::Links
diff --git a/lib/RT/View/Ticket.pm b/lib/RT/View/Ticket.pm
index 9afff8a..febc351 100644
--- a/lib/RT/View/Ticket.pm
+++ b/lib/RT/View/Ticket.pm
@@ -53,207 +53,8 @@ use Jifty::View::Declare -base;
__PACKAGE__->use_mason_wrapper;
-template '_elements/edit_links' => sub {
- my $ticket = HTML::Mason::Commands::load_ticket( get('id') );
-
- div { { class is 'ticket-links-current' };
- h3 { _("Current Links") };
- my $delete_links = new_action( class => 'DeleteTicketLinks', moniker => 'delete-links' );
- $delete_links->register
- unless Jifty->web->form->is_open; # don't need this if we open form{} with jifty
- render_param( $delete_links => 'id', default_value => $ticket->id, render_as => 'hidden' );
-
- table { tbody {
-
- show( '_edit_link_type', _('Depends on'), 'depends_on', $ticket->depends_on, $delete_links, 'target_uri' );
-
- show( '_edit_link_type', _('Depended on by'), 'depended_on_by', $ticket->depended_on_by, $delete_links, 'base_uri' );
-
- show( '_edit_link_type', _('Parents'), 'member_of', $ticket->member_of, $delete_links, 'target_uri' );
-
- show( '_edit_link_type', _('Children'), 'has_member', $ticket->members, $delete_links, 'base_uri' );
-
- show( '_edit_link_type', _('Refers to'), 'refers_to', $ticket->refers_to, $delete_links, 'target_uri' );
-
- show( '_edit_link_type', _('Referred to by'), 'referred_to_by', $ticket->referred_to_by, $delete_links, 'base_uri' );
-
- row { cell {}; cell { i { _('(Check box to delete)') } } };
- } };
-
- };
-};
-
-private template '_elements/_edit_link_type' => sub {
- my ($self, $label, $type, $collection, $delete_links, $link_target) = @_;
- row {
- cell { { class is 'labeltop' }; $label };
- cell { { class is 'value' };
- while ( my $link = $collection->next ) {
- Jifty::Web::Form::Field->new(
- action => $delete_links,
- name => $type,
- render_as => 'Checkbox',
- value => $link_target =~ /base/
- ? $link->base
- : $link->target,
- checked => 0
- )->render_widget;
- render_mason( '/Elements/ShowLink', { uri => $link->$link_target } );
- br {};
- }
- }
- };
-};
-
-template '_elements/edit_cfs' => sub {
- my ( $ticket, $queue, $cfs );
- my $id = get('id');
- if ( $id && $id ne 'new' ) {
- $ticket = HTML::Mason::Commands::load_ticket( $id );
- $cfs = $ticket->custom_fields;
- }
- elsif ( get('queue') ) {
- my $queue =
- RT::Model::Queue->new( current_user => Jifty->web->current_user );
- $queue->load( get('queue') );
- $cfs = $queue->ticket_custom_fields;
- }
-
- my $edit_cfs = new_action(
- class => 'EditTicketCFs',
- moniker => 'edit-ticket-cfs'
- );
- if ($ticket) {
- render_param(
- $edit_cfs => 'id',
- default_value => $ticket->id,
- render_as => 'hidden',
- );
- }
-
- table {
- tbody {
- while ( my $cf = $cfs->next ) {
- next unless $cf->current_user_has_right('ModifyCustomField');
- row {
- cell {
- { class is 'labeltop' };
- Jifty->web->out( $cf->name );
- br {};
- i { $cf->friendly_type };
- i { $cf->type };
- };
- cell {
- { class is 'value' };
- my $values;
- if ($ticket) {
- $values = $ticket->custom_field_values( $cf->id );
- }
-
- if ( $cf->type =~ /text/ ) {
- if ($values) {
- while ( my $value = $values->next ) {
- Jifty::Web::Form::Field->new(
- action => $edit_cfs,
- name => $cf->id,
- render_as => 'Textarea',
- default_value => $value->content,
- )->render_widget;
- br {};
- }
- }
- if (
- $cf->max_values == 0
- || ( $values
- && $values->count < $cf->max_values )
- || !$values
- )
- {
- Jifty::Web::Form::Field->new(
- action => $edit_cfs,
- name => $cf->id,
- render_as => 'Textarea',
- )->render_widget;
- br {};
- }
- }
- elsif ( $cf->type eq 'Binary' || $cf->type eq 'Image' ) {
- if ($values) {
- while ( my $value = $values->next ) {
- Jifty::Web::Form::Field->new(
- action => $edit_cfs,
- name => 'delete_'
- . $cf->id . '_'
- . $value->id,
- render_as => 'Checkbox',
- )->render_widget;
- Jifty->web->out( $value->content );
- br {};
- }
- }
-
- if (
- $cf->max_values == 0
- || ( $values
- && $values->count < $cf->max_values )
- || !$values
- )
- {
- Jifty::Web::Form::Field->new(
- action => $edit_cfs,
- name => $cf->id,
- render_as => 'Upload',
- )->render_widget;
- br {};
- }
- }
- elsif ( $cf->type eq 'Freeform' ) {
- Jifty::Web::Form::Field->new(
- action => $edit_cfs,
- name => $cf->id,
- render_as => $cf->max_values == 1 ? 'Text'
- : 'Textarea',
- default_value => $values
- ? (
- join "\n",
- map $_->content,
- @{ $values->items_array_ref }
- )
- : '',
- )->render_widget;
- br {};
- }
- elsif ( $cf->type eq 'Select' ) {
- Jifty::Web::Form::Field->new(
- action => $edit_cfs,
- name => $cf->id,
- render_as => 'Select',
- multiple => !$cf->single_value,
- default_value => $values
- ? (
- [
- map $_->content,
- @{ $values->items_array_ref }
- ]
- )
- : '',
- )->render_widget;
- br {};
- }
- elsif ( $cf->type eq 'Combobox' ) {
- Jifty::Web::Form::Field->new(
- action => $edit_cfs,
- name => $cf->id,
- render_as => 'Combobox',
- default_values => $values,
- )->render_widget;
- br {};
- }
- }
- }
- }
- }
- };
-};
+require RT::View::Ticket::Links;
+alias RT::View::Ticket::Links under '/';
1;
+
diff --git a/lib/RT/View/Ticket.pm b/lib/RT/View/Ticket/Links.pm
similarity index 99%
copy from lib/RT/View/Ticket.pm
copy to lib/RT/View/Ticket/Links.pm
index 9afff8a..2e7f939 100644
--- a/lib/RT/View/Ticket.pm
+++ b/lib/RT/View/Ticket/Links.pm
@@ -48,7 +48,7 @@
use warnings;
use strict;
-package RT::View::Ticket;
+package RT::View::Ticket::Links;
use Jifty::View::Declare -base;
__PACKAGE__->use_mason_wrapper;
@@ -257,3 +257,4 @@ template '_elements/edit_cfs' => sub {
};
1;
+
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list