Exemple #1
0
        public UserScreenViewModel()
        {
            Editor = new EditorViewModel <UserVM>(controller.Users.Select(u => CreateVM(u)),
                                                  "Выберите пользователя:",
                                                  () =>
            {
                var ent = controller.CreateUser();
                return(CreateVM(ent));
            });
            Buttons = new AddButtonsViewModel <UserVM>(OnAddRoles, "+ роли", OnAddAbilities, "+ возможности");

            Editor.PropertyChanged      += Editor_PropertyChanged;
            controller.UserRolesChanged += (s, e1) =>
            {
                SetupUserRoles();
                SetupRoleAbilities();
            };
            controller.UserAbilitiesChanged += (s, e1) =>
            {
                SetupRoleAbilities();
            };
            // возможности в роли не меняются
            controller.DeprecatedChanged += (s, e1) =>
            {
                if (e1.entity == CurrentEntity.user)
                {
                    CurrentEntity.OnDeprecatedChangedByCode();
                }
            };

            AfterConstructed();
        }
Exemple #2
0
        public AbilityScreenViewModel()
        {
            Editor = new EditorViewModel <AbilityVM>(controller.Abilities.Select(r => CreateVM(r)),
                                                     "Выберите возможность:",
                                                     () =>
            {
                var ent = controller.CreateAbility();
                return(CreateVM(ent));
            });
            Buttons = new AddButtonsViewModel <AbilityVM>(OnAddUsers, "+ пользователи", OnAddRoles, "+ роли");
            Editor.PropertyChanged += Editor_PropertyChanged;

            controller.UserRolesChanged += (s, e1) =>
            {
                SetupAbilityUsers(); // на случай автодобавления роли при добавлении возможности
                SetupUserRoles();
            };
            controller.UserAbilitiesChanged += (s, e1) =>
            {
                SetupAbilityUsers();
                SetupUserRoles();
            };
            controller.RoleAbilitiesChanged += (s, e1) =>
            {
                SetupAbilityUsers(); // если вариант проще
                SetupUserRoles();
            };
            controller.DeprecatedChanged += (s, e1) =>
            {
                if (e1.entity == CurrentEntity.ability)
                {
                    CurrentEntity.OnDeprecatedChangedByCode();
                }
            };
            PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "Mode")
                {
                    SetupUserRoles();
                }
            };

            AfterConstructed();
        }
Exemple #3
0
        public RoleScreenViewModel()
        {
            Editor = new EditorViewModel <RoleVM>(controller.Roles.Select(r => CreateVM(r)),
                                                  "Выберите роль:",
                                                  () =>
            {
                var ent = controller.CreateRole();
                return(CreateVM(ent));
            });
            Buttons = new AddButtonsViewModel <RoleVM>(OnAddAbilities, "+ возможности", OnAddUsers, "+ пользователи");
            Editor.PropertyChanged      += Editor_PropertyChanged;
            controller.UserRolesChanged += (s, e1) =>
            {
                SetupAbilityUsers();
            };
            controller.UserAbilitiesChanged += (s, e1) =>
            {
                SetupAbilityUsers();
            };
            controller.RoleAbilitiesChanged += (s, e1) =>
            {
                SetupRoleAbilities();
                SetupAbilityUsers();
            };
            controller.DeprecatedChanged += (s, e1) =>
            {
                if (e1.entity == CurrentEntity.role)
                {
                    CurrentEntity.OnDeprecatedChangedByCode();
                }
            };
            PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "Mode")
                {
                    SetupAbilityUsers();
                }
            };

            AfterConstructed();
        }