This commit is contained in:
skidoodle 2024-03-13 00:33:46 +01:00
commit e124a47765
19374 changed files with 9806149 additions and 0 deletions

View file

@ -0,0 +1,33 @@
using System.Collections.Generic;
using System.Web.Routing;
namespace Kreta.Web.Helpers.Grid
{
public class ApiUrlBuilder
{
private readonly string Controller = nameof(Controller).ToLower();
private readonly string Action = nameof(Action).ToLower();
public string Route { get; private set; }
public RouteValueDictionary RouteValues { get; private set; }
public ApiUrlBuilder(string controller, string action, IDictionary<string, object> parameters = null, string route = Constants.RouteKey.ActionApi)
{
var routeValues = new RouteValueDictionary
{
{ Controller, controller },
{ Action, action }
};
if (parameters != null)
{
foreach (var item in parameters)
{
routeValues.Add(item.Key, item.Value);
}
}
RouteValues = routeValues;
Route = route;
}
}
}

View file

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Web.Mvc;
using Kendo.Mvc.UI;
namespace Kreta.Web.Helpers
{
public static class AutoCompleteExtensions
{
public static Kendo.Mvc.UI.Fluent.AutoCompleteBuilder KretaAutoCompleteFor<TModel, TProperty>(this HtmlHelper<TModel> helper, System.Linq.Expressions.Expression<Func<TModel, TProperty>> expression, string id = "", string className = "")
{
var inputName = ExpressionHelper.GetExpressionText(expression);
var name = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(inputName);
var val = ModelMetadata.FromLambdaExpression(expression, helper.ViewData).Model;
if (helper.ViewData.ModelState[name] != null && helper.ViewData.ModelState[name].Errors.Count > 0)
className = string.Format("{0} input-validation-error", className);
var autocomplete = helper.Kendo().AutoCompleteFor(expression)
.Filter(FilterType.Contains)
.HighlightFirst(true).DataTextField("Text");
if (!string.IsNullOrWhiteSpace(className) || !string.IsNullOrWhiteSpace(id))
{
var attributes = new Dictionary<string, object>();
if (!string.IsNullOrWhiteSpace(className))
attributes.Add("class", className.Trim());
if (!string.IsNullOrWhiteSpace(id))
attributes.Add("id", id);
//attributes.Add("style", "height:17px");
autocomplete.HtmlAttributes(attributes);
}
return autocomplete;
}
}
}

View file

@ -0,0 +1,24 @@
namespace Kreta.Web.Helpers
{
public class BootsrapHelper
{
public static string GetSizeClasses(int size, bool allSizeSame = false, bool addOffset = false)
{
int smallSize = allSizeSame ? size : size * 2 > 12 ? 12 : size * 2;
return string.Format("col-xs-{0} col-sm-{0} col-md-{1} {2}", smallSize, size, addOffset ? GetOffsetClasses(size, smallSize, allSizeSame) : "");
}
private static string GetOffsetClasses(int size, int smallSize, bool allSizeSame = false)
{
return string.Format("col-xs-offset-{0} col-sm-offset-{0} col-md-offset-{1}", 12 - smallSize, 12 - size);
}
public static string GetOffsetSizeClasses(int size, bool allSizeSame = false)
{
int smallSize = allSizeSame ? size : size * 2 > 12 ? 12 : size * 2;
return string.Format("col-xs-offset-{0} col-sm-offset-{0} col-md-offset-{1}", smallSize, size);
}
}
}

View file

@ -0,0 +1,125 @@
using System;
using System.Collections.Generic;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
using Kreta.Framework;
using Kreta.Resources;
using Kreta.Web.Helpers.Modal;
namespace Kreta.Web.Helpers
{
public static class ButtonExtensions
{
private const string ObsoleteButtonExtensions = "Ne használd, a text-es KretaButton metódust használd helyette!";
[Obsolete(ObsoleteButtonExtensions)]
public static ButtonBuilder KretaButton(
this HtmlHelper helper,
string name,
int content,
bool enabled = true,
string spriteCssClass = null,
string icon = null,
string imageUrl = null,
IDictionary<string, object> htmlAttributes = null,
string clickEventName = null)
{
var type = "button";
var text = StringResourcesUtil.GetString(content);
var button = helper.KretaButton(name, text, type, enabled, spriteCssClass, icon, imageUrl, htmlAttributes, clickEventName);
return button;
}
[Obsolete(ObsoleteButtonExtensions)]
public static ButtonBuilder KretaButton(
this HtmlHelper helper,
string name,
int content,
string type = "button",
bool enabled = true,
string spriteCssClass = null,
string icon = null,
string imageUrl = null,
IDictionary<string, object> htmlAttributes = null,
string clickEventName = null)
{
var text = StringResourcesUtil.GetString(content);
var button = helper.KretaButton(name, text, type, enabled, spriteCssClass, icon, imageUrl, htmlAttributes, clickEventName);
return button;
}
public static ButtonBuilder KretaButton(this HtmlHelper helper, ModalButtonModel modalButtonModel, string type = "button")
{
var button = helper.KretaButton(
modalButtonModel.Name,
modalButtonModel.Text,
type,
modalButtonModel.Enabled,
modalButtonModel.SpriteCssClass,
modalButtonModel.Icon,
modalButtonModel.ImageUrl,
null,
modalButtonModel.EventName);
return button;
}
public static ButtonBuilder KretaButton(
this HtmlHelper helper,
string name,
string text,
string type = "button",
bool enabled = true,
string spriteCssClass = null,
string icon = null,
string imageUrl = null,
IDictionary<string, object> htmlAttributes = null,
string clickEventName = null)
{
var button = helper.Kendo().Button()
.Name(name)
.Content(text)
.Enable(enabled)
.SpriteCssClass(spriteCssClass)
.Icon(icon)
.ImageUrl(imageUrl);
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
htmlAttributes.Add("type", type);
button.HtmlAttributes(htmlAttributes);
if (clickEventName != null)
{
button.Events(x => x.Click(clickEventName));
}
return button;
}
public static ButtonBuilder KretaSaveButton(
this HtmlHelper helper,
string name,
string clickEventName = null)
{
var button = helper.Kendo().Button()
.Name(name)
.Content(CommonResource.Mentes);
var htmlAttributes = new Dictionary<string, object> { { "style", "background-color:#54a5d1" } };
htmlAttributes.Add("type", "button");
button.HtmlAttributes(htmlAttributes);
if (clickEventName != null)
{
button.Events(x => x.Click(clickEventName));
}
return button;
}
}
}

View file

@ -0,0 +1,50 @@
using System.Collections;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
using Kreta.BusinessLogic.Utils;
namespace Kreta.Web.Helpers
{
public static class ChartExtensions
{
public static ChartBuilder<object> KretaChart<T>(
this HtmlHelper<T> helper,
string name,
int title,
ChartLegendPosition legendPos,
IEnumerable seriesCol,
IEnumerable categoryAxisCol,
int labelRotation = -90,
bool majorGridLinesVisible = false,
int valueAxisMax = 5,
bool valueAxisVisible = false,
bool tooltipVisible = false,
string tooltipFormat = "{ 0:0.00}")
{
var chart = helper.Kendo().Chart()
.Name(name)
.Title(StringResourcesUtils.GetString(title))
.Legend(legend => legend.Position(legendPos))
.ChartArea(chartArea => chartArea.Background("transparent"))
.Series(series => series
.Column(seriesCol)
.Color("#406a7c")
)
.CategoryAxis(axis => axis
.Categories(categoryAxisCol)
.Labels(labels => labels.Rotation(labelRotation))
.MajorGridLines(lines => lines.Visible(majorGridLinesVisible))
)
.ValueAxis(axis => axis
.Numeric()
.Line(line => line.Visible(valueAxisVisible))
)
.Tooltip(tooltip => tooltip
.Visible(tooltipVisible)
.Format(tooltipFormat)
);
return chart;
}
}
}

View file

@ -0,0 +1,187 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
namespace Kreta.Web.Helpers
{
public static class CheckBoxExtensions
{
public static CheckBoxBuilder KretaCheckBox(this HtmlHelper helper, string name, string label, bool check, bool enabled = true, IDictionary<string, object> htmlAttributes = null)
{
CheckBoxBuilder checkBox = helper.Kendo().CheckBox()
.Name(name)
.Label(label)
.Checked(check)
.Enable(enabled);
if (htmlAttributes != null)
{
checkBox.HtmlAttributes(htmlAttributes);
}
return checkBox;
}
public static CheckBoxBuilder KretaCheckBoxFor<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> expression, IDictionary<string, object> htmlAttributes = null, bool renderLabelToRight = false, string customDisplayName = null)
{
ModelMetadata metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
var displayName = !string.IsNullOrWhiteSpace(customDisplayName) ? customDisplayName : metadata.DisplayName;
if (!renderLabelToRight)
{
htmlAttributes.Add("data-labelmsg", displayName);
}
else
{
//NOTE: Erre azért van szükség, mert a körülötte lévő div nem veszi fel a label méretét, mert fix 5px-re van állítva és emiatt belecsúszik az alatta lévő!
if (htmlAttributes.ContainsKey("class"))
{
htmlAttributes["class"] += " disableCheckBoxFixHeight";
}
else
{
htmlAttributes.Add("class", "disableCheckBoxFixHeight");
}
}
switch (expression.ReturnType.Name)
{
case "Boolean":
CheckBoxBuilder checkbox = helper.Kendo()
.CheckBoxFor(Expression.Lambda<Func<TModel, bool>>(expression.Body, expression.Parameters))
.Label(renderLabelToRight ? displayName : string.Empty) /*Ne generáljon ki label-t az input mögé, ha balra akarjuk a szöveget, azt a RenderWithName-el kell*/
.HtmlAttributes(htmlAttributes);
return checkbox;
default:
CheckBoxBuilder nullableCheckbox = helper.Kendo()
.CheckBoxFor(Expression.Lambda<Func<TModel, bool?>>(expression.Body, expression.Parameters))
.Label(renderLabelToRight ? displayName : string.Empty) /*Ne generáljon ki label-t az input mögé, ha balra akarjuk a szöveget, azt a RenderWithName-el kell*/
.HtmlAttributes(htmlAttributes);
return nullableCheckbox;
}
}
public static MvcHtmlString RenderSearchPanel(this CheckBoxBuilder helper)
{
string labelMsg = "";
foreach (KeyValuePair<string, object> item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
{
labelMsg = item.Value.ToString();
}
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("<div class=\"searchInputRowHeight\"><div>");
stringBuilder.Append("<label class=\"searchPanelInputLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
stringBuilder.Append("</div><div>");
stringBuilder.Append(helper.ToHtmlString());
stringBuilder.Append("</div></div>");
return new MvcHtmlString(stringBuilder.ToString());
}
public static MvcHtmlString RenderSearchPanelSideBar(this CheckBoxBuilder helper)
{
string labelMsg = "";
foreach (KeyValuePair<string, object> item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
{
labelMsg = item.Value.ToString();
}
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("<div class=\"searchPanelRow\">");
stringBuilder.Append("<div class=\"searchPanelRowTitle\">");
stringBuilder.Append("<label class=\"searchPanelLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
stringBuilder.Append("</div>");
stringBuilder.Append("<div class=\"searchPanelRowValue\">");
stringBuilder.Append(helper.ToHtmlString());
stringBuilder.Append("</div>");
stringBuilder.Append("</div>");
return new MvcHtmlString(stringBuilder.ToString());
}
public static MvcHtmlString RenderWithName(this CheckBoxBuilder helper, int labelWidth = 6, int inputWidth = 6, string customClass = "", string tooltipResource = null, string labelMsg = null, bool allSizeSame = false)
{
if (string.IsNullOrWhiteSpace(labelMsg))
{
foreach (KeyValuePair<string, object> item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
{
labelMsg = item.Value.ToString();
}
}
}
var stringBuilder = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
{
AddRenderWithNameBeginingFrame(stringBuilder, labelWidth, inputWidth, helper.ToComponent().Name, labelMsg, customClass, allSizeSame);
}
else
{
AddRenderWithNameTooltipBeginingFrame(stringBuilder, labelWidth, inputWidth, helper.ToComponent().Name, labelMsg, customClass, tooltipResource, allSizeSame);
}
stringBuilder.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(stringBuilder);
return new MvcHtmlString(stringBuilder.ToString());
}
public static MvcHtmlString RenderWithName(this CheckBoxBuilder helper, string label, int labelWidth = 6, int inputWidth = 6, string tooltipResource = null)
{
var stringBuilder = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
{
AddRenderWithNameBeginingFrame(stringBuilder, labelWidth, inputWidth, helper.ToComponent().Name, label, string.Empty, false);
}
else
{
AddRenderWithNameTooltipBeginingFrame(stringBuilder, labelWidth, inputWidth, helper.ToComponent().Name, label, string.Empty, tooltipResource, false);
}
stringBuilder.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(stringBuilder);
return new MvcHtmlString(stringBuilder.ToString());
}
private static void AddRenderWithNameBeginingFrame(StringBuilder stringBuilder, int labelWidth, int inputWidth, string controlName, string labelMsg, string customClass, bool allSizeSame)
{
stringBuilder.AppendFormat("<div class=\"{0} {1} \">", BootsrapHelper.GetSizeClasses(labelWidth, allSizeSame), customClass);
stringBuilder.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}</label>", controlName, labelMsg);
stringBuilder.AppendFormat("</div><div class=\"{0} {1}\">", BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame), customClass);
}
private static void AddRenderWithNameTooltipBeginingFrame(StringBuilder stringBuilder, int labelWidth, int inputWidth, string controlName, string labelMsg, string customClass, string tooltipResource, bool allSizeSame)
{
stringBuilder.AppendFormat("<div class=\"{0} {1} kretaLabelTooltip \">", BootsrapHelper.GetSizeClasses(labelWidth, allSizeSame), customClass);
stringBuilder.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}", controlName, labelMsg);
stringBuilder.Append("&nbsp;<img class='kretaLabelTooltipImg' />");
stringBuilder.AppendFormat("<span class=\"kretaLabelTooltipText\">{0}</span>", tooltipResource);
stringBuilder.Append("</label>");
stringBuilder.AppendFormat("</div><div class=\"{0} {1}\">", BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame), customClass);
}
private static void AddRenderWithNameCloseingFrame(StringBuilder stringBuilder)
{
stringBuilder.Append("</div>");
}
}
}

View file

@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.Mvc;
using Kreta.BusinessLogic.HelperClasses;
namespace Kreta.Web.Helpers
{
public static class CheckBoxListExtension
{
public static MvcHtmlString KretaCheckBoxList(this HtmlHelper helper, string id, List<SelectListItem> items, object htmlAttributes = null, bool isPostAsArray = false, string onClickEvent = null)
{
TagBuilder ultag = new TagBuilder("ul");
ultag.AddCssClass("noUlLiButton");
int cnt = 0;
foreach (SelectListItem item in items)
{
cnt++;
string generatedId = id + cnt.ToString();
StringBuilder sb = new StringBuilder();
sb.Append("<li>");
sb.AppendFormat($"<input type=\"checkbox\" name=\"{{0}}", id);
if (isPostAsArray)
{
sb.AppendFormat($"[{{0}}]", cnt);
}
sb.AppendFormat($"\" value =\"{{0}}\" id =\"{{1}}\" class=\"k-checkbox\" {{2}} ", HttpUtility.HtmlEncode(item.Value), generatedId, item.Selected ? "checked=\"checked\"" : string.Empty);
if (!string.IsNullOrWhiteSpace(onClickEvent))
{
sb.AppendFormat($" onclick=\"{{0}}\"", onClickEvent);
}
sb.Append(" />");
sb.AppendFormat("<label for= \"{0}\" class=\"k-checkbox-label\">{1}</label>", generatedId, HttpUtility.HtmlEncode(item.Text));
sb.Append("</li><br />");
// jQuerry selector name property
ultag.InnerHtml += sb.ToString();
}
return new MvcHtmlString(ultag.ToString());
}
public static MvcHtmlString KretaCheckBoxListForOpenBoardKepek(this HtmlHelper helper, string id, List<OpenBoardFileCo> items, int elementsPerColumn, bool isDisabled = false)
{
TagBuilder ultag = new TagBuilder("ul");
ultag.AddCssClass("noUlLiButton");
int cnt = 0;
foreach (var item in items)
{
cnt++;
string generatedId = id + cnt.ToString();
string contentAsBase64Encoded = "data:image/jpeg;base64," + Convert.ToBase64String(item.Content);
StringBuilder sb = new StringBuilder();
if (cnt == 1)
{
sb.Append("<div class=\"col-xs-3\">");
}
sb.Append("<li>");
sb.AppendFormat("<input type=\"checkbox\" name=\"{0}[{4}]\" value =\"{1}\" id =\"{2}\" class=\"k-checkbox\" {3} {5} />", id, HttpUtility.HtmlEncode(item.ID), generatedId, item.Lathato ? "checked=\"checked\"" : string.Empty, cnt, isDisabled ? "disabled=\"disabled\"" : string.Empty);
sb.AppendFormat("<label for= \"{0}\" class=\"k-checkbox-label-inline k-checkbox-label\"></label><label id='lblFeltoltottFajlok{4}' onclick=\"var newWindow = window.open('', '_blank'); newWindow.document.body.innerHTML = '<table><thead><tr><th><img width=60% src={1}></th></tr><tbody><tr><td align=center><a href={1} download={2}.{3} target=_blank>Kattintson ide a letöltéshez!</a></td></tr></tbody></table>'; \" onMouseOver=\"this.style.cursor = 'pointer'\">{2}</label>", generatedId, contentAsBase64Encoded, item.Nev, item.Kiterjesztes, item.ID);
sb.AppendFormat("<a title='Módosítás' href='javascript:void(0)' onclick='KepekListajaHelper.openModifyKepWindow({0})'><i style='font-size: 17px; padding-left: 3px;' class='fa fa-pencil' aria-hidden='true'></i></a>", item.ID);
sb.Append("</li><br />");
if (cnt == items.Count || cnt % elementsPerColumn == 0)
{
sb.Append("</div>");
}
if (cnt != items.Count && cnt % elementsPerColumn == 0)
{
sb.Append("<div class=\"col-xs-3\">");
}
ultag.InnerHtml += sb.ToString();
}
return new MvcHtmlString(ultag.ToString());
}
}
}

View file

@ -0,0 +1,106 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
namespace Kreta.Web.Helpers
{
public static class ColorPickerExtensions
{
public static ColorPickerBuilder KretaColorPicker(this HtmlHelper helper, string name, bool enabled = true, Dictionary<string, object> htmlAttributes = null)
{
var cp = helper.Kendo().ColorPicker()
.Name(name)
.Enable(enabled);
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
cp.HtmlAttributes(htmlAttributes);
return cp;
}
public static ColorPickerBuilder KretaColorPickerFor<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> expression, Dictionary<string, object> htmlAttributes = null)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
var value = metadata.Model;
if (htmlAttributes == null)
htmlAttributes = new Dictionary<string, object>();
htmlAttributes.Add("data-labelmsg", metadata.DisplayName);
var cp = helper.Kendo().ColorPicker()
.Name(fullBindingName)
.HtmlAttributes(htmlAttributes);
if (value != null)
{
cp.Value(value.ToString());
}
return cp;
}
public static MvcHtmlString RenderWithName(this ColorPickerBuilder helper, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string tooltipResource = null)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, labelMsg, string.Empty);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, labelMsg, string.Empty, tooltipResource);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithName(this ColorPickerBuilder helper, string label, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string tooltipResource = null)
{
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, label, string.Empty);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, label, string.Empty, tooltipResource);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
return new MvcHtmlString(sb.ToString());
}
private static void AddRenderWithNameBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, bool allSizeSame, string controlName, string labelMsg, string customClass)
{
sb.AppendFormat("<div class=\"{0} {1} \">", BootsrapHelper.GetSizeClasses(labelWidth, allSizeSame), customClass);
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}</label>", controlName, labelMsg);
sb.AppendFormat("</div><div class=\"{0} {1}\">", BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame), customClass);
}
private static void AddRenderWithNameTooltipBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, bool allSizeSame, string controlName, string labelMsg, string customClass, string tooltipResource)
{
sb.AppendFormat("<div class=\"{0} {1} kretaLabelTooltip \">", BootsrapHelper.GetSizeClasses(labelWidth, allSizeSame), customClass);
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}", controlName, labelMsg);
sb.Append("&nbsp;<img class='kretaLabelTooltipImg' />");
sb.AppendFormat("<span class=\"kretaLabelTooltipText\">{0}</span>", tooltipResource);
sb.Append("</label>");
sb.AppendFormat("</div><div class=\"{0} {1}\">", BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame), customClass);
}
private static void AddRenderWithNameCloseingFrame(StringBuilder sb)
{
sb.Append("</div>");
}
}
}

View file

@ -0,0 +1,795 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
using Kreta.Resources;
namespace Kreta.Web.Helpers
{
public static class ComboBoxExtensions
{
public const string GroupTemplate = "#if(data.First){ #<div class='k-group-header comboBox-groupHeader' >#: data.GroupName #</div>#}# #: data.Text #";
public static ComboBoxBuilder KretaComboBox(this HtmlHelper helper,
string id,
string url = null,
string dataTextField = "Text",
string datavalueField = "Value",
string placeholder = "",
string groupName = null,
Type groupType = null,
bool isServerFiltering = true,
bool isAutoComplete = false,
bool useGroup = false,
IDictionary<string, object> htmlAttributes = null,
string onChangeFunction = null,
bool selectFirstItem = false)
{
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
SetUnknownValueMessage(htmlAttributes);
var combobox = helper.Kendo().ComboBox()
.Name(id)
.DataTextField(dataTextField)
.DataValueField(datavalueField);
if (isAutoComplete)
{
combobox.Filter(FilterType.Contains);
}
if (!string.IsNullOrWhiteSpace(placeholder))
{
combobox.Placeholder(placeholder);
}
if (groupName != null)
{
combobox
.DataSource(source =>
{
source.Custom()
.ServerFiltering(isServerFiltering)
.Transport(transport =>
{
transport.Read(
read => read.Url(url));
})
.Group(g => g.Add(groupName, groupType));
});
return combobox;
}
combobox
.DataSource(source =>
{
source.Custom()
.ServerFiltering(isServerFiltering)
.Transport(transport =>
{
transport.Read(
read => read.Url(url));
});
})
.HtmlAttributes(htmlAttributes);
if (useGroup)
{
combobox.Template(GroupTemplate);
}
if (selectFirstItem)
{
combobox.SelectedIndex(0);
}
SetDefaultEvents(combobox, onChangeFunction);
return combobox;
}
public static ComboBoxBuilder KretaComboBox(
this HtmlHelper helper,
string id,
IEnumerable<SelectListItem> selectList,
IDictionary<string, object> htmlAttributes = null,
string onChangeFunction = null,
string labelText = null,
bool showUnknownValueMessage = true,
bool isSingleElementSet = true)
{
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
if (!htmlAttributes.ContainsKey("data-labelmsg"))
{
htmlAttributes.Add("data-labelmsg", labelText);
}
if (showUnknownValueMessage)
{
SetUnknownValueMessage(htmlAttributes);
}
var combobox = helper.Kendo().ComboBox()
.Name(id)
.BindTo(selectList)
.Placeholder(CommonResource.PleaseChoose)
.HtmlAttributes(htmlAttributes);
SetDefaultEvents(combobox, onChangeFunction, isSingleElementSet: isSingleElementSet);
return combobox;
}
public static ComboBoxBuilder KretaGroupableComboBox(
this HtmlHelper helper,
string id,
string url,
bool isGrouped = false,
IDictionary<string, object> htmlAttributes = null,
bool showUnknownValueMessage = true)
{
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
if (showUnknownValueMessage)
{
SetUnknownValueMessage(htmlAttributes);
}
var combobox = helper.Kendo().ComboBox()
.Name(id)
.Placeholder(CommonResource.PleaseChoose)
.HtmlAttributes(htmlAttributes)
.DataTextField("Text")
.DataValueField("Value")
.DataSource(source => source.Read(read => { read.Url(url); }));
if (isGrouped)
{
combobox.DataSource(source => source
.Custom()
.Group(g => g.Add("GroupName", typeof(string))));
}
SetDefaultEvents(combobox);
return combobox;
}
public static ComboBoxBuilder KretaComboBoxCascade(this HtmlHelper helper, string id, string url, string cascadeFrom, IDictionary<string, object> htmlAttributes = null, string placeholder = "")
{
if (string.IsNullOrWhiteSpace(placeholder))
{
placeholder = CommonResource.PleaseChoose;
}
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
SetUnknownValueMessage(htmlAttributes);
htmlAttributes.Add("data-labelmsg", id);
var combobox = helper.Kendo().ComboBox()
.Name(id)
.Placeholder(placeholder)
.HtmlAttributes(htmlAttributes)
.DataTextField("Text")
.DataValueField("Value")
.AutoBind(autoBind: false)
.CascadeFrom(cascadeFrom)
.DataSource(source =>
{
source.Custom()
.ServerFiltering(enabled: true)
.Transport(transport =>
{
transport.Read(read => read.Url(url).Data($"function(){{ return KretaComboBoxHelper.getCascadeData('#{cascadeFrom}'); }}"));
});
});
SetDefaultEvents(combobox);
return combobox;
}
public static ComboBoxBuilder KretaComboBoxFor<TModel, TProperty>(this HtmlHelper<TModel> helper,
Expression<Func<TModel, TProperty>> expression,
IEnumerable<SelectListItem> selectList,
IDictionary<string, object> htmlAttributes = null,
bool isAutoComplete = false,
bool isCustomAllowed = false,
string onChangeFunction = null,
bool isSingleElementSet = true,
bool showPlaceHolder = true)
{
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
SetUnknownValueMessage(htmlAttributes);
if (metadata.IsRequired)
{
htmlAttributes.Add("data-rule-required", "true");
htmlAttributes.Add("title", string.Format(CommonResource.Required, metadata.DisplayName));
htmlAttributes.Add("data-labelmsg", metadata.DisplayName + " *");
}
else
{
htmlAttributes.Add("data-labelmsg", metadata.DisplayName);
}
var modSelectList = new List<SelectListItem>();
var list = selectList.ToList();
for (var i = 0; i < list.Count; i++)
{
if (!string.IsNullOrWhiteSpace(list[i].Value))
{
modSelectList.Add(list[i]);
}
}
if (metadata.IsRequired && modSelectList.Count == 1)
{
modSelectList[0].Selected = true;
}
var combobox = helper.Kendo().ComboBoxFor(expression)
.BindTo(modSelectList)
.HtmlAttributes(htmlAttributes);
if (showPlaceHolder)
{
combobox.Placeholder(CommonResource.PleaseChoose);
}
if (isAutoComplete)
{
combobox.Filter(FilterType.Contains);
}
SetDefaultEvents(combobox, onChangeFunction, isCustomAllowed, isSingleElementSet: isSingleElementSet);
return combobox;
}
public static ComboBoxBuilder KretaComboBoxFor<TModel, TProperty>(
this HtmlHelper<TModel> helper,
Expression<Func<TModel, TProperty>> expression,
string url,
string dataTextField = "Text",
string datavalueField = "Value",
IDictionary<string, object> htmlAttributes = null,
bool usePlaceHolder = true,
bool useGroup = false,
bool isServerFiltering = true,
bool isCustomAllowed = false,
string dataFunction = null,
string serverFilteringFrom = null,
bool isAutoComplete = false,
string onChangeFunction = null,
bool isSingleElementSet = true,
bool showUnknownValueMessage = true)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
if (showUnknownValueMessage)
{
SetUnknownValueMessage(htmlAttributes);
}
var attributes = Mapper.GetUnobtrusiveValidationAttributes(helper, expression, htmlAttributes, metadata);
foreach (var key in attributes.Keys)
{
try
{
var keyItem = new KeyValuePair<string, object>(key, attributes[key].ToString());
if (!htmlAttributes.Contains(keyItem))
{
htmlAttributes.Add(keyItem);
}
}
catch
{
}
}
var validationAttributes = helper.GetUnobtrusiveValidationAttributes(fullBindingName, metadata);
var isRequiredIf = RequiredIfReflector.RequiredIf(helper, validationAttributes);
if (metadata.IsRequired)
{
if (!htmlAttributes.ContainsKey("data-rule-required"))
{ htmlAttributes.Add("data-rule-required", "true"); }
if (!htmlAttributes.ContainsKey("data-labelmsg"))
{ htmlAttributes.Add("data-labelmsg", metadata.DisplayName + " *"); }
if (!htmlAttributes.ContainsKey("title"))
{ htmlAttributes.Add("title", string.Format(CommonResource.Required, metadata.DisplayName)); }
}
else if (isRequiredIf)
{
if (!htmlAttributes.ContainsKey("data-labelmsg"))
{ htmlAttributes.Add("data-labelmsg", metadata.DisplayName + " *"); }
}
else
{
try
{ htmlAttributes.Add("data-labelmsg", metadata.DisplayName); }
catch { }
}
var dataFunctionHasValue = !string.IsNullOrWhiteSpace(dataFunction);
var combobox = helper.Kendo()
.ComboBoxFor(expression)
.HtmlAttributes(htmlAttributes)
.DataTextField(dataTextField)
.DataValueField(datavalueField)
.AutoBind(autoBind: false)
.DataSource(source =>
{
source.Custom()
.ServerFiltering(isServerFiltering)
.Transport(transport =>
{
transport.Read(
read =>
{
if (dataFunctionHasValue)
{
read.Url(url).Data(dataFunction); // A dataFunction egy js function, ami egy modelt ad hozzá az api kéréshez
}
else if (isServerFiltering && !string.IsNullOrWhiteSpace(serverFilteringFrom))
{
read.Url(url).Data($"function(){{ return KretaComboBoxHelper.getServerFilteringData('#{serverFilteringFrom}'); }}");
}
else
{
read.Url(url);
}
});
});
});
if (useGroup)
{
combobox.Template(GroupTemplate);
}
if (usePlaceHolder)
{
combobox.Placeholder(CommonResource.PleaseChoose);
}
if (isAutoComplete)
{
combobox.Filter(FilterType.Contains);
}
SetDefaultEvents(combobox, onChangeFunction, isCustomAllowed, isSingleElementSet: isSingleElementSet);
return combobox;
}
public static ComboBoxBuilder KretaCascadeComboBoxFor<TModel, TProperty>(
this HtmlHelper<TModel> helper,
Expression<Func<TModel, TProperty>> expression,
string url,
string cascadeFrom,
string dataTextField = "Text",
string datavalueField = "Value",
IDictionary<string, object> htmlAttributes = null,
bool usePlaceHolder = true,
bool useGroup = false,
bool isServerFiltering = true,
bool isAutoComplete = false,
bool isCustomAllowed = false,
string onChangeFunction = null,
bool isSingleElementSet = true)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
SetUnknownValueMessage(htmlAttributes);
var attributes = Mapper.GetUnobtrusiveValidationAttributes(helper, expression, htmlAttributes, metadata);
foreach (var key in attributes.Keys)
{
if (!htmlAttributes.ContainsKey(key))
{
htmlAttributes.Add(key, attributes[key].ToString());
}
}
var validationAttributes = helper.GetUnobtrusiveValidationAttributes(fullBindingName, metadata);
var isRequiredIf = RequiredIfReflector.RequiredIf(helper, validationAttributes);
htmlAttributes.Add("data-labelmsg", (metadata.IsRequired || isRequiredIf) ? metadata.DisplayName + " *" : metadata.DisplayName);
var combobox = helper.Kendo()
.ComboBoxFor(expression)
.HtmlAttributes(htmlAttributes)
.DataTextField(dataTextField)
.DataValueField(datavalueField)
.AutoBind(autoBind: false)
.CascadeFrom(cascadeFrom)
.DataSource(source =>
{
source.Custom()
.ServerFiltering(isServerFiltering)
.Transport(transport =>
{
transport.Read(read => read.Url(url).Data(string.Format("function(){{ return KretaComboBoxHelper.getCascadeData('#{0}'); }}", cascadeFrom)));
});
});
if (useGroup)
{
combobox.Template(GroupTemplate);
}
if (usePlaceHolder)
{
combobox.Placeholder(CommonResource.PleaseChoose);
}
if (isAutoComplete)
{
combobox.Filter(FilterType.Contains);
}
SetDefaultEvents(combobox, onChangeFunction, isCustomAllowed, isSingleElementSet);
return combobox;
}
public static MvcHtmlString RenderSearchPanel(this ComboBoxBuilder helper, bool withClear = false)
{
var labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (string.Equals(item.Key, "data-labelmsg", StringComparison.OrdinalIgnoreCase) && item.Value != null)
{
labelMsg = item.Value.ToString();
}
}
var id = helper.ToComponent().Id;
var sb = new StringBuilder();
sb.Append("<div class=\"searchInputRowHeight\"><div>");
sb.Append("<label class=\"searchPanelInputLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div><div>");
sb.Append(helper.ToHtmlString());
sb.Append("</div></div>");
if (withClear)
{
sb.Append("<script>$(document).ready(function() { setTimeout(function() {");
sb.Append("if($('#").Append(id).Append("').prev().hasClass('k-state-disabled') == false && $('#").Append(id).Append("').attr('aria-readonly') == 'false') {");
sb.Append("$('#").Append(id).Append("').prev().children('span').css({'right': '20px'});");
sb.Append("$('#").Append(id).Append("').prev().append(\"<span class='clearComboBox' style='font-size: 20px; position: absolute; top: 3px; right: 5px; cursor: pointer;'><i class='fa fa-times' aria-hidden=true'></i></span>\");");
sb.Append(@"$('.clearComboBox').click(function() {
var id = $(this).parent().parent().children('input').attr('Id');
if($('#' + id).attr('aria-disabled') == 'false' && $('#' + id).attr('aria-readonly') == 'false') {
$('#' + id).data('kendoComboBox').value('');
}
});
");
sb.Append('}');
AddListAutoWidthScript(sb, id);
sb.Append("},1); });");
sb.Append("</script>");
}
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderSearchPanelSideBar(this ComboBoxBuilder helper, string labelMsg = null, bool withClear = false)
{
if (string.IsNullOrWhiteSpace(labelMsg))
{
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (string.Equals(item.Key, "data-labelmsg", StringComparison.OrdinalIgnoreCase) && item.Value != null)
{
labelMsg = item.Value.ToString();
}
}
}
var id = helper.ToComponent().Id;
var sb = new StringBuilder();
sb.Append("<div class=\"searchPanelRow\">");
sb.Append("<div class=\"searchPanelRowTitle\">");
sb.Append("<label class=\"searchPanelLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div>");
sb.Append("<div class=\"searchPanelRowValue\">");
sb.Append(helper.ToHtmlString());
sb.Append("</div>");
sb.Append("</div>");
if (withClear)
{
sb.Append("<script>$(document).ready(function() { setTimeout(function() {");
sb.Append("if($('#").Append(id).Append("').prev().hasClass('k-state-disabled') == false && $('#").Append(id).Append("').attr('aria-readonly') == 'false') {");
sb.Append("$('#").Append(id).Append("').prev().children('span').css({'right': '20px'});");
sb.Append("$('#").Append(id).Append("').prev().append(\"<span class='clearComboBox' style='font-size: 20px; position: absolute; top: 3px; right: 5px; cursor: pointer;'><i class='fa fa-times' aria-hidden=true'></i></span>\");");
sb.Append(@"$('.clearComboBox').click(function() {
var id = $(this).parent().parent().children('input').attr('Id');
if($('#' + id).attr('aria-disabled') == 'false' && $('#' + id).attr('aria-readonly') == 'false') {
$('#' + id).data('kendoComboBox').value('');
}
});
");
sb.Append('}');
AddListAutoWidthScript(sb, id);
sb.Append("},1); });");
sb.Append("</script>");
}
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithClearButton(this ComboBoxBuilder helper)
{
var controlId = helper.ToComponent().Id;
var output = new StringBuilder();
output.Append(helper.ToHtmlString());
output.Append("<script>");
output.Append("$(document).ready(function() { setTimeout(function() {");
output.Append("if ($('#").Append(controlId).Append("').prev().hasClass('k-state-disabled') == false && $('#").Append(controlId).Append("').attr('aria-readonly') == 'false') {{");
output.Append("$('#").Append(controlId).Append("').prev().children('span').css({{'right': '20px'}});");
output.Append("$('#").Append(controlId).Append("').prev().append(\"<span class='clearComboBox' style='font-size: 20px; position: absolute; top: 3px; right: 5px; cursor: pointer;'><i class='fa fa-times' aria-hidden=true'></i></span>\");");
output.Append(@"$('.clearComboBox').click(function() {
var id = $(this).parent().parent().children('input').attr('Id');
if ($('#' + id).attr('aria-disabled') == 'false' && $('#' + id).attr('aria-readonly') == 'false') {
$('#' + id).data('kendoComboBox').value('');
$('#' + id).data('kendoComboBox').trigger('change');
}
});");
output.Append('}');
AddListAutoWidthScript(output, controlId);
output.Append("},1); });");
output.Append("</script>");
return new MvcHtmlString(output.ToString());
}
public static MvcHtmlString RenderWithName(this ComboBoxBuilder helper, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string customClass = "", string customLabelDivClass = "", string customLabelClass = "", string tooltipResource = null, bool addOffset = false, bool isCustomRequired = false, string labelMsg = null, bool changeEventOverride = true, bool withClear = false)
{
if (string.IsNullOrWhiteSpace(labelMsg))
{
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (string.Equals(item.Key, "data-labelmsg", StringComparison.OrdinalIgnoreCase) && item.Value != null)
{
labelMsg = item.Value.ToString();
}
}
}
if (isCustomRequired)
{
labelMsg += " *";
}
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
{
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, labelMsg, customClass, customLabelDivClass, customLabelClass, addOffset);
}
else
{
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, labelMsg, customClass, customLabelDivClass, customLabelClass, tooltipResource);
}
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb, helper.ToComponent().Id, withClear);
if (changeEventOverride)
{
AddDefaultChangeEventIfOverrided(helper, sb);
}
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithoutName(this ComboBoxBuilder helper, int inputWidth = 12, bool allSizeSame = false, string customClass = "", bool withClear = false)
{
var sb = new StringBuilder();
AddRenderWithNameBeginingFrame(sb, 0, inputWidth, allSizeSame, helper.ToComponent().Name, string.Empty, customClass, string.Empty, string.Empty);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb, helper.ToComponent().Id, withClear);
AddDefaultChangeEventIfOverrided(helper, sb);
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderIntoOneColWithName(this ComboBoxBuilder helper, int inputWidth = 6, bool allSizeSame = false, string customClass = "", string customLabelDivClass = "", string customLabelClass = "", string tooltipResource = null, Dictionary<string, object> customHtmlAttributes = null, bool withClear = false)
{
var labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (string.Equals(item.Key, "data-labelmsg", StringComparison.OrdinalIgnoreCase) && item.Value != null)
{
labelMsg = item.Value.ToString();
}
}
var sb = new StringBuilder();
AddRenderIntoOneColWithNameBeginingFrame(sb, inputWidth, allSizeSame, labelMsg, customClass, customLabelDivClass, customLabelClass, tooltipResource, customHtmlAttributes);
sb.Append(helper.ToHtmlString());
if (!string.IsNullOrWhiteSpace(tooltipResource))
{
sb.AppendFormat("<span class=\"kretaLabelTooltipText\" style=\"width: 100%;\">{0}</span>", tooltipResource);
}
sb.Append("</div>");
AddRenderWithNameCloseingFrame(sb, helper.ToComponent().Id, withClear);
AddDefaultChangeEventIfOverrided(helper, sb);
return new MvcHtmlString(sb.ToString());
}
private static void AddRenderIntoOneColWithNameBeginingFrame(StringBuilder sb, int inputWidth, bool allSizeSame, string labelMsg, string customClass, string customLabelDivClass, string customLabelClass, string tooltipResource = null, Dictionary<string, object> customHtmlAttributes = null)
{
var customHtmlAttr = "";
if (customHtmlAttributes != null)
{
customHtmlAttr = string.Join(" ", customHtmlAttributes.Select(x => $"{x.Key}=\"{x.Value}\""));
}
var needTooltip = !string.IsNullOrWhiteSpace(tooltipResource);
sb.Append("<div class=\"").Append(BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame)).Append(' ').Append(customClass).Append(' ').Append(needTooltip ? "kretaLabelTooltip" : "").Append("\" ").Append(customHtmlAttr).Append("><div class=\"col-xs-12 col-sm-12 col-md-12\" style=\"padding-left: 0px; padding-right: 20px;\"><label class=\"windowInputLabel ").Append(customLabelClass).Append(" \" for=\"").Append(customLabelClass).Append("\">").Append(labelMsg).Append(needTooltip ? "&nbsp;<img class='kretaLabelTooltipImg'/>" : "").Append("</label></div><div class=\"col-xs-12 col-sm-12 col-md-12\" style=\"padding: 0px;\">");
}
private static void AddRenderWithNameBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, bool allSizeSame, string controlName, string labelMsg, string customClass, string customLabelDivClass, string customLabelClass, bool addOffset = false)
{
//TODO: ez a replace sor az OM-127 miatt került be, de az OM-2315 esetén hibát okoz nested objectek esetén
controlName = controlName.Replace(".", "_");
if (labelWidth > 0 && !string.IsNullOrWhiteSpace(labelMsg))
{
sb.AppendFormat("<div class=\"{0} {1} {2}\">", BootsrapHelper.GetSizeClasses(labelWidth, allSizeSame), customClass, customLabelDivClass);
sb.AppendFormat("<label class=\"windowInputLabel {0} \" for=\"{1}\">{2}</label>", customLabelClass, controlName, labelMsg);
sb.Append("</div>");
}
sb.AppendFormat("<div class=\"{0} {1} \">", BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame, addOffset), customClass);
}
private static void AddRenderWithNameTooltipBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, bool allSizeSame, string controlName, string labelMsg, string customClass, string customLabelDivClass, string customLabelClass, string tooltipResource)
{
sb.AppendFormat("<div class=\"{0} {1} {2} kretaLabelTooltip \">", BootsrapHelper.GetSizeClasses(labelWidth, allSizeSame), customClass, customLabelDivClass);
sb.AppendFormat("<label class=\"windowInputLabel {0} \" for=\"{1}\">{2}", customLabelClass, controlName, labelMsg);
sb.Append("&nbsp;<img class='kretaLabelTooltipImg' />");
sb.AppendFormat("<span class=\"kretaLabelTooltipText\">{0}</span>", tooltipResource);
sb.Append("</label>");
sb.AppendFormat("</div><div class=\"{0} {1} \">", BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame), customClass);
}
private static void AddRenderWithNameCloseingFrame(StringBuilder sb, string id, bool withClear = false)
{
sb.Append("</div>");
if (withClear)
{
sb.Append("<script>$(document).ready(function() { setTimeout(function() {");
sb.AppendFormat("if($('#{0}').prev().hasClass('k-state-disabled') == false && $('#" + id + "').attr('aria-readonly') == 'false') {{", id);
sb.AppendFormat("$('#{0}').prev().children('span').css({{'right': '20px'}});", id);
sb.AppendFormat("$('#{0}').prev().append(\"<span class='clearComboBox' style='font-size: 20px; position: absolute; top: 3px; right: 5px; cursor: pointer;'><i class='fa fa-times' aria-hidden=true'></i></span>\");", id);
sb.Append(@"$('.clearComboBox').click(function() {
var id = $(this).parent().parent().children('input').attr('Id');
if($('#' + id).attr('aria-disabled') == 'false' && $('#' + id).attr('aria-readonly') == 'false') {
$('#' + id).data('kendoComboBox').value('');
$('#' + id).data('kendoComboBox').trigger('change');
}
});
");
sb.Append('}');
AddListAutoWidthScript(sb, id);
sb.Append("},1); });");
sb.Append("</script>");
}
}
private static void AddListAutoWidthScript(StringBuilder sb, string id)
{
sb.AppendFormat("var combo = $('#{0}').data('kendoComboBox');", id);
sb.Append("if(combo){ combo.list.width('auto'); }");
}
private static void SetUnknownValueMessage(IDictionary<string, object> htmlAttributes)
{
htmlAttributes.Add("data-msg-unknownvalue", CommonResource.UnknownValue);
}
private static void SetDefaultEvents(ComboBoxBuilder combobox, string onChangeFunction = null, bool isCustomAllowed = false, bool isSingleElementSet = true)
{
combobox.Events(e => e.Open("KretaComboBoxHelper.onOpenDropdown"));
if (!isCustomAllowed)
{
var onChangeFunctions = onChangeFunction == null
? "KretaComboBoxHelper.onChange"
: @"function(e){ KretaComboBoxHelper.onChange(e); " + onChangeFunction + "; }";
combobox.Events(e =>
{
e.DataBound(isSingleElementSet ? "KretaComboBoxHelper.onDataBound" : "KretaComboBoxHelper.onDataBoundWithoutSetSingleElement");
e.Change(onChangeFunctions);
});
}
}
public static MvcHtmlString RenderWithName(this ComboBoxBuilder helper, string label, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string tooltipResource = null, bool withClear = false)
{
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
{
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, label, string.Empty, string.Empty, string.Empty);
}
else
{
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, label, string.Empty, string.Empty, string.Empty, tooltipResource);
}
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb, helper.ToComponent().Id, withClear);
AddDefaultChangeEventIfOverrided(helper, sb);
return new MvcHtmlString(sb.ToString());
}
private static void AddDefaultChangeEventIfOverrided(ComboBoxBuilder helper, StringBuilder sb)
{
if (helper.ToComponent().Events.TryGetValue("change", out var eventValueObject))
{
var eventValue = (Kendo.Mvc.ClientHandlerDescriptor)eventValueObject;
if (!eventValue.HandlerName.Contains("KretaComboBoxHelper.onChange"))
{
var elementId = helper.ToComponent().Id;
var str = "<script>$(document).ready(function() {$('#" + elementId + "').blur(function() { KretaComboBoxHelper.checkSelectedValue('" + elementId + "');});});</script>";
sb.Append(str);
}
}
}
}
}

View file

@ -0,0 +1,225 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Kreta.BusinessLogic.Classes;
using Kreta.BusinessLogic.HelperClasses;
using Kreta.BusinessLogic.Helpers;
using Kreta.BusinessLogic.Security;
using Kreta.Core.ConnectionType;
using Kreta.Enums;
using Kreta.Web.Security;
using Kreta.Web.Utils;
using Newtonsoft.Json;
namespace Kreta.Web.Helpers
{
public static class CommonExtensions
{
public static List<SelectListItem> ToSelectListItemList(this IDictionary<string, string> dictionary, List<string> removeValueList = null, int? selectedValue = null)
{
var itemList = removeValueList != null
? dictionary.Where(x => !removeValueList.Contains(x.Key))
: dictionary;
var result = itemList.Select(x => new SelectListItem
{
Value = x.Key,
Text = x.Value,
Selected = selectedValue != null && x.Key == selectedValue.ToString()
}).ToList();
return result;
}
public static string ToJson(this object obj, bool isNeedEncoding = false)
{
var json = JsonConvert.SerializeObject(obj);
if (!isNeedEncoding)
{
return json;
}
return System.Web.HttpUtility.JavaScriptStringEncode(json);
}
public static string ToJsonReplaceSpecialCharaters(this string text)
{
string result = text
.Replace("'", @"\'")
.Replace("\"", "&quot;");
return result;
}
#region Nyomtatványhoz név és azonosító generálás
public static string NevGeneralas(string nyomtatvanynev, NyomtatvanyNevGeneralasModel model, bool isIktatas = false, bool notAppendDateTimeNow = false, string customMessage = null, bool forOrganization = false)
{
IConnectionType connectionType = ConnectionTypeExtensions.GetOrganizationConnectionType();
if (!forOrganization)
{
connectionType = ConnectionTypeExtensions.GetSessionConnectionType();
}
var result = new StringBuilder(nyomtatvanynev + "_");
if (model.TanuloID.HasValue)
{
var h = new TanuloHelper(connectionType);
var tanulo = h.GetTanuloiAdatok(model.TanuloID.Value, ClaimData.KovTanevID, ClaimData.IsSelectedTanev20_21OrLater, ClaimData.IsSelectedTanev21_22OrLater);
result.Append(tanulo.CsaladiNev + "_" + tanulo.UtoNev + "_" + tanulo.OktatasiAzonosito + "_");
}
if (model.OsztalyCsoportId.HasValue)
{
var h = new OsztalyCsoportHelper(connectionType);
result.Append(h.GetOsztalyCsoportNevById(model.OsztalyCsoportId.Value) + "_");
}
if (model.TanarID.HasValue)
{
var h = new TanarHelper(connectionType);
var tanar = h.GetTanarAdatok(model.TanarID.Value);
result.Append(tanar.MunkavallaloCsaladiNev + "_" + tanar.MunkavallaloUtonev + "_");
}
if (model.OsztalyID.HasValue)
{
var h = new OsztalyHelper(connectionType);
var osztaly = h.GetClassById(model.OsztalyID.Value);
result.Append(osztaly.OsztalyNev + "_");
}
if (model.CsoportId.HasValue)
{
var h = new CsoportHelper(connectionType);
var csoport = h.GetGroupByID(model.CsoportId.Value);
result.Append(csoport.CsoportNeve + "_");
}
if (model.TeremID.HasValue)
{
var h = new TeremHelper(connectionType);
var teremNev = h.GetTeremNev(model.TeremID.Value);
result.Append(teremNev + "_");
}
if (model.FoglalkozasID.HasValue)
{
var h = new FoglalkozasHelper(connectionType);
var foglalkozasNev = h.GetFoglalkozasNeve(model.FoglalkozasID.Value);
result.Append(foglalkozasNev + "_");
}
if (model.FeladatellatasiHelyId.HasValue)
{
var h = new FeladatEllatasiHelyHelper(connectionType);
var feladatellatasiHelyNev = h.GetFeladatEllatasiHelyDDl(string.Empty).ToList().First(x => x.Key == model.FeladatellatasiHelyId.Value.ToString()).Value;
result.Append(feladatellatasiHelyNev + "_");
}
if (model.TanevID.HasValue)
{
var h = new TanevHelper(new OrganizationConnectionType(connectionType.FelhasznaloId, connectionType.IntezmenyId, connectionType.IntezmenyAzonosito, model.TanevID.Value));
var tanev = h.GetTanevInfo();
result.Append(tanev.Nev.Replace("/", "_"));
if (!isIktatas)
{
result.Append('_');
}
}
if (!isIktatas && !notAppendDateTimeNow)
{
result.Append(DateTime.Now.ToShortDateString());
}
if (!string.IsNullOrWhiteSpace(customMessage))
{
result.Append("_" + customMessage);
}
return result.ToString();
}
#endregion
private const string TanarDashboardUrl = "~/Tanar/TanarDashboard";
private const string LoginUrl = "~/Adminisztracio/Login";
public static string GetDefaultPage(bool fromKretaLogo = false)
{
var role = ClaimData.FelhasznaloSzerepkor;
var package = ClaimData.FelhasznaloSzerepCsomagok;
if (package.Contains(KretaClaimPackages.IsArchivIntezmeny.ClaimValue))
{
return ApplicationData.ArchivDefaultPage;
}
if (role.Equals(SzerepkorTipusEnum.Ellenorzo))
{
if (package.Contains(KretaClaimPackages.Gondviselo.ClaimValue))
{
return ApplicationData.SzuloDefaultPage;
}
if (package.Contains(KretaClaimPackages.CsokkentettGondviselo.ClaimValue))
{
return ApplicationData.CsokkentettSzuloDefaultPage;
}
return ApplicationData.TanuloDefaultPage;
}
if (role.Equals(SzerepkorTipusEnum.Naplo))
{
if (!fromKretaLogo && !ProfileUtils.HetirendMegjeleniteseBelepeskor)
{
return TanarDashboardUrl;
}
if (package.Contains(KretaClaimPackages.Osztalyfonok.ClaimValue) || package.Contains(KretaClaimPackages.SzuperOsztalyfonok.ClaimValue))
{
return ApplicationData.OsztalyfonokDefaultPage;
}
if (package.Contains(KretaClaimPackages.Tanar.ClaimValue))
{
return ApplicationData.TanarDefaultPage;
}
return ApplicationData.NaploDefaultPage;
}
if (role.Equals(SzerepkorTipusEnum.Adminisztrator))
{
if (package.Contains(KretaClaimPackages.SzuperOsztalyfonok.ClaimValue))
{
return ApplicationData.IgazgatoDefaultPage;
}
return ApplicationData.AdminDefaultPage;
}
if (package.Contains(KretaClaimPackages.Dualis_Admin.ClaimValue))
{
return ApplicationData.DualisAdminDefaultPage;
}
if (package.Contains(KretaClaimPackages.TavolletIgenylo.ClaimValue))
{
return ApplicationData.TavolletDefaultPage;
}
return LoginUrl;
}
}
}

View file

@ -0,0 +1,24 @@
using Kreta.BusinessLogic.Utils;
using Kreta.Core.ConnectionType;
using Kreta.Web.Security;
namespace Kreta.Web.Helpers
{
public static class ConnectionTypeExtensions
{
public static SessionConnectionType GetActiveSessionConnectionType()
=> new SessionConnectionType(ClaimData.SessionId, ClaimData.FelhasznaloId, ClaimData.IntezmenyId, ClaimData.IntezmenyAzonosito, ClaimData.AktivTanevID.Value);
public static SessionConnectionType GetSessionConnectionType()
=> new SessionConnectionType(ClaimData.SessionId, ClaimData.FelhasznaloId, ClaimData.IntezmenyId, ClaimData.IntezmenyAzonosito, ClaimData.SelectedTanevID.Value);
public static SessionConnectionType GetNextSessionConnectionType()
=> new SessionConnectionType(ClaimData.SessionId, ClaimData.FelhasznaloId, ClaimData.IntezmenyId, ClaimData.IntezmenyAzonosito, ClaimData.KovTanevID.Value);
public static OrganizationConnectionType GetOrganizationConnectionType()
=> new OrganizationConnectionType(ClaimData.FelhasznaloId, CommonUtils.GetIntezmenyId(ClaimData.FelhasznaloId), CommonUtils.GetOrganizationIdentifier(), CommonUtils.GetAktualisTanevId(ClaimData.FelhasznaloId));
public static SystemConnectionType GetSystemConnectionType()
=> new SystemConnectionType(ClaimData.FelhasznaloId, ClaimData.IntezmenyId, ClaimData.IntezmenyAzonosito, ClaimData.AktivTanevID.Value);
}
}

View file

@ -0,0 +1,56 @@
using System.Text;
namespace Kreta.Web.Helpers
{
public class CustomStringBuilder
{
private StringBuilder builder = new StringBuilder();
public CustomStringBuilder Append(string s)
{
builder.Append(s);
return this;
}
public override string ToString()
{
return builder.ToString();
}
public static implicit operator CustomStringBuilder(string s)
{
var m = new CustomStringBuilder();
m.builder.Append(s);
return m;
}
public static CustomStringBuilder operator +(CustomStringBuilder m, string s)
{
return m.Append(s);
}
public CustomStringBuilder AppendFormat(string format, object arg0, object arg1, object arg2)
{
builder.AppendFormat(format, arg0, arg1, arg2);
return this;
}
public CustomStringBuilder AppendFormat(string format, params object[] args)
{
builder.AppendFormat(format, args);
return this;
}
public CustomStringBuilder AppendFormat(string format, object arg0)
{
builder.AppendFormat(format, arg0);
return this;
}
public CustomStringBuilder AppendFormat(string format, object arg0, object arg1)
{
builder.AppendFormat(format, arg0, arg1);
return this;
}
}
}

View file

@ -0,0 +1,253 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
using Kreta.Web.Security;
namespace Kreta.Web.Helpers
{
public static class DatePickerExtensions
{
public static DatePickerBuilder KretaDatePicker(this HtmlHelper helper, string id, string className = "", bool enabled = true, string culture = "hu-HU", DateTime? minValue = null, DateTime? maxValue = null, IDictionary<string, object> htmlAttributes = null)
{
if (helper.ViewData.ModelState[id] != null && helper.ViewData.ModelState[id].Errors.Count > 0)
className = string.Format("{0} input-validation-error", className);
var datepicker = helper.Kendo().DatePicker()
.Name(id)
.Enable(enabled)
.Culture(culture);
if (ClaimData.LCID == 1038 /*Magyar*/)
{
datepicker.Format("yyyy. MM. dd.");
}
if (!string.IsNullOrWhiteSpace(className) || !string.IsNullOrWhiteSpace(id))
{
var attributes = new Dictionary<string, object>();
if (!string.IsNullOrWhiteSpace(className))
attributes.Add("class", className.Trim());
if (!string.IsNullOrWhiteSpace(id))
attributes.Add("id", id);
datepicker.HtmlAttributes(attributes);
}
if (minValue.HasValue)
datepicker.Min(minValue.Value);
if (maxValue.HasValue)
datepicker.Max(maxValue.Value);
if (htmlAttributes != null)
datepicker.HtmlAttributes(htmlAttributes);
return datepicker;
}
public static DatePickerBuilder KretaDatePickerFor<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> expression, IDictionary<string, object> htmlAttributes = null)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
var value = metadata.Model;
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
string displayName = metadata.DisplayName;
bool isRequiredIf = false;
string requiredIfMsg = "", requiredIfDepProperty = "", requiredIfDepOperator = "", requiredIfDepValue = "";
fullBindingName = fullBindingName.Replace('.', '_');
var validationAttributes = helper.GetUnobtrusiveValidationAttributes(fullBindingName, metadata);
foreach (var attribute in validationAttributes)
{
var attributeValue = attribute.Value.ToString();
switch (attribute.Key)
{
case "data-val-required":
htmlAttributes.Add("data-rule-required", "true");
htmlAttributes.Add("data-msg-required", attributeValue);
htmlAttributes.Add("title", attributeValue);
displayName = metadata.DisplayName + " *";
break;
case "data-val-requiredif":
isRequiredIf = true;
requiredIfMsg = attributeValue;
displayName = metadata.DisplayName + " *";
break;
case "data-val-requiredif-dependentproperty":
requiredIfDepProperty = attributeValue;
break;
case "data-val-requiredif-operator":
requiredIfDepOperator = attributeValue;
break;
case "data-val-requiredif-dependentvalue":
requiredIfDepValue = attributeValue;
break;
//case "data-val-date":
// htmlAttributes.Add("data-rule-date", "true");
// htmlAttributes.Add("data-msg-date", attributeValue);
// break;
}
}
if (isRequiredIf)
{
htmlAttributes.Add("data-rule-requiredif", "{\"dependentproperty\":\"" + requiredIfDepProperty + "\",\"operator\":\"" + requiredIfDepOperator + "\",\"dependentvalue\":" + requiredIfDepValue.ToLower() + "}");
htmlAttributes.Add("data-msg-requiredif", requiredIfMsg);
}
htmlAttributes.Add("data-labelmsg", displayName);
//a dátum ellenőrzést fixen hozzáadjuk
//htmlAttributes.Add("data-rule-date", "true");
//htmlAttributes.Add("data-msg-date", string.Format(StringResourcesUtil.GetString(4297), metadata.DisplayName));
var datePicker = (expression.ReturnType == typeof(DateTime))
? helper.Kendo().DatePickerFor(Expression.Lambda<Func<TModel, DateTime>>(expression.Body, expression.Parameters))
: helper.Kendo().DatePickerFor(Expression.Lambda<Func<TModel, DateTime?>>(expression.Body, expression.Parameters));
datePicker.HtmlAttributes(htmlAttributes);
if (ClaimData.LCID == 1038 /*Magyar*/)
{
datePicker.Format("yyyy. MM. dd.");
}
return datePicker;
}
public static MvcHtmlString RenderSearchPanel(this DatePickerBuilder helper, bool withMask = true)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
StringBuilder sb = new StringBuilder();
sb.Append("<div class=\"searchInputRowHeight\"><div>");
sb.Append("<label class=\"searchPanelInputLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div><div>");
sb.Append(helper.ToHtmlString());
sb.Append("</div></div>");
if (withMask)
sb.Append("<script>$(\"#").Append(helper.ToComponent().Name.Replace('.', '_')).Append("\").kendoMaskedDatePicker();</script>");
sb.Append("<script>$(\"#").Append(helper.ToComponent().Name.Replace('.', '_')).Append("\").change(function() { KretaDateTimeHelper.validateDate($(this)); });</script>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderSearchPanelSideBar(this DatePickerBuilder helper, bool withMask = true)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
StringBuilder sb = new StringBuilder();
sb.Append("<div class=\"searchPanelRow\">");
sb.Append("<div class=\"searchPanelRowTitle\">");
sb.Append("<label class=\"searchPanelLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div>");
sb.Append("<div class=\"searchPanelRowValue\">");
sb.Append(helper.ToHtmlString());
sb.Append("</div>");
sb.Append("</div>");
if (withMask)
sb.Append("<script>$(\"#").Append(helper.ToComponent().Name.Replace('.', '_')).Append("\").kendoMaskedDatePicker();</script>");
sb.Append("<script>$(\"#").Append(helper.ToComponent().Name.Replace('.', '_')).Append("\").change(function() { KretaDateTimeHelper.validateDate($(this)); });</script>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithMask(this DatePickerBuilder helper)
{
var controlId = helper.ToComponent().Id;
var output = new StringBuilder();
output.Append(helper.ToHtmlString());
output.Append("<script>");
output.Append($"$(\"#{controlId}\").kendoMaskedDatePicker();");
output.Append($"$(\"#{controlId}\").change(function() {{ KretaDateTimeHelper.validateDate($(this)); }});");
output.Append("</script>");
return new MvcHtmlString(output.ToString());
}
public static MvcHtmlString RenderWithName(this DatePickerBuilder helper, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, bool withMask = true, string tooltipResource = null, bool isCustomRequired = false, string labelMsg = null)
{
if (string.IsNullOrWhiteSpace(labelMsg))
{
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
}
if (isCustomRequired)
labelMsg += " *";
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, labelMsg);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, labelMsg, tooltipResource);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb, withMask, helper.ToComponent().Name);
return new MvcHtmlString(sb.ToString());
}
private static void AddRenderWithNameBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, bool allSizeSame, string controlName, string labelMsg)
{
sb.AppendFormat("<div class=\"{0}\">", BootsrapHelper.GetSizeClasses(labelWidth, allSizeSame));
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}</label>", controlName, labelMsg);
sb.AppendFormat("</div><div class=\"{0} \">", BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame));
}
private static void AddRenderWithNameTooltipBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, bool allSizeSame, string controlName, string labelMsg, string tooltipResource)
{
sb.AppendFormat("<div class=\"{0} kretaLabelTooltip \">", BootsrapHelper.GetSizeClasses(labelWidth, allSizeSame));
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}", controlName, labelMsg);
sb.Append("&nbsp;<img class='kretaLabelTooltipImg' />");
sb.AppendFormat("<span class=\"kretaLabelTooltipText\">{0}</span>", tooltipResource);
sb.Append("</label>");
sb.AppendFormat("</div><div class=\"{0} \">", BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame));
}
private static void AddRenderWithNameCloseingFrame(StringBuilder sb, bool withMask, string controlName)
{
sb.Append("</div>");
if (withMask)
sb.AppendFormat("<script>$(\"#{0} \").kendoMaskedDatePicker();</script>", controlName.Replace('.', '_'));
sb.Append("<script>$(\"#").Append(controlName.Replace('.', '_')).Append("\").change(function() { KretaDateTimeHelper.validateDate($(this)); });</script>");
}
public static MvcHtmlString RenderWithName(this DatePickerBuilder helper, string label, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, bool withMask = true)
{
var sb = new StringBuilder();
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, label);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb, withMask, helper.ToComponent().Name);
return new MvcHtmlString(sb.ToString());
}
}
}

View file

@ -0,0 +1,219 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
using Kreta.Web.Security;
namespace Kreta.Web.Helpers
{
public static class DateTimePickerExtensions
{
public static DateTimePickerBuilder KretaDateTimePicker(this HtmlHelper helper, string id, string className = "", bool enabled = true, string culture = "hu-HU", int interval = 1, DateTime? minValue = null, DateTime? maxValue = null, IDictionary<string, object> htmlAttributes = null)
{
if (helper.ViewData.ModelState[id] != null && helper.ViewData.ModelState[id].Errors.Count > 0)
className = string.Format("{0} input-validation-error", className);
var datetimepicker = helper.Kendo().DateTimePicker()
.Name(id)
.Enable(enabled)
.Culture(culture)
.Interval(interval);
if (!string.IsNullOrWhiteSpace(className) || !string.IsNullOrWhiteSpace(id))
{
var attributes = new Dictionary<string, object>();
if (!string.IsNullOrWhiteSpace(className))
attributes.Add("class", className.Trim());
if (!string.IsNullOrWhiteSpace(id))
attributes.Add("id", id);
datetimepicker.HtmlAttributes(attributes);
}
if (minValue.HasValue)
datetimepicker.Min(minValue.Value);
if (maxValue.HasValue)
datetimepicker.Max(maxValue.Value);
if (htmlAttributes != null)
datetimepicker.HtmlAttributes(htmlAttributes);
return datetimepicker;
}
public static DateTimePickerBuilder KretaDateTimePickerFor<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> expression, IDictionary<string, object> htmlAttributes = null)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
var value = metadata.Model;
if (htmlAttributes == null)
htmlAttributes = new Dictionary<string, object>();
var validationAttributes = helper.GetUnobtrusiveValidationAttributes(fullBindingName, metadata);
foreach (var key in validationAttributes.Keys)
{
if (key == "data-val-required")
{
htmlAttributes.Add("title", validationAttributes[key].ToString());
}
}
if (metadata.IsRequired)
{
htmlAttributes.Add("data-rule-required", "true");
//htmlAttributes.Add("title", string.Format(StringResourcesUtil.GetString(3477), metadata.DisplayName));
htmlAttributes.Add("data-labelmsg", metadata.DisplayName + " *");
}
else
{
htmlAttributes.Add("data-labelmsg", metadata.DisplayName);
}
var dateTimePicker = (expression.ReturnType == typeof(DateTime))
? helper.Kendo().DateTimePickerFor(Expression.Lambda<Func<TModel, DateTime>>(expression.Body, expression.Parameters))
: helper.Kendo().DateTimePickerFor(Expression.Lambda<Func<TModel, DateTime?>>(expression.Body, expression.Parameters));
dateTimePicker.HtmlAttributes(htmlAttributes);
if (ClaimData.LCID == 1038 /*Magyar*/)
{
dateTimePicker.Format("yyyy. MM. dd. HH:mm");
}
return dateTimePicker;
}
public static MvcHtmlString RenderSearchPanel(this DateTimePickerBuilder helper, bool withMask = true)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
StringBuilder sb = new StringBuilder();
sb.Append("<div class=\"searchInputRowHeight\"><div>");
sb.Append("<label class=\"searchPanelInputLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div><div>");
sb.Append(helper.ToHtmlString());
sb.Append("</div></div>");
if (withMask)
sb.Append("<script>$(\"#").Append(helper.ToComponent().Name.Replace('.', '_')).Append("\").kendoMaskedDateTimePicker();</script>");
sb.Append("<script>$(\"#").Append(helper.ToComponent().Name.Replace('.', '_')).Append("\").change(function() { KretaDateTimeHelper.validateDateTime($(this)); });</script>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderSearchPanelSideBar(this DateTimePickerBuilder helper, bool withMask = true)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
StringBuilder sb = new StringBuilder();
sb.Append("<div class=\"searchPanelRow\">");
sb.Append("<div class=\"searchPanelRowTitle\">");
sb.Append("<label class=\"searchPanelLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div>");
sb.Append("<div class=\"searchPanelRowValue\">");
sb.Append(helper.ToHtmlString());
sb.Append("</div>");
sb.Append("</div>");
if (withMask)
sb.Append("<script>$(\"#").Append(helper.ToComponent().Name.Replace('.', '_')).Append("\").kendoMaskedDateTimePicker();</script>");
sb.Append("<script>$(\"#").Append(helper.ToComponent().Name.Replace('.', '_')).Append("\").change(function() { KretaDateTimeHelper.validateDateTime($(this)); });</script>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithMask(this DateTimePickerBuilder helper)
{
var controlId = helper.ToComponent().Id;
var output = new StringBuilder();
output.Append(helper.ToHtmlString());
output.Append("<script>");
output.Append($"$(\"#{controlId}\").kendoMaskedDateTimePicker();");
output.Append($"$(\"#{controlId}\").change(function() {{ KretaDateTimeHelper.validateDateTime($(this)); }});");
output.Append("</script>");
return new MvcHtmlString(output.ToString());
}
public static MvcHtmlString RenderWithName(this DateTimePickerBuilder helper, int labelWidth = 6, int inputWidth = 6, bool withMask = true, string tooltipResource = null)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, helper.ToComponent().Name, labelMsg);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, helper.ToComponent().Name, labelMsg, tooltipResource);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb, withMask, helper.ToComponent().Name);
return new MvcHtmlString(sb.ToString());
}
private static void AddRenderWithNameBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, string controlName, string labelMsg)
{
sb.AppendFormat("<div class=\"{0}\">", BootsrapHelper.GetSizeClasses(labelWidth));
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0} \">{1}</label>", controlName, labelMsg);
sb.AppendFormat("</div><div class=\"{0} \">", BootsrapHelper.GetSizeClasses(inputWidth));
}
private static void AddRenderWithNameTooltipBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, string controlName, string labelMsg, string tooltipResource)
{
sb.AppendFormat("<div class=\"{0} kretaLabelTooltip \">", BootsrapHelper.GetSizeClasses(labelWidth));
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0} \">{1}", controlName, labelMsg);
sb.Append("&nbsp;<img class='kretaLabelTooltipImg' />");
sb.AppendFormat("<span class=\"kretaLabelTooltipText\">{0}</span>", tooltipResource);
sb.Append("</label>");
sb.AppendFormat("</div><div class=\"{0} \">", BootsrapHelper.GetSizeClasses(inputWidth));
}
private static void AddRenderWithNameCloseingFrame(StringBuilder sb, bool withMask, string controlName)
{
sb.Append("</div>");
if (withMask)
sb.AppendFormat("<script>$(\"#{0} \").kendoMaskedDateTimePicker();</script>", controlName.Replace('.', '_'));
sb.Append("<script>$(\"#").Append(controlName.Replace('.', '_')).Append("\").change(function() { KretaDateTimeHelper.validateDateTime($(this)); });</script>");
}
public static MvcHtmlString RenderWithName(this DateTimePickerBuilder helper, string label, int labelWidth = 6, int inputWidth = 6, bool withMask = true, string tooltipResource = null)
{
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, helper.ToComponent().Name, label);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, helper.ToComponent().Name, label, tooltipResource);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb, withMask, helper.ToComponent().Name);
return new MvcHtmlString(sb.ToString());
}
}
}

View file

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Web.Mvc;
namespace Kreta.Web.Helpers
{
public static class DisplayTextExtensions
{
public static MvcHtmlString KretaDisplayTextFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, IDictionary<string, object> htmlAttributes = null, string id = null)
{
ModelMetadata metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
string htmlFieldName = ExpressionHelper.GetExpressionText(expression);
string fullHtmlFieldId = html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId(htmlFieldName);
string text = metadata.Model?.ToString();
if (string.IsNullOrWhiteSpace(text))
{
return MvcHtmlString.Empty;
}
var tag = new TagBuilder("label");
tag.MergeAttributes(htmlAttributes);
if (!string.IsNullOrWhiteSpace(id))
{
tag.MergeAttribute("id", id);
}
tag.MergeAttribute("displayfor", fullHtmlFieldId);
tag.AddCssClass("windowInputValue");
tag.SetInnerText(text);
return MvcHtmlString.Create(tag.ToString(TagRenderMode.Normal));
}
}
}

View file

@ -0,0 +1,313 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
using Kreta.Framework;
namespace Kreta.Web.Helpers
{
public static class DropdownListExtensions
{
public static DropDownListBuilder KretaDropdownList(this HtmlHelper helper, string id, string url = null
, string dataTextField = "Text", string datavalueField = "Value", string groupName = null, Type groupType = null)
{
if (groupName != null)
{
var dropdownlist = helper.Kendo().DropDownList()
.Name(id)
.DataTextField(dataTextField)
.DataValueField(datavalueField)
.DataSource(source =>
{
source.Custom()
.ServerFiltering(true)
.Transport(transport =>
{
transport.Read(
read => read.Url(url));
})
.Group(g => g.Add(groupName, groupType));
});
return dropdownlist;
}
else
{
var dropdownlist = helper.Kendo().DropDownList()
.Name(id)
.DataTextField(dataTextField)
.DataValueField(datavalueField)
.DataSource(source =>
{
source.Custom()
.ServerFiltering(true)
.Transport(transport =>
{
transport.Read(
read => read.Url(url));
});
});
return dropdownlist;
}
}
public static DropDownListBuilder KretaDropdownList(this HtmlHelper helper, string id, IEnumerable<SelectListItem> selectList, IDictionary<string, object> htmlAttributes = null)
{
if (htmlAttributes == null)
htmlAttributes = new Dictionary<string, object>();
htmlAttributes.Add("data-labelmsg", id);
var dropdown = helper.Kendo().DropDownList()
.Name(id)
.BindTo(selectList)
.HtmlAttributes(htmlAttributes);
return dropdown;
}
public static DropDownListBuilder KretaDropdownListFor<TModel, TProperty>(
this HtmlHelper<TModel> helper,
Expression<Func<TModel, TProperty>> expression,
IEnumerable<SelectListItem> selectList,
IDictionary<string, object> htmlAttributes = null,
bool addOptionLabel = true
)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
if (htmlAttributes == null)
htmlAttributes = new Dictionary<string, object>();
var validationAttributes = helper.GetUnobtrusiveValidationAttributes(fullBindingName, metadata);
foreach (var key in validationAttributes.Keys)
{
if (key == "data-val-required")
{
htmlAttributes.Add("title", validationAttributes[key].ToString());
}
}
if (metadata.IsRequired)
{
htmlAttributes.Add("data-rule-required", "true");
htmlAttributes.Add("data-labelmsg", metadata.DisplayName + " *");
}
else
{
htmlAttributes.Add("data-labelmsg", metadata.DisplayName);
}
selectList = selectList.Where(t => !string.IsNullOrWhiteSpace(t.Value)).ToList();
var dropdown = helper.Kendo()
.DropDownListFor(expression)
.BindTo(selectList)
.HtmlAttributes(htmlAttributes);
if (addOptionLabel && selectList.Count() > 1)
{
dropdown.OptionLabel(StringResourcesUtil.GetString(364));
}
return dropdown;
}
public static DropDownListBuilder KretaDropdownListFor<TModel, TProperty>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TProperty>> expression, string url, string dataTextField = "Text", string datavalueField = "Value", IDictionary<string, object> htmlAttributes = null)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
var value = metadata.Model;
if (htmlAttributes == null)
htmlAttributes = new Dictionary<string, object>();
var validationAttributes = helper.GetUnobtrusiveValidationAttributes(fullBindingName, metadata);
foreach (var key in validationAttributes.Keys)
{
if (key == "data-val-required")
{
htmlAttributes.Add("title", validationAttributes[key].ToString());
}
}
if (metadata.IsRequired)
{
htmlAttributes.Add("data-rule-required", "true");
//htmlAttributes.Add("title", string.Format(StringResourcesUtil.GetString(3477), metadata.DisplayName));
htmlAttributes.Add("data-labelmsg", metadata.DisplayName + " *");
}
else
{ htmlAttributes.Add("data-labelmsg", metadata.DisplayName); }
var dropdown = helper.Kendo()
.DropDownListFor(expression)
.HtmlAttributes(htmlAttributes)
.DataTextField(dataTextField)
.DataValueField(datavalueField)
.DataSource(source =>
{
source.Custom()
.ServerFiltering(true)
.Transport(transport =>
{
transport.Read(
read => read.Url(url));
}).Group(g => g.Add("Group", typeof(string)));
});
return dropdown;
}
public static MvcHtmlString RenderSearchPanel(this DropDownListBuilder helper)
{
List<SelectListItem> modSelectList = new List<SelectListItem>();
modSelectList.Add(new SelectListItem() { Text = StringResourcesUtil.GetString(364), Value = "" });
foreach (var item in helper.ToComponent().DataSource.Data)
{
var dli = (DropDownListItem)item;
modSelectList.Add(new SelectListItem() { Text = dli.Text, Value = dli.Value, Selected = dli.Selected });
}
if (modSelectList.Count == 2)
helper.BindTo(modSelectList);
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
StringBuilder sb = new StringBuilder();
sb.Append("<div class=\"searchInputRowHeight\"><div>");
sb.Append("<label class=\"searchPanelInputLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div><div>");
sb.Append(helper.ToHtmlString());
sb.Append("</div></div>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderSearchPanelSideBar(this DropDownListBuilder helper)
{
List<SelectListItem> modSelectList = new List<SelectListItem>();
modSelectList.Add(new SelectListItem() { Text = StringResourcesUtil.GetString(364), Value = "" });
foreach (var item in helper.ToComponent().DataSource.Data)
{
var dli = (DropDownListItem)item;
modSelectList.Add(new SelectListItem() { Text = dli.Text, Value = dli.Value, Selected = dli.Selected });
}
if (modSelectList.Count == 2)
helper.BindTo(modSelectList);
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
StringBuilder sb = new StringBuilder();
sb.Append("<div class=\"searchPanelRow\">");
sb.Append("<div class=\"searchPanelRowTitle\">");
sb.Append("<label class=\"searchPanelLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div>");
sb.Append("<div class=\"searchPanelRowValue\">");
sb.Append(helper.ToHtmlString());
sb.Append("</div>");
sb.Append("</div>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithName(this DropDownListBuilder helper, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string tooltipResource = null)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, labelMsg);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, labelMsg, tooltipResource);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
return new MvcHtmlString(sb.ToString());
}
private static void AddRenderWithNameBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, bool allSizeSame, string controlName, string labelMsg)
{
sb.AppendFormat("<div class=\"{0}\">", BootsrapHelper.GetSizeClasses(labelWidth, allSizeSame));
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}</label>", controlName, labelMsg);
sb.AppendFormat("</div><div class=\"{0} \">", BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame));
}
private static void AddRenderWithNameTooltipBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, bool allSizeSame, string controlName, string labelMsg, string tooltipResource)
{
sb.AppendFormat("<div class=\"{0} kretaLabelTooltip \">", BootsrapHelper.GetSizeClasses(labelWidth, allSizeSame));
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}", controlName, labelMsg);
sb.Append("&nbsp;<img class='kretaLabelTooltipImg' />");
sb.AppendFormat("<span class=\"kretaLabelTooltipText\">{0}</span>", tooltipResource);
sb.Append("</label>");
sb.AppendFormat("</div><div class=\"{0} \">", BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame));
}
private static void AddRenderWithNameCloseingFrame(StringBuilder sb)
{
sb.Append("</div>");
}
public static MvcHtmlString RenderWithName(this DropDownListBuilder helper, string label, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string tooltipResource = null)
{
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, label);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, label, tooltipResource);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithoutName(this DropDownListBuilder helper, int inputWidth = 6, bool allSizeSame = false, string tooltipResource = null)
{
var sb = new StringBuilder();
sb.AppendFormat($"<div class=\"{{0}} {(!string.IsNullOrWhiteSpace(tooltipResource) ? "kretaLabelTooltip" : "")}\">", BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame));
if (!string.IsNullOrWhiteSpace(tooltipResource))
{
helper.HtmlAttributes(new { style = "width: 94% !important;" });
}
sb.Append(helper.ToHtmlString());
if (!string.IsNullOrWhiteSpace(tooltipResource))
{
sb.Append("&nbsp;<img class='kretaLabelTooltipImg' />");
sb.AppendFormat("<span class=\"kretaLabelTooltipText\">{0}</span>", tooltipResource);
}
sb.Append("</div>");
return new MvcHtmlString(sb.ToString());
}
}
}

View file

@ -0,0 +1,16 @@
using System.Text;
using System.Web.Mvc;
namespace Kreta.Web.Helpers
{
public static class EmptyExtensions
{
public static MvcHtmlString KretaEmpty(this HtmlHelper helper, int width = 6)
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("<div class=\"searchInputRowHeight emptyRow {0} \"></div>", BootsrapHelper.GetSizeClasses(width));
return new MvcHtmlString(sb.ToString());
}
}
}

View file

@ -0,0 +1,16 @@
using System;
namespace Kreta.Web.Helpers.Error
{
public class KretaError : Exception
{
public KretaError(string message) : base(message)
{
}
}
public class KretaMissingTanoraException : Exception
{
public KretaMissingTanoraException(string message) : base(message) { }
}
}

View file

@ -0,0 +1,47 @@
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
namespace Kreta.Web.Helpers.Error
{
public static class ModelStateExtensions
{
public class MvcModelState
{
public MvcModelState()
{
MVCModelState = new List<Error>();
}
public List<Error> MVCModelState { get; set; }
}
public class Error
{
public Error(string key, string message)
{
Key = key;
Message = message;
}
public string Key { get; set; }
public string Message { get; set; }
}
public static MvcModelState AllErrors(this ModelStateDictionary modelState)
{
var result = new MvcModelState();
var erroneousFields = modelState.Where(ms => ms.Value.Errors.Any())
.Select(x => new { x.Key, x.Value.Errors });
foreach (var erroneousField in erroneousFields)
{
var fieldKey = erroneousField.Key;
var fieldErrors = erroneousField.Errors
.Select(error => new Error(fieldKey, error.ErrorMessage));
result.MVCModelState.AddRange(fieldErrors);
}
return result;
}
}
}

View file

@ -0,0 +1,78 @@
using System;
using System.Net;
using System.Web.Routing;
using Kreta.Enums.ManualEnums;
namespace Kreta.Web.Helpers.Error
{
public class StatusError : Exception
{
public int StatusCode { get; private set; }
public object Json { get; set; }
public Exception UnHandledException { get; set; }
public RouteValueDictionary Redirect { get; set; }
public string CloseFunction { get; set; }
public StatusError(int statusCode, string message) : base(message)
{
this.StatusCode = statusCode;
}
public StatusError(HttpStatusCode statusCode, string message) : base(message)
{
this.StatusCode = (int)statusCode;
}
public StatusError(CustomHTTPStatusEnum statusCode, string message) : base(message)
{
this.StatusCode = (int)statusCode;
}
public StatusError(HttpStatusCode statusCode, string message, Exception ex) : base(message)
{
this.StatusCode = (int)statusCode;
UnHandledException = ex;
}
}
public class ErrorModel
{
public ErrorModel()
{
IsStatusError = true;
}
public bool IsStatusError { get; set; }
public string Message { get; set; }
public object Json { get; set; }
public int Status { get; set; }
public bool IsMvc { get; set; }
public Guid? ErrorCode { get; set; }
public string CloseFunction { get; set; }
}
public class ClientErrorModel
{
public string Message { get; set; }
public string URL { get; set; }
public string Line { get; set; }
public string Column { get; set; }
public string Error { get; set; }
public string StackTrace { get; set; }
public string Agent { get; set; }
}
public class ClientError : Exception
{
public ClientError(ClientErrorModel model) : base(model.Message)
{
this.Data.Add("Line", model.Line);
this.Data.Add("Column", model.Column);
this.Data.Add("Error", model.Error);
this.Data.Add("URL", model.URL);
this.Data.Add("Agent", model.Agent);
this.Data.Add("StackTrace", model.StackTrace);
}
}
}

View file

@ -0,0 +1,17 @@
using System.Net;
namespace Kreta.Web.Helpers.Error
{
public static class StatusErrorFactory
{
public static StatusError GetSorolasStatusErrorWithReloadDDL(string message)
{
return new StatusError(HttpStatusCode.BadRequest, message) { CloseFunction = "KretaOsztalybaSorolasHelper.afterErrorReloadDDL();" };
}
public static StatusError GetSorolasStatusError(string message)
{
return new StatusError(HttpStatusCode.BadRequest, message);
}
}
}

View file

@ -0,0 +1,27 @@
using System.Collections.Generic;
using System.Web.Http.ModelBinding;
namespace Kreta.Web.Helpers
{
public static class ModelStateExtension
{
public static void AddRange(this ModelStateDictionary modelStateDictionary, Dictionary<string, string> dictionary)
{
foreach (KeyValuePair<string, string> item in dictionary)
{
modelStateDictionary.AddModelError(item.Key, item.Value);
}
}
public static void AddRange(this ModelStateDictionary modelStateDictionary, Dictionary<string, List<string>> dictionary)
{
foreach (KeyValuePair<string, List<string>> item in dictionary)
{
foreach (string value in item.Value)
{
modelStateDictionary.AddModelError(item.Key, value);
}
}
}
}
}

View file

@ -0,0 +1,213 @@
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
namespace Kreta.Web.Helpers
{
public static class FileUploadExtensions
{
public static UploadBuilder KretaFileUpload(
this HtmlHelper helper,
string name,
string saveUrl,
string removeUrl = null,
bool autoUpload = false,
bool allowMultiple = false,
bool showFileList = true,
string onSuccessEvent = null,
string onErrorEvent = null,
string onRemoveEvent = null,
string onSelectEvent = null,
string onUploadEvent = null,
string onCompleteEvent = null,
string onCancelEvent = null,
string onProgressEvent = null,
bool enabled = true,
bool batchig = true,
Dictionary<string, object> htmlAttributes = null,
string uploadText = "Fájl feltöltés",
string selectText = "Fájl kiválasztása",
string headerStatusUploadedText = "Állomány feldolgozva, feltöltés folyamatban")
{
var upload = helper.Kendo().Upload();
upload.Name(name);
upload.Events(e =>
{
if (!string.IsNullOrWhiteSpace(onErrorEvent))
e.Error(onErrorEvent);
if (!string.IsNullOrWhiteSpace(onSuccessEvent))
e.Success(onSuccessEvent);
if (!string.IsNullOrWhiteSpace(onRemoveEvent))
e.Remove(onRemoveEvent);
if (!string.IsNullOrWhiteSpace(onSelectEvent))
e.Select(onSelectEvent);
if (!string.IsNullOrWhiteSpace(onUploadEvent))
e.Upload(onUploadEvent);
if (!string.IsNullOrWhiteSpace(onCompleteEvent))
e.Complete(onCompleteEvent);
if (!string.IsNullOrWhiteSpace(onCancelEvent))
e.Cancel(onCancelEvent);
if (!string.IsNullOrWhiteSpace(onProgressEvent))
e.Progress(onProgressEvent);
});
upload.Enable(enabled);
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
htmlAttributes.Add("title", selectText);
upload.HtmlAttributes(htmlAttributes);
upload.Multiple(allowMultiple);
upload.ShowFileList(showFileList);
upload.Async(a =>
{
a.AutoUpload(autoUpload);
a.SaveUrl(saveUrl);
a.RemoveUrl(removeUrl);
a.Batch(batchig);
});
upload.Messages(m =>
{
m.Select(selectText);
m.Cancel("Mégse");
m.DropFilesHere("Húzza a kívánt fájlt ide");
m.HeaderStatusUploaded(headerStatusUploadedText);
m.HeaderStatusUploading("Feldolgozás alatt");
m.Remove("Fájl törlése");
m.Retry("Újrapróbálkozás");
m.StatusFailed("Sikertelen");
m.StatusUploaded("Sikeres");
m.StatusUploading("Feldolgozás folyamatban");
m.UploadSelectedFiles(uploadText);
});
return upload;
}
public static MvcHtmlString KretaFileUpload(
this HtmlHelper helper,
string name,
string onSelectEvent = null,
string onRemoveEvent = null,
bool allowMultiple = true,
bool needCustomHtmlString = false,
string selectText = "Fájl tallózása...",
Dictionary<string, object> htmlAttributes = null)
{
var upload = helper.Kendo().Upload();
upload.Name(name);
upload.Events(e =>
{
if (!string.IsNullOrWhiteSpace(onSelectEvent))
e.Select(onSelectEvent);
if (!string.IsNullOrWhiteSpace(onRemoveEvent))
e.Remove(onRemoveEvent);
});
if (htmlAttributes != null)
{
upload.HtmlAttributes(htmlAttributes);
}
upload.Messages(m =>
{
m.Select(selectText);
m.Cancel("Mégse");
m.DropFilesHere("Húzza a kívánt fájlt ide");
m.HeaderStatusUploaded("Állomány feldolgozva, feltöltés folyamatban");
m.HeaderStatusUploading("Feldolgozás alatt");
m.Remove("Fájl törlése");
m.Retry("Újrapróbálkozás");
m.StatusFailed("Sikertelen");
m.StatusUploaded("Sikeres");
m.StatusUploading("Feldolgozás folyamatban");
m.UploadSelectedFiles("Fájl feltöltés");
});
upload.Multiple(allowMultiple);
var htmlString = upload.ToString();
if (needCustomHtmlString)
{
Match match = Regex.Match(htmlString, @"(.*\/>)(.)", RegexOptions.IgnoreCase);
if (match.Success)
{
var inputHtmlString = match.Groups[1].Value;
var customHtmlString = string.Empty;
var scriptHtmlString = htmlString.Substring(match.Groups[2].Index);
htmlString = inputHtmlString + customHtmlString + scriptHtmlString;
}
}
return new MvcHtmlString(htmlString);
}
public static MvcHtmlString KretaAsyncFileUpload(
this HtmlHelper helper,
string name,
// Ez azért kell ide, mert ha nincs megadva, akkor hiába van ott az async, nem lesz aszinkron a komponens. Ez később felül van csapva a megfelelő url-lel
string saveUrl = "http://localhost",
string onSelectEvent = null,
string onUploadEvent = null,
string onErrorEvent = null,
string onCompleteEvent = null,
bool allowMultiple = true,
bool needCustomHtmlString = false,
string selectText = "Fájl tallózása...",
Dictionary<string, object> htmlAttributes = null
)
{
var upload = helper.Kendo().Upload();
upload.Name(name);
upload.Events(e =>
{
if (!string.IsNullOrWhiteSpace(onSelectEvent))
e.Select(onSelectEvent);
if (!string.IsNullOrWhiteSpace(onErrorEvent))
e.Error(onErrorEvent);
if (!string.IsNullOrWhiteSpace(onUploadEvent))
e.Upload(onUploadEvent);
if (!string.IsNullOrWhiteSpace(onCompleteEvent))
e.Complete(onCompleteEvent);
});
upload.Async(a =>
{
a.AutoUpload(true);
a.SaveUrl(saveUrl);
});
if (htmlAttributes != null)
{
upload.HtmlAttributes(htmlAttributes);
}
upload.Messages(m =>
{
m.Select(selectText);
m.HeaderStatusUploaded("Kész");
m.HeaderStatusUploading("Feldolgozás alatt");
});
upload.Multiple(allowMultiple);
upload.ShowFileList(false);
var htmlString = upload.ToString();
if (needCustomHtmlString)
{
Match match = Regex.Match(htmlString, @"(.*\/>)(.)", RegexOptions.IgnoreCase);
if (match.Success)
{
var inputHtmlString = match.Groups[1].Value;
var customHtmlString = string.Empty;
var scriptHtmlString = htmlString.Substring(match.Groups[2].Index);
htmlString = inputHtmlString + customHtmlString + scriptHtmlString;
}
}
return new MvcHtmlString(htmlString);
}
}
}

View file

@ -0,0 +1,51 @@
using System.Collections.Generic;
using System.Text;
using System.Web.Mvc;
using System.Web.Mvc.Html;
namespace Kreta.Web.Helpers
{
public static class FormExtensions
{
public static MvcForm KretaForm(this HtmlHelper htmlHelper, string name, Dictionary<string, object> htmlAttributes = null)
{
if (htmlAttributes == null)
htmlAttributes = new Dictionary<string, object>();
htmlAttributes.Add("id", name);
htmlAttributes.Add("onsubmit", "return false");
var mvcForm = htmlHelper.BeginForm(null, null, FormMethod.Get, htmlAttributes);
var formName = "#" + name;
StringBuilder sb = new StringBuilder();
sb.Append("<script>$.validator.setDefaults({ ignore: [] });</script>");
sb.AppendFormat("<script>KretaForm.validate($('{0}'));</script>", formName);
htmlHelper.ViewContext.Writer.Write(sb.ToString());
sb.Append("</form>");
return mvcForm;
}
public static MvcForm KretaForm(this HtmlHelper htmlHelper, string actionName, string controllerName, FormMethod method, string name, Dictionary<string, object> htmlAttributes = null)
{
if (htmlAttributes == null)
htmlAttributes = new Dictionary<string, object>();
htmlAttributes.Add("id", name);
var mvcForm = htmlHelper.BeginForm(actionName, controllerName, method, htmlAttributes);
var formName = "#" + name;
StringBuilder sb = new StringBuilder();
sb.Append("<script>$.validator.setDefaults({ ignore: [] });</script>");
sb.AppendFormat("<script>KretaForm.validate($('{0}'));</script>", formName);
htmlHelper.ViewContext.Writer.Write(sb.ToString());
return mvcForm;
}
}
}

View file

@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Text;
using Kendo.Mvc;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using Kreta.Core;
using Kreta.Framework.Util;
namespace Kreta.Web.Helpers.Grid
{
public static class Converter
{
public static GridParameters GridParameter(DataSourceRequest request)
{
var gridParameters = new GridParameters
{
LoadResultSetInfo = true
};
IList<SortDescriptor> sort = request.Sorts;
if (sort != null && sort.Count > 0)
{
var sortString = new StringBuilder(string.Empty);
foreach (SortDescriptor item in sort)
{
gridParameters.OrderDictionary.Add(item.Member, item.SortDirection);
sortString.Append(item.Member);
sortString.Append(item.SortDirection == ListSortDirection.Ascending ? " ASC" : " DESC");
sortString.Append(",");
}
gridParameters.OrderBy = sortString.ToString(0, sortString.Length - 1);
}
gridParameters.FirstRow = (request.Page - 1) * request.PageSize;
gridParameters.LastRow = request.Page * request.PageSize - 1;
return gridParameters;
}
[Obsolete(@"A ToDataSourceResult<T>-t kell használni model listákkal, mivel ezeket mostmár tudjuk sorbarendezni a GridParameters-el,
így nincs szükség , hogy elmenjen a DataSet a Web-re ezért nincs is szükség itt sorrenezni őket!")]
public static DataSourceResult ToDataSourceResult(this DataSet dataSet, DataSourceRequest request = null)
{
if (dataSet.Tables.Count < 1)
{
return null;
}
DataTable firstLevel = dataSet.Tables[0];
DataSourceResult result = firstLevel.ToDataSourceResult(request ?? new DataSourceRequest());
result.Total = Convert.ToInt32(firstLevel.ExtendedProperties["RowCount"]);
return result;
}
/// <summary>
/// Generikus objektumlistából készítünk Kendo-s DataSourceResult-ot a Kendo-s grid-eknek.
/// Sorba rendezzük az adatokat és beállítjuk a lapozást a GridParameters objektum alapján a SortingAndPaging extension method-dal.
/// Végül visszaadjuk az eredményt, beállítva az összes elem számát is(ez az összes elem számának megjelenítéséhez kell a grid-en).
/// </summary>
/// <typeparam name="T">A T bármilyen típusú objektum lehet, de leginkább Model-ekkel kellene használni.</typeparam>
/// <param name="itemList">A T típusú objektumlista, amivel dolgozunk.</param>
/// <param name="gridParameters">A GridParameters property-jei(OrderList, FirstRow, LastRow) alapján határozzuk meg, hogy milyen paraméterek alapján rendezzünk sorba és állítjuk be a lapozást.</param>
/// <returns></returns>
public static DataSourceResult ToDataSourceResult<T>(this List<T> itemList, GridParameters gridParameters = null)
{
if (itemList == null)
{
return null;
}
List<T> data = gridParameters == null ? itemList : itemList.SortingAndPaging(gridParameters.OrderDictionary, gridParameters.FirstRow, gridParameters.LastRow);
var dataSourceResult = new DataSourceResult
{
Data = data,
Total = itemList.Count
};
return dataSourceResult;
}
}
}

View file

@ -0,0 +1,8 @@
namespace Kreta.Web.Helpers.Grid
{
public class ExportColumn
{
public string Field { get; set; }
public string Title { get; set; }
}
}

View file

@ -0,0 +1,18 @@
using System.Collections.Generic;
namespace Kreta.Web.Helpers.Grid
{
public class FunctionCommand
{
public FunctionCommand()
{
Enabled = true;
}
public string Name { get; set; }
public int? NameResourceId { get; set; }
public string ClientAction { get; set; }
public bool Enabled { get; set; }
public string Classes { get; set; }
public List<FunctionCommand> NestedCommands { get; set; }
}
}

View file

@ -0,0 +1,28 @@
using System.Collections.Generic;
using System.Web.Routing;
namespace Kreta.Web.Helpers.Grid
{
public class GridApiUrl
{
public string Route { get; private set; }
public RouteValueDictionary RouteValues { get; private set; }
public GridApiUrl(string controller, string action, string route = Constants.RouteKey.ActionApi)
{
RouteValues = new RouteValueDictionary();
RouteValues.Add("controller", controller);
RouteValues.Add("action", action);
Route = route;
}
public GridApiUrl(string controller, string action, IDictionary<string, string> parameters, string route = Constants.RouteKey.ActionApi) : this(controller, action, route)
{
foreach (var item in parameters)
{
RouteValues.Add(item.Key, item.Value);
}
}
}
}

View file

@ -0,0 +1,12 @@
using Kreta.Enums.ManualEnums;
namespace Kreta.Web.Helpers.Grid
{
public class GridButtonColumn
{
public string LinkTitle { get; set; }
public string FunctionClientName { get; set; }
public GridButtonsEnum ButtonType { get; set; }
public string HiddenCondition { get; set; }
}
}

View file

@ -0,0 +1,10 @@
using Kendo.Mvc.UI;
namespace Kreta.Web.Helpers.Grid
{
public class KretaGridDataSourceRequest : DataSourceRequest
{
/*js ből jön ne nevezd át*/
public string data { get; set; }
}
}

View file

@ -0,0 +1,16 @@
using Kreta.Enums.ManualEnums;
namespace Kreta.Web.Helpers.Grid
{
public class RowFunction
{
public string Name { get; set; }
public int? NameResourceId { get; set; }
public string ClientAction { get; set; }
public GridRowFunctionIconEnum? IconEnum { get; set; }
public bool IsConditional { get; set; }
public bool IsMultipleConditionalColumn { get; set; }
public string IsVisibleRowFunctionJsFunctionName { get; set; }
public bool SendSender { get; set; }
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,35 @@
using System.Text;
using System.Web.Mvc;
namespace Kreta.Web.Helpers
{
public static class GridTemplateExtensions
{
public static MvcHtmlString KretaGridTemplate(this HtmlHelper helper, string templateId)
{
StringBuilder sb = new StringBuilder();
sb
.Append($"<script id=\"{templateId}\" type=\"text/x-kendo-template\">")
.Append("</script>");
MvcHtmlString str = new MvcHtmlString(sb.ToString());
return str;
}
public static MvcHtmlString KretaTooltipTemplate(this HtmlHelper helper, string templateId, string content)
{
StringBuilder sb = new StringBuilder();
sb
.Append($"<script id=\"{templateId}\" type=\"text/x-kendo-template\">")
.Append(content)
.Append("</script>");
MvcHtmlString str = new MvcHtmlString(sb.ToString());
return str;
}
}
}

View file

@ -0,0 +1,22 @@
using System.Text;
using System.Web.Mvc;
namespace Kreta.Web.Helpers
{
public static class GroupControlExtensions
{
public static MvcHtmlString RenderGroupStart(this HtmlHelper helper, string name, int size = 12, string paramGroupId = "")
{
var groupId = string.IsNullOrWhiteSpace(paramGroupId) ? name : paramGroupId;
StringBuilder sb = new StringBuilder();
sb.AppendFormat("<div id='{0}' style='border-top: 1px solid gainsboro; padding: 0px; margin-top: 20px;' class='{1}'>", groupId, BootsrapHelper.GetSizeClasses(size)).AppendLine();
sb.AppendFormat("<span style='position: absolute; top: -24px; left: 5px; padding: 0px 5px 0px 5px;' class='k-content windowInputLabel'>{0}</span><br />", name);
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderGroupEnd(this HtmlHelper helper)
{
return new MvcHtmlString("</div>");
}
}
}

View file

@ -0,0 +1,54 @@
using System;
using System.Linq.Expressions;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
namespace Kreta.Web.Helpers
{
public static class HtmlEditorExtensions
{
public static EditorBuilder KretaHtmlEditorFor<T>(this HtmlHelper<T> helper, Expression<Func<T, string>> expr, bool encode = true)
{
var editor = helper.Kendo().EditorFor(expr)
.HtmlAttributes(new { @class = "htmlEditor", UseEmbeddedScripts = "false" })
.Encode(encode)
.PasteCleanup(p => p
.All(false)
.Css(true)
.KeepNewLines(false)
.MsAllFormatting(true)
.MsConvertLists(true)
.MsTags(true)
.None(false)
.Span(true)
)
.Tools(tools => tools
.Clear()
.Bold()
.Italic()
.Underline()
.Strikethrough()
.Separator()
.FontName()
.FontSize()
.FontColor()
.BackColor()
.Separator()
.JustifyLeft()
.JustifyCenter()
.JustifyRight()
.JustifyFull()
.Separator()
.InsertUnorderedList()
.InsertOrderedList()
.Separator()
.Indent()
.Outdent()
.Separator()
);
return editor;
}
}
}

View file

@ -0,0 +1,49 @@

using System.Web.Mvc;
using System.Web.Routing;
namespace Kreta.Web.Helpers
{
public static class HtmlHelpers
{
public static HtmlHelper<TModel> For<TModel>(this HtmlHelper helper) where TModel : class, new()
{
return For<TModel>(helper.ViewContext, helper.ViewDataContainer.ViewData, helper.RouteCollection);
}
public static HtmlHelper<TModel> For<TModel>(this HtmlHelper helper, TModel model)
{
return For<TModel>(helper.ViewContext, helper.ViewDataContainer.ViewData, helper.RouteCollection, model);
}
public static HtmlHelper<TModel> For<TModel>(ViewContext viewContext, ViewDataDictionary viewData, RouteCollection routeCollection) where TModel : class, new()
{
TModel model = new TModel();
return For<TModel>(viewContext, viewData, routeCollection, model);
}
public static HtmlHelper<TModel> For<TModel>(ViewContext viewContext, ViewDataDictionary viewData, RouteCollection routeCollection, TModel model)
{
var newViewData = new ViewDataDictionary(viewData) { Model = model };
ViewContext newViewContext = new ViewContext(
viewContext.Controller.ControllerContext,
viewContext.View,
newViewData,
viewContext.TempData,
viewContext.Writer);
var viewDataContainer = new ViewDataContainer(newViewContext.ViewData);
return new HtmlHelper<TModel>(newViewContext, viewDataContainer, routeCollection);
}
private class ViewDataContainer : IViewDataContainer
{
public ViewDataDictionary ViewData { get; set; }
public ViewDataContainer(ViewDataDictionary viewData)
{
ViewData = viewData;
}
}
}
}

View file

@ -0,0 +1,30 @@
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Mime;
using System.Text;
using System.Web;
using Kreta.BusinessLogic.Classes;
namespace Kreta.Web.Helpers
{
public static class HttpResponseExtensions
{
public static HttpResponseMessage GetFileHttpResponse(byte[] content, string fileName)
{
var result = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new ByteArrayContent(content)
};
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
FileName = HttpUtility.UrlEncode(fileName.ToComparableString(), Encoding.UTF8)
};
result.Content.Headers.ContentType = new MediaTypeHeaderValue(MediaTypeNames.Application.Octet);
return result;
}
}
}

View file

@ -0,0 +1,27 @@
using System.Collections.Generic;
using System.Text;
using System.Web.Mvc;
namespace Kreta.Web.Helpers
{
public static class IconExtensions
{
public static MvcHtmlString KretaIcon(this HtmlHelper helper, string icon, IDictionary<string, object> htmlAttributes = null)
{
StringBuilder sb = new StringBuilder();
sb.Append(string.Format("<i class=\"fa {0}\" ", icon));
if (htmlAttributes != null)
{
foreach (var item in htmlAttributes)
{
sb.Append(string.Format(" {0}=\"{1}\" ", item.Key, item.Value.ToString()));
}
}
sb.Append("></i>");
MvcHtmlString str = new MvcHtmlString(sb.ToString());
return str;
}
}
}

View file

@ -0,0 +1,21 @@
using System.Web.Mvc;
namespace Kreta.Web.Helpers
{
public static class ImageExtensions
{
public static MvcHtmlString Base64EncodedImage(this HtmlHelper htmlHelper, string encodedImage, string alText = default(string))
{
var tagBuilder = new TagBuilder("img");
tagBuilder.Attributes.Add("class", $"rounded mx-auto d-block");
tagBuilder.Attributes.Add("src", $"{encodedImage}");
if (!string.IsNullOrWhiteSpace(alText))
{
tagBuilder.Attributes.Add("alt", alText);
}
return new MvcHtmlString(tagBuilder.ToString());
}
}
}

View file

@ -0,0 +1,113 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;
namespace Kreta.Web.Helpers
{
public static class LabelExtensions
{
public static MvcHtmlString KretaInputLabelFor<TModel, TValue>(this HtmlHelper<TModel> html, Expression<Func<TModel, TValue>> expression, IDictionary<string, object> htmlAttributes = null)
{
var metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
string htmlFieldName = ExpressionHelper.GetExpressionText(expression);
string fullHtmlFieldName = html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(htmlFieldName);
string fullHtmlFieldId = html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId(htmlFieldName);
string text = metadata.DisplayName ?? metadata.PropertyName ?? htmlFieldName.Split('.').Last();
if (string.IsNullOrWhiteSpace(text))
{
return MvcHtmlString.Empty;
}
var validationAttributes = html.GetUnobtrusiveValidationAttributes(fullHtmlFieldName, metadata);
bool isRequiredIf = RequiredIfReflector.RequiredIf(html, validationAttributes);
if (metadata.IsRequired || isRequiredIf)
{
text += " *";
}
var tag = new TagBuilder("label");
tag.MergeAttributes(htmlAttributes);
tag.MergeAttribute("for", fullHtmlFieldId);
tag.AddCssClass("windowInputLabel");
tag.SetInnerText(text);
return MvcHtmlString.Create(tag.ToString(TagRenderMode.Normal));
}
public static MvcHtmlString KretaLabelFor<TModel, TResult>(this HtmlHelper<TModel> html, Expression<Func<TModel, TResult>> expression, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string id = "", bool formatted = false, string labelText = null)
{
return KretaLabelForInner(html, expression, labelWidth, inputWidth, allSizeSame, true, id, formatted, labelText: labelText);
}
public static MvcHtmlString KretaLabelForWithoutName<TModel, TResult>(this HtmlHelper<TModel> html, Expression<Func<TModel, TResult>> expression, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string id = "", bool formatted = false, IDictionary<string, object> htmlAttributes = null)
{
return KretaLabelForInner(html, expression, labelWidth, inputWidth, allSizeSame, false, id, formatted, htmlAttributes);
}
private static MvcHtmlString KretaLabelForInner<TModel, TResult>(this HtmlHelper<TModel> html, Expression<Func<TModel, TResult>> expression, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, bool withName = true, string id = "", bool formatted = false, IDictionary<string, object> htmlAttributes = null, string labelText = null)
{
ModelMetadata metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
string htmlFieldName = ExpressionHelper.GetExpressionText(expression);
string fullHtmlFieldId = html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId(htmlFieldName);
if (string.IsNullOrWhiteSpace(labelText))
{
labelText = metadata.DisplayName ?? metadata.PropertyName ?? htmlFieldName.Split('.')[htmlFieldName.Split('.').Length - 1];
}
MvcHtmlString value = html.DisplayTextFor(expression);
StringBuilder sb = new StringBuilder();
if (withName)
{
sb.AppendFormat("<div class=\"{0}\"><label class='windowInputLabel' for='{1}'>{2}</label></div>", BootsrapHelper.GetSizeClasses(labelWidth, allSizeSame), fullHtmlFieldId, labelText);
}
string innerValue = value.ToString();
if (formatted)
{
innerValue = string.Format("<div>{0}</div>", HttpUtility.HtmlDecode(value.ToString()));
}
var tag = new TagBuilder("label");
if (htmlAttributes != null)
{
tag.MergeAttributes(htmlAttributes);
}
tag.MergeAttribute("displayfor", fullHtmlFieldId);
tag.InnerHtml = innerValue;
if (string.IsNullOrWhiteSpace(id))
{
tag.AddCssClass("windowInputLabel");
}
else
{
tag.AddCssClass("windowInputValue");
tag.Attributes.Add("id", id);
}
sb.AppendFormat("<div class=\"{0}\">{1}</div>", BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame), tag.ToString(TagRenderMode.Normal));
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithTooltip(this MvcHtmlString helper, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string customLabelDivClass = "", string customLabelClass = "", string tooltipResource = null)
{
string helperAsString = helper.ToString();
int labelOpenIndex = helperAsString.IndexOf("<label");
helperAsString = helperAsString.Insert(labelOpenIndex, "<div class=\"kretaLabelTooltip kretaLabelTooltipForLabel\">");
int labelCloseIndex = helperAsString.IndexOf("</label>");
helperAsString = helperAsString.Insert(labelCloseIndex, $@" &nbsp;<img class=""kretaLabelTooltipImg""/> <span class=""kretaLabelTooltipText""> {tooltipResource} </span> ");
int labelCloseAfterIndex = helperAsString.IndexOf("</label>") + "</label>".Length;
helperAsString = helperAsString.Insert(labelCloseAfterIndex, "</div>");
return new MvcHtmlString(helperAsString);
}
}
}

View file

@ -0,0 +1,36 @@
using System.Collections.Generic;
using System.Text;
using System.Web.Mvc;
using Kreta.Framework;
namespace Kreta.Web.Helpers
{
public static class LinkExtensions
{
public static MvcHtmlString KretaLink(this HtmlHelper helper, int title, string href = "#", string classes = "", string content = "")
{
StringBuilder sb = new StringBuilder();
sb.Append($"<a title=\"{StringResourcesUtil.GetString(title)}\" href=\"{href}\" class=\"{classes}\">{content}</a>");
MvcHtmlString str = new MvcHtmlString(sb.ToString());
return str;
}
public static MvcHtmlString KretaActionLink(this HtmlHelper helper, string title = "", string href = "#", string classes = "", string content = "", IDictionary<string, object> htmlAttributes = null)
{
StringBuilder sb = new StringBuilder();
StringBuilder htmlAttributesString = new StringBuilder();
if (htmlAttributes != null)
{
foreach (KeyValuePair<string, object> item in htmlAttributes)
{
htmlAttributesString.Append($"{item.Key}=\"{item.Value}\" ");
}
}
sb.Append($"<a target=_blank title=\"{title}\" href=\"{href}\" class=\"{classes}\" {htmlAttributesString}>{content}</a>");
MvcHtmlString str = new MvcHtmlString(sb.ToString());
return str;
}
}
}

View file

@ -0,0 +1,41 @@
using System.Web;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
using Kreta.Web.Helpers.Grid;
namespace Kreta.Web.Helpers
{
public static class ListViewExtensions
{
public static ListViewBuilder<ListViewModel> KretaListView<ListViewModel>(this HtmlHelper helper,
string name,
string tagName,
string clientTemplateId,
ApiUrlBuilder getUrl,
bool pageable = false,
bool autoBind = true,
bool serverOperation = false)
where ListViewModel : class
{
var urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);
string url = urlHelper.HttpRouteUrl(getUrl.Route, getUrl.RouteValues);
ListViewBuilder<ListViewModel> listViewBuilder = helper.Kendo().ListView<ListViewModel>()
.Name(name)
.TagName(tagName)
.ClientTemplateId(clientTemplateId)
.DataSource(dataSource =>
{
dataSource.Read(read => read.Url(url).Type(HttpVerbs.Get));
dataSource.ServerOperation(serverOperation);
})
.Pageable(x => x.Enabled(pageable))
.AutoBind(autoBind);
listViewBuilder.Render();
return listViewBuilder;
}
}
}

View file

@ -0,0 +1,182 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
namespace Kreta.Web.Helpers
{
public static class MaskedTextBoxExtensions
{
public static MaskedTextBoxBuilder KretaMaskedTextBox(this HtmlHelper helper, string name, string mask, Dictionary<string, object> htmlAttributes = null)
{
var maskedtextbox = helper.Kendo().MaskedTextBox()
.Name(name)
.Mask(mask);
if (htmlAttributes != null)
maskedtextbox.HtmlAttributes(htmlAttributes);
return maskedtextbox;
}
public static MaskedTextBoxBuilder KretaMaskedTextBoxFor<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> expression, string usedMask = "", Dictionary<string, object> htmlAttributes = null)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
var value = metadata.Model;
if (htmlAttributes == null)
htmlAttributes = new Dictionary<string, object>();
var validationAttributes = helper.GetUnobtrusiveValidationAttributes(fullBindingName, metadata);
foreach (var key in validationAttributes.Keys)
{
try
{
if (key == "data-val-required")
{ htmlAttributes.Add("data-msg-required", validationAttributes[key].ToString()); }
else if (key == "data-val-regex")
{ htmlAttributes.Add("data-msg-pattern", validationAttributes[key].ToString()); }
else if (key == "data-val-regex-pattern")
{ htmlAttributes.Add("data-rule-pattern", validationAttributes[key].ToString()); }
else
{ htmlAttributes.Add(key, validationAttributes[key].ToString()); }
}
catch { }
}
if (metadata.IsRequired)
{
htmlAttributes.Add("data-rule-required", "true");
htmlAttributes.Add("data-labelmsg", metadata.DisplayName + " *");
}
else
{ htmlAttributes.Add("data-labelmsg", metadata.DisplayName); }
var maskedtextbox = helper.Kendo().MaskedTextBox()
.Name(fullBindingName)
.HtmlAttributes(htmlAttributes);
if (value != null)
maskedtextbox.Value(value.ToString());
maskedtextbox.Mask(usedMask);
return maskedtextbox;
}
public static MvcHtmlString RenderSearchPanel(this MaskedTextBoxBuilder helper)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
StringBuilder sb = new StringBuilder();
sb.Append("<div class=\"searchInputRowHeight\"><div>");
sb.Append("<label class=\"searchPanelInputLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div><div>");
sb.Append(helper.ToHtmlString());
sb.Append("</div></div>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderSearchPanelSideBar(this MaskedTextBoxBuilder helper)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
StringBuilder sb = new StringBuilder();
sb.Append("<div class=\"searchPanelRow\">");
sb.Append("<div class=\"searchPanelRowTitle\">");
sb.Append("<label class=\"searchPanelLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div>");
sb.Append("<div class=\"searchPanelRowValue\">");
sb.Append(helper.ToHtmlString());
sb.Append("</div>");
sb.Append("</div>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithName(this MaskedTextBoxBuilder helper, int labelWidth = 6, int inputWidth = 6, string tooltipResource = null, bool needLabel = true)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, helper.ToComponent().Name, labelMsg, string.Empty, needLabel);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, helper.ToComponent().Name, labelMsg, string.Empty, tooltipResource, needLabel);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithName(this MaskedTextBoxBuilder helper, string label, int labelWidth = 6, int inputWidth = 6, string tooltipResource = null)
{
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, helper.ToComponent().Name, label, string.Empty);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, helper.ToComponent().Name, label, string.Empty, tooltipResource);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithoutName(this MaskedTextBoxBuilder helper, int inputWidth = 6, string tooltipResource = null)
{
return RenderWithName(helper, 1, inputWidth, tooltipResource, false);
}
private static void AddRenderWithNameBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, string controlName, string labelMsg, string customClass, bool needLabel = true)
{
if (needLabel)
{
sb.AppendFormat("<div class=\"{0} {1} \">", BootsrapHelper.GetSizeClasses(labelWidth), customClass);
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}</label>", controlName, labelMsg);
sb.Append("</div>");
}
sb.AppendFormat("<div class=\"{0} {1}\">", BootsrapHelper.GetSizeClasses(inputWidth), customClass);
}
private static void AddRenderWithNameTooltipBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, string controlName, string labelMsg, string customClass, string tooltipResource, bool needLabel = true)
{
sb.AppendFormat("<div class=\"{0} {1} kretaLabelTooltip \">", BootsrapHelper.GetSizeClasses(labelWidth), customClass);
if (needLabel)
{
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}", controlName, labelMsg);
sb.Append("&nbsp;<img class='kretaLabelTooltipImg' />");
sb.AppendFormat("<span class=\"kretaLabelTooltipText\">{0}</span>", tooltipResource);
sb.Append("</label>");
sb.Append("</div>");
}
sb.AppendFormat("<div class=\"{0} {1}\">", BootsrapHelper.GetSizeClasses(inputWidth), customClass);
}
private static void AddRenderWithNameCloseingFrame(StringBuilder sb)
{
sb.Append("</div>");
}
}
}

View file

@ -0,0 +1,21 @@
using System.Collections.Generic;
using System.Web.Routing;
namespace Kreta.Web.Helpers.Modal
{
public class ModalButtonModel
{
public string Name { get; set; }
public string Text { get; set; }
public bool Enabled { get; set; } = true;
public string Icon { get; set; }
public string ImageUrl { get; set; }
public string SpriteCssClass { get; set; }
public string EventName { get; set; }
public string ContainerCssClass { get; set; }
public bool SecondLine { get; set; }
public RouteValueDictionary Parameters { get; set; }
public Dictionary<string, object> HtmlAttributes { get; set; }
}
}

View file

@ -0,0 +1,30 @@
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
namespace Kreta.Web.Helpers
{
public static class ModalExtensions
{
public static WindowBuilder KretaWindow(this HtmlHelper helper, string name, string title = "", int width = 0, int height = 0, bool isModal = true
, bool isResizable = true, bool isVisible = false)
{
var window = helper.Kendo().Window()
.Name(name)
.Modal(isModal)
.Resizable()
.Draggable()
.Visible(isVisible)
.Draggable(true)
.Title(title)
.Actions(act => act.Maximize().Close());
if (width > 0)
window = window.Width(width);
if (height > 0)
window = window.Height(height);
return window;
}
}
}

View file

@ -0,0 +1,41 @@
using System.Linq;
using System.Web.Http.ModelBinding;
using Newtonsoft.Json;
namespace Kreta.Web.Helpers
{
public static class ModelStateDictionaryExtenstions
{
public static void AddModelStateErrorsFromString(this ModelStateDictionary modelState, string errors)
{
if (string.IsNullOrWhiteSpace(errors))
{
return;
}
var errorContent = JsonConvert.DeserializeObject<HttpClientErrorContent>(errors);
if (errorContent != null)
{
var errorList = errorContent.Message.Split(';');
if (errorList.Any())
{
int i = 1;
foreach (var error in errorList)
{
if (!string.IsNullOrWhiteSpace(error))
{
modelState.AddModelError(i.ToString(), error);
i++;
}
}
}
}
}
}
public class HttpClientErrorContent
{
public string Message { get; set; }
}
}

View file

@ -0,0 +1,320 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
using Kreta.Resources;
namespace Kreta.Web.Helpers
{
public static class MultiSelectExtensions
{
public static MultiSelectBuilder KretaMultiSelect(this HtmlHelper helper, string id, string url = null
, string dataTextField = "Text", string datavalueField = "Value", string groupName = null, Type groupType = null, bool isSingleElementSet = true)
{
var multiSelect = helper.Kendo().MultiSelect()
.Name(id)
.DataTextField(dataTextField)
.DataValueField(datavalueField);
if (!string.IsNullOrWhiteSpace(groupName))
{
multiSelect.DataSource(source =>
{
source.Custom()
.ServerFiltering(enabled: true)
.Transport(transport => transport.Read(read => read.Url(url)))
.Group(g => g.Add(groupName, groupType));
});
}
else
{
multiSelect.DataSource(source =>
{
source.Custom()
.ServerFiltering(enabled: true)
.Transport(transport => transport.Read(read => read.Url(url)));
});
}
SetDataBoundEvent(isSingleElementSet, multiSelect);
return multiSelect;
}
public static MultiSelectBuilder KretaMultiSelect(this HtmlHelper helper, string id, List<SelectListItem> items, object htmlAttributes = null, bool isSingleElementSet = true)
{
var multiSelect = helper.Kendo().MultiSelect()
.Name(id)
.BindTo(items)
.HtmlAttributes(htmlAttributes);
SetDataBoundEvent(isSingleElementSet, multiSelect);
return multiSelect;
}
public static MultiSelectBuilder KretaMultiSelectFor<TModel, TProperty>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TProperty>> expression, IEnumerable<SelectListItem> selectList, IDictionary<string, object> htmlAttributes = null, bool isSingleElementSet = true)
{
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
if (metadata.IsRequired)
{
htmlAttributes.Add("data-labelmsg", metadata.DisplayName + " *");
}
else
{
htmlAttributes.Add("data-labelmsg", metadata.DisplayName);
}
var multiSelect = helper.Kendo()
.MultiSelectFor(expression)
.BindTo(selectList)
.HtmlAttributes(htmlAttributes);
SetDataBoundEvent(isSingleElementSet, multiSelect);
return multiSelect;
}
public static MultiSelectBuilder KretaMultiSelectFor<TModel, TProperty>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TProperty>> expression, string url, string dataTextField = "Text", string datavalueField = "Value", IDictionary<string, object> htmlAttributes = null, bool isSingleElementSet = true)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
var value = metadata.Model;
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
if (metadata.IsRequired)
{
htmlAttributes.Add("data-labelmsg", metadata.DisplayName + " *");
}
else
{
htmlAttributes.Add("data-labelmsg", metadata.DisplayName);
}
var multiSelect = helper.Kendo()
.MultiSelectFor(expression)
.DataTextField(dataTextField)
.DataValueField(datavalueField)
.DataSource(source =>
{
source.Custom()
.Transport(transport =>
{
transport.Read(
read => read.Url(url));
});
})
.HtmlAttributes(htmlAttributes);
SetDataBoundEvent(isSingleElementSet, multiSelect);
return multiSelect;
}
public static MultiSelectBuilder KretaMultiSelectNyomtatvany(this HtmlHelper helper, string id, string url, IDictionary<string, object> htmlAttributes = null, bool? grouping = null, string groupName = null, bool isSingleElementSet = true)
{
(htmlAttributes ?? (htmlAttributes = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase))).Add("data-labelmsg", id);
var multiSelect = helper.Kendo().MultiSelect()
.Name(id)
.Placeholder(CommonResource.PleaseChoose)
.AutoClose(autoClose: false)
.HtmlAttributes(htmlAttributes)
.DataTextField("Text")
.DataValueField("Value");
SetDataBoundEvent(isSingleElementSet, multiSelect);
if (grouping == true && !string.IsNullOrWhiteSpace(groupName))
{
multiSelect.DataSource(source =>
{
source.Custom()
.Transport(transport => transport.Read(read => read.Url(url)))
.Group(g => g.Add(groupName, typeof(string)));
});
}
else
{
multiSelect.DataSource(source =>
{
source.Custom()
.Transport(transport => transport.Read(read => read.Url(url)));
});
}
multiSelect.Events(e => e.Open("KretaMultiSelectHelper.onOpenDropdownMultiSelect"));
return multiSelect;
}
private static void SetDataBoundEvent(bool isSingleElementSet, MultiSelectBuilder multiSelect)
{
if (isSingleElementSet)
{
multiSelect.Events(e => e.DataBound("KretaMultiSelectHelper.dataBoundMultiSelect"));
}
}
public static MvcHtmlString RenderSearchPanel(this MultiSelectBuilder helper)
{
var labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (string.Equals(item.Key, "data-labelmsg", StringComparison.OrdinalIgnoreCase) && item.Value != null)
{
labelMsg = item.Value.ToString();
}
}
var sb = new StringBuilder();
sb.Append("<div class=\"searchInputRowHeight\"><div>");
sb.Append("<label class=\"searchPanelInputLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div><div>");
sb.Append(helper.ToHtmlString());
sb.Append("</div></div>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderSearchPanelSideBar(this MultiSelectBuilder helper, bool allButtons = false)
{
var labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (string.Equals(item.Key, "data-labelmsg", StringComparison.OrdinalIgnoreCase) && item.Value != null)
{
labelMsg = item.Value.ToString();
}
}
var name = helper.ToComponent().Name;
var sb = new StringBuilder();
sb.Append("<div class=\"searchPanelRow\">");
sb.Append("<div class=\"searchPanelRowTitle\">");
sb.Append("<label class=\"searchPanelLabel\" for=\"").Append(name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div>");
sb.Append("<div class=\"searchPanelRowValue\">");
sb.Append(helper.ToHtmlString());
if (allButtons)
{
sb.Append("<div style=\"margin-top: 3px;\">");
sb.Append("<button id=\"selectAll").Append(name).Append("\" type=\"button\" title=\"").Append(CommonResource.MindenElemKivalasztasa).Append("\" data-role=\"button\" class=\"k-button\" role=\"button\" aria-disabled=\"false\" tabindex=\"0\">+</button>");
sb.Append("<button id=\"deselectAll").Append(name).Append("\" type=\"button\" title=\"").Append(CommonResource.MindenElemEltavolitasa).Append("\" data-role=\"button\" class=\"k-button\" role=\"button\" aria-disabled=\"false\" tabindex=\"0\" style=\"margin-left: 3px;\">-</button>");
sb.Append("</div>");
}
sb.Append("</div>");
sb.Append("</div>");
if (allButtons)
{
sb.Append("<script>$(document).ready(function() { ");
sb.Append("var comp = $(\"#").Append(name).Append("\").data(\"kendoMultiSelect\");");
sb.Append("$(\"#selectAll").Append(name).Append("\").click(function() {{ var values = []; $.each(comp.dataSource.data(), function(i, v) {{ values.push(v.Value); }}); comp.value(values); }});");
sb.Append("$(\"#deselectAll").Append(name).Append("\").click(function() {{ comp.value([]); }});");
sb.Append("});</script>");
}
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithName(this MultiSelectBuilder helper, int labelWidth = 6, int inputWidth = 6, string tooltipResource = null, bool isCustomRequired = false)
{
var labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (string.Equals(item.Key, "data-labelmsg", StringComparison.OrdinalIgnoreCase) && item.Value != null)
{
labelMsg = item.Value.ToString();
}
}
if (isCustomRequired)
{
labelMsg += " *";
}
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
{
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, helper.ToComponent().Name, labelMsg, string.Empty);
}
else
{
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, helper.ToComponent().Name, labelMsg, string.Empty, tooltipResource);
}
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithName(this MultiSelectBuilder helper, string label, int labelWidth = 6, int inputWidth = 6, string tooltipResource = null)
{
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
{
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, helper.ToComponent().Name, label, string.Empty);
}
else
{
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, helper.ToComponent().Name, label, string.Empty, tooltipResource);
}
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithoutName(this MultiSelectBuilder helper, int inputWidth = 12, string customClass = "")
{
var sb = new StringBuilder();
AddRenderWithNameBeginingFrame(sb, 0, inputWidth, helper.ToComponent().Name, string.Empty, customClass);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
return new MvcHtmlString(sb.ToString());
}
private static void AddRenderWithNameBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, string controlName, string labelMsg, string customClass)
{
sb.AppendFormat("<div class=\"{0} {1} \">", BootsrapHelper.GetSizeClasses(labelWidth), customClass);
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}</label>", controlName, labelMsg);
sb.AppendFormat("</div><div class=\"{0} {1}\">", BootsrapHelper.GetSizeClasses(inputWidth), customClass);
}
private static void AddRenderWithNameTooltipBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, string controlName, string labelMsg, string customClass, string tooltipResource)
{
sb.AppendFormat("<div class=\"{0} {1} kretaLabelTooltip \">", BootsrapHelper.GetSizeClasses(labelWidth), customClass);
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}", controlName, labelMsg);
sb.Append("&nbsp;<img class='kretaLabelTooltipImg' />");
sb.AppendFormat("<span class=\"kretaLabelTooltipText\">{0}</span>", tooltipResource);
sb.Append("</label>");
sb.AppendFormat("</div><div class=\"{0} {1}\">", BootsrapHelper.GetSizeClasses(inputWidth), customClass);
}
private static void AddRenderWithNameCloseingFrame(StringBuilder sb)
{
sb.Append("</div>");
}
}
}

View file

@ -0,0 +1,33 @@
using System.Collections.Generic;
using System.Web.Mvc;
using Kendo.Mvc.UI;
namespace Kreta.Web.Helpers
{
public static class NotificationExtensions
{
public static Kendo.Mvc.UI.Fluent.NotificationBuilder KretaNotification(this HtmlHelper helper, string name, Dictionary<string, object> htmlAttributes = null, bool tip = false)
{
var notification = helper.Kendo().Notification()
.Name(name);
if (tip)
{
notification.Events(e => e.Show("onShow"))
.Templates(t =>
{
t.Add().Type("info").ClientTemplateID("infoTemplate");
});
}
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
notification.HtmlAttributes(htmlAttributes);
return notification;
}
}
}

View file

@ -0,0 +1,572 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
using Kreta.Framework;
using Kreta.Resources;
namespace Kreta.Web.Helpers
{
public static class NumericExtensions
{
public static NumericTextBoxBuilder<double> KretaNumeric(this HtmlHelper helper, string name, Dictionary<string, object> htmlAttributes = null)
{
if (htmlAttributes == null)
htmlAttributes = new Dictionary<string, object>();
var numeric = helper.Kendo().NumericTextBox()
.Name(name)
.Min(0)
.Max(Constants.General.DoubleNumericTextboxDefaultMaxValue)
.HtmlAttributes(htmlAttributes);
numeric.DecreaseButtonTitle(CommonResource.ErtekCsokkentese).IncreaseButtonTitle(CommonResource.ErtekNovelese);
return numeric;
}
public static NumericTextBoxBuilder<decimal> KretaNumericFor<TModel>(this HtmlHelper<TModel> helper, Expression<Func<TModel, decimal>> expression, IDictionary<string, object> htmlAttributes = null)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
var value = metadata.Model;
if (htmlAttributes == null)
htmlAttributes = new Dictionary<string, object>();
//if (metadata.IsRequired) { htmlAttributes.Add("labelmsg", metadata.DisplayName + " *"); }
//else { htmlAttributes.Add("labelmsg", metadata.DisplayName); }
if (metadata.IsRequired)
{
htmlAttributes.Add("data-rule-required", "true");
htmlAttributes.Add("title", string.Format(StringResourcesUtil.GetString(3477), metadata.DisplayName));
htmlAttributes.Add("labelmsg", metadata.DisplayName + " *");
}
else
{ htmlAttributes.Add("labelmsg", metadata.DisplayName); }
var numeric = helper.Kendo()
.NumericTextBoxFor(expression)
.Min(0)
.Max(Constants.General.DecimalNumericTextboxDefaultMaxValue)
.HtmlAttributes(htmlAttributes);
if (metadata.IsRequired)
numeric.Events(e => e.Change("KretaNumericHelper.setTitle"));
numeric.DecreaseButtonTitle(CommonResource.ErtekCsokkentese).IncreaseButtonTitle(CommonResource.ErtekNovelese);
return numeric;
}
public static NumericTextBoxBuilder<decimal> KretaNumericFor<TModel>(this HtmlHelper<TModel> helper, Expression<Func<TModel, decimal?>> expression, IDictionary<string, object> htmlAttributes = null)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
var value = metadata.Model;
if (htmlAttributes == null)
htmlAttributes = new Dictionary<string, object>();
//if (metadata.IsRequired) { htmlAttributes.Add("labelmsg", metadata.DisplayName + " *"); }
//else { htmlAttributes.Add("labelmsg", metadata.DisplayName); }
if (metadata.IsRequired)
{
htmlAttributes.Add("data-rule-required", "true");
htmlAttributes.Add("title", string.Format(StringResourcesUtil.GetString(3477), metadata.DisplayName));
htmlAttributes.Add("labelmsg", metadata.DisplayName + " *");
}
else
{ htmlAttributes.Add("labelmsg", metadata.DisplayName); }
var numeric = helper.Kendo()
.NumericTextBoxFor(expression)
.Min(0)
.Max(Constants.General.DecimalNumericTextboxDefaultMaxValue)
.HtmlAttributes(htmlAttributes);
if (metadata.IsRequired)
numeric.Events(e => e.Change("KretaNumericHelper.setTitle"));
numeric.DecreaseButtonTitle(CommonResource.ErtekCsokkentese).IncreaseButtonTitle(CommonResource.ErtekNovelese);
return numeric;
}
public static NumericTextBoxBuilder<int> KretaNumericFor<TModel>(this HtmlHelper<TModel> helper, Expression<Func<TModel, int>> expression, IDictionary<string, object> htmlAttributes = null)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
var value = metadata.Model;
if (htmlAttributes == null)
htmlAttributes = new Dictionary<string, object>();
//if (metadata.IsRequired) { htmlAttributes.Add("labelmsg", metadata.DisplayName + " *"); }
//else { htmlAttributes.Add("labelmsg", metadata.DisplayName); }
if (metadata.IsRequired)
{
htmlAttributes.Add("data-rule-required", "true");
htmlAttributes.Add("title", string.Format(StringResourcesUtil.GetString(3477), metadata.DisplayName));
htmlAttributes.Add("labelmsg", metadata.DisplayName + " *");
}
else
{ htmlAttributes.Add("labelmsg", metadata.DisplayName); }
var numeric = helper.Kendo()
.NumericTextBoxFor(expression)
.Min(0)
.Max(int.MaxValue)
.Decimals(0)
.Format("#")
.HtmlAttributes(htmlAttributes);
if (metadata.IsRequired)
numeric.Events(e => e.Change("KretaNumericHelper.setTitle"));
numeric.DecreaseButtonTitle(CommonResource.ErtekCsokkentese).IncreaseButtonTitle(CommonResource.ErtekNovelese);
return numeric;
}
public static NumericTextBoxBuilder<int> KretaNumericFor<TModel>(this HtmlHelper<TModel> helper, Expression<Func<TModel, int?>> expression, IDictionary<string, object> htmlAttributes = null)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
var value = metadata.Model;
if (htmlAttributes == null)
htmlAttributes = new Dictionary<string, object>();
//if (metadata.IsRequired) { htmlAttributes.Add("labelmsg", metadata.DisplayName + " *"); }
//else { htmlAttributes.Add("labelmsg", metadata.DisplayName); }
if (metadata.IsRequired)
{
htmlAttributes.Add("data-rule-required", "true");
htmlAttributes.Add("title", string.Format(StringResourcesUtil.GetString(3477), metadata.DisplayName));
htmlAttributes.Add("labelmsg", metadata.DisplayName + " *");
}
else
{ htmlAttributes.Add("labelmsg", metadata.DisplayName); }
var numeric = helper.Kendo()
.NumericTextBoxFor(expression)
.Min(0)
.Max(int.MaxValue)
.Decimals(0)
.Format("#")
.HtmlAttributes(htmlAttributes);
if (metadata.IsRequired)
numeric.Events(e => e.Change("KretaNumericHelper.setTitle"));
numeric.DecreaseButtonTitle(CommonResource.ErtekCsokkentese).IncreaseButtonTitle(CommonResource.ErtekNovelese);
return numeric;
}
public static NumericTextBoxBuilder<double> KretaNumericFor<TModel>(this HtmlHelper<TModel> helper, Expression<Func<TModel, double>> expression, IDictionary<string, object> htmlAttributes = null)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
var value = metadata.Model;
if (htmlAttributes == null)
htmlAttributes = new Dictionary<string, object>();
//if (metadata.IsRequired) { htmlAttributes.Add("labelmsg", metadata.DisplayName + " *"); }
//else { htmlAttributes.Add("labelmsg", metadata.DisplayName); }
if (metadata.IsRequired)
{
htmlAttributes.Add("data-rule-required", "true");
htmlAttributes.Add("title", string.Format(StringResourcesUtil.GetString(3477), metadata.DisplayName));
htmlAttributes.Add("labelmsg", metadata.DisplayName + " *");
}
else
{ htmlAttributes.Add("labelmsg", metadata.DisplayName); }
//if (value != null)
// htmlAttributes.Add("value", value.ToString().Replace(",", "."));
var numeric = helper.Kendo()
.NumericTextBoxFor(expression)
.Min(0)
.Max(Constants.General.DoubleNumericTextboxDefaultMaxValue)
.HtmlAttributes(htmlAttributes);
if (metadata.IsRequired)
numeric.Events(e => e.Change("KretaNumericHelper.setTitle"));
numeric.DecreaseButtonTitle(CommonResource.ErtekCsokkentese).IncreaseButtonTitle(CommonResource.ErtekNovelese);
return numeric;
}
public static NumericTextBoxBuilder<double> KretaNumericFor<TModel>(this HtmlHelper<TModel> helper, Expression<Func<TModel, double?>> expression, IDictionary<string, object> htmlAttributes = null, string label = null)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
var value = metadata.Model;
if (htmlAttributes == null)
htmlAttributes = new Dictionary<string, object>();
//if (metadata.IsRequired) { htmlAttributes.Add("labelmsg", metadata.DisplayName + " *"); }
//else { htmlAttributes.Add("labelmsg", metadata.DisplayName); }
var displayName = string.IsNullOrWhiteSpace(label) ? metadata.DisplayName : label;
if (metadata.IsRequired)
{
htmlAttributes.Add("data-rule-required", "true");
htmlAttributes.Add("title", string.Format(StringResourcesUtil.GetString(3477), displayName));
htmlAttributes.Add("labelmsg", displayName + " *");
}
else
{ htmlAttributes.Add("labelmsg", displayName); }
//if (value != null)
// htmlAttributes.Add("value", value.ToString().Replace(",", "."));
var numeric = helper.Kendo()
.NumericTextBoxFor(expression)
.Min(0)
.Max(Constants.General.DoubleNumericTextboxDefaultMaxValue)
.HtmlAttributes(htmlAttributes);
if (metadata.IsRequired)
numeric.Events(e => e.Change("KretaNumericHelper.setTitle"));
numeric.DecreaseButtonTitle(CommonResource.ErtekCsokkentese).IncreaseButtonTitle(CommonResource.ErtekNovelese);
return numeric;
}
public static MvcHtmlString RenderSearchPanel(this NumericTextBoxBuilder<int> helper)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
StringBuilder sb = new StringBuilder();
sb.Append("<div class=\"searchInputRowHeight\"><div>");
sb.Append("<label class=\"searchPanelInputLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div><div>");
sb.Append(helper.ToHtmlString());
sb.Append("</div></div>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderSearchPanel(this NumericTextBoxBuilder<decimal> helper)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
StringBuilder sb = new StringBuilder();
sb.Append("<div class=\"searchInputRowHeight\"><div>");
sb.Append("<label class=\"searchPanelInputLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div><div>");
sb.Append(helper.ToHtmlString());
sb.Append("</div></div>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderSearchPanel(this NumericTextBoxBuilder<double> helper)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
StringBuilder sb = new StringBuilder();
sb.Append("<div class=\"searchInputRowHeight\"><div>");
sb.Append("<label class=\"searchPanelInputLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div><div>");
sb.Append(helper.ToHtmlString());
sb.Append("</div></div>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderSearchPanelSideBar(this NumericTextBoxBuilder<int> helper)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
StringBuilder sb = new StringBuilder();
sb.Append("<div class=\"searchPanelRow\">");
sb.Append("<div class=\"searchPanelRowTitle\">");
sb.Append("<label class=\"searchPanelLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div>");
sb.Append("<div class=\"searchPanelRowValue\">");
sb.Append(helper.ToHtmlString());
sb.Append("</div>");
sb.Append("</div>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderSearchPanelSideBar(this NumericTextBoxBuilder<decimal> helper)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
StringBuilder sb = new StringBuilder();
sb.Append("<div class=\"searchPanelRow\">");
sb.Append("<div class=\"searchPanelRowTitle\">");
sb.Append("<label class=\"searchPanelLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div>");
sb.Append("<div class=\"searchPanelRowValue\">");
sb.Append(helper.ToHtmlString());
sb.Append("</div>");
sb.Append("</div>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderSearchPanelSideBar(this NumericTextBoxBuilder<double> helper)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
StringBuilder sb = new StringBuilder();
sb.Append("<div class=\"searchPanelRow\">");
sb.Append("<div class=\"searchPanelRowTitle\">");
sb.Append("<label class=\"searchPanelLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div>");
sb.Append("<div class=\"searchPanelRowValue\">");
sb.Append(helper.ToHtmlString());
sb.Append("</div>");
sb.Append("</div>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithName(this NumericTextBoxBuilder<int> helper, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string tooltipResource = null)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, labelMsg, string.Empty);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, labelMsg, string.Empty, tooltipResource);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
if (helper.ToComponent().Max.HasValue)
{
sb.Append(@"<script>
$('#").Append(helper.ToComponent().Name).Append(@"').on('keydown keyup', function(e){
var maxAttr = $(this).attr('max');
if (!CommonUtils.isNullOrUndefined(maxAttr) && maxAttr !== false) {
if (parseInt(this.value) > parseInt(maxAttr) && e.keyCode != 46 && e.keyCode != 8) {
e.preventDefault();
$(this).val(maxAttr);
}
}
});
</script>");
}
if (helper.ToComponent().Min.HasValue)
{
sb.Append(@"<script>
$('#").Append(helper.ToComponent().Name).Append(@"').on('keydown keyup', function(e){
var minAttr = $(this).attr('min');
if (!CommonUtils.isNullOrUndefined(minAttr) && minAttr !== false) {
if (parseInt(this.value) < parseInt(minAttr) && e.keyCode != 46 && e.keyCode != 8) {
e.preventDefault();
$(this).val(minAttr);
}
}
});
</script>");
}
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithName(this NumericTextBoxBuilder<decimal> helper, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string tooltipResource = null)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, labelMsg, string.Empty);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, labelMsg, string.Empty, tooltipResource);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithName(this NumericTextBoxBuilder<double> helper, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string tooltipResource = null, bool needLabel = true)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, labelMsg, string.Empty, needLabel);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, labelMsg, string.Empty, tooltipResource, needLabel);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithName(this NumericTextBoxBuilder<int> helper, string label, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string tooltipResource = null)
{
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, label, string.Empty);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, label, string.Empty, tooltipResource);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
if (helper.ToComponent().Max.HasValue)
{
sb.Append(@"<script>
$('#").Append(helper.ToComponent().Name).Append(@"').on('keydown keyup', function(e){
var maxAttr = $(this).attr('max');
if (!CommonUtils.isNullOrUndefined(maxAttr) && maxAttr !== false) {
if (parseInt(this.value) > parseInt(maxAttr) && e.keyCode != 46 && e.keyCode != 8) {
e.preventDefault();
$(this).val(maxAttr);
}
}
});
</script>");
}
if (helper.ToComponent().Min.HasValue)
{
sb.Append(@"<script>
$('#").Append(helper.ToComponent().Name).Append(@"').on('keydown keyup', function(e){
var minAttr = $(this).attr('min');
if (!CommonUtils.isNullOrUndefined(minAttr) && minAttr !== false) {
if (parseInt(this.value) < parseInt(minAttr) && e.keyCode != 46 && e.keyCode != 8) {
e.preventDefault();
$(this).val(minAttr);
}
}
});
</script>");
}
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithName(this NumericTextBoxBuilder<decimal> helper, string label, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string tooltipResource = null)
{
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, label, string.Empty);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, label, string.Empty, tooltipResource);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithName(this NumericTextBoxBuilder<double> helper, string label, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string tooltipResource = null)
{
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, label, string.Empty);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, label, string.Empty, tooltipResource);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithoutName(this NumericTextBoxBuilder<double> helper, int inputWidth = 6, string tooltipResource = null)
{
return RenderWithName(helper, 1, inputWidth, tooltipResource: tooltipResource, needLabel: false);
}
private static void AddRenderWithNameBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, bool allSizeSame, string controlName, string labelMsg, string customClass, bool needLabel = true)
{
if (needLabel)
{
sb.AppendFormat("<div class=\"{0} {1} \">", BootsrapHelper.GetSizeClasses(labelWidth, allSizeSame), customClass);
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}</label>", controlName, labelMsg);
sb.AppendFormat("</div>");
}
sb.AppendFormat("<div class=\"{0} {1}\">", BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame), customClass);
}
private static void AddRenderWithNameTooltipBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, bool allSizeSame, string controlName, string labelMsg, string customClass, string tooltipResource, bool needLabel = true)
{
sb.AppendFormat("<div class=\"{0} {1} kretaLabelTooltip \">", BootsrapHelper.GetSizeClasses(labelWidth, allSizeSame), customClass);
if (needLabel)
{
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}", controlName, labelMsg);
sb.Append("&nbsp;<img class='kretaLabelTooltipImg' />");
sb.AppendFormat("<span class=\"kretaLabelTooltipText\">{0}</span>", tooltipResource);
sb.Append("</label>");
sb.Append("</div>");
}
sb.AppendFormat("<div class=\"{0} {1}\">", BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame), customClass);
}
private static void AddRenderWithNameCloseingFrame(StringBuilder sb)
{
sb.Append("</div>");
}
}
}

View file

@ -0,0 +1,31 @@
using System.Collections.Generic;
using System.IO;
using System.Web.Mvc;
namespace Kreta.Web.Helpers
{
public class NyomtatvanyModelBinderWithPoszeidonIktatasDefiniciok : System.Web.Mvc.DefaultModelBinder
{
public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
var ret = base.BindModel(controllerContext, bindingContext);
using (var reader = new StreamReader(controllerContext.HttpContext.Request.InputStream))
{
controllerContext.HttpContext.Request.InputStream.Position = 0;
var content = reader.ReadToEnd();
var contentObject = Newtonsoft.Json.JsonConvert.DeserializeObject(content) as Newtonsoft.Json.Linq.JObject;
var kulcsSzavak = contentObject["KulcsszoDefiniciok"];
if (kulcsSzavak != null)
{
((Areas.Nyomtatvanyok.Controllers.NyomtatvanyokController.NyomtatvanyModel)ret).Kulcsszodefiniciok = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Kreta.BusinessLogic.Helpers.Nyomtatvanyok.Iktatas.KulcsszoDefinicioModel>>(kulcsSzavak.Value<string>("KulcsszoDefiniciok"));
}
var foszamDefiniciok = contentObject["FoszamDefiniciok"];
if (foszamDefiniciok != null)
{
((Areas.Nyomtatvanyok.Controllers.NyomtatvanyokController.NyomtatvanyModel)ret).FoszamDefiniciok = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Kreta.BusinessLogic.Helpers.Nyomtatvanyok.Iktatas.FoszamDefinicioModel>>(foszamDefiniciok.Value<string>("FoszamDefiniciok"));
}
}
return ret;
}
}
}

View file

@ -0,0 +1,44 @@
using Kreta.BusinessLogic.Interfaces;
namespace Kreta.Web.Helpers.OsztalyCsoportSorolas
{
//public abstract class OsztalyCsoportSorolasModel
//{
// public string FromUrl { get; set; }
// public string FromChangeEvent { get; set; }
// public string FromPlaceholder { get; set; }
// public string ToUrl { get; set; }
// public string ToChangeEvent { get; set; }
// public string ToPlaceholder { get; set; }
// public string ZaradekUrl { get; set; }
// public string ZaradekPlaceholder { get; set; }
// public DateTime? Datum { get; set; }
// public string MinDatum { get; set; }
// public string MaxDatum { get; set; }
// public int? FromDDL { get; set; }
// public string[] FromElements { get; set; }
// public int? ToDDL { get; set; }
// public string[] ToElements { get; set; }
// public string ZaradekText { get; set; }
//}
public interface IOsztalyCsoportbaSorolasBase : IOsztalyCsoportbaSorolas
{
string FromUrl { get; set; }
string FromChangeEvent { get; set; }
string FromPlaceholder { get; set; }
string ToUrl { get; set; }
string ToChangeEvent { get; set; }
string ToPlaceholder { get; set; }
string MinDatum { get; set; }
string MaxDatum { get; set; }
}
}

View file

@ -0,0 +1,272 @@
using System.Web.Mvc;
using Kreta.Framework;
using Kreta.Resources;
using Kreta.Web.Helpers.OsztalyCsoportSorolas;
namespace Kreta.Web.Helpers
{
public static class OsztalyCsoportSorolasExtensions
{
public static MvcHtmlString KretaOsztalyCsoportSorolas(this HtmlHelper helper, IOsztalyCsoportbaSorolasBase model)
{
var fromDDL = ComboBoxExtensions.KretaComboBox(helper, "FromDDL", model.FromUrl, "Text", "Value", model.FromPlaceholder).AutoBind(false);
var toDDL = ComboBoxExtensions.KretaComboBox(helper, "ToDDL", model.ToUrl, "Text", "Value", model.ToPlaceholder).AutoBind(false);
if (!string.IsNullOrWhiteSpace(model.FromChangeEvent))
{ fromDDL.Events(e => e.Change(model.FromChangeEvent)); }
if (!string.IsNullOrWhiteSpace(model.ToChangeEvent))
{ toDDL.Events(e => e.Change(model.ToChangeEvent)); }
string result = @"
<div class='row'>
<div class='col-xs-5'>" + fromDDL.ToHtmlString() + @"</div>
<div class='col-xs-2'></div>
<div class='col-xs-5'>" + toDDL.ToHtmlString() + @"</div>
</div>
<div class='row' style='min-height: 0px;'>
<div class='col-xs-5' style='min-height: 0px;'>
<button id='sortNameFromElement' style='min-height: 31px;' class='k-button col-xs-4' type='button'>" + StringResourcesUtil.GetString(4898) + @"</button>
<button id='sortDateFromElement' style='min-height: 31px;' class='k-button col-xs-4' type='button'>" + StringResourcesUtil.GetString(4899) + @"</button>
<button id='sortNemFromElement' style='min-height: 31px;' class='k-button col-xs-4' type='button'>" + StringResourcesUtil.GetString(7604) + @"</button>
</div>
<div class='col-xs-2' style='min-height: 1px;'></div>
<div class='col-xs-5' style='min-height: 0px;'>
<button id='sortNameToElement' style='min-height: 31px;' class='k-button col-xs-4' type='button'>" + StringResourcesUtil.GetString(4898) + @"</button>
<button id='sortDateToElement' style='min-height: 31px;' class='k-button col-xs-4' type='button'>" + StringResourcesUtil.GetString(4899) + @"</button>
<button id='sortNemToElement' style='min-height: 31px;' class='k-button col-xs-4' type='button'>" + StringResourcesUtil.GetString(7604) + @"</button>
</div>
</div>
<div class='row'>
<div class='col-xs-5 selectBoxDiv'>
<select name='FromElements[]' id='multiselect' class='form-control' size='20' multiple='multiple' style='overflow: scroll; height: 400px;'></select>
</div>
<div class='col-xs-2'>
<button disabled type='button' id='multiselect_rightAll' class='btn btn-block'><i class='glyphicon glyphicon-forward'></i></button>
<button disabled type='button' id='multiselect_rightSelected' class='btn btn-block'><i class='glyphicon glyphicon-chevron-right'></i></button>
<button disabled type='button' id='multiselect_leftSelected' class='btn btn-block'><i class='glyphicon glyphicon-chevron-left'></i></button>
<button disabled type='button' id='multiselect_leftAll' class='btn btn-block'><i class='glyphicon glyphicon-backward'></i></button>
<br />
<label id='multiSelectErrorMsg'></label>
</div>
<div class='col-xs-5 selectBoxDiv'>
<select name = 'ToElements[]' id='multiselect_to' class='form-control' size='20' multiple='multiple' style='overflow: scroll; height: 400px;'></select>
</div>
</div>
<div class='row'>
<div class='col-xs-3'>
<label id='FromElementsCount'>0</label>
<label>" + StringResourcesUtil.GetString(4253) + @"</label>
</div>
<div class='col-xs-2' style='text-align: right;'>
<label id='FromElementsCountIn'>0</label>
<label>" + OsztalyCsoportResource.FoOsszesen + @"</label>
</div>
<div class='col-xs-2'>
<label id='multiSelectErrorMsg'></label>
</div>
<div class='col-xs-3'>
<label id='ToElementsCount'>0</label>
<label>" + StringResourcesUtil.GetString(4253) + @"</label>
</div>
<div class='col-xs-2' style='text-align: right;'>
<label id='ToElementsCountIn'>0</label>
<label>" + OsztalyCsoportResource.FoOsszesen + @"</label>
</div>
</div>
<script type='text/javascript'>
$(document).ready(function () {
$('#multiselect').multiselect(
{
afterMoveToRight: function() {
KretaOsztalybaSorolasHelper.multiselectWithShiftFrom();
KretaOsztalybaSorolasHelper.multiselectWithShiftTo();
},
afterMoveToLeft: function() {
KretaOsztalybaSorolasHelper.multiselectWithShiftFrom();
KretaOsztalybaSorolasHelper.multiselectWithShiftTo();
},
});
setTimeout(function() {
$('#multiselect').click(function() { $('#FromElementsCount').text($('#multiselect :selected').length); });
$('#multiselect_to').click(function() { $('#ToElementsCount').text($('#multiselect_to :selected').length); });
KretaOsztalybaSorolasHelper.sizeListSelect($('#multiselect'));
KretaOsztalybaSorolasHelper.sizeListSelect($('#multiselect_to'));
$('#sortNameFromElement').click(function() {
var options = $('#multiselect option');
var arr = options.map(function(_, o) { return { t: $(o).text(), v: o.value, d: $(o).attr('szulDatum'), n: $(o).attr('neme'), e: $(o).attr('nevElotagNelkul'), jc: $(o).attr('jogviszonyCount'), ji: $(o).attr('jogviszonyId'), fromId: $(o).attr('fromId'), disabled: $(o).attr('disabled'), style: $(o).attr('style'), selected: o.selected, c: $(o).attr('class'), dfi: $(o).attr('data-fa-icon'), ti: $(o).attr('title') }; }).get();
arr.sort(CommonUtils.hunSorterWithKey('e'));
options.each(function(i, o) {
o.value = arr[i].v;
o.selected = arr[i].selected;
$(o).text(arr[i].t);
$(o).attr('szulDatum', arr[i].d);
$(o).attr('Neme', arr[i].n);
$(o).attr('nevElotagNelkul', arr[i].e);
$(o).attr('jogviszonyCount', arr[i].jc);
$(o).attr('jogviszonyId', arr[i].ji);
$(o).attr('fromId', arr[i].fromId);
$(o).removeAttr('disabled'); $(o).removeAttr('style');
$(o).attr('disabled', arr[i].disabled); $(o).attr('style', arr[i].style);
$(o).removeAttr('class');
$(o).attr('class', arr[i].c);
$(o).removeAttr('data-fa-icon');
$(o).attr('data-fa-icon', arr[i].dfi);
$(o).removeAttr('title');
$(o).attr('title', arr[i].ti);
});
});
$('#sortDateFromElement').click(function() {
var options = $('#multiselect option');
var arr = options.map(function(_, o) { return { t: $(o).text(), v: o.value, e: $(o).attr('nevElotagNelkul'), jc: $(o).attr('jogviszonyCount'), ji: $(o).attr('jogviszonyId'), d: $(o).attr('szulDatum'), fromId: $(o).attr('fromId'), n: $(o).attr('neme'), disabled: $(o).attr('disabled'), style: $(o).attr('style'), selected: o.selected, c: $(o).attr('class'), dfi: $(o).attr('data-fa-icon'), ti: $(o).attr('title') }; }).get();
arr.sort(function(o1, o2) { return new Date(o1.d) - new Date(o2.d); });
options.each(function(i, o) {
o.value = arr[i].v;
o.selected = arr[i].selected;
$(o).text(arr[i].t);
$(o).attr('szulDatum', arr[i].d);
$(o).attr('Neme', arr[i].n);
$(o).attr('nevElotagNelkul', arr[i].e);
$(o).attr('jogviszonyCount', arr[i].jc);
$(o).attr('jogviszonyId', arr[i].ji);
$(o).attr('fromId', arr[i].fromId);
$(o).removeAttr('disabled'); $(o).removeAttr('style');
$(o).attr('disabled', arr[i].disabled); $(o).attr('style', arr[i].style);
$(o).removeAttr('class');
$(o).attr('class', arr[i].c);
$(o).removeAttr('data-fa-icon');
$(o).attr('data-fa-icon', arr[i].dfi);
$(o).removeAttr('title');
$(o).attr('title', arr[i].ti);
});
});
$('#sortNemFromElement').click(function() {
var options = $('#multiselect option');
var arr = options.map(function(_, o) { return { t: $(o).text(), v: o.value, e: $(o).attr('nevElotagNelkul'), jc: $(o).attr('jogviszonyCount'), ji: $(o).attr('jogviszonyId'), d: $(o).attr('szulDatum'), fromId: $(o).attr('fromId'), n: $(o).attr('neme'), disabled: $(o).attr('disabled'), style: $(o).attr('style'), selected: o.selected, c: $(o).attr('class'), dfi: $(o).attr('data-fa-icon'), ti: $(o).attr('title') }; }).get();
arr.sort(CommonUtils.hunSorterWithKey('n'));
options.each(function(i, o) {
o.value = arr[i].v;
o.selected = arr[i].selected;
$(o).text(arr[i].t);
$(o).attr('szulDatum', arr[i].d);
$(o).attr('Neme', arr[i].n);
$(o).attr('nevElotagNelkul', arr[i].e);
$(o).attr('jogviszonyCount', arr[i].jc);
$(o).attr('jogviszonyId', arr[i].ji);
$(o).attr('fromId', arr[i].fromId);
$(o).removeAttr('disabled'); $(o).removeAttr('style');
$(o).attr('disabled', arr[i].disabled); $(o).attr('style', arr[i].style);
$(o).removeAttr('class');
$(o).attr('class', arr[i].c);
$(o).removeAttr('data-fa-icon');
$(o).attr('data-fa-icon', arr[i].dfi);
$(o).removeAttr('title');
$(o).attr('title', arr[i].ti);
});
});
$('#sortNameToElement').click(function() {
var options = $('#multiselect_to option');
var arr = options.map(function(_, o) { return { t: $(o).text(), v: o.value, e: $(o).attr('nevElotagNelkul'), jc: $(o).attr('jogviszonyCount'), ji: $(o).attr('jogviszonyId'), d: $(o).attr('szulDatum'), fromId: $(o).attr('fromId'), n: $(o).attr('neme'), disabled: $(o).attr('disabled'), style: $(o).attr('style'), selected: o.selected, c: $(o).attr('class'), dfi: $(o).attr('data-fa-icon'), ti: $(o).attr('title') }; }).get();
arr.sort(CommonUtils.hunSorterWithKey('e'));
options.each(function(i, o) {
o.value = arr[i].v;
o.selected = arr[i].selected;
$(o).text(arr[i].t);
$(o).attr('szulDatum', arr[i].d);
$(o).attr('Neme', arr[i].n);
$(o).attr('nevElotagNelkul', arr[i].e);
$(o).attr('jogviszonyCount', arr[i].jc);
$(o).attr('jogviszonyId', arr[i].ji);
$(o).attr('fromId', arr[i].fromId);
$(o).removeAttr('style');
$(o).attr('disabled', arr[i].disabled); $(o).attr('style', arr[i].style);
$(o).removeAttr('class');
$(o).attr('class', arr[i].c);
$(o).removeAttr('data-fa-icon');
$(o).attr('data-fa-icon', arr[i].dfi);
$(o).removeAttr('title');
$(o).attr('title', arr[i].ti);
if(typeof arr[i].disabled === 'undefined') { $(o).attr('disabled', false); }
});
});
$('#sortDateToElement').click(function() {
var options = $('#multiselect_to option');
var arr = options.map(function(_, o) { return { t: $(o).text(), v: o.value, e: $(o).attr('nevElotagNelkul'), jc: $(o).attr('jogviszonyCount'), ji: $(o).attr('jogviszonyId'), d: $(o).attr('szulDatum'), fromId: $(o).attr('fromId'), n: $(o).attr('neme'), disabled: $(o).attr('disabled'), style: $(o).attr('style'), selected: o.selected, c: $(o).attr('class'), dfi: $(o).attr('data-fa-icon'), ti: $(o).attr('title') }; }).get();
arr.sort(function(o1, o2) { return new Date(o1.d) - new Date(o2.d); });
options.each(function(i, o) {
o.value = arr[i].v;
o.selected = arr[i].selected;
$(o).text(arr[i].t);
$(o).attr('szulDatum', arr[i].d);
$(o).attr('Neme', arr[i].n);
$(o).attr('nevElotagNelkul', arr[i].e);
$(o).attr('jogviszonyCount', arr[i].jc);
$(o).attr('jogviszonyId', arr[i].ji);
$(o).attr('fromId', arr[i].fromId);
$(o).removeAttr('style');
$(o).attr('disabled', arr[i].disabled); $(o).attr('style', arr[i].style);
$(o).removeAttr('class');
$(o).attr('class', arr[i].c);
$(o).removeAttr('data-fa-icon');
$(o).attr('data-fa-icon', arr[i].dfi);
$(o).removeAttr('title');
$(o).attr('title', arr[i].ti);
if(typeof arr[i].disabled === 'undefined') { $(o).attr('disabled', false); }
});
});
$('#sortNemToElement').click(function() {
var options = $('#multiselect_to option');
var arr = options.map(function(_, o) { return { t: $(o).text(), v: o.value, e: $(o).attr('nevElotagNelkul'), jc: $(o).attr('jogviszonyCount'), ji: $(o).attr('jogviszonyId'), d: $(o).attr('szulDatum'),fromId: $(o).attr('fromId'), n: $(o).attr('neme'), disabled: $(o).attr('disabled'), style: $(o).attr('style'), selected: o.selected, c: $(o).attr('class'), dfi: $(o).attr('data-fa-icon'), ti: $(o).attr('title') }; }).get();
arr.sort(CommonUtils.hunSorterWithKey('n'));
options.each(function(i, o) {
o.value = arr[i].v;
o.selected = arr[i].selected;
$(o).text(arr[i].t);
$(o).attr('szulDatum', arr[i].d);
$(o).attr('Neme', arr[i].n);
$(o).attr('nevElotagNelkul', arr[i].e);
$(o).attr('jogviszonyCount', arr[i].jc);
$(o).attr('jogviszonyId', arr[i].ji);
$(o).attr('fromId', arr[i].fromId);
$(o).removeAttr('style');
$(o).attr('disabled', arr[i].disabled); $(o).attr('style', arr[i].style);
$(o).removeAttr('class');
$(o).attr('class', arr[i].c);
$(o).removeAttr('data-fa-icon');
$(o).attr('data-fa-icon', arr[i].dfi);
$(o).removeAttr('title');
$(o).attr('title', arr[i].ti);
if(typeof arr[i].disabled === 'undefined') { $(o).attr('disabled', false); }
});
});
$('#multiselect_rightAll, #multiselect_rightSelected, #multiselect_leftSelected, #multiselect_leftAll').click(function() {
KretaOsztalybaSorolasHelper.deSelectAllOptions('multiselect');
KretaOsztalybaSorolasHelper.deSelectAllOptions('multiselect_to');
KretaOsztalybaSorolasHelper.LoadJogviszonyGrid();
});
},1);
});
</script>
";
return new MvcHtmlString(result);
}
}
}

View file

@ -0,0 +1,82 @@
using System.Collections.Generic;
using Kreta.BusinessLogic.Helpers;
using Kreta.BusinessLogic.Security;
using Kreta.Enums;
using Kreta.Web.Security;
namespace Kreta.Web.Helpers
{
public static class OsztalyokEsCsoportokHelpers
{
public static IDictionary<string, string> GetOsztalyokVagyOsztalyokEsCsoportok(int felhasznaloId, bool osztalyfonokiFeladat)
{
IDictionary<string, string> osztalyokVagyOsztalyokEsCsoportok;
if (AuthorizeHelper.CheckPackageAccess(new[] { KretaClaimPackages.SzuperOsztalyfonok.ClaimValue }))
{
var oHelper = new OsztalyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
if (osztalyfonokiFeladat)
{
osztalyokVagyOsztalyokEsCsoportok = oHelper.GetOsztalyokForDDL(tanarId: felhasznaloId, szuperOsztalyfonok: true);
}
else
{
osztalyokVagyOsztalyokEsCsoportok = oHelper.GetOsztalyokCsoportokForDDL(tanarId: felhasznaloId, szuperOsztalyfonok: true);
}
}
else
{
if (AuthorizeHelper.CheckPackageAccess(new[] { KretaClaimPackages.Osztalyfonok.ClaimValue }))
{
var oHelper = new OsztalyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
if (osztalyfonokiFeladat)
{
osztalyokVagyOsztalyokEsCsoportok = oHelper.GetOsztalyokForDDL(tanarId: felhasznaloId, szuperOsztalyfonok: false);
}
else
{
osztalyokVagyOsztalyokEsCsoportok = oHelper.GetOsztalyokCsoportokForDDL(tanarId: felhasznaloId, szuperOsztalyfonok: false);
}
}
else if (AuthorizeHelper.CheckPackageAccess(new[] { KretaClaimPackages.CsoportVezeto.ClaimValue }))
{
var oHelper = new CsoportHelper(ConnectionTypeExtensions.GetSessionConnectionType());
osztalyokVagyOsztalyokEsCsoportok = oHelper.GetCsoportok(tanarId: felhasznaloId);
}
else
{
var oHelper = new OsztalyCsoportHelper(ConnectionTypeExtensions.GetSessionConnectionType());
osztalyokVagyOsztalyokEsCsoportok = oHelper.GetKapcsolodoOsztalyCsoportokForDropDownList();
}
}
return osztalyokVagyOsztalyokEsCsoportok;
}
public static IDictionary<string, string> GetCsakOsztalyok(int felhasznaloId, OktNevelesiKategoriaEnum? feladatKategoriaId)
{
IDictionary<string, string> csakOsztalyok;
if (AuthorizeHelper.CheckPackageAccess(new[] { KretaClaimPackages.SzuperOsztalyfonok.ClaimValue }))
{
var helper = new OsztalyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
csakOsztalyok = helper.GetOnlyOsztalyok(feladatKategoriaId: feladatKategoriaId);
}
else
{
if (AuthorizeHelper.CheckPackageAccess(new[] { KretaClaimPackages.Osztalyfonok.ClaimValue }))
{
var helper = new OsztalyHelper(ConnectionTypeExtensions.GetSessionConnectionType());
csakOsztalyok = helper.GetOsztalyokForDDL(tanarId: felhasznaloId, szuperOsztalyfonok: false, feladatKategoriaId: feladatKategoriaId);
}
else
{
var helper = new OsztalyCsoportHelper(ConnectionTypeExtensions.GetSessionConnectionType());
csakOsztalyok = helper.GetKapcsolodoOsztalyCsoportokForDropDownList(feladatKategoriaId: feladatKategoriaId);
}
}
return csakOsztalyok;
}
}
}

View file

@ -0,0 +1,50 @@

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
namespace Kreta.Web.Helpers
{
public static class ProgressBarExtensions
{
public static ProgressBarBuilder KretaProgressBar(this HtmlHelper helper, string name, IDictionary<string, object> htmlAttributes = null)
{
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
var progressBar = helper.Kendo().ProgressBar()
.Name(name)
.HtmlAttributes(htmlAttributes)
.Type(ProgressBarType.Percent)
.Animation(true)
.Animation(a => a.Duration(600));
return progressBar;
}
public static ProgressBarBuilder KretaProgressBarFor<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> expression, IDictionary<string, object> htmlAttributes = null)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
var value = (int)metadata.Model;
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
var progressBar = helper.Kendo().ProgressBar()
.Name(fieldName)
.HtmlAttributes(htmlAttributes)
.Type(ProgressBarType.Percent)
.Value(value)
.Animation(a => a.Duration(600));
return progressBar;
}
}
}

View file

@ -0,0 +1,63 @@
using System.Collections.Generic;
using System.Text;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
namespace Kreta.Web.Helpers
{
public static class RadioButtonExtensions
{
public static RadioButtonBuilder KretaRadioButton(this HtmlHelper helper, string name, string label, bool check, bool enabled = true, IDictionary<string, object> htmlAttributes = null)
{
var rb = helper.Kendo().RadioButton()
.Name(name)
.Label(label)
.Checked(check)
.Enable(enabled);
if (htmlAttributes != null)
{
rb.HtmlAttributes(htmlAttributes);
}
return rb;
}
public static MvcHtmlString RenderWithoutName(this RadioButtonBuilder helper, string customClass = "", string tooltipResource = null, string tooltipWidth = null, bool isInnerTooltip = true)
{
var sb = new StringBuilder();
sb.AppendFormat("<div class=\"{0}\">", BootsrapHelper.GetSizeClasses(12));
sb.AppendFormat("<div class=\"{0}\" style=\"float: left;\">", customClass);
sb.Append(helper.ToHtmlString());
sb.Append("</div>");
if (!string.IsNullOrWhiteSpace(tooltipResource))
{
if (isInnerTooltip)
{
sb.AppendFormat("<div class=\"{0} kretaLabelTooltip\" style=\"width: 40px; float: left;\">", customClass);
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">", helper.ToComponent().Name);
sb.Append("&nbsp;<img class='kretaLabelTooltipImg' />");
sb.AppendFormat("<span class=\"kretaLabelTooltipText\" {1}>{0}</span>", tooltipResource, string.IsNullOrWhiteSpace(tooltipWidth) ? "" : string.Format("style=\"width:{0};\"", tooltipWidth));
sb.Append("</label>");
sb.Append("</div>");
}
else
{
sb.AppendLine($@"<div class=""kretaLabelTooltipTextOuter"" style=""bottom: 100%; {(string.IsNullOrWhiteSpace(tooltipWidth) ? "" : string.Format("width:{0};", tooltipWidth))}"">
<span>{tooltipResource}</span></div>");
sb.Append($@"<script type=""text/javascript"">
$('label[for=""{helper.ToComponent().Name}_{helper.ToComponent().Value}""]').append(""<img class='kretaLabelTooltipImgOuter'/>"");
$('label[for=""{helper.ToComponent().Name}_{helper.ToComponent().Value}""]').parent().parent().parent('div[class^=""col-""]').css(""overflow"", ""visible"");
$('label[for=""{helper.ToComponent().Name}_{helper.ToComponent().Value}""]').parent().addClass(""kretaLabelTooltipOuter"")</script>");
}
}
sb.Append("</div>");
return new MvcHtmlString(sb.ToString());
}
}
}

View file

@ -0,0 +1,196 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Web;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
namespace Kreta.Web.Helpers
{
public static class RadioButtonListExtensions
{
public static MvcHtmlString KretaRadioButtonList(this HtmlHelper helper, string id, List<SelectListItem> items, object htmlAttributes = null)
{
TagBuilder ulTag = new TagBuilder("ul");
ulTag.AddCssClass("noUlLiButton");
int index = 0;
foreach (SelectListItem item in items)
{
index++;
string generatedId = id + index;
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("<li>");
stringBuilder.Append($"<input type=\"radio\" name=\"{id}\" value =\"{HttpUtility.HtmlEncode(item.Value)}\" id =\"{generatedId}\" class=\"k-radio\" {(item.Selected ? "checked=\"checked\"" : string.Empty)} />");
stringBuilder.Append($"<label for= \"{generatedId}\" class=\"k-radio-label\">{HttpUtility.HtmlEncode(item.Text)}</label>");
stringBuilder.Append("</li><br />");
ulTag.InnerHtml += stringBuilder.ToString();
}
return new MvcHtmlString(ulTag.ToString());
}
public static MvcHtmlString KretaRadioButtonListFor<TModel, TValue>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TValue>> expression, List<SelectListItem> items, bool isHorizontal = false, object htmlAttributes = null, string onChangeFunction = null, bool isNeedValidation = false)
{
var validationAttributes = "";
if (isNeedValidation)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData);
var value = metadata.Model;
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
fullBindingName = fullBindingName.Replace('.', '_');
var validationAttributesDict = htmlHelper.GetUnobtrusiveValidationAttributes(fullBindingName, metadata);
foreach (var attribute in validationAttributesDict)
{
var attributeValue = attribute.Value.ToString();
switch (attribute.Key)
{
case "data-val-required":
((Dictionary<string, object>)htmlAttributes).Add("data-rule-required", "true");
((Dictionary<string, object>)htmlAttributes).Add("data-msg-required", attributeValue);
((Dictionary<string, object>)htmlAttributes).Add("title", attributeValue);
break;
}
}
validationAttributes = string.Join(" ", ((Dictionary<string, object>)htmlAttributes).Select(x => x.Key + "=\"" + x.Value + "\""));
}
TagBuilder ulTag = new TagBuilder("ul");
ulTag.AddCssClass("noUlLiButton k-widget");
if (isHorizontal)
{
ulTag.AddCssClass("list-inline");
}
ulTag.Attributes.Add("style", "border-style: none");
int index = 0;
MemberExpression body = expression.Body as MemberExpression;
string propertyName = body.Member.Name;
string onchangeAttribute = string.Empty;
if (!string.IsNullOrWhiteSpace(onChangeFunction))
{
onchangeAttribute = " onchange=\"" + onChangeFunction + ";\"";
}
foreach (SelectListItem item in items)
{
index++;
string generatedId = propertyName + index;
string encodedTextWithTags = HttpUtility.HtmlEncode(item.Text);
foreach (string enencodeHtmlTag in Constants.UnencodeHtmlTagList)
{
encodedTextWithTags = encodedTextWithTags?.Replace($"&lt;{enencodeHtmlTag}&gt;", $"<{enencodeHtmlTag}>").Replace($"&lt;/{enencodeHtmlTag}&gt;", $"</{enencodeHtmlTag}>");
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("<li>");
stringBuilder.Append($"<input type=\"radio\" name=\"{propertyName}\" value =\"{HttpUtility.HtmlEncode(item.Value)}\" id =\"{generatedId}\" class=\"k-radio\"{onchangeAttribute} {(item.Selected ? "checked=\"checked\"" : string.Empty)} {validationAttributes}/>");
stringBuilder.Append($"<label for= \"{generatedId}\" class=\"k-radio-label\">{encodedTextWithTags}</label>");
stringBuilder.Append("</li>");
if (!isHorizontal)
{
stringBuilder.Append("<br />");
}
ulTag.InnerHtml += stringBuilder.ToString();
}
return new MvcHtmlString(ulTag.ToString());
}
public static RadioButtonBuilder KretaRadioButtonNyomtatvany(this HtmlHelper helper, string id, IDictionary<string, object> htmlAttributes = null, object value = null, bool check = false)
{
var radioButton = helper.Kendo().RadioButton()
.Name(id)
.Value(value)
.Checked(check);
if (htmlAttributes != null)
{
radioButton.HtmlAttributes(htmlAttributes);
}
return radioButton;
}
public static MvcHtmlString RenderWithName(this RadioButtonBuilder helper, int labelWidth = 6, int inputWidth = 6, string customClass = "", string tooltipResource = null, bool includeWrapperDiv = true)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, helper.ToComponent().Name, labelMsg, customClass, includeWrapperDiv);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, helper.ToComponent().Name, labelMsg, customClass, tooltipResource, includeWrapperDiv);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb, includeWrapperDiv);
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithName(this RadioButtonBuilder helper, string label, int labelWidth = 6, int inputWidth = 6, string tooltipResource = null, bool includeWrapperDiv = true)
{
var sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, helper.ToComponent().Name, label, string.Empty, includeWrapperDiv);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, helper.ToComponent().Name, label, string.Empty, tooltipResource, includeWrapperDiv);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb, includeWrapperDiv);
return new MvcHtmlString(sb.ToString());
}
private static void AddRenderWithNameBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, string controlName, string labelMsg, string customClass, bool needsWrapperDiv)
{
if (needsWrapperDiv)
{
sb.AppendFormat("<div class=\"{0}\" style=\"padding:5px 0px;\">", BootsrapHelper.GetSizeClasses(12));
}
sb.AppendFormat("<div class=\"{0} {1} \">", BootsrapHelper.GetSizeClasses(labelWidth), customClass);
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}</label>", controlName, labelMsg);
sb.AppendFormat("</div><div class=\"{0} {1}\">", BootsrapHelper.GetSizeClasses(inputWidth), customClass);
}
private static void AddRenderWithNameTooltipBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, string controlName, string labelMsg, string customClass, string tooltipResource, bool needsWrapperDiv)
{
if (needsWrapperDiv)
{
sb.AppendFormat("<div class=\"{0}\" style=\"padding:5px 0px;\">", BootsrapHelper.GetSizeClasses(12));
}
sb.AppendFormat("<div class=\"{0} {1} kretaLabelTooltip \">", BootsrapHelper.GetSizeClasses(labelWidth), customClass);
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}", controlName, labelMsg);
sb.Append("&nbsp;<img class='kretaLabelTooltipImg' />");
sb.AppendFormat("<span class=\"kretaLabelTooltipText\">{0}</span>", tooltipResource);
sb.Append("</label>");
sb.AppendFormat("</div><div class=\"{0} {1}\">", BootsrapHelper.GetSizeClasses(inputWidth), customClass);
}
private static void AddRenderWithNameCloseingFrame(StringBuilder sb, bool needsWrapperDiv)
{
sb.Append("</div>");
if (needsWrapperDiv)
{
sb.Append("</div>");
}
}
}
}

View file

@ -0,0 +1,227 @@
using System;
using System.Linq.Expressions;
using System.Text;
using System.Web.Mvc;
using Kreta.Framework;
namespace Kreta.Web.Helpers
{
public static class RangeDatePickerExtensions
{
public static MvcHtmlString KretaRangeDatePicker<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> fromExpression, Expression<Func<TModel, TValue>> toExpression, string title = "")
{
var fromFieldName = ExpressionHelper.GetExpressionText(fromExpression);
var fromFieldId = fromFieldName.Replace(".", "_");
var fromMetadata = ModelMetadata.FromLambdaExpression(fromExpression, helper.ViewData);
var fromDisplayName = fromMetadata.DisplayName;
var toFieldName = ExpressionHelper.GetExpressionText(toExpression);
var toFieldId = toFieldName.Replace(".", "_");
var toMetadata = ModelMetadata.FromLambdaExpression(toExpression, helper.ViewData);
var toDisplayName = toMetadata.DisplayName;
StringBuilder sb = new StringBuilder();
string fromDate = "<input id='" + fromFieldId + "' name='" + fromFieldName + "' />";
string toDate = "<input id='" + toFieldId + "' name='" + toFieldName + "' />";
string scriptTag = @"<script>
$(document).ready(function () {
function start" + fromFieldId + @"Change() {
var startDate = start" + fromFieldId + @".value(), endDate = end" + toFieldId + @".value();
if (typeof startDate !== 'undefined' && typeof endDate !== 'undefined'){
if (startDate) {
startDate = new Date(startDate);
startDate.setDate(startDate.getDate());
end" + toFieldId + @".min(startDate);
} else if (endDate) {
start" + fromFieldId + @".max(new Date(endDate));
} else {
endDate = new Date();
start" + fromFieldId + @".max(endDate);
end" + toFieldId + @".min(endDate);
}
}
}
function end" + toFieldId + @"Change() {
var endDate = end" + toFieldId + @".value(), startDate = start" + fromFieldId + @".value();
if (endDate) {
endDate = new Date(endDate);
endDate.setDate(endDate.getDate());
start" + fromFieldId + @".max(endDate);
} else if (startDate) {
end" + toFieldId + @".min(new Date(startDate));
} else {
endDate = new Date();
start" + fromFieldId + @".max(endDate);
end" + toFieldId + @".min(endDate);
}
}
var start" + fromFieldId + @" = $('#" + fromFieldId + @"').kendoDatePicker({
change: start" + fromFieldId + @"Change,
'format': 'yyyy. MM. dd.'
}).data('kendoDatePicker');
var end" + toFieldId + @" = $('#" + toFieldId + @"').kendoDatePicker({
change: end" + toFieldId + @"Change,
'format': 'yyyy. MM. dd.'
}).data('kendoDatePicker');
start" + fromFieldId + @".max(end" + toFieldId + @".value());
end" + toFieldId + @".min(start" + fromFieldId + @".value());
$('#" + fromFieldId + @"').parent().parent().after('" + string.Format("<span class=\"searchPanelLabel\">{0}</span>", StringResourcesUtil.GetString(3080)) + @"');
$('#" + toFieldId + @"').parent().parent().after('" + string.Format("<span class=\"searchPanelLabel\">{0}</span>", StringResourcesUtil.GetString(3081)) + @"');
});
</script>";
string displayName = "";
if (!string.IsNullOrWhiteSpace(title))
{ displayName = title; }
else
{
if (!string.IsNullOrWhiteSpace(fromDisplayName))
{ displayName = fromDisplayName; }
else
{
if (!string.IsNullOrWhiteSpace(toDisplayName))
{ displayName = toDisplayName; }
}
}
sb.Append("<div class=\"searchPanelRow\">");
sb.Append("<div class=\"searchPanelRowTitle\">");
sb.Append("<label class=\"searchPanelLabel\" for=\"").Append("aaa").Append("\">").Append(displayName).Append("</label>");
sb.Append("</div>");
sb.Append("<div class=\"searchPanelRowValue\">");
sb.Append(fromDate).Append("&nbsp;").Append(toDate).Append(scriptTag);
sb.Append("</div>");
sb.Append("</div>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString KretaRangeDatePickerSideBar<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> fromExpression, Expression<Func<TModel, TValue>> toExpression, string title = "")
{
var fromFieldName = ExpressionHelper.GetExpressionText(fromExpression);
var fromFieldId = fromFieldName.Replace(".", "_");
var fromMetadata = ModelMetadata.FromLambdaExpression(fromExpression, helper.ViewData);
var fromDisplayName = fromMetadata.DisplayName;
var fromValue = fromMetadata.Model;
var toFieldName = ExpressionHelper.GetExpressionText(toExpression);
var toFieldId = toFieldName.Replace(".", "_");
var toMetadata = ModelMetadata.FromLambdaExpression(toExpression, helper.ViewData);
var toDisplayName = toMetadata.DisplayName;
var toValue = toMetadata.Model;
StringBuilder sb = new StringBuilder();
string fromDate = "<input id='" + fromFieldId + "' name='" + fromFieldName + "' value='" + fromValue + "' />";
string toDate = "<input id='" + toFieldId + "' name='" + toFieldName + "' value='" + toValue + "' />";
string scriptTag = @"<script>
$(document).ready(function () {
function start" + fromFieldId + @"Change() {
var startDate = start" + fromFieldId + @".value(), endDate = end" + toFieldId + @".value();
if (startDate) {
startDate = new Date(startDate);
startDate.setDate(startDate.getDate());
end" + toFieldId + @".min(startDate);
} else if (endDate) {
start" + fromFieldId + @".max(new Date(endDate));
end" + toFieldId + @".min(new Date(1900, 0, 1));
} else {
endDate = new Date();
start" + fromFieldId + @".max(endDate);
end" + toFieldId + @".min(endDate);
}
}
function end" + toFieldId + @"Change() {
var endDate = end" + toFieldId + @".value(), startDate = start" + fromFieldId + @".value();
if (endDate) {
endDate = new Date(endDate);
endDate.setDate(endDate.getDate());
start" + fromFieldId + @".max(endDate);
} else if (startDate) {
end" + toFieldId + @".min(new Date(startDate));
start" + fromFieldId + @".max(new Date(2099, 11, 31));
} else {
endDate = new Date();
start" + fromFieldId + @".max(endDate);
end" + toFieldId + @".min(endDate);
}
}
function open" + fromFieldId + @"Change() {
var endDate = Date.parse($('#" + toFieldId + @"').val());
if(isNaN(endDate)){
start" + fromFieldId + @".max(new Date(2099, 11, 31));
}
}
function open" + toFieldId + @"Change() {
var startDate = Date.parse( $('#" + fromFieldId + @"').val());
if(isNaN(startDate)){
end" + toFieldId + @".min(new Date(1900, 0, 1));
}
}
var start" + fromFieldId + @" = $('#" + fromFieldId + @"').kendoDatePicker({
change: start" + fromFieldId + @"Change,
open: open" + fromFieldId + @"Change,
'format': 'yyyy. MM. dd.'
}).data('kendoDatePicker');
var end" + toFieldId + @" = $('#" + toFieldId + @"').kendoDatePicker({
change: end" + toFieldId + @"Change,
open: open" + toFieldId + @"Change,
'format': 'yyyy. MM. dd.'
}).data('kendoDatePicker');
start" + fromFieldId + @".max(end" + toFieldId + @".value());
end" + toFieldId + @".min(start" + fromFieldId + @".value());
$('#" + fromFieldId + @"').parent().parent().after('" + string.Format("<span class=\"searchPanelLabel\">{0}</span>", StringResourcesUtil.GetString(3080)) + @"');
$('#" + toFieldId + @"').parent().parent().after('" + string.Format("<span class=\"searchPanelLabel\">{0}</span>", StringResourcesUtil.GetString(3081)) + @"');
});
</script>";
string displayName = "";
if (!string.IsNullOrWhiteSpace(title))
{ displayName = title; }
else
{
if (!string.IsNullOrWhiteSpace(fromDisplayName))
{ displayName = fromDisplayName; }
else
{
if (!string.IsNullOrWhiteSpace(toDisplayName))
{ displayName = toDisplayName; }
}
}
sb.Append("<div class=\"searchPanelRow\">");
sb.Append("<div class=\"searchPanelRowTitle\">");
sb.Append("<label class=\"searchPanelLabel\" for=\"").Append("aaa").Append("\">").Append(displayName).Append("</label>");
sb.Append("</div>");
sb.Append("<div class=\"searchPanelRowValue\">");
sb.Append(fromDate).Append("<br />").Append(toDate).Append(scriptTag);
sb.Append("</div>");
sb.Append("</div>");
sb.Append("<script>$(\"#").Append(fromFieldId).Append("\").kendoMaskedDatePicker();$(\"#").Append(toFieldName).Append("\").kendoMaskedDatePicker();");
sb.Append("$(\"#").Append(fromFieldId).Append("\").change(function() {{ KretaDateTimeHelper.validateDate($(this)); }});");
sb.Append("$(\"#").Append(toFieldId).Append("\").change(function() {{ KretaDateTimeHelper.validateDate($(this)); }});");
sb.Append("</script>");
return new MvcHtmlString(sb.ToString());
}
}
}

View file

@ -0,0 +1,216 @@
using System;
using System.Globalization;
using System.Linq.Expressions;
using System.Text;
using System.Web.Mvc;
using Kreta.Framework;
namespace Kreta.Web.Helpers
{
public static class RangeNumericExtensions
{
public static MvcHtmlString KretaRangeNumeric<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> fromexpression, Expression<Func<TModel, TValue>> toexpression, string title = "", int? precision = null, double? step = null)
{
var spinStep = (step ?? 1).ToString(CultureInfo.InvariantCulture.NumberFormat);
var fromFieldName = ExpressionHelper.GetExpressionText(fromexpression);
var fromFullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fromFieldName);
var fromMetadata = ModelMetadata.FromLambdaExpression(fromexpression, helper.ViewData);
var fromDisplayName = fromMetadata.DisplayName;
var fromValue = fromMetadata.Model;
var fromValidationAttributes = helper.GetUnobtrusiveValidationAttributes(fromFullBindingName, fromMetadata);
object globalMinValue = Constants.General.KretaRangeNumericSideBarMinValue;
if (fromValidationAttributes.Count > 0)
{ foreach (var item in fromValidationAttributes) { if (item.Key == "data-val-range-min") { globalMinValue = item.Value; } } }
int decimalPrecision = precision ?? (globalMinValue != null && globalMinValue is Double ? 2 : 0);
var toFieldName = ExpressionHelper.GetExpressionText(toexpression);
var toFullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(toFieldName);
var toMetadata = ModelMetadata.FromLambdaExpression(toexpression, helper.ViewData);
var toDisplayName = toMetadata.DisplayName;
var toValue = toMetadata.Model;
var toValidationAttributes = helper.GetUnobtrusiveValidationAttributes(toFullBindingName, toMetadata);
object globalMaxValue = Constants.General.KretaRangeNumericSideBarMaxValue;
if (toValidationAttributes.Count > 0)
{ foreach (var item in toValidationAttributes) { if (item.Key == "data-val-range-max") { globalMaxValue = item.Value; } } }
decimalPrecision = precision ?? (globalMaxValue != null && globalMaxValue is Double ? 2 : 0);
StringBuilder sb = new StringBuilder();
string fromDate = "<input id='" + fromFieldName + "' name='" + fromFieldName + "' />";
string toDate = "<input id='" + toFieldName + "' name='" + toFieldName + "' />";
string scriptTag = @"<script>
$(document).ready(function () {
function set" + fromFieldName + @"Change() {
var maxValue = $('#" + toFieldName + @"').data('kendoNumericTextBox').value();
if(!(maxValue == null || typeof maxValue === 'undefined')) {
$('#" + fromFieldName + @"').data('kendoNumericTextBox').max(maxValue);
}
$('#" + fromFieldName + @"').focusin().focusout();
}
function set" + toFieldName + @"Change() {
var minValue = $('#" + fromFieldName + @"').data('kendoNumericTextBox').value();
if(!(minValue == null || typeof minValue === 'undefined'')) {
$('#" + toFieldName + @"').data('kendoNumericTextBox').min(minValue);
}
$('#" + toFieldName + @"').focusin().focusout();
}
$('#" + fromFieldName + @"').kendoNumericTextBox({
format: 'n" + decimalPrecision.ToString() + @"',
decimals: " + decimalPrecision.ToString() + @",
step: " + spinStep + @",
change: set" + fromFieldName + @"Change";
if (globalMinValue != null)
{ scriptTag += ",min: " + (globalMinValue is Double ? (double)globalMinValue : (int)globalMinValue).ToString(CultureInfo.InvariantCulture.NumberFormat) + ""; }
scriptTag += @"
});
$('#" + toFieldName + @"').kendoNumericTextBox({
format: 'n" + decimalPrecision.ToString() + @"',
decimals: " + decimalPrecision.ToString() + @",
step: " + spinStep + @",
change: set" + toFieldName + @"Change";
if (globalMaxValue != null)
{ scriptTag += ",max: " + (globalMaxValue is Double ? (double)globalMaxValue : (int)globalMaxValue).ToString(CultureInfo.InvariantCulture.NumberFormat) + ""; }
scriptTag += @"
});
});
</script>";
string displayName = "";
if (!string.IsNullOrWhiteSpace(title))
{ displayName = title; }
else
{
if (!string.IsNullOrWhiteSpace(fromDisplayName))
{ displayName = fromDisplayName; }
else
{
if (!string.IsNullOrWhiteSpace(toDisplayName))
{ displayName = toDisplayName; }
}
}
sb.Append("<div class=\"col-xs-6\">");
sb.Append("<label class=\"searchPanelLabel\" for=\"").Append("a").Append("\">").Append(displayName).Append("</label>");
sb.Append("</div>");
sb.Append("<div class=\"col-xs-6\">");
sb.Append(fromDate).Append("&nbsp;").Append(toDate).Append(scriptTag);
sb.Append("</div>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString KretaRangeNumericSideBar<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> fromexpression, Expression<Func<TModel, TValue>> toexpression, string title = "", int? precision = null, bool needTolIgLabels = false, double? step = null)
{
var spinStep = (step ?? 1).ToString(CultureInfo.InvariantCulture.NumberFormat);
var fromFieldName = ExpressionHelper.GetExpressionText(fromexpression);
var fromFullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fromFieldName);
var fromMetadata = ModelMetadata.FromLambdaExpression(fromexpression, helper.ViewData);
var fromDisplayName = fromMetadata.DisplayName;
var fromValue = fromMetadata.Model;
var fromValidationAttributes = helper.GetUnobtrusiveValidationAttributes(fromFullBindingName, fromMetadata);
object globalMinValue = Constants.General.KretaRangeNumericSideBarMinValue;
if (fromValidationAttributes.Count > 0)
{ foreach (var item in fromValidationAttributes) { if (item.Key == "data-val-range-min") { globalMinValue = item.Value; } } }
int decimalPrecision = precision ?? (globalMinValue != null && globalMinValue is Double ? 2 : 0);
var toFieldName = ExpressionHelper.GetExpressionText(toexpression);
var toFullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(toFieldName);
var toMetadata = ModelMetadata.FromLambdaExpression(toexpression, helper.ViewData);
var toDisplayName = toMetadata.DisplayName;
var toValue = toMetadata.Model;
var toValidationAttributes = helper.GetUnobtrusiveValidationAttributes(toFullBindingName, toMetadata);
object globalMaxValue = Constants.General.KretaRangeNumericSideBarMaxValue;
if (toValidationAttributes.Count > 0)
{ foreach (var item in toValidationAttributes) { if (item.Key == "data-val-range-max") { globalMaxValue = item.Value; } } }
decimalPrecision = precision ?? (globalMaxValue != null && globalMaxValue is Double ? 2 : 0);
StringBuilder sb = new StringBuilder();
string fromDate = "<input id='" + fromFieldName + "' name='" + fromFieldName + "' />";
string toDate = "<input id='" + toFieldName + "' name='" + toFieldName + "' />";
string scriptTag = @"<script>
$(document).ready(function () {
function set" + fromFieldName + @"Change() {
var maxValue = $('#" + toFieldName + @"').data('kendoNumericTextBox').value();
if(!(maxValue == null || typeof maxValue === 'undefined')) {
$('#" + fromFieldName + @"').data('kendoNumericTextBox').max(maxValue);
}
$('#" + fromFieldName + @"').focusin().focusout();
}
function set" + toFieldName + @"Change() {
var minValue = $('#" + fromFieldName + @"').data('kendoNumericTextBox').value();
if(!(minValue == null || typeof minValue === 'undefined')) {
$('#" + toFieldName + @"').data('kendoNumericTextBox').min(minValue);
}
$('#" + toFieldName + @"').focusin().focusout();
}
$('#" + fromFieldName + @"').kendoNumericTextBox({
format: 'n" + decimalPrecision.ToString() + @"',
decimals: " + decimalPrecision.ToString() + @",
spin: set" + fromFieldName + @"Change,
step: " + spinStep;
if (globalMinValue != null)
{ scriptTag += ",min: " + (globalMinValue is Double ? (double)globalMinValue : (int)globalMinValue).ToString(CultureInfo.InvariantCulture.NumberFormat) + ""; }
if (globalMaxValue != null)
{ scriptTag += ",max: " + (globalMaxValue is Double ? (double)globalMaxValue : (int)globalMaxValue).ToString(CultureInfo.InvariantCulture.NumberFormat) + ""; }
scriptTag += @"
});
$('#" + toFieldName + @"').kendoNumericTextBox({
format: 'n" + decimalPrecision.ToString() + @"',
decimals: " + decimalPrecision.ToString() + @",
spin: set" + toFieldName + @"Change,
step: " + spinStep;
if (globalMinValue != null)
{ scriptTag += ",min: " + (globalMinValue is Double ? (double)globalMinValue : (int)globalMinValue).ToString(CultureInfo.InvariantCulture.NumberFormat) + ""; }
if (globalMaxValue != null)
{ scriptTag += ",max: " + (globalMaxValue is Double ? (double)globalMaxValue : (int)globalMaxValue).ToString(CultureInfo.InvariantCulture.NumberFormat) + ""; }
scriptTag += @"
});
";
if (needTolIgLabels)
{
scriptTag += "$('#" + fromFieldName + @"').parent().parent().after('" + string.Format("<span class=\"searchPanelLabel\">{0}</span>", StringResourcesUtil.GetString(3080)) + @"');
$('#" + toFieldName + @"').parent().parent().after('" + string.Format("<span class=\"searchPanelLabel\">{0}</span>", StringResourcesUtil.GetString(3081)) + @"');"
;
}
scriptTag += @"
});
</script>";
string displayName = "";
if (!string.IsNullOrWhiteSpace(title))
{ displayName = title; }
else
{
if (!string.IsNullOrWhiteSpace(fromDisplayName))
{ displayName = fromDisplayName; }
else
{
if (!string.IsNullOrWhiteSpace(toDisplayName))
{ displayName = toDisplayName; }
}
}
sb.Append("<div class=\"searchPanelRow\">");
sb.Append("<div class=\"searchPanelRowTitle\">");
sb.Append("<label class=\"searchPanelLabel\" for=\"").Append("aaa").Append("\">").Append(displayName).Append("</label>");
sb.Append("</div>");
sb.Append("<div class=\"searchPanelRowValue\">");
sb.Append(fromDate).Append("<br />").Append(toDate).Append(scriptTag);
sb.Append("</div>");
sb.Append("</div>");
return new MvcHtmlString(sb.ToString());
}
}
}

View file

@ -0,0 +1,113 @@
using System;
using System.Linq.Expressions;
using System.Text;
using System.Web.Mvc;
using Kreta.Framework;
namespace Kreta.Web.Helpers
{
public static class RangeTimePickerExtensions
{
public static MvcHtmlString KretaRangeTimePickerSideBar<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> fromExpression, Expression<Func<TModel, TValue>> toExpression, string title = "", int interval = 0)
{
var fromFieldName = ExpressionHelper.GetExpressionText(fromExpression);
var fromFieldId = fromFieldName.Replace(".", "_");
var fromMetadata = ModelMetadata.FromLambdaExpression(fromExpression, helper.ViewData);
var fromDisplayName = fromMetadata.DisplayName;
var fromValue = fromMetadata.Model;
var toFieldName = ExpressionHelper.GetExpressionText(toExpression);
var toFieldId = toFieldName.Replace(".", "_");
var toMetadata = ModelMetadata.FromLambdaExpression(toExpression, helper.ViewData);
var toDisplayName = toMetadata.DisplayName;
var toValue = toMetadata.Model;
StringBuilder sb = new StringBuilder();
string fromDate = "<input id='" + fromFieldId + "' name='" + fromFieldName + "' value='" + fromValue + "' />";
string toDate = "<input id='" + toFieldId + "' name='" + toFieldName + "' value='" + toValue + "' />";
string scriptTag = @"<script>
$(document).ready(function () {
function start" + fromFieldId + @"Change() {
var startTime = start" + fromFieldId + @".value(), endTime = end" + toFieldId + @".value();
if (startTime) {
startTime = new Date(startTime);
startTime.setDate(startTime.getDate());
end" + toFieldId + @".min(startTime);
} else if (endTime) {
start" + fromFieldId + @".max(new Date(endTime));
} else {
endTime = new Date();
start" + fromFieldId + @".max(endTime);
end" + toFieldId + @".min(endTime);
}
}
function end" + toFieldId + @"Change() {
var endTime = end" + toFieldId + @".value(), startTime = start" + fromFieldId + @".value();
if (endTime) {
endTime = new Date(endTime);
endTime.setDate(endTime.getDate());
start" + fromFieldId + @".max(endTime);
} else if (startTime) {
end" + toFieldId + @".min(new Date(startTime));
} else {
endTime = new Date();
start" + fromFieldId + @".max(endTime);
end" + toFieldId + @".min(endTime);
}
}
var start" + fromFieldId + @" = $('#" + fromFieldId + @"').kendoTimePicker({
change: start" + fromFieldId + @"Change,
parseFormats: [""HH:mm""]," + @"
" + ((interval > 0) ? "interval: " + interval : "") + @"
}).data('kendoTimePicker');
var end" + toFieldId + @" = $('#" + toFieldId + @"').kendoTimePicker({
change: end" + toFieldId + @"Change,
parseFormats: [""HH:mm""]," + @"
" + ((interval > 0) ? "interval: " + interval : "") + @"
}).data('kendoTimePicker');
start" + fromFieldId + @".max(end" + toFieldId + @".value());
end" + toFieldId + @".min(start" + fromFieldId + @".value());
$('#" + fromFieldId + @"').parent().parent().after('" + string.Format("<span class=\"searchPanelLabel\">{0}</span>", StringResourcesUtil.GetString(3080)) + @"');
$('#" + toFieldId + @"').parent().parent().after('" + string.Format("<span class=\"searchPanelLabel\">{0}</span>", StringResourcesUtil.GetString(3081)) + @"');
});
</script>";
string displayName = "";
if (!string.IsNullOrWhiteSpace(title))
{ displayName = title; }
else
{
if (!string.IsNullOrWhiteSpace(fromDisplayName))
{ displayName = fromDisplayName; }
else
{
if (!string.IsNullOrWhiteSpace(toDisplayName))
{ displayName = toDisplayName; }
}
}
sb.Append("<div class=\"searchPanelRow\">");
sb.Append("<div class=\"searchPanelRowTitle\">");
sb.Append("<label class=\"searchPanelLabel\" for=\"").Append("aaa").Append("\">").Append(displayName).Append("</label>");
sb.Append("</div>");
sb.Append("<div class=\"searchPanelRowValue\">");
sb.Append(fromDate).Append("<br />").Append(toDate).Append(scriptTag);
sb.Append("</div>");
sb.Append("</div>");
sb.Append("<script>");
sb.Append($"KretaDateTimeHelper.SetMaskedTimepickerById(\"{fromFieldId}\");").Append($"KretaDateTimeHelper.SetMaskedTimepickerById(\"{toFieldId}\");");
sb.Append("</script>");
return new MvcHtmlString(sb.ToString());
}
}
}

View file

@ -0,0 +1,20 @@
using System.Web;
using System.Web.Mvc;
using Kreta.BusinessLogic.Logic;
namespace Kreta.Web.Helpers
{
public static class RawTextExtensions
{
public static IHtmlString RawRichText(this HtmlHelper helper, string html)
{
if (html == null)
{
return helper.Raw(null);
}
return helper.Raw(RichTextLogic.ConvertRawHtmlToRichTextHtml(html));
}
}
}

View file

@ -0,0 +1,15 @@
namespace Kreta.Web.Helpers.ReCaptcha
{
using Kreta.BusinessLogic.Classes;
using Kreta.Web.Models;
using Newtonsoft.Json;
public static class ReCaptchaValidator
{
public static ReCaptchaModel Validate(string token)
{
var googleReply = new System.Net.WebClient().DownloadString(ApplicationData.ReCaptchaValidateUrl + $"?secret={ApplicationData.ReCaptchaPrivateKey}&response={token}");
return JsonConvert.DeserializeObject<ReCaptchaModel>(googleReply);
}
}
}

View file

@ -0,0 +1,25 @@
using System.Collections.Generic;
using System.Web.Mvc;
namespace Kreta.Web.Helpers
{
public static class RequiredIfReflector
{
public static bool RequiredIf<TModel>(HtmlHelper<TModel> helper, IDictionary<string, object> validationAttributes)
{
if (validationAttributes.Keys.Contains("data-val-requiredif-dependentproperty") && validationAttributes.Keys.Contains("data-val-requiredif-dependentvalue"))
{
string dependentPropertyName = (string)validationAttributes["data-val-requiredif-dependentproperty"];
object requiredValue = validationAttributes["data-val-requiredif-dependentvalue"];
var propertyInfo = helper.ViewData.Model.GetType().GetProperty(dependentPropertyName);
object dependentPropertyValue = propertyInfo.GetValue(helper.ViewData.Model);
return requiredValue.Equals(dependentPropertyValue);
}
return false;
}
}
}

View file

@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using Kreta.Framework;
namespace Kreta.Web.Helpers
{
public static class SearchPanelExtensions
{
public static SearchPanelHelper SearchPanel(this HtmlHelper helper, string formId, string gridId, int columnNumber = 1, bool autoOpen = false, string actionName = "ReloadGrid", Dictionary<string, object> htmlAttributes = null)
{
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
htmlAttributes.Add("id", formId);
htmlAttributes.Add("columnNumber", columnNumber);
}
string btnValue = StringResourcesUtil.GetString(238);
string btnId = formId + "Btn";
helper.SearchPanelStart(autoOpen);
var mvcForm = helper.BeginForm(null, null, FormMethod.Get, htmlAttributes);
StringBuilder sb = new StringBuilder();
sb
.Append("<script>setTimeout(function() {")
/*SearchPanel oszlopossá tétele*/
.Append("var column = $(\"#").Append(formId).Append("\").attr(\"columnnumber\"); var cnt = 0;")
.Append("$(\".searchInputRowHeight\").each(function() {")
.Append("cnt = cnt + 1;")
.Append("if (column == cnt) {")
.Append("$('<br />').insertAfter($(this));")
.Append("cnt = 0;} });")
/*SearchPanel KendoPanelBar legyen*/
.Append("$(\"#searchPanelUl\").kendoPanelBar({ expandMode: \"multiple\" });")
/*Listázás gomb felrakása*/
.Append("$(\"#").Append(formId)
.Append("\").append('</ br><input type=\"button\" class=\"k-button k-button-icontext\" id=\"").Append(btnId).Append("\" value=\"").Append(btnValue).Append("\" />\');")
/*Listázás gomb click function*/
.Append("$(\"#").Append(btnId).Append("\").click(function() {")
.Append("KretaGridHelper.refreshGridSearchPanel(\"").Append(gridId).Append("\",\"").Append(formId).Append("\")")
.Append("});")
.Append("},1);</script>");
helper.ViewContext.Writer.Write(sb.ToString());
return new SearchPanelHelper(helper);
}
public static void SearchPanelStart(this HtmlHelper html, bool autoOpen)
{
string searchPanelText = StringResourcesUtil.GetString(226);
StringBuilder beforeContent = new StringBuilder();
if (autoOpen)
beforeContent.Append("<div class=\"searchPanel\"><ul id=\"searchPanelUl\"><li class=\"k-state-active\"><span>").Append(searchPanelText).Append("</span><div><div>");
else
beforeContent.Append("<div class=\"searchPanel\"><ul id=\"searchPanelUl\"><li><span>").Append(searchPanelText).Append("</span><div><div>");
html.ViewContext.Writer.Write(beforeContent.ToString());
}
public static void SearchPanelEnd(this HtmlHelper html)
{
StringBuilder endContent = new StringBuilder();
endContent.Append("</div></div></li></ul></div>");
html.ViewContext.Writer.Write(endContent.ToString());
}
public class SearchPanelHelper : IDisposable
{
private readonly HtmlHelper rohtml;
public SearchPanelHelper(HtmlHelper html)
{
rohtml = html;
}
public void Dispose()
{
rohtml.SearchPanelEnd();
}
}
}
}

View file

@ -0,0 +1,118 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using Kreta.Resources;
namespace Kreta.Web.Helpers
{
public static class SearchPanelSideBarExtensions
{
public static SearchPanelSideBarHelper SearchPanelSideBar(this HtmlHelper helper, string formId, string gridId, string preSubmitFunction = null, string postSubmitFunction = null, Dictionary<string, object> htmlAttributes = null)
{
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
htmlAttributes.Add("id", formId);
helper.SearchPanelSideBarStart(formId, gridId, preSubmitFunction, postSubmitFunction);
helper.BeginForm(null, null, FormMethod.Get, htmlAttributes);
return new SearchPanelSideBarHelper(helper);
}
public static void SearchPanelSideBarStart(this HtmlHelper html, string formId, string gridId, string preSubmitFunction, string postSubmitFunction)
{
StringBuilder beforeContent = new StringBuilder();
beforeContent.AppendFormat("<div id=\"layout_SearchPanelContainer\" data-gridId=\"{0}\">", gridId);
beforeContent.Append("<div class=\"collapse sidebaritem in\" id=\"layout_search\" aria-expanded=\"true\">");
beforeContent.Append("<div class=\"searchPanelButton\">");
beforeContent.Append("<input style=\"width: 25%;border-top-right-radius: 0;border-bottom-right-radius: 0;background-color: #a94442;\" type=\"button\" class=\"k-button k-button-icontext\" id=\"searchPanelResetBtn\" value=\"").Append("X").Append("\" />");
beforeContent.Append("<input style=\"width: 75%;border-top-left-radius: 0;border-bottom-left-radius: 0;\" type=\"button\" class=\"k-button k-button-icontext\" id=\"searchPanelBtn\" value=\"").Append(CommonResource.Kereses).Append("\" />");
beforeContent.Append("</div>");
beforeContent.Append("<div class=\"sideSearchPanel\">");
beforeContent.Append("<script>");
beforeContent.Append("$(\"#searchPanelResetBtn\").click(function () {");
beforeContent.Append("$(\"#").Append(formId).Append("\").resetForm(").Append(formId).Append(");");
beforeContent.Append("});");
beforeContent.Append("$(\"#searchPanelBtn\").click(function () {");
beforeContent.Append("var popup = $('#popupNotification').data('kendoNotification');");
beforeContent.Append("if (popup) {");
beforeContent.Append("popup.hide();");
beforeContent.Append("}");
if (!string.IsNullOrWhiteSpace(preSubmitFunction))
{
beforeContent.AppendFormat(" if({0}){{ {0}('{1}'); }}", preSubmitFunction, formId);
}
if (!string.IsNullOrWhiteSpace(gridId))
{
beforeContent.Append("KretaGridHelper.refreshGridSearchPanel(\"").Append(gridId).Append("\",\"").Append(formId).Append("\");");
beforeContent.AppendFormat("$(\"#{0}\").removeClass(\"disabledGrid\");", gridId);
}
if (!string.IsNullOrWhiteSpace(postSubmitFunction))
{
beforeContent.AppendFormat(" if({0}){{ {0}('{1}'); }}", postSubmitFunction, formId);
}
beforeContent.Append("});");
beforeContent.Append("$(document).ready(function() {");
beforeContent.Append("document.addEventListener(\"keydown\", onKeyDown, false);");
beforeContent.Append("function onKeyDown(e) {");
beforeContent.Append("if (e.keyCode == 13) {");
beforeContent.Append("var searchbutton = $(\"#searchPanelBtn\");");
beforeContent.AppendFormat("if (searchbutton != null && searchbutton.length == 1 && $(document.activeElement).parents(\"#{0}\").length == 1) {{", formId);
beforeContent.Append("MasterLayout.searchWithEnter = true;");
beforeContent.Append("searchbutton.click();");
beforeContent.Append("}");
beforeContent.Append("}");
beforeContent.Append("}");
beforeContent.Append("});");
beforeContent.Append("var searchPanelFirstLoad = true;");
beforeContent.Append("$(document).ajaxStop(function() {");
beforeContent.Append("if (searchPanelFirstLoad) {");
beforeContent.Append("KretaGridHelper.refreshGridSearchPanel(\"").Append(gridId).Append("\",\"").Append(formId).Append("\");");
beforeContent.Append("searchPanelFirstLoad = false;");
beforeContent.Append("}");
beforeContent.Append("});");
beforeContent.Append("</script>");
html.ViewContext.Writer.Write(beforeContent.ToString());
}
public static void SearchPanelSideBarEnd(this HtmlHelper html)
{
StringBuilder endContent = new StringBuilder();
endContent.Append("</div>");
endContent.Append("</div>");
endContent.Append("</div>");
endContent.Append("</form>");
html.ViewContext.Writer.Write(endContent.ToString());
}
public class SearchPanelSideBarHelper : IDisposable
{
private readonly HtmlHelper rohtml;
public SearchPanelSideBarHelper(HtmlHelper html)
{
rohtml = html;
}
public void Dispose()
{
rohtml.SearchPanelSideBarEnd();
}
}
}
}

View file

@ -0,0 +1,257 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Text.RegularExpressions;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Web.Routing;
using Kreta.Core;
using Kreta.Framework;
using Kreta.Resources;
using Kreta.Web.Classes;
using Kreta.Web.Helpers.Error;
namespace Kreta.Web.Helpers
{
public static class SelectorExtensions
{
public static MvcHtmlString KretaSelectorFor<TModel, TResult>(this HtmlHelper<TModel> html, Expression<Func<TModel, TResult>> expression, List<SelectListItem> list, bool allowRemoveSelected = true, string clickFunctionName = "", bool preventClickEventOnDocumentReady = false)
{
ModelMetadata metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
string htmlFieldName = ExpressionHelper.GetExpressionText(expression);
var value = metadata.Model;
StringBuilder sb = new StringBuilder();
sb.Append("<div id=\"div").Append(htmlFieldName.Replace(".", "_")).Append("\">");
sb.Append("<div class=\"selectorwrapper\">");
sb.Append("<ul class=\"bars weeks\">");
foreach (var item in list)
{
sb.Append("<li val=\"").Append(item.Value).Append("\" class=\"\">");
sb.Append("<div>").Append(item.Text).Append("</div>");
sb.Append("</li>");
}
sb.Append("</ul>");
sb.Append("<div class=\"clearfix\"></div>");
sb.Append("</div>");
sb.Append("<input ");
var attributes = Mapper.GetUnobtrusiveValidationAttributes(html, expression, null, metadata);
if (metadata.IsRequired)
{
attributes.Add("data-labelmsg", metadata.DisplayName + " *");
}
else
{
attributes.Add("data-labelmsg", metadata.DisplayName);
}
foreach (var key in attributes.Keys)
{
sb.Append(key + "='" + attributes[key] + "' ");
}
sb.Append(" type =\"hidden\" value=\"\" name=\"").Append(htmlFieldName).Append("\" id=\"").Append("").Append(htmlFieldName.Replace(".", "_")).Append("\">");
sb.Append("</div>");
StringBuilder scriptSb = new StringBuilder();
scriptSb.Append("<script>");
scriptSb.Append("$(document).ready(function() {");
scriptSb.Append("$('#div").Append(htmlFieldName.Replace(".", "_")).Append("').find('.selectorwrapper > ul > li').click(function() {");
scriptSb.Append("ElemKivalasztasa(this, '").Append(htmlFieldName.Replace(".", "_")).Append("');");
if (!string.IsNullOrWhiteSpace(clickFunctionName))
scriptSb.Append(clickFunctionName).Append("(this);");
scriptSb.Append("});");
if (!preventClickEventOnDocumentReady && value != null)
scriptSb.Append("$('#div").Append(htmlFieldName.Replace(".", "_")).Append("').find('.selectorwrapper > ul > li[val=").Append(value).Append("]').click();");
scriptSb.Append("});");
scriptSb.Append("</script>");
StringBuilder scriptIISb = new StringBuilder();
if (allowRemoveSelected)
{
scriptIISb.Append(@"<script>
function ElemKivalasztasa(elem, hiddenclientid) {
var ugyanarra = $(elem).hasClass('activebar');
$(elem).siblings('li').removeClass('activebar');
if (ugyanarra) {
$(elem).removeClass('activebar');
$('#' + hiddenclientid).val('');
}
else {
$(elem).addClass('activebar');
$('#' + hiddenclientid).val($(elem).attr('val'));
}
}
</script>");
}
else
{
scriptIISb.Append(@"<script>
function ElemKivalasztasa(elem, hiddenclientid) {
var ugyanarra = $(elem).hasClass('activebar');
$(elem).siblings('li').removeClass('activebar');
if (!ugyanarra) {
$(elem).addClass('activebar');
$('#' + hiddenclientid).val($(elem).attr('val'));
}
}
</script>");
}
StringBuilder result = new StringBuilder();
result.Append(scriptIISb);
result.Append(sb);
result.Append(scriptSb);
return new MvcHtmlString(result.ToString());
}
public static MvcHtmlString RenderWithNameForSelector(this MvcHtmlString helper, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false)
{
StringBuilder sb = new StringBuilder();
string labelMsg = null;
var str = helper.ToString();
MatchCollection matches = Regex.Matches(str, @"data-labelmsg='(.*)' ");
foreach (Match match in matches)
{
labelMsg = match.Groups[1].Value;
}
string labelName = null;
MatchCollection matches2 = Regex.Matches(str.Replace('"', '@'), @"name=@(.*)@ ");
foreach (Match match in matches2)
{
labelName = match.Groups[1].Value;
}
if (labelMsg == null || labelName == null)
{
throw new StatusError(500, ErrorResource.HibaTortentAzOldalonAzAdatokBetoltesekor)
{
UnHandledException = new Exception(ErrorResource.DOMHiba)
};
}
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, labelName, labelMsg, string.Empty);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
return new MvcHtmlString(sb.ToString());
}
private static void AddRenderWithNameBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, bool allSizeSame, string controlName, string labelMsg, string customClass)
{
sb.AppendFormat("<div class=\"{0} {1} \">", BootsrapHelper.GetSizeClasses(labelWidth, allSizeSame), customClass);
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}</label>", controlName, labelMsg);
sb.AppendFormat("</div><div class=\"{0} {1}\">", BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame), customClass);
}
private static void AddRenderWithNameCloseingFrame(StringBuilder sb)
{
sb.Append("</div>");
}
public static MvcHtmlString KretaSelectorForGrid<TModel, TResult>(this HtmlHelper<TModel> html, string htmlFieldName, string name, string value, Expression<Func<TModel, TResult>> expression, List<ExtendedSelectListItem> list, bool hasTooltip = false, string customClickFunctionName = null)
{
ModelMetadata metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
var controlStringBuilder = new StringBuilder();
controlStringBuilder.Append($"<div id=\"div{htmlFieldName.Replace(".", "_")}\">");
controlStringBuilder.Append("<div class=\"selectorwrapper\">");
controlStringBuilder.Append("<ul class=\"bars weeks\">");
foreach (ExtendedSelectListItem item in list)
{
string tooltip = null;
if (hasTooltip)
{
if (!string.IsNullOrWhiteSpace(item.Tooltip))
{
tooltip = item.Tooltip;
}
else if (int.TryParse(item.Value, out var itemValue) && itemValue.IsEntityId())
{
tooltip = StringResourcesUtil.GetString(itemValue);
}
}
controlStringBuilder.Append(!string.IsNullOrWhiteSpace(tooltip) ?
$"<li val=\"{item.Value}\" class=\"kretaSelectorButton\" title=\"{tooltip}\">" :
$"<li val=\"{item.Value}\" class=\"kretaSelectorButton\">");
controlStringBuilder.Append($"<div>{item.Text}</div>");
controlStringBuilder.Append("</li>");
}
controlStringBuilder.Append("</ul>");
controlStringBuilder.Append("<div class=\"clearfix\"></div>");
controlStringBuilder.Append("<input ");
RouteValueDictionary attributes = Mapper.GetUnobtrusiveValidationAttributes(html, expression, null, metadata);
foreach (string key in attributes.Keys)
{
controlStringBuilder.Append($"{key}='{attributes[key]}' ");
}
controlStringBuilder.AppendFormat(@"type =""hidden"" value="""" name=""{0}"" id=""{0}"" data-rowInputName=""{1}"" />", htmlFieldName, name);
controlStringBuilder.Append("</div>");
controlStringBuilder.Append("</div>");
var scriptStringBuilder = new StringBuilder();
scriptStringBuilder.Append("<script>");
scriptStringBuilder.Append("$(document).ready(function() {");
scriptStringBuilder.Append($"$('\\#div{htmlFieldName.Replace(".", "_")}').find('.selectorwrapper > ul > li').click(function() {{");
scriptStringBuilder.Append(@"
var elem = $(this);
var ugyanarra = elem.hasClass('activebar');
var hidden = elem.closest('.selectorwrapper').find('input[type=""hidden""]');
elem.siblings('li').removeClass('activebar');
if (ugyanarra)
{
elem.removeClass('activebar');
hidden.val('');
hidden.trigger('change');
}
else {
elem.addClass('activebar');
hidden.val($(elem).attr('val'));
hidden.trigger('change');
}
");
if (!string.IsNullOrWhiteSpace(customClickFunctionName))
{
scriptStringBuilder.Append(customClickFunctionName + "(this);");
}
scriptStringBuilder.Append("});");
scriptStringBuilder.Append($"$('\\#div{htmlFieldName.Replace(".", "_")}').find('.selectorwrapper > ul > li[val=\"{value}\"]').click();");
scriptStringBuilder.Append("});");
scriptStringBuilder.Append("</script>");
var result = new StringBuilder();
result.Append(controlStringBuilder);
result.Append(scriptStringBuilder);
return new MvcHtmlString(result.ToString());
}
}
}

View file

@ -0,0 +1,30 @@
using System.Text;
using System.Web.Mvc;
using Kreta.BusinessLogic.Utils;
namespace Kreta.Web.Helpers
{
public static class SwitchButtonExtension
{
public static MvcHtmlString KretaSwitchButton(this HtmlHelper helper, string name, bool state, int offstateText = 134, int onstateText = 133)
{
string kikapcsolt = (bool)state ? "" : "-off";
var sb = new StringBuilder();
sb.AppendFormat("<div class='onoffswitch' onclick='SwitchButtonHelper.switchButtonChange(\"my{0}\",\"hidden{0}\")'>", name);
sb.AppendFormat("<input type='checkbox' name='{0}' class='onoffswitch-checkbox' id='my{0}' {1} Value=\"{2}\" />", name, state ? "checked" : string.Empty, state);
sb.AppendFormat("<label class='onoffswitch-label' for='my{0}'>", name);
sb.AppendFormat("<span class='onoffswitch-inner onoffswitch-inner-before'><span>{0}</span></span>", StringResourcesUtils.GetString(onstateText));
sb.AppendFormat("<span class='onoffswitch-inner'></span>");
sb.AppendFormat("<span class='onoffswitch-inner onoffswitch-inner-after'><span>{0}</span></span>", StringResourcesUtils.GetString(offstateText));
sb.AppendFormat("<span class='onoffswitch-switch'></span>");
sb.Append("</label>");
sb.Append("</div>");
sb.AppendFormat("<input type='hidden' name='{0}' Value=\"{1}\" id='hidden{2}' style='visibility:\"collapse\"'/>", name, state, name);
return new MvcHtmlString(sb.ToString());
}
}
}

View file

@ -0,0 +1,9 @@
namespace Kreta.Web.Helpers.TabStrip
{
public class JQueryTabItems
{
public string Title { get; set; }
public string Content { get; set; }
public string Url { get; set; }
}
}

View file

@ -0,0 +1,45 @@
using System.Collections.Generic;
using System.Text;
using Kreta.Web.Security;
namespace Kreta.Web.Helpers.TabStrip
{
public class TabStripItemModel
{
public string ItemId { get; set; }
public string ItemName { get; set; }
public string PartialViewName { get; set; }
public object Model { get; set; }
public bool IsActive { get; set; }
public bool IsETTFDisabled { get; set; }
public bool IsImportantDisabled { get; set; }
public string KendoCssClass
{
get
{
var sb = new StringBuilder();
if (this.IsActive)
{
sb.Append("k-state-active ");
}
// csak ettfverzios tiltas
//UPDATE: Már vttf verziós tiltás
//var ettfverzio = ApplicationData.ETTFVerzio;
var fullKretaVersion = ClaimData.IsFullKretaVerzio;
if (IsImportantDisabled || (!fullKretaVersion && IsETTFDisabled))
{
sb.Append("k-state-disabled ");
}
return sb.ToString();
}
}
public string Area { get; set; }
public string Controller { get; set; }
public string Action { get; set; }
public Dictionary<string, string> RouteParameters { get; set; }
}
}

View file

@ -0,0 +1,174 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kreta.Web.Helpers.TabStrip;
namespace Kreta.Web.Helpers
{
public static class TabStripExrtensions
{
public static Kendo.Mvc.UI.Fluent.TabStripBuilder KretaTabStrip(this HtmlHelper helper, string id, string showEventFunction = "")
{
var tab = helper.Kendo().TabStrip().Name(id);
if (!string.IsNullOrWhiteSpace(showEventFunction))
{
tab.Events(events => events.Show(showEventFunction));
}
return tab;
}
public static MvcHtmlString KretaTabStripAjax(this HtmlHelper helper, string id, List<TabStripItemModel> list, string activateEvent = null, string selectEvent = null)
{
StringBuilder sb = new StringBuilder();
if (list != null)
{
sb.Append("<div id=\"").Append(id).Append("_container\" class='tab-container'>");
sb.Append("</div>");
sb.Append("<div id=\"").Append(id).Append("\">");
sb.Append("<ul>");
var activeItem = list.FirstOrDefault(i => i.IsActive);
if (activeItem == null)
{
var firstItem = list.FirstOrDefault();
if (firstItem != null)
{
firstItem.IsActive = true;
}
}
foreach (var item in list)
{
var cssClass = item.KendoCssClass;
if (!string.IsNullOrWhiteSpace(cssClass))
{
sb.AppendFormat("<li class=\"{0}\">", cssClass).Append(item.ItemName).Append("</li>");
}
else
{
if (item.IsImportantDisabled)
{
sb.AppendFormat("<li class=\"{0}\">", "k-state-disabled ").Append(item.ItemName).Append("</li>");
}
else
{
sb.Append("<li>").Append(item.ItemName).Append("</li>");
}
}
}
sb.Append("</ul>");
var activateFunction = string.IsNullOrWhiteSpace(activateEvent) ? string.Empty : activateEvent + "(e);";
var selectFunction = string.IsNullOrWhiteSpace(selectEvent) ? string.Empty : selectEvent + "(e);";
sb.AppendFormat(@"
<script>
$(document).ready(function () {{ var ts = $('#{0}').kendoTabStrip({{animation: {{ open: {{ effects: 'fadeIn' }} }},
activate: function(e){{ {1} $('.modalContainer').scrollTop(0); }},
select: function(e){{ {2} }},
contentUrls: [", id, activateFunction, selectFunction);
int all = list.Count - 1;
int cnt2 = 0;
var urlHelper = new UrlHelper(helper.ViewContext.RequestContext);
string action;
foreach (var item in list)
{
action = string.IsNullOrWhiteSpace(item.Area) ? urlHelper.Action(item.Action, item.Controller) : urlHelper.Action(item.Action, item.Controller, new { item.Area });
if (item.RouteParameters != null && item.RouteParameters.Count > 0)
{
sb.AppendFormat("'{0}?{1}", action, string.Join("&", item.RouteParameters.Select(kvp => string.Format("{0}={1}", kvp.Key, kvp.Value))));
}
else
{
sb.AppendFormat("'{0}", action);
}
sb.Append("'");
if (cnt2 < all)
{ sb.Append(","); }
cnt2++;
}
sb.Append("]}).data('kendoTabStrip');");
// Hekkelés a design miatt
sb.Append("$('#" + id + " ul.k-tabstrip-items').appendTo('#" + id + "_container');");
sb.Append("$('#" + id + "_container').prependTo('#" + id + "');");
sb.Append("});</script>");
}
return new MvcHtmlString(sb.ToString());
}
public static HtmlString JQueryTabStrip(this HtmlHelper helper, string tabId, List<JQueryTabItems> tabItems)
{
StringBuilder scriptSb = new StringBuilder();
StringBuilder sb = new StringBuilder();
scriptSb.Append("<script>$(function() {$(\"#").Append(tabId).Append("\").tabs();});</script>");
sb.Append("<div id=\"").Append(tabId).Append("\"><ul>");
int cnt = 1;
foreach (var item in tabItems)
{
if (!string.IsNullOrWhiteSpace(item.Url))
{
sb.Append(string.Format("<li><a href=\"{0}\">{1}</a></li>", item.Url, item.Title));
}
else
{
sb.Append(string.Format("<li><a href='#{0}-{1}'>{2}</a></li>", tabId, cnt, item.Title));
}
cnt++;
}
sb.Append("</ul>");
int cnt2 = 1;
foreach (var item in tabItems)
{
if (!string.IsNullOrWhiteSpace(item.Content))
{
sb.Append(string.Format("<div id='{0}-{1}'>", tabId, cnt2));
sb.Append(item.Content);
sb.Append("</div>");
}
cnt2++;
}
sb.Append("</div>");
return new HtmlString(string.Format("{0} {1}", scriptSb, sb));
}
public static MvcHtmlString RenderOnModal(this Kendo.Mvc.UI.Fluent.TabStripBuilder helper)
{
StringBuilder sb = new StringBuilder();
var id = helper.ToComponent().Id;
sb.Append("<div id=\"").Append(id).Append("_container\" class='tab-container'>");
sb.Append("</div>");
sb.Append(helper.ToHtmlString());
// §§HOWTO: "Hekkelés a design miatt" (KretaTabStripNew-ból jött...)
var appendix = string.Format(@"
<script>
$(document).ready(function() {{
$('#{0} ul').first().appendTo('#{0}_container');
$('#{0}_container').prependTo('#{0}');
}});
</script>
", id);
sb.Append(appendix);
return new MvcHtmlString(sb.ToString());
}
}
}

View file

@ -0,0 +1,274 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
namespace Kreta.Web.Helpers
{
public static class TextBoxExtensions
{
public static TextBoxBuilder<string> KretaTextBox(this HtmlHelper helper, string name, bool enabled = true, Dictionary<string, object> htmlAttributes = null)
{
var tb = helper.Kendo().TextBox()
//.Name(Guid.NewGuid().ToString())
.Name(name)
.Enable(enabled);
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
htmlAttributes.Add("type", "text");
htmlAttributes.Add("name", name);
tb.HtmlAttributes(htmlAttributes);
return tb;
}
public static TextBoxBuilder<string> KretaTextBoxFor<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> expression, Dictionary<string, object> htmlAttributes = null)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
// var value = metadata.Model;
if (htmlAttributes == null)
htmlAttributes = new Dictionary<string, object>();
var attributes = Mapper.GetUnobtrusiveValidationAttributes(helper, expression, htmlAttributes, metadata);
foreach (var key in attributes.Keys)
{
try
{
if (htmlAttributes.ContainsKey(key) == false)
{
htmlAttributes.Add(key, attributes[key].ToString());
}
}
catch
{
}
}
var validationAttributes = helper.GetUnobtrusiveValidationAttributes(fullBindingName, metadata);
bool isRequiredIf = RequiredIfReflector.RequiredIf(helper, validationAttributes);
if (metadata.IsRequired || isRequiredIf)
{
htmlAttributes.Add("data-labelmsg", metadata.DisplayName + " *");
}
else
{
htmlAttributes.Add("data-labelmsg", metadata.DisplayName);
}
htmlAttributes.Add("type", "text");
htmlAttributes.Add("value", metadata.Model);
if (expression.Body is MemberExpression me && me.Member != null)
{
int maxLength = 0;
MaxLengthAttribute maxLengthAttribute = me.Member.GetCustomAttributes(typeof(MaxLengthAttribute), false).Cast<MaxLengthAttribute>().FirstOrDefault();
if (maxLengthAttribute != null)
{
maxLength = maxLengthAttribute.Length;
}
else
{
StringLengthAttribute stringLengthAttribute = me.Member.GetCustomAttributes(typeof(StringLengthAttribute), false).Cast<StringLengthAttribute>().FirstOrDefault();
if (stringLengthAttribute != null)
{
maxLength = stringLengthAttribute.MaximumLength;
}
}
if (maxLength > 0)
{
htmlAttributes["maxlength"] = maxLength.ToString();
}
}
var tb = helper.Kendo().TextBox()
.Name(fullBindingName)
.HtmlAttributes(htmlAttributes);
return tb;
}
public static MvcHtmlString RenderSearchPanel(this TextBoxBuilder<string> helper)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
StringBuilder sb = new StringBuilder();
sb.Append("<div class=\"searchInputRowHeight\"><div>");
sb.Append("<label class=\"searchPanelInputLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div><div>");
sb.Append(helper.ToHtmlString());
sb.Append("</div></div>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderSearchPanelSideBar(this TextBoxBuilder<string> helper)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
StringBuilder sb = new StringBuilder();
sb.Append("<div class=\"searchPanelRow\">");
sb.Append("<div class=\"searchPanelRowTitle\">");
sb.Append("<label class=\"searchPanelLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div>");
sb.Append("<div class=\"searchPanelRowValue\">");
sb.Append(helper.ToHtmlString());
sb.Append("</div>");
sb.Append("</div>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithName(this TextBoxBuilder<string> helper, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string tooltipResource = null, string customClass = null, bool tooltipOnControl = false, string customLabelMessage = null)
{
string labelMsg = "";
if (!string.IsNullOrWhiteSpace(customLabelMessage))
{
labelMsg = customLabelMessage;
}
else
{
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
}
return new MvcHtmlString(RenderWithName(labelMsg, helper, labelWidth, inputWidth, allSizeSame, tooltipResource, customClass: customClass, tooltipOnControl: tooltipOnControl));
}
public static MvcHtmlString RenderWithName(this TextBoxBuilder<string> helper, string label, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string tooltipResource = null, bool tooltipOnControl = false)
{
return new MvcHtmlString(RenderWithName(label, helper, labelWidth, inputWidth, allSizeSame, tooltipResource, tooltipOnControl: tooltipOnControl));
}
public static MvcHtmlString RenderWithBottomInfoAndName(this TextBoxBuilder<string> helper, string label, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string tooltipResource = null, string bottomInfo = null, bool tooltipOnControl = false)
{
string labelMsg = label;
if (labelMsg == null)
{
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
}
return new MvcHtmlString(RenderWithName(labelMsg, helper, labelWidth, inputWidth, allSizeSame, tooltipResource, bottomInfo, tooltipOnControl: tooltipOnControl));
}
public static MvcHtmlString RenderWithoutName(this TextBoxBuilder<string> helper, int inputWidth = 6, string customClass = null)
{
if (customClass == null)
customClass = string.Empty;
var sb = new StringBuilder();
sb.AppendFormat("<div class=\"{0} {1}\">", BootsrapHelper.GetSizeClasses(inputWidth, false), customClass);
sb.Append(helper.ToHtmlString());
sb.Append("</div>");
return new MvcHtmlString(sb.ToString());
}
private static string RenderWithName(string label, TextBoxBuilder<string> helper, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string tooltipResource = null, string bottomInfo = null, string customClass = null, bool tooltipOnControl = false)
{
var sb = new StringBuilder();
if (customClass == null)
customClass = string.Empty;
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, label, customClass);
else
{
if (!tooltipOnControl)
{
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, label, customClass, tooltipResource);
}
else
{
AddRenderWithNameTooltipOnControlBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, helper.ToComponent().Name, label, customClass, tooltipResource);
}
}
sb.Append(helper.ToHtmlString());
if (!string.IsNullOrWhiteSpace(bottomInfo))
{
AddRenderWithNameBottomInfo(sb, bottomInfo);
}
AddRenderWithNameCloseingFrame(sb);
return sb.ToString();
}
private static void AddRenderWithNameBottomInfo(StringBuilder sb, string bottomInfo)
{
sb.AppendFormat("<div style=\"text-align: right; margin: -4px 0 4px 0; font-size: 70%;\"><span>{0}</span></div>", bottomInfo);
}
private static void AddRenderWithNameBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, bool allSizeSame, string controlName, string labelMsg, string customClass)
{
sb.AppendFormat("<div class=\"{0} {1} \">", BootsrapHelper.GetSizeClasses(labelWidth, allSizeSame), customClass);
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}</label>", controlName, labelMsg);
sb.AppendFormat("</div><div class=\"{0} {1}\">", BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame), customClass);
}
private static void AddRenderWithNameTooltipBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, bool allSizeSame, string controlName, string labelMsg, string customClass, string tooltipResource)
{
sb.AppendFormat("<div class=\"{0} {1} kretaLabelTooltip \">", BootsrapHelper.GetSizeClasses(labelWidth, allSizeSame), customClass);
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}", controlName, labelMsg);
sb.Append("&nbsp;<img class='kretaLabelTooltipImg' />");
sb.AppendFormat("<span class=\"kretaLabelTooltipText\">{0}</span>", tooltipResource);
sb.Append("</label>");
sb.AppendFormat("</div><div class=\"{0} {1}\">", BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame), customClass);
}
private static void AddRenderWithNameTooltipOnControlBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, bool allSizeSame, string controlName, string labelMsg, string customClass, string tooltipResource)
{
sb.AppendFormat("<div class=\"{0} {1} kretaLabelTooltip \">", BootsrapHelper.GetSizeClasses(labelWidth, allSizeSame), customClass);
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}", controlName, labelMsg);
sb.Append("</label>");
sb.AppendFormat("</div><div class=\"{0} {1} kretaLabelTooltip\">", BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame), customClass);
sb.AppendFormat("<span class=\"kretaLabelTooltipText\">{0}</span>", tooltipResource);
}
private static void AddRenderWithNameCloseingFrame(StringBuilder sb)
{
sb.Append("</div>");
}
}
}

View file

@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
namespace Kreta.Web.Helpers
{
public static class TextBoxPasswordExtensions
{
public static TextBoxBuilder<string> KretaPassword(this HtmlHelper helper, string name, bool enabled = true, Dictionary<string, object> htmlAttributes = null)
{
var tb = helper.Kendo().TextBox()
//.Name(Guid.NewGuid().ToString())
.Name(name)
.Enable(enabled);
if (htmlAttributes == null)
{
htmlAttributes = new Dictionary<string, object>();
}
htmlAttributes.Add("type", "password");
htmlAttributes.Add("name", name);
tb.HtmlAttributes(htmlAttributes);
return tb;
}
public static TextBoxBuilder<string> KretaPasswordFor<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> expression, Dictionary<string, object> htmlAttributes = null)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
var value = metadata.Model;
if (htmlAttributes == null)
htmlAttributes = new Dictionary<string, object>();
var attributes = Mapper.GetUnobtrusiveValidationAttributes(helper, expression, htmlAttributes, metadata);
foreach (var key in attributes.Keys)
{
try
{
if (!key.Contains("equalto") && htmlAttributes.ContainsKey(key) == false)
{
htmlAttributes.Add(key, attributes[key].ToString());
}
}
catch
{
}
}
var validationAttributes = helper.GetUnobtrusiveValidationAttributes(fullBindingName, metadata);
if (metadata.IsRequired)
{ htmlAttributes.Add("data-labelmsg", metadata.DisplayName + " *"); }
else
{ htmlAttributes.Add("data-labelmsg", metadata.DisplayName); }
htmlAttributes.Add("type", "password");
var tb = helper.Kendo().TextBox()
.Name(fullBindingName)
.HtmlAttributes(htmlAttributes);
if (value != null)
tb.Value(value.ToString());
return tb;
}
}
}

View file

@ -0,0 +1,203 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;
namespace Kreta.Web.Helpers
{
public static class TextareaExtensions
{
public static MvcHtmlString KretaTextArea(this HtmlHelper helper, string name, List<string> value, int rows = 3, Dictionary<string, object> htmlAttributes = null)
{
StringBuilder textareaSB = new StringBuilder();
textareaSB.Append("<textarea id='" + name + "' name='" + name + "' rows='" + rows + "' ");
if (htmlAttributes != null)
{
if (htmlAttributes.ContainsKey("class"))
{
htmlAttributes["class"] += " k-textbox";
}
else
{
htmlAttributes.Add("class", "k-textbox");
}
foreach (var item in htmlAttributes)
{
textareaSB.Append(item.Key.ToString() + "='" + item.Value.ToString() + "'");
}
}
textareaSB.AppendFormat(">{0}</textarea>", HttpUtility.HtmlEncode(string.Join("\n", value)));
return new MvcHtmlString(textareaSB.ToString());
}
public static MvcHtmlString KretaTextAreaFor<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> expression, int rows = 3, Dictionary<string, object> htmlAttributes = null)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
var value = metadata.Model;
if (htmlAttributes == null)
htmlAttributes = new Dictionary<string, object>();
var attributes = Mapper.GetUnobtrusiveValidationAttributes(helper, expression, htmlAttributes, metadata);
foreach (var key in attributes.Keys)
{
if (!htmlAttributes.ContainsKey(key))
{
htmlAttributes.Add(key, attributes[key].ToString());
}
}
var validationAttributes = helper.GetUnobtrusiveValidationAttributes(fullBindingName, metadata);
if (metadata.IsRequired)
{ htmlAttributes.Add("data-labelmsg", metadata.DisplayName + " *"); }
else
{
if (metadata.DisplayName == null)
{
htmlAttributes.Add("data-labelmsg", "");
}
else
{
htmlAttributes.Add("data-labelmsg", metadata.DisplayName);
}
}
if (htmlAttributes.ContainsKey("class"))
{
htmlAttributes["class"] += " k-textbox";
}
else
{
htmlAttributes.Add("class", "k-textbox");
}
if (expression.Body is MemberExpression me && me.Member != null)
{
int maxLength = 0;
MaxLengthAttribute maxLengthAttribute = me.Member.GetCustomAttributes(typeof(MaxLengthAttribute), false).Cast<MaxLengthAttribute>().FirstOrDefault();
if (maxLengthAttribute != null)
{
maxLength = maxLengthAttribute.Length;
}
else
{
StringLengthAttribute stringLengthAttribute = me.Member.GetCustomAttributes(typeof(StringLengthAttribute), false).Cast<StringLengthAttribute>().FirstOrDefault();
if (stringLengthAttribute != null)
{
maxLength = stringLengthAttribute.MaximumLength;
}
}
if (maxLength > 0)
{
htmlAttributes["maxlength"] = maxLength.ToString();
}
}
StringBuilder textareaSB = new StringBuilder();
textareaSB.Append("<textarea id='" + fieldName.Replace(".", "_") + "' name='" + fieldName + "' rows='" + rows + "' ");
foreach (var item in htmlAttributes)
{
textareaSB.Append(item.Key.ToString() + "='" + item.Value.ToString() + "' ");
}
textareaSB.Append(">").Append(HttpUtility.HtmlEncode(value)).Append("</textarea>");
return new MvcHtmlString(textareaSB.ToString());
}
public static MvcHtmlString RenderWithName(this MvcHtmlString helper, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string customLabelDivClass = "", string customLabelClass = "", string tooltipResource = null)
{
StringBuilder sb = new StringBuilder();
/*Hack hogy kiszedjük a stringből a labelMsg-t*/
int startIndex = helper.ToString().IndexOf("data-labelmsg");
string str = helper.ToString().Substring(startIndex + 15).Replace("</textarea>", "");
int startIndex2 = str.IndexOf("'");
string labelMsg = str.Substring(0, startIndex2);
/*Hack hogy kiszedjük a stringből a labelMsg-t*/
/*Hack hogy kiszedjük a stringből az Id-t*/
int startIndexId = helper.ToString().IndexOf("id");
int startIndexName = helper.ToString().IndexOf("name");
string str2 = helper.ToString().Substring(0, startIndexName).Replace("<textarea id='", "");
int startIndex2Id = str2.IndexOf("'");
string labelMsg2 = str2.Substring(0, startIndex2Id);
/*Hack hogy kiszedjük a stringből a labelMsg-t*/
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, labelMsg2, labelMsg, string.Empty);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, labelMsg2, labelMsg, string.Empty, tooltipResource);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithName(this MvcHtmlString helper, string label, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false, string tooltipResource = null)
{
StringBuilder sb = new StringBuilder();
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, string.Empty, label, string.Empty);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, string.Empty, label, string.Empty, tooltipResource);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString Render(this MvcHtmlString helper, int labelWidth = 6, int inputWidth = 6, bool allSizeSame = false)
{
StringBuilder sb = new StringBuilder();
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, allSizeSame, string.Empty, string.Empty, string.Empty);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
return new MvcHtmlString(sb.ToString());
}
private static void AddRenderWithNameBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, bool allSizeSame, string controlName, string labelMsg, string customClass)
{
sb.AppendFormat("<div class=\"{0} {1} \">", BootsrapHelper.GetSizeClasses(labelWidth, allSizeSame), customClass);
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}</label>", controlName, labelMsg);
sb.AppendFormat("</div><div class=\"{0} {1}\">", BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame), customClass);
}
private static void AddRenderWithNameTooltipBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, bool allSizeSame, string controlName, string labelMsg, string customClass, string tooltipResource)
{
sb.AppendFormat("<div class=\"{0} {1} kretaLabelTooltip \">", BootsrapHelper.GetSizeClasses(labelWidth, allSizeSame), customClass);
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}", controlName, labelMsg);
sb.Append("&nbsp;<img class='kretaLabelTooltipImg' />");
sb.AppendFormat("<span class=\"kretaLabelTooltipText\">{0}</span>", tooltipResource);
sb.Append("</label>");
sb.AppendFormat("</div><div class=\"{0} {1}\">", BootsrapHelper.GetSizeClasses(inputWidth, allSizeSame), customClass);
}
private static void AddRenderWithNameCloseingFrame(StringBuilder sb)
{
sb.Append("</div>");
}
}
}

View file

@ -0,0 +1,214 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
using Kreta.Framework;
using Kreta.Web.Security;
namespace Kreta.Web.Helpers
{
public static class TimePickerExtensions
{
public static TimePickerBuilder KretaTimePicker(this HtmlHelper helper, string id, string className = "", bool enabled = true, string culture = "hu-HU", int interval = 1, DateTime? minValue = null, DateTime? maxValue = null, IDictionary<string, object> htmlAttributes = null)
{
if (helper.ViewData.ModelState[id] != null && helper.ViewData.ModelState[id].Errors.Count > 0)
className = string.Format("{0} input-validation-error", className);
var timepicker = helper.Kendo().TimePicker()
.Name(id)
.Enable(enabled)
.Culture(culture)
.Interval(interval)
.Format("HH:mm")
.ParseFormats(new string[] { "HH:mm" });
if (!string.IsNullOrWhiteSpace(className) || !string.IsNullOrWhiteSpace(id))
{
var attributes = new Dictionary<string, object>();
if (!string.IsNullOrWhiteSpace(className))
attributes.Add("class", className.Trim());
if (!string.IsNullOrWhiteSpace(id))
attributes.Add("id", id);
timepicker.HtmlAttributes(attributes);
}
if (minValue.HasValue)
timepicker.Min(minValue.Value);
if (maxValue.HasValue)
timepicker.Max(maxValue.Value);
if (htmlAttributes != null)
timepicker.HtmlAttributes(htmlAttributes);
return timepicker;
}
public static TimePickerBuilder KretaTimePickerFor<TModel, TValue>(this HtmlHelper<TModel> helper, Expression<Func<TModel, TValue>> expression, IDictionary<string, object> htmlAttributes = null)
{
var fieldName = ExpressionHelper.GetExpressionText(expression);
var fullBindingName = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(fieldName);
var metadata = ModelMetadata.FromLambdaExpression(expression, helper.ViewData);
var value = metadata.Model;
if (htmlAttributes == null)
htmlAttributes = new Dictionary<string, object>();
if (metadata.IsRequired)
{
htmlAttributes.Add("data-rule-required", "true");
htmlAttributes.Add("data-msg-required", string.Format(StringResourcesUtil.GetString(3477), metadata.DisplayName));
htmlAttributes.Add("data-labelmsg", metadata.DisplayName + " *");
}
else
{ htmlAttributes.Add("data-labelmsg", metadata.DisplayName); }
var timePicker = (expression.ReturnType == typeof(DateTime))
? helper.Kendo().TimePickerFor(Expression.Lambda<Func<TModel, DateTime>>(expression.Body, expression.Parameters))
: helper.Kendo().TimePickerFor(Expression.Lambda<Func<TModel, DateTime?>>(expression.Body, expression.Parameters));
timePicker.HtmlAttributes(htmlAttributes);
if (ClaimData.LCID == 1038 /*Magyar*/)
{
timePicker.Format("HH:mm");
}
return timePicker;
}
public static MvcHtmlString RenderSearchPanel(this TimePickerBuilder helper, bool withMask = true)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
StringBuilder sb = new StringBuilder();
if (withMask)
sb.Append($"<script>KretaDateTimeHelper.SetMaskedTimepickerById(\"{helper.ToComponent().Name.Replace('.', '_')}\");</script>");
sb.Append("<div class=\"searchInputRowHeight\"><div>");
sb.Append("<label class=\"searchPanelInputLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div><div>");
sb.Append(helper.ToHtmlString());
sb.Append("</div></div>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderSearchPanelSideBar(this TimePickerBuilder helper, bool withMask = true)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
StringBuilder sb = new StringBuilder();
if (withMask)
sb.Append($"<script>KretaDateTimeHelper.SetMaskedTimepickerById(\"{helper.ToComponent().Name.Replace('.', '_')}\");</script>");
sb.Append("<div class=\"searchPanelRow\">");
sb.Append("<div class=\"searchPanelRowTitle\">");
sb.Append("<label class=\"searchPanelLabel\" for=\"").Append(helper.ToComponent().Name).Append("\">").Append(labelMsg).Append("</label>");
sb.Append("</div>");
sb.Append("<div class=\"searchPanelRowValue\">");
sb.Append(helper.ToHtmlString());
sb.Append("</div>");
sb.Append("</div>");
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithMask(this TimePickerBuilder helper)
{
var controlId = helper.ToComponent().Id;
var output = new StringBuilder();
output.Append(helper.ToHtmlString());
output.Append("<script>");
output.Append($"KretaDateTimeHelper.SetMaskedTimepickerById(\"{controlId}\");");
output.Append("</script>");
return new MvcHtmlString(output.ToString());
}
public static MvcHtmlString RenderWithoutMask(this TimePickerBuilder helper)
{
var controlId = helper.ToComponent().Id;
var output = new StringBuilder();
output.Append(helper.ToHtmlString());
return new MvcHtmlString(output.ToString());
}
public static MvcHtmlString RenderWithName(this TimePickerBuilder helper, int labelWidth = 6, int inputWidth = 6, bool withMask = true, string tooltipResource = null)
{
string labelMsg = "";
foreach (var item in helper.ToComponent().HtmlAttributes)
{
if (item.Key == "data-labelmsg" && item.Value != null)
labelMsg = item.Value.ToString();
}
var sb = new StringBuilder();
if (withMask)
sb.Append($"<script>KretaDateTimeHelper.SetMaskedTimepickerById(\"{helper.ToComponent().Name.Replace('.', '_')}\");</script>");
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, helper.ToComponent().Name, labelMsg, string.Empty);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, helper.ToComponent().Name, labelMsg, string.Empty, tooltipResource);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
return new MvcHtmlString(sb.ToString());
}
public static MvcHtmlString RenderWithName(this TimePickerBuilder helper, string label, int labelWidth = 6, int inputWidth = 6, bool withMask = true, string tooltipResource = null)
{
var sb = new StringBuilder();
if (withMask)
sb.Append($"<script>KretaDateTimeHelper.SetMaskedTimepickerById(\"{helper.ToComponent().Name.Replace('.', '_')}\");</script>");
if (string.IsNullOrWhiteSpace(tooltipResource))
AddRenderWithNameBeginingFrame(sb, labelWidth, inputWidth, helper.ToComponent().Name, label, string.Empty);
else
AddRenderWithNameTooltipBeginingFrame(sb, labelWidth, inputWidth, helper.ToComponent().Name, label, string.Empty, tooltipResource);
sb.Append(helper.ToHtmlString());
AddRenderWithNameCloseingFrame(sb);
return new MvcHtmlString(sb.ToString());
}
private static void AddRenderWithNameBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, string controlName, string labelMsg, string customClass)
{
sb.AppendFormat("<div class=\"{0} {1} \">", BootsrapHelper.GetSizeClasses(labelWidth), customClass);
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}</label>", controlName, labelMsg);
sb.AppendFormat("</div><div class=\"{0} {1} timepickerMinWidth\">", BootsrapHelper.GetSizeClasses(inputWidth), customClass);
}
private static void AddRenderWithNameTooltipBeginingFrame(StringBuilder sb, int labelWidth, int inputWidth, string controlName, string labelMsg, string customClass, string tooltipResource)
{
sb.AppendFormat("<div class=\"{0} {1} kretaLabelTooltip \">", BootsrapHelper.GetSizeClasses(labelWidth), customClass);
sb.AppendFormat("<label class=\"windowInputLabel\" for=\"{0}\">{1}", controlName, labelMsg);
sb.Append("&nbsp;<img class='kretaLabelTooltipImg' />");
sb.AppendFormat("<span class=\"kretaLabelTooltipText\">{0}</span>", tooltipResource);
sb.Append("</label>");
sb.AppendFormat("</div><div class=\"{0} {1} timepickerMinWidth\">", BootsrapHelper.GetSizeClasses(inputWidth), customClass);
}
private static void AddRenderWithNameCloseingFrame(StringBuilder sb)
{
sb.Append("</div>");
}
}
}

View file

@ -0,0 +1,60 @@
using System;
using System.Linq.Expressions;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
using Kreta.Resources;
namespace Kreta.Web.Helpers.Unhacked
{
public static class ComboBoxExtensions
{
public struct ComboBoxParameters
{
public string Name;
public string Action;
public string Controller;
public string Area;
public string Placeholder;
public string Language;
public FilterType FilterType;
public string ContentType;
public bool ServerFiltering;
public ComboBoxParameters(string name, string action, string controller = "Enum", string area = "", string placeholder = null, string language = "Magyar",
FilterType filterType = FilterType.Contains, string contentType = Kreta.Core.Constants.ContentTypes.ApplicationJson, bool serverFiltering = false)
{
Name = name;
Action = action;
Controller = controller;
Area = area;
Language = language;
FilterType = filterType;
ContentType = contentType;
ServerFiltering = serverFiltering;
Placeholder = placeholder ?? CommonResource.PleaseChoose;
}
}
public static ComboBoxBuilder KendoComboBoxFor<TModel, TProperty>(this HtmlHelper<TModel> html, Expression<Func<TModel, TProperty>> expression, ComboBoxParameters parameters)
{
return html.Kendo().ComboBoxFor(expression)
.Name(parameters.Name + "ComboBox")
.Placeholder(parameters.Placeholder)
.DataTextField(parameters.Language)
.DataValueField("Id")
.Filter(parameters.FilterType)
.DataSource(source =>
{
source.Custom()
.ServerFiltering(parameters.ServerFiltering)
.Transport(transport =>
{
transport.Read(read =>
{
read.ContentType(parameters.ContentType).Action(parameters.Action, parameters.Controller, new { parameters.Area });
});
});
});
}
}
}

View file

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.UI.Fluent;
namespace Kreta.Web.Helpers.Unhacked
{
public static class RadioButtonExtensions
{
public static List<RadioButtonBuilder> KendoRadioButtonsFor<TModel, TProperty, T>(this HtmlHelper<TModel> html,
Expression<Func<TModel, TProperty>> expression, List<T> options, Expression<Func<T, object>> idExpression, Expression<Func<T, string>> labelExpression)
{
var idMethod = idExpression.Compile();
var labelMethod = labelExpression.Compile();
var radioButtonBuilders = new List<RadioButtonBuilder>();
foreach (var option in options)
{
radioButtonBuilders.Add(html.Kendo().RadioButtonFor(expression).Label(labelMethod(option)).Value(idMethod(option)));
}
return radioButtonBuilders;
}
}
}

View file

@ -0,0 +1,14 @@
using System.Web;
using System.Web.Mvc;
namespace Kreta.Web.Helpers
{
public static class ValidationExtensions
{
public static HtmlString KretaValidationSummary(this HtmlHelper helper)
{
HtmlString retVal = new HtmlString("<div class=\"validation-summary-valid kreta-validation-summary\" data-valmsg-summary=\"true\" ><ul><li style = \"display:none\" ></li></ul></div>");
return retVal;
}
}
}