Skip to content

Commit ae4edac

Browse files
CopilotLeftofZen
andcommitted
Expose all editable metadata properties in ViewModel and UI
- Added Availability property to ObjectMetadataViewModel with two-way binding - Added InternalName property (readonly) to ViewModel - Added UploadedDate property to ViewModel - Updated MetadataView.axaml to show all properties with appropriate controls - Changed Availability from readonly TextBox to editable ComboBox - Added InternalName field display - Fixed DataContext binding to use ViewModel properties instead of direct Metadata binding - Updated type references from LocoObjectMetadataViewModel to ObjectMetadataViewModel Co-authored-by: LeftofZen <7483209+LeftofZen@users.noreply.github.com>
1 parent 70fb9f9 commit ae4edac

3 files changed

Lines changed: 76 additions & 30 deletions

File tree

Gui/App.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
<DataTemplate DataType="vm:Graphics.ImageTableViewModel">
113113
<vi:ImageTableView />
114114
</DataTemplate>
115-
<DataTemplate DataType="vm:LocoObjectMetadataViewModel">
115+
<DataTemplate DataType="vm:ObjectMetadataViewModel">
116116
<vi:MetadataView />
117117
</DataTemplate>
118118
<DataTemplate DataType="vm:ObjectEditorViewModel">

Gui/ViewModels/ObjectMetadataViewModel.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
using Definitions;
12
using Definitions.ObjectModels;
23
using ReactiveUI;
34
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
47

58
namespace Gui.ViewModels;
69

@@ -10,8 +13,10 @@ public ObjectMetadataViewModel(ObjectMetadata metadata)
1013
{
1114
Metadata = metadata;
1215
description = metadata.Description;
16+
availability = metadata.Availability;
1317
createdDate = metadata.CreatedDate;
1418
modifiedDate = metadata.ModifiedDate;
19+
uploadedDate = metadata.UploadedDate;
1520
}
1621

1722
public ObjectMetadataViewModel() : this(new ObjectMetadata("<empty>"))
@@ -20,6 +25,12 @@ public ObjectMetadataViewModel() : this(new ObjectMetadata("<empty>"))
2025

2126
public ObjectMetadata Metadata { get; }
2227

28+
// InternalName is readonly (init-only in the model)
29+
public string InternalName => Metadata.InternalName;
30+
31+
// Available values for Availability enum
32+
public IEnumerable<ObjectAvailability> AvailabilityValues => Enum.GetValues<ObjectAvailability>();
33+
2334
string? description;
2435
public string? Description
2536
{
@@ -31,6 +42,17 @@ public string? Description
3142
}
3243
}
3344

45+
ObjectAvailability availability;
46+
public ObjectAvailability Availability
47+
{
48+
get => availability;
49+
set
50+
{
51+
_ = this.RaiseAndSetIfChanged(ref availability, value);
52+
Metadata.Availability = value;
53+
}
54+
}
55+
3456
DateTimeOffset? createdDate;
3557
public DateTimeOffset? CreatedDate
3658
{
@@ -52,4 +74,15 @@ public DateTimeOffset? ModifiedDate
5274
Metadata.ModifiedDate = value;
5375
}
5476
}
77+
78+
DateTimeOffset uploadedDate;
79+
public DateTimeOffset UploadedDate
80+
{
81+
get => uploadedDate;
82+
set
83+
{
84+
_ = this.RaiseAndSetIfChanged(ref uploadedDate, value);
85+
Metadata.UploadedDate = value;
86+
}
87+
}
5588
}

Gui/Views/MetadataView.axaml

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88
xmlns:vm="using:Gui.ViewModels"
99
d:DesignHeight="450"
1010
d:DesignWidth="800"
11-
x:DataType="vm:LocoObjectMetadataViewModel"
11+
x:DataType="vm:ObjectMetadataViewModel"
1212
mc:Ignorable="d">
1313

1414
<TabControl
1515
Margin="8"
16-
Background="{DynamicResource ExpanderContentBackground}"
17-
DataContext="{Binding Metadata}">
16+
Background="{DynamicResource ExpanderContentBackground}">
1817
<TabItem Header="Details">
1918
<Grid>
2019
<Grid.ColumnDefinitions>
@@ -45,95 +44,109 @@
4544
Margin="4"
4645
VerticalAlignment="Center"
4746
IsReadOnly="True"
48-
Text="{Binding UniqueObjectId}" />
47+
Text="{Binding Metadata.UniqueObjectId}" />
4948

5049
<TextBlock
5150
Grid.Row="1"
5251
Grid.Column="0"
5352
Margin="4"
5453
VerticalAlignment="Center"
55-
Text="Description" />
54+
Text="Internal Name" />
5655
<TextBox
5756
Grid.Row="1"
5857
Grid.Column="1"
5958
Margin="4"
6059
VerticalAlignment="Center"
61-
IsReadOnly="False"
62-
Text="{Binding Description, Mode=TwoWay}" />
60+
IsReadOnly="True"
61+
Text="{Binding InternalName}" />
6362

6463
<TextBlock
6564
Grid.Row="2"
6665
Grid.Column="0"
6766
Margin="4"
6867
VerticalAlignment="Center"
69-
Text="Created Date" />
70-
<DatePicker
68+
Text="Description" />
69+
<TextBox
7170
Grid.Row="2"
7271
Grid.Column="1"
7372
Margin="4"
7473
VerticalAlignment="Center"
75-
IsEnabled="True"
76-
SelectedDate="{Binding CreatedDate, Mode=TwoWay}" />
74+
IsReadOnly="False"
75+
Text="{Binding Description, Mode=TwoWay}" />
7776

7877
<TextBlock
7978
Grid.Row="3"
8079
Grid.Column="0"
8180
Margin="4"
8281
VerticalAlignment="Center"
83-
Text="Modified Date" />
84-
<DatePicker
82+
Text="Availability" />
83+
<ComboBox
8584
Grid.Row="3"
8685
Grid.Column="1"
8786
Margin="4"
8887
VerticalAlignment="Center"
89-
IsEnabled="True"
90-
SelectedDate="{Binding ModifiedDate, Mode=TwoWay}" />
88+
ItemsSource="{Binding AvailabilityValues}"
89+
SelectedItem="{Binding Availability, Mode=TwoWay}" />
9190

9291
<TextBlock
9392
Grid.Row="4"
9493
Grid.Column="0"
9594
Margin="4"
9695
VerticalAlignment="Center"
97-
Text="Uploaded Date" />
96+
Text="Created Date" />
9897
<DatePicker
9998
Grid.Row="4"
10099
Grid.Column="1"
101100
Margin="4"
102101
VerticalAlignment="Center"
103-
IsEnabled="False"
104-
SelectedDate="{Binding UploadedDate}" />
102+
IsEnabled="True"
103+
SelectedDate="{Binding CreatedDate, Mode=TwoWay}" />
105104

106105
<TextBlock
107106
Grid.Row="5"
108107
Grid.Column="0"
109108
Margin="4"
110109
VerticalAlignment="Center"
111-
Text="Licence" />
112-
<TextBox
110+
Text="Modified Date" />
111+
<DatePicker
113112
Grid.Row="5"
114113
Grid.Column="1"
115114
Margin="4"
116115
VerticalAlignment="Center"
117-
IsReadOnly="True"
118-
Text="{Binding Licence.Name}" />
116+
IsEnabled="True"
117+
SelectedDate="{Binding ModifiedDate, Mode=TwoWay}" />
119118

120119
<TextBlock
121120
Grid.Row="6"
122121
Grid.Column="0"
123122
Margin="4"
124123
VerticalAlignment="Center"
125-
Text="Availability" />
126-
<TextBox
124+
Text="Uploaded Date" />
125+
<DatePicker
127126
Grid.Row="6"
128127
Grid.Column="1"
129128
Margin="4"
130129
VerticalAlignment="Center"
130+
IsEnabled="False"
131+
SelectedDate="{Binding UploadedDate}" />
132+
133+
<TextBlock
134+
Grid.Row="7"
135+
Grid.Column="0"
136+
Margin="4"
137+
VerticalAlignment="Center"
138+
Text="Licence" />
139+
<TextBox
140+
Grid.Row="7"
141+
Grid.Column="1"
142+
Margin="4"
143+
VerticalAlignment="Center"
131144
IsReadOnly="True"
132-
Text="{Binding Availability}" />
145+
Text="{Binding Metadata.Licence.Name}" />
133146
</Grid>
134147
</TabItem>
135148
<TabItem Header="Authors">
136-
<ListBox ItemsSource="{Binding Authors}">
149+
<ListBox ItemsSource="{Binding Metadata.Authors}">
137150
<ListBox.ItemsPanel>
138151
<ItemsPanelTemplate>
139152
<WrapPanel />
@@ -151,7 +164,7 @@
151164
</ListBox>
152165
</TabItem>
153166
<TabItem Header="Tags">
154-
<ListBox ItemsSource="{Binding Tags}">
167+
<ListBox ItemsSource="{Binding Metadata.Tags}">
155168
<ListBox.ItemsPanel>
156169
<ItemsPanelTemplate>
157170
<WrapPanel />
@@ -167,7 +180,7 @@
167180
</ListBox>
168181
</TabItem>
169182
<TabItem Header="ObjectPacks">
170-
<ListBox ItemsSource="{Binding ObjectPacks}">
183+
<ListBox ItemsSource="{Binding Metadata.ObjectPacks}">
171184
<ListBox.ItemsPanel>
172185
<ItemsPanelTemplate>
173186
<WrapPanel />
@@ -183,7 +196,7 @@
183196
</ListBox>
184197
</TabItem>
185198
<TabItem Header="DatObjects">
186-
<ListBox ItemsSource="{Binding DatObjects}">
199+
<ListBox ItemsSource="{Binding Metadata.DatObjects}">
187200
<ListBox.ItemsPanel>
188201
<ItemsPanelTemplate>
189202
<WrapPanel />

0 commit comments

Comments
 (0)