Ejemplo n.º 1
0
        public override void Execute()
        {
            NormalEditData pageData  = ViewBag.PageData;
            HtmlAttribute  attribute = pageData.DialogMode ? new HtmlAttribute("data-dialog-action", "close")
        : new HtmlAttribute("data-url", HtmlUtil.GetDynamicRetUrl(Model.CallerInfo));
            HtmlAttribute retAttr     = new HtmlAttribute("data-action", "return");
            bool          showCaption = pageData.ShowCaption;
            string        dataClass   = showCaption ? string.Empty : "class=\"nocaption\"";

            WriteLiteral("\r\n");

            DefineSection("DefaultButtons", () => {
                WriteLiteral("\r\n    <div");

                WriteLiteral(" class=\"text-center\"");

                WriteLiteral(">\r\n");

                WriteLiteral("        ");

                Write(BootcssUtil.Button(pageData.SaveButtonCaption, "btn-submit", BootcssButton.Primary, false));

                WriteLiteral("\r\n");

                WriteLiteral("        ");

                Write(BootcssUtil.Button(pageData.CancelCaption, "m10", BootcssButton.Default, false, attribute, retAttr));

                WriteLiteral("\r\n    </div>\r\n");
            });


            EditObjectModel       model        = Model as EditObjectModel;
            ObjectContainer       mainObject   = model.Object;// HtmlUtil.GetMainObject(Model, ViewBag);
            Tk5NormalTableData    table        = ViewBag.MetaData.Table;
            List <Tk5FieldInfoEx> hiddenFields = table.HiddenList;
            List <Tk5FieldInfoEx> normalFields = table.TableList;

            WriteLiteral("\r\n<form");

            WriteAttribute("action", Tuple.Create(" action=\"", 1510), Tuple.Create("\"", 1547)
                           , Tuple.Create(Tuple.Create("", 1519), Tuple.Create <System.Object, System.Int32>(ViewBag.PageData.FormAction
                                                                                                             , 1519), false)
                           );

            WriteLiteral(" method=\"POST\"");

            WriteLiteral(" id=\"PostForm\"");

            WriteLiteral(" class=\"tk-dataform form-horizontal p5 mb15\"");

            WriteLiteral(" role=\"form\"");

            WriteLiteral(" data-check=\"true\"");

            WriteLiteral(" data-post=\"");

            Write(GetJson(table));

            WriteLiteral("\"");

            WriteLiteral(">\r\n    <div");

            WriteAttribute("id", Tuple.Create(" id=\"", 1689), Tuple.Create("\"", 1710)
                           , Tuple.Create(Tuple.Create("", 1694), Tuple.Create <System.Object, System.Int32>(table.TableName
                                                                                                             , 1694), false)
                           );

            WriteAttribute("class", Tuple.Create(" class=\"", 1711), Tuple.Create("\"", 1806)
                           , Tuple.Create(Tuple.Create("", 1719), Tuple.Create <System.Object, System.Int32>(HtmlUtil.MergeClass("tk-datatable table-row", "column" + table.ColumnCount.ToString())
                                                                                                             , 1719), false)
                           );

            WriteLiteral(">\r\n        <div");

            WriteLiteral(" class=\"hide\"");

            WriteLiteral(">\r\n");


            foreach (Tk5FieldInfoEx field in hiddenFields)
            {
                Write(RenderHidden(mainObject, field, true));
            }

            WriteLiteral("        </div>\r\n        <div");

            WriteLiteral(" class=\"p10 w100p\"");

            WriteLiteral(">\r\n");


            foreach (Tk5FieldInfoEx field in normalFields)
            {
                string fieldString = RenderFieldItem(mainObject, field);


                if (fieldString != null)
                {
                    Write(fieldString);
                }
                else
                {
                    WriteLiteral("                <div");

                    WriteAttribute("class", Tuple.Create(" class=\"", 2399), Tuple.Create("\"", 2472)
                                   , Tuple.Create(Tuple.Create("", 2407), Tuple.Create <System.Object, System.Int32>(HtmlUtil.MergeClass("tk-column form-group", field.LayoutClass())
                                                                                                                     , 2407), false)
                                   );

                    WriteLiteral(">\r\n                    <dl ");

                    Write(dataClass);

                    WriteLiteral(">\r\n");


                    if (showCaption)
                    {
                        WriteLiteral("                            <dt>");

                        Write(field.DisplayName);

                        WriteLiteral("</dt>\r\n");
                    }

                    WriteLiteral("                        <dd>\r\n                            <span");

                    WriteLiteral(" class=\"tk-control\"");

                    WriteLiteral(">\r\n");

                    WriteLiteral("                                ");

                    Write(field.Control(mainObject, model.CodeTables, true));

                    WriteLiteral("\r\n                            </span>\r\n                        </dd>\r\n           " +
                                 "         </dl>\r\n                </div>\r\n");
                }
            }

            WriteLiteral("        </div>\r\n    </div>\r\n</form>\r\n");

            Write(RenderSectionOrDefault("ModuleButtons", "DefaultButtons"));

            WriteLiteral("\r\n");
        }