コード例 #1
0
ファイル: Currency.cs プロジェクト: moayyaed/YetaWF-Modules
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public Task <string> RenderAsync(Decimal?model)
        {
            HtmlBuilder hb = new HtmlBuilder();

            hb.Append($"<div id='{ControlId}' class='yt_currency t_edit y_inline'>");

            YTagBuilder tag = new YTagBuilder("input");

            FieldSetup(tag, Validation ? FieldType.Validated : FieldType.Normal);

            bool rdonly   = PropData.GetAdditionalAttributeValue <bool>("ReadOnly", false);
            bool disabled = PropData.GetAdditionalAttributeValue <bool>("Disabled", false);

            if (disabled)
            {
                tag.Attributes.Add("disabled", "disabled");
            }

            CurrencySetup setup = new CurrencySetup {
                Min      = 0,
                Max      = 999999999.99,
                ReadOnly = rdonly,
            };
            // handle min/max
            RangeAttribute rangeAttr = PropData.TryGetAttribute <RangeAttribute>();

            if (rangeAttr != null)
            {
                setup.Min = (double)rangeAttr.Minimum;
                setup.Max = (double)rangeAttr.Maximum;
            }
            if (model != null)
            {
                tag.MergeAttribute("value", Formatting.FormatAmount((decimal)model));
            }

            hb.Append(tag.ToString(YTagRenderMode.StartTag));

            hb.Append($"</div>");
            Manager.ScriptManager.AddLast($@"new YetaWF_ComponentsHTML.CurrencyEditComponent('{ControlId}', {Utility.JsonSerialize(setup)});");

            return(Task.FromResult(hb.ToString()));
        }
コード例 #2
0
        private void EnableCurrencies()
        {
            var c = new CurrencySetup();

            c.CreateConversions();
        }