Changeset 16043 for branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views
- Timestamp:
- 08/03/18 13:50:29 (6 years ago)
- Location:
- branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.Designer.cs
r15953 r16043 153 153 this.startDateTimePicker.Size = new System.Drawing.Size(200, 20); 154 154 this.startDateTimePicker.TabIndex = 9; 155 this.startDateTimePicker.ValueChanged += new System.EventHandler(this.startDateTimePicker_ValueChanged); 155 this.startDateTimePicker.ValueChanged += new System.EventHandler(this.startDateTimePicker_ValueChanged); 156 156 // 157 157 // startLabel -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.cs
r16040 r16043 67 67 } 68 68 69 protected void RegisterControlEvents() { 70 nameTextBox.TextChanged += nameTextBox_TextChanged; 71 nameTextBox.Validating += nameTextBox_Validating; 72 descriptionTextBox.TextChanged += descriptionTextBox_TextChanged; 73 ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged; 74 startDateTimePicker.ValueChanged += startDateTimePicker_ValueChanged; 75 endDateTimePicker.ValueChanged += endDateTimePicker_ValueChanged; 76 indefiniteCheckBox.CheckedChanged += indefiniteCheckBox_CheckedChanged; 77 } 78 79 protected void DeregisterControlEvents() { 80 nameTextBox.TextChanged -= nameTextBox_TextChanged; 81 nameTextBox.Validating -= nameTextBox_Validating; 82 descriptionTextBox.TextChanged -= descriptionTextBox_TextChanged; 83 ownerComboBox.SelectedIndexChanged -= ownerComboBox_SelectedIndexChanged; 84 startDateTimePicker.ValueChanged -= startDateTimePicker_ValueChanged; 85 endDateTimePicker.ValueChanged -= endDateTimePicker_ValueChanged; 86 indefiniteCheckBox.CheckedChanged -= indefiniteCheckBox_CheckedChanged; 87 } 88 69 89 protected override void OnContentChanged() { 70 90 base.OnContentChanged(); 91 DeregisterControlEvents(); 71 92 if (Content == null) { 72 93 idTextBox.Clear(); … … 98 119 endDateTimePicker.Enabled = !indefiniteCheckBox.Checked; 99 120 } 121 RegisterControlEvents(); 100 122 } 101 123 … … 112 134 indefiniteCheckBox.Enabled = enabled; 113 135 114 if (!IsAdmin() && !HiveAdminClient.Instance.CheckOwnershipOfParentProject(Content, UserInformation.Instance.User.Id)) { 115 ownerComboBox.Enabled = false; 116 startDateTimePicker.Enabled = false; 117 endDateTimePicker.Enabled = false; 118 indefiniteCheckBox.Enabled = false; 119 } 136 if(Content != null) { 137 var parentProject = HiveAdminClient.Instance.GetAvailableProjectAncestors(Content.Id).LastOrDefault(); 138 if (parentProject == null || parentProject.EndDate.HasValue) { 139 indefiniteCheckBox.Enabled = false; 140 } 141 142 if (!IsAdmin() && !HiveAdminClient.Instance.CheckOwnershipOfParentProject(Content, UserInformation.Instance.User.Id)) { 143 ownerComboBox.Enabled = false; 144 startDateTimePicker.Enabled = false; 145 endDateTimePicker.Enabled = false; 146 indefiniteCheckBox.Enabled = false; 147 } 148 } 120 149 } 121 150 #endregion … … 187 216 188 217 private void nameTextBox_TextChanged(object sender, EventArgs e) { 189 if (Content != null && Content.Name != nameTextBox.Text) 218 if (Content != null && Content.Name != nameTextBox.Text) { 219 DeregisterContentEvents(); 190 220 Content.Name = nameTextBox.Text; 221 RegisterContentEvents(); 222 } 191 223 } 192 224 193 225 private void descriptionTextBox_TextChanged(object sender, EventArgs e) { 194 if (Content != null && Content.Description != descriptionTextBox.Text) 226 if (Content != null && Content.Description != descriptionTextBox.Text) { 227 DeregisterContentEvents(); 195 228 Content.Description = descriptionTextBox.Text; 229 RegisterContentEvents(); 230 } 196 231 } 197 232 … … 199 234 var selectedItem = (LightweightUser)ownerComboBox.SelectedItem; 200 235 var selectedOwnerUserId = selectedItem != null ? selectedItem.Id : Guid.Empty; 201 if (Content != null && Content.OwnerUserId != selectedOwnerUserId) 236 if (Content != null && Content.OwnerUserId != selectedOwnerUserId) { 237 DeregisterContentEvents(); 202 238 Content.OwnerUserId = selectedOwnerUserId; 239 RegisterContentEvents(); 240 } 203 241 } 204 242 205 243 private void startDateTimePicker_ValueChanged(object sender, EventArgs e) { 206 244 if (Content == null) return; 207 245 startDateTimePicker.ValueChanged -= startDateTimePicker_ValueChanged; 246 247 if (!IsAdmin()) { 248 var parentProject = HiveAdminClient.Instance.GetAvailableProjectAncestors(Content.Id).LastOrDefault(); 249 if (parentProject != null) { 250 if(startDateTimePicker.Value < parentProject.StartDate) 251 startDateTimePicker.Value = parentProject.StartDate; 252 } else { 253 startDateTimePicker.Value = Content.StartDate; 254 } 255 } 256 208 257 if (!Content.EndDate.HasValue || startDateTimePicker.Value > Content.EndDate) 209 258 endDateTimePicker.Value = startDateTimePicker.Value; 210 if (Content.StartDate != startDateTimePicker.Value) 259 if (Content.StartDate != startDateTimePicker.Value) { 260 DeregisterContentEvents(); 211 261 Content.StartDate = startDateTimePicker.Value; 262 RegisterContentEvents(); 263 } 264 265 startDateTimePicker.ValueChanged += startDateTimePicker_ValueChanged; 212 266 } 213 267 214 268 private void endDateTimePicker_ValueChanged(object sender, EventArgs e) { 215 269 if (Content == null) return; 270 endDateTimePicker.ValueChanged -= endDateTimePicker_ValueChanged; 271 272 if (!IsAdmin()) { 273 var parentProject = HiveAdminClient.Instance.GetAvailableProjectAncestors(Content.Id).LastOrDefault(); 274 if (parentProject != null) { 275 if (parentProject.EndDate.HasValue && endDateTimePicker.Value > parentProject.EndDate.Value) { 276 endDateTimePicker.Value = parentProject.EndDate.Value; 277 } 278 } else if(Content.EndDate.HasValue) { 279 endDateTimePicker.Value = Content.EndDate.Value; 280 } 281 } 216 282 217 283 if (endDateTimePicker.Value < startDateTimePicker.Value) 218 284 endDateTimePicker.Value = startDateTimePicker.Value; 219 if (Content.EndDate != endDateTimePicker.Value) 285 if (Content.EndDate != endDateTimePicker.Value) { 286 DeregisterContentEvents(); 220 287 Content.EndDate = endDateTimePicker.Value; 288 RegisterContentEvents(); 289 } 290 291 endDateTimePicker.ValueChanged += endDateTimePicker_ValueChanged; 221 292 } 222 293 -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs
r16040 r16043 197 197 } 198 198 199 private void addButton_Click(object sender, EventArgs e) { 200 Guid? parentProjectId = null; 201 202 if(selectedProject == null && !IsAdmin()) { 199 private void addButton_Click(object sender, EventArgs e) { 200 201 if (selectedProject == null && !IsAdmin()) { 203 202 MessageBox.Show( 204 203 "You are not allowed to add a root project - please select a parent project.", … … 218 217 } 219 218 220 if (selectedProject != null) parentProjectId = selectedProject.Id;221 219 var project = new Project { 222 220 Name = "New Project", 223 OwnerUserId = UserInformation.Instance.User.Id, 224 ParentProjectId = parentProjectId 221 OwnerUserId = UserInformation.Instance.User.Id, 225 222 }; 223 if(selectedProject != null) { 224 project.ParentProjectId = selectedProject.Id; 225 project.EndDate = selectedProject.EndDate; 226 } 226 227 227 228 SelectedProject = project; … … 508 509 509 510 bool addEnabled = !locked; 510 if (!IsAdmin() && project == null) addEnabled = false; 511 if(addEnabled) { 512 var now = DateTime.Now; 513 if (now < project.StartDate || now > project.EndDate) addEnabled = false; 514 } 511 515 512 516 bool saveEnabled = project != null;
Note: See TracChangeset
for help on using the changeset viewer.