public void InitView(ModuleDashboard permissions, DashboardType type, Int32 idCommunity, Boolean loadFromRecycleBin, long idTile = 0, TileType preloadType = TileType.None) { Person p = CurrentManager.GetPerson(UserContext.CurrentUserID); if (UserContext.isAnonymous || p == null) { View.DisplaySessionTimeout(); } else { View.IdTilesCommunity = idCommunity; //dtoFilters filters = new dtoFilters() { DashboardType = type, IdCommunity = idCommunity, IdSelectedLanguage=-1, FromRecycleBin = loadFromRecycleBin }; //if (!loadFromRecycleBin && preloadType != TileType.None) // filters.IdTileType = (long)preloadType; Dictionary <searchFilterType, long> defaultValues = (from searchFilterType n in Enum.GetValues(typeof(searchFilterType)).AsQueryable() where n != searchFilterType.none select n).ToDictionary(t => t, t => (long)-1); if (!loadFromRecycleBin && preloadType != TileType.None) { defaultValues[searchFilterType.type] = (long)preloadType; } List <lm.Comol.Core.DomainModel.Filters.Filter> filters = Service.GetDefaultFilters(type, p.Id, idCommunity, -1, idCommunity, loadFromRecycleBin, defaultValues).OrderBy(f => f.DisplayOrder).ToList(); View.LoadDefaultFilters(filters); InitializeView(permissions, new dtoFilters(type, idCommunity, loadFromRecycleBin, filters), idCommunity, idTile); } }
public void InitView(DashboardType type, Boolean loadFromRecycleBin, Int32 idCommunity, long idDashboard = 0, WizardDashboardStep step = WizardDashboardStep.None) { Person p = CurrentManager.GetPerson(UserContext.CurrentUserID); if (UserContext.isAnonymous || p == null) { View.DisplaySessionTimeout(); } else { ModuleDashboard permissions = ModuleDashboard.CreatePortalmodule(p.TypeID); if (type == DashboardType.Community) { View.IdContainerCommunity = UserContext.CurrentCommunityID; if (idCommunity < 0) { idCommunity = UserContext.CurrentCommunityID; } if (idCommunity > 0 && (!permissions.Administration && !permissions.ManageTiles)) { permissions = Service.GetPermission(idCommunity); } } else { idCommunity = 0; View.IdContainerCommunity = 0; } View.IdTilesCommunity = idCommunity; SetBackUrl(type, idDashboard, step); if (permissions.ManageTiles) { if (loadFromRecycleBin) { View.SetBackUrl(RootObject.TileList(type, false, idCommunity)); } else { View.SetRecycleUrl(RootObject.TileList(type, true, idCommunity)); View.SetAddUrl(RootObject.TileAdd(type, idCommunity)); View.AllowCommunityTypesTileAutoGenerate = (Service.GetCommunityTypesWithoutTilesCount() > 0); } TileType preloadType = TileType.None; if (idDashboard > 0) { switch (step) { case WizardDashboardStep.CommunityTypes: preloadType = TileType.CommunityType; break; } } View.InitializeListControl(permissions, type, idCommunity, loadFromRecycleBin, View.PreloadIdTile, preloadType); } else { View.DisplayNoPermission(idCommunity, CurrentIdModule); } } }
public dtoTileItem(liteTile tile, ModuleDashboard permissions, Int32 idLanguage, List <Language> languages, Int32 idCurrentUser, List <Int32> idCommunityTypes) { Id = tile.Id; Deleted = tile.Deleted; CreatedOn = tile.CreatedOn; ModifiedOn = tile.ModifiedOn; IdCreatedBy = tile.IdCreatedBy; IdModifiedBy = tile.IdModifiedBy; Status = tile.Status; IdDisplayLanguage = idLanguage; Translation = tile.GetTranslation(idLanguage); Translations = tile.Translations.Where(t => t.Deleted == BaseStatusDeleted.None && t.Translation != null && !String.IsNullOrEmpty(t.Translation.Title)).Select(t => new dtoLanguageItem() { IdLanguage = t.IdLanguage, LanguageCode = t.LanguageCode, IsDefault = languages.Where(l => l.Id == t.IdLanguage && l.isDefault).Any(), LanguageName = (languages.Where(l => l.Id == t.IdLanguage).Any() ? languages.Where(l => l.Id == t.IdLanguage).Select(l => l.Name).FirstOrDefault() : t.LanguageName) }).OrderByDescending(l => l.IsMultiLanguage).ThenByDescending(l => l.IsDefault).ThenBy(l => l.LanguageName).ToList(); Type = tile.Type; Boolean editingEnabled = (tile.Type != TileType.CommunityType || (tile.CommunityTypes != null && !tile.CommunityTypes.Where(i => idCommunityTypes.Contains(i)).Any())); Permissions = new dtoPermission(); Permissions.AllowView = permissions.List || permissions.Administration || permissions.Edit; Permissions.AllowDelete = editingEnabled && tile.Deleted == BaseStatusDeleted.Manual && (permissions.Administration || permissions.DeleteOther || (permissions.DeleteMy && idCurrentUser == tile.IdCreatedBy)); Permissions.AllowVirtualDelete = editingEnabled && tile.Deleted == BaseStatusDeleted.None && (permissions.Administration || permissions.DeleteOther || (permissions.DeleteMy && idCurrentUser == tile.IdCreatedBy)); Permissions.AllowUnDelete = editingEnabled && tile.Deleted == BaseStatusDeleted.Manual && (permissions.Administration || permissions.DeleteOther || (permissions.DeleteMy && idCurrentUser == tile.IdCreatedBy)); Permissions.AllowEdit = tile.Deleted == BaseStatusDeleted.None && (permissions.Administration || permissions.Edit); Permissions.AllowSetAvailable = tile.Deleted == BaseStatusDeleted.None && tile.Status != lm.Comol.Core.Dashboard.Domain.AvailableStatus.Available && (permissions.Administration || permissions.Edit); Permissions.AllowSetUnavailable = tile.Deleted == BaseStatusDeleted.None && tile.Status == lm.Comol.Core.Dashboard.Domain.AvailableStatus.Available && (permissions.Administration || permissions.Edit); }
private void LoadSettings(ModuleDashboard permissions, DashboardType type, Int32 idCommunity, Boolean loadFromRecycleBin, OrderSettingsBy orderBy = OrderSettingsBy.Default, Boolean ascending = true) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { List <dtoDashboardSettings> items = Service.DashboardGetSettings(permissions, type, View.GetUnknownUserName(), View.GetTranslatedStatus(), idCommunity, loadFromRecycleBin, orderBy, ascending); if (items == null) { View.DisplayErrorLoadingFromDB(); } else { //if (items.Count == 1) // items[0].Permissions.AllowSetUnavailable = items[0].Permissions.AllowSetUnavailable && !(items[0].Active && items[0].ForAll); //else if (items.Where()) ModuleDashboard.ActionType action = ModuleDashboard.ActionType.DashboardSettingsPortalList; switch (type) { case DashboardType.AllCommunities: action = ModuleDashboard.ActionType.DashboardSettingsAllCommunitiesList; break; case DashboardType.Community: action = ModuleDashboard.ActionType.DashboardSettingsCommunityList; break; } View.LoadSettings(items); View.SendUserAction(idCommunity, CurrentIdModule, action); } } }
public void InitView(long idDashboard, DashboardType dashboardType, Int32 idContainerCommunity) { Person p = CurrentManager.GetPerson(UserContext.CurrentUserID); View.IdDashboard = idDashboard; if (UserContext.isAnonymous || p == null) { View.DisplaySessionTimeout(); } else { liteDashboardSettings settings = CurrentManager.Get <liteDashboardSettings>(idDashboard); Int32 idDashboardCommunity = (settings == null) ? ((dashboardType == DashboardType.Community) ? idContainerCommunity : 0) : settings.IdCommunity; List <lm.Comol.Core.Wizard.dtoNavigableWizardItem <dtoDashboardStep> > steps = Service.GetAvailableSteps(WizardDashboardStep.HomepageSettings, idDashboard, (settings == null) ? dashboardType :settings.Type, idDashboardCommunity); View.LoadWizardSteps(steps); if (settings == null) { View.DisplayUnknownDashboard(); if (dashboardType == DashboardType.Community) { if (idContainerCommunity < 0) { idDashboardCommunity = UserContext.CurrentCommunityID; } } else { idDashboardCommunity = 0; } View.IdContainerCommunity = idDashboardCommunity; } else { View.IdContainerCommunity = idDashboardCommunity; ModuleDashboard permissions = (dashboardType == DashboardType.Community) ? Service.GetPermission(idDashboardCommunity) : ModuleDashboard.CreatePortalmodule(p.TypeID); if (permissions.Edit || permissions.Administration) { View.SetBackUrl(RootObject.DashboardList(dashboardType, false, idContainerCommunity)); } if (settings.Deleted != BaseStatusDeleted.None) { View.DisplayDeletedDashboard(); } else if (permissions.Edit || permissions.Administration) { View.AllowSave = (settings.Deleted == BaseStatusDeleted.None); View.SetPreviewUrl(RootObject.DashboardPreview(settings.Id, settings.Type, settings.IdCommunity)); View.LoadSettings(new dtoViewSettings(settings)); View.SendUserAction(idContainerCommunity, Service.ServiceModuleID(), settings.Id, ModuleDashboard.ActionType.DashboardSettingsViewsStartEditing); } else { View.DisplayNoPermission(idContainerCommunity, CurrentIdModule); } } } }
private void InitializeView(ModuleDashboard permissions, dtoFilters filters, Int32 idCommunity, long idTile = 0) { View.IdSelectedTileLanguage = -1; List <lm.Comol.Core.Dashboard.Domain.dtoItemFilter <lm.Comol.Core.DomainModel.Languages.dtoLanguageItem> > languages = ServiceTags.GetLanguageSelectorItems(View.GetDefaultLanguageName(), View.GetDefaultLanguageCode()); View.LoadLanguages(languages); View.FirstLoad = true; View.FirstLoadForLanguages = languages.ToDictionary(l => l.Value.IdLanguage, l => true); View.CurrentFilters = filters; LoadTiles(permissions, filters, idCommunity, 0, View.CurrentPageSize, idTile); }
public void InitView(DashboardType type, Boolean loadFromRecycleBin, Int32 idCommunity) { Person p = CurrentManager.GetPerson(UserContext.CurrentUserID); if (UserContext.isAnonymous || p == null) { View.DisplaySessionTimeout(); } else { ModuleDashboard permissions = ModuleDashboard.CreatePortalmodule(p.TypeID); if (type == DashboardType.Community) { idCommunity = UserContext.CurrentCommunityID; if (idCommunity < 0) { idCommunity = UserContext.CurrentCommunityID; } if (idCommunity > 0 && (!permissions.Administration && !permissions.ManageTiles)) { permissions = Service.GetPermission(idCommunity); } } else { idCommunity = 0; } View.IdContainerCommunity = idCommunity; View.SetTitle(type, (idCommunity > 0) ? CurrentManager.GetCommunityName(idCommunity) : ""); if (permissions.Administration || permissions.List || permissions.Edit) { if (loadFromRecycleBin) { View.SetBackUrl(RootObject.DashboardList(type, false, idCommunity)); } else { View.SetRecycleUrl(RootObject.DashboardList(type, true, idCommunity)); View.SetAddUrl(RootObject.DashboardAdd(type, idCommunity)); } View.InitializeListControl(permissions, type, idCommunity, loadFromRecycleBin); } else { View.DisplayNoPermission(idCommunity, CurrentIdModule); } } }
public void LoadTiles(dtoFilters filters, Int32 idCommunity, Int32 pageIndex, Int32 pageSize) { Person p = CurrentManager.GetPerson(UserContext.CurrentUserID); if (UserContext.isAnonymous || p == null) { View.DisplaySessionTimeout(); } else { ModuleDashboard permissions = ModuleDashboard.CreatePortalmodule(p.TypeID); if (filters.DashboardType == DashboardType.Community && idCommunity > 0 && (!permissions.Administration && !permissions.ManageTiles)) { permissions = Service.GetPermission(idCommunity); } LoadTiles(permissions, filters, idCommunity, pageIndex, pageSize); } }
public void LoadSettings(DashboardType type, Int32 idCommunity, Boolean loadFromRecycleBin, OrderSettingsBy orderBy, Boolean ascending) { Person p = CurrentManager.GetPerson(UserContext.CurrentUserID); if (UserContext.isAnonymous || p == null) { View.DisplaySessionTimeout(); } else { ModuleDashboard permissions = ModuleDashboard.CreatePortalmodule(p.TypeID); if (type == DashboardType.Community && idCommunity > 0 && (!permissions.Administration && !permissions.List)) { permissions = Service.GetPermission(idCommunity); } LoadSettings(permissions, type, idCommunity, loadFromRecycleBin, orderBy, ascending); } }
public void InitView(ModuleDashboard permissions, DashboardType type, Int32 idCommunity, Boolean loadFromRecycleBin) { Person p = CurrentManager.GetPerson(UserContext.CurrentUserID); if (UserContext.isAnonymous || p == null) { View.DisplaySessionTimeout(); } else { View.IdContainerCommunity = idCommunity; View.CurrentType = type; View.FromRecycleBin = loadFromRecycleBin; View.CurrentOrderBy = OrderSettingsBy.Default; View.CurrentAscending = true; LoadSettings(permissions, type, idCommunity, loadFromRecycleBin); } }
public ModuleDashboard GetPermission(Int32 idCommunity) { litePerson person = Manager.GetLitePerson(UC.CurrentUserID); if (idCommunity <= 0) { if (person == null) { return(ModuleDashboard.CreatePortalmodule((int)UserTypeStandard.Guest)); } else { return(ModuleDashboard.CreatePortalmodule(person.TypeID)); } } else { return(new ModuleDashboard(Manager.GetModulePermission(UC.CurrentUserID, idCommunity, ServiceModuleID()))); } }
public void InitView(Boolean add, long idDashboard, DashboardType dashboardType, Int32 idContainerCommunity) { Person p = CurrentManager.GetPerson(UserContext.CurrentUserID); if (UserContext.isAnonymous || p == null) { View.DisplaySessionTimeout(); } else { Int32 idDashboardCommunity = (dashboardType == DashboardType.Community) ? idContainerCommunity : 0; ModuleDashboard permissions = ModuleDashboard.CreatePortalmodule(p.TypeID); liteDashboardSettings settings = null; if (add) { settings = new liteDashboardSettings(); settings.Type = dashboardType; settings.Status = AvailableStatus.Draft; settings.Name = View.GetNewSettingsName(); settings.IdCommunity = (dashboardType == DashboardType.Community ? idDashboardCommunity : (dashboardType == DashboardType.AllCommunities ? -1 : 0)); } else { settings = CurrentManager.Get <liteDashboardSettings>(idDashboard); if (View.PreloadFromAdd) { View.DisplaySettingsAdded(); } idDashboardCommunity = (settings == null) ? ((dashboardType == DashboardType.Community) ? idContainerCommunity : 0) : settings.IdCommunity; } if (dashboardType == DashboardType.Community) { View.IdContainerCommunity = idContainerCommunity; if (idContainerCommunity < 0) { idContainerCommunity = UserContext.CurrentCommunityID; } if (idContainerCommunity > 0 && (!permissions.Administration && !permissions.ManageTiles)) { permissions = Service.GetPermission(idContainerCommunity); } } else { idContainerCommunity = 0; View.IdContainerCommunity = 0; } List <lm.Comol.Core.Wizard.dtoNavigableWizardItem <dtoDashboardStep> > steps = Service.GetAvailableSteps(WizardDashboardStep.Settings, idDashboard, dashboardType, idContainerCommunity); View.LoadWizardSteps(steps); if ((settings == null && (idDashboard > 0 || !add)) || (settings != null && settings.Deleted != BaseStatusDeleted.None && settings.Deleted != BaseStatusDeleted.Manual)) { View.DisplayUnknownDashboard(); if ((add && !permissions.Add) || (!add && (!permissions.Administration || !permissions.Edit))) { View.DisplayNoPermission(idContainerCommunity, CurrentIdModule); } else { View.SetBackUrl(RootObject.DashboardList(dashboardType, false, idContainerCommunity)); } } else if ((add && permissions.Add) || permissions.Administration || (!add && permissions.Edit)) { View.AllowSave = true; if (settings.Id > 0) { View.SetPreviewUrl(RootObject.DashboardPreview(settings.Id, settings.Type, settings.IdCommunity)); View.SendUserAction(idContainerCommunity, Service.ServiceModuleID(), settings.Id, ModuleDashboard.ActionType.DashboardSettingsStartEditing); } else { View.SendUserAction(idContainerCommunity, Service.ServiceModuleID(), ModuleDashboard.ActionType.DashboardSettingsStartAdding); } View.AllowSave = (settings.Deleted == BaseStatusDeleted.None); View.SetBackUrl(RootObject.DashboardList(dashboardType, false, idContainerCommunity)); switch (settings.Type) { case DashboardType.Portal: View.LoadSettings(settings, Service.GetDashboardAvailableProfileTypes(settings), settings.GetAssignments(DashboardAssignmentType.ProfileType).Select(a => a.IdProfileType).ToList()); break; case DashboardType.Community: View.LoadSettings(settings, Service.GetDashboardAvailableRoles(settings), settings.GetAssignments(DashboardAssignmentType.RoleType).Select(a => a.IdRole).ToList()); break; case DashboardType.AllCommunities: View.LoadSettings(settings); break; } } else { View.DisplayNoPermission(idContainerCommunity, CurrentIdModule); } } }
public void InitView(Boolean add, long idTile, DashboardType dashboardType, Int32 idContainerCommunity) { Person p = CurrentManager.GetPerson(UserContext.CurrentUserID); if (UserContext.isAnonymous || p == null) { View.DisplaySessionTimeout(); } else { Int32 idTileCommunity = (dashboardType == DashboardType.Community) ? idContainerCommunity : 0; ModuleDashboard permissions = ModuleDashboard.CreatePortalmodule(p.TypeID); List <TileType> availableTypes = null; dtoEditTile tile = null; View.IdTile = idTile; if (add) { availableTypes = Service.GetTileTypesAvailable(dashboardType); tile = new dtoEditTile(); tile.Status = AvailableStatus.Draft; tile.Type = availableTypes.FirstOrDefault(); } else { if (View.PreloadFromAdd) { View.DisplayTileAdded(); } tile = Service.GetEditTile(idTile); idTileCommunity = (tile == null) ? ((dashboardType == DashboardType.Community) ? idContainerCommunity : 0) : tile.IdCommunity; } View.IdTileCommunity = idTileCommunity; if (dashboardType == DashboardType.Community) { View.IdContainerCommunity = idContainerCommunity; if (idTileCommunity < 0) { idTileCommunity = UserContext.CurrentCommunityID; } if (idTileCommunity > 0 && (!permissions.Administration && !permissions.ManageTiles)) { permissions = Service.GetPermission(idTileCommunity); } } else { idContainerCommunity = 0; View.IdContainerCommunity = 0; } if ((tile == null && (idTile > 0 || !add)) || (tile != null && tile.Deleted != BaseStatusDeleted.None && tile.Deleted != BaseStatusDeleted.Manual)) { View.DisplayUnknownTile(); if (!permissions.ManageTiles) { View.DisplayNoPermission(idContainerCommunity, CurrentIdModule); } else { View.SetBackUrl(RootObject.TileList(dashboardType, false, idContainerCommunity, idTile, View.PreloadIdDashboard, View.PreloadStep)); } } else { if (permissions.ManageTiles) { if (tile != null && tile.Id > 0) { View.AllowVirtualUndelete = (tile.Deleted == BaseStatusDeleted.Manual); View.AllowVirtualDelete = (tile.Deleted == BaseStatusDeleted.None); View.AllowDisable = (tile.Deleted == BaseStatusDeleted.None && tile.Status == AvailableStatus.Available); View.AllowEnable = (tile.Deleted == BaseStatusDeleted.None && tile.Status != AvailableStatus.Available); View.SendUserAction(idContainerCommunity, Service.ServiceModuleID(), tile.Id, ModuleDashboard.ActionType.TileStartEditing); } else { View.SendUserAction(idContainerCommunity, Service.ServiceModuleID(), ModuleDashboard.ActionType.TileStartAdding); } View.AllowSave = (tile.Deleted == BaseStatusDeleted.None); View.SetBackUrl(RootObject.TileList(dashboardType, false, idContainerCommunity, idTile, View.PreloadIdDashboard, View.PreloadStep)); switch (tile.Type) { case TileType.CommunityTag: View.InitalizeEditor(tile, idTile, idContainerCommunity, idTileCommunity, ServiceTags.GetTagTranslation(tile.IdTags.FirstOrDefault(), UserContext.Language.Id).Title); break; case TileType.CombinedTags: Language dLanguage = CurrentManager.GetDefaultLanguage(); List <lm.Comol.Core.Tag.Domain.liteTagItem> items = ServiceTags.CacheGetTags(Tag.Domain.TagType.Community, true).Where(t => t.Status == lm.Comol.Core.Dashboard.Domain.AvailableStatus.Available || tile.IdTags.Contains(t.Id)).ToList(); List <lm.Comol.Core.DomainModel.TranslatedItem <long> > tags = items.Select(t => new lm.Comol.Core.DomainModel.TranslatedItem <long>() { Id = t.Id, Translation = t.GetTitle(UserContext.Language.Id, dLanguage.Id) }).ToList(); View.InitalizeEditor(tile, idTile, idContainerCommunity, idTileCommunity, tags, availableTypes); break; case TileType.CommunityType: View.InitalizeEditor(tile, idTile, idContainerCommunity, idTileCommunity, Service.GetCommunityTypeName(tile.IdCommunityTypes.FirstOrDefault(), UserContext.Language.Id)); break; default: View.InitalizeEditor(tile, idTile, idContainerCommunity, idTileCommunity, availableTypes); break; } } else { View.DisplayNoPermission(idContainerCommunity, CurrentIdModule); } } } }
public void InitView(long idTile, DashboardType dashboardType, Int32 idContainerCommunity) { Person p = CurrentManager.GetPerson(UserContext.CurrentUserID); if (UserContext.isAnonymous || p == null) { View.DisplaySessionTimeout(); } else { Int32 idTileCommunity = (dashboardType == DashboardType.Community) ? idContainerCommunity : 0; ModuleDashboard permissions = ModuleDashboard.CreatePortalmodule(p.TypeID); dtoEditTile tile = Service.GetEditTile(idTile); idTileCommunity = (tile == null) ? ((dashboardType == DashboardType.Community) ? idContainerCommunity : 0) : tile.IdCommunity; if (dashboardType == DashboardType.Community) { View.IdContainerCommunity = idContainerCommunity; if (idTileCommunity < 0) { idTileCommunity = UserContext.CurrentCommunityID; } if (idTileCommunity > 0 && (!permissions.Administration && !permissions.ManageTiles)) { permissions = Service.GetPermission(idTileCommunity); } } else { idContainerCommunity = 0; View.IdContainerCommunity = 0; } if ((tile == null && (idTile > 0)) || (tile != null && tile.Deleted != BaseStatusDeleted.None && tile.Deleted != BaseStatusDeleted.Manual)) { View.DisplayUnknownTile(); } if (permissions.ManageTiles) { View.SendUserAction(idContainerCommunity, Service.ServiceModuleID(), ModuleDashboard.ActionType.TileView); View.SetBackUrl(RootObject.TileList(dashboardType, false, idContainerCommunity, idTile, View.PreloadIdDashboard, View.PreloadStep)); List <lm.Comol.Core.DomainModel.Languages.dtoLanguageItem> languages = CurrentManager.GetAllLanguages().OrderByDescending(l => l.isDefault).ThenBy(l => l.Name).Select(l => new lm.Comol.Core.DomainModel.Languages.dtoLanguageItem() { IdLanguage = l.Id, LanguageCode = l.Code, LanguageName = l.Name }).ToList(); languages.Insert(0, new lm.Comol.Core.DomainModel.Languages.dtoLanguageItem() { IdLanguage = 0, LanguageCode = View.GetDefaultLanguageCode(), LanguageName = View.GetDefaultLanguageName(), IsMultiLanguage = true }); switch (tile.Type) { case TileType.CommunityTag: View.LoadTile(tile, ServiceTags.GetTagTranslation(tile.IdTags.FirstOrDefault(), UserContext.Language.Id).Title, languages, languages.Select(l => new dtoTileFullTranslation(l, tile)).ToList()); break; case TileType.CombinedTags: Language dLanguage = CurrentManager.GetDefaultLanguage(); List <lm.Comol.Core.Tag.Domain.liteTagItem> items = ServiceTags.CacheGetTags(Tag.Domain.TagType.Community, true).Where(t => t.Status == lm.Comol.Core.Dashboard.Domain.AvailableStatus.Available || tile.IdTags.Contains(t.Id)).ToList(); List <lm.Comol.Core.DomainModel.TranslatedItem <long> > tags = items.Select(t => new lm.Comol.Core.DomainModel.TranslatedItem <long>() { Id = t.Id, Translation = t.GetTitle(UserContext.Language.Id, dLanguage.Id) }).ToList(); View.LoadTile(tile, tags, languages, languages.Select(l => new dtoTileFullTranslation(l, tile)).ToList()); break; case TileType.CommunityType: View.LoadTile(tile, Service.GetCommunityTypeName(tile.IdCommunityTypes.FirstOrDefault(), UserContext.Language.Id), languages, languages.Select(l => new dtoTileFullTranslation(l, tile)).ToList()); break; default: View.LoadTile(tile, languages, languages.Select(l => new dtoTileFullTranslation(l, tile)).ToList()); break; } View.SendUserAction(idContainerCommunity, Service.ServiceModuleID(), ModuleDashboard.ActionType.TileView); } else { View.DisplayNoPermission(idContainerCommunity, CurrentIdModule); } } }
public void LoadTiles(ModuleDashboard permissions, dtoFilters filters, Int32 idCommunity, Int32 pageIndex, Int32 pageSize, long idTile = 0) { if (UserContext.isAnonymous) { View.DisplaySessionTimeout(); } else { if (filters.DashboardType == DashboardType.Portal) { View.LoadTilesInfo(Service.GetCommunityTypesWithoutTilesCount(), Service.GetUntranslatedTilesCount(filters)); } else { View.LoadTilesInfo(Service.GetUntranslatedTilesCount(filters)); } List <dtoTileItem> items = Service.GetTiles(UserContext.CurrentUserID, permissions, filters, View.GetUnknownUserName(), View.GetTranslatedTileTypes()); if (items == null) { View.DisplayErrorLoadingFromDB(); } else { Int32 itemsCount = items.Count(); PagerBase pager = new PagerBase(); pager.PageSize = pageSize; pager.Count = (itemsCount > 0) ? itemsCount - 1 : 0; if (pageIndex == 0 && idTile > 0 && items.Where(i => i.Id == idTile).Any()) { while (items.Skip(pageIndex * pageSize).Take(pageSize).Any() && !items.Skip(pageIndex * pageSize).Take(pageSize).Where(i => i.Id == idTile).Any()) { pageIndex++; } if (pageIndex > pager.LastPage - 1) { pageIndex = 0; } else if (pageIndex == pager.LastPage - 1 && !items.Skip(pageIndex * pageSize).Take(pageSize).Where(i => i.Id == idTile).Any()) { pageIndex = 0; } } pager.PageIndex = pageIndex; View.Pager = pager; String dCode = View.GetDefaultLanguageCode(); String dLanguage = View.GetDefaultLanguageName(); if (pageIndex == 0 && idTile > 0) { items = items.Skip(pager.PageIndex * pageSize).Take(pageSize).ToList(); } else { items = items.Skip(pager.PageIndex * pageSize).Take(pageSize).ToList(); } View.AllowApplyFilters(!(View.FirstLoad && !items.Any())); items.ForEach(i => i.Translations.Insert(0, new lm.Comol.Core.DomainModel.Languages.dtoLanguageItem() { IdLanguage = -1, IsMultiLanguage = true, LanguageCode = dCode, LanguageName = dLanguage })); ModuleDashboard.ActionType action = ModuleDashboard.ActionType.TilesPortalDashboardList; switch (filters.DashboardType) { case DashboardType.AllCommunities: action = ModuleDashboard.ActionType.TilesAllCommunitiesList; break; case DashboardType.Community: action = ModuleDashboard.ActionType.TilesCommunityList; break; } View.LoadTiles(items, filters.IdSelectedLanguage); View.SendUserAction((filters.DashboardType == DashboardType.Community) ? idCommunity : 0, CurrentIdModule, action); View.FirstLoad = false; View.FirstLoadForLanguages[filters.IdSelectedLanguage] = false; } } }
public void InitView(WizardDashboardStep step, long idDashboard, DashboardType dashboardType, Int32 idContainerCommunity) { View.IdDashboard = idDashboard; Person p = CurrentManager.GetPerson(UserContext.CurrentUserID); if (UserContext.isAnonymous || p == null) { View.DisplaySessionTimeout(); } else if (step == WizardDashboardStep.None) { switch (dashboardType) { case DashboardType.Portal: View.RedirectToUrl(RootObject.DashboardTileReorder(WizardDashboardStep.Tiles, idDashboard, dashboardType, idContainerCommunity)); break; default: View.RedirectToUrl(RootObject.DashboardTileReorder(WizardDashboardStep.Modules, idDashboard, dashboardType, idContainerCommunity)); break; } } else { View.CurrentStep = step; liteDashboardSettings settings = CurrentManager.Get <liteDashboardSettings>(idDashboard); Int32 idDashboardCommunity = (settings == null) ? ((dashboardType == DashboardType.Community) ? idContainerCommunity : 0) : settings.IdCommunity; List <lm.Comol.Core.Wizard.dtoNavigableWizardItem <dtoDashboardStep> > steps = Service.GetAvailableSteps(step, idDashboard, (settings == null) ? dashboardType : settings.Type, idDashboardCommunity); View.LoadWizardSteps(steps); ModuleDashboard permissions = (dashboardType == DashboardType.Community) ? Service.GetPermission(idDashboardCommunity) : ModuleDashboard.CreatePortalmodule(p.TypeID); String url = lm.Comol.Core.Dashboard.Domain.RootObject.TileList(settings.Type, false, idDashboardCommunity, 0, idDashboard, step); Boolean generateTiles = false; switch (step) { case WizardDashboardStep.CommunityTypes: generateTiles = permissions.ManageTiles && permissions.Administration && (ServiceTiles.GetCommunityTypesWithoutTilesCount() > 0); break; case WizardDashboardStep.Modules: case WizardDashboardStep.Tiles: break; } View.InitializeView(step, url, generateTiles); View.DashboardType = dashboardType; if (settings == null) { View.DisplayUnknownDashboard(); if (dashboardType == DashboardType.Community) { if (idContainerCommunity < 0) { idDashboardCommunity = UserContext.CurrentCommunityID; } } else { idDashboardCommunity = 0; } View.IdContainerCommunity = idDashboardCommunity; } else { View.DashboardType = settings.Type; View.IdContainerCommunity = idDashboardCommunity; if (permissions.Edit || permissions.Administration) { View.SetBackUrl(RootObject.DashboardList(dashboardType, false, idContainerCommunity)); } if (settings.Deleted != BaseStatusDeleted.None) { View.DisplayDeletedDashboard(); } else if (permissions.Edit || permissions.Administration) { View.AllowSave = (settings.Deleted == BaseStatusDeleted.None); View.SetPreviewUrl(RootObject.DashboardPreview(settings.Id, settings.Type, settings.IdCommunity, step)); LoadTiles(step, idDashboard, idDashboardCommunity); } else { View.DisplayNoPermission(idDashboardCommunity, CurrentIdModule); } } } }