public Object Post(StoreForm param) { if(param == null) throw new ArgumentException("param"); return dynamicFormInterface.StoreForm(param); }
private void pbOpenPluginsStore_Click(object sender, EventArgs e) { // If the options were not initialized, it means we are using the // new plugins store for the first time. Copy values from main // options file if (!PluginsStore.Options.Instance.IsInitialized) { PluginsStore.Options.Instance.PluginsStoreShowInstalled = Options.PluginsStoreShowInstalled; PluginsStore.Options.Instance.PluginsStoreShowIncompatible = Options.PluginsStoreShowIncompatible; PluginsStore.Options.Instance.PluginsStoreShowNew = Options.PluginsStoreShowNew; PluginsStore.Options.Instance.PluginsStoreShowUpdates = Options.PluginsStoreShowUpdates; PluginsStore.Options.Instance.IsInitialized = true; } var pc = new StoreForm(); pc.PluginsUpdated += (storeForm, evt) => { // If plugins list gets updated, refresh the list ReloadPluginsList(); }; // Avoid scanning for new files during Plugins Store usage. EnableNewPluginsWatching(false); pc.ShowDialog(this); EnableNewPluginsWatching(true); // Apply option to show Plugins Store on startup on main options if (Options.DisplayPluginsStoreOnStartup != PluginsStore.Options.Instance.DisplayPluginsStoreOnStartup) { Options.DisplayPluginsStoreOnStartup = PluginsStore.Options.Instance.DisplayPluginsStoreOnStartup.HasValue && PluginsStore.Options.Instance.DisplayPluginsStoreOnStartup.Value; } }
private void editStoreDataButton_Click(object sender, EventArgs e) { if (storeDataGridView.SelectedRows.Count > 0) { int index = storeDataGridView.SelectedRows[0].Index; int number; bool converted = int.TryParse(storeDataGridView[0, index].Value.ToString(), out number); if (!converted) { return; } var stores = from t in controller.Elements where int.Parse(t.Number) == number select t; Store store = stores.First(); StoreForm storeAddForm = new StoreForm(); storeAddForm.numberTextBox.Text = store.Number; storeAddForm.nameTextBox.Text = store.Name; storeAddForm.ownerComboBox.Items.AddRange(companyDataController.Elements.ToArray()); storeAddForm.ownerComboBox.SelectedItem = store.Owner; storeAddForm.trrcTextBox.Text = store.TRRC; storeAddForm.taxCodeTextBox.Text = store.TaxAuthoritiesCode; storeAddForm.codeOfRegionTextBox.Text = store.Address.CodeOfRegion; storeAddForm.postcodeTextBox.Text = store.Address.Postcode; storeAddForm.districtTextBox.Text = store.Address.District; storeAddForm.cityTextBox.Text = store.Address.City; storeAddForm.localityTextBox.Text = store.Address.Locality; storeAddForm.streetTextBox.Text = store.Address.Street; storeAddForm.houseTextBox.Text = store.Address.House; storeAddForm.buildingTextBox.Text = store.Address.Building; storeAddForm.flatTextBox.Text = store.Address.Flat; DialogResult dialogResult = storeAddForm.ShowDialog(this); if (dialogResult == DialogResult.Cancel) { return; } store.Number = storeAddForm.numberTextBox.Text; store.Name = storeAddForm.nameTextBox.Text; store.Owner = companyDataController.Elements.First(item => item.TIN == ((Company)(storeAddForm.ownerComboBox?.SelectedItem)).TIN); store.TRRC = storeAddForm.trrcTextBox.Text; store.TaxAuthoritiesCode = storeAddForm.taxCodeTextBox.Text; store.Address.CodeOfRegion = storeAddForm.codeOfRegionTextBox.Text; store.Address.Postcode = storeAddForm.postcodeTextBox.Text; store.Address.District = storeAddForm.districtTextBox.Text; store.Address.City = storeAddForm.cityTextBox.Text; store.Address.Locality = storeAddForm.localityTextBox.Text; store.Address.Street = storeAddForm.streetTextBox.Text; store.Address.House = storeAddForm.houseTextBox.Text; store.Address.Building = storeAddForm.buildingTextBox.Text; store.Address.Flat = storeAddForm.flatTextBox.Text; controller.UpdateElement(store); storeDataGridView.DataSource = controller.Elements; } }
// ToDo: Add tables datasource support, currently supports only queires public CodeGenerationSection GenerateListForm(StoreForm form, StoreCodeGeneratorContext ctx) { var result = new CodeGenerationSection() { FileName = form.Name + ".cs" }; var sb = new StringBuilder(); var schema = ctx.Schemas[form.Schema]; var dataSource = form.Datasource.Replace(ObjectBuilderConstants.DS_QUERY_START, ""); var query = ctx.Queries[dataSource]; var usingList = new List <string>(); usingList.Add(schema.Namespace); usingList.Add(query.Namespace); usingList = usingList.Distinct().ToList(); sb.AppendLine(@$ "using Platz.SqlForms;"); foreach (var u in usingList) { sb.AppendLine(@$ "using {u};"); } sb.AppendLine(); sb.AppendLine(@$ "namespace {form.Namespace};"); sb.Append(@$ "
private void buttonAddStore_Click(object sender, EventArgs e) { StoreForm form = new StoreForm(currentOperator); if (form.ShowDialog() == DialogResult.OK) { stores.FillUIElementsFromCollection(); } }
public void CreateNewForm() { var form = new StoreForm(); var formDetails = new FormDetails { Form = form }; ApplyNewFormDefaults(formDetails); Model.Forms.Add(formDetails); OpenWindow(form); formDetails.Model.IsDirty = true; }
public void ItemInShopPossibleAddToCart() { HomeForm homeForm = new HomeForm(); Assert.IsTrue(homeForm.IsHomeFormTitleDisplayed); StoreForm storeForm = homeForm.GoToStoreForm(); Assert.IsTrue(storeForm.IsStoreTitleDisplayed); StoreItemForm storeItemForm = storeForm.SelectProduct(); Assert.IsTrue(storeItemForm.IsItemDescriptionDisplayed); Assert.IsTrue(storeItemForm.IsItemPriceDisplayed); Assert.IsTrue(storeItemForm.IsPossibleAddToCart); }
public static void CopyFrom(FormBuilderModel model, StoreForm form) { model.Name = form.Name; model.OriginalName = form.Name; model.Namespace = form.Namespace; model.Validated = form.Validated; model.Schema = form.Schema; model.Datasource = form.Datasource; model.IsListForm = form.IsListForm; model.Fields = form.Fields.OrderBy(x => x.Order).Select(f => new FieldComponentModel(f)).ToList(); var buttons = form.ActionButtons.OrderBy(x => x.Order).Select(f => new FieldComponentModel(f)).ToList(); model.Fields.AddRange(buttons); model.Caption = form.Caption; model.RoutingPath = form.RoutingPath; //model.PageHeaderForm = form.PageHeaderForm?.Name; model.PageHeaderForm = form.PageHeaderForm; model.PageHeaderFormReadOnly = form.PageHeaderFormReadOnly; model.PageParameters = form.PageParameters.OrderBy(x => x.Order).Select(f => new PageParameterModel(f)).ToList(); }
private StoreCodeGeneratorContext GetCodeGenerationContext() { var ctx = new StoreCodeGeneratorContext(); // ToDo: we implement code generation of the fly - all changes made but not save should be reflected // ToDo: schemas should be taken from current model changes, for now we take originals ctx.Schemas = Model.Schemas.ToDictionary(m => m.Schema.Name, m => m.Schema); ctx.Queries = Model.Queries.ToDictionary(m => m.Query.Name, m => m.Query); // forms on the fly generation reflecting not saved changes ctx.Forms = new Dictionary <string, StoreForm>(); ValidationResult.Clear(); foreach (var formDetails in Model.Forms) { StoreForm storeForm = formDetails.Form; var formModel = (formDetails)?.Model; if (formModel != null) { var formsValidations = _formBuilderController.Validate(formModel); formModel.Validated = !formsValidations.Any(v => v.Type == ValidationResultTypes.Error); if (formModel.Validated) { // use changes if pass validation storeForm = formModel.ToStore(); } else { // validation failed - use original form var formItems = formsValidations.Select(r => new ValidationOutputItem(r, ValidationLocationType.Form)).ToList(); ValidationResult.AddRange(formItems); } } ctx.Forms[storeForm.Name] = storeForm; } return(ctx); }
private FormDetails FormBuilderControllerSwitchModel(StoreForm item) { var d = Model.Forms.FirstOrDefault(f => f.Form == item) ?? Model.Forms.FirstOrDefault(f => f.Form.Name == item.Name); var newModel = d.Model == null; if (d.Model == null) { d.Model = new FormBuilderModel(item); } _formBuilderController.SwitchModel(d.Model); UpdateFormBuilder(); _formBuilderController.RefreshDatasources(); if (newModel) { _formBuilderController.SetActive(null); } return(d); }
public StoreForm ToStore() { var src = this; var form = new StoreForm(); form.Name = src.Name; form.Namespace = src.Namespace; form.Validated = src.Validated; form.Schema = src.Schema; form.Datasource = src.Datasource; form.IsListForm = src.IsListForm; form.Fields = src.Fields.Where(f => !IsButton(f.ComponentType)).Select(f => f.ToStore()).ToList(); form.ActionButtons = src.Fields.Where(f => IsButton(f.ComponentType)).Select(f => f.ToStoreButton()).ToList(); form.Caption = src.Caption; form.RoutingPath = src.RoutingPath; form.PageHeaderForm = src.PageHeaderForm; form.PageHeaderFormReadOnly = src.PageHeaderFormReadOnly; form.PageParameters = src.PageParameters.Select(p => p.ToStore()).ToList(); return(form); }
private void addStoreDataButton_Click(object sender, EventArgs e) { StoreForm storeAddForm = new StoreForm(); storeAddForm.ownerComboBox.Items.AddRange(companyDataController.Elements.ToArray()); storeAddForm.ownerComboBox.SelectedItem = storeAddForm.ownerComboBox.Items[0]; DialogResult dialogResult = storeAddForm.ShowDialog(this); if (dialogResult == DialogResult.Cancel) { return; } if (!(Regex.IsMatch(storeAddForm.codeOfRegionTextBox.Text, @"^[0-9]{2}$") && storeAddForm.codeOfRegionTextBox.Text.Length == 2)) { MessageBox.Show(Messages.AddressCodeOfRegionFormatError); return; } var address = new Address(storeAddForm.codeOfRegionTextBox.Text, storeAddForm.postcodeTextBox.Text, storeAddForm.districtTextBox.Text, storeAddForm.cityTextBox.Text, storeAddForm.localityTextBox.Text, storeAddForm.streetTextBox.Text, storeAddForm.houseTextBox.Text, storeAddForm.buildingTextBox.Text, storeAddForm.flatTextBox.Text); var newStore = new Store(storeAddForm.numberTextBox.Text, storeAddForm.nameTextBox.Text, (Company)storeAddForm.ownerComboBox.SelectedItem, storeAddForm.trrcTextBox.Text, storeAddForm.taxCodeTextBox.Text, address); controller.AddElement(newStore); storeDataGridView.DataSource = controller.Elements; }
public StoreForm ReadForm(string json) { var result = new StoreForm(); return(result); }
public FormBuilderModel(StoreForm item) { CopyFrom(this, item); }
//private readonly IProjectLoader _loader; //public FormCodeGenerator(IProjectLoader projectLoader) //{ // _loader = projectLoader; //} public CodeGenerationSection GenerateListFormRazorPage(StoreForm form, StoreCodeGeneratorContext ctx) { var result = new CodeGenerationSection() { FileName = form.Name + ".razor.cs" }; var sb = new StringBuilder(); var psb = new StringBuilder(); var fpsb = new StringBuilder(); var comma = ""; foreach (var p in form.PageParameters) { string pt = ""; switch (p.DataType) { case "int": pt = ":int"; break; } psb.Append($"/{{{p.Name}{pt}}}"); fpsb.Append($"{comma}{p.Name}"); comma = ", "; } sb.AppendLine(@$ "@page " "/{form.RoutingPath}{psb.ToString()}" ""); sb.AppendLine(@$ "@using Platz.SqlForms"); sb.AppendLine(@$ "@using {form.Namespace}"); sb.AppendLine(); if (!string.IsNullOrWhiteSpace(form.Caption)) { sb.AppendLine(@$ "<h1>{form.Caption}</h1>"); sb.AppendLine(); } // Header if (!string.IsNullOrWhiteSpace(form.PageHeaderForm)) { var readOnly = ""; if (form.PageHeaderFormReadOnly) { readOnly = @"ReadOnly=""true"" "; } sb.AppendLine($@"<FormDynamicEditComponent TForm=""{form.PageHeaderForm}"" FormParameters=""GetHeaderParameters()"" {readOnly}/> "); } var serviceParams = string.Join(", ", form.PageParameters.Select(p => p.Name)); sb.AppendLine($@"<FormDataServiceListComponent TForm=""{form.Name}"" ServiceParameters=""@(new object[] {{ {serviceParams} }})"" /> "); sb.AppendLine(@" @code {"); foreach (var p in form.PageParameters) { sb.AppendLine(@$ " [Parameter]"); sb.AppendLine(@$ " public {p.DataType} {p.Name} {{ get; set; }}"); } // Header Parameters if (!string.IsNullOrWhiteSpace(form.PageHeaderForm)) { sb.AppendLine(); sb.AppendLine($@" private FormParameter[] GetHeaderParameters()"); sb.AppendLine($@" {{"); sb.AppendLine($@" return new FormParameter[]"); sb.AppendLine($@" {{"); var headerForm = ctx.Forms[form.PageHeaderForm]; foreach (var headerParameter in headerForm.PageParameters) { var parameter = form.PageParameters.First(p => p.HeaderFormParameterMapping == headerParameter.Name); sb.AppendLine(@$ " new FormParameter(" "{parameter.Name}" ", {parameter.Name}),"); } sb.AppendLine($@" }}"); sb.AppendLine($@" }}"); } sb.AppendLine(@"}"); result.Code = sb.ToString(); return(result); }