Skip to content

Commit

Permalink
Fixed #683 - relations not exporting. (#639)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJump committed May 16, 2024
1 parent 5fb73be commit 1fb88d0
Showing 1 changed file with 14 additions and 70 deletions.
84 changes: 14 additions & 70 deletions uSync.BackOffice/SyncHandlers/Handlers/RelationTypeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Strings;
Expand Down Expand Up @@ -70,12 +71,11 @@ public override IEnumerable<uSyncAction> ExportAll(string folder, HandlerSetting
return actions;
}


/// <summary>
/// Relations that by default we exclude, if the exlude setting is used,then it will override these values
/// and they will be included if not explicity set;
/// </summary>
private const string defaultRelations = "relateParentDocumentOnDelete,relateParentMediaFolderOnDelete,relateDocumentOnCopy,umbMedia,umbDocument";
/// <summary>
/// Relations that by default we exclude, if the exlude setting is used,then it will override these values
/// and they will be included if not explicity set;
/// </summary>
private const string defaultRelations = "relateParentDocumentOnDelete,relateParentMediaFolderOnDelete,relateDocumentOnCopy,umbMedia,umbDocument";

/// <summary>
/// Workout if we are excluding this relationType from export/import
Expand Down Expand Up @@ -103,68 +103,12 @@ protected override string GetItemName(IRelationType item)
protected override string GetItemFileName(IRelationType item)
=> GetItemAlias(item).ToSafeAlias(shortStringHelper);

// private void RelationService_SavedRelation(IRelationService sender, Umbraco.Core.Events.SaveEventArgs<IRelation> e)
// {
// if (uSync8BackOffice.eventsPaused) return;

// lock (saveLock)
// {
// saveTimer.Stop();
// saveTimer.Start();

// // add each item to the save list (if we haven't already)
// foreach (var item in e.SavedEntities)
// {
// if (!pendingSaveIds.Contains(item.RelationTypeId))
// pendingSaveIds.Add(item.RelationTypeId);
// }
// }
// }

// private void SaveTimer_Elapsed(object sender, ElapsedEventArgs e)
// {
// lock (saveLock)
// {
// UpdateRelationTypes(pendingSaveIds);
// pendingSaveIds.Clear();
// }
// }

// private static Timer saveTimer;
// private static List<int> pendingSaveIds;
// private static object saveLock;

// private void RelationService_DeletedRelation(IRelationService sender, Umbraco.Core.Events.DeleteEventArgs<IRelation> e)
// {
// if (uSync8BackOffice.eventsPaused) return;

// var types = new List<int>();

// foreach (var item in e.DeletedEntities)
// {
// if (!types.Contains(item.RelationTypeId))
// types.Add(item.RelationTypeId);
// }

// UpdateRelationTypes(types);
// }

// private void UpdateRelationTypes(IEnumerable<int> types)
// {
// foreach (var type in types)
// {
// var relationType = relationService.GetRelationTypeById(type);

// var attempts = Export(relationType, Path.Combine(rootFolder, this.DefaultFolder), DefaultConfig);

// if (!(this.DefaultConfig.GuidNames && this.DefaultConfig.UseFlatStructure))
// {
// foreach (var attempt in attempts.Where(x => x.Success))
// {
// this.CleanUp(relationType, attempt.FileName, Path.Combine(rootFolder, this.DefaultFolder));
// }
// }
// }
// }
}
protected override IEnumerable<IEntity> GetChildItems(int parent)
{
if (parent == -1)
return relationService.GetAllRelationTypes();

return [];
}
}
}

0 comments on commit 1fb88d0

Please sign in to comment.