diff --git a/.includepath b/.includepath new file mode 100644 index 0000000..3fcad69 --- /dev/null +++ b/.includepath @@ -0,0 +1,6 @@ + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..884da94 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + otrs-new-ticket-wizard + + + + + + org.epic.perleditor.perlbuilder + + + + + + org.epic.perleditor.perlnature + + diff --git a/CreateOpm.sh b/CreateOpm.sh new file mode 100755 index 0000000..f533983 --- /dev/null +++ b/CreateOpm.sh @@ -0,0 +1,5 @@ +#!/bin/bash +LOCAL="$PWD" +cd /opt/otrs/bin +./otrs.PackageManager.pl -a build -p "$LOCAL"/NewTicketWizard.sopm -o "$LOCAL"/ +cd $LOCAL diff --git a/Kernel/Config/Files/NewTicketWizard.xml b/Kernel/Config/Files/NewTicketWizard.xml new file mode 100644 index 0000000..92ead86 --- /dev/null +++ b/Kernel/Config/Files/NewTicketWizard.xml @@ -0,0 +1,213 @@ + + + + + FrontendModuleRegistration for NewTicketWizard module. + Ticket + Frontend::Customer::ModuleRegistration + + + Module for creating custom new ticket interfaces + NewTicketWizard + + New ticket wizard + New ticket + Action=NewTicketWizard + NewTicketWizard + Menu + 8400 + + + + NewTicketWizard.js + thirdparty/alpaca/alpaca-full.min.js + thirdparty/jquery-ui-1.10.3/jquery-ui.js + thirdparty/jquery-validate-1.11.1/jquery.validate.js + alpaca/alpaca-newticketwizard.css + alpaca/alpaca-jqueryui-newticketwizard.css + + + + + + + Frontend module registration for the agent interface. + Ticket + Frontend::Admin::ModuleRegistration + + + admin + Admin + Service forms + Admin + + Kernel::Output::HTML::NavBarModuleAdmin + Service forms + Create and manage service forms. + Ticket + 900 + + + + + + + Describe the form basic schema. See documentation for examples. + + Descreva o esquema básico do formulário. Veja a documentação para maiores detalhes. + + Ticket + Frontend::Customer::NewTicketWizard + + + + + + + Describe the form basic fields. See documentation for examples. + + Descreva os campos básicos do formulário. Veja a documentação para maiores detalhes. + + Ticket + Frontend::Customer::NewTicketWizard + + + + + + + When the queue comes from a field in the form, a prefix can be attached to the value while searching for the queue. A space is added between this and the queue name. + + Prefixo para ser anexado ao valor do campo que tem a fila para enviar o chamado. Um espaço é adicionado entre o prefixo e o valor o campo. + + Ticket + Frontend::Customer::NewTicketWizard + + Primeiro nível - + + + + + Name of the field in the form which indicates the queue to send the form. + Nome do campo no formulário que indica para qual fila enviar o chamado. + Ticket + Frontend::Customer::NewTicketWizard + + DF_unidade + + + + + Message to let the user choose a server. + Mensagem para o usuário selecionar um serviço. + Ticket + Frontend::Customer::NewTicketWizard + + Escolha o serviço para o qual deseja suporte + + + \ No newline at end of file diff --git a/Kernel/Language/pt_BR_NewTicketWizard.pm b/Kernel/Language/pt_BR_NewTicketWizard.pm new file mode 100644 index 0000000..555b652 --- /dev/null +++ b/Kernel/Language/pt_BR_NewTicketWizard.pm @@ -0,0 +1,32 @@ +# -- +# Kernel/Modules/pt_BR_NewTicketWizard.pm - frontend module for creating custom new ticket interfaces +# Translations +# +# Copyright (C) 2014 (Rodrigo Goncalves) (rodrigo.g@ufsc.br) +# -- +# This software comes with ABSOLUTELY NO WARRANTY. For details, see +# the enclosed file COPYING for license information (AGPL). If you +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. +# -- +package Kernel::Language::pt_BR_NewTicketWizard; + +use strict; +use warnings; + +sub Data { + my $Self = shift; + + $Self->{Translation}->{'Your ticket has been registered with the number: '} = 'Seu chamado foi registrado com sucesso! O número é: '; + $Self->{Translation}->{'New ticket wizard'} = 'Assistente de novo chamado'; + $Self->{Translation}->{'New ticket'} = 'Novo chamado'; + $Self->{Translation}->{'Service forms'} = 'Formulários de serviços'; + $Self->{Translation}->{'Service form'} = 'Formulários de serviço'; + $Self->{Translation}->{'Create and manage service forms.'} = 'Criar e gerenciar formulários de serviços'; + $Self->{Translation}->{'Introduction'} = 'Introdução'; + $Self->{Translation}->{'Form'} = 'Formulário'; + $Self->{Translation}->{'Choose the service to ask for support'} = 'Escolha o serviço para o qual deseja suporte'; + $Self->{Translation}->{'Ticket created'} = 'Chamado criado com sucesso'; + + return 1; +} +1; \ No newline at end of file diff --git a/Kernel/Modules/NewTicketWizard.pm b/Kernel/Modules/NewTicketWizard.pm new file mode 100644 index 0000000..3a6f667 --- /dev/null +++ b/Kernel/Modules/NewTicketWizard.pm @@ -0,0 +1,320 @@ +# -- +# Kernel/Modules/NewTicketWizard.pm - frontend module for creating custom new ticket interfaces +# Copyright (C) 2014 (Rodrigo Goncalves) (rodrigo.g@ufsc.br) +# -- +# This software comes with ABSOLUTELY NO WARRANTY. For details, see +# the enclosed file COPYING for license information (AGPL). If you +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. +# -- +package Kernel::Modules::NewTicketWizard; + +use strict; +use warnings; + +use Kernel::System::ServiceForm; +use Kernel::System::TicketWizard; +use Kernel::System::CustomerUser; +use Kernel::System::State; +use Kernel::System::SystemAddress; +use Kernel::System::Queue; +use Kernel::System::Web::UploadCache; +use Kernel::System::DynamicField; +use Kernel::System::DynamicField::Backend; +use Kernel::System::VariableCheck qw(:all); +use Data::Dumper; + +sub new { + my ( $Type, %Param ) = @_; + + # allocate new hash for object + my $Self = {%Param}; + bless( $Self, $Type ); + + # check needed objects + for ( + qw(ParamObject DBObject TicketObject LayoutObject LogObject QueueObject ConfigObject) + ) + { + if ( !$Self->{$_} ) { + $Self->{LayoutObject}->FatalError( Message => "Got no $_!" ); + } + } + + # needed objects + $Self->{CustomerUserObject} = Kernel::System::CustomerUser->new(%Param); + $Self->{StateObject} = Kernel::System::State->new(%Param); + $Self->{SystemAddress} = Kernel::System::SystemAddress->new(%Param); + $Self->{UploadCacheObject} = Kernel::System::Web::UploadCache->new(%Param); + $Self->{DynamicFieldObject} = Kernel::System::DynamicField->new(%Param); + $Self->{BackendObject} = Kernel::System::DynamicField::Backend->new(%Param); + $Self->{TicketWizard} = Kernel::System::TicketWizard->new(%Param); + $Self->{ServiceFormObject} = Kernel::System::ServiceForm->new(%Param); + $Self->{ServiceObject} = Kernel::System::Service->new(%Param); + + return $Self; +} + +sub Run { + my ( $Self, %Param ) = @_; + my %Data = (); + + # Build service chooser + my %Services = $Self->{ServiceObject}->ServiceList( UserID => $Self->{ConfigObject}->Get('CustomerPanelUserID'), ); + my @ServicesCombo = (); + + for my $serviceID ( keys %Services ) { + if ( grep { index( $Services{$_}, $Services{$serviceID} . "::" ) >= 0 } ( keys %Services ) ) { + my %serv = (); + $serv{Value} = $Services{$serviceID}; + $serv{Key} = $serviceID; + $serv{Disabled} = 1; + push @ServicesCombo, \%serv; + } + else { + my %serv = (); + $serv{Value} = $Services{$serviceID}; + $serv{Key} = $serviceID; + push @ServicesCombo, \%serv; + } + } + + @ServicesCombo = sort { $a->{Value} . "::" cmp $b->{Value} . "::" } @ServicesCombo; + + $Data{ServiceStrg} = $Self->{LayoutObject}->BuildSelection( + Data => \@ServicesCombo, + Name => 'ServiceID', + SelectedID => $Param{ServiceID}, + Class => "Validate_Required " . ( $Param{Errors}->{ServiceIDInvalid} || '' ), + PossibleNone => 1, + TreeView => 1, + Sort => 'TreeView', + Translation => 0, + Max => 200 + ); + $Self->{Config} = $Self->{ConfigObject}->Get("Ticket::Frontend::Customer::NewTicketWizard"); + my $msgChooseService = $Self->{Config}->{"MessageChooseService"}; + $Data{MsgChooseService} = $msgChooseService; + + if ( $Self->{ParamObject}->GetParam( Param => "Subaction" ) ) { + if ( $Self->{ParamObject}->GetParam( Param => "Subaction" ) eq "CreateTicket" ) { + return $Self->CreateTicket(); + } + elsif ( $Self->{ParamObject}->GetParam( Param => "Subaction" ) eq "GetFormJSON" ) { + return $Self->GetFormJSON( ServiceID => $Self->{ParamObject}->GetParam( Param => "ServiceID" ) ); + } + } + else { + my ( $schema, $fields ) = $Self->GetForm(); + + $Data{SchemaForm} = $schema; + $Data{FieldsForm} = $fields; + + # build output + my $Output = + $Self->{LayoutObject} + ->CustomerHeader( Title => $Self->{LayoutObject}->{LanguageObject}->Get("New ticket wizard") ); + + $Output .= $Self->{LayoutObject}->CustomerNavigationBar(); + $Output .= $Self->{LayoutObject}->Output( + Data => \%Data, + TemplateFile => 'NewTicketWizard', + ); + $Output .= $Self->{LayoutObject}->CustomerFooter(); + return $Output; + } +} + +sub GetFormJSON { + my ( $Self, %Param ) = @_; + my %serviceForm; + + if ( $Param{ServiceID} ) { + %serviceForm = $Self->{ServiceFormObject}->GetServiceForm( ServiceID => $Param{ServiceID} ); + } + + my ( $schema, $fields, $introduction ) = $Self->GetForm( ServiceForm => \%serviceForm ); + + return $Self->{LayoutObject}->Attachment( + ContentType => 'application/json; charset=' . $Self->{LayoutObject}->{Charset}, + Content => "[{" . $schema . "}, {" . $fields . "}, \"" . $introduction . "\"]", + Type => 'inline', + NoCache => 1, + ); +} + +sub GetForm { + my ( $Self, %Param ) = @_; + + my $schema = $Self->{TicketWizard}->GetBasicFieldsSchema(); + my $fields = $Self->{TicketWizard}->GetBasicFieldsOptions(); + my $introduction; + + ( $schema, $fields ) = $Self->{TicketWizard}->ReplaceOTRSValues( + Schema => $schema, + Options => $fields, + UserID => $Self->{ConfigObject}->Get('CustomerPanelUserID') + ); + ( $schema, $fields ) = $Self->{TicketWizard}->ReplaceOTRSDynamicFields( Schema => $schema, Options => $fields ); + + if ( !$Param{ServiceForm} ) { + $schema =~ s/CF_SCHEMA//g; + $fields =~ s/CF_FORM//g; + $introduction = ""; + } + else { + my %serviceForm = %{ $Param{ServiceForm} }; + $introduction = $serviceForm{Introduction}; + + if ( !$Param{ServiceForm}{Schema} ) { + $schema =~ s/CF_SCHEMA//g; + $fields =~ s/CF_FORM//g; + } + else { + my $schemaForm = "," . $serviceForm{Schema}; + my $fieldsForm = "," . $serviceForm{Form}; + $schema =~ s/CF_SCHEMA/$schemaForm/g; + $fields =~ s/CF_FORM/$fieldsForm/g; + } + } + + return ( $schema, $fields, $introduction ); +} + +sub GetQueueID() { + my ( $Self, %Param ) = @_; + + # Gets default Queue + my $ConfigTicket = $Self->{ConfigObject}->Get("Ticket::Frontend::CustomerTicketMessage"); + my $ConfigTicketWizard = $Self->{ConfigObject}->Get("Ticket::Frontend::Customer::NewTicketWizard"); + + my $QueueDefault = $ConfigTicket->{"QueueDefault"}; + my $QueueID = $Self->{QueueObject}->QueueLookup( Queue => $QueueDefault ); + my $Queue = $QueueDefault; + + # Checks if there is a field for the queue + print STDERR Dumper($ConfigTicketWizard); + + my $QueuePrefix = $ConfigTicketWizard->{"QueuePrefix"}; + my $QueueField = $ConfigTicketWizard->{"QueueField"}; + $Self->{LogObject}->Log( Priority => 'info', Message => "Searching queue for - $QueuePrefix ($QueueField)!" ); + + if ( $QueuePrefix && $QueueField ) { + + my $QueueSelected = $Self->{ParamObject}->GetParam( Param => $QueueField ); + my $QueueName = "$QueuePrefix $QueueSelected"; + $Self->{LogObject} + ->Log( Priority => 'info', Message => "Searching queue for - $QueuePrefix ($QueueField) - [$QueueName]!" ); + + my %QueueList = reverse $Self->{QueueObject}->QueueList( Valid => 1 ); + + if ( $QueueList{$QueueName} ) { + $QueueID = $QueueList{$QueueName}; + $Queue = $QueueName; + $Self->{LogObject}->Log( Priority => 'info', Message => "Custom queue found - $QueueName ($QueueID)!" ); + } + + } + + return ( $Queue, $QueueID ); +} + +sub CreateTicket { + my ( $Self, %Param ) = @_; + my %Data = (); + + # Queue + my ( $Queue, $QueueID ) = $Self->GetQueueID(%Param); + $Self->{Config} = $Self->{ConfigObject}->Get("Ticket::Frontend::CustomerTicketMessage"); + + my $TicketID = $Self->{TicketObject}->TicketCreate( + Title => $Self->{ParamObject}->GetParam( Param => "subject" ), + QueueID => $QueueID, + Priority => $Self->{Config}->{PriorityDefault}, + Lock => 'unlock', + State => 'new', + ServiceID => $Self->{ParamObject}->GetParam( Param => "service" ), + TypeID => $Self->{ParamObject}->GetParam( Param => "type" ), + CustomerID => $Self->{UserCustomerID}, + CustomerUser => $Self->{UserLogin}, + OwnerID => $Self->{ConfigObject}->Get('CustomerPanelUserID'), + UserID => $Self->{ConfigObject}->Get('CustomerPanelUserID'), + ); + + my $MimeType = 'text/plain'; + my $serviceFields = "\n\n"; + + # Service Fields + for ( $Self->{ParamObject}->GetParamNames() ) { + if ( substr( $_, 0, 3 ) eq "SF_" ) { + $serviceFields .= substr( $_, 3 ) . " = " . $Self->{ParamObject}->GetParam( Param => $_ ) . "\n"; + } + } + + # Dynamic Fields + for ( $Self->{ParamObject}->GetParamNames() ) { + if ( substr( $_, 0, 3 ) eq "DF_" ) { + my $Success = $Self->{BackendObject}->ValueSet( + DynamicFieldConfig => $Self->{DynamicFieldObject}->DynamicFieldGet( Name => substr( $_, 3 ) ), + ObjectID => $TicketID, + Value => $Self->{ParamObject}->GetParam( Param => $_ ), + UserID => $Self->{ConfigObject}->Get('CustomerPanelUserID'), + ); + } + } + + # Create article + my $FullName = $Self->{CustomerUserObject}->CustomerName( UserLogin => $Self->{UserLogin}, ); + my $From = "\"$FullName\" <$Self->{UserEmail}>"; + my $ArticleID = $Self->{TicketObject}->ArticleCreate( + TicketID => $TicketID, + ArticleType => $Self->{Config}->{ArticleType}, + SenderType => $Self->{Config}->{SenderType}, + From => $From, + To => $Queue, + Subject => $Self->{ParamObject}->GetParam( Param => "subject" ), + Body => $Self->{ParamObject}->GetParam( Param => "description" ) . $serviceFields, + MimeType => $MimeType, + Charset => $Self->{LayoutObject}->{UserCharset}, + UserID => $Self->{ConfigObject}->Get('CustomerPanelUserID'), + HistoryType => $Self->{Config}->{HistoryType}, + HistoryComment => $Self->{Config}->{HistoryComment} || '%%', + AutoResponseType => ( $Self->{ConfigObject}->Get('AutoResponseForWebTickets') ) + ? 'auto reply' + : '', + OrigHeader => { + From => $From, + To => $Queue, + Subject => $Self->{ParamObject}->GetParam( Param => "subject" ), + Body => $Self->{ParamObject}->GetParam( Param => "description" ), + }, + Queue => $Queue, + ); + + # Attachments + my %UploadStuff = $Self->{ParamObject}->GetUploadAll( Param => "attachment" ); + + # if (%UploadStuff) { + # print STDERR "\nTem anexo!\n"; + $Self->{TicketObject}->ArticleWriteAttachment( + %UploadStuff, + ArticleID => $ArticleID, + UserID => $Self->{ConfigObject}->Get('CustomerPanelUserID'), + ); + + # } + + $Data{TicketNumber} = $Self->{TicketObject}->TicketNumberLookup( TicketID => $TicketID ); + + # build output + my $Output = $Self->{LayoutObject}->CustomerHeader( Title => "Ticket created" ); + $Output .= $Self->{LayoutObject}->CustomerNavigationBar(); + $Output .= $Self->{LayoutObject}->Output( + Data => \%Data, + TemplateFile => 'NewTicketWizardTicketCreated', + ); + $Output .= $Self->{LayoutObject}->CustomerFooter(); + return $Output; + +} + +1; diff --git a/Kernel/Modules/NewTicketWizardServiceForm.pm b/Kernel/Modules/NewTicketWizardServiceForm.pm new file mode 100644 index 0000000..a47aede --- /dev/null +++ b/Kernel/Modules/NewTicketWizardServiceForm.pm @@ -0,0 +1,151 @@ +# -- +# Kernel/Modules/NewTicketWizard.pm - frontend module for customizing service forms +# Copyright (C) 2014 (Rodrigo Goncalves) (rodrigo.g@ufsc.br) +# -- +# This software comes with ABSOLUTELY NO WARRANTY. For details, see +# the enclosed file COPYING for license information (AGPL). If you +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. +# -- +package Kernel::Modules::NewTicketWizardServiceForm; + +use strict; +use warnings; + +use Kernel::System::VariableCheck qw(:all); +use Data::Dumper; +use Kernel::System::ServiceForm; +use Kernel::System::Service; + +# TODO: Traducoes + +sub new { + my ( $Type, %Param ) = @_; + + # allocate new hash for object + my $Self = {%Param}; + bless( $Self, $Type ); + + # check needed objects + for ( + qw(ParamObject DBObject LayoutObject LogObject ConfigObject) + ) + { + if ( !$Self->{$_} ) { + $Self->{LayoutObject}->FatalError( Message => "Got no $_!" ); + } + } + + # needed objects + $Self->{SystemAddress} = Kernel::System::SystemAddress->new(%Param); + $Self->{BackendObject} = Kernel::System::DynamicField::Backend->new(%Param); + $Self->{ServiceObject} = Kernel::System::Service->new(%Param); + $Self->{ServiceFormObject} = Kernel::System::ServiceForm->new(%Param); + + return $Self; +} + +sub Run { + + my ( $Self, %Param ) = @_; + my %Data = (); + + if ( $Self->{ParamObject}->GetParam( Param => "Subaction" ) ) { + if ( $Self->{Subaction} eq 'ServiceEdit' ) { + + # header + my $Output = $Self->{LayoutObject}->Header(); + $Output .= $Self->{LayoutObject}->NavigationBar(); + + my %serviceForm = + $Self->{ServiceFormObject} + ->GetServiceForm( ServiceID => $Self->{ParamObject}->GetParam( Param => "ServiceID" ) ); + + $Data{Introduction} = $serviceForm{Introduction}; + $Data{Form} = $serviceForm{Form}; + $Data{Schema} = $serviceForm{Schema}; + $Data{ServiceID} = $Self->{ParamObject}->GetParam( Param => "ServiceID" ); + + $Output .= $Self->{LayoutObject}->Output( + Data => \%Data, + TemplateFile => 'NewTicketWizardServiceFormEdit', + ); + + # html output + $Output .= $Self->{LayoutObject}->Footer(); + + return $Output; + } + elsif ( $Self->{Subaction} eq 'ServiceSave' ) { + + # header + my $Output = $Self->{LayoutObject}->Header(); + $Output .= $Self->{LayoutObject}->NavigationBar(); + + $Self->{ServiceFormObject}->SaveServiceForm( + ServiceID => $Self->{ParamObject}->GetParam( Param => "ServiceID" ), + Introduction => $Self->{ParamObject}->GetParam( Param => "Introduction" ), + Form => $Self->{ParamObject}->GetParam( Param => "Form" ), + Schema => $Self->{ParamObject}->GetParam( Param => "Schema" ), + ); + + return $Self->Overview(); + } + } + else { + return $Self->Overview(); + } +} + +sub Overview { + + my ( $Self, %Param ) = @_; + + my %Data = (); + + # build output + $Self->{LayoutObject}->Block( + Name => 'Overview', + Data => { %Param, }, + ); + + $Self->{LayoutObject}->Block( + Name => 'OverviewList', + Data => { %Param, }, + ); + + # get service list + my $ServiceList = $Self->{ServiceObject}->ServiceListGet( + Valid => 1, + UserID => $Self->{UserID}, + ); + + # if there are any services defined, they are shown + if ( @{$ServiceList} ) { + + # sort the service list by long service name + @{$ServiceList} = sort { $a->{Name} . '::' cmp $b->{Name} . '::' } @{$ServiceList}; + + for my $ServiceData ( @{$ServiceList} ) { + if (! grep { index($_->{Name}, $ServiceData->{Name} . "::") >= 0} @{$ServiceList} ) { + + # output row + $Self->{LayoutObject}->Block( + Name => 'OverviewListRow', + Data => { %{$ServiceData} }, + ); + } + } + } + + my $Output = $Self->{LayoutObject}->Header( Title => $Self->{LayoutObject}->{LanguageObject}->Get("Service Form") ); + + $Output .= $Self->{LayoutObject}->NavigationBar(); + $Output .= $Self->{LayoutObject}->Output( + Data => \%Data, + TemplateFile => 'NewTicketWizardServiceForm', + ); + $Output .= $Self->{LayoutObject}->Footer(); + return $Output; +} + +1; diff --git a/Kernel/Output/HTML/Standard/NewTicketWizard.dtl b/Kernel/Output/HTML/Standard/NewTicketWizard.dtl new file mode 100644 index 0000000..8420748 --- /dev/null +++ b/Kernel/Output/HTML/Standard/NewTicketWizard.dtl @@ -0,0 +1,42 @@ +# -- +# Kernel/Output/HTML/Standard/NewTicketWizard.dtl - template for new ticket wizard +# Copyright (C) (2014) (Rodrigo Goncalves) (rodrigo.g@ufsc.br) +# -- +# This software comes with ABSOLUTELY NO WARRANTY. For details, see +# the enclosed file COPYING for license information (AGPL). If you +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. +# -- + +
+$Data{"MsgChooseService"} +
+
+ +
+ $Text{"Service"}: +
+ $Data{"ServiceStrg"} +
+
+ +
+
+
+ + + + diff --git a/Kernel/Output/HTML/Standard/NewTicketWizardServiceForm.dtl b/Kernel/Output/HTML/Standard/NewTicketWizardServiceForm.dtl new file mode 100644 index 0000000..475f5e5 --- /dev/null +++ b/Kernel/Output/HTML/Standard/NewTicketWizardServiceForm.dtl @@ -0,0 +1,47 @@ +# -- +# NewTicketWizardServiceForm.dtl - provides HTML form for NewTicketWizardServiceForm +# Copyright (C) 2014 UFSC +# -- +# This software comes with ABSOLUTELY NO WARRANTY. For details, see +# the enclosed file COPYING for license information (AGPL). If you +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. +# -- + + +
+

$Text{"Service forms"}

+ + +
+
+ +
+ + + + + + + + + + + + + + + + + + + +
$Text{"Service"}
+ $Text{"No data found."} +
$QData{"LevelSpace"}$QData{"Name", "80"}
+
+ +
+
+
+
+ \ No newline at end of file diff --git a/Kernel/Output/HTML/Standard/NewTicketWizardServiceFormEdit.dtl b/Kernel/Output/HTML/Standard/NewTicketWizardServiceFormEdit.dtl new file mode 100644 index 0000000..f5e44af --- /dev/null +++ b/Kernel/Output/HTML/Standard/NewTicketWizardServiceFormEdit.dtl @@ -0,0 +1,51 @@ +# -- +# NewTicketWizardServiceForm.dtl - provides HTML form for NewTicketWizardServiceForm +# Copyright (C) 2014 UFSC +# -- +# This software comes with ABSOLUTELY NO WARRANTY. For details, see +# the enclosed file COPYING for license information (AGPL). If you +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. +# -- + + + +

$Text{"Edit Service"} : $QData{"Name"}

+ + +
+ +
+ + + + +
+ + +
+ +
+
+ + +
+ +
+
+ + +
+ +
+
+ +
+ + $Text{"or"} + $Text{"Cancel"} +
+
+
+ +
+
diff --git a/Kernel/Output/HTML/Standard/NewTicketWizardTicketCreated.dtl b/Kernel/Output/HTML/Standard/NewTicketWizardTicketCreated.dtl new file mode 100644 index 0000000..dc923bf --- /dev/null +++ b/Kernel/Output/HTML/Standard/NewTicketWizardTicketCreated.dtl @@ -0,0 +1,13 @@ +# -- +# Kernel/Output/HTML/Standard/NewTicketWizard.dtl - template for new ticket wizard +# Copyright (C) (2013) (Rodrigo Goncalves) (rodrigo.g@ufsc.br) +# -- +# This software comes with ABSOLUTELY NO WARRANTY. For details, see +# the enclosed file COPYING for license information (AGPL). If you +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. +# -- +
+

$Text{"Your ticket has been registered with the number: "}$Data{"TicketNumber"}

+
+ + \ No newline at end of file diff --git a/Kernel/System/ServiceForm.pm b/Kernel/System/ServiceForm.pm new file mode 100644 index 0000000..2431a5a --- /dev/null +++ b/Kernel/System/ServiceForm.pm @@ -0,0 +1,109 @@ +# -- +# Kernel/System/ServiceForm.pm - core module +# Copyright (C) (2013) (Rodrigo Goncalves) (rodrigo.g@ufsc.br) +# -- +# This software comes with ABSOLUTELY NO WARRANTY. For details, see +# the enclosed file COPYING for license information (AGPL). If you +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. +# -- +package Kernel::System::ServiceForm; + +use strict; +use warnings; +use utf8; +use Kernel::System::Service; +use Kernel::System::Type; +use Kernel::System::YAML; +use Data::Dumper; +use Kernel::System::DynamicField; + +sub new { + my ( $Type, %Param ) = @_; + + # allocate new hash for object + my $Self = {%Param}; + bless( $Self, $Type ); + + # check needed objects + for ( + qw(DBObject LayoutObject LogObject QueueObject ConfigObject) + ) + { + if ( !$Self->{$_} ) { + $Self->{LayoutObject}->FatalError( Message => "Got no $_!" ); + } + } + + # required objects + + return $Self; +} + +=head + +Returns a service form + +=cut + +sub GetServiceForm { + + my ( $Self, %Param ) = @_; + + # get service form from db + $Self->{DBObject}->Prepare( + SQL => 'SELECT service_id, introduction, form, form_schema FROM service_form WHERE service_id = ?', + Bind => [ \$Param{ServiceID} ], + Limit => 1, + ); + + # fetch the result + my %ServiceData; + while ( my @Row = $Self->{DBObject}->FetchrowArray() ) { + $ServiceData{ServiceID} = $Row[0]; + $ServiceData{Introduction} = $Row[1]; + $ServiceData{Form} = $Row[2]; + $ServiceData{Schema} = $Row[3]; + } + + return %ServiceData; +} + +=head + +Saves a service form. + +=cut + +sub SaveServiceForm { + + my ( $Self, %Param ) = @_; + for my $Argument (qw(ServiceID Introduction)) { + if ( !$Param{$Argument} ) { + $Self->{LogObject}->Log( + Priority => 'error', + Message => "Need $Argument!", + ); + return; + } + } + + my %serviceForm = $Self->GetServiceForm(ServiceID => $Param{ServiceID}); + my $update = ($serviceForm{ServiceID}); + + if ($update) { + $Self->{DBObject}->Do(SQL => 'UPDATE service_form SET introduction=?,form=?,form_schema=? where service_id=?', + Bind => [ + \$Param{Introduction}, \$Param{Form}, \$Param{Schema}, \$Param{ServiceID} + ]); + } else { + $Self->{DBObject}->Do(SQL => 'INSERT INTO service_form(service_id,introduction,form,form_schema) VALUES (?,?,?,?)', + Bind => [ + \$Param{ServiceID}, \$Param{Introduction}, \$Param{Form}, \$Param{Schema} + ]); + } + + return 1; + +} + +1; diff --git a/Kernel/System/TicketWizard.pm b/Kernel/System/TicketWizard.pm new file mode 100644 index 0000000..4036f0f --- /dev/null +++ b/Kernel/System/TicketWizard.pm @@ -0,0 +1,183 @@ +# -- +# Kernel/System/TicketWizard.pm - core module +# Copyright (C) (2013) (Rodrigo Goncalves) (rodrigo.g@ufsc.br) +# -- +# This software comes with ABSOLUTELY NO WARRANTY. For details, see +# the enclosed file COPYING for license information (AGPL). If you +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. +# -- +package Kernel::System::TicketWizard; + +use strict; +use warnings; +use utf8; +use Kernel::System::Service; +use Kernel::System::Type; +use Kernel::System::YAML; +use Data::Dumper; +use Kernel::System::DynamicField; + +sub new { + my ( $Type, %Param ) = @_; + + # allocate new hash for object + my $Self = {%Param}; + bless( $Self, $Type ); + + # check needed objects + for ( + qw(DBObject LayoutObject LogObject QueueObject ConfigObject) + ) + { + if ( !$Self->{$_} ) { + $Self->{LayoutObject}->FatalError( Message => "Got no $_!" ); + } + } + + # required objects + $Self->{YAMLObject} = Kernel::System::YAML->new(%Param); + $Self->{ServiceObject} = Kernel::System::Service->new(%Param); + $Self->{TypeObject} = Kernel::System::Type->new(%Param); + $Self->{TicketObject} = Kernel::System::Ticket->new(%Param); + $Self->{DynamicFieldObject} = Kernel::System::DynamicField->new(%Param); + + return $Self; +} + +=head + +Returns fields structure for new ticket form wizard + +=cut + +sub GetBasicFieldsOptions { + my ( $Self, %Param ) = @_; + return $Self->{ConfigObject}->Get("Ticket::Frontend::Customer::NewTicketWizard")->{BasicForm}; +} + +=head + +Returns fields schema for new ticket wizard + +=cut + +sub GetBasicFieldsSchema { + my ( $Self, %Param ) = @_; + return $Self->{ConfigObject}->Get("Ticket::Frontend::Customer::NewTicketWizard")->{BasicSchema}; +} + +=head + +Replaces OTRS system field values (service and type) + +=cut + +sub ReplaceOTRSValues { + my ( $Self, %Param ) = @_; + my $schema = $Param{Schema}; + my $options = $Param{Options}; + + my ( $serviceNames, $serviceIDs ) = $Self->GetOTRSServicesData(); + $schema =~ s/OTRS_service_values/$serviceIDs/g; + $options =~ s/OTRS_service_labels/$serviceNames/g; + + my ( $typeNames, $typeIDs ) = $Self->GetOTRSTypesData(UserID => $Param{UserID}); + $schema =~ s/OTRS_type_values/$typeIDs/g; + $options =~ s/OTRS_type_labels/$typeNames/g; + + return ( $schema, $options ); +} + +sub GetOTRSServicesData { + my ( $Self, %Param ) = @_; + my $services = $Self->{ServiceObject}; + + my %serviceList = $services->ServiceList( Valid => 1, UserID => $Self->{ConfigObject}->Get('CustomerPanelUserID') ); + my $serviceNames = ""; + my $serviceIDs = ""; + + ###print STDERR "\n\n\n Servicos: " . Dumper(\%serviceList) . "\n\n\n"; + + foreach ( sort { ( $serviceList{$a} cmp $serviceList{$b} ) } keys %serviceList ) { + $serviceNames .= "\"$serviceList{$_}\","; + $serviceIDs .= "$_,"; + } + $serviceNames = substr($serviceNames, 0, -1); + $serviceIDs = substr($serviceIDs, 0, -1); + return ( $serviceNames, $serviceIDs ); +} + +sub GetOTRSTypesData { + my ( $Self, %Param ) = @_; + my $ticketObject = $Self->{TicketObject}; + + my %typeList = $ticketObject->TicketTypeList( UserID => $Param{UserID} ); + my $typeNames = ""; + my $typeIDs = ""; + + foreach ( sort { ( $typeList{$a} cmp $typeList{$b} ) } keys %typeList ) { + $typeNames .= "\"$typeList{$_}\","; + $typeIDs .= "$_,"; + } + + $typeNames = substr($typeNames, 0, -1); + $typeIDs = substr($typeIDs, 0, -1); + + return ( $typeNames, $typeIDs ); +} + +sub ReplaceOTRSDynamicFields { + my ( $Self, %Param ) = @_; + my $schema = $Param{Schema}; + my $options = $Param{Options}; + + my $dfields = $Self->{DynamicFieldObject}; + my @dfieldList = @{ $dfields->DynamicFieldListGet( Valid => 1 ) }; + + foreach (@dfieldList) { + my $campo = $_; + + #Debug("campo", $campo); + my $name = $campo->{Name}; + my $config = $campo->{Config}; + my $type = $campo->{FieldType}; + my $idFieldValues = "DF_" . $name . "_values"; + my $idFieldLabels = "DF_" . $name . "_labels"; + if ( $type eq "Dropdown" ) { + my ( $dfValues, $dfLabels ) = $Self->GetDynamicFieldValues( ConfigDF => $config ); + $schema =~ s/$idFieldValues/$dfValues/g; + $options =~ s/$idFieldLabels/$dfLabels/g; + } + } + + #Debug("schema", $schema); + #Debug("options", $options); + return ( $schema, $options ); +} + +sub Debug { + my ( $id, $value ) = @_; + ###print STDERR "\n\n $id =" . Dumper($value) . "\n"; +} + +sub GetDynamicFieldValues { + my ( $Self, %Param ) = @_; + my $config = $Param{ConfigDF}; + my $values = $config->{PossibleValues}; + + my $dfValues = ""; + my $dfLabels = ""; + + foreach ( sort { ( $values->{$a} cmp $values->{$b} ) } keys %{$values} ) { + $dfValues .= "\"$_\","; + $dfLabels .= "\"$values->{$_}\","; + } + + $dfValues = substr($dfValues, 0, -1); + $dfLabels = substr($dfLabels, 0, -1); + Debug( "dfvalues", $dfValues ); + return ( $dfValues, $dfLabels ); + +} + +1; diff --git a/NewTicketWizard.sopm b/NewTicketWizard.sopm new file mode 100755 index 0000000..49f722c --- /dev/null +++ b/NewTicketWizard.sopm @@ -0,0 +1,64 @@ + + + NewTicketWizard + 1.0.5 + 3.x.x + SeTIC + http://www.setic.ufsc.br + Free + Assistente de chamados + + Versão 1.0.0 - Inicial + Versão 1.0.1 - Ajusta listagem de servicos do Service forms, correcao no formulario de edicao de servico + Versão 1.0.2 - Ajuste na hierarquia de servicos + + Módulo instalado com sucesso! + New Ticket Wizard + New Ticket Wizard module installed successfully! + ? + ? + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/db_schema.sql b/db_schema.sql new file mode 100644 index 0000000..1b44a6b --- /dev/null +++ b/db_schema.sql @@ -0,0 +1 @@ +CREATE TABLE service_form(service_id int primary key, introduction text, form text, form_schema text); \ No newline at end of file diff --git a/var/httpd/htdocs/js/NewTicketWizard.js b/var/httpd/htdocs/js/NewTicketWizard.js new file mode 100644 index 0000000..c1293b3 --- /dev/null +++ b/var/httpd/htdocs/js/NewTicketWizard.js @@ -0,0 +1,111 @@ +/** + * Variables + */ + +var formAlpaca; + + +/** + * Build the form options (layout) + * @param fields + * @param sendText + * @returns {___anonymous58_421} + */ +function buildOptions(fields, sendText, action) { + return { + "renderForm": true, + "fields": fields, + "form": { + "attributes" : { + "action" : action, + "method" : "post", + "enctype": "multipart/form-data" + }, + "buttons": { + "submit": { + "value" : sendText + } + }, + "toggleSubmitValidState": false + + } + }; +} + +/** + * Build the form schema + * + * @param schema + * @returns {___anonymous510_571} + */ +function buildSchema(schema) { + return { + "type": "object", + "properties": schema + }; +} + +var postRenderCallback = function(form) { + formOptions = form.options.fields; + formAlpaca = form; + + Object.keys(formOptions).forEach(function (key) { + var value = formOptions[key]; + + // Extension to set control width + if (value["control_width"]) { + $("[name='" + key + "']").width(value["control_width"]); + } + }); + + if (form) { + form.form.registerSubmitHandler(function(e, form) { + // validate the entire form (top control + all children) + form.validate(true); + + // draw the validation state (top control + all children) + form.renderValidationState(true); + + // now display something + if (form.isFormValid()) { + return true; + } else { + return false; + } + e.stopPropagation(); + return false; + }); + } +}; + +function carregaForm(dataForm, sendText, action) { + var url = "/otrs/customer.pl?Action=NewTicketWizard;Subaction=GetFormJSON"; + + if (!(typeof formAlpaca === 'undefined')) { + formAlpaca.destroy(); + } else { + //$("#formTicket").find("select").val(""); + } + + url += ";ServiceID=" + $("#ServiceID").val(); + + $.getJSON(url, function(data) { + ////formOptions = data[1]; + $("#serviceDescription").html(data[2]); + $("#serviceDescription").show(); + + $("#formTicket").alpaca({ + "data": dataForm, + "schema": buildSchema(data[0]), + "options": buildOptions(data[1], sendText, action), + "postRender": postRenderCallback, + "view": "VIEW_JQUERYUI_CREATE", + "ui": "jquery-ui" + }); + + $("[name='service']").val($("#ServiceID").val()); + + }).fail(function(jqXHR, textStatus, errorThrown) { + alert(textStatus); + }); +} diff --git a/var/httpd/htdocs/js/thirdparty/alpaca/alpaca-full.min.js b/var/httpd/htdocs/js/thirdparty/alpaca/alpaca-full.min.js new file mode 100644 index 0000000..a475964 --- /dev/null +++ b/var/httpd/htdocs/js/thirdparty/alpaca/alpaca-full.min.js @@ -0,0 +1,72 @@ +/*! +Alpaca Version 1.1.1 + +Copyright 2013 Gitana Software, Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. + +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +For more information, please contact Gitana Software, Inc. at this +address: + + info@gitanasoftware.com +*/ +(function(a,c,b){c[a]=b()})("Base",this,function(){var a=function(){};a.extend=function(c,f){var g=a.prototype.extend;a._prototyping=true;var e=new this();g.call(e,c);e.base=function(){};delete a._prototyping;var d=e.constructor;var b=e.constructor=function(){if(!a._prototyping){if(this._constructing||this.constructor===b){this._constructing=true;d.apply(this,arguments);delete this._constructing}else{if(arguments[0]!==null){return(arguments[0].extend||g).call(arguments[0],e)}}}};b.ancestor=this;b.extend=this.extend;b.forEach=this.forEach;b.implement=this.implement;b.prototype=e;b.toString=this.toString;b.valueOf=function(h){return(h==="object")?b:d.valueOf()};g.call(b,f);if(typeof b.init==="function"){b.init()}return b};a.prototype={extend:function(c,l){if(arguments.length>1){var g=this[c];if(g&&(typeof l==="function")&&(!g.valueOf||g.valueOf()!==l.valueOf())&&/\bbase\b/.test(l)){var b=l.valueOf();l=function(){var i=this.base||a.prototype.base;this.base=g;var h=b.apply(this,arguments);this.base=i;return h};l.valueOf=function(h){return(h==="object")?l:b};l.toString=a.toString}this[c]=l}else{if(c){var k=a.prototype.extend;if(!a._prototyping&&typeof this!=="function"){k=this.extend||k}var f={toSource:null};var j=["constructor","toString","valueOf"];for(var d=a._prototyping?0:1;dn.maxItems){w("There must be a maximum of "+n.maxItems+" in the array")}}else{if(n.properties||n.additionalProperties){h.concat(e(r,n.properties,v,n.additionalProperties))}}if(n.pattern&&typeof r=="string"&&!r.match(n.pattern)){w("does not match the regex pattern "+n.pattern)}if(n.maxLength&&typeof r=="string"&&r.length>n.maxLength){w("may only be "+n.maxLength+" characters long")}if(n.minLength&&typeof r=="string"&&r.lengthr){w("must have a minimum value of "+n.minimum)}if(typeof n.maximum!==undefined&&typeof r==typeof n.maximum&&n.maximum)[^>]*$|\{\{\! /,p={},e={},y,x={key:0,data:{}},w=0,q=0,g=[];function k(B,A,D,E){var C={data:E||(E===0||E===false)?E:(A?A.data:{}),_wrap:A?A._wrap:null,tmpl:null,parent:A||null,nodes:[],calls:c,nest:b,wrap:n,html:r,update:z};if(B){i.extend(C,B,{nodes:[],parent:A})}if(D){C.tmpl=D;C._ctnt=C._ctnt||C.tmpl(i,C);C.key=++w;(g.length?e:p)[w]=C}return C}i.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(A,B){i.fn[A]=function(C){var F=[],I=i(C),E,G,D,J,H=this.length===1&&this[0].parentNode;y=p||{};if(H&&H.nodeType===11&&H.childNodes.length===1&&I.length===1){I[B](this[0]);F=this}else{for(G=0,D=I.length;G0?this.clone(true):this).get();i(I[G])[B](E);F=F.concat(E)}q=0;F=this.pushStack(F,A,I.selector)}J=y;y=null;i.tmpl.complete(J);return F}});i.fn.extend({tmpl:function(C,B,A){return i.tmpl(this[0],C,B,A)},tmplItem:function(){return i.tmplItem(this[0])},template:function(A){return i.template(A,this[0])},domManip:function(E,H,G,I){if(E[0]&&i.isArray(E[0])){var B=i.makeArray(arguments),A=E[0],F=A.length,C=0,D;while(C").join(">").split('"').join(""").split("'").join("'")}});i.extend(i.tmpl,{tag:{tmpl:{_default:{$2:"null"},open:"if($notnull_1){__=__.concat($item.nest($1,$2));}"},wrap:{_default:{$2:"null"},open:"$item.calls(__,$1,$2);__=[];",close:"call=$item.calls();__=call._.concat($item.wrap(call,__));"},each:{_default:{$2:"$index, $value"},open:"if($notnull_1){$.each($1a,function($2){with(this){",close:"}});}"},"if":{open:"if(($notnull_1) && $1a){",close:"}"},"else":{_default:{$1:"true"},open:"}else if(($notnull_1) && $1a){"},html:{open:"if($notnull_1){__.push($1a);}"},"=":{_default:{$1:"$data"},open:"if($notnull_1){__.push($.encode($1a));}"},"!":{open:""}},complete:function(A){p={}},afterManip:function v(C,A,D){var B=A.nodeType===11?i.makeArray(A.childNodes):A.nodeType===1?[A]:[];D.call(C,A);o(B);q++}});function m(A,E,C){var D,B=C?i.map(C,function(F){return(typeof F==="string")?(A.key?F.replace(/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g,"$1 "+h+'="'+A.key+'" $2'):F):m(F,A,F._ctnt)}):A;if(E){return B}B=B.join("");B.replace(/^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/,function(G,H,F,I){D=i(F).get();o(D);if(H){D=a(H).concat(D)}if(I){D=D.concat(a(I))}});return D?D:a(B)}function a(B){var A=document.createElement("div");A.innerHTML=B;return i.makeArray(A.childNodes)}function l(A){return new Function("jQuery","$item","var $=jQuery,call,__=[],$data=$item.data;with($data){__.push('"+i.trim(A).replace(/([\\'])/g,"\\$1").replace(/[\r\t\n]/g," ").replace(/\$\{([^\}]*)\}/g,"{{= $1}}").replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,function(I,C,G,D,E,J,F){var L=i.tmpl.tag[G],B,H,K;if(!L){throw"Unknown template tag: "+G}B=L._default||[];if(J&&!/\w$/.test(E)){E+=J;J=""}if(E){E=j(E);F=F?(","+j(F)+")"):(J?")":"");H=J?(E.indexOf(".")>-1?E+j(J):("("+E+").call($item"+F)):E;K=J?H:"(typeof("+E+")==='function'?("+E+").call($item):("+E+"))"}else{K=H=B.$1||"null"}D=j(D);return"');"+L[C?"close":"open"].split("$notnull_1").join(E?"typeof("+E+")!=='undefined' && ("+E+")!=null":"true").split("$1a").join(K).split("$1").join(H).split("$2").join(D||B.$2||"")+"__.push('"})+"');}return __;")}function s(B,A){B._wrap=m(B,true,i.isArray(A)?A:[u.test(A)?A:i(A).html()]).join("")}function j(A){return A?A.replace(/\\'/g,"'").replace(/\\\\/g,"\\"):null}function d(A){var B=document.createElement("div");B.appendChild(A.cloneNode(true));return B.innerHTML}function o(G){var I="_"+q,B,A,E={},F,D,C;for(F=0,D=G.length;F=0;C--){H(A[C])}H(B)}function H(O){var L,N=O,M,J,K;if((K=O.getAttribute(h))){while(N.parentNode&&(N=N.parentNode).nodeType===1&&!(L=N.getAttribute(h))){}if(L!==K){N=N.parentNode?(N.nodeType===11?0:(N.getAttribute(h)||0)):0;if(!(J=p[K])){J=e[K];J=k(J,p[N]||e[N]);J.key=++w;p[w]=J}if(q){P(K)}}O.removeAttribute(h)}else{if(q&&(J=i.data(O,"tmplItem"))){P(J.key);p[J.key]=J;N=i.data(O.parentNode,"tmplItem");N=N?N.key:0}}if(J){M=J;while(M&&M.key!=N){M.nodes.push(O);M=M.parent}delete J._ctnt;delete J._wrap;i.data(O,"tmplItem",J)}function P(Q){Q=Q+I;J=E[Q]=(E[Q]||k(J,p[J.parent.key+I]||J.parent))}}}function c(C,A,D,B){if(!C){return g.pop()}g.push({_:C,tmpl:A,item:this,data:D,options:B})}function b(A,C,B){return i.tmpl(i.template(A),C,B,this)}function n(C,A){var B=C.options||{};B.wrapped=A;return i.tmpl(i.template(C.tmpl),C.data,B,C.item)}function r(B,C){var A=this._wrap;return i.map(i(i.isArray(A)?A.join(""):A).filter(B||"*"),function(D){return C?D.innerText||D.textContent:D.outerHTML||d(D)})}function z(){var A=this.nodes;i.tmpl(null,null,null,this).insertBefore(A[0]);i(A).remove()}})(jQuery);function hoozit(a){if(a.constructor===String){return"string"}else{if(a.constructor===Boolean){return"boolean"}else{if(a.constructor===Number){if(isNaN(a)){return"nan"}else{return"number"}}else{if(typeof a==="undefined"){return"undefined"}else{if(a===null){return"null"}else{if(a instanceof Array){return"array"}else{if(a instanceof Date){return"date"}else{if(a instanceof RegExp){return"regexp"}else{if(typeof a==="object"){return"object"}else{if(a instanceof Function){return"function"}else{return undefined}}}}}}}}}}}function bindCallbacks(c,b,a){var d=hoozit(c);if(d){if(hoozit(b[d])==="function"){return b[d].apply(b,a)}else{return b[d]}}}var equiv=function(){var b;var c=[];var a=function(){function d(e,f){if(e instanceof f.constructor||f instanceof e.constructor){return f==e}else{return f===e}}return{string:d,"boolean":d,number:d,"null":d,"undefined":d,nan:function(e){return isNaN(e)},date:function(e,f){return hoozit(e)==="date"&&f.valueOf()===e.valueOf()},regexp:function(e,f){return hoozit(e)==="regexp"&&f.source===e.source&&f.global===e.global&&f.ignoreCase===e.ignoreCase&&f.multiline===e.multiline},"function":function(){var e=c[c.length-1];return e!==Object&&typeof e!=="undefined"},array:function(f,g){var h;var e;if(!(hoozit(f)==="array")){return false}e=g.length;if(e!==f.length){return false}for(h=0;h0){k=e(this[0]);return k.data(e.mask.dataName)()}n=e.extend({placeholder:e.mask.placeholder,completed:null},n);i=e.mask.definitions;m=[];o=h=j.length;l=null;e.each(j.split(""),function(p,q){if(q=="?"){h--;o=p}else{if(i[q]){m.push(new RegExp(i[q]));if(l===null){l=m.length-1}}else{m.push(null)}}});return this.trigger("unmask").each(function(){var y=e(this),t=e.map(j.split(""),function(C,B){if(C!="?"){return i[C]?n.placeholder:C}}),A=y.val();function x(B){while(++B=0&&!m[B]){}return B}function s(E,B){var D,C;if(E<0){return}for(D=E,C=x(B);D=h){n.completed.call(y)}}}E.preventDefault()}}}function q(D,B){var C;for(C=D;CF.length){break}}else{if(t[B]===F.charAt(pos)&&B!==o){pos++;E=B}}}if(C){w()}else{if(E+1=2){if(a.isObject(g[1])){E=g[1].data;s=g[1].schema;l=g[1].options;o=g[1].view;m=g[1].render;h=g[1].postRender;n=g[1].error;c=g[1].connector;z=g[1].dataSource;v=g[1].schemaSource;q=g[1].optionsSource;f=g[1].viewSource;if(g[1].ui){p.ui=g[1].ui}if(g[1].type){p.type=g[1].type}if(!a.isEmpty(g[1].notTopLevel)){k=g[1].notTopLevel}if(!a.isEmpty(g[1].isDynamicCreation)){D=g[1].isDynamicCreation}}else{E=g[1];if(a.isFunction(E)){E=E()}}}if(a.isEmpty(n)){n=a.defaultErrorCallback}if(a.isEmpty(c)){var y=a.getConnectorClass("default");c=new y("default")}if(e){if(a.isString(e)){e=b("#"+e)}}var A=c;if(k){var C=a.getConnectorClass("default");A=new C("default")}if(!l){l={}}if(a.isUndefined(l.focus)){l.focus=false}var r=function(i){if(l&&l.focus){if(l.focus===true){if(i.children&&i.children.length>0){if(i.children[0].field&&i.children[0].field[0]){b(i.children[0]).focus()}}}else{var F=i.getControlByPath(l.focus);if(F&&F.field){b(F).focus()}}}if(h){h(i)}};A.loadAll({data:E,schema:s,options:l,view:o,dataSource:z,schemaSource:v,optionsSource:q,viewSource:f},function(i,F,G,H){i=i?i:E;G=G?G:s;F=F?F:l;H=H?H:o;if(a.isEmpty(i)){if(a.isEmpty(G)&&(a.isEmpty(F)||a.isEmpty(F.type))){i="";if(a.isEmpty(F)){F="text"}else{if(l&&a.isObject(l)){F.type="text"}}}}return a.init(e,i,F,G,H,p,m,r,c,n,D)},function(i){n(i);return null});return b(e)};a.Fields={};a.Connectors={};b.extend(a,{VERSION:"0.1.0",makeArray:function(c){return Array.prototype.slice.call(c)},isFunction:function(c){return Object.prototype.toString.call(c)==="[object Function]"},isString:function(c){return(typeof c=="string")},isObject:function(c){if(c===true||c===false||a.isUndefined(c)||c===null){return false}return(typeof(c)==="object")&&(typeof(c.length)==="undefined")},isPlainObject:function(c){return b.isPlainObject(c)},isNumber:function(c){return(typeof c=="number")},isArray:function(c){if(c===true||c===false||a.isUndefined(c)||c===null){return false}return c.push&&c.slice},isBoolean:function(c){return(typeof c=="boolean")},isUndefined:function(c){return(typeof c=="undefined")},trim:function(d){var c=d;if(c&&a.isString(c)){c=c.replace(/^\s+|\s+$/g,"")}return c},safeDomParse:function(c){if(c&&a.isString(c)){c=a.trim(c);c=b(c)}return c},isEmpty:function(c){return a.isUndefined(c)||c===null},copyOf:function(d){var f=d;if(a.isArray(d)){f=[];for(var e=0;e");if(e){g.attr(e)}if(d){g.css(d)}if(h){for(var f in h){g.addClass(f)}}},elementFromTemplate:function(e,f){var d=e;if(f){for(var c in f){d=a.replaceAll(d,"${"+c+"}",f[c])}}return b(d)},generateId:function(){a.uniqueIdCounter++;return"alpaca"+a.uniqueIdCounter},later:function(l,e,n,h,i){l=l||0;e=e||{};var g=n,k=b.makeArray(h),j,c;if(typeof n==="string"){g=e[n]}if(!g){throw {name:"TypeError",message:"The function is undefined."}}j=function(){g.apply(e,k)};c=(i)?setInterval(j,l):setTimeout(j,l);return{id:c,interval:i,cancel:function(){if(this.interval){clearInterval(c)}else{clearTimeout(c)}}}},endsWith:function(d,c){return d.indexOf(c,d.length-c.length)!==-1},startsWith:function(d,c){return d.substr(0,c.length)===c},isUri:function(c){return a.isString(c)&&(a.startsWith(c,"http://")||a.startsWith(c,"https://")||a.startsWith(c,"/")||a.startsWith(c,"./")||a.startsWith(c,"../"))},traverseObject:function(c,g,f){if(a.isString(g)){g=g.split(".")}var e=null;var h=c;var d=null;do{d=g.shift();if(f&&d==f){d=g.shift()}if(!a.isEmpty(h[d])){h=h[d];if(g.length===0){e=h}}else{g=[]}}while(g.length>0);return e},each:function(f,e){if(a.isArray(f)){for(var d=0;d-1){var e=h.substring(0,c)+d[g]+h.substring(c+3);h=e}}}return h},compareObject:function(d,c){return equiv(d,c)},compareArrayContent:function(d,c){var e=d&&c&&(d.length==c.length);if(e){b.each(d,function(g,f){if(!e){return false}if(b.inArray(f,c)==-1){e=false}else{e=true}})}return e},isValEmpty:function(d){var c=false;if(a.isEmpty(d)){c=true}else{if(a.isString(d)&&d===""){c=true}if(a.isObject(d)&&b.isEmptyObject(d)){c=true}if(a.isArray(d)&&d.length===0){c=true}if(a.isNumber(d)&&isNaN(d)){c=true}}return c},init:function(c,g,p,f,l,d,n,j,e,i,k){var o=this;if(a.isObject(l)){var m=l.id;if(!m){l.id=this.generateViewId()}var h=l.parent;if(!h){l.parent="VIEW_WEB_EDIT"}this.registerView(l);l=l.id}this.compile(function(r){if(r.errors&&r.errors.length>0){for(var t=0;t3){k.type="select"}else{k.type="radio"}}else{k.type=a.defaultSchemaFieldMapping[e.type]}if(e.format&&a.defaultFormatFieldMapping[e.format]){k.type=a.defaultFormatFieldMapping[e.format]}}var i=a.getFieldClass(k.type);if(!i){g({message:"Unable to find field class for type: "+k.type,reason:"FIELD_INSTANTIATION_ERROR"});return null}return new i(c,f,k,e,j,d,g)},parseJSON:function(c){if(!c){return null}return b.parseJSON(c)},compile:function(d,g){var k=this;var f={errors:[],count:0,successCount:0};var i=function(l){if(f.errors.length===0){for(var m in l){k.normalizedViews[m]=l[m]}}d(f)};var h=function(n,p,m,o,q,r){var l=m.id;f.count++;if(p){f.errors.push({view:l,template:o,err:p})}else{f.successCount++;m.compiledTemplates[o]=q}if(f.count==r){i(n)}};var c=function(v,r,t,u,m){var s=r.id;var p=null;if(a.isObject(u)){p=u.type;u=u.template}if(!p){p="text/x-jquery-tmpl"}var q=a.TemplateEngineRegistry.find(p);if(!q){a.logError("Cannot find template engine for type: "+p);var l=new Error("Cannot find template engine for type: "+p);h(v,l,r,t,n,m)}var n=s+"_"+t;if(q.isCached(n)){h(v,null,r,t,n,m)}else{var o=r.compiledTemplates["view-"+u];if(o){u=a.TemplateCache[o]}q.compile(n,u,function(w,x){h(v,w,r,t,n,m)})}};var j=function(s){var m=[];for(var q in s){var p=s[q];p.compiledTemplates={};if(p.templates){for(var l in p.templates){var r=p.templates[l];m.push(function(v,u,x,w){return function(y){c(v,u,x,w,y)}}(s,p,"view-"+l,r))}}if(p.fields){for(var t in p.fields){if(p.fields[t].templates){for(var l in p.fields[t].templates){var r=p.fields[t].templates[l];m.push(function(v,u,x,w){return function(y){c(v,u,x,w,y)}}(s,p,"field-"+t+"-"+l,r))}}}}if(p.layout&&p.layout.template){var r=p.layout.template;m.push(function(v,u,x,w){return function(y){c(v,u,x,w,y)}}(s,p,"layoutTemplate",r))}if(p.globalTemplate){var r=p.globalTemplate;m.push(function(v,u,x,w){return function(y){c(v,u,x,w,y)}}(s,p,"globalTemplate",r))}}var n=m.length;for(var o=0;o0){j(m)}else{i(m)}};e()},getTemplateDescriptor:function(i,d,j){var c={};var m;var e;if(i.templates&&i.templates[d]){m=i.templates[d];e="view"}if(j&&j.path){var n=j.path;if(i&&i.fields&&i.fields[n]&&i.fields[n].templates&&i.fields[n].templates[d]){m=i.fields[n].templates[d];e="field"}}if(d=="globalTemplate"){m="globalTemplate";e="global"}if(d=="layoutTemplate"){m="layoutTemplate";e="layout"}c.template={};c.template.id=d;c.template.type=e;c.template.value=m;var g=null;var l=m;if(a.isObject(l)){g=l.type;l=l.template}if(!g){g="text/x-jquery-tmpl"}var h=a.TemplateEngineRegistry.find(g);if(!h){return a.throwDefaultError("Cannot find template engine for type: "+g)}c.engine={};c.engine.type=g;c.engine.id=h.id;var k=null;if(e=="view"){k="view-"+d}else{if(e=="field"){k="field-"+j.path+"-"+d}else{if(e=="layout"){k="layoutTemplate"}else{if(e=="global"){k="globalTemplate"}}}}c.compiledTemplateId=k;var f=i.compiledTemplates[k];if(!f||!h.isCached(f)){return null}c.cache={};c.cache.key=f;return c},tmpl:function(d,c,e){if(a.isString(d)){d=this.normalizedViews[d]}var i=c.engine.type;var h=c.compiledTemplateId;var g=a.TemplateEngineRegistry.find(i);if(!g){return a.throwDefaultError("Cannot find template engine for type: "+i)}var j=c.cache.key;var f=g.execute(j,e,function(k){return a.throwDefaultError("The compiled template: "+h+" for view: "+d.id+" failed to execute: "+JSON.stringify(k))});return a.safeDomParse(f)}});a.DEBUG=0;a.INFO=1;a.WARN=2;a.ERROR=3;a.logLevel=a.WARN;a.logDebug=function(c){a.log(a.DEBUG,c)};a.logInfo=function(c){a.log(a.INFO,c)};a.logWarn=function(c){a.log(a.WARN,c)};a.logError=function(c){a.log(a.ERROR,c)};a.log=function(f,c){var e={0:"debug",1:"info",2:"warn",3:"error"};if(a.logLevel<=f){var d=e[f];if(typeof console!=="undefined"&&console[d]){if("debug"==d){console.debug(c)}else{if("info"==d){console.info(c)}else{if("warn"==d){console.warn(c)}else{if("error"==d){console.error(c)}else{console.log(c)}}}}}}};a.checked=function(c,d){return a.attrProp(c,"checked",d)};a.attrProp=function(d,c,e){if(!(typeof(e)==="undefined")){if(b(d).prop){b(d).prop(c,e)}else{if(e){b(d).attr(c,e)}else{b(d).removeAttr(c)}}}if(b(d).prop){return b(d).prop(c)}return b(d).attr(c)};a.loadRefSchemaOptions=function(h,g,i){if(g.indexOf("#/definitions/")>-1){var d=g.substring(14);var c=null;if(h.schema.definitions){c=h.schema.definitions[d]}var f=null;if(h.options.definitions){f=h.options.definitions[d]}i(c,f)}else{var e=a.resolveReference(h.schema,h.options,g);if(e){i(e.schema,e.options)}else{i()}}};a.DEFAULT_ERROR_CALLBACK=function(c){if(c&&c.message){a.logError(c.message);throw new Error("Alpaca caught an error with the default error handler: "+c.message)}};a.defaultErrorCallback=a.DEFAULT_ERROR_CALLBACK;a.throwDefaultError=function(d){if(d&&a.isObject(d)){d=JSON.stringify(d)}var c={message:d};a.defaultErrorCallback(c)};a.throwErrorWithCallback=function(e,c){if(e&&a.isObject(e)){e=JSON.stringify(e)}var d={message:e};if(c){c(d)}else{a.defaultErrorCallback(d)}};a.resolveReference=function(g,e,h){if(g.id==h){var d={};if(g){d.schema=g}if(e){d.options=e}return d}else{if(g&&g.properties){for(var i in g.properties){var f=g.properties[i];var j=null;if(e&&e.fields&&e.fields[i]){j=e.fields[i]}var c=a.resolveReference(f,j,h);if(c){return c}}}}return null};b.alpaca=window.Alpaca=a;b.fn.alpaca=function(){var d=a.makeArray(arguments);var c=[].concat(this,d);return a.apply(this,c)};b.fn.outerHTML=function(c){if(c){return b("
").append(this).html()}else{return b("
").append(this.clone()).html()}};b.fn.swapWith=function(c){return this.each(function(){var d=b(c).clone();var e=b(this).clone();b(c).replaceWith(e);b(this).replaceWith(d)})};b.fn.attrProp=function(c,d){return a.attrProp(b(this),c,d)};b.event.special.destroyed={remove:function(c){if(c.handler){c.handler()}}}})(jQuery);(function(){Alpaca.TemplateEngineRegistry=function(){var a={};return{register:function(c,b){a[c]=b},find:function(d){var e=null;if(a[d]){e=a[d]}else{for(var f in a){var c=a[f].supportedMimetypes();for(var b=0;b"+b+"<\/script>"}Alpaca.logDebug("Compiling template: "+this.id+", cacheKey: "+c+", template: "+b);this.doCompile(c,b,d)},doCompile:function(c,b,d){},execute:function(e,b,f){Alpaca.logDebug("Executing template for cache key: "+e);var c=this.doExecute(e,b,f);var d=function(g){var h=Alpaca.safeDomParse(g);if(a(h).length==1){if(a(h)[0].nodeName.toLowerCase()=="script"){return a(h).html()}}return g};c=d(c);return c},doExecute:function(c,b,d){},fileExtension:function(){return"html"},supportedMimetypes:function(){return[]},isCached:function(b){}})})(jQuery);(function(a){Alpaca.JQueryTemplateEngine=Alpaca.AbstractTemplateEngine.extend({fileExtension:function(){return"html"},supportedMimetypes:function(){return["text/x-jquery-template","text/x-jquery-tmpl"]},doCompile:function(d,b,f){try{a.template(d,b)}catch(c){f(c);return}Alpaca.TemplateCache[d]=b;f()},doExecute:function(k,g,l){var m=this;var f=null;try{var b=a.tmpl(k,g);b=b.outerHTML();var d=-1;do{d=b.indexOf("_tmplitem=");if(d>-1){var c=b.indexOf(" ",d);if(c==-1){c=b.indexOf(">",d)}if(c==-1){l({message:"Should have found closing whitespace or '>' for _tmplitem attribute"});return}b=b.substring(0,d)+b.substring(c)}}while(d>-1);f=Alpaca.safeDomParse(b)}catch(h){l({message:h.message});return null}return f},isCached:function(b){return(Alpaca.TemplateCache[b]?true:false)}});Alpaca.TemplateEngineRegistry.register("tmpl",new Alpaca.JQueryTemplateEngine("tmpl"))})(jQuery);(function(a){Alpaca.EJSTemplateEngine=Alpaca.AbstractTemplateEngine.extend({fileExtension:function(){return"ejs"},supportedMimetypes:function(){return["text/x-ejs-template","text/x-ejs-tmpl"]},doCompile:function(f,c,g){var b=null;try{b=new EJS({name:f,text:c})}catch(d){g(d);return}Alpaca.TemplateCache[f]=b;g()},doExecute:function(g,c,h){var b=Alpaca.TemplateCache[g];var d=null;try{d=b.render(c)}catch(f){h(f);return null}return d},isCached:function(b){return(Alpaca.TemplateCache[b]?true:false)}});Alpaca.TemplateEngineRegistry.register("ejs",new Alpaca.EJSTemplateEngine("ejs"))})(jQuery);(function(a){Alpaca.HandlebarsTemplateEngine=Alpaca.AbstractTemplateEngine.extend({fileExtension:function(){return"html"},supportedMimetypes:function(){return["text/x-handlebars-template","text/x-handlebars-tmpl"]},doCompile:function(f,b,g){var c=null;try{c=Handlebars.compile(b)}catch(d){g(d);return}Alpaca.TemplateCache[f]=c;g()},doExecute:function(g,b,h){var d=Alpaca.TemplateCache[g];var c=null;try{c=d(b)}catch(f){h(f);return null}return c},isCached:function(b){return(Alpaca.TemplateCache[b]?true:false)}});Alpaca.TemplateEngineRegistry.register("handlebars",new Alpaca.HandlebarsTemplateEngine("handlebars"))})(jQuery);(function(b){var a=b.alpaca;a.styleInjections={};a.registerView({id:"VIEW_BASE",title:"Abstract base view",description:"Foundation view which provides an abstract view from which all other views extend.",messages:{countries:{afg:"Afghanistan",ala:"Aland Islands",alb:"Albania",dza:"Algeria",asm:"American Samoa",and:"Andorra",ago:"Angola",aia:"Anguilla",ata:"Antarctica",atg:"Antigua and Barbuda",arg:"Argentina",arm:"Armenia",abw:"Aruba",aus:"Australia",aut:"Austria",aze:"Azerbaijan",bhs:"Bahamas",bhr:"Bahrain",bgd:"Bangladesh",brb:"Barbados",blr:"Belarus",bel:"Belgium",blz:"Belize",ben:"Benin",bmu:"Bermuda",btn:"Bhutan",bol:"Bolivia",bih:"Bosnia and Herzegovina",bwa:"Botswana",bvt:"Bouvet Island",bra:"Brazil",iot:"British Indian Ocean Territory",brn:"Brunei Darussalam",bgr:"Bulgaria",bfa:"Burkina Faso",bdi:"Burundi",khm:"Cambodia",cmr:"Cameroon",can:"Canada",cpv:"Cape Verde",cym:"Cayman Islands",caf:"Central African Republic",tcd:"Chad",chl:"Chile",chn:"China",cxr:"Christmas Island",cck:"Cocos (Keeling), Islands",col:"Colombia",com:"Comoros",cog:"Congo",cod:"Congo, the Democratic Republic of the",cok:"Cook Islands",cri:"Costa Rica",hrv:"Croatia",cub:"Cuba",cyp:"Cyprus",cze:"Czech Republic",civ:"Cote d'Ivoire",dnk:"Denmark",dji:"Djibouti",dma:"Dominica",dom:"Dominican Republic",ecu:"Ecuador",egy:"Egypt",slv:"El Salvador",gnq:"Equatorial Guinea",eri:"Eritrea",est:"Estonia",eth:"Ethiopia",flk:"Falkland Islands (Malvinas),",fro:"Faroe Islands",fji:"Fiji",fin:"Finland",fra:"France",guf:"French Guiana",pyf:"French Polynesia",atf:"French Southern Territories",gab:"Gabon",gmb:"Gambia",geo:"Georgia",deu:"Germany",gha:"Ghana",gib:"Gibraltar",grc:"Greece",grl:"Greenland",grd:"Grenada",glp:"Guadeloupe",gum:"Guam",gtm:"Guatemala",ggy:"Guernsey",gin:"Guinea",gnb:"Guinea-Bissau",guy:"Guyana",hti:"Haiti",hmd:"Heard Island and McDonald Islands",vat:"Holy See (Vatican City State),",hnd:"Honduras",hkg:"Hong Kong",hun:"Hungary",isl:"Iceland",ind:"India",idn:"Indonesia",irn:"Iran, Islamic Republic of",irq:"Iraq",irl:"Ireland",imn:"Isle of Man",isr:"Israel",ita:"Italy",jam:"Jamaica",jpn:"Japan",jey:"Jersey",jor:"Jordan",kaz:"Kazakhstan",ken:"Kenya",kir:"Kiribati",prk:"Korea, Democratic People's Republic of",kor:"Korea, Republic of",kwt:"Kuwait",kgz:"Kyrgyzstan",lao:"Lao People's Democratic Republic",lva:"Latvia",lbn:"Lebanon",lso:"Lesotho",lbr:"Liberia",lby:"Libyan Arab Jamahiriya",lie:"Liechtenstein",ltu:"Lithuania",lux:"Luxembourg",mac:"Macao",mkd:"Macedonia, the former Yugoslav Republic of",mdg:"Madagascar",mwi:"Malawi",mys:"Malaysia",mdv:"Maldives",mli:"Mali",mlt:"Malta",mhl:"Marshall Islands",mtq:"Martinique",mrt:"Mauritania",mus:"Mauritius",myt:"Mayotte",mex:"Mexico",fsm:"Micronesia, Federated States of",mda:"Moldova, Republic of",mco:"Monaco",mng:"Mongolia",mne:"Montenegro",msr:"Montserrat",mar:"Morocco",moz:"Mozambique",mmr:"Myanmar",nam:"Namibia",nru:"Nauru",npl:"Nepal",nld:"Netherlands",ant:"Netherlands Antilles",ncl:"New Caledonia",nzl:"New Zealand",nic:"Nicaragua",ner:"Niger",nga:"Nigeria",niu:"Niue",nfk:"Norfolk Island",mnp:"Northern Mariana Islands",nor:"Norway",omn:"Oman",pak:"Pakistan",plw:"Palau",pse:"Palestinian Territory, Occupied",pan:"Panama",png:"Papua New Guinea",pry:"Paraguay",per:"Peru",phl:"Philippines",pcn:"Pitcairn",pol:"Poland",prt:"Portugal",pri:"Puerto Rico",qat:"Qatar",rou:"Romania",rus:"Russian Federation",rwa:"Rwanda",reu:"Reunion",blm:"Saint Barthelemy",shn:"Saint Helena",kna:"Saint Kitts and Nevis",lca:"Saint Lucia",maf:"Saint Martin (French part)",spm:"Saint Pierre and Miquelon",vct:"Saint Vincent and the Grenadines",wsm:"Samoa",smr:"San Marino",stp:"Sao Tome and Principe",sau:"Saudi Arabia",sen:"Senegal",srb:"Serbia",syc:"Seychelles",sle:"Sierra Leone",sgp:"Singapore",svk:"Slovakia",svn:"Slovenia",slb:"Solomon Islands",som:"Somalia",zaf:"South Africa",sgs:"South Georgia and the South Sandwich Islands",esp:"Spain",lka:"Sri Lanka",sdn:"Sudan",sur:"Suriname",sjm:"Svalbard and Jan Mayen",swz:"Swaziland",swe:"Sweden",che:"Switzerland",syr:"Syrian Arab Republic",twn:"Taiwan, Province of China",tjk:"Tajikistan",tza:"Tanzania, United Republic of",tha:"Thailand",tls:"Timor-Leste",tgo:"Togo",tkl:"Tokelau",ton:"Tonga",tto:"Trinidad and Tobago",tun:"Tunisia",tur:"Turkey",tkm:"Turkmenistan",tca:"Turks and Caicos Islands",tuv:"Tuvalu",uga:"Uganda",ukr:"Ukraine",are:"United Arab Emirates",gbr:"United Kingdom",usa:"United States",umi:"United States Minor Outlying Islands",ury:"Uruguay",uzb:"Uzbekistan",vut:"Vanuatu",ven:"Venezuela",vnm:"Viet Nam",vgb:"Virgin Islands, British",vir:"Virgin Islands, U.S.",wlf:"Wallis and Futuna",esh:"Western Sahara",yem:"Yemen",zmb:"Zambia",zwe:"Zimbabwe"},empty:"",required:"This field is required",valid:"",invalid:"This field is invalid",months:["January","February","March","April","May","June","July","August","September","October","November","December"],timeUnits:{SECOND:"seconds",MINUTE:"minutes",HOUR:"hours",DAY:"days",MONTH:"months",YEAR:"years"}}})})(jQuery);(function(b){var a=b.alpaca;a.styleInjections={};a.registerView({id:"VIEW_WEB_DISPLAY",parent:"VIEW_BASE",title:"Default Web Display View",description:"Default web edit view which goes though field hierarchy.",type:"view",platform:"web",displayReadonly:true,templates:{controlField:'
{{if options.label}}
${options.label}
{{/if}}
 ${data}
',fieldSetOuterEl:'
{{html this.html}}
',fieldSetLegend:'{{if options.label}}
${options.label}
{{/if}}',fieldSetItemsContainer:"
{{html this.html}}
",fieldSet:'{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"fieldSetLegend")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetItemsContainer",true)}}{{/wrap}}{{/wrap}}',controlFieldContainer:"
{{html this.html}}
",arrayToolbar:"",arrayItemToolbar:""}});a.registerView({id:"VIEW_WEB_EDIT",parent:"VIEW_BASE",title:"Default Web Edit View",description:"Default web edit view which goes though field hierarchy.",type:"edit",platform:"web",displayReadonly:true,templates:{controlFieldOuterEl:"{{html this.html}}",controlFieldMessage:'
${message}
',controlFieldLabel:'{{if options.label}}
${options.label}
{{/if}}',controlFieldHelper:'{{if options.helper}}
${options.helper}
{{/if}}',controlFieldContainer:"
{{html this.html}}
",controlField:'{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"controlFieldLabel")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldContainer",true)}}{{html Alpaca.fieldTemplate(this,"controlFieldHelper")}}{{/wrap}}{{/wrap}}',fieldSetOuterEl:"
{{html this.html}}
",fieldSetMessage:'
${message}
',fieldSetLegend:'{{if options.label}}${options.label}{{/if}}',fieldSetHelper:'{{if options.helper}}
${options.helper}
{{/if}}',fieldSetItemsContainer:"
{{html this.html}}
",fieldSet:'{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"fieldSetLegend")}}{{html Alpaca.fieldTemplate(this,"fieldSetHelper")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetItemsContainer",true)}}{{/wrap}}{{/wrap}}',fieldSetItemContainer:"
",formFieldsContainer:"
{{html this.html}}
",formButtonsContainer:'
{{if options.buttons}}{{each(k,v) options.buttons}}{{/each}}{{/if}}
',form:'
{{html Alpaca.fieldTemplate(this,"formFieldsContainer")}}{{html Alpaca.fieldTemplate(this,"formButtonsContainer")}}
',wizardStep:'
',wizardNavBar:"
",wizardPreButton:"",wizardNextButton:"",wizardDoneButton:"",wizardStatusBar:'
    {{each(i,v) titles}}
  1. ${v.title}${v.description}
  2. {{/each}}
'}});a.registerView({id:"VIEW_WEB_CREATE",parent:"VIEW_WEB_EDIT",title:"Default Web Create View",description:"Default web create view which doesn't bind initial data.",type:"create",displayReadonly:false})})(jQuery);(function(c){var b=c.alpaca;var a={controlFieldOuterEl:'{{html this.html}}',controlFieldMessage:'
${message}
',controlFieldLabel:'{{if options.label}}{{/if}}',controlFieldHelper:'{{if options.helper}}
${options.helper}
{{/if}}',controlFieldContainer:"
{{html this.html}}
",controlField:'{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"controlFieldLabel")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldContainer",true)}}{{html Alpaca.fieldTemplate(this,"controlFieldHelper")}}{{/wrap}}{{/wrap}}',fieldSetOuterEl:'
{{html this.html}}
',fieldSetMessage:'
${message}
',fieldSetLegend:'{{if options.label}}${options.label}{{/if}}',fieldSetHelper:'{{if options.helper}}
${options.helper}
{{/if}}',fieldSetItemsContainer:"
    {{html this.html}}
",fieldSet:'{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"fieldSetLegend")}}{{html Alpaca.fieldTemplate(this,"fieldSetHelper")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetItemsContainer",true)}}{{/wrap}}{{/wrap}}',fieldSetItemContainer:'
  • ',itemLabel:'{{if options.itemLabel}}{{/if}}'};b.registerView({id:"VIEW_WEB_DISPLAY_LIST",parent:"VIEW_WEB_DISPLAY",title:"Web Display View List Style",description:"Web display view based on list styles.",legendStyle:"link",templates:a,styles:{},fields:{"/":{templates:{fieldSetItemsContainer:'
      {{html this.html}}
    ',fieldSetItemContainer:'
  • '}}}});b.registerView({id:"VIEW_WEB_EDIT_LIST",parent:"VIEW_WEB_EDIT",title:"Web Edit View List Style",description:"Web edit view based on list styles.",legendStyle:"link",templates:a,styles:{},fields:{"/":{templates:{fieldSetItemsContainer:'
      {{html this.html}}
    ',fieldSetItemContainer:'
  • '}}}});b.registerView({id:"VIEW_WEB_CREATE_LIST",parent:"VIEW_WEB_CREATE",title:"Web Create View List Style",description:"Web create view based on list styles.",legendStyle:"link",templates:a,styles:{},fields:{"/":{templates:{fieldSetItemsContainer:'
      {{html this.html}}
    ',fieldSetItemContainer:'
  • '}}}})})(jQuery);(function(b){var a=b.alpaca;a.styleInjections["jquery-ui"]={field:function(c){c.addClass("ui-widget")},required:function(c){b('').prependTo(c)},error:function(c){c.addClass("ui-state-error")},errorMessage:function(c){c.addClass("ui-state-error-text")},removeError:function(c){c.removeClass("ui-state-error")},container:function(c){c.addClass("ui-widget-content")},wizardStatusBar:function(c){c.addClass("ui-widget-header ui-corner-all")},wizardCurrentStep:function(c){c.addClass("ui-state-highlight ui-corner-all")},wizardUnCurrentStep:function(c){c.removeClass("ui-state-highlight ui-corner-all")},containerExpandedIcon:"ui-icon-circle-arrow-s",containerCollapsedIcon:"ui-icon-circle-arrow-e",commonIcon:"ui-icon",addIcon:"ui-icon-circle-plus",removeIcon:"ui-icon-circle-minus",upIcon:"ui-icon-circle-arrow-n",downIcon:"ui-icon-circle-arrow-s",wizardPreIcon:"ui-icon-triangle-1-w",wizardNextIcon:"ui-icon-triangle-1-e",wizardDoneIcon:"ui-icon-triangle-1-e",buttonBeautifier:function(d,c,f){d.addClass("ui-button ui-widget ui-state-default ui-corner-all");if(f){d.addClass("ui-button-text-icon-primary")}else{d.addClass("ui-button-icon-only")}var e=d.html();d.attr("title",e);d.empty().append(''+e+"");d.hover(function(){if(!d.hasClass("alpaca-fieldset-array-item-toolbar-disabled")){b(this).addClass("ui-state-hover")}},function(){if(!d.hasClass("alpaca-fieldset-array-item-toolbar-disabled")){b(this).removeClass("ui-state-hover")}})}};a.registerView({id:"VIEW_JQUERYUI_DISPLAY",parent:"VIEW_WEB_DISPLAY",title:"Web Display View for jQuery UI",description:"Web Display View for jQuery UI",style:"jquery-ui",ui:"jquery-ui"});a.registerView({id:"VIEW_JQUERYUI_EDIT",parent:"VIEW_WEB_EDIT",title:"Web Edit View for jQuery UI",description:"Web Edit View for jQuery UI",style:"jquery-ui",ui:"jquery-ui"});a.registerView({id:"VIEW_JQUERYUI_CREATE",parent:"VIEW_WEB_CREATE",title:"Web Create View for jQuery UI",description:"Web Create View for jQuery UI",style:"jquery-ui",ui:"jquery-ui"});a.registerView({id:"VIEW_JQUERYUI_EDIT_LIST",parent:"VIEW_WEB_EDIT_LIST",title:"JQuery UI Edit View List Style",description:"JQuery UI edit view based on list styles.",style:"jquery-ui",ui:"jquery-ui"});a.registerView({id:"VIEW_JQUERYUI_CREATE_LIST",parent:"VIEW_WEB_CREATE_LIST",title:"JQuery UI Create View List Style",description:"JQuery UI create view based on list styles.",style:"jquery-ui",ui:"jquery-ui"})})(jQuery);(function(c){var b=c.alpaca;b.styleInjections["jquery-mobile"]={array:function(d){if(d){if(d.find('[data-role="fieldcontain"]').fieldcontain){d.find('[data-role="fieldcontain"]').fieldcontain();d.find('[data-role="fieldcontain"]').find("[type='radio'], [type='checkbox']").checkboxradio();d.find('[data-role="fieldcontain"]').find("button, [data-role='button'], [type='button'], [type='submit'], [type='reset'], [type='image']").not(".ui-nojs").button();d.find('[data-role="fieldcontain"]').find("input, textarea").not("[type='radio'], [type='checkbox'], button, [type='button'], [type='submit'], [type='reset'], [type='image']").textinput();d.find('[data-role="fieldcontain"]').find("input, select").filter("[data-role='slider'], [data-type='range']").slider();d.find('[data-role="fieldcontain"]').find("select:not([data-role='slider'])").selectmenu();d.find('[data-role="button"]').buttonMarkup();d.find('[data-role="controlgroup"]').controlgroup()}}}};b.registerView({id:"VIEW_MOBILE_DISPLAY",parent:"VIEW_WEB_DISPLAY",title:"Mobile DISPLAY View",description:"Mobile display view using JQuery Mobile Library",type:"view",platform:"mobile",style:"jquery-mobile",ui:"mobile",legendStyle:"link",toolbarStyle:"link",buttonType:"link",templates:{controlField:'
    • {{if options.label}}

      ${options.label}

      {{/if}}

      ${data}

    ',fieldSetOuterEl:'
    {{html this.html}}
    ',fieldSetMessage:"
    * ${message}
    ",fieldSetLegend:'{{if options.label}}${options.label}{{/if}}',fieldSetHelper:'{{if options.helper}}

    ${options.helper}

    {{/if}}',fieldSetItemsContainer:'
    {{html this.html}}
    ',fieldSet:'{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"fieldSetLegend")}}{{html Alpaca.fieldTemplate(this,"fieldSetHelper")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetItemsContainer",true)}}{{/wrap}}{{/wrap}}',fieldSetItemContainer:"
    "},messages:{required:"Required Field",invalid:"Invalid Field"},render:function(e,f){var d=this;e.render(e.view,function(g){a(g.getEl());if(f){f.call(d,g)}})}});b.registerView({id:"VIEW_MOBILE_EDIT",parent:"VIEW_WEB_EDIT",title:"Mobile Edit View",description:"Mobile edit view using JQuery Mobile Library",type:"edit",platform:"mobile",style:"jquery-mobile",ui:"mobile",legendStyle:"link",toolbarStyle:"link",buttonType:"link",toolbarSticky:true,templates:{controlFieldOuterEl:'
    {{html this.html}}
    ',controlFieldMessage:"
    * ${message}
    ",controlFieldLabel:'{{if options.label}}{{/if}}',controlFieldHelper:'{{if options.helper}}
    ${options.helper}
    {{/if}}',controlFieldContainer:'
    {{html this.html}}
    ',controlField:'{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"controlFieldLabel")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldContainer",true)}}{{/wrap}}{{html Alpaca.fieldTemplate(this,"controlFieldHelper")}}{{/wrap}}',fieldSetOuterEl:'
    {{html this.html}}
    ',fieldSetMessage:"
    * ${message}
    ",fieldSetLegend:'{{if options.label}}${options.label}{{/if}}',fieldSetHelper:'{{if options.helper}}

    ${options.helper}

    {{/if}}',fieldSetItemsContainer:'
    {{html this.html}}
    ',fieldSet:'{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"fieldSetLegend")}}{{html Alpaca.fieldTemplate(this,"fieldSetHelper")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetItemsContainer",true)}}{{/wrap}}{{/wrap}}',fieldSetItemContainer:"
    ",formFieldsContainer:'
    {{html this.html}}
    ',form:'
    {{html Alpaca.fieldTemplate(this,"formFieldsContainer")}}{{html Alpaca.fieldTemplate(this,"formButtonsContainer")}}
    ',controlFieldRadio:'
    {{each selectOptions}}{{/each}}
    ',controlFieldCheckbox:'
    {{if options.rightLabel}}{{else}}{{if options.label}}{{/if}}{{/if}}
    ',arrayItemToolbar:'
    AddDeleteUpDown
    ',arrayToolbar:'
    Add
    '},messages:{required:"Required Field",invalid:"Invalid Field"},render:function(e,f){var d=this;e.render(function(g){a(g.getEl());if(f){f.call(d,g)}})}});var a=function(e){var d=e;while(!b.isEmpty(d)&&d.attr("data-role")!=="page"){d=d.parent()}if(!b.isEmpty(d)){c(d).trigger("pagecreate")}};b.registerView({id:"VIEW_MOBILE_CREATE",parent:"VIEW_MOBILE_EDIT",title:"Default Mobile Create View",description:"Default mobile create view which doesn't bind initial data.",type:"create",displayReadonly:false})})(jQuery);(function(b){var a=b.alpaca;a.styleInjections.bootstrap={error:function(e){e.addClass("control-group error")},errorMessage:function(e){e.addClass("")},removeError:function(e){e.removeClass("error")},tooltipErrorMessage:function(f,e){if(b.fn.tooltip){f.tooltip({html:e}).click()}},field:function(e){e.addClass("control-group")},required:function(e){b(' ').prependTo(e)},container:function(e){e.addClass("")},wizardStatusBar:function(e){e.addClass("ui-widget-header ui-corner-all")},wizardCurrentStep:function(e){e.addClass("ui-state-highlight ui-corner-all")},wizardUnCurrentStep:function(e){e.removeClass("ui-state-highlight ui-corner-all")},commonIcon:"",addIcon:"icon-plus-sign",removeIcon:"icon-minus-sign",upIcon:"icon-chevron-up",downIcon:"icon-chevron-down",wizardPreIcon:"ui-icon-triangle-1-w",wizardNextIcon:"ui-icon-triangle-1-e",wizardDoneIcon:"ui-icon-triangle-1-e",containerExpandedIcon:"icon-circle-arrow-down",containerCollapsedIcon:"icon-circle-arrow-right",buttonBeautifier:function(g,e,i){var h=g.html();g.attr("title",h);var f=i?h:"";g.empty().append(''+f+"")}};var d={controlFieldLabel:'{{if options.label}}{{/if}}',controlFieldHelper:'{{if options.helper}}
    ${options.helper}
    {{/if}}',controlFieldMessage:'
    ${message}
    ',arrayToolbar:'',arrayItemToolbar:'
    {{each(k,v) buttons}}{{/each}}
    ',controlFieldCheckbox:'{{if options.rightLabel}}{{/if}}',controlFieldRadio:'
    {{if !required}}{{/if}}{{each selectOptions}}{{/each}}
    ',fieldSetHelper:'{{if options.helper}}

    ${options.helper}

    {{/if}}'};var c=function(f,g){var e=this;f.render(function(h){b("select,input,textarea",h.outerEl).addClass("input-xlarge");b("button:submit, button:reset, .alpaca-form-button").addClass("btn");if(g){g.call(e,h)}})};a.registerView({id:"VIEW_BOOTSTRAP_DISPLAY",parent:"VIEW_WEB_DISPLAY",title:"Display View for Bootstrap",description:"Display View for Bootstrap",style:"bootstrap",ui:"bootstrap",templates:d,render:c});a.registerView({id:"VIEW_BOOTSTRAP_EDIT",parent:"VIEW_WEB_EDIT",title:"Edit View for Bootstrap",description:"Edit View for Bootstrap",style:"bootstrap",ui:"bootstrap",templates:d,render:c});a.registerView({id:"VIEW_BOOTSTRAP_CREATE",parent:"VIEW_WEB_CREATE",title:"Create View for Bootstrap",description:"Create View for Bootstrap",style:"bootstrap",ui:"bootstrap",templates:d,render:c});a.registerView({id:"VIEW_BOOTSTRAP_DISPLAY_LIST",parent:"VIEW_WEB_DISPLAY_LIST",title:"Display List View for Bootstrap",description:"Display List View for Bootstrap",style:"bootstrap",ui:"bootstrap",templates:d,render:c});a.registerView({id:"VIEW_BOOTSTRAP_EDIT_LIST",parent:"VIEW_WEB_EDIT_LIST",title:"Edit List View for Bootstrap",description:"Edit List View for Bootstrap",style:"bootstrap",ui:"bootstrap",templates:d,render:c});a.registerView({id:"VIEW_BOOTSTRAP_CREATE_LIST",parent:"VIEW_WEB_CREATE_LIST",title:"Create List View for Bootstrap",description:"Create List View for Bootstrap",style:"bootstrap",ui:"bootstrap",templates:d,render:c})})(jQuery);(function(b){var a=b.alpaca;a.registerView({id:"VIEW_WEB_EDIT_TABLE",parent:"VIEW_WEB_EDIT",title:"Web Edit View Table Style",description:"Web edit view based on table styles.",type:"edit",displayReadonly:true,collapsible:false,legendStyle:"link",templates:{controlFieldOuterEl:null,controlFieldLabel:'{{if options.label}}{{/if}}',controlFieldContainer:'{{html this.html}}',controlFieldMessage:'
    ${message}
    ',controlFieldHelper:'{{if options.helper}}
    ${options.helper}
    {{/if}}',controlField:'{{html Alpaca.fieldTemplate(this,"controlFieldLabel")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldContainer",true)}}{{html Alpaca.fieldTemplate(this,"controlFieldHelper")}}{{/wrap}}',fieldSetOuterEl:'
    {{html this.html}}
    ',fieldSetMessage:'
    ${message}
    ',fieldSetLegend:'{{if options.label}}${options.label}{{/if}}',fieldSetHelper:'{{if options.helper}}
    ${options.helper}
    {{/if}}',fieldSetItemsContainer:"{{html this.html}}
    ",fieldSet:'{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"fieldSetLegend")}}{{html Alpaca.fieldTemplate(this,"fieldSetHelper")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetItemsContainer",true)}}{{/wrap}}{{/wrap}}',fieldSetItemContainer:"",itemLabel:'{{if options.itemLabel}}{{/if}}'},styles:{},fields:{"/":{templates:{fieldSetItemsContainer:'{{html this.html}}
    ',fieldSetItemContainer:''}}}});a.registerView({id:"VIEW_WEB_CREATE_TABLE",parent:"VIEW_WEB_EDIT_TABLE",title:"Default Web Create View Table Stle",description:"Default web create view (Table Style) which doesn't bind initial data.",type:"create",displayReadonly:false})})(jQuery);(function(b){var a=b.alpaca;a.registerView({id:"VIEW_WEB_EDIT_YAML",parent:"VIEW_WEB_EDIT",title:"Web Edit View List Style",description:"Web edit list styled to look like a YAML editor.",type:"edit",displayReadonly:true,collapsible:true,legendStyle:"link",templates:{controlFieldOuterEl:'{{html this.html}}',controlFieldMessage:'
    ${message}
    ',controlFieldLabel:'{{if options.label}}{{/if}}',controlFieldHelper:'',controlFieldContainer:"
    {{html this.html}}
    ",controlField:'{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"controlFieldLabel")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldContainer",true)}}{{html Alpaca.fieldTemplate(this,"controlFieldHelper")}}{{/wrap}}{{/wrap}}',fieldSetOuterEl:'
    {{html this.html}}
    ',fieldSetMessage:'
    ${message}
    ',fieldSetLegend:'{{if options.label}}${options.label}{{/if}}',fieldSetHelper:'{{if options.helper}}
    ${options.helper}
    {{/if}}',fieldSetItemsContainer:"
      {{html this.html}}
    ",fieldSet:'{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"fieldSetLegend")}}{{html Alpaca.fieldTemplate(this,"fieldSetHelper")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetItemsContainer",true)}}{{/wrap}}{{/wrap}}',fieldSetItemContainer:'
  • ',itemLabel:'{{if options.itemLabel}}{{/if}}'},styles:{},fields:{"/":{templates:{fieldSetItemsContainer:'
      {{html this.html}}
    ',fieldSetItemContainer:'
  • '}}}})})(jQuery);(function(b){var a=b.alpaca;a.registerView({id:"VIEW_WEB_EDIT_INLINE",parent:"VIEW_WEB_EDIT",title:"Default Web Edit with fields inlining capabilities",description:"Edit template with form fields inlining capabilities, via options.inline level to display some forms parts inline. Useful to display for example an ArrayField containing ObjectField items in a compact manner.",type:"edit",platform:"web",style:"jquery-ui",displayReadonly:true,templates:{fieldSetOuterEl:'
    {{html this.html}}
    ',fieldSetItemContainer:'
    ',arrayItemToolbar:'
    AddDeleteUpDown
    '}})})(jQuery);(function(b){var a=b.alpaca;a.registerView({id:"VIEW_WEB_EDIT",templates:{twoColumnLayout:'
    {{if options.label}}

    ${options.label}

    {{/if}}{{if options.helper}}

    ${options.helper}

    {{/if}}
    '}});a.registerView({id:"VIEW_WEB_EDIT_LAYOUT_TWO_COLUMN",parent:"VIEW_WEB_EDIT",title:"Web Edit View with Two-Column Layout",description:"Web edit default view with two-column layout.",layout:{template:"twoColumnLayout"}});a.registerView({id:"VIEW_WEB_EDIT_LIST_LAYOUT_TWO_COLUMN",parent:"VIEW_WEB_EDIT_LIST",title:"Web List Edit View with Two-Column Layout",description:"Web edit list view with two-column layout.",layout:{template:"twoColumnLayout"}})})(jQuery);(function(b){var a=b.alpaca;a.NormalizedView=Base.extend({constructor:function(c){this.id=c},normalize:function(){var l=a.views[this.id];if(!l){a.logError("View compilation failed - view not found: "+this.id);return false}var c=[];var g=l;while(g){c.push(g);var f=g.parent;if(f){var j=a.views[g.parent];if(!j){a.logError("View compilation failed - cannot find parent view: "+f+" for view: "+g.id);return false}g=j}else{g=null}}c=c.reverse();var k=function(p,o,q){var n=o[q];var i=p[q];if(!a.isUndefined(i)&&!a.isUndefined(n)){a.logDebug("View property: "+q+" already has value: "+i+" and overwriting to: "+n)}if(!a.isUndefined(n)){p[q]=n}};var h=function(p,o,q){var n=o[q];var i=p[q];if(!a.isUndefined(i)&&!a.isUndefined(n)){a.logDebug("View property: "+q+" already has function, overwriting")}if(!a.isUndefined(n)){p[q]=n}};var m=function(n,i,p){var o=i[p];if(o){if(!n[p]){n[p]={}}a.mergeObject2(o,n[p])}};for(var e=0;e1){f.each(function(l,j){if(b(this).attr("data-control")=="append"){g=b(this)}})}this.setEl(g);if(!this.singleLevelRendering){if(!this.isDisplayOnly()||(!this.isControlField)){this.renderField(function(){if(h){h(this)}})}else{if(h){h(this)}}}else{if(h){h(this)}}},renderField:function(c){},getStyleInjection:function(e,f,d,c){if(this.view.style&&a.styleInjections[this.view.style]&&a.styleInjections[this.view.style][e]){a.styleInjections[this.view.style][e].call(this,f,d,c)}},postRender:function(){if(this.view.type!="view"){this.getStyleInjection("field",this.getEl());this.getEl().addClass("alpaca-field");if(this.getEl().attr("id")===null){this.getEl().attr("id",this.getId()+"-field-outer")}if(a.isEmpty(this.getEl().attr("alpaca-field-id"))){this.getEl().attr("alpaca-field-id",this.getId())}if(this.schema.required){this.getEl().addClass("alpaca-field-required")}else{this.getEl().addClass("alpaca-field-optional")}if(this.options.readonly){this.getEl().addClass("alpaca-field-readonly");b(":input",this.getEl()).attr("readonly","readonly");b("select",this.getEl()).attr("disabled","disabled");b(":radio",this.getEl()).attr("disabled","disabled");b(":checkbox",this.getEl()).attr("disabled","disabled")}var d=function(j,g){if(g){var h=0;var k=null;if(a.isArray(g)){for(h=0;h-1){k=g.split(",");for(h=0;h-1){k=g.split(" ");for(h=0;h0){b.each(d,function(f,h){if(h.length>0){var g=e.view.getTemplateDescriptor("controlFieldMessage");if(g){e.messageElement=e.view.tmpl(g,{message:h});e.getStyleInjection("errorMessage",e.messageElement);if(e.hideInitValidationError){e.messageElement.addClass("alpaca-controlfield-message-hidden")}else{e.messageElement.addClass("alpaca-controlfield-message")}e.messageElement.attr("id",e.getId()+"-field-message-"+f);if(b(".alpaca-controlfield-message-container",e.getEl()).length){e.messageElement.appendTo(b(".alpaca-controlfield-message-container",e.getEl()))}else{e.messageElement.appendTo(e.getEl())}}e.getStyleInjection("tooltipErrorMessage",e.getEl(),h)}})}},renderValidationState:function(d){var c=function(g,n){if(this.options.validate){if(g&&this.children){for(var k=0;k