public override Control GetFilter(BXCustomField field) { BXTextBoxFilter filter = new BXTextBoxFilter(); filter.Key = field.Name; return filter; }
public void Initialize(BXCustomField currentField, BXCustomProperty currentValue) { field = currentField; value = currentValue; if (currentField == null) return; string fieldName = currentField.EditFormLabel; string errorMessage = currentField.ErrorMessage; if (string.IsNullOrEmpty(errorMessage)) errorMessage = GetMessageFormat("Error.RegexInvalid", fieldName); BXParamsBag<object> settings = new BXParamsBag<object>(currentField.Settings); ValueRequired.Enabled = currentField.Mandatory; if (ValueRequired.Enabled) ValueRequired.ErrorMessage = GetMessageFormat("Error.Required", fieldName); int i = settings.ContainsKey("RowsCount") ? settings.GetInt("RowsCount") : 1; ValueTextBox.TextMode = (i > 1) ? TextBoxMode.MultiLine : TextBoxMode.SingleLine; if (ValueTextBox.TextMode == TextBoxMode.MultiLine) ValueTextBox.Rows = i; ValueTextBox.Columns = settings.ContainsKey("TextBoxSize") ? settings.GetInt("TextBoxSize") : 20; minLength = null; if (settings.ContainsKey("MinLength")) minLength = settings.GetInt("MinLength"); maxLength = null; if (settings.ContainsKey("MaxLength")) maxLength = settings.GetInt("MaxLength"); ValueMinLength.Enabled = minLength.HasValue && minLength > 0; ValueMaxLength.Enabled = maxLength.HasValue && maxLength > 0; minValidationScript = null; maxValidationScript = null; if (ValueMinLength.Enabled) { minValidationScript = string.Format("if(!args.Value||args.Value.length<{0})return;", minLength.Value); ValueMinLength.ErrorMessage = GetMessageFormat("Error.MinLength", fieldName, minLength.Value); } if (ValueMaxLength.Enabled) { maxValidationScript = string.Format("if(args.Value&&args.Value.length>{0})return;", maxLength.Value); ValueMaxLength.ErrorMessage = GetMessageFormat("Error.MaxLength", fieldName, maxLength.Value); } ValueRegex.Enabled = settings.ContainsKey("ValidationRegex") && !String.IsNullOrEmpty((string)settings["ValidationRegex"]); if (ValueRegex.Enabled) { ValueRegex.ValidationExpression = (string)settings["ValidationRegex"]; ValueRegex.ErrorMessage = errorMessage; } if (value != null && value.Value is string) ValueTextBox.Text = value.Value.ToString(); else ValueTextBox.Text = settings.ContainsKey("DefaultValue") ? (string)settings["DefaultValue"] : String.Empty; }
public void Initialize(BXCustomField currentField, BXCustomProperty currentValue) { field = currentField; value = currentValue; if (field == null) return; string fieldName = currentField.EditFormLabel; ValueRequired.Enabled = currentField.Mandatory; if (ValueRequired.Enabled) ValueRequired.ErrorMessage = GetMessageFormat("Error.Required", fieldName); //Инициализируем только текстбокс if (value != null && value.Value != null) { int elId; if (int.TryParse(value.Value.ToString(), out elId) && elId > 0) tbValue.Text = elId.ToString(); } BXParamsBag<object> settings = new BXParamsBag<object>(field.Settings); iblockId = settings.ContainsKey("IBlockId") ? (int)settings["IBlockId"] : 0; }
public override bool TryGetDefaultValue(BXCustomField field, out object value) { if (field != null) { BXCustomFieldEnumCollection values = BXCustomFieldEnum.GetList( new BXFilter( new BXFilterItem(BXCustomFieldEnum.Fields.FieldType, BXSqlFilterOperators.Equal, field.FieldType), new BXFilterItem(BXCustomFieldEnum.Fields.FieldId, BXSqlFilterOperators.Equal, field.Id), new BXFilterItem(BXCustomFieldEnum.Fields.Default, BXSqlFilterOperators.Equal, true) ), null, new BXSelect( BXSelectFieldPreparationMode.Normal, BXCustomFieldEnum.Fields.Id ), null, BXTextEncoder.EmptyTextEncoder ); if (values.Count > 0) { value = field.Multiple ? (object)values.ConvertAll(x => x.Id) : (object)values[0].Id; return true; } } value = 0; return false; }
public void Initialize(BXCustomField currentField,BXCustomProperty value) { field = currentField; this.value = value; if (field == null) return; IBXCalendar cal = Calendar1 as IBXCalendar; valDate.Enabled = currentField.Mandatory; DateTime? dateTime = null; BXParamsBag<object> settings = new BXParamsBag<object>(currentField.Settings); showTime = settings.ContainsKey("showTime") ? (bool)settings["showTime"] : true; if (value == null) { if (cal != null) { if (settings.ContainsKey("default")) dateTime = (DateTime)settings["default"]; if (settings.ContainsKey("current")) dateTime = DateTime.Now; } } else { if (value.Value is DateTime) dateTime = (DateTime)value.Value; } if (dateTime.HasValue) txtDate.Text = showTime ? dateTime.Value.ToString() : dateTime.Value.ToString("d"); }
public void Initialize(BXCustomField currentField, BXCustomProperty currentValue) { field = currentField; value = currentValue; if (field == null) return; string fieldName = currentField.EditFormLabel; BXParamsBag<object> settings = new BXParamsBag<object>(currentField.Settings); ValueRequired.Enabled = currentField.Mandatory; if (ValueRequired.Enabled) ValueRequired.ErrorMessage = GetMessageFormat("FieldMustBeFilled", fieldName); ValueMask.ErrorMessage = GetMessageFormat("ValueMustBeGuid", fieldName); string v = null; if (value != null && value.Values.Count > 0) { object val = value.Value; if (val != null) { if (val is SqlGuid) v = ((SqlGuid)val).Value.ToString(); else if (val is Guid) v = ((Guid)val).ToString(); } } else if (settings.GetBool("GenerateDefault")) v = Guid.NewGuid().ToString(); ValueTextBox.Text = v ?? ""; }
public override Control GetFilter(BXCustomField field) { var filter = new Filter(); filter.Key = "@" + field.OwnerEntityId + ":" + field.Name; filter.IBlockId = field.Settings.GetInt("IBlockId"); return filter; }
public override Control GetFilter(BXCustomField field) { var filter = new BXDropDownFilter(); filter.Key = "@" + field.OwnerEntityId + ":" + field.Name; filter.ValueType = BXAdminFilterValueType.Boolean; filter.Values.Add(new ListItem(GetMessageRaw("Kernel.All"), "")); filter.Values.Add(new ListItem(GetMessageRaw("Kernel.Yes"), "true")); filter.Values.Add(new ListItem(GetMessageRaw("Kernel.No"), "false")); return filter; }
public void Initialize(BXCustomField currentField, BXCustomProperty currentValue) { field = currentField; value = currentValue; if (field == null) return; string fieldName = currentField.EditFormLabel; BXParamsBag<object> settings = new BXParamsBag<object>(currentField.Settings); ValueRequired.Enabled = currentField.Mandatory; if (ValueRequired.Enabled) ValueRequired.ErrorMessage = GetMessageFormat("Error.Required", fieldName); ValueList.Rows = settings.ContainsKey("TextBoxSize") ? (int)settings["TextBoxSize"] : 5; ValueList.SelectionMode = (currentField.Multiple ? ListSelectionMode.Multiple : ListSelectionMode.Single); List<string> selectedValues = new List<string>(); if (value != null) { foreach (object v in value.Values) selectedValues.Add(v.ToString()); } ValueList.Items.Clear(); int iblockId = 0; if (!settings.ContainsKey("IBlockId")) { BXInfoBlockCollectionOld c = BXInfoBlockManagerOld.GetList(null, null); if (c.Count > 0) iblockId = c[0].IBlockId; } else iblockId = (int)settings["IBlockId"]; BXInfoBlockSectionCollectionOld sectionCollection = BXInfoBlockSectionManagerOld.GetTree(iblockId, 0); foreach (BXInfoBlockSectionOld section in sectionCollection) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < section.DepthLevel; i++) sb.Append(" . "); sb.Append(section.Name); ListItem l = new ListItem(sb.ToString(), section.SectionId.ToString()); if (value != null && selectedValues.Contains(section.SectionId.ToString())) l.Selected = true; ValueList.Items.Add(l); } }
public void Initialize(BXCustomField currentField, BXCustomProperty currentValue) { field = currentField; value = currentValue; if (field == null) return; BXParamsBag<object> settings = new BXParamsBag<object>(field.Settings); MultiView1.ActiveViewIndex = settings.ContainsKey("view") ? (int)settings["view"] : 0; //BIND VALUE if (value != null) { if (value.Value != null && value.Value is bool) { bool flag = (bool)value.Value; chValue.Checked = flag; ddValue.SelectedIndex = flag ? 0 : 1; No.Checked = !flag; Yes.Checked = flag; return; //Skip default setup } } //BIND DEFAULT int defVal; if(settings.TryGetInt("default", out defVal)) switch (defVal) { case 0: //True chValue.Checked = true; ddValue.SelectedIndex = 0; Yes.Checked = true; break; case 1: //False chValue.Checked = false; ddValue.SelectedIndex = 1; No.Checked = true; break; } }
public void Initialize(BXCustomField currentField,BXCustomProperty currentValue) { field = currentField; value = currentValue; if (field == null) return; string fieldName = currentField.EditFormLabel; BXParamsBag<object> settings = new BXParamsBag<object>(currentField.Settings); ValueRequired.Enabled = currentField.Mandatory; if (ValueRequired.Enabled) ValueRequired.ErrorMessage = GetMessageFormat("Error.Required", fieldName); ValueTextBox.Columns = settings.ContainsKey("TextBoxSize") ? settings.GetInt("TextBoxSize") : 20; ValueMin.Enabled = ValueMax.Enabled = false; ValueType.ErrorMessage = ValueMax.ErrorMessage = ValueMin.ErrorMessage = GetMessageFormat("Error.DefaultRangeInvalid", fieldName); if (settings.ContainsKey("MinValue")) { double min = Convert.ToDouble(settings["MinValue"]);// is int ? (double)((int)settings["MinValue"]) : (double)settings["MinValue"]; ValueMin.ValueToCompare = min.ToString(); ValueMin.Enabled = true; } if (settings.ContainsKey("MaxValue")) { double max = Convert.ToDouble(settings["MaxValue"]); //is int ? (double)((int)settings["MaxValue"]) : (double)settings["MaxValue"]; ValueMax.ValueToCompare = max.ToString(); ValueMax.Enabled = true; } int precision = settings.ContainsKey("Precision") ? settings.GetInt("Precision") : 4; if (value != null) ValueTextBox.Text = string.Format("{0:F" + precision + "}", value.Value); else ValueTextBox.Text = settings.ContainsKey("DefaultValue") ? settings["DefaultValue"].ToString() : String.Empty; }
public override Control GetFilter(BXCustomField field) { var iblockId = field.Settings.GetInt("IBlockId"); if (iblockId == 0) { var iblocks = BXIBlock.GetList( null, null, new BXSelect(BXIBlock.Fields.ID), new BXQueryParams(new BXPagingOptions(0, 1)) ); if (iblocks.Count > 0) iblockId = iblocks[0].Id; } var sections = BXIBlockSection.GetList( new BXFilter( new BXFilterItem(BXIBlockSection.Fields.ActiveGlobal, BXSqlFilterOperators.Equal, "Y"), new BXFilterItem(BXIBlockSection.Fields.IBlock.ID, BXSqlFilterOperators.Equal, iblockId) ), new BXOrderBy(new BXOrderByPair(BXIBlockSection.Fields.LeftMargin, BXOrderByDirection.Asc)), new BXSelect( BXIBlockSection.Fields.ID, BXIBlockSection.Fields.Name, BXIBlockSection.Fields.DepthLevel ), null, BXTextEncoder.EmptyTextEncoder ); var filter = new BXDropDownFilter(); filter.Key = "@" + field.OwnerEntityId + ":" + field.Name; filter.ValueType = BXAdminFilterValueType.Integer; filter.Values.Add(new ListItem(GetMessageRaw("Kernel.Any"), "")); filter.Values.AddRange(sections.ConvertAll(x => new ListItem(BXStringUtility.Clone(". ", x.DepthLevel) + x.Name, x.Id.ToString())).ToArray()); return filter; }
public void Initialize(BXCustomField currentField, BXCustomProperty currentValue) { field = currentField; value = currentValue; if (field == null) return; string fieldName = currentField.EditFormLabel; BXParamsBag<object> settings = new BXParamsBag<object>(currentField.Settings); ValueRequired.Enabled = currentField.Mandatory; if (ValueRequired.Enabled) ValueRequired.ErrorMessage = GetMessageFormat("Error.Required", fieldName); ValueTextBox.Columns = settings.ContainsKey("TextBoxSize") ? (int)settings["TextBoxSize"] : 20; ValueRange.Enabled = true; ValueRange.MinimumValue = int.MinValue.ToString(); ValueRange.MaximumValue = int.MaxValue.ToString(); ValueRange.ErrorMessage = GetMessageFormat("Error.DefaultRangeInvalid", fieldName); if (settings.ContainsKey("MinValue")) { int min = (int)settings["MinValue"]; ValueRange.MinimumValue = min.ToString(); } if (settings.ContainsKey("MaxValue")) { int max = (int)settings["MaxValue"]; ValueRange.MaximumValue = max.ToString(); } if (value != null) ValueTextBox.Text = string.Format("{0}", value.Value); else ValueTextBox.Text = settings.ContainsKey("DefaultValue") ? settings["DefaultValue"].ToString() : String.Empty; }
protected void mainTabControl_Command(object sender, BXTabControlCommandEventArgs e) { switch (e.CommandName) { case "save": if (TrySave()) { changed = Item; ReturnBack(); } break; case "apply": TrySave(); break; case "cancel": ReturnBack(); break; } }
public void Initialize(BXCustomField currentField) { field = currentField; }
public void Initialize(BXCustomField currentField, BXCustomProperty currentValue) { field = currentField; if (field == null) return; BXParamsBag<object> settings = new BXParamsBag<object>(currentField.Settings); RequiredValidator.Enabled = currentField.Mandatory; if (RequiredValidator.Enabled) RequiredValidator.ErrorMessage = GetMessageFormat("Error.Required", field.EditFormLabel); SizeValidator.Enabled = settings.ContainsKey("MaxSize"); if (SizeValidator.Enabled) { maxSize = (int)settings["MaxSize"]; SizeValidator.ErrorMessage = GetMessageFormat("Error.IllegalSize", field.EditFormLabel, settings["MaxSize"]); } if (settings.ContainsKey("AllowedExtensions")) extensions = settings["AllowedExtensions"] as string[]; ExtensionValidator.Enabled = (extensions != null && extensions.Length > 0); if (ExtensionValidator.Enabled) ExtensionValidator.ErrorMessage = GetMessageFormat("Error.IllegalExtension", field.EditFormLabel, string.Join(", ", extensions)); value = currentValue; RequiredValidator.Enabled = field.Mandatory; if (RequiredValidator.Enabled) RequiredValidator.ErrorMessage = GetMessageFormat("Error.Required", field.EditFormLabel); addDescription = settings.GetBool("AddDescription"); DescriptionBlock.Visible = addDescription; BXFile f = null; if (currentValue != null && (currentValue.Value != null && (int)currentValue.Value != 0) && (f = BXFile.GetById((int)currentValue.Value, BXTextEncoder.EmptyTextEncoder)) != null) { currentFile = originalFile = f; StoredId.Value = "Y"; //DisplayName.Value = f.FileNameOriginal; //DisplaySize.Value = BXStringUtility.BytesToString(f.FileSize); //ContentType.Value = f.ContentType; if (addDescription) Description.Text = f.Description; } }
public override bool TryGetDefaultValue(BXCustomField field, out object value) { int v; if (field != null && field.Settings.TryGetInt("default", out v)) { value = v != 1; return true; } value = false; return false; }
public void Store(BXCustomField field, BXCustomType type) { if (field == null) { State.Value = string.Empty; return; } BXParamsBag<object> state = new BXParamsBag<object>(); state.Add("Settings", field.Settings); state.Add("CustomTypeId", field.CustomTypeId); state.Add("EditInList", field.EditInList); state.Add("FieldName", field.Name); state.Add("IsSearchable", field.IsSearchable); state.Add("Mandatory", field.Mandatory); state.Add("Multiple", field.Multiple); state.Add("ShowInFilter", (int)field.ShowInFilter); state.Add("ShowInList", field.ShowInList); state.Add("Sort", field.Sort); state.Add("XmlId", field.XmlId); foreach (BXCustomFieldLocalization l in field.Localization) { string[] phrases = new string[5]; phrases[0] = l.TextEncoder.Decode(l.EditFormLabel); phrases[1] = l.TextEncoder.Decode(l.ErrorMessage); phrases[2] = l.TextEncoder.Decode(l.HelpMessage); phrases[3] = l.TextEncoder.Decode(l.ListColumnLabel); phrases[4] = l.TextEncoder.Decode(l.ListFilterLabel); state.Add("Loc." + l.LanguageId, phrases); } if (type != null) { IBXCustomTypeAdvancedSetting adv = null; try { adv = type.AdvancedSettings as IBXCustomTypeAdvancedSetting; } catch { } if (adv != null) { adv.Initialize(field); state.Add("Extras", adv.GetSettings()); } } Store(state); }
public override void Init(BXCustomField currentField) { field = currentField; if (field == null) return; BXParamsBag<object> settings = new BXParamsBag<object>(currentField.Settings); defaultValue = settings.GetInt("default", 1) != 1; view = settings.ContainsKey("view") ? (BooleanViewType)settings["view"] : BooleanViewType.Default; }
public void Save() { int fieldsAdded = 0; int[] sort = new int[rows.Count]; for (int i = 0; i < rows.Count; i++) { RowControl r = rows[i]; int sortValue; sort[i] = int.TryParse(r.Sort.Text, out sortValue) ? sortValue : (i + 1) * 10; } int[] index = new int[rows.Count]; for (int i = 0; i < rows.Count; i++) index[i] = i; Array.Sort(index, delegate(int a, int b) { return sort[a] - sort[b]; }); for (int i = 0; i < rows.Count; i++) { RowControl r = rows[index[i]]; BXParamsBag<object> state = r.Restore(); //UPDATE FIELD if (r.CustomField != null) { BXCustomField field = r.CustomField; FillField(field, state); field.Sort = (i + 1) * 10; field.ShowInList = r.Active.Checked; FillLocalization(field, state); BXCustomFieldLocalization l = field.Localization[BXLoc.CurrentLocale]; if (l != null) l.EditFormLabel = r.Name.Text; field.Save(); SaveExtras(state.Get("Extras"), field, r.CustomType); r.Store(); } //CREATE FIELD else if (string.IsNullOrEmpty(r.Code.Text)) { //ERROR } else { string canonical = BXCustomField.CorrectName(r.Code.Text); r.Code.Text = canonical; BXCustomField field = new BXCustomField(); FillField(field, state); field.CustomTypeId = r.Type.SelectedValue; field.ShowInList = r.Active.Checked; field.Multiple = r.Multiple.Checked; field.Name = canonical; field.OwnerEntityId = EntityId; field.Sort = (i + 1) * 10; FillLocalization(field, state); BXCustomFieldLocalization l = field.Localization[BXLoc.CurrentLocale]; if (l != null) l.EditFormLabel = r.Name.Text; field.Save(); fieldsAdded++; r.CustomField = field; r.CustomType = BXCustomTypeManager.GetCustomType(field.CustomTypeId); SaveExtras(state.Get("Extras"), field, r.CustomType); r.Store(field, r.CustomType); //UPDATE CONTROLS r.IdLabel.Text = field.Id.ToString(); r.Edit.CommandArgument = field.Id.ToString(); r.Delete.CommandArgument = field.Id.ToString(); r.Delete.Visible = true; r.CodeLabel.Text = Encode(field.CorrectedName); r.CodeLabel.Visible = true; r.Code.Visible = false; r.MultipleLabel.Text = field.Multiple ? GetMessage("Kernel.Yes") : GetMessage("Kernel.No"); r.MultipleLabel.Visible = true; r.Multiple.Visible = false; r.Type.Visible = false; r.TypeLabel.Visible = true; r.TypeLabel.Text = HttpUtility.HtmlEncode((r.CustomType != null) ? r.CustomType.Title : field.CustomTypeId); } r.Sort.Text = ((i + 1) * 10).ToString(); } HtmlTableRowCollection tableRows = CustomFields.Rows; for (int i = 0; i < rows.Count; i++) tableRows.Remove(rows[i].Row); rows.Sort(delegate(RowControl a, RowControl b) { int i = ((a.CustomField == null) ? 1 : 0) - ((b.CustomField == null) ? 1 : 0); if (i != 0) return i; if (a.CustomField == null) // then b.CustomField == null return 0; return a.CustomField.Sort - b.CustomField.Sort; }); int insertAt = 1; foreach (RowControl r in rows) tableRows.Insert(insertAt++, r.Row); for (int i = 0; i < fieldsAdded; i++) AddField(null, rows.Count + 1 + i); GenerateIds(); }
//METHODS private void AddField(BXCustomField field, int index) { RowControl r = new RowControl(); r.Row = new HtmlTableRow(); r.CustomField = field; HtmlTableCell idCell = new HtmlTableCell(); Label idLb = r.IdLabel = new Label(); idCell.Controls.Add(idLb); HiddenField fieldState = r.State = new HiddenField(); idCell.Controls.Add(fieldState); r.Row.Cells.Add(idCell); //CODE HtmlTableCell codeCell = new HtmlTableCell(); TextBox codeTxt = r.Code = new TextBox(); codeTxt.MaxLength = 20; codeTxt.Columns = 15; codeCell.Controls.Add(codeTxt); Label codeLb = r.CodeLabel = new Label(); codeCell.Controls.Add(codeLb); r.CodeValidator = new CustomValidator(); r.CodeValidator.ValidateEmptyText = true; r.CodeValidator.ValidationGroup = ValidationGroup; r.CodeValidator.ServerValidate += new ServerValidateEventHandler(CodeValidator_ServerValidate); r.CodeValidator.ClientValidationFunction = "customFieldSetUp_validateCode"; r.CodeValidator.Text = "*"; r.CodeValidator.ErrorMessage = GetMessage("Message.CodeRequired"); r.CodeValidator.Display = ValidatorDisplay.Static; codeCell.Controls.Add(r.CodeValidator); r.Row.Cells.Add(codeCell); //NAME HtmlTableCell nameCell = new HtmlTableCell(); nameCell.Width = "100%"; TextBox nameTxt = r.Name = new TextBox(); nameTxt.MaxLength = 50; nameTxt.Width = Unit.Percentage(100); nameCell.Controls.Add(nameTxt); r.NameValidator = new CustomValidator(); r.NameValidator.ValidateEmptyText = true; r.NameValidator.ValidationGroup = ValidationGroup; r.NameValidator.ServerValidate += new ServerValidateEventHandler(NameValidator_ServerValidate); r.NameValidator.ClientValidationFunction = "customFieldSetUp_validateName"; r.NameValidator.Text = "*"; r.NameValidator.ErrorMessage = GetMessage("Message.NameRequired"); r.NameValidator.Display = ValidatorDisplay.Static; nameCell.Controls.Add(r.NameValidator); r.Row.Cells.Add(nameCell); //ACTIVE HtmlTableCell actCell = new HtmlTableCell(); CheckBox actCb = r.Active = new CheckBox(); actCb.Checked = true; actCell.Controls.Add(actCb); r.Row.Cells.Add(actCell); //TYPE HtmlTableCell typeCell = new HtmlTableCell(); DropDownList typeDdl = r.Type = new DropDownList(); typeDdl.DataSource = BXCustomTypeManager.CustomTypes.Values; typeDdl.DataTextField = "Title"; typeDdl.DataValueField = "TypeName"; typeDdl.DataBind(); typeCell.Controls.Add(typeDdl); Label typeLb = r.TypeLabel = new Label(); typeCell.Controls.Add(typeLb); r.Row.Cells.Add(typeCell); //MULTIPLE HtmlTableCell multCell = new HtmlTableCell(); CheckBox multCb = r.Multiple = new CheckBox(); multCell.Controls.Add(multCb); Label multLb = r.MultipleLabel = new Label(); multCell.Controls.Add(multLb); r.Row.Cells.Add(multCell); //SORT HtmlTableCell sortCell = new HtmlTableCell(); TextBox sortTxt = r.Sort = new TextBox(); sortTxt.Text = string.Format("{0}", 10 * index); sortTxt.MaxLength = 10; sortTxt.Columns = 3; sortCell.Controls.Add(sortTxt); r.Row.Cells.Add(sortCell); //EDIT HtmlTableCell editCell = new HtmlTableCell(); editCell.Align = "center"; Button editBtn = r.Edit = new Button(); editBtn.UseSubmitBehavior = false; editBtn.Text = "..."; editBtn.Click += editBtn_Click; editBtn.CausesValidation = false; editCell.Controls.Add(editBtn); r.Row.Cells.Add(editCell); //DELETE HtmlTableCell deleteCell = new HtmlTableCell(); deleteCell.Visible = AllowDelete; deleteCell.Align = "center"; BXIconButton deleteLbn = r.Delete = new BXIconButton(); deleteLbn.OnClientClick = "return confirm('" + GetMessage("ConfirmMessage") + "');"; deleteLbn.CssClass = "delete"; deleteLbn.CausesValidation = false; deleteLbn.Visible = false; deleteLbn.Click += deleteLbn_Click; deleteCell.Controls.Add(deleteLbn); r.Row.Cells.Add(deleteCell); if (field != null) { nameTxt.Text = field.TextEncoder.Decode(field.EditFormLabel); actCb.Checked = field.ShowInList; multCb.Checked = field.Multiple; multCb.Enabled = false; idLb.Text = field.Id.ToString(); typeDdl.SelectedValue = field.CustomTypeId; deleteLbn.Visible = true; deleteLbn.CommandArgument = field.Id.ToString(); editBtn.CommandArgument = field.Id.ToString(); codeLb.Text = HttpUtility.HtmlEncode(field.CorrectedName); codeTxt.Visible = false; r.CodeValidator.Enabled = false; multLb.Text = field.Multiple ? GetMessage("Kernel.Yes") : GetMessage("Kernel.No"); multCb.Visible = false; typeDdl.Visible = false; r.CustomType = BXCustomTypeManager.GetCustomType(field.CustomTypeId); if (r.Type != null) typeLb.Text = HttpUtility.HtmlEncode(r.CustomType.Title); else typeLb.Text = HttpUtility.HtmlEncode(field.CustomTypeId); } else typeDdl.SelectedValue = "Bitrix.System.Text"; CustomFields.Rows.Add(r.Row); rows.Add(r); rowsForButton.Add(r.Edit, r); rowsForCode.Add(r.CodeValidator, r); rowsForName.Add(r.NameValidator, r); r.Store(); }
public override void Init(BXCustomField currentField) { field = currentField; if (field == null) return; BXParamsBag<object> settings = new BXParamsBag<object>(currentField.Settings); required = field.Mandatory; multiple = field.Multiple; iblockId = settings.ContainsKey("IBlockId") ? (int)settings["IBlockId"] : 0; textBoxSize = settings.ContainsKey("TextBoxSize") ? (int)settings["TextBoxSize"] : 5; BXIBlockSectionCollection sections = BXIBlockSection.GetList( new BXFilter( new BXFilterItem(BXIBlockSection.Fields.ActiveGlobal, BXSqlFilterOperators.Equal, "Y"), new BXFilterItem(BXIBlockSection.Fields.IBlock.ID, BXSqlFilterOperators.Equal, iblockId) ), new BXOrderBy( new BXOrderByPair(BXIBlockSection.Fields.LeftMargin, BXOrderByDirection.Asc) ), new BXSelect( BXIBlockSection.Fields.ID, BXIBlockSection.Fields.Name, BXIBlockSection.Fields.DepthLevel ), null, BXTextEncoder.HtmlTextEncoder ); int currentIndex = 0; int previousDepthLevel = 1; foreach (BXIBlockSection section in sections) { if (currentIndex > 0) ((SectionTreeItem)sectionTree[currentIndex - 1]).HasChildren = section.DepthLevel > previousDepthLevel; previousDepthLevel = section.DepthLevel; SectionTreeItem treeItem = new SectionTreeItem(); treeItem.Id = section.Id; treeItem.DepthLevel = section.DepthLevel; treeItem.Name = section.Name; sectionTree.Insert(currentIndex++, section.Id, treeItem); } }
public override void Init(BXCustomField field) { this.field = field; maxSize = field.Settings.GetInt("MaxSize"); IEnumerable<string> ae = field.Settings.Get<IEnumerable<string>>("AllowedExtensions"); allowedExtensions = ae != null ? new List<string>(ae) : new List<string>(); for (int i = 0; i < allowedExtensions.Count; i++) allowedExtensions[i] = allowedExtensions[i].Trim().ToLowerInvariant(); textboxSize = field.Settings.GetInt("TextBoxSize"); editor = field.Multiple ? (FieldEditor)new MultipleFieldEditor(this) : (FieldEditor)new SingleFieldEditor(this); }
public override Control GetFilter(BXCustomField field) { return null; }
public void Initialize(BXCustomField currentField, BXCustomProperty currentValue) { field = currentField; value = currentValue; if (field == null) return; settings = new BXParamsBag<object>(field.Settings); viewMode = settings.ContainsKey("ViewMode") && (string)settings["ViewMode"] == "list" ? ViewMode.List : ViewMode.Flag; valDDList.Enabled = false; valList.Enabled = false; valFlag.Enabled = false; valCheckbox.Enabled = false; ListControl list; int listCount = Math.Max(settings.GetInt("ListSize", 5), 1); if (viewMode == ViewMode.List) { if (field.Multiple) { View.ActiveViewIndex = 0; list = List; validator = valList; List.Rows = Math.Min(listCount, Enums.Count + (!field.Multiple && !field.Mandatory ? 1 : 0)); } else { View.ActiveViewIndex = 3; list = DDList; validator = valDDList; } } else { if (field.Multiple) { View.ActiveViewIndex = 2; list = ChBox; validator = valCheckbox; } else { View.ActiveViewIndex = 1; list = Flag; validator = valFlag; } } ListItem none = null; if (!field.Multiple && !field.Mandatory) { none = new ListItem(GetMessage("Option.NotSelected"), ""); none.Selected = true; list.Items.Add(none); } validator.Enabled = field.Mandatory; validator.ValidationGroup = ValidationGroup; foreach (BXCustomFieldEnum e in Enums) list.Items.Add(new ListItem(e.Value, e.Id.ToString())); if (value != null) { bool stop = false; foreach (ListItem item in list.Items) { foreach (int val in value.Values) if (item.Value == val.ToString()) { if (!field.Multiple) { if (none != null) none.Selected = false; stop = true; } item.Selected = true; break; } if (stop) break; } } else //BIND DEFAULT { bool stop = false; foreach (ListItem item in list.Items) { foreach (BXCustomFieldEnum val in Enums) if (item.Value == val.Id.ToString() && val.Default) { if (!field.Multiple) { if (none != null) none.Selected = false; stop = true; } item.Selected = true; break; } if (stop) break; } } }
public override void Init(BXCustomField currentField) { field = currentField; if (field == null) return; BXParamsBag<object> settings = new BXParamsBag<object>(currentField.Settings); required = field.Mandatory; iblockId = settings.ContainsKey("IBlockId") ? (int)settings["IBlockId"] : 0; }
public void FillLocalization(BXCustomField field, BXParamsBag<object> state) { foreach (string lang in BXLoc.Locales) { string key = "Loc." + lang; BXCustomFieldLocalization l = field.Localization[lang]; if (l == null) { l = new BXCustomFieldLocalization(); field.Localization[lang] = l; } if (!state.ContainsKey(key)) continue; string[] phrases = state.Get<string[]>(key); l.EditFormLabel = phrases[0]; l.ErrorMessage = phrases[1]; l.HelpMessage = phrases[2]; l.ListColumnLabel = phrases[3]; l.ListFilterLabel = phrases[4]; } }
private void SaveExtras(object state, BXCustomField field, BXCustomType t) { if (state != null && t != null) { IBXCustomTypeAdvancedSetting extras = null; try { extras = t.AdvancedSettings as IBXCustomTypeAdvancedSetting; } catch { } if (extras != null) { extras.Initialize(field); extras.SetSettings(state); extras.Save(); } } }
public void FillField(BXCustomField field, BXParamsBag<object> state) { field.ShowInList = state.Get("ShowInList", true); field.Sort = state.Get("Sort", 10); field.Settings.Assign(state.Get<BXParamsBag<object>>("Settings")); field.EditInList = state.Get("EditInList", true); field.IsSearchable = state.Get("IsSearchable", false); field.Mandatory = state.Get("Mandatory", false); field.ShowInFilter = (BXCustomFieldFilterVisibility)state.Get("ShowInFilter", (int)BXCustomFieldFilterVisibility.CompleteMatch); field.XmlId = state.Get("XmlId", string.Empty); }
public void Initialize(BXCustomField currentField, BXCustomProperty currentValue) { field = currentField; value = currentValue; if (field == null) return; settings = new BXParamsBag<object>(field.Settings); viewMode = settings.ContainsKey("ViewMode") && (string)settings["ViewMode"] == "list" ? ViewMode.List : ViewMode.Flag; BXCustomFieldEnumCollection values = BXCustomFieldEnum.GetList(field.Id, field.FieldType, BXTextEncoder.HtmlTextEncoder); valList.Enabled = false; valFlag.Enabled = false; valCheckbox.Enabled = false; if (viewMode == ViewMode.List) { View.ActiveViewIndex = 0; int listSize = settings.ContainsKey("ListSize") ? (int)settings["ListSize"] : 5; listSize = (listSize > values.Count) ? values.Count : listSize; if (listSize > 0) { List.Rows = listSize; List.DataSource = values.ConvertAll<ListItem>(delegate(BXCustomFieldEnum input) { return new ListItem(input.Value, input.TextEncoder.Decode(input.Value)); }); List.SelectionMode = field.Multiple ? ListSelectionMode.Multiple : ListSelectionMode.Single; List.DataBind(); valList.ValidationGroup = ValidationGroup; valList.Enabled = field.Mandatory; } else List.Visible = false; } else { if (field.Multiple) { View.ActiveViewIndex = 2; ChBox.DataSource = values.ConvertAll<ListItem>(delegate(BXCustomFieldEnum input) { return new ListItem(input.Value, input.TextEncoder.Decode(input.Value)); }); ChBox.DataBind(); valCheckbox.Enabled = field.Mandatory; valCheckbox.ValidationGroup = ValidationGroup; } else { View.ActiveViewIndex = 1; Flag.DataSource = values.ConvertAll<ListItem>(delegate(BXCustomFieldEnum input) { return new ListItem(input.Value, input.TextEncoder.Decode(input.Value)); }); Flag.DataBind(); valFlag.ValidationGroup = ValidationGroup; valFlag.Enabled = field.Mandatory; } } if (value != null) { ListControl listControl = viewMode == ViewMode.List ? (ListControl)List : field.Multiple ? (ListControl)ChBox : (ListControl)Flag; ListItemCollection items = listControl.Items; bool stop = false; foreach (ListItem item in items) { string itemValue = BXTextEncoder.HtmlTextEncoder.Decode(item.Value); foreach (string val in value.Values) if (itemValue.Equals(val, StringComparison.InvariantCulture)) { item.Selected = true; if (!field.Multiple) { stop = true; break; } } if (stop) break; } } else //BIND DEFAULT foreach (BXCustomFieldEnum item in values) { if (item.Default) { if (viewMode == ViewMode.List) List.SelectedValue = item.Value; else if (field.Multiple) ChBox.SelectedValue = item.Value; else Flag.SelectedValue = item.Value; continue; } } }