From 021c10d174acf077dc6b4d47557344dd6e26d3d3 Mon Sep 17 00:00:00 2001 From: Rodrigo Goncalves Date: Fri, 14 Aug 2015 09:44:07 -0300 Subject: [PATCH] Ajustes para funcionar o CAS diretamente --- FixTemplateGenerator.diff | 11 +++++++++++ Kernel/Modules/NewTicketWizard.pm | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------- Kernel/Modules/NewTicketWizardPublic.pm | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------ Kernel/Modules/NewTicketWizardServiceForm.pm | 37 ++++++++++++++++++++++++++++++------- Kernel/Output/HTML/Standard/NewTicketWizardServiceFormEdit.tt | 9 ++++++++- Kernel/System/RestrictedService.pm | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Kernel/System/ServiceForm.pm | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ NewTicketWizard.sopm | 25 ++++++++++++++++++++++++- scripts/test/SchemaTest.t | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ sqls.sql | 5 +++++ var/httpd/htdocs/js/NewTicketWizard.js | 1 + var/httpd/htdocs/js/thirdparty/alpaca/.alpaca-full.min.js.swp | Bin 0 -> 778240 bytes var/httpd/htdocs/js/thirdparty/alpaca/alpaca-full.min.js | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ var/httpd/htdocs/js/thirdparty/alpaca/alpaca.min.js | 9 +++++++++ var/httpd/htdocs/js/thirdparty/alpaca/handlebars.min.js | 28 ++++++++++++++++++++++++++++ var/httpd/htdocs/skins/Customer/default/css/alpaca/alpaca-jqueryui-newticketwizard.css | 10 ++++++++++ var/httpd/htdocs/skins/Customer/default/css/alpaca/alpaca-newticketwizard.css | 22 ++++++++++++++++------ 17 files changed, 730 insertions(+), 55 deletions(-) create mode 100644 FixTemplateGenerator.diff create mode 100644 Kernel/System/RestrictedService.pm create mode 100644 scripts/test/SchemaTest.t create mode 100644 sqls.sql create mode 100644 var/httpd/htdocs/js/thirdparty/alpaca/.alpaca-full.min.js.swp create mode 100644 var/httpd/htdocs/js/thirdparty/alpaca/alpaca.min.js create mode 100644 var/httpd/htdocs/js/thirdparty/alpaca/handlebars.min.js diff --git a/FixTemplateGenerator.diff b/FixTemplateGenerator.diff new file mode 100644 index 0000000..36417a7 --- /dev/null +++ b/FixTemplateGenerator.diff @@ -0,0 +1,11 @@ +1264,1266c1264,1269 +< $Data{$Attribute} = $Kernel::OM->Get('Kernel::System::HTMLUtils')->ToHTML( +< String => $Data{$Attribute}, +< ); +--- +> # Fix to allow HTML text in body +> if (!($Attribute eq "Body")) { +> $Data{$Attribute} = $Kernel::OM->Get('Kernel::System::HTMLUtils')->ToHTML( +> String => $Data{$Attribute}, +> ); +> } diff --git a/Kernel/Modules/NewTicketWizard.pm b/Kernel/Modules/NewTicketWizard.pm index dfa5823..eee86c7 100644 --- a/Kernel/Modules/NewTicketWizard.pm +++ b/Kernel/Modules/NewTicketWizard.pm @@ -3,6 +3,7 @@ # # Copyright (C) SeTIC - UFSC - http://setic.ufsc.br/ # Version 01/08/2015 - Support for OTRS 4.0.3 +# Version 25/06/2015 - Support for HTML formatting of form fields # # -- # This software comes with ABSOLUTELY NO WARRANTY. For details, see @@ -206,12 +207,15 @@ sub GetFormJSON { my $LayoutObject = $Kernel::OM->Get("Kernel::Output::HTML::Layout"); my $ParamObject = $Kernel::OM->Get("Kernel::System::Web::Request"); - if ( $Param{ServiceID} ) { - %serviceForm = $ServiceFormObject->GetServiceForm( ServiceID => $Param{ServiceID} ); - } - my $QueueID = $ParamObject->GetParam( Param => "QueueID" ); + if ( $Param{ServiceID} ) { + %serviceForm = $ServiceFormObject->GetServiceFormForQueue( ServiceID => $Param{ServiceID}, QueueID => $QueueID ); + if (! $serviceForm{ServiceID}) { + %serviceForm = $ServiceFormObject->GetServiceForm( ServiceID => $Param{ServiceID} ); + } + } + my ( $schema, $fields, $introduction ) = $Self->GetForm( ServiceForm => \%serviceForm, QueueID => $QueueID ); return $LayoutObject->Attachment( @@ -257,8 +261,13 @@ sub GetForm { $schema =~ s/CF_SCHEMA/$schemaForm/g; $fields =~ s/CF_FORM/$fieldsForm/g; } + + # Ajusta campos fixos, se houver + if ($serviceForm{FixedValues}) { + ($schema, $fields) = $Self->AdjustFixedFields(Schema => $schema, Fields => $fields, FixedValues => $serviceForm{FixedValues}); + } } - + # Incluir campos dinâmicos no replace ( $schema, $fields ) = $TicketWizard->ReplaceOTRSDynamicFields( Schema => $schema, Options => $fields ); @@ -350,17 +359,33 @@ sub CreateTicket { UserID => $ConfigObject->Get('CustomerPanelUserID'), ); - my $MimeType = 'text/plain'; + my $MimeType = 'text/html'; my $serviceFields = ""; # Service Fields for ( $ParamObject->GetParamNames() ) { if ( substr( $_, 0, 3 ) eq "SF_" ) { - $serviceFields .= substr( $_, 3 ) . ": " . $ParamObject->GetParam( Param => $_ ) . "\n"; + if ($ParamObject->GetArray( Param => $_ )) { + my @paramVals = $ParamObject->GetArray( Param => $_ ); + for my $paramValue (@paramVals) { + if (($paramValue) && (!($paramValue eq "-"))) { + $serviceFields .= "" . $Self->breakWords(Text => substr( $_, 3 )) . ": " . $paramValue . "
"; + } + } + + } else { + my $paramValue = $ParamObject->GetParam( Param => $_ ); + + if (($paramValue) && (!($paramValue eq "-"))) { + $serviceFields .= "" . $Self->breakWords(Text => substr( $_, 3 )) . ": " . $ParamObject->GetParam( Param => $_ ) . "
"; + } + } } } - $serviceFields .= "Login autenticado: " . $Self->{UserLogin} . "\n"; - $serviceFields .= "\n\n"; + + $serviceFields .= "Login autenticado: " . $Self->{UserLogin} . "
"; + $serviceFields .= "IP: " . $ENV{'REMOTE_ADDR'} . "
"; + $serviceFields .= "

"; # Dynamic Fields for ( $ParamObject->GetParamNames() ) { @@ -397,7 +422,7 @@ sub CreateTicket { From => $From, To => $Queue, Subject => $ParamObject->GetParam( Param => "subject" ), - Body => $serviceFields . $ParamObject->GetParam( Param => "description" ), + Body => $serviceFields . $Self->lineBreakToHTML(Text => $ParamObject->GetParam( Param => "description" )), }, Queue => $Queue, ); @@ -430,4 +455,57 @@ sub CreateTicket { } +sub AdjustFixedFields { + my ( $Self, %Param ) = @_; + my $schema = $Param{Schema}; + my $form = $Param{Fields}; + my $fixedValues = $Param{FixedValues}; + + my @values = split(/\n/, $fixedValues); + + + for my $value (@values) { + $value =~ s/\r//g; + my @data = split('=', $value); + + my $fieldKey = $data[0]; + my $fixedValue = $data[1]; + + my $key = '("' . $fieldKey . '"[\ ]?:[\ ]?{[^}]+})'; + my $replace = '"' . $fieldKey . '"' . ': {"type": "string", "default": "' . $fixedValue . '"}'; + + $schema =~ s/$key/$replace/; + + $key = '("' . $fieldKey . '"[\ ]?:[\ ]?{[^}]+})'; + $replace = '"' . $fieldKey . '": {"type": "hidden"' . "\n}"; + $form =~ s/$key/$replace/; + } + + return ($schema, $form); + +} + +sub lineBreakToHTML { + my ( $Self, %Param ) = @_; + + my $return = $Param{Text}; + my $LINE_BREAK = "
"; + + $return =~ s/\n/$LINE_BREAK/g; + + return $return; + +} + +sub breakWords { + my ( $Self, %Param ) = @_; + + my $return = $Param{Text}; + + $return =~ s/(.)([A-Z][^A-Z])/$1 $2/g; + $return =~ s/([\w']+)/\u\L$1/g; + + return $return; +} + 1; diff --git a/Kernel/Modules/NewTicketWizardPublic.pm b/Kernel/Modules/NewTicketWizardPublic.pm index 1416ea6..96e2421 100644 --- a/Kernel/Modules/NewTicketWizardPublic.pm +++ b/Kernel/Modules/NewTicketWizardPublic.pm @@ -3,6 +3,7 @@ # # Copyright (C) SeTIC - UFSC - http://setic.ufsc.br/ # Version 01/08/2015 - Support for OTRS 4.0.3 +# Version 25/06/2015 - Support for restricted services and HTML formatting of form fields # # -- # This software comes with ABSOLUTELY NO WARRANTY. For details, see @@ -34,7 +35,8 @@ our @ObjectDependencies = ( "Kernel::Output::HTML::Layout", "KerneL::System::Log", "Kernel::System::Queue", -"Kernel::Config" +"Kernel::Config", +"Kernel::System::RestrictedService" ); sub new { @@ -55,6 +57,7 @@ sub BuildServices { my $ConfigObject = $Kernel::OM->Get("Kernel::Config"); my $LayoutObject = $Kernel::OM->Get("Kernel::Output::HTML::Layout"); my $ServiceObject = $Kernel::OM->Get("Kernel::System::Service"); + my $RestrictedObject = $Kernel::OM->Get("Kernel::System::RestrictedService"); # Build service chooser my %Services = (); @@ -67,25 +70,32 @@ sub BuildServices { $QueueServiceObject->GetServiceList( QueueID => $ParamObject->GetParam( Param => "QueueID" ), ); } my @ServicesCombo = (); + + my @restrictedServices = $RestrictedObject->GetRestrictedServices(); 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; + + if (! ( $serviceID ~~ @restrictedServices ) ) { + 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; + if (! ( $serviceID ~~ @restrictedServices ) ) { + my %serv = (); + $serv{Value} = $Services{$serviceID}; + $serv{Key} = $serviceID; + push @ServicesCombo, \%serv; + } } } @ServicesCombo = sort { $a->{Value} . "::" cmp $b->{Value} . "::" } @ServicesCombo; - + my $retorno = $LayoutObject->BuildSelection( Data => \@ServicesCombo, Name => 'ServiceID', @@ -200,12 +210,16 @@ sub GetFormJSON { my $LayoutObject = $Kernel::OM->Get("Kernel::Output::HTML::Layout"); my $ParamObject = $Kernel::OM->Get("Kernel::System::Web::Request"); + my $QueueID = $ParamObject->GetParam(Param => "QueueID"); + if ( $Param{ServiceID} ) { - %serviceForm = $ServiceFormObject->GetServiceForm( ServiceID => $Param{ServiceID} ); + %serviceForm = $ServiceFormObject->GetServiceFormForQueue( ServiceID => $Param{ServiceID}, QueueID => $QueueID ); + + if (! $serviceForm{ServiceID}) { + %serviceForm = $ServiceFormObject->GetServiceForm( ServiceID => $Param{ServiceID} ); + } } - my $QueueID = $ParamObject->GetParam(Param => "QueueID"); - my ( $schema, $fields, $introduction ) = $Self->GetForm( ServiceForm => \%serviceForm, QueueID => $QueueID ); return $LayoutObject->Attachment( @@ -251,6 +265,12 @@ sub GetForm { $schema =~ s/CF_SCHEMA/$schemaForm/g; $fields =~ s/CF_FORM/$fieldsForm/g; } + + # Ajusta campos fixos, se houver + if ($serviceForm{FixedValues}) { + + ($schema, $fields) = $Self->AdjustFixedFields(Schema => $schema, Fields => $fields, FixedValues => $serviceForm{FixedValues}); + } } # Incluir campos dinâmicos no replace @@ -373,17 +393,32 @@ sub CreateTicket { UserID => $Self->{DefaultUserID}, ); - my $MimeType = 'text/plain'; + my $MimeType = 'text/html'; my $serviceFields = ""; # Service Fields for ( $ParamObject->GetParamNames() ) { if ( substr( $_, 0, 3 ) eq "SF_" ) { - $serviceFields .= substr( $_, 3 ) . ": " . $ParamObject->GetParam( Param => $_ ) . "\n"; + if ($ParamObject->GetArray( Param => $_ )) { + my @paramVals = $ParamObject->GetArray( Param => $_ ); + for my $paramValue (@paramVals) { + if (($paramValue) && (!($paramValue eq "-"))) { + $serviceFields .= "" . $Self->breakWords(Text => substr( $_, 3 )) . ": " . $paramValue . "
"; + } + } + + } else { + my $paramValue = $ParamObject->GetParam( Param => $_ ); + + if (($paramValue) && (!($paramValue eq "-"))) { + $serviceFields .= "" . $Self->breakWords(Text => substr( $_, 3 )) . ": " . $ParamObject->GetParam( Param => $_ ) . "
"; + } + } } } - $serviceFields .= "\n\n"; + $serviceFields .= "IP: " . $ENV{'REMOTE_ADDR'} . "
"; + $serviceFields .= "

"; # Dynamic Fields for ( $ParamObject->GetParamNames() ) { @@ -421,7 +456,7 @@ sub CreateTicket { From => $From, To => $Queue, Subject => $ParamObject->GetParam( Param => "subject" ), - Body => $serviceFields . $ParamObject->GetParam( Param => "description" ), + Body => $serviceFields . $Self->lineBreakToHTML(Text => $ParamObject->GetParam( Param => "description" )), }, Queue => $Queue, ); @@ -453,4 +488,58 @@ sub CreateTicket { } + +sub AdjustFixedFields { + my ( $Self, %Param ) = @_; + my $schema = $Param{Schema}; + my $form = $Param{Fields}; + my $fixedValues = $Param{FixedValues}; + + my @values = split(/\n/, $fixedValues); + + for my $value (@values) { + + $value =~ s/\r//g; + my @data = split('=', $value); + + my $fieldKey = $data[0]; + my $fixedValue = $data[1]; + + my $key = '("' . $fieldKey . '"[\ ]?:[\ ]?{[^}]+})'; + my $replace = '"' . $fieldKey . '"' . ': {"type": "string", "default": "' . $fixedValue . '"}'; + + $schema =~ s/$key/$replace/; + + $key = '("' . $fieldKey . '"[\ ]?:[\ ]?{[^}]+})'; + $replace = '"' . $fieldKey . '": {"type": "hidden"' . "\n}"; + $form =~ s/$key/$replace/; + } + + return ($schema, $form); + +} + +sub lineBreakToHTML { + my ( $Self, %Param ) = @_; + + my $return = $Param{Text}; + my $LINE_BREAK = "
"; + + $return =~ s/\n/$LINE_BREAK/g; + + return $return; + +} + +sub breakWords { + my ( $Self, %Param ) = @_; + + my $return = $Param{Text}; + + $return =~ s/(.)([A-Z][^A-Z])/$1 $2/g; + $return =~ s/([\w']+)/\u\L$1/g; + + return $return; +} + 1; diff --git a/Kernel/Modules/NewTicketWizardServiceForm.pm b/Kernel/Modules/NewTicketWizardServiceForm.pm index 2abdb79..e48e762 100644 --- a/Kernel/Modules/NewTicketWizardServiceForm.pm +++ b/Kernel/Modules/NewTicketWizardServiceForm.pm @@ -53,12 +53,22 @@ sub Run { my $Output = $LayoutObject->Header(); $Output .= $LayoutObject->NavigationBar(); - my %serviceForm = $ServiceFormObject->GetServiceForm( ServiceID => $ParamObject->GetParam( Param => "ServiceID" ) ); + my %serviceForm; + + # if form specific for queue + if ($ParamObject->GetParam( Param => "QueueID" )) { + %serviceForm = $ServiceFormObject->GetServiceFormForQueue( ServiceID => $ParamObject->GetParam( Param => "ServiceID" ), + QueueID => $ParamObject->GetParam( Param => "QueueID" ) ); + } else { + %serviceForm = $ServiceFormObject->GetServiceForm( ServiceID => $ParamObject->GetParam( Param => "ServiceID" ) ); + } $Data{Introduction} = $serviceForm{Introduction}; $Data{Form} = $serviceForm{Form}; $Data{Schema} = $serviceForm{Schema}; + $Data{FixedValues} = $serviceForm{FixedValues}; $Data{ServiceID} = $ParamObject->GetParam( Param => "ServiceID" ); + $Data{QueueID} = $ParamObject->GetParam( Param => "QueueID" ); $Output .= $LayoutObject->Output( Data => \%Data, @@ -76,12 +86,25 @@ sub Run { my $Output = $LayoutObject->Header(); $Output .= $LayoutObject->NavigationBar(); - $ServiceFormObject->SaveServiceForm( - ServiceID => $ParamObject->GetParam( Param => "ServiceID" ), - Introduction => $ParamObject->GetParam( Param => "Introduction" ), - Form => $ParamObject->GetParam( Param => "Form" ), - Schema => $ParamObject->GetParam( Param => "Schema" ), - ); + # If form is specific for a queue + if ($ParamObject->GetParam( Param => "QueueID" )) { + $ServiceFormObject->SaveServiceFormForQueue( + ServiceID => $ParamObject->GetParam( Param => "ServiceID" ), + QueueID => $ParamObject->GetParam( Param => "QueueID" ), + Introduction => $ParamObject->GetParam( Param => "Introduction" ), + Form => $ParamObject->GetParam( Param => "Form" ), + Schema => $ParamObject->GetParam( Param => "Schema" ), + FixedValues => $ParamObject->GetParam( Param => "FixedValues" ), + ); + } else { + $ServiceFormObject->SaveServiceForm( + ServiceID => $ParamObject->GetParam( Param => "ServiceID" ), + Introduction => $ParamObject->GetParam( Param => "Introduction" ), + Form => $ParamObject->GetParam( Param => "Form" ), + Schema => $ParamObject->GetParam( Param => "Schema" ), + FixedValues => $ParamObject->GetParam( Param => "FixedValues" ), + ); + } return $Self->Overview(); } diff --git a/Kernel/Output/HTML/Standard/NewTicketWizardServiceFormEdit.tt b/Kernel/Output/HTML/Standard/NewTicketWizardServiceFormEdit.tt index 2329ef5..6377634 100644 --- a/Kernel/Output/HTML/Standard/NewTicketWizardServiceFormEdit.tt +++ b/Kernel/Output/HTML/Standard/NewTicketWizardServiceFormEdit.tt @@ -21,6 +21,7 @@ +
@@ -41,7 +42,13 @@
- + + +
+ +
+
+
[% Translate("or") | html %] diff --git a/Kernel/System/RestrictedService.pm b/Kernel/System/RestrictedService.pm new file mode 100644 index 0000000..5180556 --- /dev/null +++ b/Kernel/System/RestrictedService.pm @@ -0,0 +1,89 @@ +# -- +# Kernel/System/RestrictedService.pm - core module +# +# Copyright (C) SeTIC - UFSC - http://setic.ufsc.br/ +# Version 2015-06-24 - First version +# +# Manages which services should only be allowed in the logged in interface for OTRS +# +# -- +# 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::RestrictedService; + +use strict; +use warnings; +use utf8; + +our @ObjectDependencies = ( +"Kernel::System::DB", +"Kernel::System::Log"); + + +sub new { + my ( $Type, %Param ) = @_; + + # allocate new hash for object + my $Self = {%Param}; + bless( $Self, $Type ); + + return $Self; +} + +=head + +Returns a service form + +@IdsRestrictedServices + +=cut + +sub GetRestrictedServices { + + my ( $Self, %Param ) = @_; + + my $DBObject = $Kernel::OM->Get("Kernel::System::DB"); + + # get service form from db + $DBObject->Prepare( + SQL => 'SELECT service_id from restricted_service order by service_id asc' + ); + + # fetch the result + my @ServiceData; + while ( my @Row = $DBObject->FetchrowArray() ) { + push(@ServiceData,$Row[0]); + } + + return @ServiceData; +} + +=head + +@IdsList + +Sets the list of restricted services + +=cut +sub SetRestrictedServices { + + my ( $Self, @Param ) = @_; + + my $DBObject = $Kernel::OM->Get("Kernel::System::DB"); + my $idsString = join(",", @Param); + + # delete old services + $DBObject->Do(SQL => 'DELETE FROM restricted_service where service_id NOT IN (' . $idsString . ')'); + + # add new services + while (my $id = @Param) { + $DBObject->Do(SQL => 'REPLACE INTO restricted_service (service_id) VALUES (' . $id . ')'); + } + + return 1; +} + + +1; diff --git a/Kernel/System/ServiceForm.pm b/Kernel/System/ServiceForm.pm index cf3c5b8..fb5cbb7 100644 --- a/Kernel/System/ServiceForm.pm +++ b/Kernel/System/ServiceForm.pm @@ -44,7 +44,7 @@ sub GetServiceForm { # get service form from db $DBObject->Prepare( - SQL => 'SELECT service_id, introduction, form, form_schema FROM service_form WHERE service_id = ?', + SQL => 'SELECT service_id, introduction, form, form_schema, fixed_values FROM service_form WHERE service_id = ? and queue_id is null', Bind => [ \$Param{ServiceID} ], Limit => 1, ); @@ -55,7 +55,40 @@ sub GetServiceForm { $ServiceData{ServiceID} = $Row[0]; $ServiceData{Introduction} = $Row[1]; $ServiceData{Form} = $Row[2]; - $ServiceData{Schema} = $Row[3]; + $ServiceData{Schema} = $Row[3]; + $ServiceData{FixedValues} = $Row[4]; + } + + return %ServiceData; +} + +=head + +Returns a service form for a give queue + +=cut + +sub GetServiceFormForQueue { + + my ( $Self, %Param ) = @_; + + my $DBObject = $Kernel::OM->Get("Kernel::System::DB"); + + # get service form from db + $DBObject->Prepare( + SQL => 'SELECT service_id, introduction, form, form_schema, fixed_values FROM service_form WHERE service_id = ? and queue_id = ? ', + Bind => [ \$Param{ServiceID}, \$Param{QueueID} ], + Limit => 1, + ); + + # fetch the result + my %ServiceData; + while ( my @Row = $DBObject->FetchrowArray() ) { + $ServiceData{ServiceID} = $Row[0]; + $ServiceData{Introduction} = $Row[1]; + $ServiceData{Form} = $Row[2]; + $ServiceData{Schema} = $Row[3]; + $ServiceData{FixedValues} = $Row[4]; } return %ServiceData; @@ -86,14 +119,55 @@ sub SaveServiceForm { my $update = ($serviceForm{ServiceID}); if ($update) { - $DBObject->Do(SQL => 'UPDATE service_form SET introduction=?,form=?,form_schema=? where service_id=?', + $DBObject->Do(SQL => 'UPDATE service_form SET introduction=?,form=?,form_schema=?,fixed_values=? where service_id=? and queue_id is null', + Bind => [ + \$Param{Introduction}, \$Param{Form}, \$Param{Schema}, \$Param{FixedValues}, \$Param{ServiceID} + ]); + } else { + $DBObject->Do(SQL => 'INSERT INTO service_form(service_id,introduction,form,form_schema,fixed_values) VALUES (?,?,?,?,?)', + Bind => [ + \$Param{ServiceID}, \$Param{Introduction}, \$Param{Form}, \$Param{Schema}, \$Param{FixedValues} + ]); + } + + return 1; + +} + + +=head + +Saves a service form for a give queue. + +=cut + +sub SaveServiceFormForQueue { + + my ( $Self, %Param ) = @_; + my $DBObject = $Kernel::OM->Get("Kernel::System::DB"); + + for my $Argument (qw(ServiceID Introduction)) { + if ( !$Param{$Argument} ) { + $Kernel::OM->Get("Kernel::System::Log")->Log( + Priority => 'error', + Message => "Need $Argument!", + ); + return; + } + } + + my %serviceForm = $Self->GetServiceFormForQueue(ServiceID => $Param{ServiceID}, QueueID => $Param{QueueID}); + my $update = ($serviceForm{ServiceID}); + + if ($update) { + $DBObject->Do(SQL => 'UPDATE service_form SET introduction=?,form=?,form_schema=?,fixed_values=? where service_id=? and queue_id=? ', Bind => [ - \$Param{Introduction}, \$Param{Form}, \$Param{Schema}, \$Param{ServiceID} + \$Param{Introduction}, \$Param{Form}, \$Param{Schema}, \$Param{FixedValues}, \$Param{ServiceID}, \$Param{QueueID} ]); } else { - $DBObject->Do(SQL => 'INSERT INTO service_form(service_id,introduction,form,form_schema) VALUES (?,?,?,?)', + $DBObject->Do(SQL => 'INSERT INTO service_form(service_id,introduction,form,form_schema,queue_id,fixed_values) VALUES (?,?,?,?,?,?)', Bind => [ - \$Param{ServiceID}, \$Param{Introduction}, \$Param{Form}, \$Param{Schema} + \$Param{ServiceID}, \$Param{Introduction}, \$Param{Form}, \$Param{Schema}, \$Param{QueueID}, \$Param{FixedValues} ]); } diff --git a/NewTicketWizard.sopm b/NewTicketWizard.sopm index 5d6d42c..a37c9be 100755 --- a/NewTicketWizard.sopm +++ b/NewTicketWizard.sopm @@ -1,7 +1,7 @@ NewTicketWizard - 1.5.3 + 1.7.7 4.0.x SeTIC http://www.setic.ufsc.br @@ -9,6 +9,11 @@ NewTicket Wizard Module Support for OTRS 4.0.3, QueuesPanel Module Separation AlpacaJS adjustment for OTRS 4.0.4 + Support for specific form per queue + Support for fixed field values and IP in created ticket + Support to set any field value + Support for multi-value fields + Support for restricted services New Ticket Wizard module installed successfully! ? ? @@ -22,6 +27,7 @@ + @@ -58,9 +64,26 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/scripts/test/SchemaTest.t b/scripts/test/SchemaTest.t new file mode 100644 index 0000000..fabd021 --- /dev/null +++ b/scripts/test/SchemaTest.t @@ -0,0 +1,145 @@ +# -- +# Responsibility.t - Responsiblity tests +# Copyright (C) 2014 OTRS AG, http://otrs.com/ +# -- +# 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. +# -- +# Autor: Rodrigo Gonçalves +# Data.: 04/08/2014 - versão inicial +# + +# +# alter table service_form add fixed_values text; +# +# + +use strict; +use warnings; +use vars (qw($Self)); + +my $schema = ' +"service": { + "type": "string", + "required": "true" + }, + "DF_unidade": { + "type": "string", + "enum": [ + DF_unidade_values + ], + "required": "true" + }, + "DF_local": { + "type": "string", + "required": "true" + }, + "DF_telefone": { + "type": "string", + "required": "true" + }, + "type": { + "type": "string", + "enum": [ + OTRS_type_values + ], + "required": "true" + } + CF_SCHEMA + , + "subject": { + "type": "string", + "required": "true" + }, + "description": { + "type": "string", + "required": "true" + }, + "attachment": { + "type": "string", + "format": "uri" + }, + "Action": { + "type": "string", + "default": "NewTicketWizard" + }, + "Subaction": { + "type": "string", + "default": "CreateTicket" + } +'; + +my $key = '("DF_telefone"[^}]+})'; +my $replace = '"DF_telefone {' . "\n" . '"type": "string"' . "\n}"; + + +$schema =~ s/$key/$replace/; + +print STDOUT $schema . "\n\n\n\n"; + + + + +my $form = ' +"DF_unidade": { + "type": "select", + "label": "Unidade:", + "optionLabels": [ + DF_unidade_labels + ] + }, + "DF_local": { + "type": "text", + "label": "Local:" + }, + "DF_telefone": { + "type": "text", + "label": "Telefone:", + "control_width": 100 + }, + "type": { + "type": "select", + "label": "Motivo:", + "optionLabels": [ + OTRS_type_labels + ] + }, + "service": { + "type": "hidden" + } + CF_FORM, + "subject": { + "type": "text", + "label": "Assunto:", + "size": 80 + }, + "description": { + "type": "textarea", + "label": "Descrição:", + "cols": 80 + }, + "attachment": { + "type": "file", + "label": "Anexo:", + "helper": "Anexe um arquivo se necessário." + }, + "Action": { + "type": "hidden" + }, + "Subaction": { + "type": "hidden" + } + +'; + +$key = '("DF_telefone"[^}]+})'; +$replace = '"DF_telefone": {' . "\n" . '"type": "hidden"' . "\n}"; + + +$form =~ s/$key/$replace/; + +print STDOUT $form ; + + +1; \ No newline at end of file diff --git a/sqls.sql b/sqls.sql new file mode 100644 index 0000000..6e0f973 --- /dev/null +++ b/sqls.sql @@ -0,0 +1,5 @@ +alter table service_form drop foreign key FK_service_form_service_id_id; +alter table service_form drop primary key; +alter table service_form add id int auto_increment not null primary key; +alter table service_form add fixed_values text; +alter table service_form add queue_id int; diff --git a/var/httpd/htdocs/js/NewTicketWizard.js b/var/httpd/htdocs/js/NewTicketWizard.js index bf62eb0..ce46cfa 100644 --- a/var/httpd/htdocs/js/NewTicketWizard.js +++ b/var/httpd/htdocs/js/NewTicketWizard.js @@ -70,6 +70,7 @@ var postRenderCallback = function(form) { if (form.isFormValid()) { return true; } else { + alert("Dados inválidos!"); return false; } e.stopPropagation(); diff --git a/var/httpd/htdocs/js/thirdparty/alpaca/.alpaca-full.min.js.swp b/var/httpd/htdocs/js/thirdparty/alpaca/.alpaca-full.min.js.swp new file mode 100644 index 0000000..1ed6558 Binary files /dev/null and b/var/httpd/htdocs/js/thirdparty/alpaca/.alpaca-full.min.js.swp differ diff --git a/var/httpd/htdocs/js/thirdparty/alpaca/alpaca-full.min.js b/var/httpd/htdocs/js/thirdparty/alpaca/alpaca-full.min.js index 556650d..b0be7f1 100644 --- a/var/httpd/htdocs/js/thirdparty/alpaca/alpaca-full.min.js +++ b/var/httpd/htdocs/js/thirdparty/alpaca/alpaca-full.min.js @@ -728,6 +728,7 @@ if (typeof JSON !== 'object') { path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i; function addError(message) { errors.push({property:path,message:message}); + Alpaca.logDebug("Erro: " + message); } if ((typeof schema != 'object' || schema instanceof Array) && (path || typeof schema != 'function') && !(schema && schema.type)) { @@ -2149,6 +2150,8 @@ var equiv = function () { // Unless we want to load individual fields (other than the templates) using the provided // loader, this should be good enough. The benefit is saving time on loader format checking. + + var loadAllConnector = connector; if (notTopLevel) { @@ -2163,6 +2166,8 @@ var equiv = function () { if (Alpaca.isUndefined(options.focus)) { options.focus = false; } + + var _renderedCallback = function(control) { // auto-set the focus? @@ -2195,6 +2200,9 @@ var equiv = function () { } }; + + + loadAllConnector.loadAll({ "data": data, "schema": schema, @@ -2242,6 +2250,8 @@ var equiv = function () { return null; }); + + // hand back the field return $(el); }; @@ -4166,7 +4176,7 @@ var equiv = function () { // by default, logging only shows warnings and above // to debug, set Alpaca.logLevel = Alpaca.DEBUG - Alpaca.logLevel = Alpaca.WARN; + Alpaca.logLevel = Alpaca.INFO; Alpaca.logDebug = function(obj) { Alpaca.log(Alpaca.DEBUG, obj); @@ -7035,6 +7045,7 @@ var equiv = function () { } } + // hidden if (this.options.hidden) { this.getEl().hide(); @@ -7046,19 +7057,25 @@ var equiv = function () { var defaultHideInitValidationError = (this.view.type == 'create'); this.hideInitValidationError = Alpaca.isValEmpty(this.options.hideInitValidationError) ? defaultHideInitValidationError : this.options.hideInitValidationError; + Alpaca.logDebug("PreRender"); + // final call to update validation state if (this.view.type != 'view') { + Alpaca.logDebug("PreRender2"); this.renderValidationState(); } // set to false after first validation (even if in CREATE mode, we only force init validation error false on first render) this.hideInitValidationError = false; + Alpaca.logDebug("PreHiden"); // for create view, hide all readonly fields if (!this.view.displayReadonly) { $('.alpaca-field-readonly', this.getEl()).hide(); } + ////console.log(this); + Alpaca.logDebug("PrePostRender"); // field level post render if (this.options.postRender) { this.options.postRender(this); @@ -7311,7 +7328,6 @@ var equiv = function () { this._validateCustomValidator(); } }; - _rvc.call(this, checkChildren, false); }, @@ -7447,8 +7463,17 @@ var equiv = function () { * @returns {Boolean} False if this field value is empty but required, true otherwise. */ _validateOptional: function() { - if (this.schema.required && this.isEmpty()) { - return false; + var id = this.id; + var obj = $("span[alpaca-field-id='" + id + "']").css('display'); + //console.log("Display para" + "span[alpaca-field-id='" + this.id + "'] => " + obj); + if (this.schema.required) { + if ((obj == "none") || (obj == "undefined")) { + console.log("alpaca-field-id='" + id + "' => OK"); + return true; + } else if (this.isEmpty()) { + console.log("alpaca-field-id='" + id + "' => NOT OK"); + return false; + } } return true; }, @@ -8367,6 +8392,14 @@ var equiv = function () { _validateEnum: function() { if (this.schema["enum"]) { var val = this.data; + + var id = this.id; + var obj = $("span[alpaca-field-id='" + id + "']").css('display'); + if ((this.schema.required) && ((obj == "none") || (obj == "undefined"))) { + console.log("alpaca-field-id='" + id + "' => OK"); + return true; + } + /*this.getValue();*/ if (!this.schema.required && Alpaca.isValEmpty(val)) { return true; @@ -9986,6 +10019,14 @@ var equiv = function () { _validatePattern: function() { if (this.schema.pattern) { var val = this.getValue(); + + var id = this.id; + var obj = $("span[alpaca-field-id='" + id + "']").css('display'); + if ((this.schema.required) && ((obj == "none") || (obj == "undefined"))) { + console.log("alpaca-field-id='" + id + "' => OK"); + return true; + } + if (val === "" && this.options.allowOptionalEmpty && !this.schema.required) { return true; } @@ -10007,6 +10048,15 @@ var equiv = function () { */ _validateMinLength: function() { if (!Alpaca.isEmpty(this.schema.minLength)) { + + + var id = this.id; + var obj = $("span[alpaca-field-id='" + id + "']").css('display'); + if ((this.schema.required) && ((obj == "none") || (obj == "undefined"))) { + console.log("alpaca-field-id='" + id + "' => OK"); + return true; + } + var val = this.getValue(); if (val === "" && this.options.allowOptionalEmpty && !this.schema.required) { return true; @@ -10028,6 +10078,15 @@ var equiv = function () { */ _validateMaxLength: function() { if (!Alpaca.isEmpty(this.schema.maxLength)) { + + var id = this.id; + var obj = $("span[alpaca-field-id='" + id + "']").css('display'); + if ((this.schema.required) && ((obj == "none") || (obj == "undefined"))) { + console.log("alpaca-field-id='" + id + "' => OK"); + return true; + } + + var val = this.getValue(); if (val === "" && this.options.allowOptionalEmpty && !this.schema.required) { return true; @@ -11291,6 +11350,7 @@ var equiv = function () { var _this = this; + if (this.schema["type"] && this.schema["type"] == "array") { this.options.multiple = true; } @@ -11320,7 +11380,6 @@ var equiv = function () { //$("select",this.field).val("0"); } - this.injectField(this.field); // do this little trick so that if we have a default value, it gets set during first render @@ -11353,6 +11412,14 @@ var equiv = function () { _validateEnum: function() { if (this.schema["enum"]) { var val = this.data; + + var id = this.id; + var obj = $("span[alpaca-field-id='" + id + "']").css('display'); + if ((this.schema.required) && ((obj == "none") || (obj == "undefined"))) { + console.log("alpaca-field-id='" + id + "' => OK"); + return true; + } + if (!this.schema.required && Alpaca.isValEmpty(val)) { return true; } @@ -13393,6 +13460,10 @@ var equiv = function () { } else if (Alpaca.isArray(def.dependencies)) { +s +v +t +w $.each(def.dependencies, function(index, value) { if (value == propertyId) { @@ -13506,7 +13577,9 @@ var equiv = function () { else { // check object value - if (!Alpaca.isEmpty(conditionalDependencies[dependentOnPropertyId]) && conditionalDependencies[dependentOnPropertyId] != dependentOnData) + if (!dependentOnData) { + valid = false; + } else if (!Alpaca.isEmpty(conditionalDependencies[dependentOnPropertyId]) && dependentOnData.indexOf(conditionalDependencies[dependentOnPropertyId]) == -1) { valid = false; } diff --git a/var/httpd/htdocs/js/thirdparty/alpaca/alpaca.min.js b/var/httpd/htdocs/js/thirdparty/alpaca/alpaca.min.js new file mode 100644 index 0000000..5d5c87a --- /dev/null +++ b/var/httpd/htdocs/js/thirdparty/alpaca/alpaca.min.js @@ -0,0 +1,9 @@ +!function(e,t){var i=!0;e&&"undefined"!=typeof e.umd&&(i=e.umd),i&&"object"==typeof exports?module.exports=t(require("jquery"),require("handlebars"),require("jquery-ui")):i&&"function"==typeof define&&define.amd?define("alpaca",["jquery","handlebars","jquery-ui"],t):e.Alpaca=t(e.jQuery,e.Handlebars,e.jQueryUI)}(this,function($,Handlebars,jQueryUI){return this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-display"]=this.HandlebarsPrecompiled["web-display"]||{},this.HandlebarsPrecompiled["web-display"]["container-array"]=function(e,t,i,a,n){function r(e,t){var a,n,r,o="";return o+="\n\n ",r={hash:{},inverse:c.noop,fn:c.program(2,s,t),data:t},(n=i.item)?a=n.call(e,r):(n=e&&e.item,a=typeof n===d?n.call(e,r):n),i.item||(a=p.call(e,a,{hash:{},inverse:c.noop,fn:c.program(2,s,t),data:t})),(a||0===a)&&(o+=a),o+="\n\n "}function s(){var e="";return e}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var o,l="",c=this,d="function",p=i.blockHelperMissing;return l+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-display"]=this.HandlebarsPrecompiled["web-display"]||{},this.HandlebarsPrecompiled["web-display"]["container-object"]=function(e,t,i,a,n){function r(e,t){var a,n,r,o="";return o+="\n\n ",r={hash:{},inverse:c.noop,fn:c.program(2,s,t),data:t},(n=i.item)?a=n.call(e,r):(n=e&&e.item,a=typeof n===d?n.call(e,r):n),i.item||(a=p.call(e,a,{hash:{},inverse:c.noop,fn:c.program(2,s,t),data:t})),(a||0===a)&&(o+=a),o+="\n\n "}function s(){var e="";return e}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var o,l="",c=this,d="function",p=i.blockHelperMissing;return l+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-display"]=this.HandlebarsPrecompiled["web-display"]||{},this.HandlebarsPrecompiled["web-display"].container=function(e,t,i,a,n){function r(e,t){var a,n="";return n+='\n ',a=e&&e.options,a=null==a||a===!1?a:a.label,a=typeof a===f?a.apply(e):a,(a||0===a)&&(n+=a),n+="\n "}function s(e){var t;return m((t=e&&e.options,t=null==t||t===!1?t:t.labelClass,typeof t===f?t.apply(e):t))}function o(e,t){var a,n="";return n+='\n

\n \n ',a=e&&e.options,a=null==a||a===!1?a:a.helper,a=typeof a===f?a.apply(e):a,(a||0===a)&&(n+=a),n+="\n

\n "}function l(e){var t;return m((t=e&&e.options,t=null==t||t===!1?t:t.helperClass,typeof t===f?t.apply(e):t))}function c(){var e="";return e}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var d,p,u,h="",f="function",m=this.escapeExpression,g=this,v=i.blockHelperMissing;return h+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-display"]=this.HandlebarsPrecompiled["web-display"]||{},this.HandlebarsPrecompiled["web-display"]["control-any"]=function(e,t,i,a,n){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var r,s,o,l="",c=i.helperMissing;return l+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-display"]=this.HandlebarsPrecompiled["web-display"]||{},this.HandlebarsPrecompiled["web-display"]["control-checkbox"]=function(e,t,i,a,n){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var r,s,o,l="",c=i.helperMissing;return l+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-display"]=this.HandlebarsPrecompiled["web-display"]||{},this.HandlebarsPrecompiled["web-display"]["control-image"]=function(e,t,i,a,n){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var r,s,o="",l="function",c=this.escapeExpression;return o+=''},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-display"]=this.HandlebarsPrecompiled["web-display"]||{},this.HandlebarsPrecompiled["web-display"]["control-radio"]=function(e,t,i,a,n){function r(e,t,a){var n,r,o,l="";return l+="\n ",r=i.compare||e&&e.compare,o={hash:{},inverse:d.noop,fn:d.program(2,s,t),data:t},n=r?r.call(e,e&&e.value,a&&a.data,o):p.call(e,"compare",e&&e.value,a&&a.data,o),(n||0===n)&&(l+=n),l+="\n "}function s(e,t){var a,n,r="";return r+="\n ",(n=i.text)?a=n.call(e,{hash:{},data:t}):(n=e&&e.text,a=typeof n===c?n.call(e,{hash:{},data:t}):n),(a||0===a)&&(r+=a),r+="\n "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var o,l="",c="function",d=this,p=i.helperMissing;return l+='\n"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-display"]=this.HandlebarsPrecompiled["web-display"]||{},this.HandlebarsPrecompiled["web-display"]["control-select"]=function(e,t,i,a,n){function r(e,t,a){var n,r,o,l="";return l+="\n ",r=i.compare||e&&e.compare,o={hash:{},inverse:d.noop,fn:d.program(2,s,t),data:t},n=r?r.call(e,e&&e.value,a&&a.data,o):p.call(e,"compare",e&&e.value,a&&a.data,o),(n||0===n)&&(l+=n),l+="\n "}function s(e,t){var a,n,r="";return r+="\n ",(n=i.text)?a=n.call(e,{hash:{},data:t}):(n=e&&e.text,a=typeof n===c?n.call(e,{hash:{},data:t}):n),(a||0===a)&&(r+=a),r+="\n "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var o,l="",c="function",d=this,p=i.helperMissing;return l+='\n"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-display"]=this.HandlebarsPrecompiled["web-display"]||{},this.HandlebarsPrecompiled["web-display"]["control-text"]=function(e,t,i,a,n){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var r,s,o="",l="function";return o+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-display"]=this.HandlebarsPrecompiled["web-display"]||{},this.HandlebarsPrecompiled["web-display"]["control-textarea"]=function(e,t,i,a,n){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var r,s,o="",l="function";return o+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-display"]=this.HandlebarsPrecompiled["web-display"]||{},this.HandlebarsPrecompiled["web-display"]["control-url"]=function(e,t,i,a,n){function r(e){var t,i="";return i+='target="'+f((t=e&&e.options,t=null==t||t===!1?t:t.anchorTarget,typeof t===h?t.apply(e):t))+'"'}function s(e){var t;return f((t=e&&e.options,t=null==t||t===!1?t:t.anchorTitle,typeof t===h?t.apply(e):t))}function o(e,t){var a,n;return(n=i.data)?a=n.call(e,{hash:{},data:t}):(n=e&&e.data,a=typeof n===h?n.call(e,{hash:{},data:t}):n),f(a)}function l(e){var t,i="";return i+="\n "+f((t=e&&e.options,t=null==t||t===!1?t:t.anchorTitle,typeof t===h?t.apply(e):t))+"\n "}function c(e,t){var a,n,r="";return r+="\n ",(n=i.data)?a=n.call(e,{hash:{},data:t}):(n=e&&e.data,a=typeof n===h?n.call(e,{hash:{},data:t}):n),r+=f(a)+"\n "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var d,p,u="",h="function",f=this.escapeExpression,m=this;return u+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-display"]=this.HandlebarsPrecompiled["web-display"]||{},this.HandlebarsPrecompiled["web-display"].control=function(e,t,i,a,n){function r(e,t){var a,n,r="";return r+='\n \n "}function s(e){var t;return m((t=e&&e.options,t=null==t||t===!1?t:t.labelClass,typeof t===f?t.apply(e):t))}function o(){var e="";return e}function l(e,t){var a,n="";return n+='\n

\n \n ',a=e&&e.options,a=null==a||a===!1?a:a.helper,a=typeof a===f?a.apply(e):a,(a||0===a)&&(n+=a),n+="\n

\n "}function c(e){var t;return m((t=e&&e.options,t=null==t||t===!1?t:t.helperClass,typeof t===f?t.apply(e):t))}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var d,p,u,h="",f="function",m=this.escapeExpression,g=this,v=i.blockHelperMissing;return h+='\n"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-display"]=this.HandlebarsPrecompiled["web-display"]||{},this.HandlebarsPrecompiled["web-display"].form=function(e,t,i,a,n){function r(){var e="";return e}function s(e,t){var a,n="";return n+="\n ",a=i.each.call(e,(a=e&&e.options,null==a||a===!1?a:a.buttons),{hash:{},inverse:v.noop,fn:v.program(4,o,t),data:t}),(a||0===a)&&(n+=a),n+="\n "}function o(e,t){var a,n,r,s="";return s+='\n \n "}function l(){return'type="submit"'}function c(){return'type="reset"'}function d(e,t){var a,n,r="";return r+=g((a=null==t||t===!1?t:t.key,typeof a===m?a.apply(e):a))+'="',(n=i.value)?a=n.call(e,{hash:{},data:t}):(n=e&&e.value,a=typeof n===m?n.call(e,{hash:{},data:t}):n),r+=g(a)+'"'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var p,u,h,f="",m="function",g=this.escapeExpression,v=this,y=i.helperMissing,b=i.blockHelperMissing;return f+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"]["container-array-actionbar"]=function(e,t,i,a,n){function r(e,t){var a,n,r="";return r+='\n \n "}function s(e){var t,i="";return i+='\n \n '}function o(e,t){var a,n;return(n=i.label)?a=n.call(e,{hash:{},data:t}):(n=e&&e.label,a=typeof n===p?n.call(e,{hash:{},data:t}):n),a||0===a?a:""}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var l,c,d="",p="function",u=this.escapeExpression,h=this;return d+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"]["container-array-toolbar"]=function(e,t,i,a,n){function r(){return" btn-group"}function s(e,t,a){var n,r,s,c="";return c+="\n\n ",r=i.compare||a&&a.compare,s={hash:{},inverse:v.noop,fn:v.program(4,o,t),data:t},n=r?r.call(e,a&&a.toolbarStyle,"link",s):y.call(e,"compare",a&&a.toolbarStyle,"link",s),(n||0===n)&&(c+=n),c+="\n\n ",r=i.compare||a&&a.compare,s={hash:{},inverse:v.noop,fn:v.program(6,l,t),data:t},n=r?r.call(e,a&&a.toolbarStyle,"button",s):y.call(e,"compare",a&&a.toolbarStyle,"button",s),(n||0===n)&&(c+=n),c+="\n\n "}function o(e){var t,i="";return i+='\n ',t=e&&e.label,t=typeof t===m?t.apply(e):t,(t||0===t)&&(i+=t),i+="\n "}function l(e,t){var a,n="";return n+='\n \n "}function c(e){var t,i="";return i+='\n \n '}function d(e,t){var a,n;return(n=i.label)?a=n.call(e,{hash:{},data:t}):(n=e&&e.label,a=typeof n===m?n.call(e,{hash:{},data:t}):n),a||0===a?a:""}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var p,u,h,f="",m="function",g=this.escapeExpression,v=this,y=i.helperMissing;return f+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"]["container-array"]=function(e,t,i,a,n){function r(e,t){var a,n,r,o="";return o+="\n\n ",r={hash:{},inverse:c.noop,fn:c.program(2,s,t),data:t},(n=i.item)?a=n.call(e,r):(n=e&&e.item,a=typeof n===d?n.call(e,r):n),i.item||(a=p.call(e,a,{hash:{},inverse:c.noop,fn:c.program(2,s,t),data:t})),(a||0===a)&&(o+=a),o+="\n\n "}function s(){var e="";return e}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var o,l="",c=this,d="function",p=i.blockHelperMissing;return l+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"]["container-object"]=function(e,t,i,a,n){function r(e,t){var a,n,r,o="";return o+="\n\n ",r={hash:{},inverse:c.noop,fn:c.program(2,s,t),data:t},(n=i.item)?a=n.call(e,r):(n=e&&e.item,a=typeof n===d?n.call(e,r):n),i.item||(a=p.call(e,a,{hash:{},inverse:c.noop,fn:c.program(2,s,t),data:t})),(a||0===a)&&(o+=a),o+="\n\n "}function s(){var e="";return e}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var o,l="",c=this,d="function",p=i.blockHelperMissing;return l+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"]["container-table"]=function(e,t,i,a,n){function r(){return" btn-group"}function s(e,t,a){var n,r,s,c="";return c+="\n\n ",r=i.compare||a&&a.compare,s={hash:{},inverse:x.noop,fn:x.program(4,o,t),data:t},n=r?r.call(e,(n=a&&a.options,null==n||n===!1?n:n.toolbarStyle),"link",s):S.call(e,"compare",(n=a&&a.options,null==n||n===!1?n:n.toolbarStyle),"link",s),(n||0===n)&&(c+=n),c+="\n\n ",r=i.compare||a&&a.compare,s={hash:{},inverse:x.noop,fn:x.program(6,l,t),data:t},n=r?r.call(e,(n=a&&a.options,null==n||n===!1?n:n.toolbarStyle),"button",s):S.call(e,"compare",(n=a&&a.options,null==n||n===!1?n:n.toolbarStyle),"button",s),(n||0===n)&&(c+=n),c+="\n\n "}function o(e){var t,i="";return i+='\n ',t=e&&e.label,t=typeof t===w?t.apply(e):t,(t||0===t)&&(i+=t),i+="\n "}function l(e,t){var a,n="";return n+='\n \n "}function c(e){var t,i="";return i+='\n \n '}function d(e,t){var a,n;return(n=i.label)?a=n.call(e,{hash:{},data:t}):(n=e&&e.label,a=typeof n===w?n.call(e,{hash:{},data:t}):n),a||0===a?a:""}function p(e,t){var a,n,r="";return r+="\n ",(n=i.label)?a=n.call(e,{hash:{},data:t}):(n=e&&e.label,a=typeof n===w?n.call(e,{hash:{},data:t}):n),(a||0===a)&&(r+=a),r+="\n "}function u(e,t,a){var n,r="";return r+="\n \n ",n=i.each.call(e,e&&e.data,{hash:{},inverse:x.noop,fn:x.program(14,h,t),data:t}),(n||0===n)&&(r+=n),r+='\n\n \n \n
\n ',n=i.each.call(e,a&&a.arrayItemActions,{hash:{},inverse:x.noop,fn:x.program(16,f,t),data:t}),(n||0===n)&&(r+=n),r+="\n
\n \n \n "}function h(e){var t,i="";return i+="\n ",t=typeof e===w?e.apply(e):e,(t||0===t)&&(i+=t),i+="\n "}function f(e,t){var a,n,r="";return r+='\n \n "}function m(e){var t,i="";return i+='\n \n '}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var g,v,y,b="",w="function",F=this.escapeExpression,x=this,S=i.helperMissing;return b+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"].container=function(e,t,i,a,n){function r(e,t){var a,n="";return n+='\n ',a=e&&e.options,a=null==a||a===!1?a:a.label,a=typeof a===f?a.apply(e):a,(a||0===a)&&(n+=a),n+="\n "}function s(e){var t;return m((t=e&&e.options,t=null==t||t===!1?t:t.labelClass,typeof t===f?t.apply(e):t))}function o(e,t){var a,n="";return n+='\n

\n \n ',a=e&&e.options,a=null==a||a===!1?a:a.helper,a=typeof a===f?a.apply(e):a,(a||0===a)&&(n+=a),n+="\n

\n "}function l(e){var t;return m((t=e&&e.options,t=null==t||t===!1?t:t.helperClass,typeof t===f?t.apply(e):t))}function c(){var e="";return e}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var d,p,u,h="",f="function",m=this.escapeExpression,g=this,v=i.blockHelperMissing;return h+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"]["control-any"]=function(e,t,i,a,n){function r(){return'readonly="readonly"'}function s(e,t){var a,n,r="";return r+='name="',(n=i.name)?a=n.call(e,{hash:{},data:t}):(n=e&&e.name,a=typeof n===p?n.call(e,{hash:{},data:t}):n),r+=u(a)+'"'}function o(e,t){var i,a="";return a+="data-"+u((i=null==t||t===!1?t:t.key,typeof i===p?i.apply(e):i))+'="'+u(typeof e===p?e.apply(e):e)+'"'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var l,c,d="",p="function",u=this.escapeExpression,h=this;return d+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"]["control-checkbox"]=function(e,t,i,a,n){function r(e,t,a){var n,r="";return r+="\n\n ",n=i.each.call(e,e&&e.checkboxOptions,{hash:{},inverse:m.noop,fn:m.programWithDepth(2,s,t,a),data:t}),(n||0===n)&&(r+=n),r+="\n\n "}function s(e,t,a){var n,r,s="";return s+='\n\n
\n\n \n
\n\n "}function o(){return'readonly="readonly"'}function l(e,t){var a,n,r="";return r+='name="',(n=i.name)?a=n.call(e,{hash:{},data:t}):(n=e&&e.name,a=typeof n===h?n.call(e,{hash:{},data:t}):n),r+=f(a)+'"'}function c(e,t){var a,n,r="";return r+="data-"+f((a=null==t||t===!1?t:t.key,typeof a===h?a.apply(e):a))+'="',(n=i.value)?a=n.call(e,{hash:{},data:t}):(n=e&&e.value,a=typeof n===h?n.call(e,{hash:{},data:t}):n),r+=f(a)+'"'}function d(e,t){var a,n="";return n+='\n\n
\n\n \n\n
\n\n "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var p,u="",h="function",f=this.escapeExpression,m=this; +return u+='\n"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"]["control-ckeditor"]=function(e,t,i,a,n){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var r,s,o="",l="function",c=this.escapeExpression;return o+=''},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"]["control-editor"]=function(e,t,i,a,n){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var r,s,o="",l="function",c=this.escapeExpression;return o+=''},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"]["control-file"]=function(e,t,i,a,n){function r(e){var t,i="";return i+='size="'+h((t=e&&e.options,t=null==t||t===!1?t:t.size,typeof t===u?t.apply(e):t))+'"'}function s(){return'readonly="readonly"'}function o(e,t){var a,n,r="";return r+='name="',(n=i.name)?a=n.call(e,{hash:{},data:t}):(n=e&&e.name,a=typeof n===u?n.call(e,{hash:{},data:t}):n),r+=h(a)+'"'}function l(e,t){var i,a="";return a+="data-"+h((i=null==t||t===!1?t:t.key,typeof i===u?i.apply(e):i))+'="'+h(typeof e===u?e.apply(e):e)+'"'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var c,d,p="",u="function",h=this.escapeExpression,f=this;return p+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"]["control-hidden"]=function(e,t,i,a,n){function r(e,t){var a,n,r="";return r+='name="',(n=i.name)?a=n.call(e,{hash:{},data:t}):(n=e&&e.name,a=typeof n===d?n.call(e,{hash:{},data:t}):n),r+=p(a)+'"'}function s(e,t){var i,a="";return a+="data-"+p((i=null==t||t===!1?t:t.key,typeof i===d?i.apply(e):i))+'="'+p(typeof e===d?e.apply(e):e)+'"'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var o,l,c="",d="function",p=this.escapeExpression,u=this;return c+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"]["control-image"]=function(e,t,i,a,n){function r(e){var t,i="";return i+='placeholder="'+f((t=e&&e.options,t=null==t||t===!1?t:t.placeholder,typeof t===h?t.apply(e):t))+'"'}function s(e){var t,i="";return i+='size="'+f((t=e&&e.options,t=null==t||t===!1?t:t.size,typeof t===h?t.apply(e):t))+'"'}function o(){return'readonly="readonly"'}function l(e,t){var a,n,r="";return r+='name="',(n=i.name)?a=n.call(e,{hash:{},data:t}):(n=e&&e.name,a=typeof n===h?n.call(e,{hash:{},data:t}):n),r+=f(a)+'"'}function c(e,t){var i,a="";return a+="data-"+f((i=null==t||t===!1?t:t.key,typeof i===h?i.apply(e):i))+'="'+f(typeof e===h?e.apply(e):e)+'"'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var d,p,u="",h="function",f=this.escapeExpression,m=this;return u+=''},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"]["control-password"]=function(e,t,i,a,n){function r(e){var t,i="";return i+='placeholder="'+f((t=e&&e.options,t=null==t||t===!1?t:t.placeholder,typeof t===h?t.apply(e):t))+'"'}function s(e){var t,i="";return i+='size="'+f((t=e&&e.options,t=null==t||t===!1?t:t.size,typeof t===h?t.apply(e):t))+'"'}function o(){return'readonly="readonly"'}function l(e,t){var a,n,r="";return r+='name="',(n=i.name)?a=n.call(e,{hash:{},data:t}):(n=e&&e.name,a=typeof n===h?n.call(e,{hash:{},data:t}):n),r+=f(a)+'"'}function c(e,t){var i,a="";return a+="data-"+f((i=null==t||t===!1?t:t.key,typeof i===h?i.apply(e):i))+'="'+f(typeof e===h?e.apply(e):e)+'"'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var d,p,u="",h="function",f=this.escapeExpression,m=this;return u+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"]["control-radio"]=function(e,t,i,a,n,r){function s(){return"\n "}function o(e,t){var a,n,r="";return r+='\n
\n \n
\n "}function l(){return'readonly="readonly"'}function c(e,t,a){var n,r,s,o="";return o+='\n
\n \n
\n "}function d(){return'checked="checked"'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var p,u="",h=this,f="function",m=this.escapeExpression,g=i.helperMissing;return u+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"]["control-select"]=function(e,t,i,a,n){function r(){return'readonly="readonly"'}function s(){return'multiple="multiple"'}function o(e){var t,i="";return i+='size="'+F((t=e&&e.options,t=null==t||t===!1?t:t.size,typeof t===w?t.apply(e):t))+'"'}function l(e,t){var a,n,r="";return r+='name="',(n=i.name)?a=n.call(e,{hash:{},data:t}):(n=e&&e.name,a=typeof n===w?n.call(e,{hash:{},data:t}):n),r+=F(a)+'"'}function c(e,t){var a,n="";return n+="\n\n ",a=i["if"].call(e,e&&e.hideNone,{hash:{},inverse:x.program(12,p,t),fn:x.program(10,d,t),data:t}),(a||0===a)&&(n+=a),n+="\n\n ",a=i.each.call(e,e&&e.selectOptions,{hash:{},inverse:x.noop,fn:x.programWithDepth(14,u,t,e),data:t}),(a||0===a)&&(n+=a),n+="\n\n "}function d(){return"\n "}function p(e,t){var a,n,r="";return r+='\n \n "}function u(e,t,a){var n,r,s="";return s+='\n \n "}function h(e,t,a){var n,r,s;return r=i.compare||e&&e.compare,s={hash:{},inverse:x.noop,fn:x.program(16,f,t),data:t},n=r?r.call(e,e&&e.value,a&&a.value,s):S.call(e,"compare",e&&e.value,a&&a.value,s),n||0===n?n:""}function f(){return'selected="selected"'}function m(e,t,a){var n,r="";return r+="\n\n ",n=i["if"].call(e,e&&e.hideNone,{hash:{},inverse:x.program(12,p,t),fn:x.program(10,d,t),data:t}),(n||0===n)&&(r+=n),r+="\n\n ",n=i.each.call(e,e&&e.selectOptions,{hash:{},inverse:x.noop,fn:x.programWithDepth(19,g,t,a),data:t}),(n||0===n)&&(r+=n),r+="\n\n "}function g(e,t,a){var n,r,s,o="";return o+='\n \n "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var v,y,b="",w="function",F=this.escapeExpression,x=this,S=i.helperMissing;return b+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"]["control-text"]=function(e,t,i,a,n){function r(e){var t,i="";return i+='placeholder="'+m((t=e&&e.options,t=null==t||t===!1?t:t.placeholder,typeof t===f?t.apply(e):t))+'"'}function s(e){var t,i="";return i+='size="'+m((t=e&&e.options,t=null==t||t===!1?t:t.size,typeof t===f?t.apply(e):t))+'"'}function o(){return'readonly="readonly"'}function l(e,t){var a,n,r="";return r+='name="',(n=i.name)?a=n.call(e,{hash:{},data:t}):(n=e&&e.name,a=typeof n===f?n.call(e,{hash:{},data:t}):n),r+=m(a)+'"'}function c(e,t){var i,a="";return a+="data-"+m((i=null==t||t===!1?t:t.key,typeof i===f?i.apply(e):i))+'="'+m(typeof e===f?e.apply(e):e)+'"'}function d(e,t){var i,a="";return a+=m((i=null==t||t===!1?t:t.key,typeof i===f?i.apply(e):i))+'="'+m(typeof e===f?e.apply(e):e)+'"'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var p,u,h="",f="function",m=this.escapeExpression,g=this;return h+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"]["control-textarea"]=function(e,t,i,a,n){function r(e){var t,i="";return i+='placeholder="'+m((t=e&&e.options,t=null==t||t===!1?t:t.placeholder,typeof t===f?t.apply(e):t))+'"'}function s(e){var t,i="";return i+='rows="'+m((t=e&&e.options,t=null==t||t===!1?t:t.rows,typeof t===f?t.apply(e):t))+'"'}function o(e){var t,i="";return i+='cols="'+m((t=e&&e.options,t=null==t||t===!1?t:t.cols,typeof t===f?t.apply(e):t))+'"'}function l(){return'readonly="readonly"'}function c(e,t){var a,n,r="";return r+='name="',(n=i.name)?a=n.call(e,{hash:{},data:t}):(n=e&&e.name,a=typeof n===f?n.call(e,{hash:{},data:t}):n),r+=m(a)+'"'}function d(e,t){var a,n,r="";return r+="data-",(n=i.fieldId)?a=n.call(e,{hash:{},data:t}):(n=e&&e.fieldId,a=typeof n===f?n.call(e,{hash:{},data:t}):n),r+=m(a)+'="',(n=i.value)?a=n.call(e,{hash:{},data:t}):(n=e&&e.value,a=typeof n===f?n.call(e,{hash:{},data:t}):n),(a||0===a)&&(r+=a),r+='"'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var p,u,h="",f="function",m=this.escapeExpression,g=this;return h+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"]["control-url"]=function(e,t,i,a,n){function r(e){var t,i="";return i+='placeholder="'+f((t=e&&e.options,t=null==t||t===!1?t:t.placeholder,typeof t===h?t.apply(e):t))+'"'}function s(e){var t,i="";return i+='size="'+f((t=e&&e.options,t=null==t||t===!1?t:t.size,typeof t===h?t.apply(e):t))+'"'}function o(){return'readonly="readonly"'}function l(e,t){var a,n,r="";return r+='name="',(n=i.name)?a=n.call(e,{hash:{},data:t}):(n=e&&e.name,a=typeof n===h?n.call(e,{hash:{},data:t}):n),r+=f(a)+'"'}function c(e,t){var i,a="";return a+="data-"+f((i=null==t||t===!1?t:t.key,typeof i===h?i.apply(e):i))+'="'+f(typeof e===h?e.apply(e):e)+'"'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var d,p,u="",h="function",f=this.escapeExpression,m=this;return u+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"].control=function(e,t,i,a,n){function r(e,t){var a,n,r="";return r+='\n \n "}function s(e){var t;return m((t=e&&e.options,t=null==t||t===!1?t:t.labelClass,typeof t===f?t.apply(e):t))}function o(){var e="";return e}function l(e,t){var a,n="";return n+='\n

\n \n ',a=e&&e.options,a=null==a||a===!1?a:a.helper,a=typeof a===f?a.apply(e):a,(a||0===a)&&(n+=a),n+="\n

\n "}function c(e){var t;return m((t=e&&e.options,t=null==t||t===!1?t:t.helperClass,typeof t===f?t.apply(e):t))}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var d,p,u,h="",f="function",m=this.escapeExpression,g=this,v=i.blockHelperMissing;return h+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"].form=function(e,t,i,a,n){function r(){var e="";return e}function s(e,t){var a,n="";return n+="\n ",a=i.each.call(e,(a=e&&e.options,null==a||a===!1?a:a.buttons),{hash:{},inverse:m.noop,fn:m.program(4,o,t),data:t}),(a||0===a)&&(n+=a),n+="\n "}function o(e,t){var a,n,r="";return r+='\n \n "}function l(e,t){var a,n,r="";return r+=f((a=null==t||t===!1?t:t.key,typeof a===h?a.apply(e):a))+'="',(n=i.value)?a=n.call(e,{hash:{},data:t}):(n=e&&e.value,a=typeof n===h?n.call(e,{hash:{},data:t}):n),r+=f(a)+'"'}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var c,d,p,u="",h="function",f=this.escapeExpression,m=this,g=i.blockHelperMissing;return u+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"].message=function(e,t,i,a,n){this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var r,s,o="",l="function";return o+='"},this.HandlebarsPrecompiled=this.HandlebarsPrecompiled||{},this.HandlebarsPrecompiled["web-edit"]=this.HandlebarsPrecompiled["web-edit"]||{},this.HandlebarsPrecompiled["web-edit"].wizard=function(e,t,i,a,n){function r(e,t){var a,n="";return n+='\n
\n \n
\n "}function s(e,t){var a,n,r="";return r+='\n
  • \n
    \n
    ',(n=i.title)?a=n.call(e,{hash:{},data:t}):(n=e&&e.title,a=typeof n===m?n.call(e,{hash:{},data:t}):n),(a||0===a)&&(r+=a),r+='
    \n
    ',(n=i.description)?a=n.call(e,{hash:{},data:t}):(n=e&&e.description,a=typeof n===m?n.call(e,{hash:{},data:t}):n),(a||0===a)&&(r+=a),r+='
    \n
    \n
    \n
  • \n '}function o(){return'\n
    \n
    \n
    \n
    \n
    \n
    \n '}function l(e,t){var a,n,r="";return r+="\n

    ",(n=i.wizardTitle)?a=n.call(e,{hash:{},data:t}):(n=e&&e.wizardTitle,a=typeof n===m?n.call(e,{hash:{},data:t}):n),(a||0===a)&&(r+=a),r+="

    \n "}function c(e,t){var a,n,r="";return r+="\n

    ",(n=i.wizardDescription)?a=n.call(e,{hash:{},data:t}):(n=e&&e.wizardDescription,a=typeof n===m?n.call(e,{hash:{},data:t}):n),(a||0===a)&&(r+=a),r+="

    \n "}function d(e,t){var a,n,r,s="";return s+="\n ",n=i.compare||e&&e.compare,r={hash:{},inverse:v.noop,fn:v.program(11,p,t),data:t},a=n?n.call(e,e&&e.align,"left",r):y.call(e,"compare",e&&e.align,"left",r),(a||0===a)&&(s+=a),s+="\n "}function p(e,t){var a,n,r="";return r+='\n \n "}function u(e,t){var a,n,r,s="";return s+="\n ",n=i.compare||e&&e.compare,r={hash:{},inverse:v.noop,fn:v.program(11,p,t),data:t},a=n?n.call(e,e&&e.align,"right",r):y.call(e,"compare",e&&e.align,"right",r),(a||0===a)&&(s+=a),s+="\n "}this.compilerInfo=[4,">= 1.0.0"],i=this.merge(i,e.helpers),n=n||{};var h,f="",m="function",g=this.escapeExpression,v=this,y=i.helperMissing;return f+=''},function(e,t,i){t[e]=i()}("Base",this,function(){var e=function(){};return e.extend=function(t,i){var a=e.prototype.extend;e._prototyping=!0;var n=new this;a.call(n,t),n.base=function(){},delete e._prototyping;var r=n.constructor,s=n.constructor=function(){if(!e._prototyping)if(this._constructing||this.constructor===s)this._constructing=!0,r.apply(this,arguments),delete this._constructing;else if(null!==arguments[0])return(arguments[0].extend||a).call(arguments[0],n)};return s.ancestor=this,s.extend=this.extend,s.forEach=this.forEach,s.implement=this.implement,s.prototype=n,s.toString=this.toString,s.valueOf=function(e){return"object"===e?s:r.valueOf()},a.call(s,i),"function"==typeof s.init&&s.init(),s},e.prototype={extend:function(t,i){if(arguments.length>1){var a=this[t];if(a&&"function"==typeof i&&(!a.valueOf||a.valueOf()!==i.valueOf())&&/\bbase\b/.test(i)){var n=i.valueOf();i=function(){var t=this.base||e.prototype.base;this.base=a;var i=n.apply(this,arguments);return this.base=t,i},i.valueOf=function(e){return"object"===e?i:n},i.toString=e.toString}this[t]=i}else if(t){var r=e.prototype.extend;e._prototyping||"function"==typeof this||(r=this.extend||r);for(var s={toSource:null},o=["constructor","toString","valueOf"],l=e._prototyping?0:1;l=2&&(t.isObject(i[1])?(n=i[1].data,r=i[1].schema,s=i[1].options,o=i[1].view,l=i[1].render,c=i[1].postRender,d=i[1].error,p=i[1].connector,f=i[1].dataSource,m=i[1].schemaSource,g=i[1].optionsSource,v=i[1].viewSource,i[1].ui&&(h.ui=i[1].ui),i[1].type&&(h.type=i[1].type),t.isEmpty(i[1].notTopLevel)||(u=i[1].notTopLevel)):(n=i[1],t.isFunction(n)&&(n=n()))),t.isEmpty(d)&&(d=t.defaultErrorCallback),t.isEmpty(p)){var T=t.getConnectorClass("default"); +p=new T("default")}a&&t.isString(a)&&(a=e("#"+a));var C=p;if(u){var O=t.getConnectorClass("default");C=new O("default")}s||(s={});var I=function(e){e.parent||(e.hideInitValidationError||e.refreshValidationState(!0),"view"!==e.view.type&&t.fieldApplyFieldAndChildren(e,function(e){e.hideInitValidationError=!1}))},k=function(e){e.parent||(e.observableScope=t.generateId()),t.isUndefined(s.focus)&&!e.parent&&(s.focus=t.defaultFocus),s&&s.focus?window.setTimeout(function(){var t=function(e){e.suspendBlurFocus=!0,e.focus(),e.suspendBlurFocus=!1};if(s.focus){if(e.isControlField&&e.isAutoFocusable())t(e);else if(e.isContainerField)if(s.focus===!0){if(e.children&&e.children.length>0)for(var i=0;i"+i+"
    ",a=e(i).children()}return a}return i},isEmpty:function(e){var i=this;if(t.isUndefined(e))return!0;if(null===e)return!0;if(e&&t.isObject(e)){var a=i.countProperties(e);if(0===a)return!0}return!1},countProperties:function(e){var i=0;if(e&&t.isObject(e))for(var a in e)e.hasOwnProperty(a)&&"function"!=typeof e[a]&&i++;return i},copyOf:function(i){var a=i;if(t.isArray(i)){a=[];for(var n=0;nt;t++)lang.isNull(e[t])||lang.isUndefined(e[t])||i.push(e[t]);return i},removeAccents:function(e){return e.replace(/[àáâãäå]/g,"a").replace(/[èéêë]/g,"e").replace(/[ìíîï]/g,"i").replace(/[òóôõö]/g,"o").replace(/[ùúûü]/g,"u").replace(/[ýÿ]/g,"y").replace(/[ñ]/g,"n").replace(/[ç]/g,"c").replace(/[œ]/g,"oe").replace(/[æ]/g,"ae")},indexOf:function(e,i,a){var n,r=i.length;for(t.isFunction(a)||(a=function(e,t){return e===t}),n=0;r>n;n++)if(a.call({},e,i[n]))return n;return-1},uniqueIdCounter:0,defaultLocale:"en_US",defaultFocus:!0,setDefaultLocale:function(e){this.defaultLocale=e},defaultSchemaFieldMapping:{},registerDefaultSchemaFieldMapping:function(e,t){e&&t&&(this.defaultSchemaFieldMapping[e]=t)},defaultFormatFieldMapping:{},registerDefaultFormatFieldMapping:function(e,t){e&&t&&(this.defaultFormatFieldMapping[e]=t)},getSchemaType:function(e){var i=null;return t.isEmpty(e)&&(i="string"),t.isObject(e)&&(i="object"),t.isString(e)&&(i="string"),t.isNumber(e)&&(i="number"),t.isArray(e)&&(i="array"),t.isBoolean(e)&&(i="boolean"),"object"==typeof e&&(i="object"),i},views:{},generateViewId:function(){return"view-"+this.generateId()},registerView:function(e){var i=e.id;if(!i)return t.throwDefaultError("Cannot register view with missing view id: "+i);var a=this.views[i];if(a)t.mergeObject(a,e);else{this.views[i]=e,e.templates||(e.templates={});for(var n=t.TemplateEngineRegistry.ids(),r=0;r");if(i&&r.attr(i),a&&r.css(a),n)for(var s in n)r.addClass(s)},elementFromTemplate:function(i,a){var n=i;if(a)for(var r in a)n=t.replaceAll(n,"${"+r+"}",a[r]);return e(n)},generateId:function(){return t.uniqueIdCounter++,"alpaca"+t.uniqueIdCounter},later:function(t,i,a,n,r){t=t||0,i=i||{};var s,o,l=a,c=e.makeArray(n);if("string"==typeof a&&(l=i[a]),!l)throw{name:"TypeError",message:"The function is undefined."};return s=function(){l.apply(i,c)},o=r?setInterval(s,t):setTimeout(s,t),{id:o,interval:r,cancel:function(){this.interval?clearInterval(o):clearTimeout(o)}}},endsWith:function(e,t){return-1!==e.indexOf(t,e.length-t.length)},startsWith:function(e,t){return e.substr(0,t.length)===t},isUri:function(e){return t.isString(e)&&(t.startsWith(e,"http://")||t.startsWith(e,"https://")||t.startsWith(e,"/")||t.startsWith(e,"./")||t.startsWith(e,"../"))},traverseObject:function(e,i,a){t.isString(i)&&(i=i.split("."));var n=null,r=e,s=null;do s=i.shift(),a&&s===a&&(s=i.shift()),t.isEmpty(r[s])?i=[]:(r=r[s],0===i.length&&(n=r));while(i.length>0);return n},each:function(e,i){if(t.isArray(e))for(var a=0;a-1){var s=e.substring(0,r)+i[a]+e.substring(r+3);e=s}}return e},compareObject:function(e,t){return equiv(e,t)},compareArrayContent:function(t,i){var a=t&&i&&t.length===i.length;if(a)for(var n=t.length-1;n>=0;n--){var r=t[n];if(e.inArray(r,i)<0)return!1}return a},testRegex:function(e,t){var i=new RegExp(e);return i.test(t)},isValEmpty:function(i){var a=!1;return t.isEmpty(i)?a=!0:(t.isString(i)&&""===i&&(a=!0),t.isObject(i)&&e.isEmptyObject(i)&&(a=!0),t.isArray(i)&&0===i.length&&(a=!0),t.isNumber(i)&&isNaN(i)&&(a=!0)),a},init:function(e,i,a,n,r,s,o,l,c,d){var p=this;if(t.isObject(r)){var u=r.id;u||(r.id=this.generateViewId());var h=r.parent;h||(r.parent="web-edit"),this.registerView(r),r=r.id}this.compile(function(u){if(u.errors&&u.errors.length>0){for(var h=[],f=0;f3?"select":"radio":t.defaultSchemaFieldMapping[n.type],n.format&&t.defaultFormatFieldMapping[n.format]&&(a.type=t.defaultFormatFieldMapping[n.format]));var c=t.getFieldClass(a.type);return c?new c(e,i,a,n,r,s,o):(o({message:"Unable to find field class for type: "+a.type,reason:"FIELD_INSTANTIATION_ERROR"}),null)},parseJSON:function(t){return t?e.parseJSON(t):null},compile:function(i,a){var n=this,r={errors:[],count:0,successCount:0},s=function(e){if(0===r.errors.length)for(var t in e)n.normalizedViews[t]=e[t];i(r)},o=function(e,t,i,a,n){var o=i.id;r.count++,t?r.errors.push({view:o,cacheKey:a,err:t}):r.successCount++,r.count==n&&s(e)},l=function(i,a,n,r,s,l,c){var d=t.makeCacheKey(a.id,n,r,s),p="text/x-handlebars-template";if(l&&t.isObject(l)&&(p=l.type,l.cacheKey&&(d=l.cacheKey),l=l.template),l&&"string"==typeof l){var u=l.toLowerCase();if(0===u.indexOf("http://")||0===u.indexOf("https://")||0===u.indexOf("/")||0===u.indexOf("./"));else if(!l||0!==l.indexOf("#")&&0!==l.indexOf(".")){if(l){var h=a.templates[l];h&&(l=h)}}else{var f=e(l);p=e(f).attr("type"),l=e(f).html()}}if(!p){t.logError("Engine type was empty");var m=new Error("Engine type was empty");return void o(i,m,a,d,c)}var g=t.TemplateEngineRegistry.find(p);if(!g){t.logError("Cannot find template engine for type: "+type);var m=new Error("Cannot find template engine for type: "+type);return void o(i,m,a,d,c)}if(l===!0){if(g.isCached(d))return void o(i,null,a,d,c);var v="View configuration for view: "+a.id+" claims to have precompiled template for cacheKey: "+d+" but it could not be found";return t.logError(v),void o(i,new Error(v),a,d,c)}return g.isCached(d)?void o(i,null,a,d,c):void g.compile(d,l,function(e){o(i,e,a,d,c)})},c=function(e){var t=[];for(var i in e){var a=e[i];if(a.templates)for(var n in a.templates){var r=a.templates[n];t.push(function(e,t,i,a,n,r){return function(s){l(e,t,i,a,n,r,s)}}(e,a,"view",a.id,n,r))}if(a.fields)for(var s in a.fields)if(a.fields[s].templates)for(var n in a.fields[s].templates){var r=a.fields[s].templates[n];t.push(function(e,t,i,a,n,r){return function(s){l(e,t,i,a,n,r,s)}}(e,a,"field",s,n,r))}if(a.layout&&a.layout.template){var r=a.layout.template;t.push(function(e,t,i,a,n,r){return function(s){l(e,t,i,a,n,r,s)}}(e,a,"layout","layout","layoutTemplate",r))}if(a.globalTemplate){var r=a.globalTemplate;t.push(function(e,t,i,a,n,r){return function(s){l(e,t,i,a,n,r,s)}}(e,a,"global","global","globalTemplate",r))}}for(var o=t.length,c=0;c0?c(e):s(e)};d()},getTemplateDescriptor:function(e,i,a){var n=null,r=null,s=null;if(e.templates&&e.templates[i]){s=t.makeCacheKey(e.id,"view",e.id,i);var o=e.templates[i];t.isObject(o)&&o.cacheKey&&(s=o.cacheKey)}if(a&&a.path){var l=a.path;e&&e.fields&&e.fields[l]&&e.fields[l].templates&&e.fields[l].templates[i]&&(s=t.makeCacheKey(e.id,"field",l,i))}if(("globalTemplate"===i||"global"===i)&&(s=t.makeCacheKey(e.id,"global","global","globalTemplate")),("layoutTemplate"===i||"layout"===i)&&(s=t.makeCacheKey(e.id,"layout","layout","layoutTemplate")),s){for(var c=t.TemplateEngineRegistry.ids(),d=0;d").append(this).html():e("
    ").append(this.clone()).html()},e.fn.swapWith=function(t){return this.each(function(){var i=e(t).clone(),a=e(this).clone();e(t).replaceWith(a),e(this).replaceWith(i)})},e.fn.attrProp=function(i,a){return t.attrProp(e(this),i,a)},e.event.special.destroyed={remove:function(e){e.handler&&e.handler()}},t.pathParts=function(e){if("string"!=typeof e)return e;var i=e,a=null,n=i.indexOf("#");n>-1&&(a=i.substring(n+1),i=i.substring(0,n)),t.endsWith(i,"/")&&(i=i.substring(0,i.length-1));var r={};return r.path=i,a&&(r.id=a),r},t.resolveField=function(e,i){var a=null;if("string"==typeof i)if(0===i.indexOf("#/")&&propertyId.length>2);else if("#"===i||"#/"===i)a=e;else if(0===i.indexOf("#")){for(var n=e;n.parent;)n=n.parent;var r=i.substring(1);a=t.resolveFieldByReference(n,r)}else a=e.childrenByPropertyId[i];return a},t.resolveFieldByReference=function(e,i){if(e.schema&&e.schema.id==i)return e;if(e.children&&e.children.length>0)for(var a=0;a1){var l=e.slice(0);l.shift(),r(l,t,function(){o(a,n,function(){i()})})}else o(a,n,function(){i()})};r(i,n,function(){t(n)})},t.updateValidationStateForContext=function(e,i){for(var a=0;a0)for(var i=0;i=t.length&&a(null))}))})},r.forEach=r.each,r.eachSeries=function(e,t,i){if(i=i||function(){},!e.length)return i();var a=0,n=function(){t(e[a],function(t){t?(i(t),i=function(){}):(a+=1,a>=e.length?i(null):n())})};n()},r.forEachSeries=r.eachSeries,r.eachLimit=function(e,t,i,a){var n=d(t);n.apply(null,[e,i,a])},r.forEachLimit=r.eachLimit;var d=function(e){return function(t,i,a){if(a=a||function(){},!t.length||0>=e)return a();var n=0,r=0,s=0;!function o(){if(n>=t.length)return a();for(;e>s&&r=t.length?a():o())})}()}},p=function(e){return function(){var t=Array.prototype.slice.call(arguments);return e.apply(null,[r.each].concat(t))}},u=function(e,t){return function(){var i=Array.prototype.slice.call(arguments);return t.apply(null,[d(e)].concat(i))}},h=function(e){return function(){var t=Array.prototype.slice.call(arguments);return e.apply(null,[r.eachSeries].concat(t))}},f=function(e,t,i,a){var n=[];t=o(t,function(e,t){return{index:t,value:e}}),e(t,function(e,t){i(e.value,function(i,a){n[e.index]=a,t(i)})},function(e){a(e,n)})};r.map=p(f),r.mapSeries=h(f),r.mapLimit=function(e,t,i,a){return m(t)(e,i,a)};var m=function(e){return u(e,f)};r.reduce=function(e,t,i,a){r.eachSeries(e,function(e,a){i(t,e,function(e,i){t=i,a(e)})},function(e){a(e,t)})},r.inject=r.reduce,r.foldl=r.reduce,r.reduceRight=function(e,t,i,a){var n=o(e,function(e){return e}).reverse();r.reduce(n,t,i,a)},r.foldr=r.reduceRight;var g=function(e,t,i,a){var n=[];t=o(t,function(e,t){return{index:t,value:e}}),e(t,function(e,t){i(e.value,function(i){i&&n.push(e),t()})},function(){a(o(n.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})};r.filter=p(g),r.filterSeries=h(g),r.select=r.filter,r.selectSeries=r.filterSeries;var v=function(e,t,i,a){var n=[];t=o(t,function(e,t){return{index:t,value:e}}),e(t,function(e,t){i(e.value,function(i){i||n.push(e),t()})},function(){a(o(n.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})};r.reject=p(v),r.rejectSeries=h(v);var y=function(e,t,i,a){e(t,function(e,t){i(e,function(i){i?(a(e),a=function(){}):t()})},function(){a()})};r.detect=p(y),r.detectSeries=h(y),r.some=function(e,t,i){r.each(e,function(e,a){t(e,function(e){e&&(i(!0),i=function(){}),a()})},function(){i(!1)})},r.any=r.some,r.every=function(e,t,i){r.each(e,function(e,a){t(e,function(e){e||(i(!1),i=function(){}),a()})},function(){i(!0)})},r.all=r.every,r.sortBy=function(e,t,i){r.map(e,function(e,i){t(e,function(t,a){t?i(t):i(null,{value:e,criteria:a})})},function(e,t){if(e)return i(e);var a=function(e,t){var i=e.criteria,a=t.criteria;return a>i?-1:i>a?1:0};i(null,o(t.sort(a),function(e){return e.value}))})},r.auto=function(e,t){t=t||function(){};var i=c(e);if(!i.length)return t(null);var a={},n=[],o=function(e){n.unshift(e)},d=function(e){for(var t=0;tt;t++)e[t].apply(null,arguments)}])))};return n.memo=i,n.unmemoized=e,n},r.unmemoize=function(e){return function(){return(e.unmemoized||e).apply(null,arguments)}},r.times=function(e,t,i){for(var a=[],n=0;e>n;n++)a.push(n);return r.map(a,t,i)},r.timesSeries=function(e,t,i){for(var a=[],n=0;e>n;n++)a.push(n);return r.mapSeries(a,t,i)},r.compose=function(){var e=Array.prototype.reverse.call(arguments);return function(){var t=this,i=Array.prototype.slice.call(arguments),a=i.pop();r.reduce(e,i,function(e,i,a){i.apply(t,e.concat([function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1);a(e,t)}]))},function(e,i){a.apply(t,[e].concat(i))})}};var x=function(e,t){var i=function(){var i=this,a=Array.prototype.slice.call(arguments),n=a.pop();return e(t,function(e,t){e.apply(i,a.concat([t]))},n)};if(arguments.length>2){var a=Array.prototype.slice.call(arguments,2);return i.apply(this,a)}return i};r.applyEach=p(x),r.applyEachSeries=h(x),r.forever=function(e,t){function i(a){if(a){if(t)return t(a);throw a}e(i)}i()},a.async=r;!function(){var e,a=[],n=function(){function i(e,t){return e instanceof t.constructor||t instanceof e.constructor?t==e:t===e}return{string:i,"boolean":i,number:i,"null":i,undefined:i,nan:function(e){return isNaN(e) +},date:function(e,i){return"date"===t(e)&&i.valueOf()===e.valueOf()},regexp:function(e,i){return"regexp"===t(e)&&i.source===e.source&&i.global===e.global&&i.ignoreCase===e.ignoreCase&&i.multiline===e.multiline},"function":function(){var e=a[a.length-1];return e!==Object&&"undefined"!=typeof e},array:function(i,a){var n,r;if("array"!==t(i))return!1;if(r=a.length,r!==i.length)return!1;for(n=0;r>n;n++)if(!e(a[n],i[n]))return!1;return!0},object:function(t,i){var n,r=!0,s=[],o=[];if(i.constructor!==t.constructor)return!1;a.push(i.constructor);for(n in i)s.push(n),e(i[n],t[n])||(r=!1);a.pop();for(n in t)o.push(n);return r&&e(s.sort(),o.sort())}}}();return e=function(){var e=Array.prototype.slice.apply(arguments);return e.length<2?!0:function(e,a){return e===a?!0:null===e||null===a||"undefined"==typeof e||"undefined"==typeof a||t(e)!==t(a)?!1:i(e,n,[a,e])}(e[0],e[1])&&arguments.callee.apply(this,e.splice(1,e.length-1))}}()}(),t.MARKER_CLASS_CONTROL_FIELD="alpaca-marker-control-field",t.MARKER_CLASS_CONTAINER_FIELD="alpaca-marker-container-field",t.MARKER_CLASS_CONTAINER_FIELD_ITEM="alpaca-marker-control-field-item",t.MARKER_DATA_CONTAINER_FIELD_ITEM_KEY="data-alpaca-container-field-item-key",t.MARKER_CLASS_FORM_ITEMS_FIELD="alpaca-marker-form-items-field",t.CLASS_CONTAINER="alpaca-container",t.CLASS_CONTROL="alpaca-control",t.MARKER_CLASS_INSERT="alpaca-marker-insert",t.MARKER_DATA_INSERT_KEY="data-alpaca-marker-insert-key",t.makeCacheKey=function(e,t,i,a){return e+":"+t+":"+i+":"+a},t.splitCacheKey=function(e){var t={},i=e.indexOf(":"),a=e.lastIndexOf(":");t.viewId=e.substring(0,i),t.templateId=e.substring(a+1);var n=e.substring(i+1,a),r=n.indexOf(":");return t.scopeType=n.substring(0,r),t.scopeId=n.substring(r+1),t},t.createEmptyDataInstance=function(){return""},t.animatedSwap=function(t,i,a,n){"function"==typeof a&&(n=a,a=500);var r=function(t,i,a,n){var r=e(t),s=e(i),o=r.offset(),l=s.offset(),c=r.clone(),d=s.clone(),p=l.top+s.height()-o.top,u=0,h=0,f=l.left+s.width()-o.left,m=0,g=0;r.css("opacity",0),s.css("opacity",0),c.insertAfter(r).css({position:"absolute",width:r.outerWidth(),height:r.outerHeight()}).offset(o).css("z-index","999"),d.insertAfter(s).css({position:"absolute",width:s.outerWidth(),height:s.outerHeight()}).offset(l).css("z-index","999"),o.top!==l.top&&(u=p-r.height()),h=p-s.height(),o.left!==l.left&&(m=f-r.width()),g=f-s.width(),c.animate({top:"+="+u+"px",left:"+="+m+"px"},a,function(){s.css("opacity",1),e(this).remove()}),d.animate({top:"-="+h+"px",left:"-="+g+"px"},a,function(){r.css("opacity",1),e(this).remove()}),window.setTimeout(function(){c.remove(),d.remove(),n()},a+1)};r(t,i,a,n)}}(jQuery),function(e){var t=e.alpaca;t.listenerId=function(){var e=0;return function(){return"listener-"+e++}}(),t.subscribe=function(){var e=t.makeArray(arguments),i=null,a=null,n=null;if(2==e.length?(i="global",a=e.shift(),n=e.shift()):(i=e.shift(),a=e.shift(),n=e.shift()),a&&t.isObject(a)&&(a=a.path),!a)return t.logError("Missing observable subscribe id: "+a),null;var r=n._lfid;r||(r=t.listenerId(),n._lfid=r);var s=function(e){return function(){return n.apply(e,arguments)}}(this);s._lfid=n._lfid;var o=t.ScopedObservables.get(i),l=o.observable(a);return l.subscribe(r,s),{scope:i,id:a,listenerId:r}},t.unsubscribe=function(){var e=t.makeArray(arguments),i=null,a=null,n=null;2==e.length?(i="global",a=e.shift(),n=e.shift()):3==e.length&&(i=e.shift(),a=e.shift(),n=e.shift());var r=n;if(t.isFunction(r)&&(r=r._lfid),a&&t.isObject(a)&&(a=a.path),!a)return t.logError("Missing observable id: "+a),null;var s=t.ScopedObservables.get(i),o=s.observable(a);return o.unsubscribe(r),{scope:i,id:a,listenerId:r}},t.observable=function(){var e,i,a=t.makeArray(arguments);if(1==a.length?(e="global",i=a.shift()):2==a.length&&(e=a.shift(),i=a.shift()),i&&t.isObject(i)&&(i=i.path),i){var n=t.ScopedObservables.get(e);observable=n.observable(i)}else t.logError("Missing observable id: "+JSON.stringify(a));return observable},t.clearObservable=function(){var e,i,a=t.makeArray(arguments);1==a.length?(e="global",i=a.shift()):2==a.length&&(e=a.shift(),i=a.shift()),i&&t.isObject(i)&&(i=i.path),i||t.logError("Missing observable id: "+JSON.stringify(a));var n=t.ScopedObservables.get(e),r=n.observable(i);r.clear()},t.dependentObservable=function(){var e=null,i=null,a=null,n=t.makeArray(arguments);if(2==n.length)e="global",i=n.shift(),a=n.shift();else{if(3!=n.length)return void t.error("Wrong number of arguments");e=n.shift(),i=n.shift(),a=n.shift()}i&&t.isObject(i)&&(i=i.path),i||t.logError("Missing observable id: "+JSON.stringify(n));var r=t.ScopedObservables.get(e);return r.dependentObservable(i,a)}}(jQuery),function(e){var t=e.alpaca;t.Observables=Base.extend({constructor:function(e){this.base(),this.scope=e,this.observables={}},observable:function(e,i){if(!this.observables[e]){var a=new t.Observable(this.scope,e);i&&a.set(i),this.observables[e]=a}return this.observables[e]},dependentObservable:function(e,i){var a=this;if(!this.observables[e]){var n=this.observable(e),r=new t.Observables(this.scope);r.observable=function(e,t){var i=a.observable(e,t);return i.markDependentOnUs(n),i};var s=function(){return i.call(r)};n.setValueFunction(s)}return this.observables[e]},observables:function(){return this.observables}})}(jQuery),function(e){var t=e.alpaca;t.Observable=Base.extend({constructor:function(t,i){this.base(),this.id=t+"-"+i,this.value=null,this.subscribers={},this.dependentOnUs={},this.notifySubscribers=function(t){var i=this;e.each(this.subscribers,function(e,a){a(i.value,t)})},this.notifyDependents=function(){e.each(this.dependentOnUs,function(e,t){t.onDependencyChange()})},this.valueFunction=null},setValueFunction:function(e){this.valueFunction=e,this.onDependencyChange()},subscribe:function(e,t){this.isSubscribed(e)||(this.subscribers[e]=t)},unsubscribe:function(e){delete this.subscribers[e]},isSubscribed:function(e){return this.subscribers[e]?!0:!1},markDependentOnUs:function(e){this.dependentOnUs[e.id]=e},onDependencyChange:function(){var e=this.get();if(this.valueFunction){var t=this.valueFunction();e!=t&&this.set(t)}},set:function(e){var t=this.value;this.value=e,this.notifyDependents(t),this.notifySubscribers(t)},get:function(e){var t=this.value;return t||(t=e),t},clear:function(){var e=this.value;delete this.value,this.notifyDependents(e),this.notifySubscribers(e)}})}(jQuery),function(e){var t=e.alpaca;t.ScopedObservables={},t.ScopedObservables.map={},t.ScopedObservables.get=function(e){return t.ScopedObservables.map[e]||(t.ScopedObservables.map[e]=new t.Observables(e)),t.ScopedObservables.map[e]}}(jQuery),function(){Alpaca.TemplateEngineRegistry=function(){var e={};return{register:function(t,i){e[t]=i,i.init()},find:function(t){var i=null;if(e[t])i=e[t];else for(var a in e)for(var n=e[a].supportedMimetypes(),r=0;r"+t+""),Alpaca.logDebug("Compiling template: "+this.id+", cacheKey: "+e+", template: "+t),this.doCompile(e,t,i)},doCompile:function(){},execute:function(e,t,i){Alpaca.logDebug("Executing template for cache key: "+e);var a=this.doExecute(e,t,i);return a=this.cleanup(a)},doExecute:function(){return null},fileExtension:function(){return"html"},supportedMimetypes:function(){return[]},isCached:function(){return!1},findCacheKeys:function(){return[]}})}(jQuery),function($,Handlebars,HandlebarsPrecompiled){var COMPILED_TEMPLATES={},helpers={};helpers.compare=function(e,t,i){if(arguments.length<3)throw new Error("Handlerbars Helper 'compare' needs 2 parameters");var a=i.hash.operator||"==",n={"==":function(e,t){return e==t},"===":function(e,t){return e===t},"!=":function(e,t){return e!=t},"!==":function(e,t){return e!==t},"<":function(e,t){return t>e},">":function(e,t){return e>t},"<=":function(e,t){return t>=e},">=":function(e,t){return e>=t},"typeof":function(e,t){return typeof e==t}};if(!n[a])throw new Error("Handlerbars Helper 'compare' doesn't know the operator "+a);var r=n[a](e,t);return r?i.fn(this):i.inverse(this)},helpers.times=function(e,t){for(var i="",a=0;e>a;++a)i+=t.fn(a);return i},helpers.control=function(){return"
    "},helpers.container=function(){return"
    "},helpers.item=function(){return"
    "},helpers.formItems=function(){return"
    "},helpers.insert=function(e){return"
    "},helpers.str=function(e){return e===!1?"false":e===!0?"true":0===e?"0":"undefined"==typeof e?"":null===e?"":Alpaca.isString(e)?e:Alpaca.isNumber(e)?e:Alpaca.isObject(e)?JSON.stringify(e,null," "):Alpaca.isArray(e)?JSON.stringify(e,null," "):e},Handlebars.registerHelper("setIndex",function(e){this.index=Number(e)}),Handlebars.registerHelper("uploadErrorMessage",function(e){var t=e;return 1===e?t="File exceeds upload_max_filesize":2===e?t="File exceeds MAX_FILE_SIZE":3===e?t="File was only partially uploaded":4===e?t="No File was uploaded":5===e?t="Missing a temporary folder":6===e?t="Failed to write file to disk":7===e?t="File upload stopped by extension":"maxFileSize"===e?t="File is too big":"minFileSize"===e?t="File is too small":"acceptFileTypes"===e?t="Filetype not allowed":"maxNumberOfFiles"===e?t="Max number of files exceeded":"uploadedBytes"===e?t="Uploaded bytes exceed file size":"emptyResult"===e&&(t="Empty file upload result"),t}),Handlebars.registerHelper("compare",helpers.compare),Handlebars.registerHelper("control",helpers.control),Handlebars.registerHelper("container",helpers.container),Handlebars.registerHelper("item",helpers.item),Handlebars.registerHelper("formItems",helpers.formItems),Handlebars.registerHelper("times",helpers.times),Handlebars.registerHelper("str",helpers.str),Handlebars.registerHelper("with",function(e,t){return t.fn(e)});var partials={};Alpaca.HandlebarsTemplateEngine=Alpaca.AbstractTemplateEngine.extend({fileExtension:function(){return"html"},supportedMimetypes:function(){return["text/x-handlebars-template","text/x-handlebars-tmpl"]},init:function(){if(HandlebarsPrecompiled)for(var e in HandlebarsPrecompiled){var t=HandlebarsPrecompiled[e];for(var i in t){var a=t[i];if("function"==typeof a){var n=Alpaca.makeCacheKey(e,"view",e,i);COMPILED_TEMPLATES[n]=a}}}},doCompile:function(cacheKey,html,callback){var self=this,template=null;try{var functionString=Handlebars.precompile(html);template=eval("("+functionString+")"),COMPILED_TEMPLATES[cacheKey]=template}catch(e){return void callback(e)}callback()},doExecute:function(e,t,i){var a=COMPILED_TEMPLATES[e];if(!a)return void i(new Error("Could not find handlebars cached template for key: "+e));var n=null;try{n=Handlebars.template(a)(t)}catch(r){return i(r),null}return n},isCached:function(e){return COMPILED_TEMPLATES[e]?!0:!1},findCacheKeys:function(e){var t=[];for(var i in COMPILED_TEMPLATES)0===i.indexOf(e+":")&&t.push(i);return t}}),Alpaca.TemplateEngineRegistry.register("handlebars",new Alpaca.HandlebarsTemplateEngine("handlebars"))}(jQuery,"undefined"!=typeof Handlebars?Handlebars:window.Handlebars,"undefined"!=typeof HandlebarsPrecompiled?HandlebarsPrecompiled:window.HandlebarsPrecompiled),function(e){var t=e.alpaca;t.NormalizedView=Base.extend({constructor:function(e){this.id=e},normalize:function(e){var i=e[this.id];if(!i)return t.logError("View compilation failed - view not found: "+this.id),!1;for(var a=[],n=i;n;){a.push(n);var r=n.parent;if(r){var s=e[n.parent];if(!s)return t.logError("View compilation failed - cannot find parent view: "+r+" for view: "+n.id),!1;n=s}else n=null}a=a.reverse();for(var o=function(e,i,a){var n=i[a],r=e[a];t.isUndefined(r)||t.isUndefined(n)||t.logDebug("View property: "+a+" already has value: "+r+" and overwriting to: "+n),t.isUndefined(n)||(e[a]=n)},l=function(e,i,a){var n=i[a],r=e[a];t.isUndefined(r)||t.isUndefined(n)||t.logDebug("View property: "+a+" already has function, overwriting"),t.isUndefined(n)||(e[a]=n)},c=function(e,i,a){var n=i[a];n&&(e[a]||(e[a]={}),t.mergeObject2(n,e[a]))},d=0;d");a._processRender(r,function(){n.formFieldsContainer.before(a.field),n.formFieldsContainer.remove(),n.topControl=a,a.view.type&&"view"!==a.view.type&&n.initEvents(),a.form=n,a.postRender(function(){i&&t.isFunction(i)&&i(a)})})})}else this._processRender(a.domEl,function(){a.postRender(function(){i&&t.isFunction(i)&&i(a)})})},_processRender:function(e,t){var i=this;i.renderField(e,function(){i.fireCallback("field"),i.renderFieldElements(function(){t()})})},renderField:function(e,i){var a=this,n=this.getTemplateDescriptor(),r=this.data;this.isDisplayOnly()&&"object"==typeof r&&(r=JSON.stringify(r));var s=t.tmpl(n,{id:this.getId(),options:this.options,schema:this.schema,data:r,view:this.view,path:this.path,name:this.name});a._oldFieldEl=a.field,this.field=s,this.field.appendTo(e),i()},renderFieldElements:function(e){e()},postRender:function(i){var a=this;if(this.field.addClass("alpaca-field"),this.field.addClass("alpaca-field-"+this.getFieldType()),this.field.attr("data-alpaca-field-id",this.getId()),"view"!==this.view.type){this.isRequired()?(e(this.field).addClass("alpaca-required"),a.fireCallback("required")):(e(this.field).addClass("alpaca-optional"),a.fireCallback("optional")),this.options.readonly&&(e(this.field).addClass("alpaca-readonly"),e(":input",this.field).attr("readonly","readonly"),e("select",this.field).attr("disabled","disabled"),e(":radio",this.field).attr("disabled","disabled"),e(":checkbox",this.field).attr("disabled","disabled"),a.fireCallback("readonly"));var n=function(e,i){if(i){var a=0,n=null;if(t.isArray(i))for(a=0;a-1)for(n=i.split(","),a=0;a-1)for(n=i.split(" "),a=0;a");e(i.field).before(a),i.domEl=e("
    "),i.setup(),i._render(function(){e(a).before(i.domEl.children()),e(a).remove(),i._oldFieldEl&&e(i._oldFieldEl).remove(),t&&t()})},applyStyle:function(e,t){this.view.applyStyle(e,t)},fireCallback:function(e,t,i,a,n,r){this.view.fireCallback(this,e,t,i,a,n,r)},getFieldEl:function(){return this.field},getId:function(){return this.id},getParent:function(){return this.parent},isTopLevel:function(){return t.isEmpty(this.parent)},getValue:function(){var e=this,t=this.data;return t=e.ensureProperType(t)},setValue:function(e){this.data=e,this.updateObservable(),this.triggerUpdate()},setDefault:function(){},getTemplateDescriptor:function(){return this.templateDescriptor},setTemplateDescriptor:function(e){this.templateDescriptor=e},displayMessage:function(i){var a=this;i&&t.isObject(i)&&(i=[i]),i&&t.isString(i)&&(i=[{id:"custom",message:i}]),e(this.getFieldEl()).children(".alpaca-message").remove(),a.fireCallback("removeMessages"),i&&i.length>0&&e.each(i,function(i,n){var r=!1;a.hideInitValidationError&&(r=!0);var s=a.view.getTemplateDescriptor("message");if(s){var o=t.tmpl(s,{id:n.id,message:n.message});o.addClass("alpaca-message"),r&&o.addClass("alpaca-message-hidden"),e(a.getFieldEl()).append(o)}a.fireCallback("addMessage",i,n.id,n.message,r)})},refreshValidationState:function(e,i){var a=this,n=[],r=[],s=function(e,i){return function(a){t.compileValidationContext(e,function(e){i.push(e),a()})}};if(e){var o=function(e,t){if(e.isValidationParticipant()){if(e.children&&e.children.length>0)for(var i=0;idisplayReadonly attribute set to false, the read-only field will not appear.",type:"boolean","default":!1},required:{title:"Required",description:"Indicates whether the field's value is required. If set to true, the field must take on a valid value and cannnot be left empty or unassigned.",type:"boolean","default":!1},"default":{title:"Default",description:"The default value to be assigned for this property. If the data for the field is empty or not provided, this default value will be plugged in for you. Specify a default value when you want to pre-populate the field's value ahead of time.",type:"any"},type:{title:"Type",description:"Data type of the property.",type:"string",readonly:!0},format:{title:"Format",description:"Data format of the property.",type:"string"},disallow:{title:"Disallowed Values",description:"List of disallowed values for the property.",type:"array"},dependencies:{title:"Dependencies",description:"List of property dependencies.",type:"array"}}};return this.getType&&!t.isValEmpty(this.getType())&&(e.properties.type["default"]=this.getType(),e.properties.type["enum"]=[this.getType()]),e},getOptionsForSchema:function(){return{fields:{title:{helper:"Field short description",type:"text"},description:{helper:"Field detailed description",type:"textarea"},readonly:{helper:"Field will be read only if checked",rightLabel:"This field is read-only",type:"checkbox"},required:{helper:"Field value must be set if checked",rightLabel:"This field is required",type:"checkbox"},"default":{helper:"Field default value",type:"textarea"},type:{helper:"Field data type",type:"text"},format:{type:"select",dataSource:function(e){for(var i in t.defaultFormatFieldMapping)this.selectOptions.push({value:i,text:i}); +e()}},disallow:{helper:"Disallowed values for the field",itemLabel:"Value",type:"array"},dependencies:{helper:"Field Dependencies",multiple:!0,size:3,type:"select",dataSource:function(e,t){if(e.parent&&e.parent.schemaParent&&e.parent.schemaParent.parent)for(var i in e.parent.schemaParent.parent.childrenByPropertyId)i!=e.parent.schemaParent.propertyId&&e.selectOptions.push({value:i,text:i});t&&t()}}}}},getSchemaOfOptions:function(){var e={title:"Options for "+this.getTitle(),description:this.getDescription()+" (Options)",type:"object",properties:{form:{},id:{title:"Field Id",description:"Unique field id. Auto-generated if not provided.",type:"string"},type:{title:"Field Type",description:"Field type.",type:"string","default":this.getFieldType(),readonly:!0},validate:{title:"Validation",description:"Field validation is required if true.",type:"boolean","default":!0},showMessages:{title:"Show Messages",description:"Display validation messages if true.",type:"boolean","default":!0},disabled:{title:"Disabled",description:"Field will be disabled if true.",type:"boolean","default":!1},readonly:{title:"Readonly",description:"Field will be readonly if true.",type:"boolean","default":!1},hidden:{title:"Hidden",description:"Field will be hidden if true.",type:"boolean","default":!1},label:{title:"Label",description:"Field label.",type:"string"},helper:{title:"Helper",description:"Field help message.",type:"string"},fieldClass:{title:"CSS class",description:"Specifies one or more CSS classes that should be applied to the dom element for this field once it is rendered. Supports a single value, comma-delimited values, space-delimited values or values passed in as an array.",type:"string"},hideInitValidationError:{title:"Hide Initial Validation Errors",description:"Hide initial validation errors if true.",type:"boolean","default":!1},focus:{title:"Focus",description:"If true, the initial focus for the form will be set to the first child element (usually the first field in the form). If a field name or path is provided, then the specified child field will receive focus. For example, you might set focus to 'name' (selecting the 'name' field) or you might set it to 'client/name' which picks the 'name' field on the 'client' object.",type:"checkbox","default":!0},optionLabels:{title:"Enumerated Value Labels",description:"An array of string labels for items in the enum array",type:"array"},view:{title:"Override of the view for this field",description:"Allows for this field to be rendered with a different view (such as 'display' or 'create')",type:"string"}}};return this.isTopLevel()?e.properties.form={title:"Form",description:"Options for rendering the FORM tag.",type:"object",properties:{attributes:{title:"Form Attributes",description:"List of attributes for the FORM tag.",type:"object",properties:{id:{title:"Id",description:"Unique form id. Auto-generated if not provided.",type:"string"},action:{title:"Action",description:"Form submission endpoint",type:"string"},method:{title:"Method",description:"Form submission method","enum":["post","get"],type:"string"},rubyrails:{title:"Ruby On Rails",description:"Ruby on Rails Name Standard","enum":["true","false"],type:"string"},name:{title:"Name",description:"Form name",type:"string"},focus:{title:"Focus",description:"Focus Setting",type:"any"}}},buttons:{title:"Form Buttons",description:"Configuration for form-bound buttons",type:"object",properties:{submit:{type:"object",title:"Submit Button",required:!1},reset:{type:"object",title:"Reset button",required:!1}}},toggleSubmitValidState:{title:"Toggle Submit Valid State",description:"Toggle the validity state of the Submit button",type:"boolean","default":!0}}}:delete e.properties.form,e},getOptionsForOptions:function(){var e={type:"object",fields:{id:{type:"text",readonly:!0},type:{type:"text"},validate:{rightLabel:"Enforce validation",type:"checkbox"},showMessages:{rightLabel:"Show validation messages",type:"checkbox"},disabled:{rightLabel:"Disable this field",type:"checkbox"},hidden:{type:"checkbox",rightLabel:"Hide this field"},label:{type:"text"},helper:{type:"textarea"},fieldClass:{type:"text"},hideInitValidationError:{rightLabel:"Hide initial validation errors",type:"checkbox"},focus:{type:"checkbox",rightLabel:"Auto-focus first child field"},optionLabels:{type:"array",items:{type:"string"}},view:{type:"text"}}};return this.isTopLevel()&&(e.fields.form={type:"object",fields:{attributes:{type:"object",fields:{id:{type:"text",readonly:!0},action:{type:"text"},method:{type:"select"},name:{type:"text"}}}}}),e}}),t.registerMessages({disallowValue:"{0} are disallowed values.",notOptional:"This field is not optional."})}(jQuery),function(e){var t=e.alpaca;t.ControlField=t.Field.extend({onConstruct:function(){var t=this;this.isControlField=!0,this._getControlVal=function(i){var a=null;return this.control&&(a=e(this.control).val(),i&&(a=t.ensureProperType(a))),a}},setup:function(){var e=this;this.base();var i=e.resolveControlTemplateType();return i?void(this.controlDescriptor=this.view.getTemplateDescriptor("control-"+i,e)):t.throwErrorWithCallback("Unable to find template descriptor for control: "+e.getFieldType())},getControlEl:function(){return this.control},resolveControlTemplateType:function(){var e=this,t=!1,i=null,a=this;do if(a.getFieldType){var n=this.view.getTemplateDescriptor("control-"+a.getFieldType(),e);n?(i=a.getFieldType(),t=!0):a=a.constructor.ancestor.prototype}else t=!0;while(!t);return i},onSetup:function(){},isAutoFocusable:function(){return!0},getTemplateDescriptorId:function(){return"control"},renderFieldElements:function(i){var a=this;this.control=e(this.field).find("."+t.MARKER_CLASS_CONTROL_FIELD),this.control.removeClass(t.MARKER_CLASS_CONTROL_FIELD),a.prepareControlModel(function(e){a.beforeRenderControl(e,function(){a.renderControl(e,function(n){n&&(a.control.replaceWith(n),a.control=n,a.control.addClass(t.CLASS_CONTROL)),a.fireCallback("control"),a.afterRenderControl(e,function(){i()})})})})},prepareControlModel:function(e){var t={};t.id=this.getId(),t.name=this.name,t.options=this.options,t.schema=this.schema,t.data=this.data,t.required=this.isRequired(),e(t)},beforeRenderControl:function(e,t){t()},afterRenderControl:function(e,t){var i=this;i.firstUpdateObservableFire||"undefined"==typeof i.data||null==i.data||(i.firstUpdateObservableFire=!0,i.updateObservable()),t()},renderControl:function(e,i){var a=null;this.controlDescriptor&&(a=t.tmpl(this.controlDescriptor,e)),i(a)},postRender:function(e){this.base(function(){e()})},setDefault:function(){var e=t.isEmpty(this.schema["default"])?"":this.schema["default"];this.setValue(e)},_validateEnum:function(){if(this.schema["enum"]){var i=this.data;return i=this.getValue(),!this.isRequired()&&t.isValEmpty(i)?!0:e.inArray(i,this.schema["enum"])>-1?!0:!1}return!0},handleValidate:function(){var e=this.base(),i=this.validation,a=this._validateEnum();return i.invalidValueOfEnum={message:a?"":t.substituteTokens(this.view.getMessage("invalidValueOfEnum"),[this.schema["enum"].join(", "),this.data]),status:a},e&&i.invalidValueOfEnum.status},initEvents:function(){this.base(),this.control&&this.control.length>0&&this.initControlEvents()},initControlEvents:function(){var e=this,t=this.control;t.click(function(t){e.onClick.call(e,t),e.trigger("click",t)}),t.change(function(t){setTimeout(function(){e.onChange.call(e,t),e.triggerWithPropagation("change",t)},250)}),t.focus(function(t){e.suspendBlurFocus||(e.onFocus.call(e,t),e.trigger("focus",t))}),t.blur(function(t){e.suspendBlurFocus||(e.onBlur.call(e,t),e.trigger("blur",t))}),t.keypress(function(t){e.onKeyPress.call(e,t),e.trigger("keypress",t)}),t.keyup(function(t){e.onKeyUp.call(e,t),e.trigger("keyup",t)}),t.keydown(function(t){e.onKeyDown.call(e,t),e.trigger("keydown",t)})},onKeyPress:function(){var e=this,t=this.isValid();t||window.setTimeout(function(){e.refreshValidationState()},50)},onKeyDown:function(){},onKeyUp:function(){},onClick:function(){},disable:function(){this.base(),this.control&&this.control.length>0&&e(this.control).prop("disabled",!0)},enable:function(){this.base(),this.control&&this.control.length>0&&e(this.control).prop("disabled",!1)},getSchemaOfSchema:function(){return t.merge(this.base(),{properties:{"enum":{title:"Enumerated Values",description:"List of specific values for this property",type:"array"}}})},getOptionsForSchema:function(){return t.merge(this.base(),{fields:{"enum":{itemLabel:"Value",type:"array"}}})},getSchemaOfOptions:function(){return t.merge(this.base(),{properties:{name:{title:"Field Name",description:"Field Name.",type:"string"}}})},getOptionsForOptions:function(){return t.merge(this.base(),{fields:{name:{type:"text"}}})}}),t.registerMessages({invalidValueOfEnum:"This field should have one of the values in {0}. Current value is: {1}"})}(jQuery),function(e){var t=e.alpaca;t.ContainerField=t.Field.extend({onConstruct:function(){this.isContainerField=!0},isContainer:function(){return!0},getContainerEl:function(){return this.container},getTemplateDescriptorId:function(){return"container"},resolveContainerTemplateType:function(){var e=!1,t=null,i=this;do if(i.getFieldType){var a=this.view.getTemplateDescriptor("container-"+i.getFieldType(),this);a?(t=i.getFieldType(),e=!0):i=i.constructor.ancestor.prototype}else e=!0;while(!e);return t},setup:function(){var e=this;this.base();var i=e.resolveContainerTemplateType();if(!i)return t.throwErrorWithCallback("Unable to find template descriptor for container: "+e.getFieldType());this.containerDescriptor=this.view.getTemplateDescriptor("container-"+i,e);var a=!0;t.isEmpty(this.view.collapsible)||(a=this.view.collapsible),t.isEmpty(this.options.collapsible)||(a=this.options.collapsible),this.options.collapsible=a;var n="button";t.isEmpty(this.view.legendStyle)||(n=this.view.legendStyle),t.isEmpty(this.options.legendStyle)||(n=this.options.legendStyle),this.options.legendStyle=n,this.lazyLoading=!1,t.isEmpty(this.options.lazyLoading)||(this.lazyLoading=this.options.lazyLoading,this.lazyLoading&&(this.options.collapsed=!0)),this.children=[],this.childrenById={},this.childrenByPropertyId={},this.expandedIcon=this.view.getStyle("expandedIcon"),this.collapsedIcon=this.view.getStyle("collapsedIcon"),this.commonIcon=this.view.getStyle("commonIcon"),this.addIcon=this.view.getStyle("addIcon"),this.removeIcon=this.view.getStyle("removeIcon"),this.upIcon=this.view.getStyle("upIcon"),this.downIcon=this.view.getStyle("downIcon")},destroy:function(){this.form&&(this.form.destroy(!0),delete this.form),t.each(this.children,function(){this.destroy()}),this.base()},renderFieldElements:function(i){var a=this;this.container=e(this.field).find("."+t.MARKER_CLASS_CONTAINER_FIELD),this.container.removeClass(t.MARKER_CLASS_CONTAINER_FIELD),a.prepareContainerModel(function(e){a.beforeRenderContainer(e,function(){a.renderContainer(e,function(n){n&&(a.container.replaceWith(n),a.container=n,a.container.addClass(t.CLASS_CONTAINER)),a.container.addClass(a.view.horizontal?"alpaca-horizontal":"alpaca-vertical"),a.fireCallback("container"),a.afterRenderContainer(e,function(){i()})})})})},prepareContainerModel:function(e){var t=this,i={id:this.getId(),name:this.name,options:this.options};t.createItems(function(t){t||(t=[]),i.items=t,e(i)})},beforeRenderContainer:function(e,t){t()},renderContainer:function(e,i){var a=null;this.containerDescriptor&&(a=t.tmpl(this.containerDescriptor,e)),i(a)},afterRenderContainer:function(e,t){var i=this;i.applyCreatedItems(e,function(){i.afterApplyCreatedItems(e,function(){t()})})},postRender:function(e){this.base(function(){e()})},initEvents:function(){this.base()},createItems:function(e){e()},applyCreatedItems:function(i,a){var n=this,r=null;if(n.isTopLevel()&&n.view.getLayout()&&(r=n.view.getLayout().bindings,!r&&n.view.getLayout().templateDescriptor&&i.items.length>0)){r={};for(var s=0;s0?(e(n.container).addClass("alpaca-container-has-items"),e(n.container).attr("data-alpaca-container-item-count",i.items.length)):(e(n.container).removeClass("alpaca-container-has-items"),e(n.container).removeAttr("data-alpaca-container-item-count"));for(var s=0;s0&&(e(l.field).appendTo(p),l.domEl=p)}e(c).remove()}else{var p=e(c).parent();e(c).replaceWith(l.field),l.domEl=p}e(l.field).addClass("alpaca-container-item"),0===s&&e(l.field).addClass("alpaca-container-item-first"),s+1===i.items.length&&e(l.field).addClass("alpaca-container-item-last"),e(l.field).attr("data-alpaca-container-item-index",s),e(l.field).attr("data-alpaca-container-item-name",l.name),n.registerChild(l,s)}n.options.collapsible&&n.fireCallback("collapsible"),n.triggerUpdate(),a()},afterApplyCreatedItems:function(e,t){t()},registerChild:function(e,i){t.isEmpty(i)?this.children.push(e):this.children.splice(i,0,e),this.childrenById[e.getId()]=e,e.propertyId&&(this.childrenByPropertyId[e.propertyId]=e),e.parent=this},unregisterChild:function(e){var i=this.children[e];i&&(t.isEmpty(e)||this.children.splice(e,1),delete this.childrenById[i.getId()],i.propertyId&&delete this.childrenByPropertyId[i.propertyId],i.parent=null)},updateChildDOMElements:function(){var t=this,i=null;if(t.view.getLayout()&&(i=t.view.getLayout().bindings),!i){t.children.length>0?(e(t.getContainerEl()).addClass("alpaca-container-has-items"),e(t.getContainerEl()).attr("data-alpaca-container-item-count",t.children.length)):(e(t.getContainerEl()).removeClass("alpaca-container-has-items"),e(t.getContainerEl()).removeAttr("data-alpaca-container-item-count"));for(var a=0;a0&&(e=0),e>-1&&this.children[e].focus()},disable:function(){this.base();for(var e=0;ea;a+=1)indent+=" ";else"string"==typeof i&&(indent=i);if(rep=t,t&&"function"!=typeof t&&("object"!=typeof t||"number"!=typeof t.length))throw new Error("JSON.stringify");return this.str("",{"":e})},i.prototype.quote=function(e){var t=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;return t.lastIndex=0,t.test(e)?'"'+e.replace(t,function(e){var t=meta[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'},i.prototype.str=function(e,t){var i,a,n,r,s,o=gap,l=t[e];switch(l&&"object"==typeof l&&"function"==typeof l.toJSON&&(l=l.toJSON(e)),"function"==typeof rep&&(l=rep.call(t,e,l)),typeof l){case"string":return this.quote(l);case"number":return isFinite(l)?String(l):"null";case"boolean":case"null":return String(l);case"object":if(!l)return"null";if(gap+=indent,s=[],"[object Array]"===Object.prototype.toString.apply(l)){for(r=l.length,i=0;r>i;i+=1)s[i]=this.str(i,l)||"null";return n=0===s.length?"[]":gap?"[\n"+gap+s.join(",\n"+gap)+"\n"+o+"]":"["+s.join(",")+"]",gap=o,n}if(rep&&"object"==typeof rep)for(r=rep.length,i=0;r>i;i+=1)a=rep[i],"string"==typeof a&&(n=this.str(a,l),n&&s.push(this.quote(a)+(gap?": ":":")+n));else for(a in l)Object.hasOwnProperty.call(l,a)&&(n=this.str(a,l),n&&s.push(this.quote(a)+(gap?": ":":")+n));return n=0===s.length?"{}":gap?"{\n"+gap+s.join(",\n"+gap)+"\n"+o+"}":"{"+s.join(",")+"}",gap=o,n}}}(jQuery),function(e){var t=e.alpaca;t.Form=Base.extend({constructor:function(e,i,a,n,r){if(this.domEl=e,this.parent=null,this.connector=n,this.errorCallback=r,this.options=i,this.attributes=this.options.attributes?this.options.attributes:{},this.options.buttons){this.options.buttons.submit&&(this.options.buttons.submit.type||(this.options.buttons.submit.type="submit"),this.options.buttons.submit.name||(this.options.buttons.submit.name="submit"),this.options.buttons.submit.value||(this.options.buttons.submit.value="Submit")),this.options.buttons.reset&&(this.options.buttons.reset.type||(this.options.buttons.reset.type="reset"),this.options.buttons.reset.name||(this.options.buttons.reset.name="reset"),this.options.buttons.reset.value||(this.options.buttons.reset.value="Reset"));for(var s in this.options.buttons)this.options.buttons[s].label&&(this.options.buttons[s].value=this.options.buttons[s].label),this.options.buttons[s].title&&(this.options.buttons[s].value=this.options.buttons[s].title),this.options.buttons[s].type||(this.options.buttons[s].type="button")}this.attributes.id?this.id=this.attributes.id:(this.id=t.generateId(),this.attributes.id=this.id),this.options.buttons&&this.options.buttons.submit&&t.isUndefined(this.options.toggleSubmitValidState)&&(this.options.toggleSubmitValidState=!0),this.viewType=i.viewType,this.view=new t.RuntimeView(a,this)},render:function(e){var t=this;this.form&&this.form.remove(),this.processRender(this.domEl,function(){t.form.appendTo(t.container),t.form.addClass("alpaca-form"),t.fireCallback("form"),e(t)})},isFormValid:function(){this.topControl.validate(!0);var e=this.topControl.isValid(!0);return e},isValid:function(){return this.isFormValid()},validate:function(e){return this.topControl.validate(e)},enableSubmitButton:function(){if(e(".alpaca-form-button-submit").attrProp("disabled",!1),e.mobile)try{e(".alpaca-form-button-submit").button("refresh")}catch(t){}},disableSubmitButton:function(){if(e(".alpaca-form-button-submit").attrProp("disabled",!0),e.mobile)try{e(".alpaca-form-button-submit").button("refresh")}catch(t){}},adjustSubmitButtonState:function(){this.disableSubmitButton(),this.isFormValid()&&this.enableSubmitButton()},processRender:function(i,a){var n=this;if(this.formDescriptor=this.view.getTemplateDescriptor("form"),!this.formDescriptor)return t.throwErrorWithCallback("Could not find template descriptor: form");var r=t.tmpl(this.formDescriptor,{id:this.getId(),options:this.options,view:this.view});r.appendTo(i),this.form=r,this.formFieldsContainer=e(this.form).find("."+t.MARKER_CLASS_FORM_ITEMS_FIELD),this.formFieldsContainer.removeClass(t.MARKER_CLASS_FORM_ITEMS_FIELD),t.isEmpty(this.form.attr("id"))&&this.form.attr("id",this.getId()+"-form-outer"),t.isEmpty(this.form.attr("alpaca-field-id"))&&this.form.attr("alpaca-field-id",this.getId()),i.find("form").attr(this.attributes),this.buttons={},e(i).find(".alpaca-form-button").each(function(){e(this).click(function(){e(this).attr("button-pushed",!0)});var t=e(this).attr("data-key");if(t){var i=n.options.buttons[t];i&&i.click&&e(this).click(function(e,t){return function(i){i.preventDefault(),t.call(e,i)}}(n,i.click))}}),a()},getId:function(){return this.id},getType:function(){return this.type},getParent:function(){return this.parent},getValue:function(){return this.topControl.getValue()},setValue:function(e){this.topControl.setValue(e)},initEvents:function(){var t=this,i=e(this.domEl).find("form"),a=this.getValue();e(i).submit(a,function(e){return t.onSubmit(e,t)}),this.options.toggleSubmitValidState&&(e(t.topControl.getFieldEl()).bind("fieldupdate",function(){t.adjustSubmitButtonState()}),this.adjustSubmitButtonState())},getButtonEl:function(t){return e(this.domEl).find(".alpaca-form-button-"+t)},onSubmit:function(e,i){if(this.submitHandler){e.stopPropagation();var a=this.submitHandler(e,i);return t.isUndefined(a)&&(a=!1),a}},registerSubmitHandler:function(e){t.isFunction(e)&&(this.submitHandler=e)},refreshValidationState:function(e,t){this.topControl.refreshValidationState(e,t)},disable:function(){this.topControl.disable()},enable:function(){this.topControl.enable()},focus:function(){this.topControl.focus()},destroy:function(e){this.getFieldEl().remove(),!e&&this.parent&&this.parent.destroy()},show:function(){this.getFieldEl().css({display:""})},hide:function(){this.getFieldEl().css({display:"none"})},clear:function(e){this.topControl.clear(e)},isEmpty:function(){return this.topControl.isEmpty()},fireCallback:function(e,t,i,a,n,r){this.view.fireCallback(this,e,t,i,a,n,r)},getFormEl:function(){return this.form},submit:function(){this.form.submit()},ajaxSubmit:function(){var t=this;return e.ajax({data:this.getValue(),url:t.options.attributes.action,type:t.options.attributes.method,dataType:"json"})}})}(jQuery),function(e){var t=e.alpaca;t.Fields.TextField=t.ControlField.extend({getFieldType:function(){return"text"},setup:function(){this.base(),this.options.size||(this.options.size=40),this.inputType||(this.inputType="text"),this.options.inputType&&(this.inputType=this.options.inputType),this.options.data||(this.options.data={}),this.options.attributes||(this.options.attributes={}),"undefined"==typeof this.options.allowOptionalEmpty&&(this.options.allowOptionalEmpty=!0)},destroy:function(){this.base(),this.control&&this.control.typeahead&&this.options.typeahead&&e(this.control).typeahead("destroy")},postRender:function(e){var t=this;this.base(function(){t.control&&(t.applyMask(),t.applyTypeAhead(),t.updateMaxLengthIndicator()),e()})},applyMask:function(){var e=this;e.control.mask&&e.options.maskString&&e.control.mask(e.options.maskString)},applyTypeAhead:function(){var i=this;if(i.control.typeahead&&i.options.typeahead&&!t.isEmpty(i.options.typeahead)){var a=i.options.typeahead.config;a||(a={});var n=i.options.typeahead.datasets;n||(n={}),n.name||(n.name=i.getId());var r=i.options.typeahead.events;if(r||(r={}),"local"===n.type||"remote"===n.type||"prefetch"===n.type){var s={datumTokenizer:function(e){return Bloodhound.tokenizers.whitespace(e.value)},queryTokenizer:Bloodhound.tokenizers.whitespace};if("local"===n.type){var o=[];if("function"==typeof n.source)s.local=n.source;else{for(var l=0;l

    "),e(i.control).after(a));var n=!1,r="";if(!t.isEmpty(i.schema.maxLength)&&i.options.showMaxLengthIndicator){var s=i.getValue()||"",o=i.schema.maxLength-s.length;o>=0?r="You have "+o+" characters remaining":(r="Your message is too long by "+-1*o+" characters",n=!0),e(a).html(r),e(a).removeClass("err"),n&&e(a).addClass("err")}},getValue:function(){var t=this,i=null;if(!this.isDisplayOnly()&&this.control&&this.control.length>0){if(i=this._getControlVal(!0),t.control.mask&&t.options.maskString){var a=e(this.control).data(e.mask.dataName);a&&(i=a(),i=t.ensureProperType(i))}}else i=this.base();return i},setValue:function(e){this.control&&this.control.length>0&&this.control.val(t.isEmpty(e)?"":e),this.base(e),this.updateMaxLengthIndicator()},handleValidate:function(){var e=this.base(),i=this.validation,a=this._validatePattern();return i.invalidPattern={message:a?"":t.substituteTokens(this.view.getMessage("invalidPattern"),[this.schema.pattern]),status:a},a=this._validateMaxLength(),i.stringTooLong={message:a?"":t.substituteTokens(this.view.getMessage("stringTooLong"),[this.schema.maxLength]),status:a},a=this._validateMinLength(),i.stringTooShort={message:a?"":t.substituteTokens(this.view.getMessage("stringTooShort"),[this.schema.minLength]),status:a},e&&i.invalidPattern.status&&i.stringTooLong.status&&i.stringTooShort.status},_validatePattern:function(){if(this.schema.pattern){var e=this.getValue();if(""===e&&this.options.allowOptionalEmpty&&!this.isRequired())return!0;if(t.isEmpty(e)&&(e=""),!e.match(this.schema.pattern))return!1}return!0},_validateMinLength:function(){if(!t.isEmpty(this.schema.minLength)){var e=this.getValue();if(""===e&&this.options.allowOptionalEmpty&&!this.isRequired())return!0;if(t.isEmpty(e)&&(e=""),e.lengththis.schema.maxLength)return!1}return!0},focus:function(){if(this.control&&this.control.length>0){var t=e(this.control).get(0);try{var i=t.value?t.value.length:0;t.selectionStart=i,t.selectionEnd=i}catch(a){}t.focus()}},getType:function(){return"string"},onKeyDown:function(e){var i=this;if(8===e.keyCode){if(!t.isEmpty(i.schema.minLength)&&(i.options.constrainLengths||i.options.constrainMinLength)){var a=i.getValue()||"";a.length<=i.schema.minLength&&(e.preventDefault(),e.stopImmediatePropagation())}}else if(!t.isEmpty(i.schema.maxLength)&&(i.options.constrainLengths||i.options.constrainMaxLength)){var a=i.getValue()||"";a.length>=i.schema.maxLength&&(e.preventDefault(),e.stopImmediatePropagation())}},onKeyUp:function(){var e=this;e.updateMaxLengthIndicator()},getTitle:function(){return"Single-Line Text"},getDescription:function(){return"Text field for single-line text."},getSchemaOfSchema:function(){return t.merge(this.base(),{properties:{minLength:{title:"Minimal Length",description:"Minimal length of the property value.",type:"number"},maxLength:{title:"Maximum Length",description:"Maximum length of the property value.",type:"number"},pattern:{title:"Pattern",description:"Regular expression for the property value.",type:"string"}}})},getOptionsForSchema:function(){return t.merge(this.base(),{fields:{"default":{helper:"Field default value",type:"text"},minLength:{type:"integer"},maxLength:{type:"integer"},pattern:{type:"text"}}})},getSchemaOfOptions:function(){return t.merge(this.base(),{properties:{size:{title:"Field Size",description:"Field size.",type:"number","default":40},maskString:{title:"Mask Expression",description:"Expression for the field mask. Field masking will be enabled if not empty.",type:"string"},placeholder:{title:"Field Placeholder",description:"Field placeholder.",type:"string"},typeahead:{title:"Type Ahead",description:"Provides configuration for the $.typeahead plugin if it is available. For full configuration options, see: https://github.com/twitter/typeahead.js"},allowOptionalEmpty:{title:"Allow Optional Empty",description:"Allows this non-required field to validate when the value is empty"},inputType:{title:"HTML5 Input Type",description:"Allows for the override of the underlying HTML5 input type. If not specified, an assumed value is provided based on the kind of input control (i.e. 'text', 'date', 'email' and so forth)",type:"string"},data:{title:"Data attributes for the underlying DOM input control",description:"Allows you to specify a key/value map of data attributes that will be added as DOM attribuets for the underlying input control. The data attributes will be added as data-{name}='{value}'.",type:"object"}}}) +},getOptionsForOptions:function(){return t.merge(this.base(),{fields:{size:{type:"integer"},maskString:{helper:"a - an alpha character;9 - a numeric character;* - an alphanumeric character",type:"text"},typeahead:{type:"object"},allowOptionalEmpty:{type:"checkbox"},inputType:{type:"string"},data:{type:"object"}}})}}),t.registerMessages({invalidPattern:"This field should have pattern {0}",stringTooShort:"This field should contain at least {0} numbers or characters",stringTooLong:"This field should contain at most {0} numbers or characters"}),t.registerFieldClass("text",t.Fields.TextField),t.registerDefaultSchemaFieldMapping("string","text")}(jQuery),function(e){var t=e.alpaca;t.Fields.TextAreaField=t.Fields.TextField.extend({getFieldType:function(){return"textarea"},setup:function(){this.base(),this.options.rows||(this.options.rows=5),this.options.cols||(this.options.cols=40)},handleValidate:function(){var e=this.base(),i=this.validation,a=this._validateWordCount();return i.wordLimitExceeded={message:a?"":t.substituteTokens(this.view.getMessage("wordLimitExceeded"),[this.options.wordlimit]),status:a},e&&i.wordLimitExceeded.status},_validateWordCount:function(){if(this.options.wordlimit&&this.options.wordlimit>-1){var e=this.data;if(e){var t=e.split(" ").length;if(t>this.options.wordlimit)return!1}}return!0},getTitle:function(){return"Multi-Line Text"},getDescription:function(){return"Textarea field for multiple line text."},getSchemaOfOptions:function(){return t.merge(this.base(),{properties:{rows:{title:"Rows",description:"Number of rows",type:"number","default":5},cols:{title:"Columns",description:"Number of columns",type:"number","default":40},wordlimit:{title:"Word Limit",description:"Limits the number of words allowed in the text area.",type:"number","default":-1}}})},getOptionsForOptions:function(){return t.merge(this.base(),{fields:{rows:{type:"integer"},cols:{type:"integer"},wordlimit:{type:"integer"}}})}}),t.registerMessages({wordLimitExceeded:"The maximum word limit of {0} has been exceeded."}),t.registerFieldClass("textarea",t.Fields.TextAreaField)}(jQuery),function(e){var t=e.alpaca;t.Fields.CheckBoxField=t.ControlField.extend({getFieldType:function(){return"checkbox"},setup:function(){var i=this;i.base(),this.options.rightLabel||(this.options.rightLabel=""),"undefined"==typeof i.options.multiple&&("array"===i.schema.type?i.options.multiple=!0:"undefined"!=typeof i.schema["enum"]&&(i.options.multiple=!0)),i.checkboxOptions=[],i.options.multiple&&e.each(i.getEnum(),function(e,a){var n=a;i.options.optionLabels&&(t.isEmpty(i.options.optionLabels[e])?t.isEmpty(i.options.optionLabels[a])||(n=i.options.optionLabels[a]):n=i.options.optionLabels[e]),i.checkboxOptions.push({value:a,text:n})})},getEnum:function(){var e=[];return this.schema&&this.schema["enum"]&&(e=this.schema["enum"]),e},onClick:function(){this.refreshValidationState()},prepareControlModel:function(e){var t=this;this.base(function(i){i.checkboxOptions=t.checkboxOptions,e(i)})},postRender:function(t){var i=this;this.base(function(){if(i.data&&"undefined"!=typeof i.data&&i.setValue(i.data),e(i.getFieldEl()).find("input:checkbox").change(function(){i.triggerWithPropagation("change")}),i.options.multiple&&(e(i.getFieldEl()).find("input:checkbox").prop("checked",!1),i.data)){var a=i.data;if("string"==typeof i.data){a=i.data.split(",");for(var n=0;n0?t.checked(e(l[0])):!1}return a},setValue:function(i){var a=this,n=function(i){t.isString(i)&&(i="true"===i);var n=e(a.getFieldEl()).find("input");n.length>0&&t.checked(e(n[0]),i)},r=function(n){"string"==typeof n&&(n=n.split(","));for(var r=0;r0&&t.checked(e(o[0]),i)}},s=!1;a.options.multiple?"string"==typeof i?(r(i),s=!0):t.isArray(i)&&(r(i),s=!0):"boolean"==typeof i?(n(i),s=!0):"string"==typeof i&&(n(i),s=!0),!s&&i&&t.logError("CheckboxField cannot set value for schema.type="+a.schema.type+" and value="+i),this.base(i)},_validateEnum:function(){var e=this;if(!e.options.multiple)return!0;var i=e.getValue();return!e.isRequired()&&t.isValEmpty(i)?!0:("string"==typeof i&&(i=i.split(",")),t.anyEquality(i,e.schema["enum"]))},disable:function(){e(this.control).find("input").each(function(){e(this).disabled=!0})},enable:function(){e(this.control).find("input").each(function(){e(this).disabled=!1})},getType:function(){return"boolean"},getTitle:function(){return"Checkbox Field"},getDescription:function(){return"Checkbox Field for boolean (true/false), string ('true', 'false' or comma-delimited string of values) or data array."},getSchemaOfOptions:function(){return t.merge(this.base(),{properties:{rightLabel:{title:"Option Label",description:"Optional right-hand side label for single checkbox field.",type:"string"},multiple:{title:"Multiple",description:"Whether to render multiple checkboxes for multi-valued type (such as an array or a comma-delimited string)",type:"boolean"}}})},getOptionsForOptions:function(){return t.merge(this.base(),{fields:{rightLabel:{type:"text"},multiple:{type:"checkbox"}}})}}),t.registerFieldClass("checkbox",t.Fields.CheckBoxField),t.registerDefaultSchemaFieldMapping("boolean","checkbox")}(jQuery),function(e){var t=e.alpaca;t.Fields.FileField=t.Fields.TextField.extend({getFieldType:function(){return"file"},setValue:function(e){this.data=e,this.data=e,this.updateObservable(),this.triggerUpdate()},getValue:function(){return this.data},onChange:function(e){this.base(e),this.options.selectionHandler&&this.processSelectionHandler(e.target.files)},processSelectionHandler:function(e){if(e&&e.length>0&&"undefined"!=typeof FileReader){var t=[],i=0,a=new FileReader;a.onload=function(){var a=this;return function(n){var r=n.target.result;t.push(r),i++,i===e.length&&a.options.selectionHandler.call(a,e,t)}}.call(this);for(var n=0;n0&&(i.data=i.schema.enum[0])},prepareControlModel:function(e){var t=this;this.base(function(i){i.noneLabel="-","undefined"!=typeof t.options.noneLabel&&(i.noneLabel=t.options.noneLabel),i.hideNone=t.isRequired(),"undefined"!=typeof t.options.removeDefaultNone&&(i.hideNone=t.options.removeDefaultNone),e(i)})},getEnum:function(){return this.schema&&this.schema["enum"]?this.schema["enum"]:void 0},getValue:function(i){var a=this;return t.isArray(i)?e.each(i,function(t,n){e.each(a.selectOptions,function(e,a){a.value===n&&(i[t]=a.value)})}):e.each(this.selectOptions,function(e,t){t.value===i&&(i=t.value)}),i},beforeRenderControl:function(i,a){var n=this;this.base(i,function(){if(n.options.dataSource){n.selectOptions=[];var r=function(){n.schema.enum=[],n.options.optionLabels=[];for(var e=0;e0&&(n.data=n.selectOptions[0].value,0===e("input:radio:checked",n.control).length&&t.checked(e(n.control).find("input:radio").first(),"checked")),n.options.vertical&&e(".alpaca-controlfield-radio-item",n.control).css("display","block"),a()})},onClick:function(t){this.base(t);var i=this,a=e(t.currentTarget).find("input").val();"undefined"!=typeof a&&(i.setValue(a),i.refreshValidationState())},getTitle:function(){return"Radio Group Field"},getDescription:function(){return"Radio Group Field with list of options."},getSchemaOfOptions:function(){return t.merge(this.base(),{properties:{name:{title:"Field name",description:"Field name.",type:"string"},emptySelectFirst:{title:"Empty Select First",description:"If the data is empty, then automatically select the first item in the list.",type:"boolean","default":!1},vertical:{title:"Position the radio selector items vertically",description:"When true, the radio selector items will be stacked vertically and not horizontally",type:"boolean","default":!1}}})}}),t.registerFieldClass("radio",t.Fields.RadioField)}(jQuery),function(e){var t=e.alpaca;t.Fields.SelectField=t.Fields.ListField.extend({getFieldType:function(){return"select"},setup:function(){this.base(),t.isUndefined(this.options.emptySelectFirst)&&(this.options.emptySelectFirst=!1)},getValue:function(){if(this.control&&this.control.length>0){var e=this._getControlVal(!0);return"undefined"==typeof e&&(e=this.data),this.base(e)}},setValue:function(e){t.isArray(e)?t.compareArrayContent(e,this.getValue())||(!t.isEmpty(e)&&this.control&&this.control.val(e),this.base(e)):e!==this.getValue()&&(this.control&&"undefined"!=typeof e&&null!=e&&this.control.val(e),this.base(e))},getEnum:function(){if(this.schema){if(this.schema["enum"])return this.schema["enum"];if(this.schema.type&&"array"===this.schema.type&&this.schema.items&&this.schema.items["enum"])return this.schema.items["enum"]}},initControlEvents:function(){var e=this;if(e.base(),e.options.multiple){var t=this.control.parent().find("button.multiselect");t.focus(function(t){e.suspendBlurFocus||(e.onFocus.call(e,t),e.trigger("focus",t))}),t.blur(function(t){e.suspendBlurFocus||(e.onBlur.call(e,t),e.trigger("blur",t))})}},beforeRenderControl:function(e,t){var i=this;this.base(e,function(){i.schema.type&&"array"===i.schema.type&&(i.options.multiple=!0),t()})},prepareControlModel:function(e){var t=this;this.base(function(i){i.selectOptions=t.selectOptions,e(i)})},afterRenderControl:function(i,a){var n=this;this.base(i,function(){if(t.isUndefined(n.data)&&n.options.emptySelectFirst&&n.selectOptions&&n.selectOptions.length>0&&(n.data=n.selectOptions[0].value),n.data&&n.setValue(n.data),n.options.multiple&&e.fn.multiselect){var i=null;i=n.options.multiselect?n.options.multiselect:{},i.nonSelectedText||(i.nonSelectedText="None",n.options.noneLabel&&(i.nonSelectedText=n.options.noneLabel)),n.options.hideNone&&delete i.nonSelectedText,e(n.getControlEl()).multiselect(i)}a()})},_validateEnum:function(){var i=this;if(this.schema["enum"]){var a=this.data;if(!this.isRequired()&&t.isValEmpty(a))return!0;if(this.options.multiple){var n=!0;return a||(a=[]),t.isArray(a)||t.isObject(a)||(a=[a]),e.each(a,function(t,a){return e.inArray(a,i.schema["enum"])<=-1?(n=!1,!1):void 0}),n}return e.inArray(a,this.schema["enum"])>-1}return!0},onChange:function(e){this.base(e);var i=this;t.later(25,this,function(){var e=i.getValue();i.setValue(e),i.refreshValidationState()})},_validateMinItems:function(){return this.schema.items&&this.schema.items.minItems&&e(":selected",this.control).lengththis.schema.items.maxItems?!1:!0},handleValidate:function(){var e=this.base(),i=this.validation,a=this._validateMaxItems();return i.tooManyItems={message:a?"":t.substituteTokens(this.view.getMessage("tooManyItems"),[this.schema.items.maxItems]),status:a},a=this._validateMinItems(),i.notEnoughItems={message:a?"":t.substituteTokens(this.view.getMessage("notEnoughItems"),[this.schema.items.minItems]),status:a},e&&i.tooManyItems.status&&i.notEnoughItems.status},getTitle:function(){return"Select Field"},getDescription:function(){return"Select Field"},getSchemaOfOptions:function(){return t.merge(this.base(),{properties:{multiple:{title:"Mulitple Selection",description:"Allow multiple selection if true.",type:"boolean","default":!1},size:{title:"Displayed Options",description:"Number of options to be shown.",type:"number"},emptySelectFirst:{title:"Empty Select First",description:"If the data is empty, then automatically select the first item in the list.",type:"boolean","default":!1},multiselect:{title:"Multiselect Plugin Settings",description:"Multiselect plugin properties - http://davidstutz.github.io/bootstrap-multiselect",type:"any"}}})},getOptionsForOptions:function(){return t.merge(this.base(),{fields:{multiple:{rightLabel:"Allow multiple selection ?",helper:"Allow multiple selection if checked",type:"checkbox"},size:{type:"integer"},emptySelectFirst:{type:"checkbox",rightLabel:"Empty Select First"},multiselect:{type:"object",rightLabel:"Multiselect plugin properties - http://davidstutz.github.io/bootstrap-multiselect"}}})}}),t.registerFieldClass("select",t.Fields.SelectField)}(jQuery),function(e){var t=e.alpaca;t.Fields.NumberField=t.Fields.TextField.extend({setup:function(){this.base()},getFieldType:function(){return"number"},getValue:function(){var e=this._getControlVal(!0);return"undefined"==typeof e||""==e?e:parseFloat(e)},handleValidate:function(){var e=this.base(),i=this.validation,a=this._validateNumber();return i.stringNotANumber={message:a?"":this.view.getMessage("stringNotANumber"),status:a},a=this._validateDivisibleBy(),i.stringDivisibleBy={message:a?"":t.substituteTokens(this.view.getMessage("stringDivisibleBy"),[this.schema.divisibleBy]),status:a},a=this._validateMaximum(),i.stringValueTooLarge={message:"",status:a},a||(i.stringValueTooLarge.message=this.schema.exclusiveMaximum?t.substituteTokens(this.view.getMessage("stringValueTooLargeExclusive"),[this.schema.maximum]):t.substituteTokens(this.view.getMessage("stringValueTooLarge"),[this.schema.maximum])),a=this._validateMinimum(),i.stringValueTooSmall={message:"",status:a},a||(i.stringValueTooSmall.message=this.schema.exclusiveMinimum?t.substituteTokens(this.view.getMessage("stringValueTooSmallExclusive"),[this.schema.minimum]):t.substituteTokens(this.view.getMessage("stringValueTooSmall"),[this.schema.minimum])),a=this._validateMultipleOf(),i.stringValueNotMultipleOf={message:"",status:a},a||(i.stringValueNotMultipleOf.message=t.substituteTokens(this.view.getMessage("stringValueNotMultipleOf"),[this.schema.multipleOf])),e&&i.stringNotANumber.status&&i.stringDivisibleBy.status&&i.stringValueTooLarge.status&&i.stringValueTooSmall.status&&i.stringValueNotMultipleOf.status},_validateNumber:function(){var e=this._getControlVal();if("number"==typeof e&&(e=""+e),t.isValEmpty(e))return!0;var i=t.testRegex(t.regexps.number,e);if(!i)return!1;var a=this.getValue();return isNaN(a)?!1:!0},_validateDivisibleBy:function(){var e=this.getValue();return t.isEmpty(this.schema.divisibleBy)||e%this.schema.divisibleBy===0?!0:!1},_validateMaximum:function(){var e=this.getValue();if(!t.isEmpty(this.schema.maximum)){if(e>this.schema.maximum)return!1;if(!t.isEmpty(this.schema.exclusiveMaximum)&&e==this.schema.maximum&&this.schema.exclusiveMaximum)return!1}return!0},_validateMinimum:function(){var e=this.getValue();if(!t.isEmpty(this.schema.minimum)){if(ea?(n.setValue(e[a]),a++):i.removeItem(a)}while(a");return l.alpaca({data:r,options:n,schema:a,view:this.view.id?this.view.id:this.view,connector:this.connector,error:function(e){o.destroy(),o.errorCallback.call(_this,e)},notTopLevel:!0,render:function(e,t){e.parent=o,e.path=o.path+"["+i+"]",e.render(null,function(){o.refreshValidationState(),o.updatePathAndName(),o.triggerUpdate(),t&&t()})},postRender:function(e){t.isFunction(o.options.items.postRender)&&o.options.items.postRender(l),s&&s(e)}}),l}},resolveItemSchemaOptions:function(e){var i,a=this;a.options&&a.options.fields&&a.options.fields.item&&(i=a.options.fields.item);var n;if(a.schema&&a.schema.items&&(n=a.schema.items),n&&n.$ref){for(var r=n.$ref,s=this,o=[s];s.parent;)s=s.parent,o.push(s);var l=n,c=i;t.loadRefSchemaOptions(s,r,function(i,a){for(var n=0,s=0;s1,p={};l&&t.mergeObject(p,l),i&&t.mergeObject(p,i),delete p.id;var u={};c&&t.mergeObject(u,c),a&&t.mergeObject(u,a),e(p,u,d)})}else e(n,i)},handleValidate:function(){var e=this.base(),i=this.validation,a=this._validateUniqueItems();return i.valueNotUnique={message:a?"":this.view.getMessage("valueNotUnique"),status:a},a=this._validateMaxItems(),i.tooManyItems={message:a?"":t.substituteTokens(this.view.getMessage("tooManyItems"),[this.schema.items.maxItems]),status:a},a=this._validateMinItems(),i.notEnoughItems={message:a?"":t.substituteTokens(this.view.getMessage("notEnoughItems"),[this.schema.items.minItems]),status:a},e&&i.valueNotUnique.status&&i.tooManyItems.status&&i.notEnoughItems.status},_validateEqualMaxItems:function(){return this.schema.items&&this.schema.items.maxItems&&this.getSize()>=this.schema.items.maxItems?!1:!0},_validateEqualMinItems:function(){return this.schema.items&&this.schema.items.minItems&&this.getSize()<=this.schema.items.minItems?!1:!0},_validateMinItems:function(){return this.schema.items&&this.schema.items.minItems&&this.getSize()this.schema.items.maxItems?!1:!0},_validateUniqueItems:function(){if(this.schema.items&&this.schema.uniqueItems)for(var e={},t=0,i=this.children.length;i>t;++t){if(e.hasOwnProperty(this.children[t]))return!1;e[this.children[t]]=!0}return!0},findAction:function(t,i){var a=null;return e.each(t,function(e,t){t.action==i&&(a=t)}),a},postRender:function(e){var t=this;this.base(function(){t.updateToolbars(),e()})},getSize:function(){return this.children.length},updatePathAndName:function(){var i=function(a){a.children&&e.each(a.children,function(n,r){a.prePath&&t.startsWith(r.path,a.prePath)&&(r.prePath=r.path,r.path=r.path.replace(a.prePath,a.path)),a.preName&&t.startsWith(r.name,a.preName)&&(r.preName=r.name,r.name=r.name.replace(a.preName,a.name),r.field&&e(r.field).attr("name",r.name)),i(r)})};this.children&&this.children.length>0&&e.each(this.children,function(t,a){var n=a.path.lastIndexOf("/"),r=a.path.substring(n+1);r.indexOf("[")<0&&r.indexOf("]")<0&&(r=r.substring(r.indexOf("[")+1,r.indexOf("]"))),r!==t&&(a.prePath=a.path,a.path=a.path.substring(0,n)+"/["+t+"]"),a.nameCalculated&&(a.preName=a.name,a.parent&&a.parent.name&&a.path?a.name=a.parent.name+"_"+t:a.path&&(a.name=a.path.replace(/\//g,"").replace(/\[/g,"_").replace(/\]/g,"")),this.parent.options.rubyrails?e(a.field).attr("name",a.parent.name):e(a.field).attr("name",a.name)),a.prePath||(a.prePath=a.path),i(a)})},updateToolbars:function(){var t=this;if("display"!==this.view.type&&!this.schema.readonly){t.toolbar&&(t.fireCallback("arrayToolbar",!0),t.fireCallback("arrayToolbar")),t.actionbar&&(t.fireCallback("arrayActionbars",!0),t.fireCallback("arrayActionbars"));var i=e(this.getFieldEl()).find(".alpaca-array-toolbar[data-alpaca-array-toolbar-field-id='"+t.getId()+"']");if(this.children.length>0?e(i).hide():(e(i).show(),e(i).find("[data-alpaca-array-toolbar-action]").each(function(){var i=e(this).attr("data-alpaca-array-toolbar-action"),a=t.findAction(t.toolbar.actions,i);a&&e(this).off().click(function(e){e.preventDefault(),a.click.call(t,i,a)})})),this.options.toolbarSticky)e(t.getFieldEl()).find(".alpaca-array-actionbar[data-alpaca-array-actionbar-field-id='"+t.getId()+"']").show();else{var a=this.getFieldEl().find(".alpaca-container-item");e(a).each(function(i){var a=e(t.getFieldEl()).find(".alpaca-array-actionbar[data-alpaca-array-actionbar-field-id='"+t.getId()+"'][data-alpaca-array-actionbar-item-index='"+i+"']");a&&a.length>0&&(e(this).hover(function(){e(a).show()},function(){e(a).hide()}),e(a).hide())})}var n=e(this.getFieldEl()).find(".alpaca-array-actionbar[data-alpaca-array-actionbar-field-id='"+t.getId()+"']");e(n).each(function(){var i=e(this).attr("data-alpaca-array-actionbar-item-index");"string"==typeof i&&(i=parseInt(i,10)),e(this).find("[data-alpaca-array-actionbar-action]").each(function(){var a=e(this).attr("data-alpaca-array-actionbar-action"),n=t.findAction(t.actionbar.actions,a);n&&e(this).off().click(function(e){e.preventDefault(),n.click.call(t,a,n,i)})}),e(this).find("[data-alpaca-array-actionbar-action='add']").each(t._validateEqualMaxItems()?function(){e(this).removeClass("alpaca-button-disabled"),t.fireCallback("enableButton",this)}:function(){e(this).addClass("alpaca-button-disabled"),t.fireCallback("disableButton",this)}),e(this).find("[data-alpaca-array-actionbar-action='remove']").each(t._validateEqualMinItems()?function(){e(this).removeClass("alpaca-button-disabled"),t.fireCallback("enableButton",this) +}:function(){e(this).addClass("alpaca-button-disabled"),t.fireCallback("disableButton",this)})}),e(n).first().find("[data-alpaca-array-actionbar-action='up']").each(function(){e(this).addClass("alpaca-button-disabled"),t.fireCallback("disableButton",this)}),e(n).last().find("[data-alpaca-array-actionbar-action='down']").each(function(){e(this).addClass("alpaca-button-disabled"),t.fireCallback("disableButton",this)})}},addItem:function(t,i,a,n,r){var s=this;s._validateEqualMaxItems()&&s.createItem(t,i,a,n,function(i){if(s.registerChild(i,t),0===t)e(s.container).append(i.getFieldEl());else{var a=s.getContainerEl().children("[data-alpaca-container-item-index='"+(t-1)+"']");a&&a.length>0&&a.after(i.getFieldEl())}s.updateChildDOMElements(),s.updateToolbars(),s.refreshValidationState(),s.triggerUpdate(),r&&r()})},removeItem:function(e,t){var i=this;this._validateEqualMinItems()&&(i.unregisterChild(e),i.getContainerEl().children("[data-alpaca-container-item-index='"+e+"']").remove(),i.updateChildDOMElements(),i.updateToolbars(),i.refreshValidationState(),i.triggerUpdate(),t&&t())},moveItem:function(i,a,n,r){var s=this;if("function"==typeof n&&(r=n,n=s.options.animate),"undefined"==typeof n&&(n=s.options.animate?s.options.animate:!0),"string"==typeof i&&(i=parseInt(i,10)),"string"==typeof a&&(a=parseInt(a,10)),0>a&&(a=0),a>=s.children.length&&(a=s.children.length-1),-1!==a&&i!==a){var o=s.children[a];if(o){var l=s.getContainerEl().children("[data-alpaca-container-item-index='"+i+"']"),c=s.getContainerEl().children("[data-alpaca-container-item-index='"+a+"']"),d=e("
    ");l.before(d);var p=e("
    ");c.before(p);var u=function(){for(var t=[],n=0;n0&&t.logDebug("There were "+i.length+" extra data keys that were not part of the schema "+JSON.stringify(i)),e(a)},l=[];for(var c in s){var d=null;i.data&&(d=i.data[c]);var p=function(e,n,r){return function(s){i.resolvePropertySchemaOptions(e,function(o,l,c){return c?t.throwErrorWithCallback("Circular reference detected for schema: "+o,i.errorCallback):(o||t.logDebug("Unable to resolve schema for property: "+e),void i.createItem(e,o,l,n,null,function(i){a.push(i),delete r[e],t.nextTick(function(){s()})}))})}}(c,d,n);l.push(p)}t.series(l,function(){o()})},createItem:function(t,i,a,n,r,s){var o=this,l=e("
    ");l.alpaca({data:n,options:a,schema:i,view:this.view.id?this.view.id:this.view,connector:this.connector,error:function(e){o.destroy(),o.errorCallback.call(o,e)},notTopLevel:!0,render:function(e,i){e.parent=o,e.propertyId=t,e.path="/"!==o.path?o.path+"/"+t:o.path+t,e.render(null,function(){i()})},postRender:function(e){s&&s(e)}})},resolvePropertySchemaOptions:function(e,i){var a=this,n=null;a.schema&&a.schema.properties&&a.schema.properties[e]&&(n=a.schema.properties[e]);var r={};if(a.options&&a.options.fields&&a.options.fields[e]&&(r=a.options.fields[e]),n&&n.$ref){for(var s=n.$ref,o=this,l=[o];o.parent;)o=o.parent,l.push(o);var c=n,d=r;t.loadRefSchemaOptions(o,s,function(e,a){for(var n=0,r=0;r1,p={};c&&t.mergeObject(p,c),e&&t.mergeObject(p,e),c&&c.id&&(p.id=c.id);var u={};d&&t.mergeObject(u,d),a&&t.mergeObject(u,a),t.nextTick(function(){i(p,u,o)})})}else t.nextTick(function(){i(n,r)})},applyCreatedItems:function(e,t){var i=this;this.base(e,function(){var a=function(n){if(n===e.items.length)return void t();var r=e.items[n],s=r.propertyId;i.showOrHidePropertyBasedOnDependencies(s),i.bindDependencyFieldUpdateEvent(s),i.refreshDependentFieldStates(s),a(n+1)};a(0)})},handleValidate:function(){var e=this.base(),i=this.validation,a=this._validateMaxProperties();return i.tooManyProperties={message:a?"":t.substituteTokens(this.view.getMessage("tooManyProperties"),[this.schema.maxProperties]),status:a},a=this._validateMinProperties(),i.tooFewProperties={message:a?"":t.substituteTokens(this.view.getMessage("tooManyItems"),[this.schema.items.minProperties]),status:a},e&&i.tooManyProperties.status&&i.tooFewProperties.status},_validateMaxProperties:function(){if("undefined"==typeof this.schema.maxProperties)return!0;var e=this.schema.maxProperties,t=0;for(var i in this.data)t++;return e>=t},_validateMinProperties:function(){if("undefined"==typeof this.schema.minProperties)return!0;var e=this.schema.minProperties,t=0;for(var i in this.data)t++;return t>=e},showOrHidePropertyBasedOnDependencies:function(e){var i=this,a=this.childrenByPropertyId[e];if(!a)return t.throwErrorWithCallback("Missing property: "+e,i.errorCallback);var n=this.determineAllDependenciesValid(e);n?(a.show(),a.onDependentReveal()):(a.hide(),a.onDependentConceal()),a.getFieldEl().trigger("fieldupdate")},determineAllDependenciesValid:function(i){var a=this,n=this.childrenByPropertyId[i];if(!n)return t.throwErrorWithCallback("Missing property: "+i,a.errorCallback);var r=n.schema.dependencies;if(!r)return!0;var s=!0;return t.isString(r)?s=a.determineSingleDependencyValid(i,r):t.isArray(r)&&e.each(r,function(e,t){s=s&&a.determineSingleDependencyValid(i,t)}),s},bindDependencyFieldUpdateEvent:function(i){var a=this,n=this.childrenByPropertyId[i];if(!n)return t.throwErrorWithCallback("Missing property: "+i,a.errorCallback);var r=n.schema.dependencies;if(!r)return!0;var s=function(e,i){var r=t.resolveField(a,i);r&&(r.getFieldEl().bind("fieldupdate",function(e,t,i){return function(){a.showOrHidePropertyBasedOnDependencies(i),e.getFieldEl().trigger("fieldupdate")}}(n,r,e,i)),r.getFieldEl().trigger("fieldupdate"))};t.isString(r)?s(i,r):t.isArray(r)&&e.each(r,function(e,t){s(i,t)})},refreshDependentFieldStates:function(i){var a=this,n=this.childrenByPropertyId[i];if(!n)return t.throwErrorWithCallback("Missing property: "+i,a.errorCallback);var r=n.schema.dependencies;if(!r)return!0;var s=function(e){var i=t.resolveField(a,e);i&&i.getFieldEl().trigger("fieldupdate")};t.isString(r)?s(r):t.isArray(r)&&e.each(r,function(e,t){s(t)})},determineSingleDependencyValid:function(e,i){var a=this,n=t.resolveField(a,i);if(!n)return!1;var r=n.data,s=!1,o=this.childrenByPropertyId[e].options.dependencies;if(o&&0!==o.length){"boolean"!==n.getType()||r||(r=!1);var l=o[i];!t.isEmpty(l)&&t.isFunction(l)?s=l.call(this,r):(s=!0,t.isArray(l)?t.anyEquality(r,l)&&(s=!1):t.isEmpty(l)||t.anyEquality(l,r)||(s=!1))}else s="boolean"!==n.getType()||this.childrenByPropertyId[e].options.dependencies||r?!t.isValEmpty(n.data):!1;return n&&n.isHidden()&&(s=!1),s},getIndex:function(e){if(t.isEmpty(e))return-1;for(var i=0;i0&&n.after(t.getFieldEl())}else e(o.container).append(t.getFieldEl());o.updateChildDOMElements(),o.refreshValidationState(!0,function(){o.triggerUpdate(),s&&s()})})},removeItem:function(t,i){var a=this;this.children=e.grep(this.children,function(e){return e.getId()!=t});var n=this.childrenById[t];delete this.childrenById[t],n.propertyId&&delete this.childrenByPropertyId[n.propertyId],n.destroy(),this.refreshValidationState(!0,function(){a.triggerUpdate(),i&&i()})},wizard:function(){var i=this,a=this.wizardConfigs.steps;a||(a=[]);var n=this.wizardConfigs.title,r=this.wizardConfigs.description,s=this.wizardConfigs.buttons;s||(s={}),s.previous||(s.previous={}),s.previous.title||(s.previous.title="Previous"),s.previous.align||(s.previous.align="left"),s.previous.type||(s.previous.type="button"),s.next||(s.next={}),s.next.title||(s.next.title="Next"),s.next.align||(s.next.align="right"),s.next.type||(s.next.type="button"),this.wizardConfigs.hideSubmitButton||(s.submit||(s.submit={}),s.submit.title||(s.submit.title="Submit"),s.submit.align||(s.submit.align="right"),s.submit.type||(s.submit.type="button"));for(var o in s)s[o].type||(s[o].type="button");var l=this.wizardConfigs.showSteps;"undefined"==typeof l&&(l=!0);var c=this.wizardConfigs.showProgressBar,d=this.wizardConfigs.validation;"undefined"==typeof d&&(d=!0);var n=e(this.field).attr("data-alpaca-wizard-title"),r=e(this.field).attr("data-alpaca-wizard-description"),p=e(this.field).attr("data-alpaca-wizard-validation");"undefined"!=typeof p&&(d=p?!0:!1);var u=e(this.field).attr("data-alpaca-wizard-show-steps");"undefined"!=typeof u&&(l=u?!0:!1);var h=e(this.field).attr("data-alpaca-wizard-show-progress-bar");"undefined"!=typeof h&&(c=h?!0:!1);var f=e(this.field).find("[data-alpaca-wizard-role='step']");0==a.length&&f.each(function(t){var i={},n=e(this).attr("data-alpaca-wizard-step-title");"undefined"!=typeof n&&(i.title=n),i.title||(i.title="Step "+t);var r=e(this).attr("data-alpaca-wizard-step-description");"undefined"!=typeof r&&(i.description=r),i.description||(i.description="Step "+t),a.push(i)}),"undefined"==typeof c&&a.length>1&&(c=!0);var m={};m.wizardTitle=n,m.wizardDescription=r,m.showSteps=l,m.performValidation=d,m.steps=a,m.buttons=s,m.schema=i.schema,m.options=i.options,m.data=i.data,m.showProgressBar=c,m.markAllStepsVisited=this.wizardConfigs.markAllStepsVisited;var g=i.view.getTemplateDescriptor("wizard",i);if(g){var v=t.tmpl(g,m);e(i.field).append(v);var y=e(v).find(".alpaca-wizard-nav"),b=e(v).find(".alpaca-wizard-steps"),w=e(v).find(".alpaca-wizard-buttons"),F=e(v).find(".alpaca-wizard-progress-bar");e(b).append(f),function(a,n,r,s){var o=0,l=e(r).find("[data-alpaca-wizard-button-key='previous']"),c=e(r).find("[data-alpaca-wizard-button-key='next']"),d=e(r).find("[data-alpaca-wizard-button-key='submit']"),p=function(){if(s.showSteps){if(s.visits||(s.visits={}),s.markAllStepsVisited)for(var t=e(a).find("[data-alpaca-wizard-step-index]"),i=0;ii?e(a).find("[data-alpaca-wizard-step-index='"+i+"']").addClass("completed"):i===o?e(a).find("[data-alpaca-wizard-step-index='"+i+"']").addClass("active"):s.visits&&s.visits[i]||e(a).find("[data-alpaca-wizard-step-index='"+i+"']").addClass("disabled"),s.visits&&s.visits[i]&&e(a).find("[data-alpaca-wizard-step-index='"+i+"']").addClass("visited")}if(s.showProgressBar){var r=o+1,p=s.steps.length+1,u=parseInt(r/p*100,10)+"%";e(F).find(".progress-bar").attr("aria-valuemax",p),e(F).find(".progress-bar").attr("aria-valuenow",r),e(F).find(".progress-bar").css("width",u)}l.hide(),c.hide(),d.hide(),1==s.steps.length?d.show():s.steps.length>1&&(o>0&&l.show(),c.show(),0==o?c.show():o==s.steps.length-1&&(c.hide(),d.show())),e(n).find("[data-alpaca-wizard-role='step']").hide(),e(e(n).find("[data-alpaca-wizard-role='step']")[o]).show()},u=function(a,r){if(!s.performValidation)return void r(!0);var l=[],c=e(e(n).find("[data-alpaca-wizard-role='step']")[o]);e(c).find(".alpaca-field").each(function(){var t=e(this).attr("data-alpaca-field-id");if(t){var a=i.childrenById[t];a&&l.push(a)}});for(var d=[],p=0;p=1){var t=s.buttons.previous;t&&t.click&&t.click.call(i,e),o--,p()}}),e(c).click(function(e){e.preventDefault(),o+1<=s.steps.length-1&&u("next",function(t){if(t){var a=s.buttons.next;a&&a.click&&a.click.call(i,e),o++,p()}})}),e(d).click(function(e){e.preventDefault(),o===s.steps.length-1&&u("submit",function(t){if(t){var a=s.buttons.submit;a&&(a.click?a.click.call(i,e):i.form&&i.form.submit())}})}),e(r).find("[data-alpaca-wizard-button-key]").each(function(){var t=e(this).attr("data-alpaca-wizard-button-key");if("submit"!=t&&"next"!=t&&"previous"!=t){var a=s.buttons[t];a&&a.click&&e(this).click(function(e){return function(t){e.click.call(i,t)}}(a))}}),e(a).find("[data-alpaca-wizard-step-index]").click(function(t){t.preventDefault();var i=e(this).attr("data-alpaca-wizard-step-index");i&&(i=parseInt(i,10),(i==o||s.visits&&s.visits[i])&&(o>i?(o=i,p()):i>o&&u(null,function(e){e&&(o=i,p())})))}),i.on("moveToStep",function(e){var t=e.index,i=e.skipValidation;"undefined"!=typeof t&&t<=s.steps.length-1&&(i?(o=t,p()):u(null,function(e){e&&(o=t,p())}))}),i.on("advanceOrSubmit",function(){u(null,function(t){t&&(o===s.steps.length-1?e(d).click():e(c).click())})}),p()}(y,b,w,m)}},autoWizard:function(){var t=this.wizardConfigs.bindings;t||(t={});for(var i in this.childrenByPropertyId)t.hasOwnProperty(i)||(t[i]=1);var a=!0;e(this.field).find("[data-alpaca-wizard-role='step']").length>0&&(a=!1);var n=1,r=[];do{r=[];for(var i in t)t[i]==n&&this.childrenByPropertyId&&this.childrenByPropertyId[i]&&r.push(this.childrenByPropertyId[i].field);if(r.length>0){var s=null;a?(s=e('
    '),e(this.field).append(s)):s=e(e(this.field).find("[data-alpaca-wizard-role='step']")[n-1]);for(var o=0;o0);this.wizard()},getType:function(){return"object"},moveItem:function(i,a,n,r){var s=this;if("function"==typeof n&&(r=n,n=s.options.animate),"undefined"==typeof n&&(n=s.options.animate?s.options.animate:!0),"string"==typeof i&&(i=parseInt(i,10)),"string"==typeof a&&(a=parseInt(a,10)),0>a&&(a=0),a>=s.children.length&&(a=s.children.length-1),-1!==a){var o=s.children[a];if(o){var l=s.getContainerEl().children("[data-alpaca-container-item-index='"+i+"']"),c=s.getContainerEl().children("[data-alpaca-container-item-index='"+a+"']"),d=e("
    ");l.before(d);var p=e("
    ");c.before(p);var u=function(){for(var t=[],n=0;n