Beispiel #1
0
        public static ResponseCollection Links(
            this ResponseCollection res,
            Context context,
            SiteSettings ss,
            long id,
            BaseModel.MethodTypes?methodType)
        {
            var dataSet = DataSet(
                context: context,
                ss: ss,
                id: id);
            var links = HtmlLinkCreations.Links(
                context: context,
                ss: ss);

            new[] { ss.TabName(0) }
            .Concat(ss.Tabs?.Select(tab => ss.TabName(tab.Id)) ?? new List <string>())
            .Select((tabName, tabIndex) => new { tabName, tabIndex })
            .ForEach(data =>
            {
                ss.EditorColumnHash?.Get(data.tabName)?.ForEach(columnName =>
                {
                    var linkId = ss.LinkId(columnName);
                    if (linkId > 0)
                    {
                        var sourceSs      = TargetSiteSettings(ss.Sources, linkId);
                        var destinationSs = TargetSiteSettings(ss.Destinations, linkId);
                        var targetSs      = sourceSs ?? destinationSs;
                        if (targetSs != null)
                        {
                            var direction = sourceSs != null
                                    ? "Source"
                                    : "Destination";
                            var dataTableName = DataTableName(
                                ss: targetSs,
                                direction: direction);
                            res.Html("#" + dataTableName + "Field", new HtmlBuilder().Link(
                                         context: context,
                                         ss: ss,
                                         id: id,
                                         linkId: linkId,
                                         direction: direction,
                                         targetSs: targetSs,
                                         links: links,
                                         dataSet: dataSet,
                                         methodType: methodType,
                                         tabIndex: data.tabIndex));
                        }
                    }
                });
            });
            return(res);
        }
 public static HtmlBuilder LinkField(
     this HtmlBuilder hb,
     Context context,
     SiteSettings ss,
     long id,
     long linkId,
     List <Link> links,
     DataSet dataSet,
     BaseModel.MethodTypes?methodType,
     int tabIndex)
 {
     new[]
     {
         new
         {
             Ss        = TargetSiteSettings(ss.Destinations, linkId),
             Direction = "Destination"
         },
         new
         {
             Ss        = TargetSiteSettings(ss.Sources, linkId),
             Direction = "Source"
         }
     }.Where(target => target.Ss != null).ForEach(target =>
     {
         var targetSs = ss.JoinedSsHash.Get(linkId);
         if (targetSs != null)
         {
             var dataTableName = DataTableName(
                 ss: targetSs,
                 direction: target.Direction);
             hb.Div(
                 id: dataTableName + "Field",
                 action: () => hb.Link(
                     context: context,
                     ss: ss,
                     id: id,
                     linkId: linkId,
                     direction: target.Direction,
                     targetSs: targetSs,
                     links: links,
                     dataSet: dataSet,
                     methodType: methodType,
                     tabIndex: tabIndex));
         }
     });
     return(hb);
 }
Beispiel #3
0
        public static HtmlBuilder LinkField(
            this HtmlBuilder hb,
            Context context,
            SiteSettings ss,
            long id,
            long linkId,
            List <Link> links,
            DataSet dataSet,
            BaseModel.MethodTypes?methodType,
            int tabIndex)
        {
            var sourceSs      = TargetSiteSettings(ss.Sources, linkId);
            var destinationSs = TargetSiteSettings(ss.Destinations, linkId);
            var targetSs      = sourceSs ?? destinationSs;

            if (targetSs != null)
            {
                var direction = sourceSs != null
                    ? "Source"
                    : "Destination";
                var dataTableName = DataTableName(
                    ss: targetSs,
                    direction: direction);
                hb.Div(
                    id: dataTableName + "Field",
                    action: () => hb.Link(
                        context: context,
                        ss: ss,
                        id: id,
                        linkId: linkId,
                        direction: direction,
                        targetSs: targetSs,
                        links: links,
                        dataSet: dataSet,
                        methodType: methodType,
                        tabIndex: tabIndex));
            }
            return(hb);
        }
Beispiel #4
0
 private static HtmlBuilder Link(
     this HtmlBuilder hb,
     Context context,
     SiteSettings ss,
     long id,
     long linkId,
     string direction,
     SiteSettings targetSs,
     List <Link> links,
     DataSet dataSet,
     BaseModel.MethodTypes?methodType,
     int tabIndex)
 {
     return(hb.FieldSet(
                css: " enclosed link-creations",
                legendText: Displays.Links(context: context),
                action: () => hb.Div(action: () =>
     {
         var link = links.FirstOrDefault(o => o.SourceId == linkId);
         if (link != null && direction == "Source")
         {
             hb.Div(action: () => hb.LinkCreationButton(
                        context: context,
                        ss: ss,
                        linkId: id,
                        sourceId: link.SourceId,
                        text: link.SiteTitle,
                        tabIndex: tabIndex));
         }
         hb.LinkTable(
             context: context,
             ss: targetSs,
             direction: direction,
             dataSet: dataSet,
             tabIndex: tabIndex);
     }),
                _using: methodType != BaseModel.MethodTypes.New));
 }