From 77e9cabf87bf9d8afe1b8e2d037340b0cc110f9b Mon Sep 17 00:00:00 2001 From: Nate Hoffman Date: Thu, 24 Jan 2019 09:32:29 -0700 Subject: [PATCH] + Change ActionItem field type split character to a carrot "^" character instead of "|" due to not being able to load attributes via lava. Client render/response still supports both characters for backwards compatibility. + Add support for Lava in text over image block. + Added LavaCommands support to text and icon fields --- Plugin/AvalancheUtilities.cs | 11 ++++++++++- Plugin/Controls/ActionItem.cs | 14 +++++++++++--- Plugin/Models/FormResponse.cs | 11 ++++++++++- Plugin/Plugins/Avalanche/IconButton.ascx.cs | 4 ++-- Plugin/Plugins/Avalanche/TextOverImage.ascx.cs | 13 +++++++++++-- 5 files changed, 44 insertions(+), 9 deletions(-) diff --git a/Plugin/AvalancheUtilities.cs b/Plugin/AvalancheUtilities.cs index 2ad1d44..6d60f98 100644 --- a/Plugin/AvalancheUtilities.cs +++ b/Plugin/AvalancheUtilities.cs @@ -44,7 +44,16 @@ public static string GetShortAssembly( Type type ) public static void SetActionItems( string ActionItemValue, Dictionary CustomAttributes, Person CurrentPerson, Dictionary MergeObjects = null, string EnabledLavaCommands = "", string parameter = "" ) { - var actionItems = ( ActionItemValue ?? "" ).Split( new char[] { '|' } ); + char[] splitchar = { }; + if ( ActionItemValue.Contains( "^" ) ) + { + splitchar = new char[] { '^' }; + } + else + { + splitchar = new char[] { '|' }; + } + var actionItems = ( ActionItemValue ?? "" ).Split( splitchar ); if ( actionItems.Length > 0 && !string.IsNullOrWhiteSpace( actionItems[0] ) ) { diff --git a/Plugin/Controls/ActionItem.cs b/Plugin/Controls/ActionItem.cs index fa7642d..93bc683 100644 --- a/Plugin/Controls/ActionItem.cs +++ b/Plugin/Controls/ActionItem.cs @@ -243,12 +243,12 @@ public string Value { if ( ddlActionList.SelectedValue == "1" || ddlActionList.SelectedValue == "2" ) { - return string.Format( "{0}|{1}|{2}", ddlActionList.SelectedValue, ppPage.SelectedValue, tbParameter.Text ); + return string.Format( "{0}^{1}^{2}", ddlActionList.SelectedValue, ppPage.SelectedValue, tbParameter.Text ); } if ( ddlActionList.SelectedValue == "4" ) { - return string.Format( "{0}|{1}|{2}", ddlActionList.SelectedValue, tbTarget.Text, ddlRckipid.SelectedValue ); + return string.Format( "{0}^{1}^{2}", ddlActionList.SelectedValue, tbTarget.Text, ddlRckipid.SelectedValue ); } return ddlActionList.SelectedValue; @@ -256,7 +256,15 @@ public string Value set { EnsureChildControls(); - var values = value.Split( '|' ); + string[] values = null; + if ( value.Contains( '^' ) ) + { + values = value.Split( '^' ); + } + else + { + values = value.Split( '|' ); + } ddlActionList.SelectedValue = values[0]; if ( ddlActionList.SelectedValue == "1" || ddlActionList.SelectedValue == "2" ) diff --git a/Plugin/Models/FormResponse.cs b/Plugin/Models/FormResponse.cs index 94bf6f8..85b24c7 100644 --- a/Plugin/Models/FormResponse.cs +++ b/Plugin/Models/FormResponse.cs @@ -17,7 +17,16 @@ public class FormResponse public void SetResponse( string attributeValue ) { - var actionItems = ( attributeValue ?? "" ).Split( new char[] { '|' } ); + char[] splitchar = { }; + if ( attributeValue.Contains( "^" ) ) + { + splitchar = new char[] { '^' }; + } + else + { + splitchar = new char[] { '|' }; + } + var actionItems = ( attributeValue ?? "" ).Split( splitchar ); if ( actionItems.Length > 0 && !string.IsNullOrWhiteSpace( actionItems[0] ) ) { diff --git a/Plugin/Plugins/Avalanche/IconButton.ascx.cs b/Plugin/Plugins/Avalanche/IconButton.ascx.cs index 2d60fef..6d99c5d 100644 --- a/Plugin/Plugins/Avalanche/IconButton.ascx.cs +++ b/Plugin/Plugins/Avalanche/IconButton.ascx.cs @@ -64,8 +64,8 @@ public override MobileBlock GetMobile( string parameter ) parameter ); - CustomAttributes.Add( "Text", AvalancheUtilities.ProcessLava( GetAttributeValue( "Text" ), CurrentPerson, parameter ) ); - CustomAttributes.Add( "Icon", AvalancheUtilities.ProcessLava( GetAttributeValue( "Icon" ), CurrentPerson, parameter ) ); + CustomAttributes.Add( "Text", AvalancheUtilities.ProcessLava( GetAttributeValue( "Text" ), CurrentPerson, parameter, GetAttributeValue( "EnabledLavaCommands" ) ) ); + CustomAttributes.Add( "Icon", AvalancheUtilities.ProcessLava( GetAttributeValue( "Icon" ), CurrentPerson, parameter, GetAttributeValue( "EnabledLavaCommands" ) ) ); return new MobileBlock() { diff --git a/Plugin/Plugins/Avalanche/TextOverImage.ascx.cs b/Plugin/Plugins/Avalanche/TextOverImage.ascx.cs index e5d5b24..bd5c6af 100644 --- a/Plugin/Plugins/Avalanche/TextOverImage.ascx.cs +++ b/Plugin/Plugins/Avalanche/TextOverImage.ascx.cs @@ -54,7 +54,11 @@ protected override void OnLoad( EventArgs e ) CurrentPerson, "", GetAttributeValue( "EnabledLavaCommands" ) ); - lLava.Text = GetAttributeValue( "Text" ); + lLava.Text = AvalancheUtilities.ProcessLava( GetAttributeValue( "Text" ), + CurrentPerson, + "", + GetAttributeValue( "EnabledLavaCommands" ) + ); } public override MobileBlock GetMobile( string parameter ) @@ -67,7 +71,12 @@ public override MobileBlock GetMobile( string parameter ) if ( !string.IsNullOrWhiteSpace( GetAttributeValue( "Text" ) ) ) { - CustomAttributes["Text"] = GetAttributeValue( "Text" ); + //CustomAttributes["Text"] = GetAttributeValue( "Text" ); + CustomAttributes.Add( "Text", AvalancheUtilities.ProcessLava( GetAttributeValue( "Text" ), + CurrentPerson, + parameter, + GetAttributeValue( "EnabledLavaCommands" ) + ) ); } if ( GetAttributeValue( "AspectRatio" ).AsDouble() != 0 )