Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in migrator for Codery.TextCount #300

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.PropertyEditors;
using Umbraco.Extensions;

namespace uSync.Migrations.Migrators.Community.Codery;

[SyncMigrator("Codery.TextCount")]
public class TextCountToTextboxMigrator : SyncPropertyMigratorBase
{
public override string GetDatabaseType(SyncMigrationDataTypeProperty dataTypeProperty, SyncMigrationContext context)
=> nameof(ValueStorageType.Ntext);

public override string GetEditorAlias(SyncMigrationDataTypeProperty dataTypeProperty, SyncMigrationContext context)
=> UmbConstants.PropertyEditors.Aliases.TextBox;

public override object? GetConfigValues(
SyncMigrationDataTypeProperty dataTypeProperty,
SyncMigrationContext context)
{
var limitPreValue = dataTypeProperty.PreValues
.EmptyNull()
.FirstOrDefault(pv => pv.Alias == "limit");

int? limitValue = (!string.IsNullOrEmpty(limitPreValue?.Value) &&
int.TryParse(limitPreValue.Value, out int parsedValue))
? parsedValue
: null;

return new TextboxConfiguration
{
MaxChars = limitValue
};
}
}
Loading