public ConnectorDisplayContext(IConnector item, string displayType, SocketDisplayContext context) : base(context.Connector) { ConnectorContent = item; RenderConnector = true; SocketContext = context; RightField = new Lazy <SocketEndpoint>(() => new SocketEndpoint(ConnectorContent.RightContent, displayType)); }
protected override void Displaying(SocketDisplayContext context) { // TODO: Optionally expose a unified feed comprised of all applicable connector types. // TODO: We could feasibly want to register the feed on other display types if (context.Left.DisplayType == "Detail") { var settings = context.Connector.PartDefinition.Settings.GetModel<AggregationTypePartSettings>(); if (settings != null && settings.ExposeFeed) { _feedManager.Register(context.Left.ContentItem.GetTitle() + " - " + context.SocketMetadata.SocketTitle, "rss", new RouteValueDictionary { { "id", context.Left.ContentItem.Id }, { "connector", context.Connector.Name } }); } } }
protected override void Preparing(SocketDisplayContext context) { context.ModelContext.With<DrillFilterData>(df => { if (context.Connector.Name == df.DrillType) { context.Paradigms.Add("DrillSummary"); if (df.Id.HasValue) { context.ModelContext.Paradigms.Add("DrillDetail"); } } else { context.Paradigms.Add("DrillExclude"); } }); }
protected override void Displaying(SocketDisplayContext context) { // Set a paradigm for empty sockets if (context.Query.TotalCount == 0) { context.Paradigms.Add("Empty"); if (!context.Paradigms.Has("ShowEmpty")) { context.RenderSocket = false; } // TODO: A pure-placement method didn't work because Displaying happens after Placement. But we don't want to execute the count for every single connector type // because a lot will already be decided against in advance. Either a) cache the current count on SocketsPartRecord or b) find another way, e.g. a delegate that // will only run if placement hasn't already been denied. // context.Paradigms.Add("Empty"); } // Do some default display type mapping // TODO: Could be done in placement now? if (String.IsNullOrWhiteSpace(context.Connector.DisplayType)) { switch (context.Left.DisplayType) { case "Detail": context.Connector.DisplayType = "Summary"; break; case "Summary": context.Connector.DisplayType = "SummaryTiny"; context.Paradigms.Add("ConnectorsFlatten"); break; case "SummaryAdmin": context.Connector.DisplayType = "Link"; context.Paradigms.Add("ConnectorsFlatten"); break; case "SummaryTiny": // Prevent further recursion by default context.RenderSocket = false; break; case "Link": // Prevent further recursion by default context.RenderSocket = false; break; default: // Any other situtations we don't understand, just use links. context.Connector.DisplayType = "Link"; break; } } }
protected override void Preparing(SocketDisplayContext context) { if (context.Left.DisplayType == "Detail") { var clipPart = context.Connector.Definition.Parts.FirstOrDefault(p => p.PartDefinition.Name == "PaperclipPart"); if (clipPart != null) { // Get actual part model from item var settings = clipPart.Settings.GetModel<PaperclipTypePartSettings>(); if (!String.IsNullOrWhiteSpace(settings.DefaultPlacement)) { context.LayoutPlacement = settings.DefaultPlacement; } if (!String.IsNullOrWhiteSpace(settings.DefaultDisplayType)) { context.Connector.DisplayType = settings.DefaultDisplayType; } } } }
protected override void Displaying(SocketDisplayContext context) { if (context.RootModel.DisplayType == "Detail") { switch (context.Connector.Name) { case "CountryToTown": context.Left.DisplayType = context.Connector.DisplayType = "Directory"; // TODO: In migration add to settings context.Paradigms.Add("Count"); break; case "TownToAddress": context.Left.DisplayType = context.Connector.DisplayType = "Listing"; // TODO: In migration add to settings context.Paradigms.Add("Collapse"); break; } } // From DirectoryController, we get a bunch of Address items in Summary mode if (context.RootModel.DisplayType == "Summary") { switch (context.Connector.Name) { case "AddressToUser": context.Left.DisplayType = context.Connector.DisplayType = "Listing"; break; case "AddressToTown": context.Left.DisplayType = context.Connector.DisplayType = "Listing"; break; } } if (context.RootModel.DisplayType == "Listing") { // ... } }
void ISocketHandler.Updated(SocketDisplayContext context) { Updated(context); }
void ISocketHandler.Editor(SocketDisplayContext context) { Editor(context); }
void ISocketHandler.Displaying(SocketDisplayContext context) { Displaying(context); }
void ISocketHandler.Preparing(SocketDisplayContext context) { Preparing(context); }
protected virtual void Updated(SocketDisplayContext context) { }
protected virtual void Preparing(SocketDisplayContext context) { }
protected override void Displaying(SocketDisplayContext context) { }
public ConnectorDisplayContext(IConnector item, string displayType, SocketDisplayContext context) : base(context.Connector) { ConnectorContent = item; RenderConnector = true; SocketContext = context; RightField = new Lazy<SocketEndpoint>(() => new SocketEndpoint(ConnectorContent.RightContent, displayType)); }
protected virtual void Displaying(SocketDisplayContext context) { }
protected virtual void Editor(SocketDisplayContext context) { }
protected override void Preparing(SocketDisplayContext context) { if (context.ModelContext.Mode == "Display" && context.Paradigms.Has("Navigation") && context.ModelContext.DisplayType=="Navigation") { context.Connector.DisplayType = "Navigation"; } }
protected override void Editing(SocketDisplayContext context) { context.Left.DisplayType="Editor"; context.Connector.DisplayType = "EditorConnector"; if (context.Query.TotalCount == 0) { context.Paradigms.Add("Empty"); } // Check box list or drop down list? context.Paradigms.Add(context.Connector.Settings.AllowMany ? "Many" : "One"); context.Paradigms.Add(context.Connector.Settings.AllowDuplicates ? "DuplicatesPossible" : "Unique"); // Outright hide editor. Typically used when we have an inverse connector and we only // actually want to work with one end of the connector in UI. if (context.Paradigms.Has("Hidden")) { context.RenderSocket = false; } }
public SocketsDriverResult(string shapeType, string prefix, Framework.SocketDisplayContext socketContext, Func<SocketDisplayContext, ModelShapeContext, dynamic> factory) : base(shapeType,prefix,(c)=>factory(socketContext,c)) { SocketContext = socketContext; }