Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Add URL multi-field handler to AliasVault.Client (#1404)

Leendert de Borsta8cce0a907ca
diff --git a/apps/server/AliasVault.Client/Main/Components/Forms/MultiValueFormRow.razor b/apps/server/AliasVault.Client/Main/Components/Forms/MultiValueFormRow.razor
new file mode 100644
index 000000000..5c73048bb
--- /dev/null
+++ b/apps/server/AliasVault.Client/Main/Components/Forms/MultiValueFormRow.razor
@@ -0,0 +1,106 @@
+<label for="@Id" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">@Label</label>
+<div class="space-y-2">
+ @for (int i = 0; i < Values.Count; i++)
+ {
+ var index = i;
+ var isLastInput = index == Values.Count - 1;
+ <div class="relative">
+ <input type="text"
+ id="@($"{Id}-{index}")"
+ autocomplete="off"
+ class="outline-0 shadow-sm bg-gray-50 border border-gray-300 text-gray-900 sm:text-sm rounded-lg block w-full p-2.5 pr-10 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white"
+ value="@Values[index]"
+ @oninput="e => OnInputChanged(index, e)"
+ @onfocus="e => OnFocusEvent(index, e)"
+ placeholder="@Placeholder"
+ autocapitalize="off"
+ autocorrect="off">
+ @if (isLastInput)
+ {
+ <button type="button"
+ @onclick="AddValue"
+ @onclick:preventDefault="true"
+ class="absolute right-2 top-1/2 -translate-y-1/2 w-6 h-6 flex items-center justify-center text-gray-400 hover:text-primary-500 dark:hover:text-primary-400 transition-colors">
+ <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
+ </svg>
+ </button>
+ }
+ </div>
+ }
+</div>
+
+@code {
+ /// <summary>
+ /// Id prefix for the input fields.
+ /// </summary>
+ [Parameter]
+ public string Id { get; set; } = string.Empty;
+
+ /// <summary>
+ /// Label for the input fields.
+ /// </summary>
+ [Parameter]
+ public string Label { get; set; } = "Value";
+
+ /// <summary>
+ /// List of values for multi-value field.
+ /// </summary>
+ [Parameter]
+ public List<string> Values { get; set; } = new() { string.Empty };
+
+ /// <summary>
+ /// Callback that is triggered when values change.
+ /// </summary>
+ [Parameter]
+ public EventCallback<List<string>> ValuesChanged { get; set; }
+
+ /// <summary>
+ /// Callback that is triggered when focus event happens.
+ /// </summary>
+ [Parameter]
+ public EventCallback<(int Index, FocusEventArgs Args)> OnFocus { get; set; }
+
+ /// <summary>
+ /// Placeholder text for the input fields.
+ /// </summary>
+ [Parameter]
+ public string Placeholder { get; set; } = string.Empty;
+
+ /// <inheritdoc />
+ protected override void OnParametersSet()
+ {
+ // Ensure at least one empty input is always shown
+ if (Values == null || Values.Count == 0)
+ {
+ Values = new List<string> { string.Empty };
+ }
+ }
+
+ private async Task OnInputChanged(int index, ChangeEventArgs e)
+ {
+ var newValue = e.Value?.ToString() ?? string.Empty;
+
+ // Create a new list to trigger change detection
+ var newValues = new List<string>(Values);
+ newValues[index] = newValue;
+ Values = newValues;
+
+ await ValuesChanged.InvokeAsync(Values);
+ }
+
+ private async Task OnFocusEvent(int index, FocusEventArgs e)
+ {
+ if (OnFocus.HasDelegate)
+ {
+ await OnFocus.InvokeAsync((index, e));
+ }
+ }
+
+ private async Task AddValue()
+ {
+ var newValues = new List<string>(Values) { string.Empty };
+ Values = newValues;
+ await ValuesChanged.InvokeAsync(Values);
+ }
+}
diff --git a/apps/server/AliasVault.Client/Main/Models/ItemEdit.cs b/apps/server/AliasVault.Client/Main/Models/ItemEdit.cs
index f5d209501..52f04e2e1 100644
--- a/apps/server/AliasVault.Client/Main/Models/ItemEdit.cs
+++ b/apps/server/AliasVault.Client/Main/Models/ItemEdit.cs
@@ -106,35 +106,46 @@ public sealed class ItemEdit
LastUpdate = item.UpdatedAt,
};
- // Convert all field values to SystemFieldEdit
- foreach (var fv in item.FieldValues.Where(f => !f.IsDeleted))
+ // Group field values by FieldKey to handle multi-value fields
+ var groupedFields = item.FieldValues
+ .Where(f => !f.IsDeleted)
+ .GroupBy(f => f.FieldKey ?? f.FieldDefinitionId?.ToString() ?? string.Empty);
+
+ foreach (var group in groupedFields)
{
- var isCustomField = fv.FieldDefinitionId != null && string.IsNullOrEmpty(fv.FieldKey);
- var systemField = !string.IsNullOrEmpty(fv.FieldKey) ? SystemFieldRegistry.GetSystemField(fv.FieldKey) : null;
+ var firstFv = group.First();
+ var isCustomField = firstFv.FieldDefinitionId != null && string.IsNullOrEmpty(firstFv.FieldKey);
+ var systemField = !string.IsNullOrEmpty(firstFv.FieldKey) ? SystemFieldRegistry.GetSystemField(firstFv.FieldKey) : null;
+ var isMultiValue = systemField?.IsMultiValue ?? false;
- edit.Fields.Add(new SystemFieldEdit
+ var fieldEdit = new SystemFieldEdit
{
- FieldKey = fv.FieldKey ?? fv.FieldDefinitionId?.ToString() ?? string.Empty,
- FieldValueId = fv.Id,
- FieldDefinitionId = fv.FieldDefinitionId,
+ FieldKey = firstFv.FieldKey ?? firstFv.FieldDefinitionId?.ToString() ?? string.Empty,
+ FieldValueId = firstFv.Id,
+ FieldDefinitionId = firstFv.FieldDefinitionId,
Label = isCustomField
- ? fv.FieldDefinition?.Label ?? "Custom Field"
- : fv.FieldKey ?? string.Empty,
+ ? firstFv.FieldDefinition?.Label ?? "Custom Field"
+ : firstFv.FieldKey ?? string.Empty,
FieldType = isCustomField
- ? fv.FieldDefinition?.FieldType ?? "Text"
+ ? firstFv.FieldDefinition?.FieldType ?? "Text"
: systemField?.FieldType ?? "Text",
- Value = fv.Value ?? string.Empty,
IsCustomField = isCustomField,
IsHidden = isCustomField
- ? fv.FieldDefinition?.IsHidden ?? false
+ ? firstFv.FieldDefinition?.IsHidden ?? false
: systemField?.IsHidden ?? false,
EnableHistory = isCustomField
- ? fv.FieldDefinition?.EnableHistory ?? false
+ ? firstFv.FieldDefinition?.EnableHistory ?? false
: systemField?.EnableHistory ?? false,
- DisplayOrder = systemField?.DefaultDisplayOrder ?? fv.Weight,
- Category = GetCategoryFromFieldKey(fv.FieldKey),
- IsMultiValue = systemField?.IsMultiValue ?? false,
- });
+ DisplayOrder = systemField?.DefaultDisplayOrder ?? firstFv.Weight,
+ Category = GetCategoryFromFieldKey(firstFv.FieldKey),
+ IsMultiValue = isMultiValue,
+ Values = group.OrderBy(fv => fv.Weight).Select(fv => fv.Value ?? string.Empty).ToList(),
+ };
+
+ // Set Value to first value for easier handling with single-value form components
+ fieldEdit.Value = fieldEdit.Values.FirstOrDefault() ?? string.Empty;
+
+ edit.Fields.Add(fieldEdit);
}
return edit;
@@ -158,8 +169,17 @@ public sealed class ItemEdit
};
// Convert all fields to FieldValue entities
- foreach (var field in Fields.Where(f => !string.IsNullOrEmpty(f.Value)))
+ foreach (var field in Fields)
{
+ // Check if field has any values (single or multi)
+ var hasValue = !string.IsNullOrEmpty(field.Value) ||
+ (field.IsMultiValue && field.Values.Any(v => !string.IsNullOrEmpty(v)));
+
+ if (!hasValue)
+ {
+ continue;
+ }
+
if (field.IsCustomField)
{
// Custom field handling
@@ -224,9 +244,27 @@ public sealed class ItemEdit
item.FieldValues.Add(fieldValue);
}
}
+ else if (field.IsMultiValue)
+ {
+ // Multi-value system field (e.g., login.url) - create separate FieldValue for each value
+ var nonEmptyValues = field.Values.Where(v => !string.IsNullOrEmpty(v)).ToList();
+ for (int i = 0; i < nonEmptyValues.Count; i++)
+ {
+ item.FieldValues.Add(new FieldValue
+ {
+ Id = Guid.NewGuid(),
+ ItemId = item.Id,
+ FieldKey = field.FieldKey,
+ Value = nonEmptyValues[i],
+ Weight = i, // Use index as weight for ordering
+ CreatedAt = DateTime.UtcNow,
+ UpdatedAt = DateTime.UtcNow,
+ });
+ }
+ }
else
{
- // System field
+ // Single-value system field
ItemService.SetFieldValue(item, field.FieldKey, field.Value);
}
}
@@ -244,6 +282,39 @@ public sealed class ItemEdit
return Fields.FirstOrDefault(f => f.FieldKey == fieldKey)?.Value ?? string.Empty;
}
+ /// <summary>
+ /// Gets all values for a multi-value field by its field key.
+ /// </summary>
+ /// <param name="fieldKey">The field key.</param>
+ /// <returns>List of field values.</returns>
+ public List<string> GetFieldValues(string fieldKey)
+ {
+ var field = Fields.FirstOrDefault(f => f.FieldKey == fieldKey);
+ if (field == null)
+ {
+ return new List<string>();
+ }
+
+ return field.IsMultiValue && field.Values.Any()
+ ? field.Values.Where(v => !string.IsNullOrEmpty(v)).ToList()
+ : (string.IsNullOrEmpty(field.Value) ? new List<string>() : new List<string> { field.Value });
+ }
+
+ /// <summary>
+ /// Sets multiple values for a multi-value field.
+ /// </summary>
+ /// <param name="fieldKey">The field key.</param>
+ /// <param name="values">The values to set.</param>
+ public void SetFieldValues(string fieldKey, List<string> values)
+ {
+ var field = GetField(fieldKey);
+ if (field != null)
+ {
+ field.Values = values ?? new List<string>();
+ field.Value = values?.FirstOrDefault() ?? string.Empty;
+ }
+ }
+
/// <summary>
/// Gets a field by its field key.
/// If the field doesn't exist, creates it based on the system field definition.
@@ -271,6 +342,7 @@ public sealed class ItemEdit
Label = fieldKey,
FieldType = systemField.FieldType,
Value = string.Empty,
+ Values = systemField.IsMultiValue ? new List<string> { string.Empty } : new List<string>(),
IsCustomField = false,
IsHidden = systemField.IsHidden,
EnableHistory = systemField.EnableHistory,
@@ -285,6 +357,7 @@ public sealed class ItemEdit
/// <summary>
/// Sets the value of a field by its field key.
/// If the field doesn't exist, it will be added.
+ /// For multi-value fields, this sets the first value.
/// </summary>
/// <param name="fieldKey">The field key.</param>
/// <param name="value">The value to set.</param>
@@ -294,6 +367,14 @@ public sealed class ItemEdit
if (field != null)
{
field.Value = value;
+
+ // Also update Values list for multi-value fields
+ if (field.IsMultiValue)
+ {
+ field.Values = string.IsNullOrEmpty(value)
+ ? new List<string> { string.Empty }
+ : new List<string> { value };
+ }
}
else
{
@@ -301,18 +382,22 @@ public sealed class ItemEdit
var systemField = SystemFieldRegistry.GetSystemField(fieldKey);
if (systemField != null)
{
+ var isMultiValue = systemField.IsMultiValue;
Fields.Add(new SystemFieldEdit
{
FieldKey = fieldKey,
Label = fieldKey,
FieldType = systemField.FieldType,
Value = value,
+ Values = isMultiValue
+ ? (string.IsNullOrEmpty(value) ? new List<string> { string.Empty } : new List<string> { value })
+ : new List<string>(),
IsCustomField = false,
IsHidden = systemField.IsHidden,
EnableHistory = systemField.EnableHistory,
DisplayOrder = systemField.DefaultDisplayOrder,
Category = systemField.Category,
- IsMultiValue = systemField.IsMultiValue,
+ IsMultiValue = isMultiValue,
});
}
}
@@ -320,12 +405,24 @@ public sealed class ItemEdit
/// <summary>
/// Checks if a field has a non-empty value.
+ /// For multi-value fields, checks if any value is non-empty.
/// </summary>
/// <param name="fieldKey">The field key.</param>
/// <returns>True if the field has a value.</returns>
public bool HasFieldValue(string fieldKey)
{
- return !string.IsNullOrEmpty(GetFieldValue(fieldKey));
+ var field = Fields.FirstOrDefault(f => f.FieldKey == fieldKey);
+ if (field == null)
+ {
+ return false;
+ }
+
+ if (field.IsMultiValue)
+ {
+ return field.Values.Any(v => !string.IsNullOrEmpty(v));
+ }
+
+ return !string.IsNullOrEmpty(field.Value);
}
/// <summary>
diff --git a/apps/server/AliasVault.Client/Main/Models/SystemFieldEdit.cs b/apps/server/AliasVault.Client/Main/Models/SystemFieldEdit.cs
index 1c76c2e00..0fbb54fe3 100644
--- a/apps/server/AliasVault.Client/Main/Models/SystemFieldEdit.cs
+++ b/apps/server/AliasVault.Client/Main/Models/SystemFieldEdit.cs
@@ -52,9 +52,16 @@ public sealed class SystemFieldEdit
/// <summary>
/// Gets or sets the field value.
+ /// For single-value fields, use Value property.
+ /// For multi-value fields, use Values property.
/// </summary>
public string Value { get; set; } = string.Empty;
+ /// <summary>
+ /// Gets or sets the field values for multi-value fields.
+ /// </summary>
+ public List<string> Values { get; set; } = new();
+
/// <summary>
/// Gets or sets a value indicating whether this is a custom field.
/// </summary>
diff --git a/apps/server/AliasVault.Client/Main/Pages/Items/AddEdit.razor b/apps/server/AliasVault.Client/Main/Pages/Items/AddEdit.razor
index dbb81a4d1..dadfae66b 100644
--- a/apps/server/AliasVault.Client/Main/Pages/Items/AddEdit.razor
+++ b/apps/server/AliasVault.Client/Main/Pages/Items/AddEdit.razor
@@ -51,11 +51,16 @@ else
@* Folder Selector - below name field *@
<FolderSelector @bind-SelectedFolderId="Obj.FolderId" />
</div>
- @* URL field - only for Login and Alias types *@
+ @* URL field - only for Login and Alias types (multi-value) *@
@if (ShouldShowField(FieldKey.LoginUrl))
{
<div class="col-span-6 sm:col-span-3">
- <EditFormRow Id="service-url" OnFocus="OnFocusUrlInput" Label="@Localizer["ServiceUrlLabel"]" @bind-Value="Obj.GetField(FieldKey.LoginUrl)!.Value"></EditFormRow>
+ <MultiValueFormRow
+ Id="service-url"
+ Label="@Localizer["ServiceUrlLabel"]"
+ Values="@GetUrlValues()"
+ ValuesChanged="OnUrlValuesChanged"
+ OnFocus="OnFocusUrlInput" />
</div>
}
</div>
@@ -894,12 +899,50 @@ else
NavigationManager.NavigateTo("/items", false, true);
}
+ /// <summary>
+ /// Gets the URL values for the multi-value field.
+ /// Ensures at least one entry exists.
+ /// </summary>
+ private List<string> GetUrlValues()
+ {
+ var field = Obj.GetField(FieldKey.LoginUrl);
+ if (field == null)
+ {
+ return new List<string> { string.Empty };
+ }
+
+ // Return Values if populated, otherwise convert single Value
+ if (field.Values != null && field.Values.Count > 0)
+ {
+ return field.Values;
+ }
+
+ return string.IsNullOrEmpty(field.Value)
+ ? new List<string> { string.Empty }
+ : new List<string> { field.Value };
+ }
+
+ /// <summary>
+ /// Handles URL values change from the multi-value component.
+ /// </summary>
+ private void OnUrlValuesChanged(List<string> values)
+ {
+ Obj.SetFieldValues(FieldKey.LoginUrl, values);
+ StateHasChanged();
+ }
+
/// <summary>
/// When the URL input is focused, place cursor at the end of the default URL.
/// </summary>
- private void OnFocusUrlInput(FocusEventArgs e)
+ private void OnFocusUrlInput((int Index, FocusEventArgs Args) e)
{
- var currentUrl = Obj.GetFieldValue(FieldKey.LoginUrl);
+ var urlValues = GetUrlValues();
+ if (e.Index >= urlValues.Count)
+ {
+ return;
+ }
+
+ var currentUrl = urlValues[e.Index];
if (currentUrl != ItemService.DefaultServiceUrl)
{
return;
@@ -907,7 +950,7 @@ else
Task.Delay(1).ContinueWith(_ =>
{
- JSRuntime.InvokeVoidAsync("eval", $"document.getElementById('service-url').setSelectionRange({ItemService.DefaultServiceUrl.Length}, {ItemService.DefaultServiceUrl.Length})");
+ JSRuntime.InvokeVoidAsync("eval", $"document.getElementById('service-url-{e.Index}').setSelectionRange({ItemService.DefaultServiceUrl.Length}, {ItemService.DefaultServiceUrl.Length})");
});
}
diff --git a/apps/server/AliasVault.Client/Resources/Components/Main/Components/TotpCodes/TotpCodes.en.resx b/apps/server/AliasVault.Client/Resources/Components/Main/Components/TotpCodes/TotpCodes.en.resx
index 2241f4c74..674045f33 100644
--- a/apps/server/AliasVault.Client/Resources/Components/Main/Components/TotpCodes/TotpCodes.en.resx
+++ b/apps/server/AliasVault.Client/Resources/Components/Main/Components/TotpCodes/TotpCodes.en.resx
@@ -62,10 +62,6 @@
<value>Two-factor authentication</value>
<comment>Section title for 2FA codes</comment>
</data>
- <data name="AddTotpCodeButton" xml:space="preserve">
- <value>Add TOTP Code</value>
- <comment>Button text to add new TOTP code</comment>
- </data>
<data name="AddTotpCodeDescription" xml:space="preserve">
<value>Add a two-factor authenticator code</value>
<comment>Description for adding TOTP codes</comment>
diff --git a/apps/server/AliasVault.Client/Services/ItemService.cs b/apps/server/AliasVault.Client/Services/ItemService.cs
index 5b718201f..8bcd123ce 100644
--- a/apps/server/AliasVault.Client/Services/ItemService.cs
+++ b/apps/server/AliasVault.Client/Services/ItemService.cs
@@ -770,10 +770,11 @@ public sealed class ItemService(HttpClient httpClient, DbService dbService, Conf
// Get the existing tracked field values from the existingItem (loaded with Include)
var existingFields = existingItem.FieldValues.Where(fv => !fv.IsDeleted).ToList();
- // Build maps for quick lookup
+ // Group existing fields by key to support multi-value fields
var existingByFieldKey = existingFields
.Where(f => f.FieldKey != null)
- .ToDictionary(f => f.FieldKey!, f => f);
+ .GroupBy(f => f.FieldKey!)
+ .ToDictionary(g => g.Key, g => g.OrderBy(f => f.Weight).ToList());
var existingByFieldDefId = existingFields
.Where(f => f.FieldDefinitionId != null)
@@ -782,111 +783,155 @@ public sealed class ItemService(HttpClient httpClient, DbService dbService, Conf
var processedFieldKeys = new HashSet<string>();
var processedFieldDefIds = new HashSet<Guid>();
- // Process new field values
- foreach (var newField in newItem.FieldValues.Where(fv => !fv.IsDeleted))
+ // Group new fields by key to handle multi-value fields
+ var newFieldsByKey = newItem.FieldValues
+ .Where(fv => !fv.IsDeleted && fv.FieldKey != null)
+ .GroupBy(f => f.FieldKey!)
+ .ToDictionary(g => g.Key, g => g.OrderBy(f => f.Weight).ToList());
+
+ // Process new system field values (grouped by key for multi-value support)
+ foreach (var kvp in newFieldsByKey)
{
- if (newField.FieldKey != null)
- {
- // System field
- processedFieldKeys.Add(newField.FieldKey);
+ var fieldKey = kvp.Key;
+ var newValues = kvp.Value;
+ processedFieldKeys.Add(fieldKey);
- if (existingByFieldKey.TryGetValue(newField.FieldKey, out var existingField))
+ if (existingByFieldKey.TryGetValue(fieldKey, out var existingValues))
+ {
+ // Update existing values - match by position (Weight)
+ for (int i = 0; i < newValues.Count; i++)
{
- // Update existing - just update the tracked entity
- if (existingField.Value != newField.Value || existingField.Weight != newField.Weight)
+ var newField = newValues[i];
+ if (i < existingValues.Count)
{
- existingField.Value = newField.Value;
- existingField.Weight = newField.Weight;
- existingField.UpdatedAt = updateDateTime;
+ // Update existing field value
+ var existingField = existingValues[i];
+ if (existingField.Value != newField.Value || existingField.Weight != i)
+ {
+ existingField.Value = newField.Value;
+ existingField.Weight = i;
+ existingField.UpdatedAt = updateDateTime;
+ }
+ }
+ else
+ {
+ // Insert new value (more values than before)
+ context.FieldValues.Add(new FieldValue
+ {
+ Id = Guid.NewGuid(),
+ ItemId = existingItem.Id,
+ FieldKey = fieldKey,
+ FieldDefinitionId = null,
+ Value = newField.Value,
+ Weight = i,
+ CreatedAt = updateDateTime,
+ UpdatedAt = updateDateTime,
+ IsDeleted = false,
+ });
}
}
- else
+
+ // Soft-delete extra existing values (fewer values than before)
+ for (int i = newValues.Count; i < existingValues.Count; i++)
+ {
+ existingValues[i].IsDeleted = true;
+ existingValues[i].UpdatedAt = updateDateTime;
+ }
+ }
+ else
+ {
+ // Insert all new values (field didn't exist before)
+ for (int i = 0; i < newValues.Count; i++)
{
- // Insert new - add to tracked collection
+ var newField = newValues[i];
context.FieldValues.Add(new FieldValue
{
Id = Guid.NewGuid(),
ItemId = existingItem.Id,
- FieldKey = newField.FieldKey,
+ FieldKey = fieldKey,
FieldDefinitionId = null,
Value = newField.Value,
- Weight = newField.Weight,
+ Weight = i,
CreatedAt = updateDateTime,
UpdatedAt = updateDateTime,
IsDeleted = false,
});
}
}
- else if (newField.FieldDefinitionId != null)
+ }
+
+ // Process new custom field values
+ foreach (var newField in newItem.FieldValues.Where(fv => !fv.IsDeleted && fv.FieldDefinitionId != null))
+ {
+ processedFieldDefIds.Add(newField.FieldDefinitionId!.Value);
+
+ if (existingByFieldDefId.TryGetValue(newField.FieldDefinitionId.Value, out var existingField))
{
- // Custom field
- processedFieldDefIds.Add(newField.FieldDefinitionId.Value);
+ // Update existing field value
+ if (existingField.Value != newField.Value || existingField.Weight != newField.Weight)
+ {
+ existingField.Value = newField.Value;
+ existingField.Weight = newField.Weight;
+ existingField.UpdatedAt = updateDateTime;
+ }
- if (existingByFieldDefId.TryGetValue(newField.FieldDefinitionId.Value, out var existingField))
+ // Also update the FieldDefinition label if it has changed
+ if (newField.FieldDefinition != null && existingField.FieldDefinition != null)
{
- // Update existing field value
- if (existingField.Value != newField.Value || existingField.Weight != newField.Weight)
+ if (existingField.FieldDefinition.Label != newField.FieldDefinition.Label)
{
- existingField.Value = newField.Value;
- existingField.Weight = newField.Weight;
- existingField.UpdatedAt = updateDateTime;
- }
-
- // Also update the FieldDefinition label if it has changed
- if (newField.FieldDefinition != null && existingField.FieldDefinition != null)
- {
- if (existingField.FieldDefinition.Label != newField.FieldDefinition.Label)
- {
- existingField.FieldDefinition.Label = newField.FieldDefinition.Label;
- existingField.FieldDefinition.UpdatedAt = updateDateTime;
- }
+ existingField.FieldDefinition.Label = newField.FieldDefinition.Label;
+ existingField.FieldDefinition.UpdatedAt = updateDateTime;
}
}
- else
+ }
+ else
+ {
+ // New custom field - need to add FieldDefinition first if provided
+ if (newField.FieldDefinition != null)
{
- // New custom field - need to add FieldDefinition first if provided
- if (newField.FieldDefinition != null)
- {
- context.FieldDefinitions.Add(new FieldDefinition
- {
- Id = newField.FieldDefinition.Id,
- FieldType = newField.FieldDefinition.FieldType,
- Label = newField.FieldDefinition.Label,
- IsMultiValue = newField.FieldDefinition.IsMultiValue,
- IsHidden = newField.FieldDefinition.IsHidden,
- EnableHistory = newField.FieldDefinition.EnableHistory,
- Weight = newField.FieldDefinition.Weight,
- ApplicableToTypes = newField.FieldDefinition.ApplicableToTypes,
- CreatedAt = updateDateTime,
- UpdatedAt = updateDateTime,
- IsDeleted = false,
- });
- }
-
- // Add the FieldValue
- context.FieldValues.Add(new FieldValue
+ context.FieldDefinitions.Add(new FieldDefinition
{
- Id = Guid.NewGuid(),
- ItemId = existingItem.Id,
- FieldKey = null,
- FieldDefinitionId = newField.FieldDefinitionId,
- Value = newField.Value,
- Weight = newField.Weight,
+ Id = newField.FieldDefinition.Id,
+ FieldType = newField.FieldDefinition.FieldType,
+ Label = newField.FieldDefinition.Label,
+ IsMultiValue = newField.FieldDefinition.IsMultiValue,
+ IsHidden = newField.FieldDefinition.IsHidden,
+ EnableHistory = newField.FieldDefinition.EnableHistory,
+ Weight = newField.FieldDefinition.Weight,
+ ApplicableToTypes = newField.FieldDefinition.ApplicableToTypes,
CreatedAt = updateDateTime,
UpdatedAt = updateDateTime,
IsDeleted = false,
});
}
+
+ // Add the FieldValue
+ context.FieldValues.Add(new FieldValue
+ {
+ Id = Guid.NewGuid(),
+ ItemId = existingItem.Id,
+ FieldKey = null,
+ FieldDefinitionId = newField.FieldDefinitionId,
+ Value = newField.Value,
+ Weight = newField.Weight,
+ CreatedAt = updateDateTime,
+ UpdatedAt = updateDateTime,
+ IsDeleted = false,
+ });
}
}
- // Soft-delete removed system fields
- foreach (var existingField in existingFields.Where(f => f.FieldKey != null))
+ // Soft-delete removed system fields (all values for a field key)
+ foreach (var existingFieldKey in existingByFieldKey.Keys)
{
- if (!processedFieldKeys.Contains(existingField.FieldKey!))
+ if (!processedFieldKeys.Contains(existingFieldKey))
{
- existingField.IsDeleted = true;
- existingField.UpdatedAt = updateDateTime;
+ foreach (var existingField in existingByFieldKey[existingFieldKey])
+ {
+ existingField.IsDeleted = true;
+ existingField.UpdatedAt = updateDateTime;
+ }
}
}
diff --git a/apps/server/AliasVault.Client/wwwroot/css/tailwind.css b/apps/server/AliasVault.Client/wwwroot/css/tailwind.css
index 990ce389a..f7da3338b 100644
--- a/apps/server/AliasVault.Client/wwwroot/css/tailwind.css
+++ b/apps/server/AliasVault.Client/wwwroot/css/tailwind.css
@@ -706,6 +706,14 @@ video {
top: 0.75rem;
}
+.right-2 {
+ right: 0.5rem;
+}
+
+.top-1\/2 {
+ top: 50%;
+}
+
.-z-10 {
z-index: -10;
}
@@ -1273,6 +1281,11 @@ video {
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
}
+.-translate-y-1\/2 {
+ --tw-translate-y: -50%;
+ transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
+}
+
.rotate-180 {
--tw-rotate: 180deg;
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
@@ -2941,6 +2954,11 @@ video {
color: rgb(249 115 22 / var(--tw-text-opacity));
}
+.hover\:text-primary-500:hover {
+ --tw-text-opacity: 1;
+ color: rgb(244 149 65 / var(--tw-text-opacity));
+}
+
.hover\:underline:hover {
text-decoration-line: underline;
}