Exemple #1
0
        private static IChart ChartHasDataTable()
        {
            var chart = (GanttChart)ChartWithScrolling();

            chart.Caption = "Chart with DataTable";
            chart.DataTable.HeaderAttr.VAlign = FusionVerticalAlign.Bottom;

            var dataColumn = new DataColumnElement
            {
                HeaderText = "Worker"
            };

            dataColumn.HeaderAttr.FontAttr.Font      = "맑은 고딕";
            dataColumn.HeaderAttr.FontAttr.FontColor = Color.DarkSlateGray;
            dataColumn.HeaderAttr.FontAttr.FontSize  = 18.ToString();
            dataColumn.HeaderAttr.VAlign             = FusionVerticalAlign.Bottom;
            dataColumn.HeaderAttr.Align           = FusionTextAlign.Right;
            dataColumn.ItemAttr.Align             = FusionTextAlign.Left;
            dataColumn.ItemAttr.FontAttr.FontSize = 12.ToString();

            foreach (var worker in RoleNames)
            {
                var text = new DataColumnTextElement {
                    Label = worker
                };
                text.ItemAttr.FontAttr.Font     = "맑은 고딕";
                text.ItemAttr.FontAttr.FontSize = "12";
                text.ItemAttr.Align             = FusionTextAlign.Center;
                // mailto 는 javascript로 처리할 수 없다...
                // text.Link.Javascript = "mailto:[email protected]";
                // dataColumn.TextElements.Add(text);
                dataColumn.Add(text);
            }

            // chart.DataTable.DataColumnElements.Add(dataColumn);
            chart.DataTable.Add(dataColumn);

            return(chart);
        }
        /// <summary>
        /// Defines the products backend content view.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <returns></returns>
        public static ContentViewControlElement DefineProductsBackendContentView(ConfigElement parent)
        {
            // define content view control
            var backendContentView = new ContentViewControlElement(parent)
            {
                ControlDefinitionName = BackendDefinitionName,
                ContentType = typeof(ProductItem)
            };

            // *** define views ***

            #region products backend list view

            var productsGridView = new MasterGridViewElement(backendContentView.ViewsConfig)
            {
                ViewName = ProductsDefinitions.BackendListViewName,
                ViewType = typeof(MasterGridView),
                AllowPaging = true,
                DisplayMode = FieldDisplayMode.Read,
                ItemsPerPage = 50,
                ResourceClassId = typeof(ProductsResources).Name,
                SearchFields = "Title",
                SortExpression = "Title ASC",
                Title = "ProductsViewTitle",
                WebServiceBaseUrl = "~/Sitefinity/Services/Content/Products.svc/"
            };

            #region Toolbar definition

            WidgetBarSectionElement masterViewToolbarSection = new WidgetBarSectionElement(productsGridView.ToolbarConfig.Sections)
            {
                Name = "toolbar"
            };


            var createproductsWidget = new CommandWidgetElement(masterViewToolbarSection.Items)
            {
                Name = "CreateproductsWidget",
                ButtonType = CommandButtonType.Create,
                CommandName = DefinitionsHelper.CreateCommandName,
                Text = "CreateItem",
                ResourceClassId = typeof(ProductsResources).Name,
                CssClass = "sfMainAction",
                WidgetType = typeof(CommandWidget),
                PermissionSet = ProductsConstants.Security.PermissionSetName,
                ActionName = ProductsConstants.Security.Create
            };
            masterViewToolbarSection.Items.Add(createproductsWidget);

            var deleteproductsWidget = new CommandWidgetElement(masterViewToolbarSection.Items)
            {
                Name = "DeleteproductsWidget",
                ButtonType = CommandButtonType.Standard,
                CommandName = DefinitionsHelper.GroupDeleteCommandName,
                Text = "Delete",
                ResourceClassId = typeof(ProductsResources).Name,
                WidgetType = typeof(CommandWidget),
                CssClass = "sfGroupBtn"
            };
            masterViewToolbarSection.Items.Add(deleteproductsWidget);

            masterViewToolbarSection.Items.Add(DefinitionsHelper.CreateSearchButtonWidget(masterViewToolbarSection.Items, typeof(ProductItem)));

            productsGridView.ToolbarConfig.Sections.Add(masterViewToolbarSection);

            #endregion

            #region Sidebar definition

            var languagesSection = new LocalizationWidgetBarSectionElement(productsGridView.SidebarConfig.Sections)
            {
                Name = "Languages",
                Title = "Languages",
                ResourceClassId = typeof(LocalizationResources).Name,
                CssClass = "sfFirst sfSeparator sfLangSelector",
                WrapperTagId = "languagesSection"
            };

            languagesSection.Items.Add(new LanguagesDropDownListWidgetElement(languagesSection.Items)
            {
                Name = "Languages",
                Text = "Languages",
                ResourceClassId = typeof(LocalizationResources).Name,
                CssClass = string.Empty,
                WidgetType = typeof(LanguagesDropDownListWidget),
                IsSeparator = false,
                LanguageSource = LanguageSource.Frontend,
                AddAllLanguagesOption = false,
                CommandName = DefinitionsHelper.ChangeLanguageCommandName
            });

            WidgetBarSectionElement sidebarSection = new WidgetBarSectionElement(productsGridView.SidebarConfig.Sections)
            {
                Name = "Filter",
                Title = "FilterProducts",
                ResourceClassId = typeof(ProductsResources).Name,
                CssClass = "sfFirst sfWidgetsList sfSeparator sfModules",
                WrapperTagId = "filterSection"
            };

            sidebarSection.Items.Add(new CommandWidgetElement(sidebarSection.Items)
            {
                Name = "AllProducts",
                CommandName = DefinitionsHelper.ShowAllItemsCommandName,
                ButtonType = CommandButtonType.SimpleLinkButton,
                Text = "AllProducts",
                ResourceClassId = typeof(ProductsResources).Name,
                CssClass = String.Empty,
                WidgetType = typeof(CommandWidget),
                IsSeparator = false,
                ButtonCssClass = "sfSel",
            });

            sidebarSection.Items.Add(new CommandWidgetElement(sidebarSection.Items)
            {
                Name = "MyProducts",
                CommandName = DefinitionsHelper.ShowMyItemsCommandName,
                ButtonType = CommandButtonType.SimpleLinkButton,
                Text = "MyProducts",
                ResourceClassId = typeof(ProductsResources).Name,
                CssClass = String.Empty,
                WidgetType = typeof(CommandWidget),
                IsSeparator = false
            });

            sidebarSection.Items.Add(new CommandWidgetElement(sidebarSection.Items)
            {
                Name = "DraftProducts",
                CommandName = DefinitionsHelper.ShowMasterItemsCommandName,
                ButtonType = CommandButtonType.SimpleLinkButton,
                Text = "DraftProducts",
                ResourceClassId = typeof(ProductsResources).Name,
                CssClass = String.Empty,
                WidgetType = typeof(CommandWidget),
                IsSeparator = false
            });

            sidebarSection.Items.Add(new CommandWidgetElement(sidebarSection.Items)
            {
                Name = "PublishedProducts",
                CommandName = DefinitionsHelper.ShowPublishedItemsCommandName,
                ButtonType = CommandButtonType.SimpleLinkButton,
                Text = "PublishedProducts",
                ResourceClassId = typeof(ProductsResources).Name,
                CssClass = String.Empty,
                WidgetType = typeof(CommandWidget),
                IsSeparator = false
            });

            sidebarSection.Items.Add(new CommandWidgetElement(sidebarSection.Items)
            {
                Name = "ScheduledProducts",
                CommandName = DefinitionsHelper.ShowScheduledItemsCommandName,
                ButtonType = CommandButtonType.SimpleLinkButton,
                Text = "ScheduledProducts",
                ResourceClassId = typeof(ProductsResources).Name,
                CssClass = String.Empty,
                WidgetType = typeof(CommandWidget),
                IsSeparator = false
            });

            sidebarSection.Items.Add(new CommandWidgetElement(sidebarSection.Items)
            {
                Name = "PendingApprovalProducts",
                CommandName = DefinitionsHelper.PendingApprovalItemsCommandName,
                ButtonType = CommandButtonType.SimpleLinkButton,
                Text = "WaitingForApproval",
                ResourceClassId = typeof(ProductsResources).Name,
                CssClass = String.Empty,
                WidgetType = typeof(CommandWidget),
                IsSeparator = false
            });

            sidebarSection.Items.Add(new LiteralWidgetElement(sidebarSection.Items)
            {
                Name = "Separator",
                WrapperTagKey = HtmlTextWriterTag.Li,
                WidgetType = typeof(LiteralWidget),
                CssClass = "sfSeparator",
                Text = "&nbsp;",
                IsSeparator = true
            });

            var categoryFilterSection = new WidgetBarSectionElement(productsGridView.SidebarConfig.Sections)
            {
                Name = "Category",
                Title = "ProductItemsByCategory",
                ResourceClassId = typeof(ProductsResources).Name,
                CssClass = "sfFilterBy sfSeparator",
                WrapperTagId = "categoryFilterSection",
                Visible = false
            };
            productsGridView.SidebarConfig.Sections.Add(categoryFilterSection);

            var tagFilterSection = new WidgetBarSectionElement(productsGridView.SidebarConfig.Sections)
            {
                Name = "ByTag",
                Title = "ProductItemsByTag",
                ResourceClassId = typeof(ProductsResources).Name,
                CssClass = "sfFilterBy sfSeparator",
                WrapperTagId = "tagFilterSection",
                Visible = false
            };
            productsGridView.SidebarConfig.Sections.Add(tagFilterSection);

            var dateFilterSection = new WidgetBarSectionElement(productsGridView.SidebarConfig.Sections)
            {
                Name = "UpdatedProducts",
                Title = "DisplayLastUpdatedProducts",
                ResourceClassId = typeof(ProductsResources).Name,
                CssClass = "sfFilterBy sfFilterByDate sfSeparator",
                WrapperTagId = "dateFilterSection",
                Visible = false
            };
            productsGridView.SidebarConfig.Sections.Add(dateFilterSection);

            categoryFilterSection.Items.Add(new CommandWidgetElement(categoryFilterSection.Items)
            {
                Name = "CloseCategories",
                CommandName = DefinitionsHelper.ShowSectionsExceptCommandName,
                CommandArgument = DefinitionsHelper.ConstructDisplaySectionsCommandArgument(
                    categoryFilterSection.WrapperTagId, tagFilterSection.WrapperTagId, dateFilterSection.WrapperTagId),
                ButtonType = CommandButtonType.SimpleLinkButton,
                Text = "CloseCategories",
                ResourceClassId = typeof(Labels).Name,
                CssClass = "sfCloseFilter",
                WidgetType = typeof(CommandWidget),
                IsSeparator = false
            });

            var categoryFilterWidget = new DynamicCommandWidgetElement(categoryFilterSection.Items)
            {
                Name = "CategoryFilter",
                CommandName = "filterByCategory",
                PageSize = 10,
                WidgetType = typeof(DynamicCommandWidget),
                IsSeparator = false,
                BindTo = BindCommandListTo.HierarchicalData,
                BaseServiceUrl = String.Format("~/Sitefinity/Services/Taxonomies/HierarchicalTaxon.svc/{0}/", TaxonomyManager.CategoriesTaxonomyId),
                ChildItemsServiceUrl = "~/Sitefinity/Services/Taxonomies/HierarchicalTaxon.svc/subtaxa/",
                PredecessorServiceUrl = "~/Sitefinity/Services/Taxonomies/HierarchicalTaxon.svc/predecessor/",
                ClientItemTemplate = @"<a href='javascript:void(0);' class='sf_binderCommand_filterByCategory'>{{ Title }}</a> <span class='sfCount'>({{ItemsCount}})</span>"
            };

            categoryFilterWidget.UrlParameters.Add("itemType", typeof(ProductItem).AssemblyQualifiedName);
            categoryFilterSection.Items.Add(categoryFilterWidget);

            tagFilterSection.Items.Add(new CommandWidgetElement(tagFilterSection.Items)
            {
                Name = "CloseTags",
                CommandName = DefinitionsHelper.ShowSectionsExceptCommandName,
                CommandArgument = DefinitionsHelper.ConstructDisplaySectionsCommandArgument(
                    tagFilterSection.WrapperTagId, categoryFilterSection.WrapperTagId, dateFilterSection.WrapperTagId),
                ButtonType = CommandButtonType.SimpleLinkButton,
                Text = "CloseTags",
                ResourceClassId = typeof(Labels).Name,
                CssClass = "sfCloseFilter",
                WidgetType = typeof(CommandWidget),
                IsSeparator = false
            });

            var clientTemplateBuilder = new System.Text.StringBuilder();
            clientTemplateBuilder.Append(@"<a href=""javascript:void(0);"" class=""sf_binderCommand_filterByTag");
            clientTemplateBuilder.Append(@""">{{Title}}</a> <span class='sfCount'>({{ItemsCount}})</span>");
            var tagFilterWidget = new DynamicCommandWidgetElement(tagFilterSection.Items)
            {
                Name = "TagFilter",
                CommandName = "filterByTag",
                PageSize = 10,
                WidgetType = typeof(DynamicCommandWidget),
                IsSeparator = false,
                BindTo = BindCommandListTo.Client,
                BaseServiceUrl = String.Format("~/Sitefinity/Services/Taxonomies/FlatTaxon.svc/{0}/", TaxonomyManager.TagsTaxonomyId),
                ResourceClassId = typeof(Labels).Name,
                MoreLinkText = "ShowMoreTags",
                MoreLinkCssClass = "sfShowMore",
                LessLinkText = "ShowLessTags",
                LessLinkCssClass = "sfShowMore",
                SelectedItemCssClass = "sfSel",
                ClientItemTemplate = clientTemplateBuilder.ToString()
            };
            tagFilterWidget.UrlParameters.Add("itemType", typeof(ProductItem).AssemblyQualifiedName);

            tagFilterSection.Items.Add(tagFilterWidget);


            DefinitionsHelper.CreateTaxonomyLink(
                TaxonomyManager.CategoriesTaxonomyId,
                DefinitionsHelper.HideSectionsExceptCommandName,
                DefinitionsHelper.ConstructDisplaySectionsCommandArgument(categoryFilterSection.WrapperTagId),
                sidebarSection);

            DefinitionsHelper.CreateTaxonomyLink(
                TaxonomyManager.TagsTaxonomyId,
                DefinitionsHelper.HideSectionsExceptCommandName,
                DefinitionsHelper.ConstructDisplaySectionsCommandArgument(tagFilterSection.WrapperTagId),
                sidebarSection);

            #region Filter by date

            var closeDateFilterWidget = (new CommandWidgetElement(dateFilterSection.Items)
            {
                Name = "CloseDateFilter",
                CommandName = DefinitionsHelper.ShowSectionsExceptCommandName,
                CommandArgument = DefinitionsHelper.ConstructDisplaySectionsCommandArgument(
                    tagFilterSection.WrapperTagId, categoryFilterSection.WrapperTagId, dateFilterSection.WrapperTagId),
                ButtonType = CommandButtonType.SimpleLinkButton,
                Text = "CloseDateFilter",
                ResourceClassId = typeof(ProductsResources).Name,
                CssClass = "sfCloseFilter",
                WidgetType = typeof(CommandWidget),
                IsSeparator = false
            });
            dateFilterSection.Items.Add(closeDateFilterWidget);

            var dateFilterWidget = new DateFilteringWidgetDefinitionElement(dateFilterSection.Items)
            {
                Name = "DateFilter",
                WidgetType = typeof(DateFilteringWidget),
                IsSeparator = false,
                PropertyNameToFilter = "LastModified"
            };

            DefinitionsHelper.GetPredefinedDateFilteringRanges(dateFilterWidget.PredefinedFilteringRanges);

            dateFilterSection.Items.Add(dateFilterWidget);

            sidebarSection.Items.Add(new CommandWidgetElement(sidebarSection.Items)
            {
                Name = "FilterByDate",
                CommandName = DefinitionsHelper.HideSectionsExceptCommandName,
                CommandArgument = DefinitionsHelper.ConstructDisplaySectionsCommandArgument(dateFilterSection.WrapperTagId),
                ButtonType = CommandButtonType.SimpleLinkButton,
                Text = "ByDateModified",
                ResourceClassId = typeof(ProductsResources).Name,
                WidgetType = typeof(CommandWidget),
                IsSeparator = false
            });

            #endregion Filter by date

            WidgetBarSectionElement manageAlso = new WidgetBarSectionElement(productsGridView.SidebarConfig.Sections)
            {
                Name = "ManageAlso",
                Title = "ManageAlso",
                ResourceClassId = typeof(ProductsResources).Name,
                CssClass = "sfWidgetsList sfSeparator",
                WrapperTagId = "manageAlsoSection"
            };

            CommandWidgetElement productsComments = new CommandWidgetElement(manageAlso.Items)
            {
                Name = "productsComments",
                CommandName = DefinitionsHelper.CommentsCommandName,
                ButtonType = CommandButtonType.SimpleLinkButton,
                Text = "CommentsForProducts",
                ResourceClassId = typeof(ProductsResources).Name,
                CssClass = "sfComments",
                WidgetType = typeof(CommandWidget),
                IsSeparator = false
            };
            manageAlso.Items.Add(productsComments);

            WidgetBarSectionElement settings = new WidgetBarSectionElement(productsGridView.SidebarConfig.Sections)
            {
                Name = "Settings",
                Title = "Settings",
                ResourceClassId = typeof(ProductsResources).Name,
                CssClass = "sfWidgetsList sfSettings",
                WrapperTagId = "settingsSection"
            };

            CommandWidgetElement productsPermissions = new CommandWidgetElement(settings.Items)
            {
                Name = "productsPermissions",
                CommandName = DefinitionsHelper.PermissionsCommandName,
                ButtonType = CommandButtonType.SimpleLinkButton,
                Text = "PermissionsForProducts",
                ResourceClassId = typeof(ProductsResources).Name,
                WidgetType = typeof(CommandWidget),
                IsSeparator = false
            };
            settings.Items.Add(productsPermissions);

            CommandWidgetElement newsCustomFields = new CommandWidgetElement(settings.Items)
            {
                Name = "ProductsCustomFields",
                CommandName = DefinitionsHelper.ModuleEditor,
                ButtonType = CommandButtonType.SimpleLinkButton,
                Text = "CustomFields",
                ResourceClassId = typeof(ProductsResources).Name,
                WidgetType = typeof(CommandWidget),
                IsSeparator = false
            };
            settings.Items.Add(newsCustomFields);

            CommandWidgetElement productsSettings = new CommandWidgetElement(settings.Items)
            {
                Name = "productsSettings",
                CommandName = DefinitionsHelper.SettingsCommandName,
                ButtonType = CommandButtonType.SimpleLinkButton,
                Text = "SettingsForProducts",
                ResourceClassId = typeof(ProductsResources).Name,
                WidgetType = typeof(CommandWidget),
                IsSeparator = false
            };
            settings.Items.Add(productsSettings);



            productsGridView.SidebarConfig.Title = "ManageProducts";
            productsGridView.SidebarConfig.ResourceClassId = typeof(ProductsResources).Name;
            productsGridView.SidebarConfig.Sections.Add(languagesSection);
            productsGridView.SidebarConfig.Sections.Add(sidebarSection);
            productsGridView.SidebarConfig.Sections.Add(manageAlso);
            productsGridView.SidebarConfig.Sections.Add(settings);

            #endregion

            #region ContextBar definition

            var translationsContextBarSection = new LocalizationWidgetBarSectionElement(productsGridView.ContextBarConfig.Sections)
            {
                Name = "Languages",
                WrapperTagKey = HtmlTextWriterTag.Div,
                CssClass = "sfContextWidgetWrp",
                MinLanguagesCountTreshold = DefinitionsHelper.LanguageItemsPerRow
            };

            translationsContextBarSection.Items.Add(new CommandWidgetElement(translationsContextBarSection.Items)
            {
                Name = "ShowMoreTranslations",
                CommandName = DefinitionsHelper.ShowMoreTranslationsCommandName,
                ButtonType = CommandButtonType.SimpleLinkButton,
                Text = "ShowAllTranslations",
                ResourceClassId = typeof(LocalizationResources).Name,
                WidgetType = typeof(CommandWidget),
                IsSeparator = false,
                CssClass = "sfShowHideLangVersions",
                WrapperTagKey = HtmlTextWriterTag.Div
            });

            translationsContextBarSection.Items.Add(new CommandWidgetElement(translationsContextBarSection.Items)
            {
                Name = "HideMoreTranslations",
                CommandName = DefinitionsHelper.HideMoreTranslationsCommandName,
                ButtonType = CommandButtonType.SimpleLinkButton,
                Text = "ShowBasicTranslationsOnly",
                ResourceClassId = typeof(LocalizationResources).Name,
                WidgetType = typeof(CommandWidget),
                IsSeparator = false,
                CssClass = "sfDisplayNone sfShowHideLangVersions",
                WrapperTagKey = HtmlTextWriterTag.Div
            });

            productsGridView.ContextBarConfig.Sections.Add(translationsContextBarSection);

            #endregion

            #region Grid View Mode

            var gridMode = new GridViewModeElement(productsGridView.ViewModesConfig)
            {
                Name = "Grid"
            };
            productsGridView.ViewModesConfig.Add(gridMode);

            DataColumnElement titleColumn = new DataColumnElement(gridMode.ColumnsConfig)
            {
                Name = "Title",
                HeaderText = Res.Get<Labels>().Title,
                HeaderCssClass = "sfTitleCol",
                ItemCssClass = "sfTitleCol",
                ClientTemplate = @"<a sys:href='javascript:void(0);' sys:class=""{{ 'sf_binderCommand_edit sfItemTitle sf' + UIStatus.toLowerCase()}}"">
                    <strong>{{Title}}</strong>
                    <span class='sfStatusLocation'>{{Status}}</span></a>"
            };
            gridMode.ColumnsConfig.Add(titleColumn);

            DataColumnElement qtyColumn = new DataColumnElement(gridMode.ColumnsConfig)
            {
                Name = "QuantityInStock",
                HeaderText = "QuantityInStock",
                ResourceClassId = typeof(ProductsResources).Name,
                ClientTemplate = "<span>{{QuantityInStock}}</span>",
                HeaderCssClass = "sfRegular",
                ItemCssClass = "sfRegular"
            };
            gridMode.ColumnsConfig.Add(qtyColumn);

            DataColumnElement priceColumn = new DataColumnElement(gridMode.ColumnsConfig)
            {
                Name = "Price",
                HeaderText = "Price",
                ResourceClassId = typeof(ProductsResources).Name,
                ClientTemplate = "<span>{{Price}}</span>",
                HeaderCssClass = "sfRegular",
                ItemCssClass = "sfRegular"
            };
            gridMode.ColumnsConfig.Add(priceColumn);


            var translationsColumn = new DynamicColumnElement(gridMode.ColumnsConfig)
            {
                Name = "Translations",
                HeaderText = "Translations",
                ResourceClassId = typeof(LocalizationResources).Name,
                DynamicMarkupGenerator = typeof(LanguagesColumnMarkupGenerator),
                ItemCssClass = "sfLanguagesCol",
                HeaderCssClass = "sfLanguagesCol"
            };
            translationsColumn.GeneratorSettingsElement = new LanguagesColumnMarkupGeneratorElement(translationsColumn)
            {
                LanguageSource = LanguageSource.Frontend,
                ItemsInGroupCount = DefinitionsHelper.LanguageItemsPerRow,
                ContainerTag = "div",
                GroupTag = "div",
                ItemTag = "div",
                ContainerClass = string.Empty,
                GroupClass = string.Empty,
                ItemClass = string.Empty
            };
            gridMode.ColumnsConfig.Add(translationsColumn);

            ActionMenuColumnElement actionsColumn = new ActionMenuColumnElement(gridMode.ColumnsConfig)
            {
                Name = "Actions",
                HeaderText = Res.Get<Labels>().Actions,
                HeaderCssClass = "sfMoreActions",
                ItemCssClass = "sfMoreActions"
            };
            FillActionMenuItems(actionsColumn.MenuItems, actionsColumn, typeof(ProductsResources).Name);
            gridMode.ColumnsConfig.Add(actionsColumn);

            DataColumnElement authorColumn = new DataColumnElement(gridMode.ColumnsConfig)
            {
                Name = "Author",
                HeaderText = Res.Get<Labels>().Author,
                ClientTemplate = "<span>{{Author}}</span>",
                HeaderCssClass = "sfRegular",
                ItemCssClass = "sfRegular"
            };
            gridMode.ColumnsConfig.Add(authorColumn);

            DataColumnElement dateColumn = new DataColumnElement(gridMode.ColumnsConfig)
            {
                Name = "Date",
                HeaderText = Res.Get<Labels>().Date,
                ClientTemplate = "<span>{{ (DateCreated) ? DateCreated.sitefinityLocaleFormat('dd MMM, yyyy hh:mm:ss'): '-' }}</span>",
                HeaderCssClass = "sfDate",
                ItemCssClass = "sfDate"
            };
            gridMode.ColumnsConfig.Add(dateColumn);

            #endregion

            #region DecisionScreens definition

            DecisionScreenElement dsElement = new DecisionScreenElement(productsGridView.DecisionScreensConfig)
            {
                Name = "NoItemsExistScreen",
                DecisionType = DecisionType.NoItemsExist,
                MessageType = MessageType.Neutral,
                Displayed = false,
                Title = "WhatDoYouWantToDoNow",
                MessageText = "NoProductItems",
                ResourceClassId = typeof(ProductsResources).Name
            };

            CommandWidgetElement actionCreateNew = new CommandWidgetElement(dsElement.Actions)
            {
                Name = "Create",
                ButtonType = CommandButtonType.Create,
                CommandName = DefinitionsHelper.CreateCommandName,
                Text = "CreateItem",
                ResourceClassId = typeof(ProductsResources).Name,
                CssClass = "sfCreateItem",
                PermissionSet = ProductsConstants.Security.PermissionSetName,
                ActionName = ProductsConstants.Security.Create
            };
            dsElement.Actions.Add(actionCreateNew);

            productsGridView.DecisionScreensConfig.Add(dsElement);

            #endregion

            #region Dialogs definition

            var parameters = string.Concat(
                "?ControlDefinitionName=",
                ProductsDefinitions.BackendDefinitionName,
                "&ViewName=",
                ProductsDefinitions.BackendInsertViewName);
            DialogElement createDialogElement = DefinitionsHelper.CreateDialogElement(
                productsGridView.DialogsConfig,
                DefinitionsHelper.CreateCommandName,
                "ContentViewInsertDialog",
                parameters);
            productsGridView.DialogsConfig.Add(createDialogElement);

            parameters = string.Concat(
                "?ControlDefinitionName=",
                ProductsDefinitions.BackendDefinitionName,
                "&ViewName=",
                ProductsDefinitions.BackendEditViewName);
            DialogElement editDialogElement = DefinitionsHelper.CreateDialogElement(
                productsGridView.DialogsConfig,
                DefinitionsHelper.EditCommandName,
                "ContentViewEditDialog",
                parameters);
            productsGridView.DialogsConfig.Add(editDialogElement);

            parameters = string.Concat(
                "?ControlDefinitionName=",
                ProductsDefinitions.BackendDefinitionName,
                "&ViewName=",
                ProductsDefinitions.BackendPreviewViewName,
                "&backLabelText=", Res.Get<ProductsResources>().BackToItems, "&SuppressBackToButtonLabelModify=true");
            DialogElement previewDialogElement = DefinitionsHelper.CreateDialogElement(
                productsGridView.DialogsConfig,
                DefinitionsHelper.PreviewCommandName,
                "ContentViewEditDialog",
                parameters);
            productsGridView.DialogsConfig.Add(previewDialogElement);

            string permissionsParams = string.Concat(
                "?moduleName=", ProductsModule.ModuleName,
                "&typeName=", typeof(ProductItem).AssemblyQualifiedName,
                "&backLabelText=", Res.Get<ProductsResources>().BackToItems,
                "&title=", Res.Get<ProductsResources>().PermissionsForProducts);
            DialogElement permissionsDialogElement = DefinitionsHelper.CreateDialogElement(
                productsGridView.DialogsConfig,
                DefinitionsHelper.PermissionsCommandName,
                "ModulePermissionsDialog",
                permissionsParams);
            productsGridView.DialogsConfig.Add(permissionsDialogElement);

            string versioningParams = string.Concat(
                "?ControlDefinitionName=",
                ProductsDefinitions.BackendDefinitionName,
                "&moduleName=", ProductsModule.ModuleName,
                "&typeName=", typeof(ProductItem).AssemblyQualifiedName,
                "&title=", Res.Get<ProductsResources>().PermissionsForProducts,
                "&backLabelText=", Res.Get<ProductsResources>().BackToItems,
                "&" + ProductsDefinitions.ComparisonViewHistoryScreenQueryParameter + "=" + ProductsDefinitions.BackendVersionComapreViewName);

            DialogElement versioningDialogElement = DefinitionsHelper.CreateDialogElement(
                productsGridView.DialogsConfig,
                DefinitionsHelper.HistoryCommandName,
                "VersionHistoryDialog",
                versioningParams);
            productsGridView.DialogsConfig.Add(versioningDialogElement);

            string versioningGridParams = string.Concat(
               "?ControlDefinitionName=",
               ProductsDefinitions.BackendDefinitionName,
               "&moduleName=", ProductsModule.ModuleName,
               "&typeName=", typeof(ProductItem).AssemblyQualifiedName,
               "&title=", Res.Get<ProductsResources>().PermissionsForProducts,
               "&backLabelText=", Res.Get<ProductsResources>().BackToItems,
               "&" + ProductsDefinitions.ComparisonViewHistoryScreenQueryParameter + "=" + ProductsDefinitions.BackendVersionComapreViewName);

            DialogElement versioningGridDialogElement = DefinitionsHelper.CreateDialogElement(
                productsGridView.DialogsConfig,
                ProductsDefinitions.HistoryGridCommandName,
                "VersionHistoryDialog",
                versioningGridParams);
            productsGridView.DialogsConfig.Add(versioningGridDialogElement);

            parameters = string.Concat(
               "?ControlDefinitionName=",
               ProductsDefinitions.BackendDefinitionName,
               "&ViewName=",
               ProductsDefinitions.BackendVersionPreviewViewName, "&backLabelText=", Res.Get<Labels>().BackToRevisionHistory, "&SuppressBackToButtonLabelModify=true");
            DialogElement previewVersionDialogElement = DefinitionsHelper.CreateDialogElement(
                productsGridView.DialogsConfig,
                DefinitionsHelper.VersionPreviewCommandName,
                "ContentViewEditDialog",
                parameters);
            productsGridView.DialogsConfig.Add(previewVersionDialogElement);


            parameters = string.Concat("?TypeName=ProductCatalogSample.Model.ProductItem&Title=", "Product Fields", "&BackLabelText=", Res.Get<ProductsResources>().BackToItems, "&ItemsName=", "Products");
            DialogElement moduleEditorDialogElement = DefinitionsHelper.CreateDialogElement(
                productsGridView.DialogsConfig,
                DefinitionsHelper.ModuleEditor,
                "ModuleEditorDialog",
                parameters);
            productsGridView.DialogsConfig.Add(moduleEditorDialogElement);
            #endregion

            #region Links definition

            productsGridView.LinksConfig.Add(new LinkElement(productsGridView.LinksConfig)
            {
                Name = "viewComments",
                CommandName = DefinitionsHelper.CommentsCommandName,
                NavigateUrl = RouteHelper.CreateNodeReference(ProductsModule.CommentsPageId)
            });

            productsGridView.LinksConfig.Add(new LinkElement(productsGridView.LinksConfig)
            {
                Name = "viewSettings",
                CommandName = DefinitionsHelper.SettingsCommandName,
                NavigateUrl = RouteHelper.CreateNodeReference(SiteInitializer.AdvancedSettingsNodeId) + "/products"
            });

            DefinitionsHelper.CreateNotImplementedLink(productsGridView);

            #endregion

            backendContentView.ViewsConfig.Add(productsGridView);

            #endregion

            #region products backend details view

            var productsEditDetailView = new DetailFormViewElement(backendContentView.ViewsConfig)
            {
                Title = "EditItem",
                ViewName = ProductsDefinitions.BackendEditViewName,
                ViewType = typeof(DetailFormView),
                ShowSections = true,
                DisplayMode = FieldDisplayMode.Write,
                ShowTopToolbar = true,
                ResourceClassId = typeof(ProductsResources).Name,
                WebServiceBaseUrl = "~/Sitefinity/Services/Content/Products.svc/",
                IsToRenderTranslationView = true
            };

            backendContentView.ViewsConfig.Add(productsEditDetailView);

            #region Versioning Comparison Screen

            var versionComparisonView = new ComparisonViewElement(backendContentView.ViewsConfig)
            {
                Title = "VersionComparison",
                ViewName = ProductsDefinitions.BackendVersionComapreViewName,
                ViewType = typeof(VersionComparisonView),
                DisplayMode = FieldDisplayMode.Read,
                ResourceClassId = typeof(ProductsResources).Name,
                UseWorkflow = false
            };

            backendContentView.ViewsConfig.Add(versionComparisonView);

            versionComparisonView.Fields.Add(new ComparisonFieldElement(versionComparisonView.Fields) { FieldName = "Title", Title = "lTitle", ResourceClassId = typeof(ProductsResources).Name });
            versionComparisonView.Fields.Add(new ComparisonFieldElement(versionComparisonView.Fields) { FieldName = "Content", Title = "Content", ResourceClassId = typeof(ProductsResources).Name });
            versionComparisonView.Fields.Add(new ComparisonFieldElement(versionComparisonView.Fields) { FieldName = "WhatIsInTheBox", Title = "WhatIsInTheBox", ResourceClassId = typeof(ProductsResources).Name });
            versionComparisonView.Fields.Add(new ComparisonFieldElement(versionComparisonView.Fields) { FieldName = "Price", Title = "Price", ResourceClassId = typeof(ProductsResources).Name });
            versionComparisonView.Fields.Add(new ComparisonFieldElement(versionComparisonView.Fields) { FieldName = "QuantityInStock", Title = "QuantityInStock", ResourceClassId = typeof(ProductsResources).Name });

            versionComparisonView.Fields.Add(new ComparisonFieldElement(versionComparisonView.Fields) { FieldName = "Category", Title = "Category", ResourceClassId = typeof(ProductsResources).Name });
            versionComparisonView.Fields.Add(new ComparisonFieldElement(versionComparisonView.Fields) { FieldName = "Tags", Title = "Tags", ResourceClassId = typeof(ProductsResources).Name });

            versionComparisonView.Fields.Add(new ComparisonFieldElement(versionComparisonView.Fields) { FieldName = "UrlName", Title = "UrlName", ResourceClassId = typeof(ProductsResources).Name });

            #endregion

            var productsInsertDetailView = new DetailFormViewElement(backendContentView.ViewsConfig)
            {
                Title = "CreateNewItem",
                ViewName = ProductsDefinitions.BackendInsertViewName,
                ViewType = typeof(DetailFormView),
                ShowSections = true,
                DisplayMode = FieldDisplayMode.Write,
                ShowTopToolbar = true,
                ResourceClassId = typeof(ProductsResources).Name,
                WebServiceBaseUrl = "~/Sitefinity/Services/Content/Products.svc/",
                IsToRenderTranslationView = false
            };

            backendContentView.ViewsConfig.Add(productsInsertDetailView);

            var previewExternalScripts = DefinitionsHelper.GetExtenalClientScripts(
                "Telerik.Sitefinity.Versioning.Web.UI.Scripts.VersionHistoryExtender.js, Telerik.Sitefinity",
                "OnDetailViewLoaded");

            var productsPreviewDetailView = new DetailFormViewElement(backendContentView.ViewsConfig)
            {
                ViewName = ProductsDefinitions.BackendPreviewViewName,
                ViewType = typeof(DetailFormView),
                ShowSections = true,
                DisplayMode = FieldDisplayMode.Read,
                ShowTopToolbar = true,
                ResourceClassId = typeof(ProductsResources).Name,
                ShowNavigation = false,
                WebServiceBaseUrl = "~/Sitefinity/Services/Content/Products.svc/",
                UseWorkflow = false,
                ExternalClientScripts = previewExternalScripts
            };

            backendContentView.ViewsConfig.Add(productsPreviewDetailView);

            #region products backend forms definition

            #region Insert Form

            ProductsDefinitions.CreateBackendSections(productsInsertDetailView, FieldDisplayMode.Write);
            ProductsDefinitions.CreateBackendFormToolbar(productsInsertDetailView, typeof(ProductsResources).Name, true);

            #endregion

            #region Edit Form

            ProductsDefinitions.CreateBackendSections(productsEditDetailView, FieldDisplayMode.Write);
            ProductsDefinitions.CreateBackendFormToolbar(productsEditDetailView, typeof(ProductsResources).Name, false);

            #endregion

            #region Preview History Form

            var previewLocalization = new Dictionary<string, string>()
            {
                { "ItemVersionOfClientTemplate", Res.Get<VersionResources>().ItemVersionOfClientTemplate },
                { "PreviouslyPublished", Res.Get<VersionResources>().PreviouslyPublishedBrackets },
                { "CannotDeleteLastPublishedVersion", Res.Get<VersionResources>().CannotDeleteLastPublishedVersion }
            };
            //var previewExternalScripts = DefinitionsHelper.GetExtenalClientScripts(
            //    "Telerik.Sitefinity.Versioning.Web.UI.Scripts.VersionHistoryExtender.js, Telerik.Sitefinity",
            //    "OnDetailViewLoaded");

            var productsHistoryPreviewDetailView = new DetailFormViewElement(backendContentView.ViewsConfig)
            {
                Title = "EditItem",
                ViewName = ProductsDefinitions.BackendVersionPreviewViewName,
                ViewType = typeof(DetailFormView),
                ShowSections = true,
                DisplayMode = FieldDisplayMode.Read,
                ShowTopToolbar = false,
                ResourceClassId = typeof(ProductsResources).Name,
                ExternalClientScripts = previewExternalScripts,
                WebServiceBaseUrl = "~/Sitefinity/Services/Content/Products.svc/",
                ShowNavigation = true,
                Localization = previewLocalization,
                UseWorkflow = false
            };

            CreateHistoryPreviewToolbar(productsHistoryPreviewDetailView);

            backendContentView.ViewsConfig.Add(productsHistoryPreviewDetailView);

            ProductsDefinitions.CreateBackendSections(productsHistoryPreviewDetailView, FieldDisplayMode.Read);

            #endregion

            #region Preview Form
            ProductsDefinitions.CreateBackendSections(productsPreviewDetailView, FieldDisplayMode.Read);
            //TODO: add the preview screen toolbar widgets -->Edit,etc...

            #endregion

            #endregion

            #endregion

            return backendContentView;

        }
Exemple #3
0
        /// <summary>
        /// Defines the jobs backend content view.
        /// </summary>
        /// <param name="parent">The parent.</param>
        /// <returns></returns>
        public static ContentViewControlElement DefineJobsBackendContentView(ConfigElement parent)
        {
            // define content view control
            var backendContentView = new ContentViewControlElement(parent)
            {
                ControlDefinitionName = BackendDefinitionName,
                ContentType           = typeof(JobApplication)
            };

            // define views
            var jobsGridView = new MasterGridViewElement(backendContentView.ViewsConfig)
            {
                ViewName          = JobsDefinitions.BackendListViewName,
                ViewType          = typeof(MasterGridView),
                AllowPaging       = true,
                DisplayMode       = FieldDisplayMode.Read,
                ItemsPerPage      = 50,
                ResourceClassId   = typeof(JobsResources).Name,
                Title             = "JobsViewTitle",
                WebServiceBaseUrl = "~/Sitefinity/Services/Content/Jobs.svc/",
            };

            // define columns
            var gridMode = new GridViewModeElement(jobsGridView.ViewModesConfig)
            {
                Name = "Grid",
            };

            jobsGridView.ViewModesConfig.Add(gridMode);

            DataColumnElement firstNameColumn = new DataColumnElement(gridMode.ColumnsConfig)
            {
                Name           = "FirstName",
                HeaderText     = Res.Get <JobsResources>().FirstName,
                ClientTemplate = "<span>{{FirstName}}</span>",
                HeaderCssClass = "sfRegular",
                ItemCssClass   = "sfRegular"
            };

            gridMode.ColumnsConfig.Add(firstNameColumn);

            DataColumnElement lastNameColumn = new DataColumnElement(gridMode.ColumnsConfig)
            {
                Name           = "LastName",
                HeaderText     = Res.Get <JobsResources>().LastName,
                ClientTemplate = "<span>{{LastName}}</span>",
                HeaderCssClass = "sfRegular",
                ItemCssClass   = "sfRegular"
            };

            gridMode.ColumnsConfig.Add(lastNameColumn);

            DataColumnElement phoneColumn = new DataColumnElement(gridMode.ColumnsConfig)
            {
                Name           = "Phone",
                HeaderText     = Res.Get <JobsResources>().PhoneNumber,
                ClientTemplate = "<span>{{Phone}}</span>",
                HeaderCssClass = "sfRegular",
                ItemCssClass   = "sfRegular"
            };

            gridMode.ColumnsConfig.Add(phoneColumn);

            DataColumnElement refferalColumn = new DataColumnElement(gridMode.ColumnsConfig)
            {
                Name           = "Refferal",
                HeaderText     = Res.Get <JobsResources>().Referrer,
                ClientTemplate = "<span>{{Referral}}</span>",
                HeaderCssClass = "sfRegular",
                ItemCssClass   = "sfRegular"
            };

            gridMode.ColumnsConfig.Add(refferalColumn);

            ActionMenuColumnElement actionsColumn = new ActionMenuColumnElement(gridMode.ColumnsConfig)
            {
                Name           = "Actions",
                HeaderText     = Res.Get <Labels>().Actions,
                HeaderCssClass = "sfMoreActions",
                ItemCssClass   = "sfMoreActions"
            };

            FillActionMenuItems(actionsColumn.MenuItems, actionsColumn, typeof(JobsResources).Name);
            gridMode.ColumnsConfig.Add(actionsColumn);

            DataColumnElement authorColumn = new DataColumnElement(gridMode.ColumnsConfig)
            {
                Name           = "Author",
                HeaderText     = Res.Get <Labels>().Author,
                ClientTemplate = "<span>{{Author}}</span>",
                HeaderCssClass = "sfRegular",
                ItemCssClass   = "sfRegular"
            };

            gridMode.ColumnsConfig.Add(authorColumn);

            DataColumnElement dateColumn = new DataColumnElement(gridMode.ColumnsConfig)
            {
                Name           = "Date",
                HeaderText     = Res.Get <Labels>().Date,
                ClientTemplate = "<span>{{ (DateCreated) ? DateCreated.sitefinityLocaleFormat('dd MMM, yyyy hh:mm:ss'): '-' }}</span>",
                HeaderCssClass = "sfDate",
                ItemCssClass   = "sfDate"
            };

            gridMode.ColumnsConfig.Add(dateColumn);

            backendContentView.ViewsConfig.Add(jobsGridView);

            var parameters = string.Concat(
                "?ControlDefinitionName=",
                JobsDefinitions.BackendDefinitionName,
                "&ViewName=",
                JobsDefinitions.BackendEditViewName);
            DialogElement editDialogElement = DefinitionsHelper.CreateDialogElement(
                jobsGridView.DialogsConfig,
                DefinitionsHelper.EditCommandName,
                "ContentViewEditDialog",
                parameters);

            jobsGridView.DialogsConfig.Add(editDialogElement);

            var jobsEditDetailView = new DetailFormViewElement(backendContentView.ViewsConfig)
            {
                Title                     = "EditItem",
                ViewName                  = JobsDefinitions.BackendEditViewName,
                ViewType                  = typeof(DetailFormView),
                ShowSections              = true,
                DisplayMode               = FieldDisplayMode.Write,
                ShowTopToolbar            = true,
                ResourceClassId           = typeof(JobsResources).Name,
                WebServiceBaseUrl         = "~/Sitefinity/Services/Content/Jobs.svc/",
                IsToRenderTranslationView = false,
                UseWorkflow               = false
            };

            backendContentView.ViewsConfig.Add(jobsEditDetailView);

            JobsDefinitions.CreateBackendSections(jobsEditDetailView, FieldDisplayMode.Write);
            JobsDefinitions.CreateBackendFormToolbar(jobsEditDetailView, typeof(JobsResources).Name, false);

            return(backendContentView);
        }
        private static IChart ChartHasDataTable() {
            var chart = (GanttChart)ChartWithScrolling();

            chart.Caption = "Chart with DataTable";
            chart.DataTable.HeaderAttr.VAlign = FusionVerticalAlign.Bottom;

            var dataColumn = new DataColumnElement
                             {
                                 HeaderText = "Worker"
                             };
            dataColumn.HeaderAttr.FontAttr.Font = "맑은 고딕";
            dataColumn.HeaderAttr.FontAttr.FontColor = Color.DarkSlateGray;
            dataColumn.HeaderAttr.FontAttr.FontSize = 18.ToString();
            dataColumn.HeaderAttr.VAlign = FusionVerticalAlign.Bottom;
            dataColumn.HeaderAttr.Align = FusionTextAlign.Right;
            dataColumn.ItemAttr.Align = FusionTextAlign.Left;
            dataColumn.ItemAttr.FontAttr.FontSize = 12.ToString();

            foreach(var worker in RoleNames) {
                var text = new DataColumnTextElement { Label = worker };
                text.ItemAttr.FontAttr.Font = "맑은 고딕";
                text.ItemAttr.FontAttr.FontSize = "12";
                text.ItemAttr.Align = FusionTextAlign.Center;
                // mailto 는 javascript로 처리할 수 없다...
                // text.Link.Javascript = "mailto:[email protected]";
                // dataColumn.TextElements.Add(text);
                dataColumn.Add(text);
            }

            // chart.DataTable.DataColumnElements.Add(dataColumn);
            chart.DataTable.Add(dataColumn);

            return chart;
        }
Exemple #5
0
        public void ChartHasDataTable() {
            var chart = CreateSampleChart("Chart with DataTable");

            chart.DataTable.HeaderAttr.VAlign = FusionVerticalAlign.Bottom;

            var dataColumn = new DataColumnElement
                             {
                                 HeaderText = "작업자"
                             };
            dataColumn.HeaderAttr.FontAttr.FontSize = 18.ToString();
            dataColumn.HeaderAttr.VAlign = FusionVerticalAlign.Bottom;
            dataColumn.HeaderAttr.Align = FusionTextAlign.Right;
            dataColumn.ItemAttr.Align = FusionTextAlign.Left;
            dataColumn.ItemAttr.FontAttr.FontSize = 12.ToString();

            foreach(var worker in RoleNames) {
                var text = new DataColumnTextElement { Label = worker };
                text.Link.Url = "mailto:[email protected]";
                // dataColumn.TextElements.Add(text);
                dataColumn.Add(text);
            }

            // chart.DataTable.DataColumnElements.Add(dataColumn);
            chart.DataTable.Add(dataColumn);


            ValidateChartXml(chart);
        }
		/// <summary>
		/// Defines the locations backend content view (control panel and views).
		/// </summary>
		/// <param name="parent">The parent element hosting the backend content view.</param>
		/// <returns></returns>
		public static ContentViewControlElement DefineLocationsBackendContentView(ConfigElement parent)
		{
			// initialize the content view; this is the element that will be returned to the page and holds all views of the admin panel
			var backendContentView = new ContentViewControlElement(parent)
			{
				ControlDefinitionName = BackendDefinitionName,
				ContentType = typeof(LocationItem),
				UseWorkflow = false
			};

			// GridView element serves as the "List View" for the item list. Grid columns are defined later
			var locationsGridView = new MasterGridViewElement(backendContentView.ViewsConfig)
			{
				ViewName = LocationsDefinitions.BackendListViewName,
				ViewType = typeof(MasterGridView),
				AllowPaging = true,
				DisplayMode = FieldDisplayMode.Read,
				ItemsPerPage = 50,
				SearchFields = "Title",
				SortExpression = "Title ASC",
				Title = "Locations",
				WebServiceBaseUrl = "~/Sitefinity/Services/Content/Locations.svc/"
			};
			backendContentView.ViewsConfig.Add(locationsGridView);

			#region Module Main Toolbar definition

			// Toolbar is the top menu with action buttons such as Create, Delete, Search, etc.
			var masterViewToolbarSection = new WidgetBarSectionElement(locationsGridView.ToolbarConfig.Sections)
			{
				Name = "Toolbar"
			};

			// "Create" Button for Toolbar
			var createLocationsWidget = new CommandWidgetElement(masterViewToolbarSection.Items)
			{
				Name = "CreateLocationsCommandWidget",
				ButtonType = CommandButtonType.Create,
				CommandName = DefinitionsHelper.CreateCommandName,
				Text = "Create Location",
				CssClass = "sfMainAction",
				WidgetType = typeof(CommandWidget)
			};
			masterViewToolbarSection.Items.Add(createLocationsWidget);

			// "Delete" button for Toolbar
			var deleteLocationsWidget = new CommandWidgetElement(masterViewToolbarSection.Items)
			{
				Name = "DeleteLocationsCommandWidget",
				ButtonType = CommandButtonType.Standard,
				CommandName = DefinitionsHelper.GroupDeleteCommandName,
				Text = "Delete",
				WidgetType = typeof(CommandWidget),
				CssClass = "sfGroupBtn"
			};
			masterViewToolbarSection.Items.Add(deleteLocationsWidget);

			// "Search" button for toolbar
			masterViewToolbarSection.Items.Add(DefinitionsHelper.CreateSearchButtonWidget(masterViewToolbarSection.Items, typeof(LocationItem)));
			locationsGridView.ToolbarConfig.Sections.Add(masterViewToolbarSection);

			#endregion

			#region Locations Grid (List View)

			// Define GridView mode
			var gridMode = new GridViewModeElement(locationsGridView.ViewModesConfig)
			{
				Name = "Grid"
			};
			locationsGridView.ViewModesConfig.Add(gridMode);

			#region Locations Grid Columns

			// Title column
			DataColumnElement titleColumn = new DataColumnElement(gridMode.ColumnsConfig)
			{
				Name = "Title",
				HeaderText = "Title",
				HeaderCssClass = "sfTitleCol",
				ItemCssClass = "sfTitleCol",
				ClientTemplate = @"<a sys:href='javascript:void(0);' sys:class=""{{ 'sf_binderCommand_edit sfItemTitle sfpublished"">
					<strong>{{Title}}</strong></a>"
			};
			gridMode.ColumnsConfig.Add(titleColumn);

			ActionMenuColumnElement actionsColumn = new ActionMenuColumnElement(gridMode.ColumnsConfig)
			{
				Name = "Actions",
				HeaderText = "Actions",
				HeaderCssClass = "sfMoreActions",
				ItemCssClass = "sfMoreActions"
			};
			actionsColumn.MenuItems.Add(DefinitionsHelper.CreateActionMenuCommand(actionsColumn.MenuItems, "View", HtmlTextWriterTag.Li, "preview", "View", string.Empty));
			actionsColumn.MenuItems.Add(DefinitionsHelper.CreateActionMenuCommand(actionsColumn.MenuItems, "Delete", HtmlTextWriterTag.Li, "delete", "Delete", string.Empty));

			gridMode.ColumnsConfig.Add(actionsColumn);

			#endregion

			#endregion

			#region Dialog Window definitions

			#region Insert Item Dialog

			// Insert Item Parameters
			var parameters = string.Concat(
				"?ControlDefinitionName=",
				LocationsDefinitions.BackendDefinitionName,
				"&ViewName=",
				LocationsDefinitions.BackendInsertViewName);

			// Insert Item Dialog
			DialogElement createDialogElement = DefinitionsHelper.CreateDialogElement(
				locationsGridView.DialogsConfig,
				DefinitionsHelper.CreateCommandName,
				"ContentViewInsertDialog",
				parameters);

			// add dialog to Backend
			locationsGridView.DialogsConfig.Add(createDialogElement);

			#endregion

			#region Edit Item Dialog

			// "Edit Item" Parameters
			parameters = string.Concat(
				"?ControlDefinitionName=",
				LocationsDefinitions.BackendDefinitionName,
				"&ViewName=",
				LocationsDefinitions.BackendEditViewName);

			// "Edit Item" Dialog
			DialogElement editDialogElement = DefinitionsHelper.CreateDialogElement(
				locationsGridView.DialogsConfig,
				DefinitionsHelper.EditCommandName,
				"ContentViewEditDialog",
				parameters);

			// Add Dialog to Backend
			locationsGridView.DialogsConfig.Add(editDialogElement);

			#endregion

			#region Preview Item Dialog

			// "Preview Item" parameters
			parameters = string.Concat(
				"?ControlDefinitionName=",
				LocationsDefinitions.BackendDefinitionName,
				"&ViewName=",
				LocationsDefinitions.BackendPreviewName,
				"&backLabelText=", "BacktoItems", "&SuppressBackToButtonLabelModify=true");

			// Preview Item Dialog
			DialogElement previewDialogElement = DefinitionsHelper.CreateDialogElement(
				locationsGridView.DialogsConfig,
				DefinitionsHelper.PreviewCommandName,
				"ContentViewEditDialog",
				parameters);

			// Add Dialog to Backend
			locationsGridView.DialogsConfig.Add(previewDialogElement);

			#endregion

			#endregion

			#region Admin Forms Views

			#region Create Item Form View

			// bind create item view to web service
			var locationsInsertDetailView = new DetailFormViewElement(backendContentView.ViewsConfig)
			{
				Title = "Create Location",
				ViewName = LocationsDefinitions.BackendInsertViewName,
				ViewType = typeof(DetailFormView),
				ShowSections = true,
				DisplayMode = FieldDisplayMode.Write,
				ShowTopToolbar = true,
				WebServiceBaseUrl = "~/Sitefinity/Services/Content/locations.svc/",
				IsToRenderTranslationView = false,
				UseWorkflow = false
			};

			backendContentView.ViewsConfig.Add(locationsInsertDetailView);

			#endregion

			#region Edit Item Form View

			// bind Edit item form to web service
			var locationsEditDetailView = new DetailFormViewElement(backendContentView.ViewsConfig)
			{
				Title = "Edit Location",
				ViewName = LocationsDefinitions.BackendEditViewName,
				ViewType = typeof(DetailFormView),
				ShowSections = true,
				DisplayMode = FieldDisplayMode.Write,
				ShowTopToolbar = true,
				WebServiceBaseUrl = "~/Sitefinity/Services/Content/Locations.svc/",
				IsToRenderTranslationView = false,
				UseWorkflow = false
			};

			backendContentView.ViewsConfig.Add(locationsEditDetailView);

			#endregion

			#region Preview Item Form View

			// bind Preview Form to web service
			var locationsPreviewDetailView = new DetailFormViewElement(backendContentView.ViewsConfig)
			{
				Title = "Location Preview",
				ViewName = LocationsDefinitions.BackendPreviewName,
				ViewType = typeof(DetailFormView),
				ShowSections = true,
				DisplayMode = FieldDisplayMode.Read,
				ShowTopToolbar = true,
				ShowNavigation = true,
				WebServiceBaseUrl = "~/Sitefinity/Services/Content/Locations.svc/",
				UseWorkflow = false
			};

			backendContentView.ViewsConfig.Add(locationsPreviewDetailView);

			#endregion

			#endregion

			#region Locations Backend Forms Definition

			#region Insert Form

			LocationsDefinitions.CreateBackendSections(locationsInsertDetailView, FieldDisplayMode.Write);
			LocationsDefinitions.CreateBackendFormToolbar(locationsInsertDetailView, true, true);

			#endregion

			#region Edit Form

			LocationsDefinitions.CreateBackendSections(locationsEditDetailView, FieldDisplayMode.Write);
			LocationsDefinitions.CreateBackendFormToolbar(locationsEditDetailView, false, true);

			#endregion

			#region Preview Form

			CreateBackendSections(locationsPreviewDetailView, FieldDisplayMode.Read);

			#endregion

			#endregion

			return backendContentView;
		}
Exemple #7
0
        /// <summary>
        /// Defines the locations backend content view (control panel and views).
        /// </summary>
        /// <param name="parent">The parent element hosting the backend content view.</param>
        /// <returns></returns>
        public static ContentViewControlElement DefineLocationsBackendContentView(ConfigElement parent)
        {
            // initialize the content view; this is the element that will be returned to the page and holds all views of the admin panel
            var backendContentView = new ContentViewControlElement(parent)
            {
                ControlDefinitionName = BackendDefinitionName,
                ContentType           = typeof(LocationItem),
                UseWorkflow           = false
            };

            // GridView element serves as the "List View" for the item list. Grid columns are defined later
            var locationsGridView = new MasterGridViewElement(backendContentView.ViewsConfig)
            {
                ViewName          = LocationsDefinitions.BackendListViewName,
                ViewType          = typeof(MasterGridView),
                AllowPaging       = true,
                DisplayMode       = FieldDisplayMode.Read,
                ItemsPerPage      = 50,
                SearchFields      = "Title",
                SortExpression    = "Title ASC",
                Title             = "Locations",
                WebServiceBaseUrl = "~/Sitefinity/Services/Content/Locations.svc/"
            };

            backendContentView.ViewsConfig.Add(locationsGridView);

            #region Module Main Toolbar definition

            // Toolbar is the top menu with action buttons such as Create, Delete, Search, etc.
            var masterViewToolbarSection = new WidgetBarSectionElement(locationsGridView.ToolbarConfig.Sections)
            {
                Name = "Toolbar"
            };

            // "Create" Button for Toolbar
            var createLocationsWidget = new CommandWidgetElement(masterViewToolbarSection.Items)
            {
                Name        = "CreateLocationsCommandWidget",
                ButtonType  = CommandButtonType.Create,
                CommandName = DefinitionsHelper.CreateCommandName,
                Text        = "Create Location",
                CssClass    = "sfMainAction",
                WidgetType  = typeof(CommandWidget)
            };
            masterViewToolbarSection.Items.Add(createLocationsWidget);

            // "Delete" button for Toolbar
            var deleteLocationsWidget = new CommandWidgetElement(masterViewToolbarSection.Items)
            {
                Name        = "DeleteLocationsCommandWidget",
                ButtonType  = CommandButtonType.Standard,
                CommandName = DefinitionsHelper.GroupDeleteCommandName,
                Text        = "Delete",
                WidgetType  = typeof(CommandWidget),
                CssClass    = "sfGroupBtn"
            };
            masterViewToolbarSection.Items.Add(deleteLocationsWidget);

            // "Search" button for toolbar
            masterViewToolbarSection.Items.Add(DefinitionsHelper.CreateSearchButtonWidget(masterViewToolbarSection.Items, typeof(LocationItem)));
            locationsGridView.ToolbarConfig.Sections.Add(masterViewToolbarSection);

            #endregion

            #region Locations Grid (List View)

            // Define GridView mode
            var gridMode = new GridViewModeElement(locationsGridView.ViewModesConfig)
            {
                Name = "Grid"
            };
            locationsGridView.ViewModesConfig.Add(gridMode);

            #region Locations Grid Columns

            // Title column
            DataColumnElement titleColumn = new DataColumnElement(gridMode.ColumnsConfig)
            {
                Name           = "Title",
                HeaderText     = "Title",
                HeaderCssClass = "sfTitleCol",
                ItemCssClass   = "sfTitleCol",
                ClientTemplate = @"<a sys:href='javascript:void(0);' sys:class=""{{ 'sf_binderCommand_edit sfItemTitle sfpublished"">
					<strong>{{Title}}</strong></a>"
            };
            gridMode.ColumnsConfig.Add(titleColumn);

            ActionMenuColumnElement actionsColumn = new ActionMenuColumnElement(gridMode.ColumnsConfig)
            {
                Name           = "Actions",
                HeaderText     = "Actions",
                HeaderCssClass = "sfMoreActions",
                ItemCssClass   = "sfMoreActions"
            };
            actionsColumn.MenuItems.Add(DefinitionsHelper.CreateActionMenuCommand(actionsColumn.MenuItems, "View", HtmlTextWriterTag.Li, "preview", "View", string.Empty));
            actionsColumn.MenuItems.Add(DefinitionsHelper.CreateActionMenuCommand(actionsColumn.MenuItems, "Delete", HtmlTextWriterTag.Li, "delete", "Delete", string.Empty));

            gridMode.ColumnsConfig.Add(actionsColumn);

            #endregion

            #endregion

            #region Dialog Window definitions

            #region Insert Item Dialog

            // Insert Item Parameters
            var parameters = string.Concat(
                "?ControlDefinitionName=",
                LocationsDefinitions.BackendDefinitionName,
                "&ViewName=",
                LocationsDefinitions.BackendInsertViewName);

            // Insert Item Dialog
            DialogElement createDialogElement = DefinitionsHelper.CreateDialogElement(
                locationsGridView.DialogsConfig,
                DefinitionsHelper.CreateCommandName,
                "ContentViewInsertDialog",
                parameters);

            // add dialog to Backend
            locationsGridView.DialogsConfig.Add(createDialogElement);

            #endregion

            #region Edit Item Dialog

            // "Edit Item" Parameters
            parameters = string.Concat(
                "?ControlDefinitionName=",
                LocationsDefinitions.BackendDefinitionName,
                "&ViewName=",
                LocationsDefinitions.BackendEditViewName);

            // "Edit Item" Dialog
            DialogElement editDialogElement = DefinitionsHelper.CreateDialogElement(
                locationsGridView.DialogsConfig,
                DefinitionsHelper.EditCommandName,
                "ContentViewEditDialog",
                parameters);

            // Add Dialog to Backend
            locationsGridView.DialogsConfig.Add(editDialogElement);

            #endregion

            #region Preview Item Dialog

            // "Preview Item" parameters
            parameters = string.Concat(
                "?ControlDefinitionName=",
                LocationsDefinitions.BackendDefinitionName,
                "&ViewName=",
                LocationsDefinitions.BackendPreviewName,
                "&backLabelText=", "BacktoItems", "&SuppressBackToButtonLabelModify=true");

            // Preview Item Dialog
            DialogElement previewDialogElement = DefinitionsHelper.CreateDialogElement(
                locationsGridView.DialogsConfig,
                DefinitionsHelper.PreviewCommandName,
                "ContentViewEditDialog",
                parameters);

            // Add Dialog to Backend
            locationsGridView.DialogsConfig.Add(previewDialogElement);

            #endregion

            #endregion

            #region Admin Forms Views

            #region Create Item Form View

            // bind create item view to web service
            var locationsInsertDetailView = new DetailFormViewElement(backendContentView.ViewsConfig)
            {
                Title                     = "Create Location",
                ViewName                  = LocationsDefinitions.BackendInsertViewName,
                ViewType                  = typeof(DetailFormView),
                ShowSections              = true,
                DisplayMode               = FieldDisplayMode.Write,
                ShowTopToolbar            = true,
                WebServiceBaseUrl         = "~/Sitefinity/Services/Content/locations.svc/",
                IsToRenderTranslationView = false,
                UseWorkflow               = false
            };

            backendContentView.ViewsConfig.Add(locationsInsertDetailView);

            #endregion

            #region Edit Item Form View

            // bind Edit item form to web service
            var locationsEditDetailView = new DetailFormViewElement(backendContentView.ViewsConfig)
            {
                Title                     = "Edit Location",
                ViewName                  = LocationsDefinitions.BackendEditViewName,
                ViewType                  = typeof(DetailFormView),
                ShowSections              = true,
                DisplayMode               = FieldDisplayMode.Write,
                ShowTopToolbar            = true,
                WebServiceBaseUrl         = "~/Sitefinity/Services/Content/Locations.svc/",
                IsToRenderTranslationView = false,
                UseWorkflow               = false
            };

            backendContentView.ViewsConfig.Add(locationsEditDetailView);

            #endregion

            #region Preview Item Form View

            // bind Preview Form to web service
            var locationsPreviewDetailView = new DetailFormViewElement(backendContentView.ViewsConfig)
            {
                Title             = "Location Preview",
                ViewName          = LocationsDefinitions.BackendPreviewName,
                ViewType          = typeof(DetailFormView),
                ShowSections      = true,
                DisplayMode       = FieldDisplayMode.Read,
                ShowTopToolbar    = true,
                ShowNavigation    = true,
                WebServiceBaseUrl = "~/Sitefinity/Services/Content/Locations.svc/",
                UseWorkflow       = false
            };

            backendContentView.ViewsConfig.Add(locationsPreviewDetailView);

            #endregion

            #endregion

            #region Locations Backend Forms Definition

            #region Insert Form

            LocationsDefinitions.CreateBackendSections(locationsInsertDetailView, FieldDisplayMode.Write);
            LocationsDefinitions.CreateBackendFormToolbar(locationsInsertDetailView, true, true);

            #endregion

            #region Edit Form

            LocationsDefinitions.CreateBackendSections(locationsEditDetailView, FieldDisplayMode.Write);
            LocationsDefinitions.CreateBackendFormToolbar(locationsEditDetailView, false, true);

            #endregion

            #region Preview Form

            CreateBackendSections(locationsPreviewDetailView, FieldDisplayMode.Read);

            #endregion

            #endregion

            return(backendContentView);
        }