Ejemplo n.º 1
0
 /// <summary>
 /// The initialize.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="parentViewModel">The parent view model.</param>
 public void Initialize(CrossRefFieldEdit model, FieldsSelectorViewModel parentViewModel)
 {
     Model = model;
     ParentViewModel = parentViewModel;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Display Popup for select derived fields for current process field selected for header.
        /// </summary>
        public void ShowPopup()
        {
            var field = AvailableFields.FirstOrDefault(f => f.SystemName == Model.HeaderObject);

            if (field != null && field.StepList.Any(s => s is CrossRefRequiredStepEdit))
            {
                var requiredStep =
                    (CrossRefRequiredStepEdit)field.StepList.FirstOrDefault(s => s is CrossRefRequiredStepEdit);

                if (requiredStep != null && requiredStep.CrossRefProcessId.HasValue)
            {
                FieldList.BeginGetCrossReferenceSubfields(
                    requiredStep.Process.SystemName,
                    field.SystemName,
                    (sender, result) =>
                        {
                            if (result.Error == null)
                            {
                                var derivedFileds =
                                    new ObservableCollection<FieldInfo>(result.Object);

                                FieldsSelectorVM = new FieldsSelectorViewModel { Logger = Logger, FieldsForSelect = derivedFileds, ParentModel = this };

                                if (!string.IsNullOrEmpty(Model.HeaderFields))
                                {
                                    var maxOrder = 0.0;

                                    foreach (var str in Model.HeaderFields.Split(','))
                                    {
                                        if (!string.IsNullOrEmpty(str))
                                        {
                                            var fieldViewModel =
                                                derivedFileds.FirstOrDefault(
                                                    f => f.SystemName == str);

                                            var lfield = new CrossRefFieldEdit();
                                            if (fieldViewModel != null)
                                            {
                                                lfield.FieldName = fieldViewModel.Name;
                                                lfield.FullPath = fieldViewModel.SystemName;
                                            }
                                            lfield.Order = maxOrder + 1.0;
                                            if (fieldViewModel != null)
                                            {
                                                lfield.FieldGuid = fieldViewModel.Guid;
                                            }

                                            var vm =
                                                new FieldsSelectorViewModel.SelectedFieldViewModel();

                                            vm.Initialize(lfield, FieldsSelectorVM);
                                            FieldsSelectorVM.SelectedDisplayFields.Add(vm);

                                            maxOrder = maxOrder + 1.0;
                                        }
                                    }
                                }

                                this.ThePopupFactory.Value.Popup()
                                                .SetCustomViewModel(this.FieldsSelectorVM)
                                                .SetPosition(PopupPosition.Center)
                                                .SetIsModal(true)
                                                .SetCaption(
                                                    LanguageService.Translate(
                                                        "ItemStatus"))
                                                .Show(() =>
                                                {
                                                    if (Model.HeaderDisplayFields.IndexOf(",", System.StringComparison.Ordinal) > 0)
                                                    {
                                                        Model.HeaderDisplayFields = Model.HeaderDisplayFields.Substring(
                                                            0,
                                                            Model.HeaderDisplayFields.Length - 1);
                                                    }
                                                    RaisePropertyChanged(() => Model);
                                                    });
                            }
                        });
            }
        }
    }
Ejemplo n.º 3
0
        /// <summary>
        /// Select A field from the field list.
        /// </summary>
        /// <param name="fieldViewModel">Selected field.</param>
        public void SelectDisplayField(ISelectorFieldViewModel fieldViewModel)
        {
            var path = fieldViewModel.SystemName;

            if (SelectedFields.Contains(path + ","))
            {
                return;
            }

            var maxOrder = 0.0;

            if (!string.IsNullOrEmpty(SelectedFields))
                maxOrder = SelectedFields.Split(',').Length;

            SelectedFields += path + ",";
            if (string.IsNullOrEmpty(ParentModel.Model.HeaderDisplayFields))
                ParentModel.Model.HeaderDisplayFields = fieldViewModel.Name;
            else
                ParentModel.Model.HeaderDisplayFields += ", " + fieldViewModel.Name;

            var field = new CrossRefFieldEdit();
            field.FieldName = fieldViewModel.Name;
            field.FullPath = fieldViewModel.SystemName;
            field.Order = maxOrder + 1.0;
            field.FieldGuid = fieldViewModel.Model.Guid;

            var vm = new SelectedFieldViewModel();

            vm.Initialize(field, this);
            SelectedDisplayFields.Add(vm);

            UpdateCanMoveFields();
        }