コード例 #1
0
    public Task <Form> GetConfigForm(JObject config, string locale, CancellationToken cancellationToken = default)
    {
        var fakeConfig = ParseConfig(config);

        var form     = new Form();
        var fieldset = new Fieldset();

        // Maybe a decimal type field would be better?
        var fakeBTCBalance = new TextField("BTC Balance", "BTCBalance", fakeConfig?.BTCBalance.ToString(), true,
                                           "Enter the amount of BTC you want to have.");
        var fakeLTCBalance = new TextField("LTC Balance", "LTCBalance", fakeConfig?.LTCBalance.ToString(), true,
                                           "Enter the amount of LTC you want to have.");
        var fakeEURBalance = new TextField("EUR Balance", "EURBalance", fakeConfig?.EURBalance.ToString(), true,
                                           "Enter the amount of EUR you want to have.");
        var fakeUSDBalance = new TextField("USD Balance", "USDBalance", fakeConfig?.USDBalance.ToString(), true,
                                           "Enter the amount of USD you want to have.");

        fieldset.Label = "Your fake balances";
        fieldset.Fields.Add(fakeBTCBalance);
        fieldset.Fields.Add(fakeLTCBalance);
        fieldset.Fields.Add(fakeEURBalance);
        fieldset.Fields.Add(fakeUSDBalance);
        form.Fieldsets.Add(fieldset);

        return(Task.FromResult(form));
    }
コード例 #2
0
        public static SqlBuilder AddAggregatorTokens(this SqlBuilder builder, AggregatorSqlBuilderSettings settings, int recordCount)
        {
            if (builder is null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (settings is null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            if (settings.TableName is null)
            {
                throw new ArgumentException("TableName property required", nameof(settings));
            }

            if (settings.FieldNames is null)
            {
                throw new ArgumentException("FieldNames property required", nameof(settings));
            }

            var fields = new Fieldset(settings.FieldNames);

            builder.SetToken("TableName", settings.TableName);
            builder.SetToken("StoreTableName", settings.StoreTableName ?? $"{settings.TableName}_store");
            builder.SetToken("ColumnList", fields.ToFieldListSql());
            builder.SetToken("AliasedColumnList", fields.ToAliasedFieldListSql());
            builder.SetToken("UpdateClause", settings.UpdateStatements == null ? "" : $"ON DUPLICATE KEY UPDATE {settings.UpdateStatements}");

            builder.SetToken("ValuesList", fields.ToValuesParameterListSql(recordCount));

            return(builder);
        }
コード例 #3
0
        public async Task <IActionResult> Edit(string id, Fieldset fieldset)
        {
            if (id != fieldset.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    fieldset.UpdateDate = DateTime.Now;
                    fieldset.UpdatedBy  = User.Identity.Name;
                    _context.Update(fieldset);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TabExists(fieldset.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Edit", "Forms", new { id = fieldset.FormId }));
            }
            ViewData["FormId"] = new SelectList(_context.Forms.OrderBy(f => f.Name).ToList(), "Id", "Name", fieldset.FormId);

            return(View(fieldset));
        }
コード例 #4
0
        // GET: Fields/Create
        public IActionResult Create(string formId)
        {
            var fieldset = new Fieldset();

            ViewData["FormId"] = new SelectList(_context.Forms.OrderBy(f => f.Name).ToList(), "Id", "Name");
            fieldset.FormId    = formId;
            ViewBag.FormIdRef  = formId;
            return(View(fieldset));
        }
コード例 #5
0
ファイル: CatListLayer.cs プロジェクト: JeffESchmitz/CatApp
        public override void Load(Dictionary<string, string> parameters)
        {
            //			var catList = new CatRepository ().GetCats ();
            catRepo = new CatRepository ();
            var catList = catRepo.GetCats ();

            if (parameters.ContainsKey ("textField1")) {
                if (catList.Exists (o => o.Name == parameters ["textField1"])) {
                    iApp.Session ["Cat"] = catList.Single (o => o.Name == parameters ["textField1"]);
                    this.CancelLoadAndNavigate ("CatDetail".AppendPath (parameters ["textField1"]));
                    return;
                } else {
                    this.Title = "<bad cat>";
                }
            }

            //			Title = "Cats";
            var menu = new iMenu ();
            menu.Header = "Items";

            foreach (var c in catList) {
                menu.Items.Add (new iItem () {
                    Text = c.Name,
                    Subtext = c.Breed.ToString(),
                    Link = new Link ("CatDetail".AppendPath(c.Name))
                });
            }

            this.Items.Add (menu);

            var fieldSet = new Fieldset ();
            fieldSet.Header = "Fields";

            //			fieldSet.Fields.Add (new TextField ("textField1") {
            //				Label =  "TF1",
            //				Text = parameters.ContainsKey("textField1") ? parameters ["textField1"] : string.Empty
            //			});

            var textField = (new TextField ("textField1") {
                Label =  "TF1",
                Text = parameters.ContainsKey("textField1") ? parameters ["textField1"] : string.Empty
            });

            textField.Validate = (value, errorMsg, args) => {
                if (!catList.Exists (o => o.Name == value)) {
                    errorMsg = "bad cat";
                    textField.BrokenRules.Add("bad cat");
                }
            };

            fieldSet.Fields.Add (textField);

            this.Items.Add (fieldSet);
            this.ActionButtons.Add (new SubmitButton ("Save", "CatList"));
        }
コード例 #6
0
        internal void DoBind(Dictionary <string, PreBindingArgs> map)
        {
            int _i     = 0;
            var keyArr = new string[map.Keys.Count];

            foreach (string str in map.Keys)
            {
                keyArr[_i] = str;
                _i++;
            }
            for (int i = 0; i < keyArr.Length; i++)
            {
                string         str         = keyArr[i];
                PreBindingArgs bindingArgs = map[str];
                Fieldset       fieldset    = Provider.Request <FieldLocatorService>().LocateName(bindingArgs.FieldSet_Name);

                if (bindingArgs.IsGroup)
                {
                    Type localType = bindingArgs.TargetVariable_Type;
                    for (int j = 1; j <= bindingArgs.GroupSize; j++)
                    {
                        var fs = Owner.LocateField.LocateName(map[keyArr[i + j]].FieldSet_Name);
                        for (int k = 0; k < fieldset.GroupFieldInfo.Count; k++)
                        {
                            fs.GroupFieldInfo.Add(fieldset.GroupFieldInfo[k]);
                        }

                        fs.GroupFieldInfo.Add(bindingArgs.TargetVariable_FieldInfo);

                        Owner.Binder.BindToVariable(map[keyArr[i + j]].FieldSet_Name, map[keyArr[i + j]].TargetVariable_Name);

                        // Fix posX of fields/labels
                        var offX = (fs.GroupFieldInfo.Count * 10);
                        fs.BackPanel.Location = new Point(fs.BackPanel.Location.X + offX, fs.BackPanel.Location.Y);
                        fs.BackPanel.Width   -= offX;
                        fs.Field.Location     = new Point(fs.Field.Location.X - offX, fs.Field.Location.Y);
                    }

                    continue;
                }
                else
                {
                    Owner.Binder.BindToVariable(bindingArgs.FieldSet_Name, bindingArgs.TargetVariable_Name);
                }

                if (fieldset.Field  is ComboBox cb)
                {
                    cb.SelectedIndex = -1;
                }

                bindingArgs.Post?.Invoke(Owner.LocateField.LocateLast());
            }
        }
コード例 #7
0
ファイル: QueryContext.cs プロジェクト: moayyaed/saule
        /// <inheritdoc/>
        public override string ToString()
        {
            var result = new List <string>
            {
                Pagination?.ToString(),
                Sort?.ToString(),
                Filter?.ToString(),
                Include?.ToString(),
                Fieldset?.ToString()
            };

            return(string.Join("&", result.Where(c => !string.IsNullOrEmpty(c))));
        }
        private static Fieldset GetFieldListFilteredByCategory(string categoryFilter, Fieldset fields)
        {
            if (string.IsNullOrWhiteSpace(categoryFilter))
            {
                return(fields);
            }

            Fieldset categoryFields;

            if (FieldsByCategory.TryGetValue(categoryFilter, out categoryFields))
            {
                fields = new Fieldset(fields.Intersect(categoryFields));
            }

            return(fields);
        }
コード例 #9
0
        public async Task <IActionResult> Create(Fieldset fieldset, string FormIdRef)
        {
            if (ModelState.IsValid)
            {
                fieldset.CreateDate = DateTime.Now;
                fieldset.CreatedBy  = User.Identity.Name;
                fieldset.UpdateDate = DateTime.Now;
                fieldset.UpdatedBy  = User.Identity.Name;
                _context.Add(fieldset);
                await _context.SaveChangesAsync();

                if (FormIdRef != null)
                {
                    string url = "/Forms/Edit/" + FormIdRef + "#tab_1_2";
                    return(Redirect(url));
                }
                return(RedirectToAction("Index"));
            }
            ViewData["FormId"] = new SelectList(_context.Forms.OrderBy(f => f.Name).ToList(), "Name", fieldset.FormId);

            return(View(fieldset));
        }
コード例 #10
0
        protected void OutputForm(iLayer layer, Fieldset fieldset)
        {
            System.Console.WriteLine();

            Link link = layer.ActionButtons.FirstOrDefault(b => b.Action == iFactr.Core.Controls.Button.ActionType.Submit);

            if (link == null)
            {
                return;
            }
            link = (Link)link.Clone();

            layer.FieldValuesRequested -= GetFieldValues;
            layer.FieldValuesRequested += GetFieldValues;

            var parameters = layer.GetFieldValues();

            if (link.Parameters == null)
            {
                link.Parameters = parameters;
            }
            else
            {
                foreach (var key in parameters.Keys)
                {
                    link.Parameters[key] = parameters[key];
                }
            }

            if (link.RequestType == RequestType.ClearPaneHistory)
            {
                ClearHistory();
            }

            iApp.Navigate(link);
        }
コード例 #11
0
        public static SqlBuilder AddEslrSaverTokens(this SqlBuilder builder, EslrSaverSqlBuilderSettings settings)
        {
            if (builder is null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (settings is null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            if (settings.FieldNames is null)
            {
                throw new ArgumentException("FieldNames property required", nameof(settings));
            }

            var fields = new Fieldset(settings.FieldNames);

            builder.SetToken("ColumnList", fields.ToFieldListSql());
            builder.SetToken("AliasedParameterList", fields.ToAliasedParameterListSql());

            return(builder);
        }
コード例 #12
0
        private string GenerateFormGroup(
            Label label,
            Hint hint,
            ErrorMessage errorMessage,
            FormGroup formGroup,
            Fieldset fieldset,
            GenerateFormGroupElement generateElement)
        {
            var haveError = errorMessage != null;

            string describedBy = null;

            var attributes = new AttributeDictionary()
                             .MergeAttribute("class", formGroup?.Classes);

            var contentBuilder = new HtmlContentBuilder();

            if (label != null)
            {
                var labelTagBuilder = BuildLabel(_componentGenerator, label);
                contentBuilder.AppendHtml(labelTagBuilder);
            }

            if (hint != null)
            {
                var hintTagBuilder = BuildHint(_componentGenerator, hint);
                contentBuilder.AppendHtml(hintTagBuilder);

                AppendToDescribedBy(ref describedBy, hint.Id);
            }

            if (errorMessage != null)
            {
                var errorMessageTagBuilder = BuildErrorMessage(_componentGenerator, errorMessage);
                contentBuilder.AppendHtml(errorMessageTagBuilder);

                AppendToDescribedBy(ref describedBy, errorMessage.Id);
            }

            var element = generateElement(haveError, describedBy);

            contentBuilder.AppendHtml(element);

            IHtmlContent content = contentBuilder;

            if (fieldset != null)
            {
                AppendToDescribedBy(ref describedBy, fieldset.DescribedBy);

                content = _componentGenerator.GenerateFieldset(
                    describedBy,
                    role: fieldset.Role,
                    fieldset.Legend?.IsPageHeading ?? ComponentGenerator.FieldsetLegendDefaultIsPageHeading,
                    legendContent: TextOrHtmlHelper.GetHtmlContent(
                        fieldset.Legend?.Text,
                        fieldset.Legend?.Html),
                    legendAttributes: new AttributeDictionary()
                    .MergeAttribute("class", fieldset.Legend?.Classes),
                    content: contentBuilder,
                    attributes: fieldset.Attributes.ToAttributesDictionary()
                    .MergeAttribute("class", fieldset.Classes));
            }

            return(_componentGenerator.GenerateFormGroup(
                       haveError,
                       content,
                       attributes)
                   .RenderToString());
        }
コード例 #13
0
 protected override void When()
 {
     element = Document.Navigation.GetCurrentPage <GenericElementPage>().Document.Fieldset(elementId);
 }
コード例 #14
0
ファイル: CarList.cs プロジェクト: JeffESchmitz/listr
        public override void Load(Dictionary<string, string> parameters)
        {
            base.Load(parameters);

            Title = "List";

            //// add items to an iList
            //iList list = new iList();

            //var menu = new iMenu();
            //menu.Header = "Items";

            //this.Items.Add(menu);

            carRepository = new CarRepository();
            var carList = carRepository.GetCars();
            // test comment

            if (parameters.ContainsKey(TEXTFIELD1))
            {
                if (carList.Exists(o => o.Name == parameters[TEXTFIELD1]))
                {
                    iApp.Session[CAR] = carList.Single(o => o.Name == parameters[TEXTFIELD1]);
                    this.CancelLoadAndNavigate(CAR_DETAIL.AppendPath(parameters[TEXTFIELD1]));
                    return;
                }
                     else
                    this.Title = BAD_CAR;
            }

            // Make the menu
            var menu = new iMenu();
            menu.Header = ITEMS;

            // Add the cars to the list
            foreach (var car in carList)
            {
                menu.Items.Add(new iItem()
                {
                    Text = car.Name,
                    Subtext = car.VehicleClass.ToString(),
                    Link = new iFactr.Core.Controls.Link(CAR_DETAIL.AppendPath(car.Name))
                });
            }
            this.Items.Add(menu);

            var fieldSet = new Fieldset();
            fieldSet.Header = FIELDS;

            var textField = (new TextField(TEXTFIELD1)
            {
                Label = TF1,
                Text = parameters.ContainsKey(TEXTFIELD1) ? parameters[TEXTFIELD1] : string.Empty
            });

            // Validation
            textField.Validate = (value, errorMsg, args) =>
            {
                if (!carList.Exists(o => o.Name == value))
                {
                    errorMsg = BAD_CAR;
                    textField.BrokenRules.Add(BAD_CAR);
                }
            };
            fieldSet.Fields.Add(textField);
            this.Items.Add(fieldSet);
            this.ActionButtons.Add(new SubmitButton(SAVE, CAR_LIST));
        }
コード例 #15
0
ファイル: FieldsetTest.cs プロジェクト: tbossi/Tags
 public void SetUp()
 {
     _tag = new Fieldset();
 }