From 7795a3f6c798936b0ae7fe5da5076db3d37c2d2e Mon Sep 17 00:00:00 2001 From: Arthur Zaczek Date: Mon, 28 Jun 2021 09:19:13 +0200 Subject: [PATCH] Fix CP List viewmodels. Bus sadly, newly created CP objects in a list will be saved. Only the second time, when they are modified. This is a major bug --- Zetbox.API/TypeTransformations.cs | 2 ++ Zetbox.API/Utils/ReadOnlyObservableProjection.cs | 3 ++- Zetbox.Assets/Zetbox.Assets.csproj | 9 +++++++++ Zetbox.Client/Models/ColumnDisplayModel.cs | 10 +++++++--- Zetbox.Client/Models/PropertyValueModel.cs | 9 ++++++++- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Zetbox.API/TypeTransformations.cs b/Zetbox.API/TypeTransformations.cs index a9ae93336b..1263d2f373 100644 --- a/Zetbox.API/TypeTransformations.cs +++ b/Zetbox.API/TypeTransformations.cs @@ -215,6 +215,8 @@ private InterfaceType(Type type, IInterfaceTypeChecker typeChecker) typeof(IRelationEntry), typeof(IValueCollectionEntry<,>), typeof(IValueCollectionEntry), + typeof(IValueListEntry<,>), + typeof(IValueListEntry), typeof(IPersistenceObject) }; diff --git a/Zetbox.API/Utils/ReadOnlyObservableProjection.cs b/Zetbox.API/Utils/ReadOnlyObservableProjection.cs index 255fb3795a..ce595a2840 100644 --- a/Zetbox.API/Utils/ReadOnlyObservableProjection.cs +++ b/Zetbox.API/Utils/ReadOnlyObservableProjection.cs @@ -104,7 +104,8 @@ protected virtual void OnCollectionChanged(NotifyCollectionChangedEventArgs args { if (CollectionChanged != null) { - CollectionChanged(this, args); + // TODO: CollectionChanged(this, args); + CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } } diff --git a/Zetbox.Assets/Zetbox.Assets.csproj b/Zetbox.Assets/Zetbox.Assets.csproj index b984aa8120..bbf8cabfbb 100644 --- a/Zetbox.Assets/Zetbox.Assets.csproj +++ b/Zetbox.Assets/Zetbox.Assets.csproj @@ -132,6 +132,7 @@ + @@ -148,8 +149,10 @@ + + @@ -198,12 +201,15 @@ + + + @@ -410,6 +416,8 @@ + + @@ -496,6 +504,7 @@ + diff --git a/Zetbox.Client/Models/ColumnDisplayModel.cs b/Zetbox.Client/Models/ColumnDisplayModel.cs index c4e8544328..ca832bd979 100644 --- a/Zetbox.Client/Models/ColumnDisplayModel.cs +++ b/Zetbox.Client/Models/ColumnDisplayModel.cs @@ -539,9 +539,13 @@ private void BuildColumns(Zetbox.App.Base.DataType cls, IEnumerable pr if (props == null) throw new ArgumentNullException("props"); if (methods == null) throw new ArgumentNullException("methods"); - ShowIcon = cls.ShowIconInLists; - ShowId = cls.ShowIdInLists; - ShowName = cls.ShowNameInLists; + if (cls is ObjectClass) + { + // Makes no sense on CompoundObjects + ShowIcon = cls.ShowIconInLists; + ShowId = cls.ShowIdInLists; + ShowName = cls.ShowNameInLists; + } this.Columns = new ObservableCollection( props.Select(p => ColumnDisplayModel.Create(mode, p)) diff --git a/Zetbox.Client/Models/PropertyValueModel.cs b/Zetbox.Client/Models/PropertyValueModel.cs index 7c887efdec..0378dd738c 100644 --- a/Zetbox.Client/Models/PropertyValueModel.cs +++ b/Zetbox.Client/Models/PropertyValueModel.cs @@ -101,7 +101,14 @@ public static IValueModel GetPropertyValueModel(this Property prop, INotifyingOb var cop = (CompoundObjectProperty)prop; if (cop.IsList) { - return new CompoundCollectionPropertyValueModel(obj, cop); + if (cop.HasPersistentOrder) + { + return new CompoundListPropertyValueModel(obj, cop); + } + else + { + return new CompoundCollectionPropertyValueModel(obj, cop); + } } else {