Chorem-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
June 2012
- 4 participants
- 32 discussions
r178 - in trunk/chorem-webmotion/src/main: java/org/wikitty/web/jsptag webapp/js
by ymartel@users.chorem.org 06 Jun '12
by ymartel@users.chorem.org 06 Jun '12
06 Jun '12
Author: ymartel
Date: 2012-06-06 11:43:14 +0200 (Wed, 06 Jun 2012)
New Revision: 178
Url: http://chorem.org/repositories/revision/chorem/178
Log:
Display a datepicker whith time when needed
Modified:
trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyInput.java
trunk/chorem-webmotion/src/main/webapp/js/jquery-ui-timepicker-addon.js
Modified: trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyInput.java
===================================================================
--- trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyInput.java 2012-06-05 15:25:22 UTC (rev 177)
+++ trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyInput.java 2012-06-06 09:43:14 UTC (rev 178)
@@ -151,7 +151,11 @@
if (date != null) {
value = DateFormatUtils.format(date, "dd/MM/yyyy HH:mm");
}
- /*{<input class="datetimepicker" type="date" name="<%=name%>" value="<%=value%>"<%=getDynamicAttribute()%>/>}*/
+ if ("datetime".equals(field.getTagValue("subtime"))) {
+ /*{<input class="datetimepicker" type="date" name="<%=name%>" value="<%=value%>"<%=getDynamicAttribute()%>/>}*/
+ } else {
+ /*{<input class="datepicker" type="date" name="<%=name%>" value="<%=value%>"<%=getDynamicAttribute()%>/>}*/
+ }
}
protected void inputNumeric(JspWriter output, String contextPath, String name,
Modified: trunk/chorem-webmotion/src/main/webapp/js/jquery-ui-timepicker-addon.js
===================================================================
--- trunk/chorem-webmotion/src/main/webapp/js/jquery-ui-timepicker-addon.js 2012-06-05 15:25:22 UTC (rev 177)
+++ trunk/chorem-webmotion/src/main/webapp/js/jquery-ui-timepicker-addon.js 2012-06-06 09:43:14 UTC (rev 178)
@@ -870,6 +870,9 @@
if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0))
return;
+ // next line added by ymartel on 06/06/12 to display hour in input
+ this.formattedTime = $.datepicker.formatTime(this._defaults.timeFormat, this, this._defaults);
+
if (this._defaults.timeOnly === true) {
formattedDateTime = this.formattedTime;
} else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
1
0
r177 - in trunk/chorem-webmotion/src/main: java/org/chorem/webmotion/actions resources webapp/WEB-INF/jsp
by ymartel@users.chorem.org 05 Jun '12
by ymartel@users.chorem.org 05 Jun '12
05 Jun '12
Author: ymartel
Date: 2012-06-05 17:25:22 +0200 (Tue, 05 Jun 2012)
New Revision: 177
Url: http://chorem.org/repositories/revision/chorem/177
Log:
be abel to add an attachment for a wikitty
Modified:
trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java
trunk/chorem-webmotion/src/main/resources/mapping
trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/view.jsp
Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java
===================================================================
--- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java 2012-06-05 13:54:15 UTC (rev 176)
+++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java 2012-06-05 15:25:22 UTC (rev 177)
@@ -1,15 +1,6 @@
package org.chorem.webmotion.actions;
import com.google.common.collect.LinkedHashMultimap;
-import java.io.ByteArrayInputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.StringUtils;
@@ -17,6 +8,7 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.ChoremClient;
import org.chorem.ChoremConfigOption;
+import org.chorem.entities.Attachment;
import org.debux.webmotion.server.WebMotionController;
import org.debux.webmotion.server.call.Call;
import org.debux.webmotion.server.call.UploadFile;
@@ -32,6 +24,16 @@
import org.nuiton.wikitty.query.WikittyQueryParser;
import org.nuiton.wikitty.query.WikittyQueryResult;
+import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+
/**
*
* @author poussin
@@ -389,6 +391,30 @@
return renderView("edit.jsp", "wikitty", w, "extensions", exts);
}
+ public Render addAttachment(ChoremClient client, String wikittyId) {
+ log.debug("add attachment for : " + wikittyId);
+ Wikitty w = client.restore(wikittyId, ".*");
+
+ Wikitty attachment = new WikittyImpl();
+
+ LinkedHashSet<WikittyExtension> exts = new LinkedHashSet<WikittyExtension>();
+
+ // Load Attachment extension, and potential dependencies
+ List<String> extensionNames = Arrays.asList(Attachment.EXT_ATTACHMENT);
+ List<WikittyExtension> newExts =
+ client.restoreExtensionAndDependenciesLastVesion(extensionNames);
+ attachment.addExtension(newExts);
+
+ // As we want to edit a wikitty by its extensions, we should edit the required extensions too
+ // Add the extension and required ones in the list of extensions to display
+ exts.addAll(newExts);
+ // Show all wikitty if no extension were mentioned
+ exts.addAll(attachment.getExtensions());
+
+ attachment.setField(Attachment.EXT_ATTACHMENT, Attachment.FIELD_ATTACHMENT_TARGET, w);
+ return renderView("edit.jsp", "wikitty", attachment, "extensions", exts);
+ }
+
public Render save(ChoremClient client, String id, String[] extension, Call call) {
log.debug("save: " + id);
Wikitty w = client.restore(id);
Modified: trunk/chorem-webmotion/src/main/resources/mapping
===================================================================
--- trunk/chorem-webmotion/src/main/resources/mapping 2012-06-05 13:54:15 UTC (rev 176)
+++ trunk/chorem-webmotion/src/main/resources/mapping 2012-06-05 15:25:22 UTC (rev 177)
@@ -16,6 +16,7 @@
* /wikitty/{extension}/search action:GenericAction.search
* /wikitty/{extension}/view/{id} action:GenericAction.view
* /wikitty/{extension}/edit/{id} action:GenericAction.edit
+* /wikitty/{wikittyId}/Attachment/edit/new action:GenericAction.addAttachment
* /wikitty/{extension}/delete/{id} action:GenericAction.delete
* /wikitty/search action:GenericAction.search
* /wikitty/searchRelated?id={query} action:GenericAction.search
Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/view.jsp
===================================================================
--- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/view.jsp 2012-06-05 13:54:15 UTC (rev 176)
+++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/view.jsp 2012-06-05 15:25:22 UTC (rev 177)
@@ -20,6 +20,14 @@
</dl>
</c:forEach>
+<p>
+ <c:if test="${not empty wikitty}">
+ <p>
+ <a class="btn btn-success" href="<c:url value="/wikitty/${wikitty.id}/Attachment/edit/new"/>"><i class="icon-plus icon-white"></i> Add Attachment</a>
+ </p>
+ </c:if>
+</p>
+
<div class="container">
<jsp:include page="/wikitty/searchRelated?id=${wikitty.id}"/>
<%--
1
0
r176 - in trunk/chorem-webmotion/src/main: java/org/wikitty/web/jsptag webapp/WEB-INF/jsp webapp/js
by ymartel@users.chorem.org 05 Jun '12
by ymartel@users.chorem.org 05 Jun '12
05 Jun '12
Author: ymartel
Date: 2012-06-05 15:54:15 +0200 (Tue, 05 Jun 2012)
New Revision: 176
Url: http://chorem.org/repositories/revision/chorem/176
Log:
Add a date time picker. TODO : use it only for need
Added:
trunk/chorem-webmotion/src/main/webapp/js/jquery-ui-timepicker-addon.js
trunk/chorem-webmotion/src/main/webapp/js/jquery-ui-timepicker-fr.js
Modified:
trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyInput.java
trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/decorator.jsp
trunk/chorem-webmotion/src/main/webapp/js/chorem.js
Modified: trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyInput.java
===================================================================
--- trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyInput.java 2012-06-05 08:27:48 UTC (rev 175)
+++ trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyInput.java 2012-06-05 13:54:15 UTC (rev 176)
@@ -149,9 +149,9 @@
Date date = wikitty.getFieldAsDate(extName, fieldName);
String value = "";
if (date != null) {
- value = DateFormatUtils.format(date, "dd/MM/yyyy");
+ value = DateFormatUtils.format(date, "dd/MM/yyyy HH:mm");
}
- /*{<input class="datepicker" type="date" name="<%=name%>" value="<%=value%>"<%=getDynamicAttribute()%>/>}*/
+ /*{<input class="datetimepicker" type="date" name="<%=name%>" value="<%=value%>"<%=getDynamicAttribute()%>/>}*/
}
protected void inputNumeric(JspWriter output, String contextPath, String name,
Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/decorator.jsp
===================================================================
--- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/decorator.jsp 2012-06-05 08:27:48 UTC (rev 175)
+++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/decorator.jsp 2012-06-05 13:54:15 UTC (rev 176)
@@ -12,6 +12,8 @@
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://jquery-ui.googlecode.com/svn/trunk/ui/i18n/jquery.ui.datepicker-fr.js"></script>
+ <script type="text/javascript" src="/js/jquery-ui-timepicker-addon.js"></script>
+ <script type="text/javascript" src="/js/jquery-ui-timepicker-fr.js"></script>
<%-- Bootstrap --%>
<link rel="stylesheet" href="/css/bootstrap.min.css">
<link rel="stylesheet" href="/css/bootstrap-responsive.min.css">
Modified: trunk/chorem-webmotion/src/main/webapp/js/chorem.js
===================================================================
--- trunk/chorem-webmotion/src/main/webapp/js/chorem.js 2012-06-05 08:27:48 UTC (rev 175)
+++ trunk/chorem-webmotion/src/main/webapp/js/chorem.js 2012-06-05 13:54:15 UTC (rev 176)
@@ -3,6 +3,11 @@
$( ".datepicker" ).datepicker($.datepicker.regional['fr']);
$( ".datepicker" ).datepicker( "option", "gotoCurrent", true );
});
+// tout ce qui aura la classe datetimepicker servira a editer une date avec heure
+$(function() {
+ $( ".datetimepicker" ).datetimepicker($.timepicker.regional['fr']);
+ $( ".datetimepicker" ).datetimepicker( "option", "gotoCurrent", true );
+});
// nouveau composant pour afficher les wikitties lors de l'edition classe par extension
$.widget( "custom.autocompleteByExtension", $.ui.autocomplete, {
Added: trunk/chorem-webmotion/src/main/webapp/js/jquery-ui-timepicker-addon.js
===================================================================
--- trunk/chorem-webmotion/src/main/webapp/js/jquery-ui-timepicker-addon.js (rev 0)
+++ trunk/chorem-webmotion/src/main/webapp/js/jquery-ui-timepicker-addon.js 2012-06-05 13:54:15 UTC (rev 176)
@@ -0,0 +1,1326 @@
+/*
+* jQuery timepicker addon
+* By: Trent Richardson [http://trentrichardson.com]
+* Version 1.0.0
+* Last Modified: 02/05/2012
+*
+* Copyright 2012 Trent Richardson
+* Dual licensed under the MIT and GPL licenses.
+* http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
+* http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
+*
+* HERES THE CSS:
+* .ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
+* .ui-timepicker-div dl { text-align: left; }
+* .ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
+* .ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
+* .ui-timepicker-div td { font-size: 90%; }
+* .ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
+*/
+
+(function($) {
+
+// Prevent "Uncaught RangeError: Maximum call stack size exceeded"
+$.ui.timepicker = $.ui.timepicker || {};
+if ($.ui.timepicker.version) {
+ return;
+}
+
+$.extend($.ui, { timepicker: { version: "1.0.0" } });
+
+/* Time picker manager.
+ Use the singleton instance of this class, $.timepicker, to interact with the time picker.
+ Settings for (groups of) time pickers are maintained in an instance object,
+ allowing multiple different settings on the same page. */
+
+function Timepicker() {
+ this.regional = []; // Available regional settings, indexed by language code
+ this.regional[''] = { // Default regional settings
+ currentText: 'Now',
+ closeText: 'Done',
+ ampm: false,
+ amNames: ['AM', 'A'],
+ pmNames: ['PM', 'P'],
+ timeFormat: 'hh:mm tt',
+ timeSuffix: '',
+ timeOnlyTitle: 'Choose Time',
+ timeText: 'Time',
+ hourText: 'Hour',
+ minuteText: 'Minute',
+ secondText: 'Second',
+ millisecText: 'Millisecond',
+ timezoneText: 'Time Zone'
+ };
+ this._defaults = { // Global defaults for all the datetime picker instances
+ showButtonPanel: true,
+ timeOnly: false,
+ showHour: true,
+ showMinute: true,
+ showSecond: false,
+ showMillisec: false,
+ showTimezone: false,
+ showTime: true,
+ stepHour: 1,
+ stepMinute: 1,
+ stepSecond: 1,
+ stepMillisec: 1,
+ hour: 0,
+ minute: 0,
+ second: 0,
+ millisec: 0,
+ timezone: '+0000',
+ hourMin: 0,
+ minuteMin: 0,
+ secondMin: 0,
+ millisecMin: 0,
+ hourMax: 23,
+ minuteMax: 59,
+ secondMax: 59,
+ millisecMax: 999,
+ minDateTime: null,
+ maxDateTime: null,
+ onSelect: null,
+ hourGrid: 0,
+ minuteGrid: 0,
+ secondGrid: 0,
+ millisecGrid: 0,
+ alwaysSetTime: true,
+ separator: ' ',
+ altFieldTimeOnly: true,
+ showTimepicker: true,
+ timezoneIso8609: false,
+ timezoneList: null,
+ addSliderAccess: false,
+ sliderAccessArgs: null
+ };
+ $.extend(this._defaults, this.regional['']);
+};
+
+$.extend(Timepicker.prototype, {
+ $input: null,
+ $altInput: null,
+ $timeObj: null,
+ inst: null,
+ hour_slider: null,
+ minute_slider: null,
+ second_slider: null,
+ millisec_slider: null,
+ timezone_select: null,
+ hour: 0,
+ minute: 0,
+ second: 0,
+ millisec: 0,
+ timezone: '+0000',
+ hourMinOriginal: null,
+ minuteMinOriginal: null,
+ secondMinOriginal: null,
+ millisecMinOriginal: null,
+ hourMaxOriginal: null,
+ minuteMaxOriginal: null,
+ secondMaxOriginal: null,
+ millisecMaxOriginal: null,
+ ampm: '',
+ formattedDate: '',
+ formattedTime: '',
+ formattedDateTime: '',
+ timezoneList: null,
+
+ /* Override the default settings for all instances of the time picker.
+ @param settings object - the new settings to use as defaults (anonymous object)
+ @return the manager object */
+ setDefaults: function(settings) {
+ extendRemove(this._defaults, settings || {});
+ return this;
+ },
+
+ //########################################################################
+ // Create a new Timepicker instance
+ //########################################################################
+ _newInst: function($input, o) {
+ var tp_inst = new Timepicker(),
+ inlineSettings = {};
+
+ for (var attrName in this._defaults) {
+ var attrValue = $input.attr('time:' + attrName);
+ if (attrValue) {
+ try {
+ inlineSettings[attrName] = eval(attrValue);
+ } catch (err) {
+ inlineSettings[attrName] = attrValue;
+ }
+ }
+ }
+ tp_inst._defaults = $.extend({}, this._defaults, inlineSettings, o, {
+ beforeShow: function(input, dp_inst) {
+ if ($.isFunction(o.beforeShow))
+ return o.beforeShow(input, dp_inst, tp_inst);
+ },
+ onChangeMonthYear: function(year, month, dp_inst) {
+ // Update the time as well : this prevents the time from disappearing from the $input field.
+ tp_inst._updateDateTime(dp_inst);
+ if ($.isFunction(o.onChangeMonthYear))
+ o.onChangeMonthYear.call($input[0], year, month, dp_inst, tp_inst);
+ },
+ onClose: function(dateText, dp_inst) {
+ if (tp_inst.timeDefined === true && $input.val() != '')
+ tp_inst._updateDateTime(dp_inst);
+ if ($.isFunction(o.onClose))
+ o.onClose.call($input[0], dateText, dp_inst, tp_inst);
+ },
+ timepicker: tp_inst // add timepicker as a property of datepicker: $.datepicker._get(dp_inst, 'timepicker');
+ });
+ tp_inst.amNames = $.map(tp_inst._defaults.amNames, function(val) { return val.toUpperCase(); });
+ tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) { return val.toUpperCase(); });
+
+ if (tp_inst._defaults.timezoneList === null) {
+ var timezoneList = [];
+ for (var i = -11; i <= 12; i++)
+ timezoneList.push((i >= 0 ? '+' : '-') + ('0' + Math.abs(i).toString()).slice(-2) + '00');
+ if (tp_inst._defaults.timezoneIso8609)
+ timezoneList = $.map(timezoneList, function(val) {
+ return val == '+0000' ? 'Z' : (val.substring(0, 3) + ':' + val.substring(3));
+ });
+ tp_inst._defaults.timezoneList = timezoneList;
+ }
+
+ tp_inst.hour = tp_inst._defaults.hour;
+ tp_inst.minute = tp_inst._defaults.minute;
+ tp_inst.second = tp_inst._defaults.second;
+ tp_inst.millisec = tp_inst._defaults.millisec;
+ tp_inst.ampm = '';
+ tp_inst.$input = $input;
+
+ if (o.altField)
+ tp_inst.$altInput = $(o.altField)
+ .css({ cursor: 'pointer' })
+ .focus(function(){ $input.trigger("focus"); });
+
+ if(tp_inst._defaults.minDate==0 || tp_inst._defaults.minDateTime==0)
+ {
+ tp_inst._defaults.minDate=new Date();
+ }
+ if(tp_inst._defaults.maxDate==0 || tp_inst._defaults.maxDateTime==0)
+ {
+ tp_inst._defaults.maxDate=new Date();
+ }
+
+ // datepicker needs minDate/maxDate, timepicker needs minDateTime/maxDateTime..
+ if(tp_inst._defaults.minDate !== undefined && tp_inst._defaults.minDate instanceof Date)
+ tp_inst._defaults.minDateTime = new Date(tp_inst._defaults.minDate.getTime());
+ if(tp_inst._defaults.minDateTime !== undefined && tp_inst._defaults.minDateTime instanceof Date)
+ tp_inst._defaults.minDate = new Date(tp_inst._defaults.minDateTime.getTime());
+ if(tp_inst._defaults.maxDate !== undefined && tp_inst._defaults.maxDate instanceof Date)
+ tp_inst._defaults.maxDateTime = new Date(tp_inst._defaults.maxDate.getTime());
+ if(tp_inst._defaults.maxDateTime !== undefined && tp_inst._defaults.maxDateTime instanceof Date)
+ tp_inst._defaults.maxDate = new Date(tp_inst._defaults.maxDateTime.getTime());
+ return tp_inst;
+ },
+
+ //########################################################################
+ // add our sliders to the calendar
+ //########################################################################
+ _addTimePicker: function(dp_inst) {
+ var currDT = (this.$altInput && this._defaults.altFieldTimeOnly) ?
+ this.$input.val() + ' ' + this.$altInput.val() :
+ this.$input.val();
+
+ this.timeDefined = this._parseTime(currDT);
+ this._limitMinMaxDateTime(dp_inst, false);
+ this._injectTimePicker();
+ },
+
+ //########################################################################
+ // parse the time string from input value or _setTime
+ //########################################################################
+ _parseTime: function(timeString, withDate) {
+ var regstr = this._defaults.timeFormat.toString()
+ .replace(/h{1,2}/ig, '(\\d?\\d)')
+ .replace(/m{1,2}/ig, '(\\d?\\d)')
+ .replace(/s{1,2}/ig, '(\\d?\\d)')
+ .replace(/l{1}/ig, '(\\d?\\d?\\d)')
+ .replace(/t{1,2}/ig, this._getPatternAmpm())
+ .replace(/z{1}/ig, '(z|[-+]\\d\\d:?\\d\\d)?')
+ .replace(/\s/g, '\\s?') + this._defaults.timeSuffix + '$',
+ order = this._getFormatPositions(),
+ ampm = '',
+ treg;
+
+ if (!this.inst) this.inst = $.datepicker._getInst(this.$input[0]);
+
+ if (withDate || !this._defaults.timeOnly) {
+ // the time should come after x number of characters and a space.
+ // x = at least the length of text specified by the date format
+ var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
+ // escape special regex characters in the seperator
+ var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g");
+ regstr = '^.{' + dp_dateFormat.length + ',}?' + this._defaults.separator.replace(specials, "\\$&") + regstr;
+ }
+
+ treg = timeString.match(new RegExp(regstr, 'i'));
+
+ if (treg) {
+ if (order.t !== -1) {
+ if (treg[order.t] === undefined || treg[order.t].length === 0) {
+ ampm = '';
+ this.ampm = '';
+ } else {
+ ampm = $.inArray(treg[order.t].toUpperCase(), this.amNames) !== -1 ? 'AM' : 'PM';
+ this.ampm = this._defaults[ampm == 'AM' ? 'amNames' : 'pmNames'][0];
+ }
+ }
+
+ if (order.h !== -1) {
+ if (ampm == 'AM' && treg[order.h] == '12')
+ this.hour = 0; // 12am = 0 hour
+ else if (ampm == 'PM' && treg[order.h] != '12')
+ this.hour = (parseFloat(treg[order.h]) + 12).toFixed(0); // 12pm = 12 hour, any other pm = hour + 12
+ else this.hour = Number(treg[order.h]);
+ }
+
+ if (order.m !== -1) this.minute = Number(treg[order.m]);
+ if (order.s !== -1) this.second = Number(treg[order.s]);
+ if (order.l !== -1) this.millisec = Number(treg[order.l]);
+ if (order.z !== -1 && treg[order.z] !== undefined) {
+ var tz = treg[order.z].toUpperCase();
+ switch (tz.length) {
+ case 1: // Z
+ tz = this._defaults.timezoneIso8609 ? 'Z' : '+0000';
+ break;
+ case 5: // +hhmm
+ if (this._defaults.timezoneIso8609)
+ tz = tz.substring(1) == '0000'
+ ? 'Z'
+ : tz.substring(0, 3) + ':' + tz.substring(3);
+ break;
+ case 6: // +hh:mm
+ if (!this._defaults.timezoneIso8609)
+ tz = tz == 'Z' || tz.substring(1) == '00:00'
+ ? '+0000'
+ : tz.replace(/:/, '');
+ else if (tz.substring(1) == '00:00')
+ tz = 'Z';
+ break;
+ }
+ this.timezone = tz;
+ }
+
+ return true;
+
+ }
+ return false;
+ },
+
+ //########################################################################
+ // pattern for standard and localized AM/PM markers
+ //########################################################################
+ _getPatternAmpm: function() {
+ var markers = [],
+ o = this._defaults;
+ if (o.amNames)
+ $.merge(markers, o.amNames);
+ if (o.pmNames)
+ $.merge(markers, o.pmNames);
+ markers = $.map(markers, function(val) { return val.replace(/[.*+?|()\[\]{}\\]/g, '\\$&'); });
+ return '(' + markers.join('|') + ')?';
+ },
+
+ //########################################################################
+ // figure out position of time elements.. cause js cant do named captures
+ //########################################################################
+ _getFormatPositions: function() {
+ var finds = this._defaults.timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|l{1}|t{1,2}|z)/g),
+ orders = { h: -1, m: -1, s: -1, l: -1, t: -1, z: -1 };
+
+ if (finds)
+ for (var i = 0; i < finds.length; i++)
+ if (orders[finds[i].toString().charAt(0)] == -1)
+ orders[finds[i].toString().charAt(0)] = i + 1;
+
+ return orders;
+ },
+
+ //########################################################################
+ // generate and inject html for timepicker into ui datepicker
+ //########################################################################
+ _injectTimePicker: function() {
+ var $dp = this.inst.dpDiv,
+ o = this._defaults,
+ tp_inst = this,
+ // Added by Peter Medeiros:
+ // - Figure out what the hour/minute/second max should be based on the step values.
+ // - Example: if stepMinute is 15, then minMax is 45.
+ hourMax = parseInt((o.hourMax - ((o.hourMax - o.hourMin) % o.stepHour)) ,10),
+ minMax = parseInt((o.minuteMax - ((o.minuteMax - o.minuteMin) % o.stepMinute)) ,10),
+ secMax = parseInt((o.secondMax - ((o.secondMax - o.secondMin) % o.stepSecond)) ,10),
+ millisecMax = parseInt((o.millisecMax - ((o.millisecMax - o.millisecMin) % o.stepMillisec)) ,10),
+ dp_id = this.inst.id.toString().replace(/([^A-Za-z0-9_])/g, '');
+
+ // Prevent displaying twice
+ //if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0) {
+ if ($dp.find("div#ui-timepicker-div-"+ dp_id).length === 0 && o.showTimepicker) {
+ var noDisplay = ' style="display:none;"',
+ html = '<div class="ui-timepicker-div" id="ui-timepicker-div-' + dp_id + '"><dl>' +
+ '<dt class="ui_tpicker_time_label" id="ui_tpicker_time_label_' + dp_id + '"' +
+ ((o.showTime) ? '' : noDisplay) + '>' + o.timeText + '</dt>' +
+ '<dd class="ui_tpicker_time" id="ui_tpicker_time_' + dp_id + '"' +
+ ((o.showTime) ? '' : noDisplay) + '></dd>' +
+ '<dt class="ui_tpicker_hour_label" id="ui_tpicker_hour_label_' + dp_id + '"' +
+ ((o.showHour) ? '' : noDisplay) + '>' + o.hourText + '</dt>',
+ hourGridSize = 0,
+ minuteGridSize = 0,
+ secondGridSize = 0,
+ millisecGridSize = 0,
+ size = null;
+
+ // Hours
+ html += '<dd class="ui_tpicker_hour"><div id="ui_tpicker_hour_' + dp_id + '"' +
+ ((o.showHour) ? '' : noDisplay) + '></div>';
+ if (o.showHour && o.hourGrid > 0) {
+ html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
+
+ for (var h = o.hourMin; h <= hourMax; h += parseInt(o.hourGrid,10)) {
+ hourGridSize++;
+ var tmph = (o.ampm && h > 12) ? h-12 : h;
+ if (tmph < 10) tmph = '0' + tmph;
+ if (o.ampm) {
+ if (h == 0) tmph = 12 +'a';
+ else if (h < 12) tmph += 'a';
+ else tmph += 'p';
+ }
+ html += '<td>' + tmph + '</td>';
+ }
+
+ html += '</tr></table></div>';
+ }
+ html += '</dd>';
+
+ // Minutes
+ html += '<dt class="ui_tpicker_minute_label" id="ui_tpicker_minute_label_' + dp_id + '"' +
+ ((o.showMinute) ? '' : noDisplay) + '>' + o.minuteText + '</dt>'+
+ '<dd class="ui_tpicker_minute"><div id="ui_tpicker_minute_' + dp_id + '"' +
+ ((o.showMinute) ? '' : noDisplay) + '></div>';
+
+ if (o.showMinute && o.minuteGrid > 0) {
+ html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
+
+ for (var m = o.minuteMin; m <= minMax; m += parseInt(o.minuteGrid,10)) {
+ minuteGridSize++;
+ html += '<td>' + ((m < 10) ? '0' : '') + m + '</td>';
+ }
+
+ html += '</tr></table></div>';
+ }
+ html += '</dd>';
+
+ // Seconds
+ html += '<dt class="ui_tpicker_second_label" id="ui_tpicker_second_label_' + dp_id + '"' +
+ ((o.showSecond) ? '' : noDisplay) + '>' + o.secondText + '</dt>'+
+ '<dd class="ui_tpicker_second"><div id="ui_tpicker_second_' + dp_id + '"'+
+ ((o.showSecond) ? '' : noDisplay) + '></div>';
+
+ if (o.showSecond && o.secondGrid > 0) {
+ html += '<div style="padding-left: 1px"><table><tr>';
+
+ for (var s = o.secondMin; s <= secMax; s += parseInt(o.secondGrid,10)) {
+ secondGridSize++;
+ html += '<td>' + ((s < 10) ? '0' : '') + s + '</td>';
+ }
+
+ html += '</tr></table></div>';
+ }
+ html += '</dd>';
+
+ // Milliseconds
+ html += '<dt class="ui_tpicker_millisec_label" id="ui_tpicker_millisec_label_' + dp_id + '"' +
+ ((o.showMillisec) ? '' : noDisplay) + '>' + o.millisecText + '</dt>'+
+ '<dd class="ui_tpicker_millisec"><div id="ui_tpicker_millisec_' + dp_id + '"'+
+ ((o.showMillisec) ? '' : noDisplay) + '></div>';
+
+ if (o.showMillisec && o.millisecGrid > 0) {
+ html += '<div style="padding-left: 1px"><table><tr>';
+
+ for (var l = o.millisecMin; l <= millisecMax; l += parseInt(o.millisecGrid,10)) {
+ millisecGridSize++;
+ html += '<td>' + ((l < 10) ? '0' : '') + l + '</td>';
+ }
+
+ html += '</tr></table></div>';
+ }
+ html += '</dd>';
+
+ // Timezone
+ html += '<dt class="ui_tpicker_timezone_label" id="ui_tpicker_timezone_label_' + dp_id + '"' +
+ ((o.showTimezone) ? '' : noDisplay) + '>' + o.timezoneText + '</dt>';
+ html += '<dd class="ui_tpicker_timezone" id="ui_tpicker_timezone_' + dp_id + '"' +
+ ((o.showTimezone) ? '' : noDisplay) + '></dd>';
+
+ html += '</dl></div>';
+ $tp = $(html);
+
+ // if we only want time picker...
+ if (o.timeOnly === true) {
+ $tp.prepend(
+ '<div class="ui-widget-header ui-helper-clearfix ui-corner-all">' +
+ '<div class="ui-datepicker-title">' + o.timeOnlyTitle + '</div>' +
+ '</div>');
+ $dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide();
+ }
+
+ this.hour_slider = $tp.find('#ui_tpicker_hour_'+ dp_id).slider({
+ orientation: "horizontal",
+ value: this.hour,
+ min: o.hourMin,
+ max: hourMax,
+ step: o.stepHour,
+ slide: function(event, ui) {
+ tp_inst.hour_slider.slider( "option", "value", ui.value);
+ tp_inst._onTimeChange();
+ }
+ });
+
+
+ // Updated by Peter Medeiros:
+ // - Pass in Event and UI instance into slide function
+ this.minute_slider = $tp.find('#ui_tpicker_minute_'+ dp_id).slider({
+ orientation: "horizontal",
+ value: this.minute,
+ min: o.minuteMin,
+ max: minMax,
+ step: o.stepMinute,
+ slide: function(event, ui) {
+ tp_inst.minute_slider.slider( "option", "value", ui.value);
+ tp_inst._onTimeChange();
+ }
+ });
+
+ this.second_slider = $tp.find('#ui_tpicker_second_'+ dp_id).slider({
+ orientation: "horizontal",
+ value: this.second,
+ min: o.secondMin,
+ max: secMax,
+ step: o.stepSecond,
+ slide: function(event, ui) {
+ tp_inst.second_slider.slider( "option", "value", ui.value);
+ tp_inst._onTimeChange();
+ }
+ });
+
+ this.millisec_slider = $tp.find('#ui_tpicker_millisec_'+ dp_id).slider({
+ orientation: "horizontal",
+ value: this.millisec,
+ min: o.millisecMin,
+ max: millisecMax,
+ step: o.stepMillisec,
+ slide: function(event, ui) {
+ tp_inst.millisec_slider.slider( "option", "value", ui.value);
+ tp_inst._onTimeChange();
+ }
+ });
+
+ this.timezone_select = $tp.find('#ui_tpicker_timezone_'+ dp_id).append('<select></select>').find("select");
+ $.fn.append.apply(this.timezone_select,
+ $.map(o.timezoneList, function(val, idx) {
+ return $("<option />")
+ .val(typeof val == "object" ? val.value : val)
+ .text(typeof val == "object" ? val.label : val);
+ })
+ );
+ this.timezone_select.val((typeof this.timezone != "undefined" && this.timezone != null && this.timezone != "") ? this.timezone : o.timezone);
+ this.timezone_select.change(function() {
+ tp_inst._onTimeChange();
+ });
+
+ // Add grid functionality
+ if (o.showHour && o.hourGrid > 0) {
+ size = 100 * hourGridSize * o.hourGrid / (hourMax - o.hourMin);
+
+ $tp.find(".ui_tpicker_hour table").css({
+ width: size + "%",
+ marginLeft: (size / (-2 * hourGridSize)) + "%",
+ borderCollapse: 'collapse'
+ }).find("td").each( function(index) {
+ $(this).click(function() {
+ var h = $(this).html();
+ if(o.ampm) {
+ var ap = h.substring(2).toLowerCase(),
+ aph = parseInt(h.substring(0,2), 10);
+ if (ap == 'a') {
+ if (aph == 12) h = 0;
+ else h = aph;
+ } else if (aph == 12) h = 12;
+ else h = aph + 12;
+ }
+ tp_inst.hour_slider.slider("option", "value", h);
+ tp_inst._onTimeChange();
+ tp_inst._onSelectHandler();
+ }).css({
+ cursor: 'pointer',
+ width: (100 / hourGridSize) + '%',
+ textAlign: 'center',
+ overflow: 'hidden'
+ });
+ });
+ }
+
+ if (o.showMinute && o.minuteGrid > 0) {
+ size = 100 * minuteGridSize * o.minuteGrid / (minMax - o.minuteMin);
+ $tp.find(".ui_tpicker_minute table").css({
+ width: size + "%",
+ marginLeft: (size / (-2 * minuteGridSize)) + "%",
+ borderCollapse: 'collapse'
+ }).find("td").each(function(index) {
+ $(this).click(function() {
+ tp_inst.minute_slider.slider("option", "value", $(this).html());
+ tp_inst._onTimeChange();
+ tp_inst._onSelectHandler();
+ }).css({
+ cursor: 'pointer',
+ width: (100 / minuteGridSize) + '%',
+ textAlign: 'center',
+ overflow: 'hidden'
+ });
+ });
+ }
+
+ if (o.showSecond && o.secondGrid > 0) {
+ $tp.find(".ui_tpicker_second table").css({
+ width: size + "%",
+ marginLeft: (size / (-2 * secondGridSize)) + "%",
+ borderCollapse: 'collapse'
+ }).find("td").each(function(index) {
+ $(this).click(function() {
+ tp_inst.second_slider.slider("option", "value", $(this).html());
+ tp_inst._onTimeChange();
+ tp_inst._onSelectHandler();
+ }).css({
+ cursor: 'pointer',
+ width: (100 / secondGridSize) + '%',
+ textAlign: 'center',
+ overflow: 'hidden'
+ });
+ });
+ }
+
+ if (o.showMillisec && o.millisecGrid > 0) {
+ $tp.find(".ui_tpicker_millisec table").css({
+ width: size + "%",
+ marginLeft: (size / (-2 * millisecGridSize)) + "%",
+ borderCollapse: 'collapse'
+ }).find("td").each(function(index) {
+ $(this).click(function() {
+ tp_inst.millisec_slider.slider("option", "value", $(this).html());
+ tp_inst._onTimeChange();
+ tp_inst._onSelectHandler();
+ }).css({
+ cursor: 'pointer',
+ width: (100 / millisecGridSize) + '%',
+ textAlign: 'center',
+ overflow: 'hidden'
+ });
+ });
+ }
+
+ var $buttonPanel = $dp.find('.ui-datepicker-buttonpane');
+ if ($buttonPanel.length) $buttonPanel.before($tp);
+ else $dp.append($tp);
+
+ this.$timeObj = $tp.find('#ui_tpicker_time_'+ dp_id);
+
+ if (this.inst !== null) {
+ var timeDefined = this.timeDefined;
+ this._onTimeChange();
+ this.timeDefined = timeDefined;
+ }
+
+ //Emulate datepicker onSelect behavior. Call on slidestop.
+ var onSelectDelegate = function() {
+ tp_inst._onSelectHandler();
+ };
+ this.hour_slider.bind('slidestop',onSelectDelegate);
+ this.minute_slider.bind('slidestop',onSelectDelegate);
+ this.second_slider.bind('slidestop',onSelectDelegate);
+ this.millisec_slider.bind('slidestop',onSelectDelegate);
+
+ // slideAccess integration: http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibi…
+ if (this._defaults.addSliderAccess){
+ var sliderAccessArgs = this._defaults.sliderAccessArgs;
+ setTimeout(function(){ // fix for inline mode
+ if($tp.find('.ui-slider-access').length == 0){
+ $tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
+
+ // fix any grids since sliders are shorter
+ var sliderAccessWidth = $tp.find('.ui-slider-access:eq(0)').outerWidth(true);
+ if(sliderAccessWidth){
+ $tp.find('table:visible').each(function(){
+ var $g = $(this),
+ oldWidth = $g.outerWidth(),
+ oldMarginLeft = $g.css('marginLeft').toString().replace('%',''),
+ newWidth = oldWidth - sliderAccessWidth,
+ newMarginLeft = ((oldMarginLeft * newWidth)/oldWidth) + '%';
+
+ $g.css({ width: newWidth, marginLeft: newMarginLeft });
+ });
+ }
+ }
+ },0);
+ }
+ // end slideAccess integration
+
+ }
+ },
+
+ //########################################################################
+ // This function tries to limit the ability to go outside the
+ // min/max date range
+ //########################################################################
+ _limitMinMaxDateTime: function(dp_inst, adjustSliders){
+ var o = this._defaults,
+ dp_date = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay);
+
+ if(!this._defaults.showTimepicker) return; // No time so nothing to check here
+
+ if($.datepicker._get(dp_inst, 'minDateTime') !== null && $.datepicker._get(dp_inst, 'minDateTime') !== undefined && dp_date){
+ var minDateTime = $.datepicker._get(dp_inst, 'minDateTime'),
+ minDateTimeDate = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), 0, 0, 0, 0);
+
+ if(this.hourMinOriginal === null || this.minuteMinOriginal === null || this.secondMinOriginal === null || this.millisecMinOriginal === null){
+ this.hourMinOriginal = o.hourMin;
+ this.minuteMinOriginal = o.minuteMin;
+ this.secondMinOriginal = o.secondMin;
+ this.millisecMinOriginal = o.millisecMin;
+ }
+
+ if(dp_inst.settings.timeOnly || minDateTimeDate.getTime() == dp_date.getTime()) {
+ this._defaults.hourMin = minDateTime.getHours();
+ if (this.hour <= this._defaults.hourMin) {
+ this.hour = this._defaults.hourMin;
+ this._defaults.minuteMin = minDateTime.getMinutes();
+ if (this.minute <= this._defaults.minuteMin) {
+ this.minute = this._defaults.minuteMin;
+ this._defaults.secondMin = minDateTime.getSeconds();
+ } else if (this.second <= this._defaults.secondMin){
+ this.second = this._defaults.secondMin;
+ this._defaults.millisecMin = minDateTime.getMilliseconds();
+ } else {
+ if(this.millisec < this._defaults.millisecMin)
+ this.millisec = this._defaults.millisecMin;
+ this._defaults.millisecMin = this.millisecMinOriginal;
+ }
+ } else {
+ this._defaults.minuteMin = this.minuteMinOriginal;
+ this._defaults.secondMin = this.secondMinOriginal;
+ this._defaults.millisecMin = this.millisecMinOriginal;
+ }
+ }else{
+ this._defaults.hourMin = this.hourMinOriginal;
+ this._defaults.minuteMin = this.minuteMinOriginal;
+ this._defaults.secondMin = this.secondMinOriginal;
+ this._defaults.millisecMin = this.millisecMinOriginal;
+ }
+ }
+
+ if($.datepicker._get(dp_inst, 'maxDateTime') !== null && $.datepicker._get(dp_inst, 'maxDateTime') !== undefined && dp_date){
+ var maxDateTime = $.datepicker._get(dp_inst, 'maxDateTime'),
+ maxDateTimeDate = new Date(maxDateTime.getFullYear(), maxDateTime.getMonth(), maxDateTime.getDate(), 0, 0, 0, 0);
+
+ if(this.hourMaxOriginal === null || this.minuteMaxOriginal === null || this.secondMaxOriginal === null){
+ this.hourMaxOriginal = o.hourMax;
+ this.minuteMaxOriginal = o.minuteMax;
+ this.secondMaxOriginal = o.secondMax;
+ this.millisecMaxOriginal = o.millisecMax;
+ }
+
+ if(dp_inst.settings.timeOnly || maxDateTimeDate.getTime() == dp_date.getTime()){
+ this._defaults.hourMax = maxDateTime.getHours();
+ if (this.hour >= this._defaults.hourMax) {
+ this.hour = this._defaults.hourMax;
+ this._defaults.minuteMax = maxDateTime.getMinutes();
+ if (this.minute >= this._defaults.minuteMax) {
+ this.minute = this._defaults.minuteMax;
+ this._defaults.secondMax = maxDateTime.getSeconds();
+ } else if (this.second >= this._defaults.secondMax) {
+ this.second = this._defaults.secondMax;
+ this._defaults.millisecMax = maxDateTime.getMilliseconds();
+ } else {
+ if(this.millisec > this._defaults.millisecMax) this.millisec = this._defaults.millisecMax;
+ this._defaults.millisecMax = this.millisecMaxOriginal;
+ }
+ } else {
+ this._defaults.minuteMax = this.minuteMaxOriginal;
+ this._defaults.secondMax = this.secondMaxOriginal;
+ this._defaults.millisecMax = this.millisecMaxOriginal;
+ }
+ }else{
+ this._defaults.hourMax = this.hourMaxOriginal;
+ this._defaults.minuteMax = this.minuteMaxOriginal;
+ this._defaults.secondMax = this.secondMaxOriginal;
+ this._defaults.millisecMax = this.millisecMaxOriginal;
+ }
+ }
+
+ if(adjustSliders !== undefined && adjustSliders === true){
+ var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)) ,10),
+ minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)) ,10),
+ secMax = parseInt((this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)) ,10),
+ millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)) ,10);
+
+ if(this.hour_slider)
+ this.hour_slider.slider("option", { min: this._defaults.hourMin, max: hourMax }).slider('value', this.hour);
+ if(this.minute_slider)
+ this.minute_slider.slider("option", { min: this._defaults.minuteMin, max: minMax }).slider('value', this.minute);
+ if(this.second_slider)
+ this.second_slider.slider("option", { min: this._defaults.secondMin, max: secMax }).slider('value', this.second);
+ if(this.millisec_slider)
+ this.millisec_slider.slider("option", { min: this._defaults.millisecMin, max: millisecMax }).slider('value', this.millisec);
+ }
+
+ },
+
+
+ //########################################################################
+ // when a slider moves, set the internal time...
+ // on time change is also called when the time is updated in the text field
+ //########################################################################
+ _onTimeChange: function() {
+ var hour = (this.hour_slider) ? this.hour_slider.slider('value') : false,
+ minute = (this.minute_slider) ? this.minute_slider.slider('value') : false,
+ second = (this.second_slider) ? this.second_slider.slider('value') : false,
+ millisec = (this.millisec_slider) ? this.millisec_slider.slider('value') : false,
+ timezone = (this.timezone_select) ? this.timezone_select.val() : false,
+ o = this._defaults;
+
+ if (typeof(hour) == 'object') hour = false;
+ if (typeof(minute) == 'object') minute = false;
+ if (typeof(second) == 'object') second = false;
+ if (typeof(millisec) == 'object') millisec = false;
+ if (typeof(timezone) == 'object') timezone = false;
+
+ if (hour !== false) hour = parseInt(hour,10);
+ if (minute !== false) minute = parseInt(minute,10);
+ if (second !== false) second = parseInt(second,10);
+ if (millisec !== false) millisec = parseInt(millisec,10);
+
+ var ampm = o[hour < 12 ? 'amNames' : 'pmNames'][0];
+
+ // If the update was done in the input field, the input field should not be updated.
+ // If the update was done using the sliders, update the input field.
+ var hasChanged = (hour != this.hour || minute != this.minute
+ || second != this.second || millisec != this.millisec
+ || (this.ampm.length > 0
+ && (hour < 12) != ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1))
+ || timezone != this.timezone);
+
+ if (hasChanged) {
+
+ if (hour !== false)this.hour = hour;
+ if (minute !== false) this.minute = minute;
+ if (second !== false) this.second = second;
+ if (millisec !== false) this.millisec = millisec;
+ if (timezone !== false) this.timezone = timezone;
+
+ if (!this.inst) this.inst = $.datepicker._getInst(this.$input[0]);
+
+ this._limitMinMaxDateTime(this.inst, true);
+ }
+ if (o.ampm) this.ampm = ampm;
+
+ //this._formatTime();
+ this.formattedTime = $.datepicker.formatTime(this._defaults.timeFormat, this, this._defaults);
+ if (this.$timeObj) this.$timeObj.text(this.formattedTime + o.timeSuffix);
+ this.timeDefined = true;
+ if (hasChanged) this._updateDateTime();
+ },
+
+ //########################################################################
+ // call custom onSelect.
+ // bind to sliders slidestop, and grid click.
+ //########################################################################
+ _onSelectHandler: function() {
+ var onSelect = this._defaults.onSelect;
+ var inputEl = this.$input ? this.$input[0] : null;
+ if (onSelect && inputEl) {
+ onSelect.apply(inputEl, [this.formattedDateTime, this]);
+ }
+ },
+
+ //########################################################################
+ // left for any backwards compatibility
+ //########################################################################
+ _formatTime: function(time, format) {
+ time = time || { hour: this.hour, minute: this.minute, second: this.second, millisec: this.millisec, ampm: this.ampm, timezone: this.timezone };
+ var tmptime = (format || this._defaults.timeFormat).toString();
+
+ tmptime = $.datepicker.formatTime(tmptime, time, this._defaults);
+
+ if (arguments.length) return tmptime;
+ else this.formattedTime = tmptime;
+ },
+
+ //########################################################################
+ // update our input with the new date time..
+ //########################################################################
+ _updateDateTime: function(dp_inst) {
+ dp_inst = this.inst || dp_inst;
+ var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
+ dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
+ formatCfg = $.datepicker._getFormatConfig(dp_inst),
+ timeAvailable = dt !== null && this.timeDefined;
+ this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
+ var formattedDateTime = this.formattedDate;
+ if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0))
+ return;
+
+ if (this._defaults.timeOnly === true) {
+ formattedDateTime = this.formattedTime;
+ } else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
+ formattedDateTime += this._defaults.separator + this.formattedTime + this._defaults.timeSuffix;
+ }
+
+ this.formattedDateTime = formattedDateTime;
+
+ if(!this._defaults.showTimepicker) {
+ this.$input.val(this.formattedDate);
+ } else if (this.$altInput && this._defaults.altFieldTimeOnly === true) {
+ this.$altInput.val(this.formattedTime);
+ this.$input.val(this.formattedDate);
+ } else if(this.$altInput) {
+ this.$altInput.val(formattedDateTime);
+ this.$input.val(formattedDateTime);
+ } else {
+ this.$input.val(formattedDateTime);
+ }
+
+ this.$input.trigger("change");
+ }
+
+});
+
+$.fn.extend({
+ //########################################################################
+ // shorthand just to use timepicker..
+ //########################################################################
+ timepicker: function(o) {
+ o = o || {};
+ var tmp_args = arguments;
+
+ if (typeof o == 'object') tmp_args[0] = $.extend(o, { timeOnly: true });
+
+ return $(this).each(function() {
+ $.fn.datetimepicker.apply($(this), tmp_args);
+ });
+ },
+
+ //########################################################################
+ // extend timepicker to datepicker
+ //########################################################################
+ datetimepicker: function(o) {
+ o = o || {};
+ tmp_args = arguments;
+
+ if (typeof(o) == 'string'){
+ if(o == 'getDate')
+ return $.fn.datepicker.apply($(this[0]), tmp_args);
+ else
+ return this.each(function() {
+ var $t = $(this);
+ $t.datepicker.apply($t, tmp_args);
+ });
+ }
+ else
+ return this.each(function() {
+ var $t = $(this);
+ $t.datepicker($.timepicker._newInst($t, o)._defaults);
+ });
+ }
+});
+
+//########################################################################
+// format the time all pretty...
+// format = string format of the time
+// time = a {}, not a Date() for timezones
+// options = essentially the regional[].. amNames, pmNames, ampm
+//########################################################################
+$.datepicker.formatTime = function(format, time, options) {
+ options = options || {};
+ options = $.extend($.timepicker._defaults, options);
+ time = $.extend({hour:0, minute:0, second:0, millisec:0, timezone:'+0000'}, time);
+
+ var tmptime = format;
+ var ampmName = options['amNames'][0];
+
+ var hour = parseInt(time.hour, 10);
+ if (options.ampm) {
+ if (hour > 11){
+ ampmName = options['pmNames'][0];
+ if(hour > 12)
+ hour = hour % 12;
+ }
+ if (hour === 0)
+ hour = 12;
+ }
+ tmptime = tmptime.replace(/(?:hh?|mm?|ss?|[tT]{1,2}|[lz])/g, function(match) {
+ switch (match.toLowerCase()) {
+ case 'hh': return ('0' + hour).slice(-2);
+ case 'h': return hour;
+ case 'mm': return ('0' + time.minute).slice(-2);
+ case 'm': return time.minute;
+ case 'ss': return ('0' + time.second).slice(-2);
+ case 's': return time.second;
+ case 'l': return ('00' + time.millisec).slice(-3);
+ case 'z': return time.timezone;
+ case 't': case 'tt':
+ if (options.ampm) {
+ if (match.length == 1)
+ ampmName = ampmName.charAt(0);
+ return match.charAt(0) == 'T' ? ampmName.toUpperCase() : ampmName.toLowerCase();
+ }
+ return '';
+ }
+ });
+
+ tmptime = $.trim(tmptime);
+ return tmptime;
+};
+
+//########################################################################
+// the bad hack :/ override datepicker so it doesnt close on select
+// inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closin…
+//########################################################################
+$.datepicker._base_selectDate = $.datepicker._selectDate;
+$.datepicker._selectDate = function (id, dateStr) {
+ var inst = this._getInst($(id)[0]),
+ tp_inst = this._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ tp_inst._limitMinMaxDateTime(inst, true);
+ inst.inline = inst.stay_open = true;
+ //This way the onSelect handler called from calendarpicker get the full dateTime
+ this._base_selectDate(id, dateStr);
+ inst.inline = inst.stay_open = false;
+ this._notifyChange(inst);
+ this._updateDatepicker(inst);
+ }
+ else this._base_selectDate(id, dateStr);
+};
+
+//#############################################################################################
+// second bad hack :/ override datepicker so it triggers an event when changing the input field
+// and does not redraw the datepicker on every selectDate event
+//#############################################################################################
+$.datepicker._base_updateDatepicker = $.datepicker._updateDatepicker;
+$.datepicker._updateDatepicker = function(inst) {
+
+ // don't popup the datepicker if there is another instance already opened
+ var input = inst.input[0];
+ if($.datepicker._curInst &&
+ $.datepicker._curInst != inst &&
+ $.datepicker._datepickerShowing &&
+ $.datepicker._lastInput != input) {
+ return;
+ }
+
+ if (typeof(inst.stay_open) !== 'boolean' || inst.stay_open === false) {
+
+ this._base_updateDatepicker(inst);
+
+ // Reload the time control when changing something in the input text field.
+ var tp_inst = this._get(inst, 'timepicker');
+ if(tp_inst) tp_inst._addTimePicker(inst);
+ }
+};
+
+//#######################################################################################
+// third bad hack :/ override datepicker so it allows spaces and colon in the input field
+//#######################################################################################
+$.datepicker._base_doKeyPress = $.datepicker._doKeyPress;
+$.datepicker._doKeyPress = function(event) {
+ var inst = $.datepicker._getInst(event.target),
+ tp_inst = $.datepicker._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ if ($.datepicker._get(inst, 'constrainInput')) {
+ var ampm = tp_inst._defaults.ampm,
+ dateChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
+ datetimeChars = tp_inst._defaults.timeFormat.toString()
+ .replace(/[hms]/g, '')
+ .replace(/TT/g, ampm ? 'APM' : '')
+ .replace(/Tt/g, ampm ? 'AaPpMm' : '')
+ .replace(/tT/g, ampm ? 'AaPpMm' : '')
+ .replace(/T/g, ampm ? 'AP' : '')
+ .replace(/tt/g, ampm ? 'apm' : '')
+ .replace(/t/g, ampm ? 'ap' : '') +
+ " " +
+ tp_inst._defaults.separator +
+ tp_inst._defaults.timeSuffix +
+ (tp_inst._defaults.showTimezone ? tp_inst._defaults.timezoneList.join('') : '') +
+ (tp_inst._defaults.amNames.join('')) +
+ (tp_inst._defaults.pmNames.join('')) +
+ dateChars,
+ chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
+ return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1);
+ }
+ }
+
+ return $.datepicker._base_doKeyPress(event);
+};
+
+//#######################################################################################
+// Override key up event to sync manual input changes.
+//#######################################################################################
+$.datepicker._base_doKeyUp = $.datepicker._doKeyUp;
+$.datepicker._doKeyUp = function (event) {
+ var inst = $.datepicker._getInst(event.target),
+ tp_inst = $.datepicker._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ if (tp_inst._defaults.timeOnly && (inst.input.val() != inst.lastVal)) {
+ try {
+ $.datepicker._updateDatepicker(inst);
+ }
+ catch (err) {
+ $.datepicker.log(err);
+ }
+ }
+ }
+
+ return $.datepicker._base_doKeyUp(event);
+};
+
+//#######################################################################################
+// override "Today" button to also grab the time.
+//#######################################################################################
+$.datepicker._base_gotoToday = $.datepicker._gotoToday;
+$.datepicker._gotoToday = function(id) {
+ var inst = this._getInst($(id)[0]),
+ $dp = inst.dpDiv;
+ this._base_gotoToday(id);
+ var now = new Date();
+ var tp_inst = this._get(inst, 'timepicker');
+ if (tp_inst && tp_inst._defaults.showTimezone && tp_inst.timezone_select) {
+ var tzoffset = now.getTimezoneOffset(); // If +0100, returns -60
+ var tzsign = tzoffset > 0 ? '-' : '+';
+ tzoffset = Math.abs(tzoffset);
+ var tzmin = tzoffset % 60;
+ tzoffset = tzsign + ('0' + (tzoffset - tzmin) / 60).slice(-2) + ('0' + tzmin).slice(-2);
+ if (tp_inst._defaults.timezoneIso8609)
+ tzoffset = tzoffset.substring(0, 3) + ':' + tzoffset.substring(3);
+ tp_inst.timezone_select.val(tzoffset);
+ }
+ this._setTime(inst, now);
+ $( '.ui-datepicker-today', $dp).click();
+};
+
+//#######################################################################################
+// Disable & enable the Time in the datetimepicker
+//#######################################################################################
+$.datepicker._disableTimepickerDatepicker = function(target, date, withDate) {
+ var inst = this._getInst(target),
+ tp_inst = this._get(inst, 'timepicker');
+ $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
+ if (tp_inst) {
+ tp_inst._defaults.showTimepicker = false;
+ tp_inst._updateDateTime(inst);
+ }
+};
+
+$.datepicker._enableTimepickerDatepicker = function(target, date, withDate) {
+ var inst = this._getInst(target),
+ tp_inst = this._get(inst, 'timepicker');
+ $(target).datepicker('getDate'); // Init selected[Year|Month|Day]
+ if (tp_inst) {
+ tp_inst._defaults.showTimepicker = true;
+ tp_inst._addTimePicker(inst); // Could be disabled on page load
+ tp_inst._updateDateTime(inst);
+ }
+};
+
+//#######################################################################################
+// Create our own set time function
+//#######################################################################################
+$.datepicker._setTime = function(inst, date) {
+ var tp_inst = this._get(inst, 'timepicker');
+ if (tp_inst) {
+ var defaults = tp_inst._defaults,
+ // calling _setTime with no date sets time to defaults
+ hour = date ? date.getHours() : defaults.hour,
+ minute = date ? date.getMinutes() : defaults.minute,
+ second = date ? date.getSeconds() : defaults.second,
+ millisec = date ? date.getMilliseconds() : defaults.millisec;
+
+ //check if within min/max times..
+ if ((hour < defaults.hourMin || hour > defaults.hourMax) || (minute < defaults.minuteMin || minute > defaults.minuteMax) || (second < defaults.secondMin || second > defaults.secondMax) || (millisec < defaults.millisecMin || millisec > defaults.millisecMax)) {
+ hour = defaults.hourMin;
+ minute = defaults.minuteMin;
+ second = defaults.secondMin;
+ millisec = defaults.millisecMin;
+ }
+
+ tp_inst.hour = hour;
+ tp_inst.minute = minute;
+ tp_inst.second = second;
+ tp_inst.millisec = millisec;
+
+ if (tp_inst.hour_slider) tp_inst.hour_slider.slider('value', hour);
+ if (tp_inst.minute_slider) tp_inst.minute_slider.slider('value', minute);
+ if (tp_inst.second_slider) tp_inst.second_slider.slider('value', second);
+ if (tp_inst.millisec_slider) tp_inst.millisec_slider.slider('value', millisec);
+
+ tp_inst._onTimeChange();
+ tp_inst._updateDateTime(inst);
+ }
+};
+
+//#######################################################################################
+// Create new public method to set only time, callable as $().datepicker('setTime', date)
+//#######################################################################################
+$.datepicker._setTimeDatepicker = function(target, date, withDate) {
+ var inst = this._getInst(target),
+ tp_inst = this._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ this._setDateFromField(inst);
+ var tp_date;
+ if (date) {
+ if (typeof date == "string") {
+ tp_inst._parseTime(date, withDate);
+ tp_date = new Date();
+ tp_date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
+ }
+ else tp_date = new Date(date.getTime());
+ if (tp_date.toString() == 'Invalid Date') tp_date = undefined;
+ this._setTime(inst, tp_date);
+ }
+ }
+
+};
+
+//#######################################################################################
+// override setDate() to allow setting time too within Date object
+//#######################################################################################
+$.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
+$.datepicker._setDateDatepicker = function(target, date) {
+ var inst = this._getInst(target),
+ tp_date = (date instanceof Date) ? new Date(date.getTime()) : date;
+
+ this._updateDatepicker(inst);
+ this._base_setDateDatepicker.apply(this, arguments);
+ this._setTimeDatepicker(target, tp_date, true);
+};
+
+//#######################################################################################
+// override getDate() to allow getting time too within Date object
+//#######################################################################################
+$.datepicker._base_getDateDatepicker = $.datepicker._getDateDatepicker;
+$.datepicker._getDateDatepicker = function(target, noDefault) {
+ var inst = this._getInst(target),
+ tp_inst = this._get(inst, 'timepicker');
+
+ if (tp_inst) {
+ this._setDateFromField(inst, noDefault);
+ var date = this._getDate(inst);
+ if (date && tp_inst._parseTime($(target).val(), tp_inst.timeOnly)) date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
+ return date;
+ }
+ return this._base_getDateDatepicker(target, noDefault);
+};
+
+//#######################################################################################
+// override parseDate() because UI 1.8.14 throws an error about "Extra characters"
+// An option in datapicker to ignore extra format characters would be nicer.
+//#######################################################################################
+$.datepicker._base_parseDate = $.datepicker.parseDate;
+$.datepicker.parseDate = function(format, value, settings) {
+ var date;
+ try {
+ date = this._base_parseDate(format, value, settings);
+ } catch (err) {
+ if (err.indexOf(":") >= 0) {
+ // Hack! The error message ends with a colon, a space, and
+ // the "extra" characters. We rely on that instead of
+ // attempting to perfectly reproduce the parsing algorithm.
+ date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
+ } else {
+ // The underlying error was not related to the time
+ throw err;
+ }
+ }
+ return date;
+};
+
+//#######################################################################################
+// override formatDate to set date with time to the input
+//#######################################################################################
+$.datepicker._base_formatDate = $.datepicker._formatDate;
+$.datepicker._formatDate = function(inst, day, month, year){
+ var tp_inst = this._get(inst, 'timepicker');
+ if(tp_inst) {
+ tp_inst._updateDateTime(inst);
+ return tp_inst.$input.val();
+ }
+ return this._base_formatDate(inst);
+};
+
+//#######################################################################################
+// override options setter to add time to maxDate(Time) and minDate(Time). MaxDate
+//#######################################################################################
+$.datepicker._base_optionDatepicker = $.datepicker._optionDatepicker;
+$.datepicker._optionDatepicker = function(target, name, value) {
+ var inst = this._getInst(target),
+ tp_inst = this._get(inst, 'timepicker');
+ if (tp_inst) {
+ var min = null, max = null, onselect = null;
+ if (typeof name == 'string') { // if min/max was set with the string
+ if (name === 'minDate' || name === 'minDateTime' )
+ min = value;
+ else if (name === 'maxDate' || name === 'maxDateTime')
+ max = value;
+ else if (name === 'onSelect')
+ onselect = value;
+ } else if (typeof name == 'object') { //if min/max was set with the JSON
+ if (name.minDate)
+ min = name.minDate;
+ else if (name.minDateTime)
+ min = name.minDateTime;
+ else if (name.maxDate)
+ max = name.maxDate;
+ else if (name.maxDateTime)
+ max = name.maxDateTime;
+ }
+ if(min) { //if min was set
+ if (min == 0)
+ min = new Date();
+ else
+ min = new Date(min);
+
+ tp_inst._defaults.minDate = min;
+ tp_inst._defaults.minDateTime = min;
+ } else if (max) { //if max was set
+ if(max==0)
+ max=new Date();
+ else
+ max= new Date(max);
+ tp_inst._defaults.maxDate = max;
+ tp_inst._defaults.maxDateTime = max;
+ } else if (onselect)
+ tp_inst._defaults.onSelect = onselect;
+ }
+ if (value === undefined)
+ return this._base_optionDatepicker(target, name);
+ return this._base_optionDatepicker(target, name, value);
+};
+
+//#######################################################################################
+// jQuery extend now ignores nulls!
+//#######################################################################################
+function extendRemove(target, props) {
+ $.extend(target, props);
+ for (var name in props)
+ if (props[name] === null || props[name] === undefined)
+ target[name] = props[name];
+ return target;
+};
+
+$.timepicker = new Timepicker(); // singleton instance
+$.timepicker.version = "1.0.0";
+
+})(jQuery);
Added: trunk/chorem-webmotion/src/main/webapp/js/jquery-ui-timepicker-fr.js
===================================================================
--- trunk/chorem-webmotion/src/main/webapp/js/jquery-ui-timepicker-fr.js (rev 0)
+++ trunk/chorem-webmotion/src/main/webapp/js/jquery-ui-timepicker-fr.js 2012-06-05 13:54:15 UTC (rev 176)
@@ -0,0 +1,20 @@
+/* French translation for the jQuery Timepicker Addon */
+/* Written by Thomas Lété */
+(function($) {
+ $.timepicker.regional['fr'] = {
+ timeOnlyTitle: 'Choisir une heure',
+ timeText: 'Heure',
+ hourText: 'Heures',
+ minuteText: 'Minutes',
+ secondText: 'Secondes',
+ millisecText: 'Millisecondes',
+ timezoneText: 'Fuseau horaire',
+ currentText: 'Maintenant',
+ closeText: 'Terminé',
+ timeFormat: 'hh:mm',
+ amNames: ['AM', 'A'],
+ pmNames: ['PM', 'P'],
+ ampm: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['fr']);
+})(jQuery);
1
0
r175 - trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag
by ymartel@users.chorem.org 05 Jun '12
by ymartel@users.chorem.org 05 Jun '12
05 Jun '12
Author: ymartel
Date: 2012-06-05 10:27:48 +0200 (Tue, 05 Jun 2012)
New Revision: 175
Url: http://chorem.org/repositories/revision/chorem/175
Log:
Do not display current date when not date is defined
Modified:
trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyInput.java
Modified: trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyInput.java
===================================================================
--- trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyInput.java 2012-06-04 15:52:06 UTC (rev 174)
+++ trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyInput.java 2012-06-05 08:27:48 UTC (rev 175)
@@ -147,10 +147,10 @@
Wikitty wikitty, FieldType field, String extName , String fieldName)
throws JspException, IOException {
Date date = wikitty.getFieldAsDate(extName, fieldName);
- if (date == null) {
- date = new Date();
+ String value = "";
+ if (date != null) {
+ value = DateFormatUtils.format(date, "dd/MM/yyyy");
}
- String value = DateFormatUtils.format(date, "dd/MM/yyyy");
/*{<input class="datepicker" type="date" name="<%=name%>" value="<%=value%>"<%=getDynamicAttribute()%>/>}*/
}
1
0
r174 - in trunk: . chorem-webmotion/src/main/java/org/chorem/webmotion chorem-webmotion/src/main/java/org/chorem/webmotion/filters chorem-webmotion/src/main/java/org/chorem/webmotion/injector chorem-webmotion/src/main/resources
by ymartel@users.chorem.org 04 Jun '12
by ymartel@users.chorem.org 04 Jun '12
04 Jun '12
Author: ymartel
Date: 2012-06-04 17:52:06 +0200 (Mon, 04 Jun 2012)
New Revision: 174
Url: http://chorem.org/repositories/revision/chorem/174
Log:
Migrate to webmotion 2.2
Added:
trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/injector/
trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/injector/InjectorListener.java
Modified:
trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/filters/ChoremClientFilter.java
trunk/chorem-webmotion/src/main/resources/mapping
trunk/pom.xml
Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/filters/ChoremClientFilter.java
===================================================================
--- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/filters/ChoremClientFilter.java 2012-06-04 05:08:40 UTC (rev 173)
+++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/filters/ChoremClientFilter.java 2012-06-04 15:52:06 UTC (rev 174)
@@ -1,8 +1,6 @@
package org.chorem.webmotion.filters;
-import java.lang.reflect.Method;
-import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.ChoremClient;
@@ -11,6 +9,9 @@
import org.debux.webmotion.server.call.Executor;
import org.debux.webmotion.server.mapping.Mapping;
+import java.lang.reflect.Method;
+import java.util.Map;
+
/**
* Inject dans les parametres des actions le client wikitty a utiliser pour les
* actions (ChoremClient)
@@ -20,6 +21,8 @@
*
* Last update: $Date$
* by : $Author$
+ *
+ * @deprecated filter has been replaced by {@link org.chorem.webmotion.injector.InjectorListener}
*/
public class ChoremClientFilter extends WebMotionFilter {
Added: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/injector/InjectorListener.java
===================================================================
--- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/injector/InjectorListener.java (rev 0)
+++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/injector/InjectorListener.java 2012-06-04 15:52:06 UTC (rev 174)
@@ -0,0 +1,40 @@
+package org.chorem.webmotion.injector;
+
+import org.chorem.ChoremClient;
+import org.debux.webmotion.server.WebMotionServerListener;
+import org.debux.webmotion.server.call.Call;
+import org.debux.webmotion.server.call.ServerContext;
+import org.debux.webmotion.server.handler.ExecutorParametersInjectorHandler.Injector;
+import org.debux.webmotion.server.mapping.Mapping;
+
+import java.lang.reflect.Type;
+
+/**
+ * @author ymartel <martel(a)codelutin.com>
+ */
+public class InjectorListener implements WebMotionServerListener {
+
+ @Override
+ public void onStart(ServerContext context) {
+ // Get Client
+ String token = "";
+ final ChoremClient client = ChoremClient.getClient(null);
+
+ // Declare injector
+ context.addInjector(new Injector() {
+ @Override
+ public Object getValue(Mapping mapping, Call call, Class<?> type, Type generic) {
+ if (ChoremClient.class.isAssignableFrom(type)) {
+ return client;
+ }
+ return null;
+ }
+ });
+ }
+
+ @Override
+ public void onStop(ServerContext context) {
+ // Do nothing
+ }
+
+}
Modified: trunk/chorem-webmotion/src/main/resources/mapping
===================================================================
--- trunk/chorem-webmotion/src/main/resources/mapping 2012-06-04 05:08:40 UTC (rev 173)
+++ trunk/chorem-webmotion/src/main/resources/mapping 2012-06-04 15:52:06 UTC (rev 174)
@@ -2,9 +2,10 @@
package.views=WEB-INF/jsp
package.filters=org.chorem.webmotion.filters
package.actions=org.chorem.webmotion.actions
+server.listener.class=org.chorem.webmotion.injector.InjectorListener
[filters]
-* /* ChoremClientFilter.inject
+#* /* ChoremClientFilter.inject
#GET /wikitty/{extension}/view/{id} DecoratorFilter.decorate slotEntityFooter={extension}Footer.jsp
* /wikitty-json/* DecoratorFilter.decorate wmDecoratorNo=true
* /fragment/* DecoratorFilter.decorate wmDecoratorNo=true
@@ -22,7 +23,7 @@
* /wikitty/edit/{id} action:GenericAction.edit
* /wikitty/delete/{id} action:GenericAction.delete
* /wikitty/save action:GenericAction.save
-* /wikitty/view/{id}/{extension}/{field} action:GenericAction.download
+* /wikitty/view/{id}/{extension}/{field} action:GenericAction.download wmDecoratorNo=true
* /wikitty-json/searchField?q={query} action:GenericAction.searchFieldJson
* /wikitty-json/search?q={query} action:GenericAction.searchJson
* /wikitty-json/search?term={query} action:GenericAction.searchJson
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-06-04 05:08:40 UTC (rev 173)
+++ trunk/pom.xml 2012-06-04 15:52:06 UTC (rev 174)
@@ -107,7 +107,7 @@
<servletApiVersion>2.5</servletApiVersion>
<jspApiVersion>2.0</jspApiVersion>
<h2Version>1.2.134</h2Version>
- <webmotionVersion>2.1</webmotionVersion>
+ <webmotionVersion>2.2</webmotionVersion>
<jstlVersion>1.2</jstlVersion>
<!-- license to use -->
1
0
r173 - in trunk: chorem-entities/src/main/java/org/chorem chorem-entities/src/main/xmi chorem-webmotion/src/main/java/org/chorem/webmotion/actions chorem-webmotion/src/main/resources chorem-webmotion/src/main/webapp/WEB-INF/jsp
by bpoussin@users.chorem.org 04 Jun '12
by bpoussin@users.chorem.org 04 Jun '12
04 Jun '12
Author: bpoussin
Date: 2012-06-04 07:08:40 +0200 (Mon, 04 Jun 2012)
New Revision: 173
Url: http://chorem.org/repositories/revision/chorem/173
Log:
- ajout de category sur invoiceable (et ajout en preload)
- modif des dashboard qui utilisait Quotation.type pour utiliser Quotation.category
- ajout page admin pour l'objet Configuration
- ajout d'extension dans la base dans la sequence d'init de programme
- ajout dasboard budget (fonctionne pas encore, probleme de recherche des noeuds racines)
Added:
trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/AdminAction.java
trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardBudget.jsp
Modified:
trunk/chorem-entities/src/main/java/org/chorem/ChoremClient.java
trunk/chorem-entities/src/main/xmi/chorem-model.properties
trunk/chorem-entities/src/main/xmi/chorem-model.zargo
trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java
trunk/chorem-webmotion/src/main/resources/mapping
trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardProfitability.jsp
trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardQuotation.jsp
trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/decorator.jsp
trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/financial.jsp
Modified: trunk/chorem-entities/src/main/java/org/chorem/ChoremClient.java
===================================================================
--- trunk/chorem-entities/src/main/java/org/chorem/ChoremClient.java 2012-06-02 03:17:10 UTC (rev 172)
+++ trunk/chorem-entities/src/main/java/org/chorem/ChoremClient.java 2012-06-04 05:08:40 UTC (rev 173)
@@ -94,6 +94,7 @@
List<WikittyExtension> exts = new ArrayList<WikittyExtension>();
exts.addAll(org.chorem.entities.ConfigurationAbstract.extensions);
+ exts.addAll(org.chorem.entities.CategoryAbstract.extensions);
exts.addAll(org.chorem.entities.AttachmentAbstract.extensions);
exts.addAll(org.chorem.entities.CompanyAbstract.extensions);
exts.addAll(org.chorem.entities.ContactDetailsAbstract.extensions);
@@ -116,6 +117,13 @@
exts.addAll(org.chorem.entities.VacationAbstract.extensions);
exts.addAll(org.chorem.entities.WorkerAbstract.extensions);
+ exts.addAll(org.nuiton.wikitty.entities.WikittyGroupAbstract.extensions);
+ exts.addAll(org.nuiton.wikitty.entities.WikittyUserAbstract.extensions);
+ exts.addAll(org.nuiton.wikitty.entities.WikittyTreeNodeAbstract.extensions);
+ exts.addAll(org.nuiton.wikitty.entities.WikittyHookAbstract.extensions);
+ exts.addAll(org.nuiton.wikitty.entities.WikittyAuthorisationAbstract.extensions);
+ exts.addAll(org.nuiton.wikitty.entities.WikittyLabelAbstract.extensions);
+
ws.storeExtension(null, exts);
}
}
Modified: trunk/chorem-entities/src/main/xmi/chorem-model.properties
===================================================================
--- trunk/chorem-entities/src/main/xmi/chorem-model.properties 2012-06-02 03:17:10 UTC (rev 172)
+++ trunk/chorem-entities/src/main/xmi/chorem-model.properties 2012-06-04 05:08:40 UTC (rev 173)
@@ -1,4 +1,6 @@
-org.chorem.entities.Configration.class.tagvalue.version=2.0
+org.chorem.entities.Configuration.class.tagvalue.version=2.0
+org.chorem.entities.Category.class.tagvalue.version=3.0
+org.chorem.entities.Category.class.tagvalue.toString=%WikittyTreeNode.name|noname$s
org.chorem.entities.Project.class.tagvalue.version=5.0
org.chorem.entities.Project.class.tagvalue.toString=%Project.name|noname$s
org.chorem.entities.Project.class.tagvalue.sortOrder=Project.name
@@ -69,17 +71,17 @@
org.chorem.entities.Attachment.class.tagvalue.toString=%Attachment.name|noname$s (%Attachment.mimetype|notype$s) %Attachment.date$tF
org.chorem.entities.Attachment.class.tagvalue.sortOrder=Attachment.name,Attachment.mimetype,Attachment.date
org.chorem.entities.Quotation.class.tagvalue.version=10.0
-org.chorem.entities.Quotation.class.tagvalue.preload=Quotation.project;Quotation.customer;Quotation.supplier
-org.chorem.entities.Quotation.class.tagvalue.toString=%Interval.beginDate$tF-%Interval.endDate$tF %Quotation.reference|noref$s(%Quotation.type|notype$s) %Quotation.description|nodescription$s
+org.chorem.entities.Quotation.class.tagvalue.preload=Quotation.project;Quotation.customer;Quotation.supplier;Quotation.category
+org.chorem.entities.Quotation.class.tagvalue.toString=%Interval.beginDate$tF-%Interval.endDate$tF %Quotation.reference|noref$s(%Quotation.category|noCategory$s) %Quotation.description|nodescription$s
org.chorem.entities.Quotation.class.tagvalue.sortOrder=Interval.beginDate,Interval.endDate,Quotation.reference,Quotation.type,Quotation.description
org.chorem.entities.Quotation.attribute.status.tagvalue.allowed=DRAFT,SEND,REJECTED,ACCEPTED,STARTED,DELIVERED,VRS,WARRANTY,CLOSED
org.chorem.entities.Quotation.attribute.conversionHope.tagvalue.min=0
org.chorem.entities.Quotation.attribute.conversionHope.tagvalue.max=100
-org.chorem.entities.Invoice.class.tagvalue.version=6.0
-org.chorem.entities.Invoice.class.tagvalue.preload=Invoice.target
+org.chorem.entities.Invoice.class.tagvalue.version=8.0
+org.chorem.entities.Invoice.class.tagvalue.preload=Invoice.target;Invoice.customer;Invoice.supplier
org.chorem.entities.Invoice.class.tagvalue.toString=%Invoice.reference|noref$s %Invoice.amount|noamount$s %Invoice.postedDate$tF %Invoice.expectedDate$tF %Invoice.paymentDate$tF
org.chorem.entities.Invoice.class.tagvalue.sortOrder=Invoice.postedDate,Invoice.expectedDate,Invoice.paymentDate,Invoice.reference,Invoice.amount
-org.chorem.entities.Invoiceable.class.tagvalue.version=6.0
-org.chorem.entities.Invoiceable.class.tagvalue.preload=Invoiceable.customer;Invoiceable.supplier
+org.chorem.entities.Invoiceable.class.tagvalue.version=8.0
+org.chorem.entities.Invoiceable.class.tagvalue.preload=Invoiceable.category
org.chorem.entities.Invoiceable.class.tagvalue.toString=%Invoiceable.name|noname$s
org.chorem.entities.Invoiceable.class.tagvalue.sortOrder=Invoiceable.name
Modified: trunk/chorem-entities/src/main/xmi/chorem-model.zargo
===================================================================
(Binary files differ)
Added: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/AdminAction.java
===================================================================
--- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/AdminAction.java (rev 0)
+++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/AdminAction.java 2012-06-04 05:08:40 UTC (rev 173)
@@ -0,0 +1,37 @@
+package org.chorem.webmotion.actions;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.ChoremClient;
+import org.chorem.entities.Configuration;
+import org.debux.webmotion.server.WebMotionController;
+import org.debux.webmotion.server.render.Render;
+import org.nuiton.wikitty.query.WikittyQuery;
+import org.nuiton.wikitty.query.WikittyQueryMaker;
+
+/**
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class AdminAction extends WebMotionController {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(AdminAction.class);
+
+ /**
+ * Bilan du nombre de jour travaille sur des projets client depuis le 01/01 par employer de la
+ * societe par defaut (Configuration.defaultCompany)
+ */
+ public Render variables(ChoremClient client) {
+ Configuration conf = client.getConfiguration();
+
+ GenericAction g = new GenericAction();
+ return g.view(client, conf.getWikittyId(), null);
+ }
+
+}
Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java
===================================================================
--- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java 2012-06-02 03:17:10 UTC (rev 172)
+++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/DashboardAction.java 2012-06-04 05:08:40 UTC (rev 173)
@@ -8,18 +8,22 @@
import java.util.Date;
import java.util.EnumSet;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.ChoremClient;
import org.chorem.entities.Attachment;
+import org.chorem.entities.Category;
import org.chorem.entities.Configuration;
import org.chorem.entities.ConfigurationImpl;
import org.chorem.entities.Employee;
@@ -35,10 +39,14 @@
import org.debux.webmotion.server.render.Render;
import org.nuiton.util.ObjectUtil;
import org.nuiton.wikitty.entities.Element;
+import org.nuiton.wikitty.entities.ElementField;
+import org.nuiton.wikitty.entities.WikittyTreeNode;
import org.nuiton.wikitty.query.WikittyQuery;
import org.nuiton.wikitty.query.WikittyQueryMaker;
import org.nuiton.wikitty.query.WikittyQueryParser;
import org.nuiton.wikitty.query.WikittyQueryResult;
+import org.nuiton.wikitty.query.WikittyQueryResultTreeNode;
+import org.nuiton.wikitty.query.conditions.Aggregate;
/**
*
@@ -63,11 +71,17 @@
* @param <K>
* @param <V>
*/
- static public class MapWithDefault<K, V> implements Map<K, V> {
+ static public class MapWithDefault<K, V> implements Map<K, V>, Cloneable {
protected Map<K, V> map;
protected Object defaultValue;
protected Collection args;
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ MapWithDefault result = (MapWithDefault)super.clone();
+ return result;
+ }
+
/**
* L'objet par default utilise est l'objet passe en parametre s'il n'est
* pas clonable ou un clone de l'objet s'il est clonable.
@@ -622,4 +636,116 @@
"workingProjectDaysByEmployee", days
);
}
+
+ /**
+ * Prévisionnel entre deux dates en fonction des factures
+ */
+ public Render budget(ChoremClient client, Date start, Date end, String filter) {
+ if (log.isDebugEnabled()) {
+ log.debug(String.format(
+ "budget for period '%s' to '%s' with filter '%s'",
+ start, end, filter));
+ }
+ String companyId = client.getConfiguration().getDefaultCompany();
+
+ if (start == null) {
+ start = new Date();
+ start = DateUtils.addMonths(start, -1);
+ }
+
+ if (end == null) {
+ end = DateUtils.addMonths(start, 6);
+ }
+
+ // La somme des factures que la company doit payer jusqu'a la date demandee
+ WikittyQuery debt = new WikittyQueryMaker()
+ .select(Invoice.FQ_FIELD_INVOICE_AMOUNT, Aggregate.SUM)
+ .and()
+ .eq(Invoice.FQ_FIELD_INVOICE_CUSTOMER, companyId)
+ .lt(Invoice.FQ_FIELD_INVOICE_EXPECTEDDATE, start)
+ .end()
+ .setLimit(WikittyQuery.MAX);
+
+ // La somme des factures que la company doit percevoir jusqu'a la date demandee
+ WikittyQuery income = new WikittyQueryMaker()
+ .select(Invoice.FQ_FIELD_INVOICE_AMOUNT, Aggregate.SUM)
+ .and()
+ .eq(Invoice.FQ_FIELD_INVOICE_SUPPLIER, companyId)
+ .lt(Invoice.FQ_FIELD_INVOICE_EXPECTEDDATE, start)
+ .end()
+ .setLimit(WikittyQuery.MAX);
+
+ // La liste des factures entre les deux dates
+ WikittyQuery q = new WikittyQueryMaker().and()
+ .parse(filter)
+ .bw(Invoice.FQ_FIELD_INVOICE_EXPECTEDDATE, start, end)
+ .end()
+ .setLimit(WikittyQuery.MAX);
+
+ Double[] amounts = client.findByQuery(Double.class, debt, income);
+ WikittyQueryResult<Invoice> invoices = client.findAllByQuery(Invoice.class, q);
+
+ WikittyQuery categoriesQuery = new WikittyQueryMaker()
+ .exteq(Category.EXT_CATEGORY)
+ .end();
+ WikittyQuery rootCategoriesQuery = new WikittyQueryMaker().and()
+ .exteq(Category.EXT_CATEGORY)
+ .isNull(Category.FQ_FIELD_WIKITTYTREENODE_PARENT)
+ .end()
+ .addSortAscending(new ElementField(Category.FQ_FIELD_CATEGORY_INDEX));
+
+ WikittyQueryResult<Category>[] categories =
+ client.findAllByQuery(Category.class, categoriesQuery, rootCategoriesQuery);
+
+
+ String dateFormat = "MM/yyyy";
+
+ List<String> dates = new LinkedList<String>();
+ do {
+ dates.add(DateFormatUtils.format(start, dateFormat));
+ start = DateUtils.addMonths(start, 1);
+ } while (!start.after(end));
+
+
+ // key: date as MM/yyyy
+ Map<String, Map<Category, Double>> values = new HashMap<String, Map<Category, Double>>();
+
+ for (String d : dates) {
+ Map<Category, Double> catMap = new HashMap<Category, Double>();
+ values.put(d, catMap);
+ for (Category c: categories[0]) {
+ catMap.put(c, 0.0);
+ }
+ }
+
+ for (Invoice i : invoices) {
+ String date = DateFormatUtils.format(i.getExpectedDate(), dateFormat);
+ Map<Category, Double> catMap = values.get(date);
+ System.out.println(String.format("*** date '%s' %s map %s", date, dates, values));
+ Category c = i.getCategory(true);
+ System.out.println("c: " + c + " catMap: " + catMap);
+ if (catMap.containsKey(c)) {
+ double v = catMap.get(c);
+ v += i.getAmount();
+ catMap.put(c, v);
+ }
+ }
+
+ List<WikittyQueryResultTreeNode<Category>> categoriesTree =
+ new LinkedList<WikittyQueryResultTreeNode<Category>>();
+ for (Category c : categories[1]) {
+ WikittyQueryResultTreeNode<Category> treeResults =
+ client.findTreeNode(Category.class, c.getWikittyId(), Integer.MAX_VALUE, false, null);
+ if (treeResults != null) {
+ CollectionUtils.addAll(categoriesTree, treeResults.iterator());
+ }
+ }
+
+ System.out.println("DDDD dates: " + dates + " categoriesTree: " + categoriesTree + " values: " + values);
+ return renderView("dashboardBudget.jsp",
+ "dates", dates,
+ "categoriesTree", categoriesTree,
+ "values", values);
+ }
+
}
Modified: trunk/chorem-webmotion/src/main/resources/mapping
===================================================================
--- trunk/chorem-webmotion/src/main/resources/mapping 2012-06-02 03:17:10 UTC (rev 172)
+++ trunk/chorem-webmotion/src/main/resources/mapping 2012-06-04 05:08:40 UTC (rev 173)
@@ -28,6 +28,8 @@
* /wikitty-json/search?term={query} action:GenericAction.searchJson
* /wikitty-json/get/{id} action:GenericAction.getById
* /fragment/dashboard/{method} action:DashboardAction.{method}
+* /admin view:contact.jsp
+* /admin/{method} action:AdminAction.{method}
* /contact view:contact.jsp
* /project view:project.jsp
* /financial view:financial.jsp
Added: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardBudget.jsp
===================================================================
--- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardBudget.jsp (rev 0)
+++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardBudget.jsp 2012-06-04 05:08:40 UTC (rev 173)
@@ -0,0 +1,33 @@
+<%@page contentType="text/html" pageEncoding="UTF-8"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="/WEB-INF/wikitty.tld" prefix="w"%>
+
+<h1>Budget</h1>
+
+<form>
+ date start: <input type="date" name="start"/>
+ end: <input type="date" name="end"/>
+ <input type="submit"/>
+</form>
+
+<table class="table table-striped table-bordered table-condensed">
+ <thead>
+ <tr>
+ <c:forEach var="d" items="${dates}">
+ <th>${d}</th>
+ </c:forEach>
+ </tr>
+ </thead>
+ <tbody>
+ <c:forEach var="c" items="${categoriesTree}">
+ <tr>
+ <td class="level${c.level}">${c.userObject}</td>
+ </tr>
+ <tr>
+ <c:forEach var="d" items="${dates}">
+ <td>${values.get(d).get(c.userObject)}</td>
+ </c:forEach>
+ </tr>
+ </tbody>
+ </c:forEach>
+</table>
Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardProfitability.jsp
===================================================================
--- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardProfitability.jsp 2012-06-02 03:17:10 UTC (rev 172)
+++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardProfitability.jsp 2012-06-04 05:08:40 UTC (rev 173)
@@ -7,7 +7,7 @@
<thead>
<tr>
<th>Project</th>
- <th>Type</th>
+ <th>Category</th>
<th>Description</th>
<th>estimated days</th>
<th>Amount</th>
@@ -24,7 +24,7 @@
<tbody>
<tr>
<td><a href="<c:url value="/wikitty/Project/view/${q.project}"/>">${q.getProject(false).getName()}</a></td>
- <td>${q.type}</td>
+ <td>${q.category}</td>
<td><a href="<c:url value="/wikitty/Quotation/view/${q.wikittyId}"/>">${q.description}</a></td>
<td>${q.estimatedDays}</td>
<td>${q.amount}</td>
Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardQuotation.jsp
===================================================================
--- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardQuotation.jsp 2012-06-02 03:17:10 UTC (rev 172)
+++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/dashboardQuotation.jsp 2012-06-04 05:08:40 UTC (rev 173)
@@ -7,7 +7,7 @@
<thead>
<tr>
<th>Project</th>
- <th>Type</th>
+ <th>Category</th>
<th>Description</th>
<th>Customer</th>
<th>Supplier</th>
@@ -23,7 +23,7 @@
<tbody>
<tr>
<td><a href="<c:url value="/wikitty/Project/view/${q.project}"/>">${q.getProject(false).getName()}</a></td>
- <td>${q.type}</td>
+ <td>${q.category}</td>
<td><a href="<c:url value="/wikitty/Quotation/view/${q.wikittyId}"/>">${q.description}</a></td>
<td><a href="<c:url value="/wikitty/Employee/view/${q.customer}"/>">${q.getCustomer(false)}</a></td>
<td><a href="<c:url value="/wikitty/Employee/view/${q.supplier}"/>">${q.getSupplier(false)}</a></td>
Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/decorator.jsp
===================================================================
--- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/decorator.jsp 2012-06-02 03:17:10 UTC (rev 172)
+++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/decorator.jsp 2012-06-04 05:08:40 UTC (rev 173)
@@ -107,6 +107,10 @@
<li><a href="<c:url value="/wikitty/Invoice/search"/>"><i class="icon-th-list icon-black"></i> All invoices</a></li>
<li><a href="<c:url value="/wikitty/Invoice/edit/new"/>"><i class="icon-plus icon-black"></i> Add invoice</a></li>
<li class="divider"></li>
+ <li>Category</li>
+ <li><a href="<c:url value="/wikitty/Category/search"/>"><i class="icon-th-list icon-black"></i> All categories</a></li>
+ <li><a href="<c:url value="/wikitty/Category/edit/new"/>"><i class="icon-plus icon-black"></i> Add category</a></li>
+ <li class="divider"></li>
<li>Other</li>
<li><a href="/wikitty/search?query=extension=Accounting">Accounting</a></li>
</ul>
@@ -127,6 +131,21 @@
<li><a href="/wikitty/search?query=extension=Interview">Annual interview</a></li>
</ul>
</li>
+ <li class="dropdown nav-group">
+ <a href="/admin">Admin</a>
+ <a href="#"
+ class="dropdown-toggle"
+ data-toggle="dropdown">
+ <b class="caret"></b>
+ </a>
+ <ul class="dropdown-menu">
+ <li>User</li>
+ <li><a href="<c:url value="/wikitty/WikittyUser/search"/>"><i class="icon-th-list icon-black"></i> All users</a></li>
+ <li><a href="<c:url value="/wikitty/WikittyUser/edit/new"/>"><i class="icon-plus icon-black"></i> Add user</a></li>
+ <li class="divider"></li>
+ <li><a href="/admin/variables">Variables</a></li>
+ </ul>
+ </li>
</ul>
<form class="navbar-search pull-left" action="<c:url value="/wikitty/search"/>">
Modified: trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/financial.jsp
===================================================================
--- trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/financial.jsp 2012-06-02 03:17:10 UTC (rev 172)
+++ trunk/chorem-webmotion/src/main/webapp/WEB-INF/jsp/financial.jsp 2012-06-04 05:08:40 UTC (rev 173)
@@ -9,3 +9,4 @@
<jsp:include page="/fragment/dashboard/invoice?query=${query}"/>
<jsp:include page="/fragment/dashboard/profitability?query=${query}"/>
+<jsp:include page="/fragment/dashboard/budget?query=${query}"/>
1
0
r172 - trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag
by bpoussin@users.chorem.org 02 Jun '12
by bpoussin@users.chorem.org 02 Jun '12
02 Jun '12
Author: bpoussin
Date: 2012-06-02 05:17:10 +0200 (Sat, 02 Jun 2012)
New Revision: 172
Url: http://chorem.org/repositories/revision/chorem/172
Log:
si le wikitty est null on ne met pas null, mais une chaine vide
Modified:
trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyInput.java
Modified: trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyInput.java
===================================================================
--- trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyInput.java 2012-06-02 02:23:42 UTC (rev 171)
+++ trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyInput.java 2012-06-02 03:17:10 UTC (rev 172)
@@ -236,6 +236,17 @@
String id = wikitty.getId() + "-" + extName + "-" + fieldName;
String value = wikitty.getFieldAsWikitty(extName, fieldName);
Wikitty wikittyValue = wikitty.getFieldAsWikitty(extName, fieldName, false);
+
+ String wlabel = "";
+ if (wikittyValue != null) {
+ wlabel = wikittyValue.toString();
+ }
+
+ String wid = "";
+ if (value != null) {
+ wid = value;
+ }
+
String url = "";
if (field.hasAllowed()) {
url = contextPath + "/wikitty-json/search?extension=" + field.getAllowed();
@@ -258,8 +269,8 @@
});
</script>
-<input type="text" id="text-<%=id%>" value="<%=wikittyValue%>"<%=getDynamicAttribute()%>/>
-<input type="hidden" id="hidden-<%=id%>" name="<%=name%>" value="<%=value%>"/>
+<input type="text" id="text-<%=id%>" value="<%=wlabel%>"<%=getDynamicAttribute()%>/>
+<input type="hidden" id="hidden-<%=id%>" name="<%=name%>" value="<%=wid%>"/>
}*/
}
1
0
r171 - trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions
by bpoussin@users.chorem.org 02 Jun '12
by bpoussin@users.chorem.org 02 Jun '12
02 Jun '12
Author: bpoussin
Date: 2012-06-02 04:23:42 +0200 (Sat, 02 Jun 2012)
New Revision: 171
Url: http://chorem.org/repositories/revision/chorem/171
Log:
fix bug in collection field "" must be empty collection and not collection with empty string
Modified:
trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java
Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java
===================================================================
--- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java 2012-06-01 17:38:34 UTC (rev 170)
+++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java 2012-06-02 02:23:42 UTC (rev 171)
@@ -1,7 +1,17 @@
package org.chorem.webmotion.actions;
import com.google.common.collect.LinkedHashMultimap;
+import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -22,16 +32,6 @@
import org.nuiton.wikitty.query.WikittyQueryParser;
import org.nuiton.wikitty.query.WikittyQueryResult;
-import java.io.ByteArrayInputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-
/**
*
* @author poussin
@@ -409,12 +409,13 @@
v = file.getFile();
} else {
String[] values = (String[]) params.get(fqfield);
+ System.out.println("ZZZZ fqfield:"+fqfield+" values: " + Arrays.toString(values) + " size:" + values.length);
if (w.getFieldType(fqfield).isCollection()) {
if (values.length == 1 && w.getFieldType(fqfield).getType() == WikittyTypes.WIKITTY) {
// petit hack si l'editeur utilise n'est pas un select,
// mais un input (et donc des valeurs separees par des ','
- values = values[0].split(",");
- System.out.println("YYYY " + Arrays.toString(values));
+ values = StringUtils.split(values[0], ",");
+ System.out.println("YYYY " + Arrays.toString(values) + " size: " + values.length);
}
v = values;
} else {
@@ -423,7 +424,7 @@
}
try {
w.setFqField(fqfield, v);
- System.out.println("XXX after field: " + w.getFqField(fqfield));
+ System.out.println("XXX after field: " + w.getFqField(fqfield) + "(" + ClassUtils.getSimpleName(w.getFqField(fqfield), "NULLclasse!!!") + ")");
} catch (Exception eee) {
String msg = String.format("Can't put value '%s' in field '%s'", v, fqfield);
error += "\n<li>" + msg + "</li>";
1
0
r170 - in trunk/chorem-webmotion/src/main: java/org/chorem/webmotion/actions java/org/wikitty/web/jsptag resources
by ymartel@users.chorem.org 01 Jun '12
by ymartel@users.chorem.org 01 Jun '12
01 Jun '12
Author: ymartel
Date: 2012-06-01 19:38:34 +0200 (Fri, 01 Jun 2012)
New Revision: 170
Url: http://chorem.org/repositories/revision/chorem/170
Log:
Prepare download of binary fields
Modified:
trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java
trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyDisplay.java
trunk/chorem-webmotion/src/main/resources/mapping
Modified: trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java
===================================================================
--- trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java 2012-06-01 16:16:37 UTC (rev 169)
+++ trunk/chorem-webmotion/src/main/java/org/chorem/webmotion/actions/GenericAction.java 2012-06-01 17:38:34 UTC (rev 170)
@@ -6,21 +6,23 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.ChoremClient;
+import org.chorem.ChoremConfigOption;
import org.debux.webmotion.server.WebMotionController;
import org.debux.webmotion.server.call.Call;
import org.debux.webmotion.server.call.UploadFile;
import org.debux.webmotion.server.render.Render;
import org.nuiton.wikitty.entities.Element;
+import org.nuiton.wikitty.entities.ElementField;
import org.nuiton.wikitty.entities.Wikitty;
import org.nuiton.wikitty.entities.WikittyExtension;
import org.nuiton.wikitty.entities.WikittyImpl;
import org.nuiton.wikitty.entities.WikittyTypes;
-import org.nuiton.wikitty.generator.WikittyTagValue;
import org.nuiton.wikitty.query.WikittyQuery;
import org.nuiton.wikitty.query.WikittyQueryMaker;
import org.nuiton.wikitty.query.WikittyQueryParser;
import org.nuiton.wikitty.query.WikittyQueryResult;
+import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -29,9 +31,6 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
-import org.chorem.ChoremConfig;
-import org.chorem.ChoremConfigOption;
-import org.nuiton.wikitty.entities.ElementField;
/**
*
@@ -456,7 +455,7 @@
/**
* Search the objects in relation with one given.
- * The method {@link this#searchAsMap(org.chorem.ChoremClient, String[], String)}
+ * The method {@link this#searchAsMap(org.chorem.ChoremClient, String[], String, Integer)}
* is called with a query created from the given id.
*
* @param client objet injecte par le framework webmotion/chorem
@@ -467,4 +466,14 @@
LinkedHashMultimap<String, Wikitty> map = searchAsMap(client, null, query, 0);
return renderView("search.jsp", "result", map);
}
+
+ public Render download(ChoremClient client, String id, String extension, String field) {
+ Wikitty wikitty = client.restore(id);
+ byte[] fieldValue = wikitty.getFieldAsBytes(extension, field);
+ ByteArrayInputStream stream = new ByteArrayInputStream(fieldValue);
+ //TODO ymartel
+ String name = wikitty.getFieldAsString(extension, "name");
+ return renderDownload(stream, name, "application/octet-stream");
+ }
+
}
Modified: trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyDisplay.java
===================================================================
--- trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyDisplay.java 2012-06-01 16:16:37 UTC (rev 169)
+++ trunk/chorem-webmotion/src/main/java/org/wikitty/web/jsptag/WikittyDisplay.java 2012-06-01 17:38:34 UTC (rev 170)
@@ -102,8 +102,8 @@
protected void viewBinary(JspWriter output, String contextPath, String name,
Wikitty wikitty, FieldType field, String extName , String fieldName)
throws JspException, IOException {
- String value = wikitty.getFieldAsString(extName, fieldName);
- /*{<%=name%> : <%=value%>}*/
+ String url = contextPath + "/wikitty/view/" + wikitty.getId() + "/" + extName + "/" + fieldName;
+ /*{<%=name%> : <a href="<%=url%>">Download</a>}*/
}
protected void viewBoolean(JspWriter output, String contextPath, String name,
Modified: trunk/chorem-webmotion/src/main/resources/mapping
===================================================================
--- trunk/chorem-webmotion/src/main/resources/mapping 2012-06-01 16:16:37 UTC (rev 169)
+++ trunk/chorem-webmotion/src/main/resources/mapping 2012-06-01 17:38:34 UTC (rev 170)
@@ -22,6 +22,7 @@
* /wikitty/edit/{id} action:GenericAction.edit
* /wikitty/delete/{id} action:GenericAction.delete
* /wikitty/save action:GenericAction.save
+* /wikitty/view/{id}/{extension}/{field} action:GenericAction.download
* /wikitty-json/searchField?q={query} action:GenericAction.searchFieldJson
* /wikitty-json/search?q={query} action:GenericAction.searchJson
* /wikitty-json/search?term={query} action:GenericAction.searchJson
1
0
Author: ymartel
Date: 2012-06-01 18:16:37 +0200 (Fri, 01 Jun 2012)
New Revision: 169
Url: http://chorem.org/repositories/revision/chorem/169
Log:
Add Category element. Quotation.type is now a Category
Modified:
trunk/chorem-entities/src/main/xmi/chorem-model.properties
trunk/chorem-entities/src/main/xmi/chorem-model.zargo
Modified: trunk/chorem-entities/src/main/xmi/chorem-model.properties
===================================================================
--- trunk/chorem-entities/src/main/xmi/chorem-model.properties 2012-06-01 16:13:04 UTC (rev 168)
+++ trunk/chorem-entities/src/main/xmi/chorem-model.properties 2012-06-01 16:16:37 UTC (rev 169)
@@ -68,7 +68,7 @@
org.chorem.entities.Attachment.class.tagvalue.version=6.0
org.chorem.entities.Attachment.class.tagvalue.toString=%Attachment.name|noname$s (%Attachment.mimetype|notype$s) %Attachment.date$tF
org.chorem.entities.Attachment.class.tagvalue.sortOrder=Attachment.name,Attachment.mimetype,Attachment.date
-org.chorem.entities.Quotation.class.tagvalue.version=9.0
+org.chorem.entities.Quotation.class.tagvalue.version=10.0
org.chorem.entities.Quotation.class.tagvalue.preload=Quotation.project;Quotation.customer;Quotation.supplier
org.chorem.entities.Quotation.class.tagvalue.toString=%Interval.beginDate$tF-%Interval.endDate$tF %Quotation.reference|noref$s(%Quotation.type|notype$s) %Quotation.description|nodescription$s
org.chorem.entities.Quotation.class.tagvalue.sortOrder=Interval.beginDate,Interval.endDate,Quotation.reference,Quotation.type,Quotation.description
Modified: trunk/chorem-entities/src/main/xmi/chorem-model.zargo
===================================================================
(Binary files differ)
1
0