Skip to content
Snippets Groups Projects
Commit 0a78ecfd authored by srosse's avatar srosse
Browse files

OO-3345: add the possibility to set an other date chooser as default value

parent 76853fb4
No related branches found
No related tags found
No related merge requests found
......@@ -31,7 +31,7 @@ import java.util.Date;
* @author patrickb
*
*/
public interface DateChooser extends TextElement{
public interface DateChooser extends TextElement {
/**
* @return the date or null if the value is not valid (parsed with
......@@ -62,5 +62,16 @@ public interface DateChooser extends TextElement{
public void setValidDateCheck(String errorKey);
public String getExampleDateString();
public DateChooser getDefaultValue();
/**
* Set an other date chooser as default value for this
* chooser.
*
* @param dateChooser A date chooser
*/
public void setDefaultValue(DateChooser dateChooser);
}
\ No newline at end of file
......@@ -42,8 +42,6 @@ import org.olat.core.util.ValidationStatus;
import org.olat.core.util.ValidationStatusImpl;
/**
* Description:<br>
* TODO: patrickb Class Description for JSDateChooser
* <P>
* Initial Date: 19.01.2007 <br>
*
......@@ -65,7 +63,9 @@ public class JSDateChooser extends TextElementImpl implements DateChooser {
private boolean dateChooserTimeEnabled;
private String forValidDateErrorKey;
private boolean checkForValidDate;
private int minute, hour;
private int minute;
private int hour;
private DateChooser defaultDateValue;
public JSDateChooser(String name, Locale locale) {
this(null, name, null, locale);
......@@ -111,6 +111,16 @@ public class JSDateChooser extends TextElementImpl implements DateChooser {
return dateComponent;
}
@Override
public DateChooser getDefaultValue() {
return defaultDateValue;
}
@Override
public void setDefaultValue(DateChooser dateChooser) {
defaultDateValue = dateChooser;
}
/**
* @see org.olat.core.gui.components.form.flexible.elements.AbstractTextElement#validate(java.util.List)
*/
......
......@@ -35,9 +35,6 @@ import org.olat.core.gui.render.ValidationResult;
import org.olat.core.gui.translator.Translator;
/**
* Description:<br>
* TODO: patrickb Class Description for JSDateChooserComponent
*
* <P>
* Initial Date: 19.01.2007 <br>
*
......@@ -45,7 +42,7 @@ import org.olat.core.gui.translator.Translator;
*/
class JSDateChooserComponent extends FormBaseComponentImpl {
private final static ComponentRenderer RENDERER = new JSDateChooserRenderer();
private static final ComponentRenderer RENDERER = new JSDateChooserRenderer();
private JSDateChooser element;
public JSDateChooserComponent(JSDateChooser element) {
......@@ -104,4 +101,8 @@ class JSDateChooserComponent extends FormBaseComponentImpl {
public String getExampleDateString() {
return element.getExampleDateString();
}
public JSDateChooser getFormItem() {
return element;
}
}
......@@ -40,8 +40,6 @@ import org.olat.core.gui.translator.Translator;
import org.olat.core.util.Util;
/**
* Description:<br>
* TODO: patrickb Class Description for JSDateChooserRenderer
* <P>
* Initial Date: 19.01.2007 <br>
*
......@@ -87,7 +85,7 @@ class JSDateChooserRenderer extends DefaultComponentRenderer {
.append("></i></span>")
.append("</div></div>");//input-group
// date chooser javascript
sb.append("<script type=\"text/javascript\">\n /* <![CDATA[ */ \n")
sb.append("<script>\n /* <![CDATA[ */ \n")
.append("jQuery(function(){ jQuery('#").append(receiverId).append("').datepicker({\n")
.append(" dateFormat:'").append(format).append("',\n")
.append(" firstDay:1,\n")
......@@ -114,11 +112,18 @@ class JSDateChooserRenderer extends DefaultComponentRenderer {
.append("'").append(dateTranslator.translate("day.short.fr")).append("',")
.append("'").append(dateTranslator.translate("day.short.sa")).append("'")
.append("],\n")
.append(" showOtherMonths:true,\n")
.append(" onSelect:function(){\n")
.append(" setFlexiFormDirty('").append(te.getRootForm().getDispatchFieldId()).append("');\n")
.append(" jQuery(this).change();\n")
.append(" }\n")
.append(" showOtherMonths:true,\n");
if(jsdcc.getFormItem().getDefaultValue() != null) {
String id = ((JSDateChooser)jsdcc.getFormItem().getDefaultValue()).getTextElementComponent().getFormDispatchId();
sb.append(" beforeShow:function(el, inst) {\n")
.append(" var defDate = jQuery('#").append(id).append("').datepicker('getDate');\n")
.append(" jQuery('#").append(receiverId).append("').datepicker('option', 'defaultDate', defDate);")
.append(" },\n");
}
sb.append(" onSelect:function(){\n")
.append(" setFlexiFormDirty('").append(te.getRootForm().getDispatchFieldId()).append("');\n")
.append(" jQuery(this).change();\n")
.append(" }\n")
.append("})});")
.append("\n/* ]]> */ \n</script>");
......
......@@ -196,6 +196,7 @@ public class AssessmentModeEditController extends FormBasicController {
endEl = uifactory.addDateChooser("mode.end", assessmentMode.getEnd(), formLayout);
endEl.setElementCssClass("o_sel_assessment_mode_end");
endEl.setDateChooserTimeEnabled(true);
endEl.setDefaultValue(beginEl);
endEl.setMandatory(true);
endEl.setEnabled(status != Status.end);
......@@ -606,7 +607,7 @@ public class AssessmentModeEditController extends FormBasicController {
//update groups
if(groupKeys.isEmpty()) {
if(assessmentMode.getGroups().size() > 0) {
if(!assessmentMode.getGroups().isEmpty()) {
assessmentMode.getGroups().clear();
}
} else {
......@@ -631,7 +632,7 @@ public class AssessmentModeEditController extends FormBasicController {
//update areas
if(areaKeys.isEmpty()) {
if(assessmentMode.getAreas().size() > 0) {
if(!assessmentMode.getAreas().isEmpty()) {
assessmentMode.getAreas().clear();
}
} else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment