Пример #1
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);
        }
Пример #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);
        }