Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/28/18 09:48:33 (6 years ago)
Author:
jzenisek
Message:

#2839: updated setting enabled state of controls in project view

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs

    r16072 r16089  
    111111      base.SetEnabledStateOfControls();
    112112      bool selectedProjectExists = selectedProject != null && selectedProject.Id != Guid.Empty && Content.Contains(selectedProject);
     113      bool projectIsNew = selectedProject != null && selectedProject.Id == Guid.Empty;
    113114      bool locked = Content == null || selectedProject == null || Locked || ReadOnly;
    114115      bool parentOwner = HiveAdminClient.Instance.CheckOwnershipOfParentProject(selectedProject, UserInformation.Instance.User.Id);
    115116      bool saveLocked = locked || (!IsAdmin() && selectedProject.OwnerUserId != UserInformation.Instance.User.Id && !parentOwner);
    116       bool addLocked = saveLocked || selectedProject.Id == Guid.Empty;
     117      bool addLocked = saveLocked || projectIsNew || selectedProject.Id == Guid.Empty;
    117118      bool deleteLocked = locked || (!IsAdmin() && !parentOwner) || Content.Where(x => x.ParentProjectId == selectedProject.Id).Any();
     119
     120      var now = DateTime.Now;
     121      if (!addLocked && (now < selectedProject.StartDate || now > selectedProject.EndDate)) addLocked = true;
    118122
    119123      addButton.Enabled = !addLocked;
     
    124128      projectResourcesView.Enabled = !locked;
    125129      projectJobsView.Enabled = !locked;
     130
     131      projectView.Locked = locked;
     132      projectPermissionsView.Locked = locked;
     133      projectResourcesView.Locked = locked;
     134      projectJobsView.Locked = locked;
    126135    }
    127136    #endregion
     
    504513      projectResourcesView.Content = project;
    505514      projectJobsView.Content = project;
    506 
    507       bool projectIsNew = project != null && project.Id == Guid.Empty;
    508       bool locked = project == null || projectIsNew;
    509 
    510       // if the project is new, or:
    511       // the project does have any descendant projects and
    512       // the user is an admin or owner of a parent project
    513       bool deleteEnabled = project != null && (
    514         projectIsNew
    515         ||  (!HiveAdminClient.Instance.ProjectDescendants[project.Id].Any()
    516               && (HiveAdminClient.Instance.CheckOwnershipOfParentProject(project, UserInformation.Instance.User.Id)
    517               || IsAdmin())
    518             )
    519       );
    520 
    521       bool addEnabled = !locked;
    522       if(addEnabled) {
    523         var now = DateTime.Now;
    524         if (now < project.StartDate || now > project.EndDate) addEnabled = false;
    525       }
    526 
    527       bool saveEnabled = project != null;
    528       if (!IsAdmin() && !project.ParentProjectId.HasValue) saveEnabled = false;
    529 
    530       addButton.Enabled = addEnabled;
    531       removeButton.Enabled = deleteEnabled;
    532       saveProjectButton.Enabled = saveEnabled;
    533       projectPermissionsView.Locked = locked;
    534       projectResourcesView.Locked = locked;
    535       projectJobsView.Locked = locked;
    536515      selectedProject = project;
     516      SetEnabledStateOfControls();
    537517    }
    538518
Note: See TracChangeset for help on using the changeset viewer.