Exemplo n.º 1
0
        public static CommandWidgetElement CreateActionMenuCommand(
            ConfigElement parent,
            string name,
            HtmlTextWriterTag wrapperTagKey,
            string commandName,
            string text,
            string resourceClassId,
            string cssClass)
        {
            var commandWidgetElement = DefinitionsHelper.CreateActionMenuCommand(parent, name, wrapperTagKey, commandName, text, resourceClassId);

            commandWidgetElement.CssClass = cssClass;
            return(commandWidgetElement);
        }
Exemplo n.º 2
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);
        }