private static HtmlBuilder MainCommandExtensions(
     this HtmlBuilder hb, SiteSettings ss, DeptModel deptModel)
 {
     return(hb);
 }
 private static HtmlBuilder EditorExtensions(
     this HtmlBuilder hb, DeptModel deptModel, SiteSettings ss)
 {
     return(hb);
 }
        private static HtmlBuilder FieldSetGeneralColumns(
            this HtmlBuilder hb,
            SiteSettings ss,
            DeptModel deptModel,
            bool preview = false)
        {
            ss.GetEditorColumns().ForEach(column =>
            {
                switch (column.Name)
                {
                case "DeptId":
                    hb.Field(
                        ss,
                        column,
                        deptModel.MethodType,
                        deptModel.DeptId.ToControl(ss, column),
                        column.ColumnPermissionType(),
                        preview: preview);
                    break;

                case "Ver":
                    hb.Field(
                        ss,
                        column,
                        deptModel.MethodType,
                        deptModel.Ver.ToControl(ss, column),
                        column.ColumnPermissionType(),
                        preview: preview);
                    break;

                case "DeptCode":
                    hb.Field(
                        ss,
                        column,
                        deptModel.MethodType,
                        deptModel.DeptCode.ToControl(ss, column),
                        column.ColumnPermissionType(),
                        preview: preview);
                    break;

                case "DeptName":
                    hb.Field(
                        ss,
                        column,
                        deptModel.MethodType,
                        deptModel.DeptName.ToControl(ss, column),
                        column.ColumnPermissionType(),
                        preview: preview);
                    break;

                case "Body":
                    hb.Field(
                        ss,
                        column,
                        deptModel.MethodType,
                        deptModel.Body.ToControl(ss, column),
                        column.ColumnPermissionType(),
                        preview: preview);
                    break;
                }
            });
            if (!preview)
            {
                hb.VerUpCheckBox(deptModel);
            }
            return(hb);
        }
        private static HtmlBuilder Editor(
            this HtmlBuilder hb, SiteSettings ss, DeptModel deptModel)
        {
            var commentsColumn = ss.GetColumn("Comments");
            var commentsColumnPermissionType = commentsColumn.ColumnPermissionType();
            var showComments = ss.ShowComments(commentsColumnPermissionType);
            var tabsCss      = showComments ? null : "max";

            return(hb.Div(id: "Editor", action: () => hb
                          .Form(
                              attributes: new HtmlAttributes()
                              .Id("DeptForm")
                              .Class("main-form confirm-reload")
                              .Action(deptModel.DeptId != 0
                            ? Locations.Action("Depts", deptModel.DeptId)
                            : Locations.Action("Depts")),
                              action: () => hb
                              .RecordHeader(
                                  ss: ss,
                                  baseModel: deptModel,
                                  tableName: "Depts")
                              .Div(
                                  id: "EditorComments", action: () => hb
                                  .Comments(
                                      comments: deptModel.Comments,
                                      column: commentsColumn,
                                      verType: deptModel.VerType,
                                      columnPermissionType: commentsColumnPermissionType),
                                  _using: showComments)
                              .Div(id: "EditorTabsContainer", css: tabsCss, action: () => hb
                                   .EditorTabs(deptModel: deptModel)
                                   .FieldSetGeneral(ss: ss, deptModel: deptModel)
                                   .FieldSet(
                                       attributes: new HtmlAttributes()
                                       .Id("FieldSetHistories")
                                       .DataAction("Histories")
                                       .DataMethod("post"),
                                       _using: deptModel.MethodType != BaseModel.MethodTypes.New)
                                   .MainCommands(
                                       ss: ss,
                                       siteId: 0,
                                       verType: deptModel.VerType,
                                       referenceId: deptModel.DeptId,
                                       updateButton: true,
                                       mailButton: true,
                                       deleteButton: true,
                                       extensions: () => hb
                                       .MainCommandExtensions(
                                           deptModel: deptModel,
                                           ss: ss)))
                              .Hidden(controlId: "BaseUrl", value: Locations.BaseUrl())
                              .Hidden(
                                  controlId: "MethodType",
                                  value: deptModel.MethodType.ToString().ToLower())
                              .Hidden(
                                  controlId: "Depts_Timestamp",
                                  css: "always-send",
                                  value: deptModel.Timestamp)
                              .Hidden(
                                  controlId: "SwitchTargets",
                                  css: "always-send",
                                  value: deptModel.SwitchTargets?.Join(),
                                  _using: !Request.IsAjax()))
                          .OutgoingMailsForm("Depts", deptModel.DeptId, deptModel.Ver)
                          .CopyDialog("Depts", deptModel.DeptId)
                          .OutgoingMailDialog()
                          .EditorExtensions(deptModel: deptModel, ss: ss)));
        }
        public static HtmlBuilder TdValue(
            this HtmlBuilder hb, SiteSettings ss, Column column, DeptModel deptModel)
        {
            if (!column.GridDesign.IsNullOrEmpty())
            {
                return(hb.TdCustomValue(
                           ss: ss,
                           gridDesign: column.GridDesign,
                           deptModel: deptModel));
            }
            else
            {
                var mine = deptModel.Mine();
                switch (column.Name)
                {
                case "DeptId":
                    return(ss.ReadColumnAccessControls.Allowed(column, ss.PermissionType, mine)
                            ? hb.Td(column: column, value: deptModel.DeptId)
                            : hb.Td(column: column, value: string.Empty));

                case "Ver":
                    return(ss.ReadColumnAccessControls.Allowed(column, ss.PermissionType, mine)
                            ? hb.Td(column: column, value: deptModel.Ver)
                            : hb.Td(column: column, value: string.Empty));

                case "DeptCode":
                    return(ss.ReadColumnAccessControls.Allowed(column, ss.PermissionType, mine)
                            ? hb.Td(column: column, value: deptModel.DeptCode)
                            : hb.Td(column: column, value: string.Empty));

                case "Dept":
                    return(ss.ReadColumnAccessControls.Allowed(column, ss.PermissionType, mine)
                            ? hb.Td(column: column, value: deptModel.Dept)
                            : hb.Td(column: column, value: string.Empty));

                case "Body":
                    return(ss.ReadColumnAccessControls.Allowed(column, ss.PermissionType, mine)
                            ? hb.Td(column: column, value: deptModel.Body)
                            : hb.Td(column: column, value: string.Empty));

                case "Comments":
                    return(ss.ReadColumnAccessControls.Allowed(column, ss.PermissionType, mine)
                            ? hb.Td(column: column, value: deptModel.Comments)
                            : hb.Td(column: column, value: string.Empty));

                case "Creator":
                    return(ss.ReadColumnAccessControls.Allowed(column, ss.PermissionType, mine)
                            ? hb.Td(column: column, value: deptModel.Creator)
                            : hb.Td(column: column, value: string.Empty));

                case "Updator":
                    return(ss.ReadColumnAccessControls.Allowed(column, ss.PermissionType, mine)
                            ? hb.Td(column: column, value: deptModel.Updator)
                            : hb.Td(column: column, value: string.Empty));

                case "CreatedTime":
                    return(ss.ReadColumnAccessControls.Allowed(column, ss.PermissionType, mine)
                            ? hb.Td(column: column, value: deptModel.CreatedTime)
                            : hb.Td(column: column, value: string.Empty));

                case "UpdatedTime":
                    return(ss.ReadColumnAccessControls.Allowed(column, ss.PermissionType, mine)
                            ? hb.Td(column: column, value: deptModel.UpdatedTime)
                            : hb.Td(column: column, value: string.Empty));

                default: return(hb);
                }
            }
        }
Пример #6
0
        public static ErrorData OnCreating(
            Context context, SiteSettings ss, DeptModel deptModel, 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: deptModel.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 "DeptCode":
                    if (deptModel.DeptCode_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "DeptName":
                    if (deptModel.DeptName_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "Body":
                    if (deptModel.Body_Updated(context: context, column: column))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                case "Comments":
                    if (deptModel.Comments_Updated(context: context))
                    {
                        return(new ErrorData(type: Error.Types.HasNotPermission));
                    }
                    break;

                default:
                    switch (Def.ExtendedColumnTypes.Get(column.Name))
                    {
                    case "Class":
                        if (deptModel.Class_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;

                    case "Num":
                        if (deptModel.Num_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;

                    case "Date":
                        if (deptModel.Date_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;

                    case "Description":
                        if (deptModel.Description_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;

                    case "Check":
                        if (deptModel.Check_Updated(
                                columnName: column.Name,
                                context: context,
                                column: column))
                        {
                            return(new ErrorData(type: Error.Types.HasNotPermission));
                        }
                        break;

                    case "Attachments":
                        if (deptModel.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));
        }
Пример #7
0
 public static Error.Types OnDeleting(SiteSettings ss, DeptModel deptModel)
 {
     return(ss.CanDelete()
         ? Error.Types.None
         : Error.Types.HasNotPermission);
 }