public void OpenWindow(IStoreObject item) { if (ActivateWindow(item)) { return; } var w = new EditWindowDetails { StoreObject = item, StoreObjectDetails = FindModelStoreObjectDetails(item), Type = GetStoreObjectType(item) }; Model.EditWindows.Add(w); ActivateWindow(item); }
public void OpenSpecialWindow(string name, EditWindowType type, SpecialWindowContent content = null) { var w = Model.EditWindows.FirstOrDefault(x => x.Type == type && x.StoreObject.Name == name); if (w == null) { w = new EditWindowDetails { StoreObject = new SpecialWindowStoreObject { Name = name, Content = content }, Type = type }; Model.EditWindows.Add(w); } ActiveWindowIndex = GetEditWindows().IndexOf(w); ActiveWindowName = w.StoreObject.Name; }
private void ShowGeneratedFormCode(EditWindowDetails wnd) { // Validate form before generateion var formDetails = wnd.StoreObjectDetails as FormDetails; var formModel = (formDetails)?.Model; var formsValidations = _formBuilderController.Validate(formModel); formModel.Validated = !formsValidations.Any(v => v.Type == ValidationResultTypes.Error); if (!formModel.Validated) { var formItems = formsValidations.Select(r => new ValidationOutputItem(r, ValidationLocationType.Form)).ToList(); ValidationResult.Clear(); ValidationResult.AddRange(formItems); OpenSpecialWindow("Output", EditWindowType.Output); return; } var storeForm = formModel.ToStore(); var ctx = GetCodeGenerationContext(); var code = formModel.IsListForm ? new CodeGenerationSection[] { _formCodeGenerator.GenerateListFormRazorPage(storeForm, ctx), _formCodeGenerator.GenerateListForm(storeForm, ctx) } : new CodeGenerationSection[] { _formCodeGenerator.GenerateEditFormRazorPage(storeForm, ctx), _formCodeGenerator.GenerateEditForm(storeForm, ctx) }; var name = $"Code preview: {ActiveWindow.StoreObject.Name}"; var w = Model.EditWindows.FirstOrDefault(x => x.Type == EditWindowType.CodePreview && x.StoreObject.Name == name); if (w != null) { w.StoreObject = new SpecialWindowStoreObject { Name = name, Content = new CodePreviewSpecialWindowContent(code) }; } OpenSpecialWindow(name, EditWindowType.CodePreview, new CodePreviewSpecialWindowContent(code)); }