/// <summary> /// Fieldses for edit field context. /// </summary> /// <param name="editFieldContext"> /// The edit field context. /// </param> /// <returns> /// The <see cref="List"/>. /// </returns> public virtual List <UPMField> FieldsForEditFieldContext(UPEditFieldContext editFieldContext) { if (editFieldContext == null) { return(null); } if (editFieldContext.ReadOnly) { var field = editFieldContext.Field; return(field != null ? new List <UPMField> { editFieldContext.Field } : null); } var fieldArray = new List <UPMField>(); var editFields = editFieldContext.EditFields; if (editFields != null) { foreach (var editField in editFields) { editField.EditFieldsContext = this.EditPageContext; fieldArray.Add(editField); } } return(fieldArray); }
private void FillUploadRequestsForRecord(UPCRMRecord record) { this.uploadDocumentRequests = new List <UPOfflineUploadDocumentRequest>(); foreach (UPPageModelController modelController in this.PageModelControllers) { if (modelController is EditPageModelController) { ObjectivesEditPageModelController editModelController = (ObjectivesEditPageModelController)modelController; UPMObjectivesPage editPage = (UPMObjectivesPage)editModelController.Page; foreach (UPMGroup editGroup in editPage.Groups) { foreach (UPMObjective objective in editGroup.Children) { foreach (UPMEditField editField in objective.Fields) { if (editField is UPMImageEditField && editField.Changed) { UPMImageEditField imageEditField = (UPMImageEditField)editField; UPEditFieldContext fieldContext = editModelController.FieldContextForEditField(imageEditField); //this.uploadDocumentRequest = new UPOfflineUploadDocumentRequest(UIImageJPEGRepresentation(imageEditField.Image, 1.0), -1, "photo.jpg", "image/jpeg", record.RecordIdentification, fieldContext.FieldId, "true"); // CRM-5007 this.uploadDocumentRequests.Add(this.uploadDocumentRequest); } } } } } } }
private void HandleDependentFieldsSectionCounterItemCounter(Dictionary <string, UPEditFieldContext> editFields, int sectionCounter, int itemCounter) { List <UPEditFieldContext> parentFieldContextArray = new List <UPEditFieldContext>(); foreach (UPEditFieldContext fieldContext in editFields.Values) { UPCRMField parentField = fieldContext.ParentField; if (parentField != null) { UPEditFieldContext parentFieldContext = this.editPageContext.EditFields.ValueOrDefault(this.FieldIdentificationSectionCounterItemCounter(parentField, sectionCounter, itemCounter)); if (parentFieldContext != null) { parentFieldContext.AddDependentFieldContext(fieldContext); if (parentFieldContextArray.Contains(parentFieldContext) == false) { parentFieldContextArray.Add(parentFieldContext); } } } } foreach (UPEditFieldContext parentFieldContext in parentFieldContextArray) { parentFieldContext.NotifyDependentFields(); } }
/// <summary> /// Fieldses for edit field context. /// </summary> /// <param name="editFieldContext">The edit field context.</param> /// <returns> /// The <see cref="List" />. /// </returns> public override List <UPMField> FieldsForEditFieldContext(UPEditFieldContext editFieldContext) { List <UPMField> editFieldArray = base.FieldsForEditFieldContext(editFieldContext); if (editFieldArray != null) { foreach (UPMEditField editField in editFieldArray) { editField.EditFieldDelegate = this; editField.ContinuousUpdate = true; if (!string.IsNullOrEmpty(editFieldContext.FieldFunction)) { this.editFieldDictionary[editFieldContext.FieldFunction] = editFieldContext; if (editField.RequiredField) { if (!editFieldContext.FieldConfig.IsEmptyValue(string.Empty)) { this.mustFieldDictionary[editFieldContext.FieldFunction] = "0"; } else { this.mustFieldDictionary[editFieldContext.FieldFunction] = string.Empty; } } } if (editField is UPMCatalogEditField) { ((UPMCatalogEditField)editField).CatalogElementViewType = CatalogElementViewType.PopOver; } } } return(editFieldArray); }
/// <summary> /// Groups from row. /// </summary> /// <param name="resultRow">The result row.</param> /// <returns> /// The <see cref="UPMGroup" />. /// </returns> public override UPMGroup GroupFromRow(UPCRMResultRow resultRow) { UPMGroup group = base.GroupFromRow(resultRow); this.skipTemplateFilter = false; if (group != null) { if (this.emptyMustFieldCount < 0) { this.emptyMustFieldCount = 0; List <string> mustFieldFunctionNames = this.mustFieldDictionary.Keys.ToList(); foreach (string functionName in mustFieldFunctionNames) { UPEditFieldContext ctx = this.editFieldDictionary[functionName]; if (ctx.FieldConfig.IsEmptyValue(ctx.Value)) { this.emptyMustFieldCount++; this.mustFieldDictionary[functionName] = string.Empty; } else if (string.IsNullOrEmpty(ctx.Value)) { this.mustFieldDictionary[functionName] = "0"; } else { this.mustFieldDictionary[functionName] = ctx.Value; } } } this.Delegate.GroupModelControllerValueChanged(this, this.CurrentData); } return(group); }
/// <summary> /// Initializes a new instance of the <see cref="UPEditConstraintViolation"/> class. /// </summary> /// <param name="context"> /// The context. /// </param> /// <param name="violationType"> /// Type of the violation. /// </param> /// <param name="violationKey"> /// The violation key. /// </param> public UPEditConstraintViolation( UPEditFieldContext context, EditConstraintViolationType violationType, string violationKey) { this.EditFieldContext = context; this.ViolationType = violationType; this.ViolationKey = violationKey; }
/// <summary> /// Applies the context. /// </summary> /// <param name="contextDictionary">The context dictionary.</param> /// <returns></returns> public override UPMGroup ApplyContext(Dictionary <string, object> contextDictionary) { UPMGroup returnGroup; base.ApplyContext(contextDictionary); if (!this.skipTemplateFilter) { string templateFilterName = this.FormItem.ViewReference.ContextValueForKey("Func1"); Dictionary <string, object> initialValues = null; if (!string.IsNullOrEmpty(templateFilterName)) { UPConfigFilter templateFilter = ConfigurationUnitStore.DefaultStore.FilterByName(templateFilterName); if (templateFilter != null) { Dictionary <string, object> dict = contextDictionary["$_copyFields"] as Dictionary <string, object>; templateFilter = templateFilter.FilterByApplyingValueDictionaryDefaults(dict, true); initialValues = templateFilter.FieldsWithValues(true, true); } } this.EditPageContext = new UPEditPageContext(this.FieldControl.InfoAreaId, true, initialValues, null, null); returnGroup = this.ApplyResultRow(null); this.skipTemplateFilter = true; } else { returnGroup = this.Group; } if (this.dependentFieldDictionary != null) { foreach (string dependentKey in this.dependentFieldDictionary.Keys) { if (contextDictionary.Keys.Contains(dependentKey)) { string depVal = contextDictionary[dependentKey] as string; if (!string.IsNullOrEmpty(depVal)) { UPEditFieldContext editFieldContext = this.editFieldDictionary[this.dependentFieldDictionary[dependentKey]]; if (editFieldContext != null) { editFieldContext.Value = depVal; if (editFieldContext.EditField != null) { this.SimpleChangedValue(editFieldContext.EditField); } } } } } } return(returnGroup); }
private void UpdateChildEditContext(UPChildEditContext childEditContext, Dictionary <string, object> _initialValues) { foreach (string fieldKey in _initialValues.Keys) { UPEditFieldContext editFieldContext = childEditContext.EditFieldContext[fieldKey]; if (editFieldContext != null) { editFieldContext.SetValue(_initialValues[fieldKey] as string); editFieldContext.ChildEditContext = childEditContext; } } }
private void UserDidChangeCatalogField(UPMCatalogEditField editField) { UPEditPageContext fieldEditPageContext = (UPEditPageContext)editField.EditFieldsContext; UPEditFieldContext context = fieldEditPageContext.ContextForEditField(editField); if (context.HasDependentFields) { context.NotifyDependentFields(); this.SimpleChangedValue(editField); this.Delegate.ForceRedraw(this); } else { this.SimpleChangedValue(editField); } }
private bool NeedsSignalValueChange(UPMEditField editField) { if (editField.RequiredField) { if (this.currentField != editField) { foreach (UPEditFieldContext ctx in this.editFieldDictionary.Values) { if (ctx.EditField == editField) { this.currentContext = ctx; break; } } this.currentField = editField; } if (this.currentContext != null) { string val = this.currentContext.Value; string storedVal = this.mustFieldDictionary[this.currentContext.FieldFunction]; if (!string.IsNullOrEmpty(val) && string.IsNullOrEmpty(storedVal)) { this.mustFieldDictionary[this.currentContext.FieldFunction] = val; return(--this.emptyMustFieldCount == 0); } if (string.IsNullOrEmpty(val) && !string.IsNullOrEmpty(storedVal)) { this.mustFieldDictionary[this.currentContext.FieldFunction] = string.Empty; return(++this.emptyMustFieldCount == 1); } if (!string.IsNullOrEmpty(val)) { this.mustFieldDictionary[this.currentContext.FieldFunction] = val; } return(this.emptyMustFieldCount <= 0 && this.SignalEveryChange); } } return(this.SignalEveryChange); }
/// <summary> /// Initializes a new instance of the <see cref="UPInBoxPageModelController"/> class. /// </summary> /// <param name="viewReference">The view reference.</param> public UPInBoxPageModelController(ViewReference viewReference) : base(viewReference) { UPMInBoxPage page = new UPMInBoxPage(StringIdentifier.IdentifierWithStringId("Inbox")) { Invalid = true, SkipUploadIfPossible = viewReference.ContextValueIsSet("SkipUploadPageIfPossible") }; this.removeUploadedFileFromInbox = viewReference.ContextValueIsSet("RemoveUploadedFile"); this.TopLevelElement = page; this.editFieldContexts = new Dictionary <StringIdentifier, UPEditFieldContext>(); IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; FieldControl editFieldControl = configStore.FieldControlByNameFromGroup("Edit", viewReference.ContextValueForKey("UploadFields")); UPMGroup uploadFieldGroup = new UPMGroup(StringIdentifier.IdentifierWithStringId("uploadFieldGroup")); if (editFieldControl != null) { int numberOfFields = editFieldControl.NumberOfFields; for (int index = 0; index < numberOfFields; index++) { UPConfigFieldControlField field = editFieldControl.FieldAtIndex(index); StringIdentifier fieldIdentifier = StringIdentifier.IdentifierWithStringId($"Field {field.FieldId} {field.InfoAreaId}"); UPEditFieldContext initialValueEditField = UPEditFieldContext.FieldContextFor(field, fieldIdentifier, null, (List <UPEditFieldContext>)null); this.editFieldContexts[fieldIdentifier] = initialValueEditField; if (field.Function == "Filename") { page.FileNameEditField = initialValueEditField.EditField; } uploadFieldGroup.AddField(initialValueEditField.EditField); } } this.recordIdentification = this.ViewReference.ContextValueForKey("RecordId"); page.UploadFieldGroup = uploadFieldGroup; // load directly this.UpdatedElement(page); }
/// <summary> /// Applies the result row. /// </summary> /// <param name="row">The row.</param> /// <returns></returns> public override UPMGroup ApplyResultRow(UPCRMResultRow row) { IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore; UPMStandardGroup detailGroup = null; int fieldCount = this.LayoutTab.FieldCount; List <UPEditFieldContext> editFieldContextArray = new List <UPEditFieldContext>(fieldCount); for (int j = 0; j < fieldCount; j++) { WebConfigLayoutField fieldDef = this.LayoutTab.FieldAtIndex(j); IIdentifier fieldIdentifier = StringIdentifier.IdentifierWithStringId(fieldDef.ValueName); string fieldValue = configStore.ConfigValue(fieldDef.ValueName); UPEditFieldContext editFieldContext = UPEditFieldContext.FieldContextForWebConfigParameterFieldIdentifierValue(fieldDef, fieldIdentifier, fieldValue); if (editFieldContext == null) { continue; } editFieldContextArray.Add(editFieldContext); if (detailGroup == null) { detailGroup = new UPMStandardGroup(StringIdentifier.IdentifierWithStringId($"{this.Layout.UnitName}_{this.TabIndex}")); detailGroup.LabelText = this.TabLabel; } foreach (UPMEditField editField in editFieldContext.EditFields) { detailGroup.AddField(editField); } } this.EditFieldContexts = editFieldContextArray; this.Group = detailGroup; this.ControllerState = (detailGroup == null) ? GroupModelControllerState.Empty : GroupModelControllerState.Finished; return(detailGroup); }
private UPMStandardGroup CreateNewGroupRecordAsNew(Dictionary <string, object> parentInitialValues, UPCRMRecord record, bool asNew) { UPContainerMetaInfo metaInfo = new UPContainerMetaInfo(this.ChildFieldControl); UPCRMResult result = !string.IsNullOrEmpty(record?.RecordId) ? metaInfo.NewRecordWithRecordId(record.RecordId) : metaInfo.NewRecord(); UPCRMResultRow childRow = (UPCRMResultRow)result.ResultRowAtIndex(0); UPChildEditContext childEditContext = new UPChildEditContext(childRow, this.NextPostfix); if (asNew) { childEditContext.SetAsNew(); } if (record != null) { childEditContext.AddChangedLinksFromRecordParentLink(record, null); } FieldControlTab childFieldControlTab = this.ChildFieldControl.TabAtIndex(0); this.combinedInitialValues = null; if (this.initialValues != null) { if (parentInitialValues != null) { Dictionary <string, object> combined = new Dictionary <string, object>(this.initialValues); foreach (var item in parentInitialValues) { combined[item.Key] = item.Value; } this.combinedInitialValues = combined; } else { this.combinedInitialValues = this.initialValues; } } else { this.combinedInitialValues = parentInitialValues; } List <UPCRMRecord> initialRecords = record != null ? new List <UPCRMRecord> { record } : null; List <object> editFieldContextArray = this.EditContextsFor(childRow, childFieldControlTab, childEditContext.EditFieldContext, this.combinedInitialValues, initialRecords); int editFieldCount = editFieldContextArray.Count; if (editFieldCount > 0) { UPMStandardGroup group = new UPMStandardGroup(new RecordIdentifier(childRow.RootRecordIdentification)); group.Deletable = true; childEditContext.Group = group; this.AddChildRecordContext(childEditContext); for (int j = 0; j < editFieldCount; j++) { UPEditFieldContext editFieldContext = editFieldContextArray[j] as UPEditFieldContext; if (editFieldContext != null) { editFieldContext.ChildEditContext = childEditContext; editFieldContext.FieldLabelPostfix = childEditContext.FieldLabelPostfix; List <UPMEditField> editFields = editFieldContext.EditFields; if (editFields.Count > 0) { foreach (UPMEditField editField in editFields) { editField.EditFieldsContext = childEditContext; group.AddField(editField); } } else { UPMField field = editFieldContext.Field; if (field != null) { group.AddField(field); } } } else { group.AddField((UPMField)editFieldContextArray[j]); } } childEditContext.HandleDependentFields(); return(group); } return(null); }
/// <summary> /// Changeds the records for context new record link user changes only. /// </summary> /// <param name="childEditContext">The child edit context.</param> /// <param name="newRecord">if set to <c>true</c> [new record].</param> /// <param name="link">The link.</param> /// <param name="userChangesOnly">if set to <c>true</c> [user changes only].</param> /// <returns></returns> public List <UPCRMRecord> ChangedRecordsForContextNewRecordLinkUserChangesOnly(UPChildEditContext childEditContext, bool newRecord, UPCRMLink link, bool userChangesOnly) { if (childEditContext.DeleteRecord) { if (newRecord) { return(null); } UPCRMRecord record = new UPCRMRecord(childEditContext.RecordIdentification); record.Deleted = true; return(new List <UPCRMRecord> { record }); } Dictionary <string, UPEditFieldContext> changedFields = null; if (newRecord && !userChangesOnly) { if (this.combinedInitialValues != null) { foreach (string fieldIdentification in this.combinedInitialValues.Keys) { int fieldId = fieldIdentification.FieldIdFromStringWithInfoAreaId(this.ChildInfoAreaId); if (fieldId >= 0) { UPEditFieldContext initialValueEditField = new UPEditFieldContext(fieldId, this.combinedInitialValues[fieldIdentification] as string); if (changedFields == null) { changedFields = new Dictionary <string, UPEditFieldContext> { { initialValueEditField.Key, initialValueEditField } }; } else { changedFields.SetObjectForKey(initialValueEditField, initialValueEditField.Key); } } } } } foreach (UPEditFieldContext editFieldContext in childEditContext.EditFieldContext.Values) { if (editFieldContext.WasChanged(userChangesOnly)) { if (changedFields != null) { changedFields.SetObjectForKey(editFieldContext, editFieldContext.Key); } else { changedFields = new Dictionary <string, UPEditFieldContext> { { editFieldContext.Key, editFieldContext } }; } } } List <UPCRMRecord> additionalRecords = null; ICollection <UPCRMLink> changedLinks = (ICollection <UPCRMLink>)childEditContext.ChangedLinkArray ?? new List <UPCRMLink>(); if (changedFields?.Count > 0 || changedLinks?.Count > 0) { UPCRMRecord record; if (newRecord) { record = childEditContext.RecordIdentification.RecordId().Length > 6 ? new UPCRMRecord(childEditContext.RecordIdentification) : UPCRMRecord.CreateNew(childEditContext.RecordIdentification.InfoAreaId()); record.AddLink(link); UPConfigFilter createFilter = ConfigurationUnitStore.DefaultStore.FilterByName($"{record.InfoAreaId}.ChildCreateTemplate"); createFilter = createFilter.FilterByApplyingDefaultReplacements(); additionalRecords = record.ApplyValuesFromTemplateFilter(createFilter, false); } else { record = new UPCRMRecord(childEditContext.RecordIdentification); } foreach (UPEditFieldContext changedField in changedFields.Values) { if (newRecord) { record.NewValueFieldId(changedField.Value, changedField.FieldId); } else { record.NewValueFromValueFieldId(changedField.Value, changedField.OriginalValue, changedField.FieldId); } } foreach (UPCRMLink changedLink in changedLinks) { record.AddLink(changedLink); } if (additionalRecords?.Count > 0) { List <UPCRMRecord> arr = new List <UPCRMRecord> { record }; arr.AddRange(additionalRecords); return(arr); } return(new List <UPCRMRecord> { record }); } return(null); }
private void FillPage() { UPMCharacteristicsPage newPage = (UPMCharacteristicsPage)this.InstantiatePage(); newPage.IsReadOnly = this.IsReadOnly; foreach (UPCharacteristicsGroup crmGroup in this.Characteristics.Groups) { UPMCharacteristicsItemGroup group = new UPMCharacteristicsItemGroup(StringIdentifier.IdentifierWithStringId(crmGroup.CatalogValue)) { GroupNameField = new UPMStringField(StringIdentifier.IdentifierWithStringId(crmGroup.Label)) { StringValue = crmGroup.Label }, ShowExpanded = crmGroup.ShowExpanded, GroupType = crmGroup.SingleSelection ? UPMCharacteristicsItemGroupType.SingleSelect : UPMCharacteristicsItemGroupType.MultiSelect }; foreach (UPCharacteristicsItem crmItem in crmGroup.Items) { UPMCharacteristicsItem item = new UPMCharacteristicsItem(StringIdentifier.IdentifierWithStringId(crmItem.CatalogValue)) { ItemNameField = new UPMStringField(StringIdentifier.IdentifierWithStringId(crmItem.Label)) { StringValue = crmItem.Label }, SelectedField = new UPMBooleanEditField(StringIdentifier.IdentifierWithStringId(crmItem.Label)) { BoolValue = crmItem.Record != null } }; group.AddChild(item); List <UPMField> additionalEditFields = new List <UPMField>(); if (crmItem.ShowAdditionalFields) { for (int additionalFieldIndex = 0; additionalFieldIndex < crmItem.AdditionalFields.Count; additionalFieldIndex++) { UPConfigFieldControlField configField = crmItem.AdditionalFields[additionalFieldIndex]; FieldIdentifier fieldIdentifier = FieldIdentifier.IdentifierWithRecordIdentificationFieldId(this.CharacteristicsRootRecordIdentification, configField.Identification); UPEditFieldContext fieldContext = UPEditFieldContext.FieldContextFor(configField, fieldIdentifier, crmItem.Values[additionalFieldIndex], (List <UPEditFieldContext>)null); if (fieldContext != null) { additionalEditFields.Add(fieldContext.EditField); this.editPageContext.EditFields.SetObjectForKey(fieldContext, $"{configField.Identification}-{crmItem.CatalogValue}-{crmGroup.CatalogValue}"); } } } item.EditFields = additionalEditFields; } if (group.Children.Count > 0) { newPage.AddChild(group); } } if (this.IsReadOnly) { newPage = this.PageForOverview(newPage); } ITopLevelElement oldPage = this.TopLevelElement; this.TopLevelElement = newPage; newPage.Invalid = false; this.InformAboutDidChangeTopLevelElement(oldPage, newPage, null, null); }
private void LoadData(UPMObjectivesPage objectivesPage) { int itemCounter = 0; int sectionCounter = 0; foreach (UPObjectivesGroup group in this.objectivesGroupArray) { UPMObjectivesSection section = this.CreateSectionIdentfier(group.Label, StringIdentifier.IdentifierWithStringId(group.GroupKey)); foreach (UPObjectivesItem item in group.Items) { UPMObjective mobjective = this.CreateObjectiveIdentfier(item, StringIdentifier.IdentifierWithStringId($"ObjectiveItem_{itemCounter}")); if (item.Documents != null) { UPMDocumentsGroup documentGroup = new UPMDocumentsGroup(StringIdentifier.IdentifierWithStringId($"documentgroup{itemCounter}")); foreach (DocumentData document in item.Documents) { UPMDocument documentModel = new UPMDocument(document); documentGroup.AddChild(documentModel); } mobjective.AddGroup(documentGroup); } mobjective.ObjectiveItem = item; Dictionary <string, UPEditFieldContext> itemEditFields = new Dictionary <string, UPEditFieldContext>(); for (int additionalFieldIndex = 0; additionalFieldIndex < item.AdditionalFields.Count; additionalFieldIndex++) { UPConfigFieldControlField field = item.AdditionalFields[additionalFieldIndex]; RecordIdentifier fieldIdentifier = new RecordIdentifier(field.Identification); UPEditFieldContext fieldContext = null; FieldAttributes attributes = field.Attributes; if (attributes != null && attributes.Hide) { fieldContext = UPEditFieldContext.HiddenFieldFor(field, fieldIdentifier, item.Values[additionalFieldIndex]); } else if (attributes != null && attributes.ReadOnly) { fieldContext = UPEditFieldContext.ReadonlyFieldFor(field, fieldIdentifier, item.Values[additionalFieldIndex]); } else { fieldContext = UPEditFieldContext.FieldContextFor(field, fieldIdentifier, item.Values[additionalFieldIndex], (List <UPEditFieldContext>)null); } if (fieldContext?.Field != null) { string fieldIdentification = this.FieldIdentificationSectionCounterItemCounter(field.Field, sectionCounter, itemCounter); this.editPageContext.EditFields.SetObjectForKey(fieldContext, fieldIdentification); itemEditFields.SetObjectForKey(fieldContext, fieldIdentification); if (fieldContext.EditField != null) { fieldContext.EditField.EditFieldsContext = this.editPageContext; mobjective.AddField(fieldContext.EditField); } else { mobjective.AddField(fieldContext.Field); } } } this.HandleDependentFieldsSectionCounterItemCounter(itemEditFields, sectionCounter, itemCounter); if (item.ButtonActions.Count > 0) { List <UPMOrganizerAction> buttonActions = new List <UPMOrganizerAction>(); foreach (UPConfigButton button in item.ButtonActions) { StringIdentifier fieldIdentifier = StringIdentifier.IdentifierWithStringId("button"); UPMOrganizerAction action = new UPMOrganizerAction(fieldIdentifier); //action.SetTargetAction(this.ParentOrganizerModelController, PerformObjectivesAction); action.ViewReference = button.ViewReference.ViewReferenceWith(item.Record.RecordIdentification); action.LabelText = button.Label; buttonActions.Add(action); } mobjective.Actions = buttonActions; } section.AddChild(mobjective); itemCounter++; } if (section.Children.Count > 0) { objectivesPage.AddChild(section); } } if (objectivesPage.Children.Count == 0) { UPMMessageStatus messageStatus = new UPMMessageStatus(StringIdentifier.IdentifierWithStringId("messageIdentifier")); UPMStringField messageField = new UPMStringField(StringIdentifier.IdentifierWithStringId("statusFieldIdentifier")); messageField.FieldValue = LocalizedString.Localize(LocalizationKeys.TextGroupBasic, LocalizationKeys.KeyBasicNoObjectives); messageStatus.DetailMessageField = messageField; objectivesPage.Status = messageStatus; } }
/// <summary> /// Edits the contexts for result row. /// </summary> /// <param name="resultRow">The result row.</param> /// <param name="tabConfig">The tab configuration.</param> /// <param name="editFieldDictionary">The edit field dictionary.</param> /// <param name="initialValues">The initial values.</param> /// <param name="fieldPostfix">The field postfix.</param> /// <param name="initialRecords">The initial records.</param> /// <returns></returns> public List <object> EditContextsForResultRow(UPCRMResultRow resultRow, FieldControlTab tabConfig, Dictionary <string, UPEditFieldContext> editFieldDictionary, Dictionary <string, object> initialValues, string fieldPostfix, List <UPCRMRecord> initialRecords) { var recordIdentification = resultRow?.RecordIdentificationAtIndex(0); var fieldArray = new List <object>(); UPCRMRecord offlineRootRecord = null; if (initialRecords?.Count > 0) { offlineRootRecord = initialRecords.FirstOrDefault(); } var identifierPrefix = recordIdentification; if (string.IsNullOrEmpty(identifierPrefix)) { identifierPrefix = $"{this.TabConfig.FieldControl.UnitName}_{this.TabIndex}"; } var fieldCount = tabConfig?.NumberOfFields ?? 0; for (var j = 0; j < fieldCount; j++) { var fieldConfig = tabConfig?.FieldAtIndex(j); if (fieldConfig == null) { continue; } var fieldAttributes = fieldConfig.Attributes; var currentInfoAreaId = fieldConfig.InfoAreaId; var currentLinkId = fieldConfig.LinkId; var fieldIdentifier = FieldIdentifier.IdentifierWithRecordIdentificationFieldId(identifierPrefix, fieldConfig.Identification); UPSelector selector = null; var selectorDef = fieldConfig.Attributes?.Selector; if (selectorDef != null) { var filterParameters = this.EditPageContext?.ViewReference?.ContextValueForKey("copyFields")?.JsonDictionaryFromString(); if (resultRow?.Result != null && resultRow.IsNewRow) { selector = UPSelector.SelectorFor( resultRow.RootRecordIdentification?.InfoAreaId(), resultRow.Result.ParentRecordIdentification, resultRow.Result.LinkId, selectorDef, filterParameters, fieldConfig); } else { selector = UPSelector.SelectorFor(resultRow?.RootRecordIdentification, selectorDef, filterParameters, fieldConfig); } selector.Build(); if (selector.OptionCount == 0 && selector.IsStaticSelector) { selector = null; } } var isEditField = this.enableLinkedEditFields || selector != null || (tabConfig.FieldControl.InfoAreaId == currentInfoAreaId && currentLinkId <= 0); var isHidden = fieldAttributes.Hide; var isReadOnly = isEditField && fieldAttributes.ReadOnly; var rawFieldValue0 = resultRow?.RawValueAtIndex(fieldConfig.TabIndependentFieldIndex); var fieldInfo = fieldConfig.Field.FieldInfo; if (isEditField && !isReadOnly && !(selector is UPRecordSelector && ((UPRecordSelector)selector).IgnoreFieldInfo)) { if (fieldInfo.IsReadOnly) { isReadOnly = true; } else if (resultRow?.IsNewRow == true || string.IsNullOrEmpty(rawFieldValue0)) { if (fieldInfo.LockedOnNew) { isReadOnly = true; } } else if (fieldInfo.LockedOnUpdate && !fieldInfo.IsEmptyValue(rawFieldValue0)) { isReadOnly = true; } } string offlineValue = null; bool offlineChanged; string rawFieldValue; UPEditFieldContext editFieldContext; if (isEditField) { List <UPEditFieldContext> childFields = null; if (fieldAttributes.FieldCount > 1 && selector == null) { childFields = new List <UPEditFieldContext>(); for (var k = 1; k < fieldAttributes.FieldCount; k++) { var childFieldConfig = tabConfig.FieldAtIndex(++j); if (childFieldConfig != null) { rawFieldValue = resultRow.RawValueAtIndex(childFieldConfig.TabIndependentFieldIndex); if (initialValues != null) { rawFieldValue = this.ValueByApplyingInitialValuesForField(rawFieldValue, childFieldConfig, initialValues); } offlineChanged = false; if (offlineRootRecord != null) { offlineValue = offlineRootRecord.StringFieldValueForFieldIndex(childFieldConfig.FieldId); if (offlineValue != null && !offlineValue.Equals(rawFieldValue)) { offlineChanged = true; } } editFieldContext = UPEditFieldContext.ChildFieldContextForFieldConfigValue(childFieldConfig, rawFieldValue); if (offlineChanged) { editFieldContext.SetOfflineChangeValue(offlineValue); } childFields.Add(editFieldContext); } } } var markAsChanged = false; rawFieldValue = rawFieldValue0; if (initialValues != null) { string initialValue = this.ValueByApplyingInitialValuesForField(rawFieldValue, fieldConfig, initialValues); if (!rawFieldValue.Equals(initialValue)) { markAsChanged = true; rawFieldValue = initialValue; } } offlineChanged = false; offlineValue = null; if (offlineRootRecord != null) { offlineValue = offlineRootRecord.StringFieldValueForFieldIndex(fieldConfig.FieldId); if (offlineValue != null && !offlineValue.Equals(rawFieldValue)) { offlineChanged = true; } } if (selector != null) { // Sometimes it makes sense to add the Link field , so you have the link information on the EditPage , but the field is not displayed . // Thus, the field is interpreted as EditField Selector must be set. if (isHidden) { editFieldContext = UPEditFieldContext.HiddenFieldFor(fieldConfig, fieldIdentifier, rawFieldValue); } else if (isReadOnly && ConfigurationUnitStore.DefaultStore.ConfigValueIsSet("Disable.82213")) { editFieldContext = UPEditFieldContext.ReadonlyFieldFor(fieldConfig, fieldIdentifier, rawFieldValue); } else { editFieldContext = UPEditFieldContext.FieldContextFor(fieldConfig, fieldIdentifier, rawFieldValue, selector); } } else { if (isHidden) { editFieldContext = UPEditFieldContext.HiddenFieldFor(fieldConfig, fieldIdentifier, rawFieldValue); } else if (isReadOnly) { editFieldContext = UPEditFieldContext.ReadonlyFieldFor(fieldConfig, fieldIdentifier, rawFieldValue); } else { editFieldContext = UPEditFieldContext.FieldContextFor(fieldConfig, fieldIdentifier, rawFieldValue, childFields as List <UPEditFieldContext>); } } if (fieldInfo.DateFieldId >= 0 && tabConfig.FieldControl.InfoAreaId == currentInfoAreaId) { editFieldContext.DateOriginalValue = resultRow?.RawValueForFieldIdInfoAreaIdLinkId(fieldInfo.DateFieldId, currentInfoAreaId, -1); } else if (fieldInfo.TimeFieldId >= 0 && tabConfig.FieldControl.InfoAreaId == currentInfoAreaId) { editFieldContext.TimeOriginalValue = resultRow?.RawValueForFieldIdInfoAreaIdLinkId(fieldInfo.TimeFieldId, currentInfoAreaId, -1); } if (offlineChanged) { editFieldContext.SetOfflineChangeValue(offlineValue); } else if (markAsChanged) { editFieldContext.SetChanged(true); } if (editFieldContext != null) { if (!string.IsNullOrEmpty(fieldPostfix)) { editFieldContext.FieldLabelPostfix = fieldPostfix; } if (editFieldDictionary != null) { editFieldDictionary.SetObjectForKey(editFieldContext, fieldConfig.Identification); if (childFields != null) { foreach (var childFieldContext in childFields) { editFieldDictionary.SetObjectForKey(childFieldContext, childFieldContext.FieldConfig.Identification); } } } fieldArray.Add(editFieldContext); } } else { string fieldValue; if (fieldAttributes.FieldCount > 1) { fieldValue = resultRow?.ValueAtIndex(fieldConfig.TabIndependentFieldIndex); if (string.IsNullOrEmpty(fieldValue)) { fieldValue = this.ValueForLinkFieldFromInitialValues(fieldConfig, initialValues); } var values = !string.IsNullOrEmpty(fieldValue) ? new List <string> { fieldValue } : new List <string>(); for (var k = 1; k < fieldAttributes.FieldCount; k++) { var childfieldConfig = tabConfig.FieldAtIndex(++j); if (childfieldConfig == null) { continue; } fieldValue = resultRow?.ValueAtIndex(childfieldConfig.TabIndependentFieldIndex); if (string.IsNullOrEmpty(fieldValue)) { fieldValue = this.ValueForLinkFieldFromInitialValues(childfieldConfig, initialValues); } if (string.IsNullOrEmpty(fieldValue)) { fieldValue = string.Empty; } values.Add(fieldValue); } fieldValue = fieldAttributes.FormatValues(values); } else { fieldValue = resultRow?.ValueAtIndex(fieldConfig.TabIndependentFieldIndex); if (string.IsNullOrEmpty(fieldValue)) { fieldValue = this.ValueForLinkFieldFromInitialValues(fieldConfig, initialValues); } } UPMField field; if (!isHidden && !string.IsNullOrEmpty(fieldValue)) { field = new UPMStringField(fieldIdentifier); ((UPMStringField)field).StringValue = fieldValue; } else { field = null; } if (field != null) { if (!fieldConfig.Attributes.NoLabel) { field.LabelText = fieldConfig.Label; } SetAttributesOnField(fieldAttributes, field); fieldArray.Add(field); } } } return(fieldArray); }
/// <summary> /// Initializes a new instance of the <see cref="UPEditConstraintViolation"/> class. /// </summary> /// <param name="context"> /// The context. /// </param> /// <param name="violationType"> /// Type of the violation. /// </param> public UPEditConstraintViolation(UPEditFieldContext context, EditConstraintViolationType violationType) : this(context, violationType, null) { }