Esempio n. 1
0
        public async Task <ActionResult> MoveBottom(Guid pageGuid, Guid moduleGuid, string pane, int moduleIndex = -1)
        {
            if (pageGuid == Guid.Empty || moduleGuid == Guid.Empty || pane == null || moduleIndex == -1)
            {
                throw new ArgumentException();
            }
            PageDefinition page = await LoadPageAsync(pageGuid);

            if (!page.IsAuthorized_Edit())
            {
                return(NotAuthorized());
            }
            page.ModuleDefinitions.MoveBottom(pane, moduleGuid, moduleIndex);
            await page.SaveAsync();

            return(Reload());
        }
Esempio n. 2
0
        public async Task <ActionResult> MoveToPane(Guid pageGuid, Guid moduleGuid, string oldPane, string newPane)
        {
            if (pageGuid == Guid.Empty || moduleGuid == Guid.Empty || oldPane == null || newPane == null)
            {
                throw new ArgumentException();
            }
            PageDefinition page = await LoadPageAsync(pageGuid);

            if (!page.IsAuthorized_Edit())
            {
                return(NotAuthorized());
            }
            page.ModuleDefinitions.MoveToPane(oldPane, moduleGuid, newPane);
            await page.SaveAsync();

            return(Reload());
        }
Esempio n. 3
0
 public async Task <ModuleAction> GetAction_MoveToPaneAsync(PageDefinition page, ModuleDefinition mod, string oldPane, string newPane)
 {
     if (page == null)
     {
         return(null);
     }
     if (oldPane == null)
     {
         return(null);
     }
     if (newPane == null)
     {
         return(null);
     }
     if (!page.IsAuthorized_Edit())
     {
         return(null);
     }
     return(new ModuleAction(this)
     {
         Url = Utility.UrlFor(typeof(ModuleControlModuleController), nameof(ModuleControlModuleController.MoveToPane)),
         QueryArgs = new { PageGuid = page.PageGuid, ModuleGuid = mod.ModuleGuid, OldPane = oldPane, NewPane = newPane },
         QueryArgsDict = new QueryHelper(new QueryDictionary {
             { Basics.ModuleGuid, this.ModuleGuid }, // the module authorizing this
         }),
         Image = await CustomIconAsync("MoveToPane.png"),
         LinkText = this.__ResStr("modMoveToLink", "Move To {0}", newPane),
         Style = ModuleAction.ActionStyleEnum.Post,
         MenuText = newPane,
         Tooltip = this.__ResStr("ttMoveToPane", "Move the module to the {0} pane", newPane),
         Legend = this.__ResStr("modMoveToLegend", "Moves the module to the {0} pane", newPane),
         Enabled = string.Compare(oldPane, newPane, true) != 0,
         Category = ModuleAction.ActionCategoryEnum.Update,
         Mode = ModuleAction.ActionModeEnum.Edit,
         Location = ModuleAction.ActionLocationEnum.ModuleMenu,
     });
 }
Esempio n. 4
0
        public async Task <ModuleAction> GetAction_MoveBottomAsync(PageDefinition page, ModuleDefinition mod, string pane)
        {
            if (page == null)
            {
                return(null);
            }
            if (pane == null)
            {
                return(null);
            }
            if (!page.IsAuthorized_Edit())
            {
                return(null);
            }
            PageDefinition.ModuleList modList = page.ModuleDefinitions.GetModulesForPane(pane);
            int modIndex = modList.IndexInPane(mod, pane);

            return(new ModuleAction(this)
            {
                Url = Utility.UrlFor(typeof(ModuleControlModuleController), nameof(ModuleControlModuleController.MoveBottom)),
                QueryArgs = new { PageGuid = page.PageGuid, ModuleGuid = mod.ModuleGuid, Pane = pane, ModuleIndex = modIndex },
                QueryArgsDict = new QueryHelper(new QueryDictionary {
                    { Basics.ModuleGuid, this.ModuleGuid }, // the module authorizing this
                }),
                Image = await CustomIconAsync("MoveBottom.png"),
                Style = ModuleAction.ActionStyleEnum.Post,
                LinkText = this.__ResStr("modMoveBottomLink", "Move To Bottom"),
                MenuText = this.__ResStr("modMoveBottomText", "Bottom"),
                Tooltip = this.__ResStr("modMoveBottomTooltip", "Move the module to the bottom of the pane"),
                Legend = this.__ResStr("modMoveBottomLegend", "Moves the module to the bottom of the pane"),
                Enabled = modIndex < modList.Count - 1,
                Category = ModuleAction.ActionCategoryEnum.Update,
                Mode = ModuleAction.ActionModeEnum.Edit,
                Location = ModuleAction.ActionLocationEnum.ModuleMenu,
            });
        }
Esempio n. 5
0
        public async Task <ActionResult> PageControl()
        {
            if (Manager.IsInPopup)
            {
                return(new EmptyResult());
            }
            if (Manager.CurrentPage == null || Manager.CurrentPage.Temporary)
            {
                return(new EmptyResult());
            }
#if DEBUG
            // allow in debug mode without checking unless marked deployed
            if (YetaWFManager.Deployed && !Manager.CurrentPage.IsAuthorized_Edit())
            {
                return(new EmptyResult());
            }
#else
            if (!Manager.CurrentPage.IsAuthorized_Edit())
            {
                return(new EmptyResult());
            }
#endif

            Guid pageGuid = Guid.Empty;
            if (pageGuid == Guid.Empty)
            {
                if (Manager.CurrentPage == null)
                {
                    pageGuid = new Guid(); // we're not on a designed page
                }
                else
                {
                    pageGuid = Manager.CurrentPage.PageGuid;
                }
            }

            PageDefinition page = await PageDefinition.LoadAsync(pageGuid);

            bool editAuthorized = false;
            if (page.IsAuthorized_Edit())
            {
                editAuthorized = true;
            }

            PageControlModel model = new PageControlModel()
            {
                EditAuthorized  = editAuthorized,
                AddNewPageModel = new AddNewPageModel()
                {
                    CurrentPageGuid = Manager.CurrentPage.PageGuid,
                },
                AddNewModel = new AddNewModuleModel()
                {
                    CurrentPageGuid = Manager.CurrentPage.PageGuid,
                },
                AddExistingModel = new AddExistingModel()
                {
                    CurrentPageGuid = Manager.CurrentPage.PageGuid,
                },
                ImportPageModel   = new ImportPageModel(),
                ImportModuleModel = new ImportModuleModel()
                {
                    CurrentPageGuid = Manager.CurrentPage.PageGuid,
                },
                SkinSelectionModel = new SkinSelectionModel {
                    BootstrapSkin            = Manager.CurrentSite.BootstrapSkin,
                    jQueryUISkin             = Manager.CurrentSite.jQueryUISkin,
                    KendoUISkin              = Manager.CurrentSite.KendoUISkin,
                    BootstrapSkinDescription = (!Manager.SkinInfo.UsingBootstrap || !Manager.SkinInfo.UseDefaultBootstrap) ?
                                               this.__ResStr("noBootswatch", "The current page skin does not support selecting a default Bootstrap skin. The skin does not support Bootswatch, which is required for skin selection.") :
                                               null,
                },
                LoginSiteSelectionModel = new LoginSiteSelectionModel(),
            };

            PageEditModule modEdit = new PageEditModule();
            model.Actions = new List <ModuleAction>();
            model.Actions.New(await modEdit.GetAction_EditAsync(null));
            model.Actions.New(await Module.GetAction_ExportPageAsync(null));
            model.Actions.New(await modEdit.GetAction_RemoveAsync(null));
            model.Actions.New(Module.GetAction_SwitchToView());
            model.Actions.New(Module.GetAction_SwitchToEdit());
            model.Actions.New(await Module.GetAction_W3CValidationAsync());
            model.Actions.New(await Module.GetAction_RestartSite());
            model.Actions.New(Module.GetAction_ClearJsCssCache());

            model.AddNewModel.AddData(page);
            model.AddExistingModel.AddData(page);
            model.ImportPageModel.AddData(page, Module);
            model.ImportModuleModel.AddData(page, Module);
            await model.LoginSiteSelectionModel.AddDataAsync();

            return(View(model));
        }