shpaass/yafc-ce

Delete page sometimes only hides it

Closed this issue · 5 comments

afbeelding

The delete page button above does not work for some pages, but does work for others. Need to dig into this to find out why.

While studying my local project with this issue, I noticed that for many tabs, the property canDelete of my YAFC.Model.ProductionTable is false. However, checking the code, it should only ever be false for YAFC.Mode.Summary so i'm not sure how my local project got in that state.

Ah i think i found it:

212f938

This change made existing pages impossible to delete, since 'canDelete' will be false when the boolean is absent.

Hm... I messed up by picking a new field where the default (false) is wrong. So on existing saves (from before this change) the default is wrong, as for those pages the canDelete should have been true...

I do not think it is possible to fix this anymore, as we do not have file versions, so we cannot detect whether the fix was applied on a save already or not.

I suppose the easiest way to fix a save, is to open the file in your favorite text editor and manually change the canDelete values to true (except for the YAFC.Model.Summary as this field was introduce for this).

Now that I think about it, if the SummaryPage would support getting deleted (I forgot why this is not the case). The whole canField field can be removed and the issue would be solved as well/properly.

Yes, i think we can just find out if it's a summary page another way, like with page.contentType == typeof(Summary), but if SummaryPage gets delete support, you could get rid of the entire logic. What would you prefer? I could make PR for either scenario, but i'm not sure if supporting deletino for SummaryPage require additional work.