Exemple #1
0
 private void UpdateCommandsCanExecuteStatus()
 {
     CancelCommand.RaiseCanExecuteChanged();
     CommitCommand.RaiseCanExecuteChanged();
     BeginEditCommand.RaiseCanExecuteChanged();
     AddCommand.RaiseCanExecuteChanged();
     DeleteCommand.RaiseCanExecuteChanged();
 }
Exemple #2
0
 private void StatusVM_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "IsStaged")
     {
         NotifyPropertyChanged("AllStaged");
         MainWindow.Instance.Dispatcher.Invoke(() => CommitCommand.RaiseCanExecuteChanged());
     }
 }
Exemple #3
0
 private void ItemsView_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == nameof(IEditableCollectionView.IsEditingItem) ||
         e.PropertyName == nameof(IEditableCollectionView.IsAddingNew))
     {
         OnPropertyChanged(nameof(IsEditingItem));
         CommitCommand.RaiseCanExecuteChanged();
         CancelCommand.RaiseCanExecuteChanged();
         ReloadCommand.RaiseCanExecuteChanged();
         ToggleEditCommand.RaiseCanExecuteChanged();
     }
 }
Exemple #4
0
        private async Task TestAccountAsync()
        {
            AccountDefinition worker = AccountDefinition.GetByPrefix(ConnectedAccount.Prefix);

            IsValidating = true;
            Exception ex = await worker.ValidateInteractiveAsync(ConnectedAccount.Id, ConnectedAccount.StorageConnectionString);

            ValidationError        = ex?.Message;
            ValidationErrorDetails = ex?.ToString();
            IsValidating           = false;
            ValidationPassed       = ex == null;
            CommitCommand?.RaiseCanExecuteChanged();
        }
Exemple #5
0
        public void SetStaged(List <StatusEntryVM> statusEntries, bool staged)
        {
            if (staged)
            {
                _areaVM.Area.RecordChanges(_status, statusEntries.Select(x => x.StatusEntry).ToList(), true, false, (se, code, b) => { se.Code = code; se.Staged = true; });
            }
            else
            {
                _areaVM.Area.Revert(statusEntries.Select(x => x.StatusEntry).ToList(), false, false, false, (se, code) => { se.Code = code; se.Staged = false; });
            }

            statusEntries.ForEach(x =>
            {
                x.NotifyPropertyChanged("IsStaged");
                x.NotifyPropertyChanged("Code");
            });

            NotifyPropertyChanged("AllStaged");
            MainWindow.Instance.Dispatcher.Invoke(() => CommitCommand.RaiseCanExecuteChanged());
        }
Exemple #6
0
        public void Refresh()
        {
            if (_areaVM.IsValid)
            {
                lock (refreshLock)
                {
                    _status   = _areaVM.Area.GetStatus(_areaVM.Area.Root);
                    _elements = new List <StatusEntryVM>();

                    _tagPresets = new List <TagPresetVM>();
                    if (_areaVM.Area.Directives.TagPresets != null)
                    {
                        _tagPresets.AddRange(_areaVM.Area.Directives.TagPresets.Select(x => new TagPresetVM(x)));
                    }

                    foreach (Status.StatusEntry statusEntry in Status.Elements.OrderBy(x => x.CanonicalName))
                    {
                        if (statusEntry.Code != StatusCode.Ignored &&
                            statusEntry.Code != StatusCode.Excluded &&
                            statusEntry.Code != StatusCode.Unchanged)
                        {
                            StatusEntryVM statusEntryVM = new StatusEntryVM(statusEntry, this, _areaVM.Area);
                            if (statusEntryVM != null)
                            {
                                _elements.Add(statusEntryVM);
                                statusEntryVM.PropertyChanged += StatusVM_PropertyChanged;
                            }
                        }
                    }

                    NotifyPropertyChanged("Status");
                    NotifyPropertyChanged("Elements");
                    NotifyPropertyChanged("AllStaged");
                    NotifyPropertyChanged("TagPresets");
                    MainWindow.Instance.Dispatcher.Invoke(() => CommitCommand.RaiseCanExecuteChanged());
                }
            }
        }
Exemple #7
0
        private void UpdateAccountFields()
        {
            AccountFields.Clear();
            if (SelectedConnectionType == null)
            {
                return;
            }

            foreach (AccountField accountField in SelectedConnectionType.Fields)
            {
                ConnectedAccount.StorageConnectionString.Parameters.TryGetValue(accountField.Name, out string fieldValue);

                accountField.Value = fieldValue ?? string.Empty;

                if (accountField is HiddenAccountField)
                {
                    ConnectedAccount.StorageConnectionString.Parameters[accountField.Name] = accountField.Value;
                }

                PropertyChangedEventHandler eh = (sender, pcea) =>
                {
                    if (pcea.PropertyName == nameof(AccountField.Value) && sender is AccountField af)
                    {
                        //update connection string parameter
                        ConnectedAccount.StorageConnectionString.Parameters[af.Name] = af.Value;

                        IsDirty = true;
                        CommitCommand?.RaiseCanExecuteChanged();

                        Debug.WriteLine($"{ConnectedAccount.DisplayName}: {af.Name} => {af.Value}");
                    }
                };

                accountField.PropertyChanged += eh;
                _fieldToHandler[accountField] = eh;
                AccountFields.Add(accountField);
            }
        }
 /// <summary>
 /// Called when edit is enabled.
 /// </summary>
 private void OnEnableEdit()
 {
     Reset(false);
     CommitCommand.RaiseCanExecuteChanged();
 }
Exemple #9
0
        public EmployeeApprovalsViewModel()
        {
            Header = Localization.Resources.EmployeeApprovalsView_Header;

            _WireDesignerData();

            if (InDesigner)
            {
                return;
            }

            RegisterValidationErrorsCommand = new ActionCommand <ValidationErrorEventArgs>(e =>
            {
                if (e.Action == ValidationErrorEventAction.Added)
                {
                    _validationErrors++;
                }
                else
                {
                    _validationErrors--;
                }
                RaisePropertyChanged(() => HasValidationErrors);
                CommitCommand.RaiseCanExecuteChanged();
            });

            CommitCommand = new ActionCommand <object>(obj =>
            {
                var dataForm        = obj as RadDataForm;
                Action commitAction = () => { dataForm.CancelEdit(); };                 // Using cancel edit since we are reloading!
                var editedApproval  = PagedEmployeeApprovalViewCollection.CurrentItem as EmployeeApproval;

                if (editedApproval != null)
                {
                    HandleAddUpdate(editedApproval, commitAction);
                }
            }, obj =>
            {
                bool serverValidationError = false;
                var dataForm = obj as RadDataForm;
                if (dataForm != null)
                {
                    var current = dataForm.CurrentItem as EmployeeSkill;
                    if (current != null && current.HasErrors)
                    {
                        serverValidationError = true;
                    }
                }

                return(IsEditing && !serverValidationError && !HasValidationErrors && ContextService.Current.Role.HasPermission(
                           EntityPermissions.Employee,
                           OperationPermissions.Update | OperationPermissions.Create));
            });

            CancelCommand = new ActionCommand <object>(obj =>
            {
                var dataForm = obj as RadDataForm;
                if (dataForm == null)
                {
                    return;
                }

                CheckCancel(cancel =>
                {
                    if (cancel)
                    {
                        dataForm.CancelEdit();
                        Error     = false;
                        ApiError  = false;
                        IsEditing = false;
                        UpdateCommandsCanExecuteStatus();
                    }
                });
            }, obj => IsEditing);

            BeginEditCommand = new ActionCommand <object>(obj =>
            {
                var dataForm = obj as RadDataForm;
                if (dataForm != null)
                {
                    dataForm.BeginEdit();
                }
            }, obj => false);

            AddCommand = new ActionCommand <object>(obj =>
            {
                var dataForm = obj as RadDataForm;
                if (dataForm != null)
                {
                    dataForm.AddNewItem();
                }
            }, obj => false);

            DeleteCommand = new ActionCommand <object>(obj =>
            {
                var currentItem   = PagedEmployeeApprovalViewCollection.CurrentItem as EmployeeApproval;
                var description   = currentItem != null ? currentItem.Description : string.Empty;
                var dialogMessage = UIResources.Resources.Global_DeleteMessage + description + "?";
                var dialogService = GSPApplicationService.Current.DeploymentService.Container.GetExportedValue <IDialogService>();

                dialogService.ShowDialog(UIResources.Resources.Global_DeleteQuestion, dialogMessage, true, res =>
                {
                    if (!res)
                    {
                        return;
                    }

                    var dataForm = obj as RadDataForm;
                    Action dataFormDeleteAction = () => { dataForm.DeleteItem(); };

                    if (currentItem != null)
                    {
                        HandleDelete(currentItem, dataFormDeleteAction);
                    }
                });
            }, obj => false);
        }
Exemple #10
0
 /// <summary>
 /// Called when sub topic edit is enabled.
 /// </summary>
 private void OnEnableEditSubtopic()
 {
     ClearErrors(() => SubtopicName);
     Reset(false);
     CommitCommand.RaiseCanExecuteChanged();
 }