private WebControl getTableForFormItemList()
        {
            var actualNumberOfColumns = numberOfColumns ?? formItems.Sum(fi => getCellSpan(fi));

            if (actualNumberOfColumns < 1)
            {
                throw new ApplicationException("There must be at least one column.");
            }

            var table = EwfTable.Create(caption: heading, disableEmptyFieldDetection: true);

            if (formItems.Any(fi => getCellSpan(fi) > actualNumberOfColumns))
            {
                throw new ApplicationException("Form fields cannot have a column span greater than the number of columns.");
            }

            // NOTE: Make control list use an implementation more like this?
            foreach (var row in getFormItemRows(formItems, actualNumberOfColumns))
            {
                var items = row.ToList();
                (actualNumberOfColumns - row.Sum(r => getCellSpan(r))).Times(() => items.Add(getPlaceholderFormItem()));

                table.AddItem(
                    new EwfTableItem(
                        new EwfTableItemSetup(verticalAlignment: verticalAlignment),
                        items.Select(i => i.ToControl().ToCell(new TableCellSetup(fieldSpan: getCellSpan(i), textAlignment: i.TextAlignment))).ToArray()));
            }
            return(table);
        }
        private WebControl getTableForFormItemTable()
        {
            var columnWidthSpecified = firstColumnWidth != null || secondColumnWidth != null;
            var table = EwfTable.Create(
                caption: heading,
                fields:
                new[]
            {
                new EwfTableField(size: columnWidthSpecified?firstColumnWidth: Unit.Percentage(1)),
                new EwfTableField(size: columnWidthSpecified ? secondColumnWidth : Unit.Percentage(2))
            });

            table.AddData(
                formItems,
                i => {
                var stack = ControlStack.Create(true);
                if (i.Validation != null)
                {
                    stack.AddModificationErrorItem(i.Validation, new ListErrorDisplayStyle());
                }
                stack.AddControls(i.Control);
                return(new EwfTableItem(i.Label, stack.ToCell(new TableCellSetup(textAlignment: i.TextAlignment))));
            });
            return(table);
        }
        /// <summary>
        /// Creates a file collection manager.
        /// </summary>
        /// <param name="fileCollectionId"></param>
        /// <param name="displaySetup"></param>
        /// <param name="postBackIdBase">Do not pass null.</param>
        /// <param name="sortByName"></param>
        /// <param name="thumbnailResourceGetter">A function that takes a file ID and returns the corresponding thumbnail resource. Do not return null.</param>
        /// <param name="openedFileIds">The file IDs that should not be marked with a UI element drawing the user’s attention to the fact that they haven’t read it.
        /// All other files not in this collection will be marked. The collection can be null, and will result as nothing being shown as new.</param>
        /// <param name="unopenedFileOpenedNotifier">A method that executes when an unopened file is opened. Use to update the app’s database with an indication
        /// that the file has been seen by the user.</param>
        /// <param name="disableModifications">Pass true if there should be no way to upload or delete files.</param>
        /// <param name="uploadValidationMethod"></param>
        /// <param name="fileCreatedOrReplacedNotifier">A method that executes after a file is created or replaced.</param>
        /// <param name="filesDeletedNotifier">A method that executes after one or more files are deleted.</param>
        public BlobFileCollectionManager(
            int fileCollectionId, DisplaySetup displaySetup  = null, string postBackIdBase              = "", bool sortByName = false,
            Func <int, ResourceInfo> thumbnailResourceGetter = null, IEnumerable <int> openedFileIds    = null, MarkFileAsReadMethod unopenedFileOpenedNotifier = null,
            bool disableModifications = false, Action <RsFile, Validator> uploadValidationMethod        = null,
            NewFileNotificationMethod fileCreatedOrReplacedNotifier = null, Action filesDeletedNotifier = null)
        {
            postBackIdBase = PostBack.GetCompositeId("ewfFileCollection", postBackIdBase);

            var columnSetups = new List <EwfTableField>();

            if (thumbnailResourceGetter != null)
            {
                columnSetups.Add(new EwfTableField(size: 10.ToPercentage()));
            }
            columnSetups.Add(new EwfTableField(classes: new ElementClass("ewfOverflowedCell")));
            columnSetups.Add(new EwfTableField(size: 13.ToPercentage()));
            columnSetups.Add(new EwfTableField(size: 7.ToPercentage()));

            var table = EwfTable.Create(
                postBackIdBase: postBackIdBase,
                caption: "Files",
                selectedItemActions: disableModifications
                                                             ? null
                                                             : SelectedItemAction.CreateWithFullPostBackBehavior <int>(
                    "Delete Selected Files",
                    ids => {
                foreach (var i in ids)
                {
                    BlobStorageStatics.SystemProvider.DeleteFile(i);
                }
                filesDeletedNotifier?.Invoke();
                EwfPage.AddStatusMessage(StatusMessageType.Info, "Selected files deleted successfully.");
            })
                .ToCollection(),
                fields: columnSetups);

            IReadOnlyCollection <BlobFile> files = BlobStorageStatics.SystemProvider.GetFilesLinkedToFileCollection(fileCollectionId);

            files = (sortByName ? files.OrderByName() : files.OrderByUploadedDateDescending()).Materialize();

            foreach (var file in files)
            {
                addFileRow(postBackIdBase, thumbnailResourceGetter, openedFileIds, unopenedFileOpenedNotifier, table, file);
            }

            children = files.Any() || !disableModifications
                                           ? table.Concat(
                !disableModifications
                ?getUploadComponents( fileCollectionId, files, displaySetup, postBackIdBase, uploadValidationMethod, fileCreatedOrReplacedNotifier )
                : Enumerable.Empty <FlowComponent>())
                       .Materialize()
                                           : Enumerable.Empty <FlowComponent>().Materialize();
        }
예제 #4
0
        private static IReadOnlyCollection <FlowComponent> getFieldTree(string name, IEnumerable <MergeRow> emptyRowTree)
        {
            var singleRow = emptyRowTree.Single();

            var table = EwfTable.Create(caption: name, headItems: EwfTableItem.Create("Field name".ToCell(), "Description".ToCell()).ToCollection());

            table.AddData(singleRow.Values, i => EwfTableItem.Create(getFieldNameCellText(i).ToCell(), i.GetDescription().ToCell()));
            table.AddData(
                singleRow.Children,
                i => EwfTableItem.Create(
                    new GenericFlowContainer(getFieldTree(i.NodeName, i.Rows), classes: fieldTreeChildClass).ToCollection()
                    .ToCell(new TableCellSetup(fieldSpan: 2))));
            return(table.ToCollection());
        }
예제 #5
0
        private IReadOnlyCollection <FlowComponent> getContentFootBlock(
            bool isAutoDataUpdater, IReadOnlyCollection <ButtonSetup> contentFootActions, IReadOnlyCollection <FlowComponent> contentFootComponents)
        {
            var components = new List <FlowComponent>();

            if (contentFootActions != null)
            {
                if (contentFootActions.Any())
                {
                    components.Add(
                        new GenericFlowContainer(
                            new LineList(
                                contentFootActions.Select(
                                    (action, index) => (LineListItem)action.GetActionComponent(
                                        null,
                                        (text, icon) => new StandardButtonStyle(text, buttonSize: ButtonSize.Large, icon: icon),
                                        enableSubmitButton: index == 0)
                                    .ToComponentListItem(displaySetup: action.DisplaySetup))).ToCollection(),
                            classes: contentFootActionListContainerClass));
                }
                else if (isAutoDataUpdater)
                {
                    components.Add(new SubmitButton(new StandardButtonStyle("Update Now"), postBack: PageBase.Current.DataUpdatePostBack));
                }
            }
            else
            {
                if (isAutoDataUpdater)
                {
                    throw new ApplicationException("AutoDataUpdater is not currently compatible with custom content foot controls.");
                }
                components.AddRange(contentFootComponents);
            }

            if (!components.Any())
            {
                return(Enumerable.Empty <FlowComponent>().Materialize());
            }

            var table = EwfTable.Create(style: EwfTableStyle.StandardLayoutOnly, classes: contentFootBlockClass);

            table.AddItem(
                EwfTableItem.Create(
                    components.ToCell(
                        new TableCellSetup(
                            textAlignment: contentFootActions == null || !contentFootActions.Any() ? TextAlignment.Center : TextAlignment.NotSpecified))));
            return(table.ToCollection());
        }
        private void addFileRow(
            string postBackIdBase, Func <int, ResourceInfo> thumbnailResourceGetter, IEnumerable <int> openedFileIds, MarkFileAsReadMethod unopenedFileOpenedNotifier,
            EwfTable table, BlobFile file)
        {
            var cells = new List <EwfTableCell>();

            var thumbnailControl = BlobManagementStatics.GetThumbnailControl(file, thumbnailResourceGetter);

            if (thumbnailControl.Any())
            {
                cells.Add(thumbnailControl.ToCell());
            }

            var fileIsUnopened = openedFileIds != null && !openedFileIds.Contains(file.FileId);

            cells.Add(
                new EwfButton(
                    new StandardButtonStyle(file.FileName),
                    behavior: new PostBackBehavior(
                        postBack: PostBack.CreateFull(
                            id: PostBack.GetCompositeId(postBackIdBase, file.FileId.ToString()),
                            firstModificationMethod: () => {
                if (fileIsUnopened)
                {
                    unopenedFileOpenedNotifier?.Invoke(file.FileId);
                }
            },
                            actionGetter: () => new PostBackAction(
                                new PageReloadBehavior(secondaryResponse: new SecondaryResponse(new BlobFileResponse(file.FileId, () => true), false))))))
                .ToCollection()
                .ToCell());

            cells.Add(file.UploadedDate.ToDayMonthYearString(false).ToCell());
            cells.Add((fileIsUnopened ? "New!" : "").ToCell(new TableCellSetup(classes: "ewfNewness".ToCollection())));

            table.AddItem(EwfTableItem.Create(cells, setup: EwfTableItemSetup.Create(id: new SpecifiedValue <int>(file.FileId))));
        }
예제 #7
0
        /// <summary>
        /// Creates a page content object that uses the EWF user interface.
        /// </summary>
        /// <param name="omitContentBox">Pass true to omit the box-style effect around the page content. Useful when all content is contained within multiple
        /// box-style sections.</param>
        /// <param name="pageActions">The page actions.</param>
        /// <param name="contentFootActions">The content-foot actions. The first action, if it is a post-back, will produce a submit button.</param>
        /// <param name="contentFootComponents">The content-foot components.</param>
        /// <param name="dataUpdateModificationMethod">The modification method for the page’s data-update modification.</param>
        /// <param name="isAutoDataUpdater">Pass true to force a post-back when a hyperlink is clicked.</param>
        /// <param name="pageLoadPostBack">A post-back that will be triggered automatically by the browser when the page is finished loading.</param>
        public UiPageContent(
            bool omitContentBox = false, IReadOnlyCollection <ActionComponentSetup> pageActions = null, IReadOnlyCollection <ButtonSetup> contentFootActions = null,
            IReadOnlyCollection <FlowComponent> contentFootComponents = null, Action dataUpdateModificationMethod = null, bool isAutoDataUpdater             = false,
            ActionPostBack pageLoadPostBack = null)
        {
            pageActions = pageActions ?? Enumerable.Empty <ActionComponentSetup>().Materialize();
            if (contentFootActions != null && contentFootComponents != null)
            {
                throw new ApplicationException("Either contentFootActions or contentFootComponents may be specified, but not both.");
            }
            if (contentFootActions == null && contentFootComponents == null)
            {
                contentFootActions = Enumerable.Empty <ButtonSetup>().Materialize();
            }

            entityUiSetup = (PageBase.Current.EsAsBaseType as UiEntitySetup)?.GetUiSetup();
            basicContent  =
                new BasicPageContent(
                    dataUpdateModificationMethod: dataUpdateModificationMethod,
                    isAutoDataUpdater: isAutoDataUpdater,
                    pageLoadPostBack: pageLoadPostBack).Add(
                    getGlobalContainer()
                    .Append(
                        new GenericFlowContainer(
                            getEntityAndTopTabContainer()
                            .Append(
                                EwfTable.Create(style: EwfTableStyle.Raw, classes: sideTabAndContentBlockClass)
                                .AddItem(
                                    EwfTableItem.Create(
                                        (entityUsesTabMode(TabMode.Vertical)
                                                                                                                  ? getSideTabContainer().ToCell(setup: new TableCellSetup(classes: sideTabContainerClass)).ToCollection()
                                                                                                                  : Enumerable.Empty <EwfTableCell>()).Append(
                                            getPageActionListContainer(pageActions)
                                            .Append(
                                                new DisplayableElement(
                                                    context => new DisplayableElementData(
                                                        null,
                                                        () => new DisplayableElementLocalData("div"),
                                                        classes: omitContentBox ? null : contentClass,
                                                        children: content)))
                                            .Concat(getContentFootBlock(isAutoDataUpdater, contentFootActions, contentFootComponents))
                                            .Materialize()
                                            .ToCell(setup: new TableCellSetup(classes: contentClass)))
                                        .Materialize())))
                            .Materialize(),
                            clientSideIdOverride: entityAndTabAndContentBlockId))
                    .Concat(getGlobalFootContainer())
                    .Materialize());

            if (!EwfUiStatics.AppProvider.BrowserWarningDisabled() && AppRequestState.Instance.Browser.IsOldVersionOfMajorBrowser())
            {
                PageBase.AddStatusMessage(
                    StatusMessageType.Warning,
                    StringTools.ConcatenateWithDelimiter(
                        " ",
                        "We've detected that you are not using the latest version of your browser.",
                        "While most features of this site will work, and you will be safe browsing here, we strongly recommend using the newest version of your browser in order to provide a better experience on this site and a safer experience throughout the Internet.") +
                    "<br/>" +
                    Tewl.Tools.NetTools.BuildBasicLink("Click here to get Firefox (it's free)", new ExternalResource("http://www.getfirefox.com").GetUrl(), true) +
                    "<br />" +
                    Tewl.Tools.NetTools.BuildBasicLink(
                        "Click here to get Chrome (it's free)",
                        new ExternalResource("https://www.google.com/intl/en/chrome/browser/").GetUrl(),
                        true) + "<br />" + Tewl.Tools.NetTools.BuildBasicLink(
                        "Click here to get the latest Internet Explorer (it's free)",
                        new ExternalResource("http://www.beautyoftheweb.com/").GetUrl(),
                        true));
            }
        }