public static string Histories( SiteSettings ss, long wikiId, Message message = null) { var wikiModel = new WikiModel(ss, wikiId); ss.SetColumnAccessControls(wikiModel.Mine()); var columns = ss.GetHistoryColumns(checkPermission: true); if (!ss.CanRead()) { return(Error.Types.HasNotPermission.MessageJson()); } var hb = new HtmlBuilder(); hb .HistoryCommands(ss: ss) .Table( attributes: new HtmlAttributes().Class("grid history"), action: () => hb .THead(action: () => hb .GridHeader( columns: columns, sort: false, checkRow: true)) .TBody(action: () => hb .HistoriesTableBody( ss: ss, columns: columns, wikiModel: wikiModel))); return(new WikisResponseCollection(wikiModel) .Html("#FieldSetHistories", hb) .Message(message) .ToJson()); }
public static string Editor(SiteSettings ss, WikiModel wikiModel) { var invalid = WikiValidators.OnEditing(ss, wikiModel); switch (invalid) { case Error.Types.None: break; default: return(HtmlTemplates.Error(invalid)); } var hb = new HtmlBuilder(); ss.SetColumnAccessControls(wikiModel.Mine()); return(hb.Template( ss: ss, verType: wikiModel.VerType, methodType: wikiModel.MethodType, siteId: wikiModel.SiteId, parentId: ss.ParentId, referenceType: "Wikis", title: wikiModel.MethodType == BaseModel.MethodTypes.New ? Displays.New() : wikiModel.Title.DisplayValue, useTitle: ss.TitleColumns?.Any(o => ss.EditorColumns.Contains(o)) == true, userScript: ss.EditorScripts(wikiModel.MethodType), userStyle: ss.EditorStyles(wikiModel.MethodType), action: () => hb .Editor( ss: ss, wikiModel: wikiModel) .Hidden(controlId: "TableName", value: "Wikis") .Hidden(controlId: "Id", value: wikiModel.WikiId.ToString())) .ToString()); }
public static Error.Types OnCreating(SiteSettings ss, WikiModel wikiModel) { if (!ss.CanCreate()) { return(Error.Types.HasNotPermission); } ss.SetColumnAccessControls(wikiModel.Mine()); foreach (var controlId in Forms.Keys()) { switch (controlId) { case "Wikis_Title": if (!ss.GetColumn("Title").CanCreate) { return(Error.Types.HasNotPermission); } break; case "Wikis_Body": if (!ss.GetColumn("Body").CanCreate) { return(Error.Types.HasNotPermission); } break; case "Comments": if (!ss.GetColumn("Comments").CanCreate) { return(Error.Types.HasNotPermission); } break; } } return(Error.Types.None); }
private static HtmlBuilder FieldSetGeneral( this HtmlBuilder hb, SiteSettings ss, WikiModel wikiModel) { var mine = wikiModel.Mine(); return(hb.FieldSet(id: "FieldSetGeneral", action: () => hb .FieldSetGeneralColumns( ss: ss, wikiModel: wikiModel))); }
private static HtmlBuilder FieldSetGeneral( this HtmlBuilder hb, SiteSettings ss, WikiModel wikiModel) { var mine = wikiModel.Mine(); return(hb.FieldSet(id: "FieldSetGeneral", action: () => { ss.GetEditorColumns().ForEach(column => { switch (column.ColumnName) { case "WikiId": hb.Field( ss, column, wikiModel.MethodType, wikiModel.WikiId.ToControl(ss, column), column.ColumnPermissionType()); break; case "Ver": hb.Field( ss, column, wikiModel.MethodType, wikiModel.Ver.ToControl(ss, column), column.ColumnPermissionType()); break; case "Title": hb.Field( ss, column, wikiModel.MethodType, wikiModel.Title.ToControl(ss, column), column.ColumnPermissionType()); break; case "Body": hb.Field( ss, column, wikiModel.MethodType, wikiModel.Body.ToControl(ss, column), column.ColumnPermissionType()); break; } }); hb.VerUpCheckBox(wikiModel); })); }
private static HtmlBuilder FieldSetGeneral( this HtmlBuilder hb, IContext context, SiteSettings ss, WikiModel wikiModel, bool editInDialog = false) { var mine = wikiModel.Mine(context: context); return(hb.FieldSet(id: "FieldSetGeneral", action: () => hb .FieldSetGeneralColumns( context: context, ss: ss, wikiModel: wikiModel, editInDialog: editInDialog))); }
public static string History(SiteSettings ss, long wikiId) { var wikiModel = new WikiModel(ss, wikiId); ss.SetColumnAccessControls(wikiModel.Mine()); wikiModel.Get( ss, where : Rds.WikisWhere() .WikiId(wikiModel.WikiId) .Ver(Forms.Int("Ver")), tableType: Sqls.TableTypes.NormalAndHistory); wikiModel.VerType = Forms.Bool("Latest") ? Versions.VerTypes.Latest : Versions.VerTypes.History; return(EditorResponse(ss, wikiModel).ToJson()); }
public static string Histories(SiteSettings ss, long wikiId) { var wikiModel = new WikiModel(ss, wikiId); ss.SetColumnAccessControls(wikiModel.Mine()); var columns = ss.GetHistoryColumns(checkPermission: true); if (!ss.CanRead()) { return(Error.Types.HasNotPermission.MessageJson()); } var hb = new HtmlBuilder(); hb.Table( attributes: new HtmlAttributes().Class("grid"), action: () => hb .THead(action: () => hb .GridHeader( columns: columns, sort: false, checkRow: false)) .TBody(action: () => new WikiCollection( ss: ss, column: HistoryColumn(columns), where : Rds.WikisWhere().WikiId(wikiModel.WikiId), orderBy: Rds.WikisOrderBy().Ver(SqlOrderBy.Types.desc), tableType: Sqls.TableTypes.NormalAndHistory) .ForEach(wikiModelHistory => hb .Tr( attributes: new HtmlAttributes() .Class("grid-row history not-link") .DataAction("History") .DataMethod("post") .DataVer(wikiModelHistory.Ver) .DataLatest(1, _using: wikiModelHistory.Ver == wikiModel.Ver), action: () => columns .ForEach(column => hb .TdValue( ss: ss, column: column, wikiModel: wikiModelHistory)))))); return(new WikisResponseCollection(wikiModel) .Html("#FieldSetHistories", hb).ToJson()); }
public static Error.Types OnCreating( Context context, SiteSettings ss, WikiModel wikiModel, bool api = false) { if (api && (context.ContractSettings.Api == false || !Parameters.Api.Enabled)) { return(Error.Types.InvalidRequest); } if (!context.CanCreate(ss: ss)) { return(Error.Types.HasNotPermission); } ss.SetColumnAccessControls(context: context, mine: wikiModel.Mine(context: context)); foreach (var column in ss.Columns .Where(o => !o.CanCreate) .Where(o => !ss.FormulaTarget(o.ColumnName)) .Where(o => !o.Linking)) { switch (column.ColumnName) { case "Title": if (wikiModel.Title_Updated(context: context, column: column)) { return(Error.Types.HasNotPermission); } break; case "Body": if (wikiModel.Body_Updated(context: context, column: column)) { return(Error.Types.HasNotPermission); } break; case "Comments": if (!ss.GetColumn(context: context, columnName: "Comments").CanUpdate) { return(Error.Types.HasNotPermission); } break; } } return(Error.Types.None); }
public static ResponseCollection FieldResponse( this ResponseCollection res, SiteSettings ss, WikiModel wikiModel) { var mine = wikiModel.Mine(); ss.EditorColumns .Select(o => ss.GetColumn(o)) .Where(o => o != null) .ForEach(column => { switch (column.ColumnName) { default: break; } }); return(res); }
public static Error.Types OnCreating(SiteSettings ss, WikiModel wikiModel) { if (!ss.CanCreate()) { return(Error.Types.HasNotPermission); } ss.SetColumnAccessControls(wikiModel.Mine()); foreach (var column in ss.Columns .Where(o => !o.CanCreate) .Where(o => !ss.FormulaTarget(o.ColumnName)) .Where(o => !o.Linking)) { switch (column.ColumnName) { case "Title": if (wikiModel.Title_Updated() && (column.DefaultInput.IsNullOrEmpty() || column.DefaultInput.ToString() != wikiModel.Title.Value)) { return(Error.Types.HasNotPermission); } break; case "Body": if (wikiModel.Body_Updated() && (column.DefaultInput.IsNullOrEmpty() || column.DefaultInput.ToString() != wikiModel.Body)) { return(Error.Types.HasNotPermission); } break; case "Comments": if (!ss.GetColumn("Comments").CanUpdate) { return(Error.Types.HasNotPermission); } break; } } return(Error.Types.None); }
public static ResponseCollection FieldResponse( this WikisResponseCollection res, IContext context, SiteSettings ss, WikiModel wikiModel) { var mine = wikiModel.Mine(context: context); ss.EditorColumns .Select(columnName => ss.GetColumn(context: context, columnName: columnName)) .Where(column => column != null) .ForEach(column => { switch (column.Name) { case "WikiId": res.Val( "#Wikis_WikiId", wikiModel.WikiId.ToResponse(context: context, ss: ss, column: column)); break; case "Title": res.Val( "#Wikis_Title", wikiModel.Title.ToResponse(context: context, ss: ss, column: column)); break; case "Body": res.Val( "#Wikis_Body", wikiModel.Body.ToResponse(context: context, ss: ss, column: column)); break; default: break; } }); return(res); }
public static Error.Types OnUpdating( Context context, SiteSettings ss, WikiModel wikiModel) { if (!context.CanUpdate(ss: ss)) { return(Error.Types.HasNotPermission); } ss.SetColumnAccessControls(context: context, mine: wikiModel.Mine(context: context)); foreach (var column in ss.Columns .Where(o => !o.CanUpdate) .Where(o => !ss.FormulaTarget(o.ColumnName))) { switch (column.ColumnName) { case "Title": if (wikiModel.Title_Updated(context: context)) { return(Error.Types.HasNotPermission); } break; case "Body": if (wikiModel.Body_Updated(context: context)) { return(Error.Types.HasNotPermission); } break; case "Comments": if (!ss.GetColumn(context: context, columnName: "Comments").CanUpdate) { return(Error.Types.HasNotPermission); } break; } } return(Error.Types.None); }
public static ResponseCollection FieldResponse( this ResponseCollection res, SiteSettings ss, WikiModel wikiModel) { var mine = wikiModel.Mine(); ss.EditorColumns .Select(o => ss.GetColumn(o)) .Where(o => o != null) .ForEach(column => { switch (column.Name) { case "SiteId": res.Val( "#Wikis_SiteId", wikiModel.SiteId.ToControl(ss, column)); break; case "UpdatedTime": res.Val( "#Wikis_UpdatedTime", wikiModel.UpdatedTime.ToControl(ss, column)); break; case "WikiId": res.Val( "#Wikis_WikiId", wikiModel.WikiId.ToControl(ss, column)); break; case "Ver": res.Val( "#Wikis_Ver", wikiModel.Ver.ToControl(ss, column)); break; case "Title": res.Val( "#Wikis_Title", wikiModel.Title.ToControl(ss, column)); break; case "Body": res.Val( "#Wikis_Body", wikiModel.Body.ToControl(ss, column)); break; case "Comments": res.Val( "#Wikis_Comments", wikiModel.Comments.ToControl(ss, column)); break; case "Creator": res.Val( "#Wikis_Creator", wikiModel.Creator.ToControl(ss, column)); break; case "Updator": res.Val( "#Wikis_Updator", wikiModel.Updator.ToControl(ss, column)); break; case "CreatedTime": res.Val( "#Wikis_CreatedTime", wikiModel.CreatedTime.ToControl(ss, column)); break; default: break; } }); return(res); }
public static string Editor( IContext context, SiteSettings ss, WikiModel wikiModel, bool editInDialog = false) { var invalid = WikiValidators.OnEditing( context: context, ss: ss, wikiModel: wikiModel); switch (invalid) { case Error.Types.None: break; default: return(HtmlTemplates.Error(context, invalid)); } var hb = new HtmlBuilder(); ss.SetColumnAccessControls( context: context, mine: wikiModel.Mine(context: context)); return(editInDialog ? hb.DialogEditorForm( context: context, siteId: wikiModel.SiteId, referenceId: wikiModel.WikiId, action: () => hb .FieldSetGeneral( context: context, ss: ss, wikiModel: wikiModel, editInDialog: editInDialog)) .ToString() : hb.Template( context: context, ss: ss, view: null, verType: wikiModel.VerType, methodType: wikiModel.MethodType, siteId: wikiModel.SiteId, parentId: ss.ParentId, referenceType: "Wikis", title: wikiModel.MethodType == BaseModel.MethodTypes.New ? Displays.New(context: context) : wikiModel.Title.DisplayValue, useTitle: ss.TitleColumns?.Any(o => ss.EditorColumns.Contains(o)) == true, userScript: ss.EditorScripts( context: context, methodType: wikiModel.MethodType), userStyle: ss.EditorStyles( context: context, methodType: wikiModel.MethodType), action: () => hb .Editor( context: context, ss: ss, wikiModel: wikiModel) .Hidden(controlId: "TableName", value: "Wikis") .Hidden(controlId: "Id", value: wikiModel.WikiId.ToString()) .Hidden(controlId: "TriggerRelatingColumns", value: Jsons.ToJson(ss.RelatingColumns)) .Hidden(controlId: "DropDownSearchPageSize", value: Parameters.General.DropDownSearchPageSize.ToString())) .ToString()); }
public static HtmlBuilder TdValue( this HtmlBuilder hb, IContext context, SiteSettings ss, Column column, WikiModel wikiModel) { if (!column.GridDesign.IsNullOrEmpty()) { return(hb.TdCustomValue( context: context, ss: ss, gridDesign: column.GridDesign, wikiModel: wikiModel)); } else { var mine = wikiModel.Mine(context: context); switch (column.Name) { case "SiteId": return(ss.ReadColumnAccessControls.Allowed( context: context, ss: ss, column: column, type: ss.PermissionType, mine: mine) ? hb.Td( context: context, column: column, value: wikiModel.SiteId) : hb.Td( context: context, column: column, value: string.Empty)); case "UpdatedTime": return(ss.ReadColumnAccessControls.Allowed( context: context, ss: ss, column: column, type: ss.PermissionType, mine: mine) ? hb.Td( context: context, column: column, value: wikiModel.UpdatedTime) : hb.Td( context: context, column: column, value: string.Empty)); case "WikiId": return(ss.ReadColumnAccessControls.Allowed( context: context, ss: ss, column: column, type: ss.PermissionType, mine: mine) ? hb.Td( context: context, column: column, value: wikiModel.WikiId) : hb.Td( context: context, column: column, value: string.Empty)); case "Ver": return(ss.ReadColumnAccessControls.Allowed( context: context, ss: ss, column: column, type: ss.PermissionType, mine: mine) ? hb.Td( context: context, column: column, value: wikiModel.Ver) : hb.Td( context: context, column: column, value: string.Empty)); case "Title": return(ss.ReadColumnAccessControls.Allowed( context: context, ss: ss, column: column, type: ss.PermissionType, mine: mine) ? hb.Td( context: context, column: column, value: wikiModel.Title) : hb.Td( context: context, column: column, value: string.Empty)); case "Body": return(ss.ReadColumnAccessControls.Allowed( context: context, ss: ss, column: column, type: ss.PermissionType, mine: mine) ? hb.Td( context: context, column: column, value: wikiModel.Body) : hb.Td( context: context, column: column, value: string.Empty)); case "TitleBody": return(ss.ReadColumnAccessControls.Allowed( context: context, ss: ss, column: column, type: ss.PermissionType, mine: mine) ? hb.Td( context: context, column: column, value: wikiModel.TitleBody) : hb.Td( context: context, column: column, value: string.Empty)); case "Comments": return(ss.ReadColumnAccessControls.Allowed( context: context, ss: ss, column: column, type: ss.PermissionType, mine: mine) ? hb.Td( context: context, column: column, value: wikiModel.Comments) : hb.Td( context: context, column: column, value: string.Empty)); case "Creator": return(ss.ReadColumnAccessControls.Allowed( context: context, ss: ss, column: column, type: ss.PermissionType, mine: mine) ? hb.Td( context: context, column: column, value: wikiModel.Creator) : hb.Td( context: context, column: column, value: string.Empty)); case "Updator": return(ss.ReadColumnAccessControls.Allowed( context: context, ss: ss, column: column, type: ss.PermissionType, mine: mine) ? hb.Td( context: context, column: column, value: wikiModel.Updator) : hb.Td( context: context, column: column, value: string.Empty)); case "CreatedTime": return(ss.ReadColumnAccessControls.Allowed( context: context, ss: ss, column: column, type: ss.PermissionType, mine: mine) ? hb.Td( context: context, column: column, value: wikiModel.CreatedTime) : hb.Td( context: context, column: column, value: string.Empty)); default: return(hb); } } }
public static ErrorData OnCreating( Context context, SiteSettings ss, WikiModel wikiModel, bool api = false) { if (api && (context.ContractSettings.Api == false || !Parameters.Api.Enabled)) { return(new ErrorData(type: Error.Types.InvalidRequest)); } if (!context.CanCreate(ss: ss)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } ss.SetColumnAccessControls(context: context, mine: wikiModel.Mine(context: context)); foreach (var column in ss.Columns .Where(o => !o.CanCreate) .Where(o => !ss.FormulaTarget(o.ColumnName)) .Where(o => !o.Linking)) { switch (column.ColumnName) { case "Title": if (wikiModel.Title_Updated(context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Body": if (wikiModel.Body_Updated(context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Comments": if (!ss.GetColumn(context: context, columnName: "Comments").CanUpdate) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; default: switch (Def.ExtendedColumnTypes.Get(column.Name)) { case "Class": if (wikiModel.Class_Updated( columnName: column.Name, context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Num": if (wikiModel.Num_Updated( columnName: column.Name, context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Date": if (wikiModel.Date_Updated( columnName: column.Name, context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Description": if (wikiModel.Description_Updated( columnName: column.Name, context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Check": if (wikiModel.Check_Updated( columnName: column.Name, context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Attachments": if (wikiModel.Attachments_Updated( columnName: column.Name, context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; } break; } } return(new ErrorData(type: Error.Types.None)); }
public static ErrorData OnCreating( Context context, SiteSettings ss, WikiModel wikiModel, bool api = false) { if (api) { if ((context.ContractSettings.Api == false || !Parameters.Api.Enabled)) { return(new ErrorData(type: Error.Types.InvalidRequest)); } if (context.InvalidJsonData) { return(new ErrorData(type: Error.Types.InvalidJsonData)); } } if (ss.LockedTable()) { return(new ErrorData( type: Error.Types.LockedTable, data: new string[] { ss.LockedTableUser.Name, ss.LockedTableTime.DisplayValue.ToString(context.CultureInfo()) })); } if (!context.CanCreate(ss: ss) || wikiModel.ReadOnly) { return(!context.CanRead(ss: ss) ? new ErrorData(type: Error.Types.NotFound) : new ErrorData(type: Error.Types.HasNotPermission)); } foreach (var column in ss.Columns .Where(o => !o.CanCreate( context: context, ss: ss, mine: wikiModel.Mine(context: context))) .Where(o => !ss.FormulaTarget(o.ColumnName)) .Where(o => !o.Linking)) { switch (column.ColumnName) { case "Title": if (wikiModel.Title_Updated(context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Body": if (wikiModel.Body_Updated(context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Locked": if (wikiModel.Locked_Updated(context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Comments": if (wikiModel.Comments_Updated(context: context)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; default: switch (Def.ExtendedColumnTypes.Get(column.Name)) { case "Class": if (wikiModel.Class_Updated( columnName: column.Name, context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Num": if (wikiModel.Num_Updated( columnName: column.Name, context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Date": if (wikiModel.Date_Updated( columnName: column.Name, context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Description": if (wikiModel.Description_Updated( columnName: column.Name, context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Check": if (wikiModel.Check_Updated( columnName: column.Name, context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; case "Attachments": if (wikiModel.Attachments_Updated( columnName: column.Name, context: context, column: column)) { return(new ErrorData(type: Error.Types.HasNotPermission)); } break; } break; } } return(new ErrorData(type: Error.Types.None)); }