- Timestamp:
- 07/10/18 23:06:00 (6 years ago)
- Location:
- branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.cs
r15966 r15992 82 82 nameTextBox.Text = Content.Name; 83 83 descriptionTextBox.Text = Content.Description; 84 ownerComboBox.SelectedItem = AccessClient.Instance.UsersAndGroups.FirstOrDefault(x => x.Id == Content.OwnerUserId); 84 85 ownerComboBox.SelectedIndexChanged -= ownerComboBox_SelectedIndexChanged; 86 var users = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>(); 87 if (!Content.ParentProjectId.HasValue) users = users.Where(x => x.Roles.Select(y => y.Name).Contains(HiveRoles.Administrator)); 88 ownerComboBox.DataSource = users.ToList(); 89 ownerComboBox.SelectedItem = users.FirstOrDefault(x => x.Id == Content.OwnerUserId); 90 ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged; 91 85 92 createdTextBox.Text = Content.DateCreated.ToString("ddd, dd.MM.yyyy, HH:mm:ss"); 86 93 startDateTimePicker.Value = Content.StartDate; … … 135 142 finallyCallback: () => { 136 143 ownerComboBox.SelectedIndexChanged -= ownerComboBox_SelectedIndexChanged; 137 ownerComboBox.DataSource = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>().ToList(); 144 var users = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>(); 145 if (Content != null && !Content.ParentProjectId.HasValue) users = users.Where(x => x.Roles.Select(y => y.Name).Contains(HiveRoles.Administrator)); 146 ownerComboBox.DataSource = users.ToList(); 138 147 ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged; 139 148 }); … … 150 159 finallyCallback: () => { 151 160 ownerComboBox.SelectedIndexChanged -= ownerComboBox_SelectedIndexChanged; 152 ownerComboBox.DataSource = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>().ToList(); 153 ownerComboBox.SelectedItem = AccessClient.Instance.UsersAndGroups.FirstOrDefault(x => x.Id == persistedOwnerUserId); 161 var users = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>(); 162 if (Content != null && !Content.ParentProjectId.HasValue) users = users.Where(x => x.Roles.Select(y => y.Name).Contains(HiveRoles.Administrator)); 163 ownerComboBox.DataSource = users.ToList(); 164 ownerComboBox.SelectedItem = users.FirstOrDefault(x => x.Id == persistedOwnerUserId); 154 165 ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged; 155 166 refreshButton.Enabled = true; … … 203 214 private void indefiniteCheckBox_CheckedChanged(object sender, EventArgs e) { 204 215 if (Content == null) return; 205 var newEndDate = indefiniteCheckBox.Checked ? (DateTime?)null : Content.StartDate;216 var newEndDate = indefiniteCheckBox.Checked ? (DateTime?)null : endDateTimePicker.Value; 206 217 endDateTimePicker.Enabled = !indefiniteCheckBox.Checked; 207 218 if (Content.EndDate != newEndDate) { 208 219 DeregisterContentEvents(); 209 220 Content.EndDate = newEndDate; 210 endDateTimePicker.Value = newEndDate.HasValue ? newEndDate.Value : Content.StartDate;211 221 RegisterContentEvents(); 212 222 } -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs
r15966 r15992 110 110 bool enabled = Content != null && !Locked && !ReadOnly; 111 111 refreshButton.Enabled = enabled; 112 addButton.Enabled = enabled;113 removeButton.Enabled = enabled;114 saveProjectButton.Enabled = enabled;112 //addButton.Enabled = enabled; 113 //removeButton.Enabled = enabled; 114 //saveProjectButton.Enabled = enabled; 115 115 projectView.Enabled = enabled; 116 116 projectPermissionsView.Enabled = enabled; … … 199 199 Guid? parentProjectId = null; 200 200 201 if(selectedProject == null && !IsAdmin()) { 202 MessageBox.Show( 203 "You are not allowed to add a root project - please select a parent project.", 204 "HeuristicLab Hive Administrator", 205 MessageBoxButtons.OK, 206 MessageBoxIcon.Information); 207 return; 208 } 209 201 210 if (selectedProject != null && selectedProject.Id == Guid.Empty) { 202 211 MessageBox.Show( … … 459 468 bool projectIsNew = project != null && project.Id == Guid.Empty; 460 469 bool locked = project == null || projectIsNew; 470 471 // if the project is new, or: 472 // the project does have any descendant projects and 473 // the user is an admin or owner of a parent project 461 474 bool deleteEnabled = project != null && ( 462 475 projectIsNew 463 || HiveAdminClient.Instance.CheckOwnershipOfParentProject(project, UserInformation.Instance.User.Id) 464 || !HiveAdminClient.Instance.ProjectDescendants[project.Id].Any()); 465 466 addButton.Enabled = !locked; 476 || (!HiveAdminClient.Instance.ProjectDescendants[project.Id].Any() 477 && (HiveAdminClient.Instance.CheckOwnershipOfParentProject(project, UserInformation.Instance.User.Id) 478 || IsAdmin()) 479 ) 480 ); 481 482 bool addEnabled = !locked; 483 if (!IsAdmin() && project == null) addEnabled = false; 484 485 bool saveEnabled = project != null; 486 if (!IsAdmin() && !project.ParentProjectId.HasValue) saveEnabled = false; 487 488 addButton.Enabled = addEnabled; 467 489 removeButton.Enabled = deleteEnabled; 490 saveProjectButton.Enabled = saveEnabled; 468 491 projectPermissionsView.Locked = locked; 469 492 projectResourcesView.Locked = locked;
Note: See TracChangeset
for help on using the changeset viewer.