Ejemplo n.º 1
0
        private VueComponentDefinition[] FullPreviewValue(ContentField field, ContentFieldDefinition definition)
        {
            var f       = field.DirectCastTo <FauxUrlSlugField>();
            var fullUrl = GetFullUrl(f);

            return(new VueComponentDefinition[] {
                new VueHtmlWidget($"<a href='{fullUrl}' target='_blank'>{fullUrl}</a>")
            });
        }
        public ContentModifierForm BuildModifierForm(ContentField field,
                                                     ContentModifyOperation operation, ProtoContent content, ContentFieldDefinition fieldDefinition)
        {
            var f    = field.DirectCastTo <TrashingField>();
            var form = new TrashingFieldModifierForm {
                TrashedAt = f.TrashedUtc?.ToLocalTime()
            };

            return(form);
        }
        public ContentModifierForm BuildModifierForm(ContentField field, ContentModifyOperation operation,
                                                     ProtoContent content,
                                                     ContentFieldDefinition fieldDefinition)
        {
            var fi = field.DirectCastTo <FilePickerField>();
            var fm = new FilePickerFieldModifierForm {
                Val = fi.Val
            };

            return(fm);
        }
        private string GetSummaryValue(ContentField field, ContentFieldDefinition definition)
        {
            var f         = field.DirectCastTo <TextField>();
            var cfg       = definition.Config.DirectCastTo <TextFieldConfiguration>();
            var stripped  = f.Val.StripHtmlTags();
            var shortened = stripped == null ? "" : (stripped.Length > cfg.MaxSummaryLength
                ? stripped.Substring(0, cfg.MaxSummaryLength) + "..."
                : stripped);

            return(shortened);
        }
        private string SummarizedValueForWeb(ContentField contentField, ContentFieldDefinition contentFieldDefinition)
        {
            var fi   = contentField.DirectCastTo <FilePickerField>();
            var fcfg = contentFieldDefinition.Config.DirectCastTo <FilePickerFieldConfiguration>();

            if (fcfg.IsMultiSelect)
            {
                return($"{fi.WebPaths.Length} file{(fi.WebPaths.Length > 1 ? "s" : "")}");
            }
            return(fi.WebPaths.FirstOrDefault());
        }
Ejemplo n.º 6
0
        public ContentModifierForm BuildModifierForm(ContentField field, ContentModifyOperation operation,
                                                     ProtoContent content,
                                                     ContentFieldDefinition fieldDefinition)
        {
            var cf   = field.DirectCastTo <SelectField>();
            var val  = cf.Val;
            var form = new SelectFieldModifierForm {
                Val = val
            };

            return(form);
        }
        public ContentModifierForm BuildModifierForm(ContentField field,
                                                     ContentModifyOperation operation, ProtoContent content,
                                                     ContentFieldDefinition fieldDefinition)
        {
            var f = field != null?field.DirectCastTo <PublishingField>() : new PublishingField();

            var form = new PublishingFieldModifierForm {
                PublishedAt   = f.PublishedUtc?.ToLocalTime(),
                UnpublishedAt = f.UnpublishedUtc?.ToLocalTime()
            };

            return(form);
        }
Ejemplo n.º 8
0
        private string GetColumnSummarizedValue(ContentField field, ContentFieldDefinition definition)
        {
            var f     = field.DirectCastTo <BooleanField>();
            var label = definition.Config.Label ?? definition.FieldName;

            if (!f.Val.HasValue)
            {
                return($"{label} unknown");
            }
            if (f.Val.Value)
            {
                return($"{label}");
            }
            return("");
        }
        public ContentModifierForm BuildModifierForm(ContentField field, ContentModifyOperation operation,
                                                     ProtoContent content,
                                                     ContentFieldDefinition fieldDefinition)
        {
            var cf  = field.DirectCastTo <TextField>();
            var cfg = fieldDefinition.Config.DirectCastTo <TextFieldConfiguration>();
            var val = cf.Val;

            if (operation.IsCreateOperation())
            {
                val = cfg.InitialValue;
            }
            var form = new TextFieldModifierForm {
                Val = val
            };

            return(form);
        }
        private VueComponentDefinition[] FullPreviewValueForReal(ContentField contentField,
                                                                 ContentFieldDefinition contentFieldDefinition)
        {
            var vues = new List <VueComponentDefinition>();
            var fi   = contentField.DirectCastTo <FilePickerField>();
            var idx  = 0;

            if (fi.Val.Length != fi.DownloadPaths.Length)
            {
                fi.UpdateRelatedPaths(_fileMgr.GetHandler());
            }
            foreach (var val in fi.RealPaths)
            {
                vues.Add(new VueHtmlWidget($"<li><a href='{_urlProv.GetBaseWebsiteContentUrl()}{fi.DownloadPaths[idx]}' target='_blank'>{val}</a></li>"));
                idx++;
            }
            return(vues.ToArray());
        }
        private VueComponentDefinition[] FullPreviewValue(ContentField contentField,
                                                          ContentFieldDefinition contentFieldDefinition)
        {
            var field   = contentField.DirectCastTo <SelectField>();
            var fcfg    = contentFieldDefinition.Config.DirectCastTo <SelectFieldConfiguration>();
            var handler = fcfg.OptionsHandler();

            if (!fcfg.IsMultiSelect)
            {
                var val  = field.Val.FirstOrDefault();
                var html = "-n/a-";
                if (val != null)
                {
                    var opt = handler.GetOptionObject(val, fcfg.OptionsHandlerParam);
                    if (opt != null)
                    {
                        html = $"<li>{handler.GetOptionDisplay(opt, fcfg.OptionsHandlerParam).Label} <code class='small text-muted'>{val}</code></li>";
                    }
                }
                return(new VueComponentDefinition[] {
                    new VueHtmlWidget(html)
                });
            }
            var vues = new List <VueComponentDefinition>();

            foreach (var val in field.Val)
            {
                var html = "-n/a-";
                if (val != null)
                {
                    var opt = handler.GetOptionObject(val, fcfg.OptionsHandlerParam);
                    if (opt != null)
                    {
                        html = $"<li>{handler.GetOptionDisplay(opt, fcfg.OptionsHandlerParam).Label} <code class='small text-muted'>{val}</code></li>";
                    }
                }
                vues.Add(new VueHtmlWidget(html));
            }
            if (vues.Count == 0)
            {
                vues.Add(new VueHtmlWidget("-n/a-"));
            }
            return(vues.ToArray());
        }
Ejemplo n.º 12
0
        private VueComponentDefinition[] GetColumnCellValue(ContentField field, ContentFieldDefinition definition)
        {
            var f    = field.DirectCastTo <BooleanField>();
            var fcfg = definition.Config.DirectCastTo <BooleanFieldConfiguration>();

            if (!f.Val.HasValue)
            {
                return(new VueComponentDefinition[] {
                    new VueHtmlWidget($"<i class='fa fa-question-circle'></i> {fcfg.NullBoolLabel ?? "Unknown"}")
                });
            }
            if (f.Val.Value)
            {
                return(new VueComponentDefinition[] {
                    new VueHtmlWidget($"<i class='fa fa-check-square'></i> {fcfg.TrueBoolLabel ?? "Yes"}")
                });
            }
            return(new VueComponentDefinition[] {
                new VueHtmlWidget($"<i class='fa fa-square-o'></i> {fcfg.FalseBoolLabel ?? "Yes"}")
            });
        }
        private string SummarizedValue(ContentField contentField, ContentFieldDefinition contentFieldDefinition)
        {
            var field   = contentField.DirectCastTo <SelectField>();
            var fcfg    = contentFieldDefinition.Config.DirectCastTo <SelectFieldConfiguration>();
            var handler = fcfg.OptionsHandler();

            if (!fcfg.IsMultiSelect)
            {
                var val    = field.Val.FirstOrDefault();
                var sumval = "-n/a-";
                if (val != null)
                {
                    var opt = handler.GetOptionObject(val, fcfg.OptionsHandlerParam);
                    if (opt != null)
                    {
                        sumval = $"{handler.GetOptionDisplay(opt, fcfg.OptionsHandlerParam).Label}";
                    }
                }
                return(sumval);
            }
            return($"{field.Val.Length} items in {fcfg.Label} field");
        }
Ejemplo n.º 14
0
        private string SummarizedValue(ContentField field, ContentFieldDefinition definition)
        {
            var f = field.DirectCastTo <FauxUrlSlugField>();

            return(GetFullUrl(f));
        }