/// <summary> /// Context record for given edit field. /// </summary> /// <param name="editField">Edit field</param> /// <returns><see cref="string"/></returns> public string ContextRecordForEditField(UPMEditField editField) { if (this.Selector.DisableLinkOption && this.Selector.LinkIsDisabled) { return(null); } if (this.Selector.RecordLinkInfoAreaIds?.Count > 0) { if (this.ChildEditContext != null) { return(this.ChildEditContext.ContextRecordForSenderSelector(editField, this.Selector)); } for (var i = 0; i < this.Selector.RecordLinkInfoAreaIds.Count; i++) { var linkInfoAreaId = this.Selector.RecordLinkInfoAreaIds[i]; var linkId = this.Selector.RecordLinkLinkIds[i].ToInt(); var rid = UPSelector.StaticSelectorContextDelegate?.SenderLinkForInfoAreaIdLinkId(this, linkInfoAreaId, linkId); if (rid?.Length > 8) { return(rid); } } } return(null); }
private UPCRMRecord CreateNewRecord( UPCRMRecord parentRecord, UPCRMLinkParticipant participant, bool hasRequirement, UPMEditField requirementField, bool hasAcceptance, UPMEditField acceptanceField) { var record = UPCRMRecord.CreateNew(this.ParticipantsControl.LinkParticipantsInfoAreaId); if (parentRecord.IsNew && (parentRecord.Links == null || parentRecord.Links.Count == 0)) { parentRecord.AddLink(new UPCRMLink(participant.LinkRecordIdentification)); } this.ApplyTemplateFilterToRecord(record); record.AddLink(new UPCRMLink(parentRecord, -1)); record.AddLink(new UPCRMLink(participant.LinkRecordIdentification)); if (hasRequirement) { record.NewValueFieldId(requirementField.StringValue, participant.Context.RequirementField.FieldId); } if (hasAcceptance) { record.NewValueFieldId(acceptanceField.StringValue, participant.Context.AcceptanceField.FieldId); } return(record); }
public override void UserDidChangeField(UPMEditField field) { IQuestionnaireEditFieldContext fieldContext = field as IQuestionnaireEditFieldContext; if (fieldContext != null) { string answerId = field.StringEditValue; UPSurveyActionResult surveyActionResult; if (field is UPMCatalogEditField) { object v = field.FieldValue; if (v is List <string> ) { surveyActionResult = this.Survey.SetAnswerArrayForQuestionKey((List <string>)v, fieldContext.Question.QuestionId); } else { surveyActionResult = this.Survey.SetAnswerForQuestionKey((string)v, fieldContext.Question.QuestionId); } } else { surveyActionResult = this.Survey.SetAnswerForQuestionKey(answerId, fieldContext.Question.QuestionId); } if (surveyActionResult.QuestionOrderChanged) { this.FillPage(this.Page); this.InformAboutDidChangeTopLevelElement(this.Page, this.Page, null, null); } } }
/// <inheritdoc/> public string ContextRecordForEditField(UPMEditField field) { var editField = field as UPMParticipantsRecordSelectorEditField; if (editField.CurrentSelector.DisableLinkOption && editField.CurrentSelector.LinkIsDisabled) { return(null); } if (editField.CurrentSelector?.RecordLinkInfoAreaIds?.Count > 0) { UPRecordSelector selector = editField.CurrentSelector; for (int i = 0; i < selector.RecordLinkInfoAreaIds.Count; i++) { string linkInfoAreaId = selector.RecordLinkInfoAreaIds[i]; int linkId = selector.RecordLinkLinkIds[i]; string rid = UPSelector.StaticSelectorContextDelegate.SenderLinkForInfoAreaIdLinkId(this, linkInfoAreaId, linkId); if (rid.Length > 8) { return(rid); } } } return(null); }
/// <summary> /// Applies the attributes on edit field configuration. /// </summary> /// <param name="_editField"> /// The _edit field. /// </param> /// <param name="fieldConfig"> /// The field configuration. /// </param> public override void ApplyAttributesOnEditFieldConfig( UPMEditField _editField, UPConfigFieldControlField fieldConfig) { base.ApplyAttributesOnEditFieldConfig(_editField, fieldConfig); ((UPMNumberEditField)_editField).ShowZero = fieldConfig?.Field?.FieldInfo?.ShowZero ?? false; }
private void SimpleChangedValue(UPMEditField editField) { if (this.NeedsSignalValueChange(editField)) { this.Delegate.GroupModelControllerValueChanged(this, this.CurrentData); } }
private static void ProcessEditField( UPMQuestionnaireGroup questionnaireGroup, UPQuestionnaireQuestion currentQuestion, UPMEditField editField, IQuestionnaireEditFieldContext editFieldContext, UPQuestionnaireCatalogEditField catalogEditField, string surveyAnswer, IList <string> answerIds, bool multiSelect) { if (questionnaireGroup == null) { throw new ArgumentNullException(nameof(questionnaireGroup)); } if (currentQuestion == null) { throw new ArgumentNullException(nameof(currentQuestion)); } if (editFieldContext == null) { throw new ArgumentNullException(nameof(editFieldContext)); } if (answerIds == null) { throw new ArgumentNullException(nameof(answerIds)); } editField.LabelText = currentQuestion.Label; editField.DetailText = currentQuestion.AdditionalInfo; editField.RequiredField = currentQuestion.Mandatory; editFieldContext.Question = currentQuestion; if (multiSelect) { if (catalogEditField != null) { foreach (string a in answerIds) { catalogEditField.AddFieldValue(a); } } } else { editField.FieldValue = surveyAnswer; } editField.ContinuousUpdate = true; var questionnaireQuestion = new UPMQuestionnaireQuestion(editField) { Mandatory = currentQuestion.Mandatory }; questionnaireGroup.AddQuestion(questionnaireQuestion); }
/// <inheritdoc/> public List <IIdentifier> UserDidChangeField(UPMEditField field, object pageModelController) { List <IIdentifier> changedFields = null; if (field is UPMParticipantsRecordSelectorEditField) { var selectorEditfield = (UPMParticipantsRecordSelectorEditField)field; string recordIdentification = null; var crmLinkInfo = selectorEditfield.CurrentSelector.LinkInfo; if (crmLinkInfo != null && !string.IsNullOrEmpty(selectorEditfield.ResultRows.RootRecordIdentification)) { recordIdentification = selectorEditfield.ResultRows.RootRecordIdentification; } string key = this.KeyForEditGroup(selectorEditfield.Group); if (key != null) { var participant = this.ParticipantsControl.ParticipantWithKey(key) as UPCRMLinkParticipant; if (participant != null) { if (!string.IsNullOrEmpty(recordIdentification)) { participant.MarkAsDeleted = false; var tableCaption = selectorEditfield.ResultRows.RowResult as string; participant.ChangeRepName(recordIdentification, tableCaption); selectorEditfield.FieldValue = participant.Name; selectorEditfield.Participant = participant; changedFields = new List <IIdentifier> { selectorEditfield.Identifier }; } else { participant.MarkAsDeleted = true; } } } } else if (field is UPMParticipantCatalogEditField) { var selectorEditfield = (UPMParticipantCatalogEditField)field; var key = this.KeyForEditGroup(selectorEditfield.Group); if (key != null) { var participant = this.ParticipantsControl.ParticipantWithKey(key) as UPCRMLinkParticipant; if (participant != null) { changedFields = new List <IIdentifier> { field.Identifier }; } } } return(changedFields); }
/// <summary> /// Returns changed records. /// </summary> /// <returns></returns> public override List <UPCRMRecord> ChangedRecords() { if (this.IsReadOnly) { return(null); } UPMCharacteristicsPage characteristicsPage = (UPMCharacteristicsPage)this.Page; foreach (UPMCharacteristicsItemGroup group in characteristicsPage.Children) { foreach (UPMCharacteristicsItem item in group.Children) { UPCharacteristicsItem crmItem = this.FindCharacteristicItemWithGroupIdentifierItemIdentifier(group.Identifier, item.Identifier); bool updateEditFields = true; if (item.SelectedField.Changed) { if (crmItem != null) { if (item.SelectedField.BoolValue) { crmItem.MarkItemAsSet(); } else { crmItem.MarkItemAsUnset(); updateEditFields = false; } } } if (updateEditFields) { for (int editFieldIndex = 0; editFieldIndex < item.EditFields.Count; editFieldIndex++) { UPMEditField field = item.EditFields[editFieldIndex] as UPMEditField; if (field != null && field.Changed) { List <UPEditFieldContext> fieldContextList = this.editPageContext.EditFields.Values.ToList(); foreach (UPEditFieldContext fieldContext in fieldContextList) { if (fieldContext.EditField == field) { crmItem?.SetValueForAdditionalFieldPosition(fieldContext.Value, editFieldIndex); } } } } } } } return(this.Characteristics?.ChangedRecords()); }
/// <summary> /// Fields the context for edit field. /// </summary> /// <param name="editField">The edit field.</param> /// <returns></returns> public UPEditFieldContext FieldContextForEditField(UPMEditField editField) { List <UPEditFieldContext> fieldContextList = this.editPageContext.EditFields.Values.ToList(); foreach (UPEditFieldContext fieldContext in fieldContextList) { if (fieldContext.EditField == editField) { return(fieldContext); } } return(null); }
/// <summary> /// Returns current record for given edit field /// </summary> /// <param name="editField">Edit field</param> /// <returns><see cref="string"/></returns> public string CurrentRecordForEditField(UPMEditField editField) { if (this.ChildEditContext != null) { return(this.ChildEditContext.CurrentRecordForSenderSelector(editField, this.Selector)); } if (this.Selector.LinkTargetInfoAreaId == null) { return(null); } return(UPSelector.StaticSelectorContextDelegate.SenderLinkForInfoAreaIdLinkId(this, this.Selector.LinkTargetInfoAreaId, this.Selector.LinklinkId)); }
/// <summary> /// The field changed value. /// </summary> /// <param name="editField">The edit field.</param> public void FieldChangedValue(UPMEditField editField) { if (editField is UPMRecordSelectorEditField) { this.UserDidChangeRecordSelectorEditField((UPMRecordSelectorEditField)editField); } else if (editField is UPMCatalogEditField) { this.UserDidChangeCatalogField((UPMCatalogEditField)editField); } else { this.SimpleChangedValue(editField); } }
/// <summary> /// Pages for overview. /// </summary> /// <param name="page">The page.</param> /// <returns></returns> public Page PageForOverview(Page page) { Page newPage = this.InstantiatePage(); if (this.portfolioGroup != null) { newPage.AddGroup(this.portfolioGroup); } foreach (UPMQuestionnaireGroup currentGroup in page.Groups) { UPMQuestionnaireGroup questionnaireGroup = new UPMQuestionnaireGroup(currentGroup.Identifier) { LabelText = currentGroup.LabelText }; bool insertGroup = false; foreach (UPMQuestionnaireQuestion currentQuestion in currentGroup.Questions) { if (currentQuestion.Field.Empty) { continue; } insertGroup = true; UPMEditField editField = (UPMEditField)currentQuestion.Field; UPMField field = new UPMStringField(editField.Identifier) { LabelText = editField.LabelText }; if (!editField.Empty) { field.FieldValue = editField.StringDisplayValue; } UPMQuestionnaireQuestion questionnaireQuestion = new UPMQuestionnaireQuestion(field); questionnaireGroup.AddQuestion(questionnaireQuestion); } if (insertGroup) { newPage.AddGroup(questionnaireGroup); } } return(newPage); }
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> /// Applies the attributes on edit field configuration. /// </summary> /// <param name="_editField"> /// The _edit field. /// </param> /// <param name="fieldConfig"> /// The field configuration. /// </param> public virtual void ApplyAttributesOnEditFieldConfig( UPMEditField _editField, UPConfigFieldControlField fieldConfig) { if (fieldConfig == null) { return; } if (fieldConfig.Attributes.Must) { _editField.RequiredField = true; } else if (!fieldConfig.IsLinkedField) { var fieldInfo = fieldConfig.Field?.FieldInfo; _editField.RequiredField = fieldInfo != null && fieldInfo.MustField; } }
public List <IIdentifier> UserDidChangeField(UPMEditField field, object pageModelController) { if (field.GetType() == (typeof(UPMRepEditField))) { UPMRepEditField _field = (UPMRepEditField)field; string key = keyForEditGroup(field.Group); if (key != null) { UPCRMRepParticipant participant = (UPCRMRepParticipant)this.ParticipantsControl.ParticipantWithKey(key); if (participant != null) { participant.MarkAsDeleted = false; participant.ChangeRep(field.FieldValue); } } } else if (_field.IsKindOfClass(typeof(UPMParticipantCatalogEditField))) { UPMParticipantCatalogEditField field = (UPMParticipantCatalogEditField)_field; string key = this.KeyForEditGroup(field.Group); if (key != null) { UPCRMRepParticipant participant = (UPCRMRepParticipant)this.ParticipantsControl.ParticipantWithKey(key); string participantIdentification = participant.Key; UPMGroup editGroup = this.EditGroupForKey(participantIdentification); UPMDependsEditField dependsEditField = (UPMDependsEditField)editGroup.Fields.ObjectAtIndex(0); UPMEditField acceptanceField = dependsEditField.DependField; UPMEditField requirementField = dependsEditField.DependField2; if (field == acceptanceField) { participant.AcceptanceText = field.FieldValue; } else if (field == requirementField) { participant.RequirementText = field.FieldValue; } } } return(null); }
private UPCRMRecord CreateNewRecord( UPCRMLinkParticipant participant, bool hasRequirement, UPMEditField requirementField, bool hasAcceptance, UPMEditField acceptanceField) { var record = UPCRMRecord.CreateNew(participant.RecordIdentification); this.ApplyTemplateFilterToRecord(record); if (hasRequirement && requirementField.StringValue != participant.RequirementText) { record.NewValueFromValueFieldId(requirementField.StringValue, participant.RequirementText, participant.Context.RequirementField.FieldId); } if (hasAcceptance && acceptanceField.StringValue != participant.AcceptanceText) { record.NewValueFromValueFieldId(acceptanceField.StringValue, participant.AcceptanceText, participant.Context.AcceptanceField.FieldId); } return(record); }
private static void CreateEditFields(UPCRMFieldInfo fieldInfo, bool rangFilter, string type, out UPMEditField editField, out UPMEditField secondEditField) { editField = null; secondEditField = null; switch (type) { case "F" when fieldInfo.PercentField: editField = new UPMPercentEditField(StringIdentifier.IdentifierWithStringId("percentParam")); if (rangFilter) { secondEditField = new UPMPercentEditField(StringIdentifier.IdentifierWithStringId("percentParam2")); } break; case "F": editField = new UPMFloatEditField(StringIdentifier.IdentifierWithStringId("floatParam")); if (rangFilter) { secondEditField = new UPMFloatEditField(StringIdentifier.IdentifierWithStringId("floatParam2")); } break; case "C": editField = new UPMStringEditField(StringIdentifier.IdentifierWithStringId("stringParam")); if (rangFilter) { secondEditField = new UPMStringEditField(StringIdentifier.IdentifierWithStringId("stringParam2")); } break; case "B": editField = new UPMBooleanEditField(StringIdentifier.IdentifierWithStringId("booleanParam")); break; default: editField = new UPMIntegerEditField(StringIdentifier.IdentifierWithStringId("intParam")); if (rangFilter) { secondEditField = new UPMIntegerEditField(StringIdentifier.IdentifierWithStringId("intParam2")); } break; } }
private void ProcessGroup(UPMQuestionnairePage page, int index, UPQuestionnaireQuestionGroup currentGroup) { if (page == null) { throw new ArgumentNullException(nameof(page)); } if (currentGroup == null) { throw new ArgumentNullException(nameof(currentGroup)); } bool firstQuestion = true; var questionnaireGroup = new UPMQuestionnaireGroup(StringIdentifier.IdentifierWithStringId($"group_{currentGroup.Label}")) { LabelText = currentGroup.Label }; page.AddGroup(questionnaireGroup); var questions = this.Survey.VisibleQuestionsForGroup(currentGroup); foreach (var currentQuestion in questions) { if (currentQuestion.Hide) { continue; } UPMEditField editField = null; IQuestionnaireEditFieldContext editFieldContext = null; UPQuestionnaireCatalogEditField catalogEditField = null; if (firstQuestion) { if (string.IsNullOrEmpty(questionnaireGroup.LabelText)) { questionnaireGroup.LabelText = currentQuestion.Label; } firstQuestion = false; } var fieldIdentifier = StringIdentifier.IdentifierWithStringId($"{currentQuestion.RecordIdentification}_{index}"); var surveyAnswer = this.Survey.SurveyAnswerForQuestion(currentQuestion); var answerIds = surveyAnswer.AnswerIds; bool multiSelect = currentQuestion.Multiple; var explicitKeyOrder = new List <string>(); CreateFields( currentQuestion, out editField, out editFieldContext, out catalogEditField, fieldIdentifier, multiSelect, explicitKeyOrder); if (editField != null) { ProcessEditField( questionnaireGroup, currentQuestion, editField, editFieldContext, catalogEditField, surveyAnswer.Answer, answerIds, multiSelect); } } }
/// <inheritdoc/> public List <IIdentifier> UserDidChangeField(UPMEditField field, object pageModelController) { if (field is UPMRepEditField) { var editField = (UPMRepEditField)field; var key = this.KeyForEditGroup(editField.Group); if (key != null) { var participant = (UPCRMRepParticipant)this.ParticipantsControl.ParticipantWithKey(key); if (participant != null) { participant.MarkAsDeleted = false; participant.ChangeRep((string)field.FieldValue); } } } else if (field is UPMParticipantCatalogEditField) { var editField = (UPMParticipantCatalogEditField)field; var key = this.KeyForEditGroup(editField.Group); if (key != null) { var participant = (UPCRMRepParticipant)this.ParticipantsControl.ParticipantWithKey(key); var participantIdentification = participant.Key; var editGroup = this.EditGroupForKey(participantIdentification); var dependsEditField = (UPMDependsEditField)editGroup.Fields[0]; var acceptanceField = dependsEditField.DependField; var requirementField = dependsEditField.DependField2; if (field == acceptanceField) { participant.AcceptanceText = (string)field.FieldValue; } else if (field == requirementField) { participant.RequirementText = (string)field.FieldValue; } } } else if (field is UPMDependsEditField) { var editField = (UPMDependsEditField)field; var selectedRep = ((UPMRepEditField)editField.MainField).RepContainer.SelectedRepKeys; foreach (var key in selectedRep) { var participant = (UPCRMRepParticipant)this.ParticipantsControl.ParticipantWithKey(key); if (participant == null) { var newParticipant = this.ParticipantsControl.AddRepParticipantWithRepId(key, null); } } var deletedRep = this.ParticipantsControl.RepParticipants.Where(p => !selectedRep.Contains(p.Key)).ToList(); foreach (var rep in deletedRep) { rep.MarkAsDeleted = true; this.ParticipantsControl.RemoveRepParticipant(rep); } this.Group = this.GroupFromParticipantControl(); } return(null); }
/// <inheritdoc/> public string CurrentRecordForEditField(UPMEditField field) { return(null); }
/// <summary> /// Returns changed records. /// </summary> /// <returns></returns> public override List <UPCRMRecord> ChangedRecords() { List <UPCRMRecord> changedRecords = new List <UPCRMRecord>(); UPMObjectivesPage page = (UPMObjectivesPage)this.Page; foreach (UPMObjectivesSection section in page.Children) { foreach (UPMObjective item in section.Children) { UPObjectivesItem crmItem = item.ObjectiveItem; if (item.DoneField.Changed) { if (crmItem != null) { crmItem.Completed = item.DoneField.BoolValue; } } int editFieldIndex = 0; for (int elementIndex = 0; elementIndex < item.Fields.Count; elementIndex++) { UPMElement element = item.Fields[elementIndex]; if (element is UPMEditField) { UPMEditField editField = (UPMEditField)element; if (editField.Changed) { List <UPEditFieldContext> fieldContextList = this.editPageContext.EditFields.Values.ToList(); foreach (UPEditFieldContext fieldContext in fieldContextList) { if (fieldContext.EditField == editField) { crmItem?.SetValueForAdditionalFieldPosition(fieldContext.Value ?? string.Empty, editFieldIndex); } } } editFieldIndex++; } else if (element is UPMStringField) { editFieldIndex++; } } List <UPCRMRecord> itemChangedRecords = crmItem?.ChangedRecords(); if (itemChangedRecords != null) { changedRecords.AddRange(itemChangedRecords); } } } foreach (UPObjectivesItem deletedItem in this.DeletedItems) { List <UPCRMRecord> itemChangedRecords = deletedItem.ChangedRecords(); if (itemChangedRecords != null) { changedRecords.AddRange(deletedItem.ChangedRecords()); } } return(changedRecords.Count == 0 ? null : changedRecords); }
/// <summary> /// Users the did change field. /// </summary> /// <param name="field">The field.</param> public void UserDidChangeField(UPMEditField field) { field.EditFieldDelegate?.FieldChangedValue(field); }
/// <summary> /// Contexts for edit field. /// </summary> /// <param name="field">The field.</param> /// <returns></returns> public UPEditFieldContext ContextForEditField(UPMEditField field) { return(this.EditFields?.Values?.FirstOrDefault(context => context.EditField == field)); }
private static void CreateFields( UPQuestionnaireQuestion currentQuestion, out UPMEditField editField, out IQuestionnaireEditFieldContext editFieldContext, out UPQuestionnaireCatalogEditField catalogEditField, IIdentifier fieldIdentifier, bool multiSelect, IList <string> explicitKeyOrder) { if (currentQuestion == null) { throw new ArgumentNullException(nameof(currentQuestion)); } if (explicitKeyOrder == null) { throw new ArgumentNullException(nameof(explicitKeyOrder)); } editField = null; editFieldContext = null; catalogEditField = null; switch (currentQuestion.FieldType[0]) { case FieldTypeX: case FieldTypeK: var answers = currentQuestion.Answers(); if (answers == null) { break; } if (answers.Count > 10) { catalogEditField = new UPQuestionnaireCatalogEditField(fieldIdentifier, multiSelect) { CatalogElementViewType = CatalogElementViewType.PopOver }; } else { catalogEditField = new UPQuestionnaireCatalogEditField(fieldIdentifier, multiSelect) { CatalogElementViewType = CatalogElementViewType.Table }; } catalogEditField.NullValueKey = "0"; if (multiSelect) { catalogEditField.MultiSelectMaxCount = answers.Count; } editField = catalogEditField; editFieldContext = catalogEditField; foreach (var answer in answers) { var catalogPossibleValue = new UPMCatalogPossibleValue { TitleLabelField = new UPMStringField(null) { StringValue = answer.AnswerText } }; explicitKeyOrder.Add(answer.AnswerId); catalogEditField.AddPossibleValue(catalogPossibleValue, answer.AnswerId); } catalogEditField.ExplicitKeyOrder = explicitKeyOrder as List <string>; break; case FieldTypeD: editField = new UPQuestionnaireDateTimeEditField(fieldIdentifier); editFieldContext = (IQuestionnaireEditFieldContext)editField; break; default: editField = new UPQuestionnaireStringEditField(fieldIdentifier); editFieldContext = (IQuestionnaireEditFieldContext)editField; break; } }