Skip to content

Commit

Permalink
Multiple Class Setup: Date Pattern
Browse files Browse the repository at this point in the history
- corrected the name of the default date pattern when a date pattern is set on the scheduling subpart
  • Loading branch information
tomas-muller committed Jul 22, 2024
1 parent d067114 commit a0ec316
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.unitime.timetable.gwt.shared.ClassSetupInterface.ClassLine;
import org.unitime.timetable.gwt.shared.ClassSetupInterface.ClassSetupColumn;
import org.unitime.timetable.gwt.shared.ClassSetupInterface.Reference;
import org.unitime.timetable.gwt.shared.ClassSetupInterface.Subpart;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
Expand Down Expand Up @@ -622,6 +623,9 @@ public void onChange(ChangeEvent event) {
final MyListBox datePattern = new MyListBox(14000);
datePattern.setWidth("150px");
datePattern.addStyleName("class-date-pattern");
Subpart subpart = iData.getSubpart(line.getSubpartId());
datePattern.addItem(MESSAGES.dropDefaultDatePattern() + (subpart != null && subpart.hasDefaultDatePatternName() ? " (" + subpart.getDefaultDatePatternName() + ")" : ""), "-1");
if (line.getDatePatternId() == null) datePattern.setSelectedIndex(0);
for (Reference d: iData.getDatePatterns()) {
if (d.isSelectable() || d.getId().equals(line.getDatePatternId()))
datePattern.addItem(d.getLabel(), d.getId().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class ClassSetupInterface implements IsSerializable, Serializable, GwtRpc
private List<Reference> iInstructionalMethods;
private List<Reference> iLMSs;
private List<Reference> iDatePatterns;
private List<Reference> iSubparts;
private List<Subpart> iSubparts;

private Long iConfigId;
private Integer iLimit;
Expand Down Expand Up @@ -152,15 +152,15 @@ public Reference getDatePattern(Long id) {
return null;
}

public void addSubpart(Long id, String ref, String label) {
if (iSubparts == null) iSubparts = new ArrayList<Reference>();
iSubparts.add(new Reference(id, ref, label, true));
public void addSubpart(Long id, String ref, String label, String defaultDatePatternName) {
if (iSubparts == null) iSubparts = new ArrayList<Subpart>();
iSubparts.add(new Subpart(id, ref, label, true, defaultDatePatternName));
}
public boolean hasSubparts() { return iSubparts != null && !iSubparts.isEmpty(); }
public List<Reference> getSubparts() { return iSubparts; }
public Reference getSubpart(Long id) {
public List<Subpart> getSubparts() { return iSubparts; }
public Subpart getSubpart(Long id) {
if (iSubparts == null || id == null) return null;
for (Reference ref: iSubparts)
for (Subpart ref: iSubparts)
if (ref.getId().equals(id)) return ref;
return null;
}
Expand Down Expand Up @@ -556,6 +556,21 @@ public String toString() {
}
}

public static class Subpart extends Reference implements IsSerializable, Serializable {
private static final long serialVersionUID = 5252024032132689730L;
private String iDefaultDatePatternName;

public Subpart() { super(); }
public Subpart(Long id, String ref, String label, boolean selectable, String defaultDatePatternName) {
super(id, ref, label, selectable);
iDefaultDatePatternName = defaultDatePatternName;
}

public String getDefaultDatePatternName() { return iDefaultDatePatternName; }
public boolean hasDefaultDatePatternName() { return iDefaultDatePatternName != null && !iDefaultDatePatternName.isEmpty(); }
public void setDefaultDatePatternName(String defaultDatePatternName) { iDefaultDatePatternName = defaultDatePatternName; }
}

public static enum ClassSetupColumn {
ERROR,
CLASS_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ protected ClassSetupInterface load(ClassSetupInterface request, SessionContext c
for (SchedulingSubpart ss: subparts) {
if (ss.getClasses() == null || ss.getClasses().isEmpty())
throw new GwtRpcException(MSG.errorInitialIOSetupIncomplete());
form.addSubpart(ss.getUniqueId(), ss.getItype().getAbbv(), ss.getItype().getDesc());
DatePattern dp = ss.effectiveDatePattern();
form.addSubpart(ss.getUniqueId(), ss.getItype().getAbbv(), ss.getItype().getDesc(), dp == null ? null : dp.getName());
if (ss.getParentSubpart() == null)
loadClasses(form, ss.getClasses(), true, 0, proxy, context);
}
Expand Down Expand Up @@ -180,8 +181,6 @@ protected ClassSetupInterface load(ClassSetupInterface request, SessionContext c
form.addInstructionalMethod(type.getUniqueId(), type.getReference(), type.getLabel());
}

DatePattern dpDefault = io.getSession().getDefaultDatePatternNotNull();
form.addDatePattern(-1l, MSG.dropDefaultDatePattern(), MSG.dropDefaultDatePattern() + (dpDefault == null ? "" : " (" + dpDefault.getName() + ")"), true);
try {
for (DatePattern dp: DatePattern.findAll(context.getUser(), io.getDepartment(), io.getSession().getDefaultDatePatternNotNull()))
form.addDatePattern(dp.getUniqueId(), dp.getName(), dp.getName(), !dp.isExtended());
Expand Down
9 changes: 9 additions & 0 deletions WebContent/help/Release-Notes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@
<release>
<version>4.8.${build.number}</version>
<release-date>${build.date}</release-date>
<category>
<title>Course Timetabling</title>
<item>
<name>Multiple Class Setup</name>
<description>
<line>Date Pattern: Corrected the name of the default date pattern when a date pattern is set on the scheduling subpart.</line>
</description>
</item>
</category>
<category>
<title>Student Scheduling</title>
<item>
Expand Down

0 comments on commit a0ec316

Please sign in to comment.