Skip to content

Commit 2ac5bdb

Browse files
authored
Merge pull request #35 from delegateas/feature/multi-language-standard-field-filter
Reimplemented hardcoded defaultfields, but with filter in frontend
2 parents ffca456 + 01ece65 commit 2ac5bdb

7 files changed

Lines changed: 221 additions & 8 deletions

File tree

Generator/DTO/Attributes/Attribute.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ namespace Generator.DTO.Attributes;
44

55
public abstract class Attribute
66
{
7+
public bool IsStandardFieldModified { get; set; }
78
public bool IsCustomAttribute { get; set; }
89
public bool IsPrimaryId { get; set; }
910
public string DisplayName { get; }

Generator/DTO/Attributes/BooleanAttribute.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ internal class BooleanAttribute : Attribute
66
{
77
public string TrueLabel { get; }
88
public string FalseLabel { get; }
9-
109
public bool? DefaultValue { get; }
1110

1211
public BooleanAttribute(BooleanAttributeMetadata metadata)

Generator/DTO/Attributes/ChoiceAttribute.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Microsoft.Xrm.Sdk.Metadata;
2-
using Newtonsoft.Json;
32

43
namespace Generator.DTO.Attributes;
54

@@ -14,15 +13,15 @@ public class ChoiceAttribute : Attribute
1413
public ChoiceAttribute(PicklistAttributeMetadata metadata) : base(metadata)
1514
{
1615
Options = metadata.OptionSet.Options.Select(x => new Option(
17-
x.Label.UserLocalizedLabel?.Label ?? string.Empty,
16+
x.Label.UserLocalizedLabel?.Label ?? string.Empty,
1817
x.Value,
1918
x.Color,
2019
x.Description.UserLocalizedLabel?.Label.PrettyDescription() ?? string.Empty));
2120
Type = "Single";
2221
DefaultValue = metadata.DefaultFormValue;
2322
}
2423

25-
public ChoiceAttribute(MultiSelectPicklistAttributeMetadata metadata): base(metadata)
24+
public ChoiceAttribute(MultiSelectPicklistAttributeMetadata metadata) : base(metadata)
2625
{
2726
Options = metadata.OptionSet.Options.Select(x => new Option(
2827
x.Label.UserLocalizedLabel?.Label ?? string.Empty,

Generator/DataverseService.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,12 @@ private static Record MakeRecord(
136136
{
137137
var attributes =
138138
relevantAttributes
139-
.Select(metadata => GetAttribute(metadata, entity, logicalToSchema, logger))
139+
.Select(metadata =>
140+
{
141+
var attr = GetAttribute(metadata, entity, logicalToSchema, logger);
142+
attr.IsStandardFieldModified = MetadataExtensions.StandardFieldHasChanged(metadata, entity.DisplayName.UserLocalizedLabel?.Label ?? string.Empty);
143+
return attr;
144+
})
140145
.Where(x => !string.IsNullOrEmpty(x.DisplayName))
141146
.ToList();
142147

Generator/MetadataExtensions.cs

Lines changed: 208 additions & 0 deletions
Large diffs are not rendered by default.

Website/components/Attributes.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { EntityType, AttributeType } from "@/lib/Types"
44
import { TableHeader, TableRow, TableHead, TableBody, TableCell, Table } from "./ui/table"
55
import { Button } from "./ui/button"
66
import { useState } from "react"
7-
import { ArrowUpDown, ArrowUp, ArrowDown, Search, X, PencilOff, Pencil } from "lucide-react"
7+
import { ArrowUpDown, ArrowUp, ArrowDown, Search, X, PencilOff, Pencil, EyeOff, Eye } from "lucide-react"
88
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./ui/select"
99
import { Input } from "./ui/input"
1010
import { AttributeDetails } from "./entity/AttributeDetails"
@@ -62,7 +62,7 @@ function Attributes({ entity, onSelect }: { entity: EntityType, onSelect: (entit
6262
)
6363
}
6464

65-
if (hideStandardFields) filteredAttributes = filteredAttributes.filter(attr => attr.IsCustomAttribute);
65+
if (hideStandardFields) filteredAttributes = filteredAttributes.filter(attr => attr.IsCustomAttribute || attr.IsStandardFieldModified);
6666

6767
if (!sortColumn || !sortDirection) return filteredAttributes
6868

@@ -151,7 +151,7 @@ function Attributes({ entity, onSelect }: { entity: EntityType, onSelect: (entit
151151
title="Control customfields"
152152
>
153153
{
154-
hideStandardFields ? <PencilOff className="w-4 h-4" /> : <Pencil className="w-4 h-4" />
154+
hideStandardFields ? <EyeOff className="w-4 h-4" /> : <Eye className="w-4 h-4" />
155155
}
156156
</Button>
157157
{(searchQuery || typeFilter !== "all") && (

Website/lib/Types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const enum CalculationMethods {
4343
export type BaseAttribute = {
4444
IsPrimaryId: boolean;
4545
IsCustomAttribute: boolean;
46+
IsStandardFieldModified: boolean;
4647
DisplayName: string,
4748
SchemaName: string,
4849
Description: string | null,

0 commit comments

Comments
 (0)