public VueActionTrigger[] TableActionsForSingleContent(ProtoContent content, ProtoCmsRuntimeContext cmsContext, ContentType contentType) { var trigs = new List <VueActionTrigger>(); if (contentType.IsModifyOperationAllowed(CommonFieldModifyOperationsProvider.UPDATE_OPERATION_NAME)) { trigs.Add(new VueButton { Label = $"Update", IconCssClass = "fa fa-pencil", OnClick = $"protoCms.utils.popupEntityOperationForm('content', '{content.Id}', '{contentType.Id}', " + $"'{CommonFieldModifyOperationsProvider.UPDATE_OPERATION_NAME}', " + $"'Update', '{contentType.Name}')" }); } if (contentType.IsModifyOperationAllowed(CommonFieldModifyOperationsProvider.DELETE_OPERATION_NAME)) { trigs.Add(new VueButton { Label = $"Delete", IconCssClass = "fa fa-trash", OnClick = $"protoCms.utils.popupEntityOperationForm('content', '{content.Id}', '{contentType.Id}', " + $"'{CommonFieldModifyOperationsProvider.DELETE_OPERATION_NAME}', " + $"'Delete', '{contentType.Name}')" }); } return(trigs.ToArray()); }
protected void CheckUserHasPermissionToListDatum(DatumType dt, ProtoCmsRuntimeContext rctx) { if (!rctx.UserHasPermission(dt.ListPermissionBase.Id)) { throw new HttpException(403, $"ProtoCMS: user is forbidden to list datum type '{dt.Id}'."); } }
public VueActionTrigger[] TableActionsForSingleContent(string contentId, ProtoCmsRuntimeContext cmsContext) { var actions = new List <VueActionTrigger>(); var content = _currentQuery.FirstOrDefault(x => x.Id == contentId); if (ContentType != null) { actions.Add(new VueButton { Label = $"View Raw", IconCssClass = "fa fa-eye", OnClick = $"protoCms.utils.popupEntityRawDataViewer('content', '{contentId}', '{ContentType.Id}', " + $"'Raw Data View', '{ContentType.Name}')" }); } foreach (var prov in TableActionsHandlers) { var acts = prov.TableActionsForSingleContent(content, cmsContext, ContentType); if (acts != null && acts.Length > 0) { actions.AddRange(acts); } } return(actions.ToArray()); }
protected void CheckUserCanModifySetting(ProtoCmsRuntimeContext rctx, string settingId) { if (!rctx.UserHasPermission(ModifySiteSettingPermission.GetIdFor(settingId))) { throw new HttpException(403, $"ProtoCMS: user has no permission to modify setting '{settingId}'."); } }
protected void CheckUserHasPermissionToModifyContent(ProtoCmsRuntimeContext rctx, ModifyContentPermission modPerm, ContentModifyOperation modOp, ContentType ct) { if (!rctx.UserHasPermission(modPerm.Id)) { throw new HttpException(403, $"ProtoCMS: user is forbidden to perform modify operation " + $"'{modOp.Name}' on content type '{ct.Id}'."); } }
protected void CheckUserHasPermissionToListContent(ContentType ct, ProtoCmsRuntimeContext rctx) { var listPerm = new ListContentPermission(ct); if (!rctx.UserHasPermission(listPerm.Id)) { throw new HttpException(403, $"ProtoCMS: user is forbidden to list content type '{ct.Id}'."); } }
public VueActionTrigger[] TableActionsForNoContent(ProtoCmsRuntimeContext cmsContext) { var actions = new List <VueActionTrigger>(); foreach (var prov in TableActionsHandlers) { var acts = prov.TableActionsForNoContent(cmsContext, ContentType); if (acts != null && acts.Length > 0) { actions.AddRange(acts); } } return(actions.ToArray()); }
public VueActionTrigger[] TableActionsForNoContent(ProtoCmsRuntimeContext cmsContext, ContentType contentType) { var trigs = new List <VueActionTrigger>(); if (contentType.IsModifyOperationAllowed(CommonFieldModifyOperationsProvider.CREATE_OPERATION_NAME)) { trigs.Add(new VueButton { Label = $"Create New {contentType.Name}", IconCssClass = "fa fa-plus", OnClick = $"protoCms.utils.popupEntityOperationForm('content', null, '{contentType.Id}', " + $"'{CommonFieldModifyOperationsProvider.CREATE_OPERATION_NAME}', " + $"'Create {contentType.Name}', null)" }); } return(trigs.ToArray()); }
public override VueActionTrigger[] TableActionsForNoContent(ProtoCmsRuntimeContext cmsContext, Type datumType) { var dtt = datumType.GetDatumTypeFromType <ApplicationRole>(); if (dtt == null || !dtt.IsModifyOperationAllowed(StandardModifyOperationsProvider.CREATE_OPERATION_NAME)) { return(null); } return(new VueActionTrigger[] { new VueButton { Label = $"Create New {dtt.Name}", IconCssClass = "fa fa-plus", OnClick = $"protoCms.utils.popupEntityOperationForm('datum', null, '{dtt.Id}', " + $"'{StandardModifyOperationsProvider.CREATE_OPERATION_NAME}', " + $"'Create {dtt.Name}', null)" } }); }
public VueActionTrigger[] TableActionsForSingleContent(ProtoContent content, ProtoCmsRuntimeContext cmsContext, ContentType contentType) { var trigs = new List <VueActionTrigger>(); if (contentType.IsModifyOperationAllowed( TrashingFieldModifyOperationsProvider.CHANGE_TRASH_STATUS_OPERATION_NAME)) { trigs.Add(new VueButton { Label = "Trash/Untrash", IconCssClass = "fa fa-trash-o", OnClick = $"protoCms.utils.popupEntityOperationForm('content', '{content.Id}', '{contentType.Id}', " + $"'{TrashingFieldModifyOperationsProvider.CHANGE_TRASH_STATUS_OPERATION_NAME}', " + $"'Trash/Untrash', '{contentType.Name}')" }); } return(trigs.ToArray()); }
public dynamic GetDatumShaped(object datum, DatumType datumType, ProtoCmsRuntimeContext cmsContext, ContentListShape shape) { var finder = datumType.FinderBase(); var datumId = finder.GetDatumIdBase(datum); switch (shape) { case ContentListShape.TableRowVue: var cdt = finder.AsTableRowVueBase(datum); cdt.Add(DatumListApiResult.DATUM_TABLE_ACTION_KEY, new[] { new VueComponentDefinition { Name = "cms-widget-dropdown-button", Props = new { label = "Opt", size = "xs", type = "warning", iconCssClass = "fa fa-angle-down", items = finder.TableActionsForSingleContent(datumId, cmsContext) } } }); return(cdt); case ContentListShape.Summary: return(new { DatumId = datumId, DatumTypeId = datumType?.Id, Summary = finder.AsSummarizedValueBase(datum) }); case ContentListShape.FullPreview: return(finder.AsFullPreviewBase(datum)); default: return(datum); } }
public override VueActionTrigger[] TableActionsForSingleContent(ApplicationRole datum, ProtoCmsRuntimeContext cmsContext, Type datumType) { var dtt = datumType.GetDatumTypeFromType <ApplicationRole>(); if (dtt == null) { return(null); } var trigs = new List <VueActionTrigger>(); if (dtt.IsModifyOperationAllowed(StandardModifyOperationsProvider.UPDATE_OPERATION_NAME)) { trigs.Add( new VueButton { Label = $"Update", IconCssClass = "fa fa-pencil", OnClick = $"protoCms.utils.popupEntityOperationForm('datum', '{datum.Id}', '{dtt.Id}', " + $"'{StandardModifyOperationsProvider.UPDATE_OPERATION_NAME}', " + $"'Update {datum.Name}', '{dtt.Name}')" }); } if (dtt.IsModifyOperationAllowed(StandardModifyOperationsProvider.DELETE_OPERATION_NAME)) { trigs.Add( new VueButton { Label = $"Delete", IconCssClass = "fa fa-trash", OnClick = $"protoCms.utils.popupEntityOperationForm('datum', '{datum.Id}', '{dtt.Id}', " + $"'{StandardModifyOperationsProvider.DELETE_OPERATION_NAME}', " + $"'Delete {datum.Name}', '{dtt.Name}')" }); } return(trigs.ToArray()); }
public dynamic GetContentShaped(ProtoContent content, ContentType contentType, ProtoCmsRuntimeContext cmsContext, ContentListShape shape) { var finder = contentType.Finder(); switch (shape) { case ContentListShape.TableRowVue: var cdt = finder.AsTableRowVue(content); cdt.Add(ContentListApiResult.CONTENT_TABLE_ACTION_KEY, new[] { new VueComponentDefinition { Name = "cms-widget-dropdown-button", Props = new { label = "Opt", size = "xs", type = "warning", iconCssClass = "fa fa-angle-down", items = finder.TableActionsForSingleContent(content.Id, cmsContext) } } }); return(cdt); case ContentListShape.Summary: return(new { content.Id, content.ContentTypeId, Summary = finder.AsSummarizedValue(content, contentType.FieldNamesIncludedInSummary) }); case ContentListShape.FullPreview: return(finder.AsFullPreview(content)); default: return(finder.AsDynamic(content)); } }
public VueActionTrigger[] TableActionsForSingleContentBase(object datum, ProtoCmsRuntimeContext cmsContext, Type datumType) { return(TableActionsForSingleContent(datum.DirectCastTo <TDat>(), cmsContext, datumType)); }
public ContentListApiResult(ProtoCmsRuntimeContext cmsContext, ContentType contentType, string search, string sortColumn, bool?isDescending, int offset, int limit, ContentListShape?shape, IContentFinder finder = null) { finder = finder ?? contentType.Finder(); var contentShape = shape ?? ContentListShape.Normal; if (!string.IsNullOrWhiteSpace(search)) { finder = finder.Search(search.Trim()); } if (!string.IsNullOrWhiteSpace(sortColumn)) { SortColumn = sortColumn; if (isDescending.HasValue) { SortIsDescending = isDescending.Value; finder = finder.Sort(sortColumn, isDescending.Value); } else { SortIsDescending = contentType.DefaultSortDescending; finder = finder.Sort(sortColumn, contentType.DefaultSortDescending); } } else { SortColumn = contentType.DefaultSortFieldName; if (isDescending.HasValue) { SortIsDescending = isDescending.Value; finder = finder.Sort(contentType.DefaultSortFieldName, isDescending.Value); } else { SortIsDescending = contentType.DefaultSortDescending; finder = finder.Sort(contentType.DefaultSortFieldName, contentType.DefaultSortDescending); } } if (offset < 0) { offset = 0; } if (limit < 1) { limit = 100; } var currentPage = offset / limit + 1; var paginated = new PaginatedQueryable <ProtoContent>(finder.AsQueryable(), currentPage, limit); var rawData = paginated.CurrentPageQueryable.ToArray(); CurrentPage = paginated.CurrentPage; TotalPage = paginated.TotalPage; StartNumbering = paginated.StartNumbering; GlobalCount = paginated.Count; CurrentCount = rawData.Length; Offset = paginated.Offset; Limit = paginated.Limit; SearchKeywords = search; ResultShape = $"{contentShape.ToString()} ({(int) contentShape})"; var data = new List <dynamic>(); var getter = new ContentShapedApiModelBuilder(); foreach (var rd in rawData) { data.Add(getter.GetContentShaped(rd, contentType, cmsContext, contentShape)); } Data = data.ToArray(); }
public abstract VueActionTrigger[] TableActionsForNoContent(ProtoCmsRuntimeContext cmsContext);
public abstract VueActionTrigger[] TableActionsForSingleContent(string datumId, ProtoCmsRuntimeContext cmsContext);
public abstract VueActionTrigger[] TableActionsForSingleContent(TDat datum, ProtoCmsRuntimeContext cmsContext, Type datumType);
public VueActionTrigger[] TableActionsForNoContent(ProtoCmsRuntimeContext cmsContext, ContentType contentType) { return(null); }