Skip to content

Commit ba48f01

Browse files
authored
Merge pull request #392 from tze088/dg-updates
Dg updates
2 parents e568329 + 21fa168 commit ba48f01

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

docs/DeveloperGuide.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,22 @@ A `Group` has:
178178

179179
and are stored in a single `UniqueGroupList` within an `AddressBook`.
180180

181+
#### Group Methods and Responsibilities
182+
The `Group` class is responsible for managing its internal members and events, but it does not directly modify the global contact list or other global data. Instead, it ensures internal consistency within the group. Synchronisation with global data is handled by higher-level methods elsewhere in the application.
183+
184+
##### Internal lists and modification
185+
The internal lists (persons and events) are not exposed except as read-only `ObservableList`s. The only way to modify the group’s state is through its methods such as: `addPerson`, `removePerson`, `addEvent`, and `removeEvent`.
186+
187+
##### Factory and update methods
188+
* `Group.fromStorage`: A factory method used to create a new `Group` from input data (e.g., event list, person list, dashboard). This method is intended to be used only by specific methods and is not typically used for new groups, which should start with empty fields (except for the group name).
189+
190+
* `Group#withUpdatedName`: Returns a new `Group` with copied internal data but a different name. This method is used in commands like edit-group.
191+
* This approach ensures that changes are explicit, preventing unintended side effects and making state management more predictable.
192+
* While containers like lists or dashboards are copied to avoid modifying the original state, immutable elements are reused to optimize memory.
193+
194+
##### Why This Design?
195+
This approach ensures that the `Group` class focuses solely on managing its own data, while global data (like contacts) is updated through methods in the `Model` layer. It keeps the system modular and reduces the risk of unintended side effects.
196+
181197
#### Key Components
182198
##### Unique Lists
183199
The implementation of `UniqueGroupList` and `UniqueEventList` follow the `UniquePersonList` pattern - that is, they are wrappers on an `ObservableList` which prevent the addition of duplicate entries.
@@ -201,7 +217,7 @@ To maintain the integrity of the application, the following invariants must be r
201217
* Use Existing High-Level Methods (e.g., `Model#setPerson`): To modify a person’s details, always use the existing method `Model#setPerson`. This method ensures updates are properly synchronised across the model. Avoid manually calling lower-level methods like `UniquePersonList#setPerson`.
202218
* Note: setPerson is a well-implemented method and serves as a good example for handling updates. While the codebase isn't fully consistent, use similar methods for other objects when available, or manually ensure synchronisation when necessary.
203219

204-
The immutability of Persons and Events allows for future implementation of features such as:
220+
The immutability of Persons and Events simplifies the future implementation of features such as:
205221

206222
* **State Saving:** Enabling features like undo/redo.
207223

@@ -304,6 +320,25 @@ The following activity diagram summarizes what happens when a user executes a ne
304320
## **Planned Enhancements**
305321
Team size: 5
306322

323+
1. **Improve text wrapping behaviour in dashboard:**
324+
The current dashboard GUI element does not properly wrap text for long member or event entries.
325+
As a result, users must manually scroll horizontally to see the entire entry.
326+
We plan to implement automatic text wrapping to improve the readability of these entries, ensuring that all content is visible without the need for horizontal scrolling.
327+
2. **Fix vertical scrolling issue in Event list GUI (Group card):**
328+
Currently, the Event list GUI sub-element in the Group card doesn’t handle long event strings properly.
329+
When the event string is too long, text wrapping causes the list to scroll vertically, instead of expanding as expected.
330+
We plan to fix this by ensuring the event list expands horizontally to accommodate long text without forcing vertical scrolling.
331+
3. **Clarify event index error message:**
332+
Currently, for commands using the event-index prefix, the error message does not specify if the event index is incorrect.
333+
Instead, it generically states: "Index is not a non-zero unsigned integer." This could be confusing, especially when the command also uses a group index, as users wouldn’t know which index is causing the error.
334+
We’ll update it to "Event index is not a non-zero unsigned integer" to clearly specify which index is invalid when both event and group indexes are used.
335+
4. **Improve error message for index parsing in command preamble (Contact command):**
336+
Currently, index parsing errors in the command preamble (for contact-related commands) result in a generic command usage message.
337+
We will update this behavior to specify that the contact index is invalid (if non-empty) with the message "Contact index is not a non-zero unsigned integer", making the error message more informative.
338+
5. **Improve error message for index parsing in command preamble (Group command):**
339+
Currently, index parsing errors in the command preamble (for group-related commands) result in a generic command usage message.
340+
We will update this behavior to specify that the group index is invalid (if non-empty) with the message "Group index is not a non-zero unsigned integer", making the error message more informative.
341+
307342

308343
--------------------------------------------------------------------------------------------------------------------
309344

src/main/java/seedu/address/model/event/UniqueEventList.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public void setEvent(Event target, Event edited) {
6060
internalList.set(index, edited);
6161
}
6262

63+
public void setEvents(UniqueEventList replacement) {
64+
requireNonNull(replacement);
65+
internalList.setAll(replacement.internalList);
66+
}
67+
6368
/**
6469
* Removes an {@code Event} from the list.
6570
* The {@code Event} must already exist in the list.

src/main/java/seedu/address/model/group/Group.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,14 @@ public static Group fromStorage(GroupName name, UniqueEventList events, UniquePe
8080
public Group withUpdatedName(GroupName newName) {
8181
requireNonNull(newName);
8282

83-
return new Group(newName, events, persons, repoLink, dashboard);
83+
UniqueEventList newEvents = new UniqueEventList();
84+
newEvents.setEvents(this.events);
85+
UniquePersonList newPersons = new UniquePersonList();
86+
newPersons.setPersons(this.persons);
87+
88+
Group newGroup = new Group(newName, newEvents, newPersons, repoLink);
89+
newGroup.setDashboard(dashboard.getNotes());
90+
return newGroup;
8491
}
8592

8693
public GroupName getName() {

0 commit comments

Comments
 (0)