Skip to content

Commit

Permalink
Add properties to enable datetime display upon loading site and toggl…
Browse files Browse the repository at this point in the history
…e time in datetimepicker
  • Loading branch information
Antoniafriedrich committed Sep 2, 2024
1 parent ac90ba1 commit ccaef67
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@
</label>
<div class="col-md-6 center-vertical">
<mir:dateRangeInput xpath="mods:originInfo[@eventType='publication']/mods:dateIssued[@encoding='w3cdtf']" class="datetimepicker mainDate"
placeholder="{i18n:mir.placeholder.date}" type="publication" />
placeholder="{i18n:mir.placeholder.date}" type="publication" startsWithDateTime="false" showDateTimeOption="false"/>
<span class="fas fa-chevron-down expand-item" title="{i18n:mir.help.expand}" aria-hidden="true"></span>
</div>
<mir:help-pmud help-text="{i18n:mir.help.date.issued.10}" pmud="false" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,19 @@ $(document).ready(function() {
$(elm).attr("data-format", "range");
var input = $(elm).find("div.date-simple > input");
var simpleVal = $(input).val();
var clock = $(elm).find("div.date-range > input.startDate").hasClass("withTime");
if (simpleVal != "") {
$(elm).find("div.date-range > input.startDate").val(simpleVal);
$(input).val("");
updateDatePicker($(elm).find("div.date-range > input.startDate"), false);
updateDatePicker($(input));
}
updateDatePicker($(elm).find("div.date-range > input.startDate"), clock);
updateDatePicker($(input));
var endDate = $(input).attr("data-end");
if(endDate != "" && endDate != undefined){
$(elm).find("div.date-range > input.endDate").val(endDate);
updateDatePicker($(elm).find("div.date-range > input.endDate"), false);
}
updateDatePicker($(elm).find("div.date-range > input.endDate"), clock);

}

function setDateToSimple(elm){
Expand Down Expand Up @@ -321,9 +323,12 @@ $(document).ready(function() {
// Enables the datetimepicker
if (jQuery.fn.datepicker) {
$('.datetimepicker').find('input').each( function(index, elm){
if ($(elm).val().includes("T")) {

if ($(elm).val().includes("T") || $(elm).hasClass('startsWithDatetime')) {
pickDatePickerFormatAndAdd(elm, true);
if ($(elm).val().trim() !== "") {
initTime(elm);
}
} else {
pickDatePickerFormatAndAdd(elm, false);
}
Expand Down
2 changes: 1 addition & 1 deletion mir-module/src/main/resources/config/mir/mycore.properties
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ MCR.Jersey.Resource.Packages=%MCR.Jersey.Resource.Packages%,org.mycore.mir.stati
##############################################################################
# xEditor #
##############################################################################
MIR.Editor.AddTimeWidget=false

# exclude genres from licence validation
MIR.Editor.Validate.Genre.Licence=journal newspaper series lecture blog

Expand Down
49 changes: 40 additions & 9 deletions mir-module/src/main/resources/xsl/editor/mir2xeditor.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
xmlns:i18n="xalan://org.mycore.services.i18n.MCRTranslation" xmlns:mir="http://www.mycore.de/mir"
exclude-result-prefixes="xsl mir i18n">

<xsl:param name="MIR.Editor.AddTimeWidget"/>

<xsl:include href="copynodes.xsl" />
<xsl:variable name="institutesURI">
Expand Down Expand Up @@ -131,7 +130,10 @@
<xed:output i18n="{@label}" />
</label>
<div class="col-md-6 {@class}" data-type="{@type}">
<xsl:call-template name="mir-dateRange"/>
<xsl:call-template name="mir-dateRange">
<xsl:with-param name="showDateTimeOption" select="@showDateTimeOption"/>
<xsl:with-param name="startsWithDateTime" select="@startsWithDateTime"/>
</xsl:call-template>
</div>
<div class="col-md-3">
<xsl:if test="string-length(@help-text) &gt; 0">
Expand All @@ -143,11 +145,35 @@

<xsl:template match="mir:dateRangeInput">
<div class="{@class}" data-type="{@type}">
<xsl:call-template name="mir-dateRange"/>
<xsl:call-template name="mir-dateRange">
<xsl:with-param name="showDateTimeOption" select="@showDateTimeOption"/>
</xsl:call-template>
</div>
</xsl:template>

<xsl:template name="mir-dateRange">
<xsl:param name="showDateTimeOption" select="false" />
<xsl:param name="startsWithDateTime" select="false" />
<xsl:variable name="timeClass">
<xsl:choose>
<xsl:when test="$startsWithDateTime='true'">
<xsl:text>startsWithDatetime</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text></xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="dateRangeWithTime">
<xsl:choose>
<xsl:when test="$showDateTimeOption='true'">
<xsl:text>withTime</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text></xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="apos">'</xsl:variable>
<xsl:variable name="xpathSimple" >
<xsl:value-of select="concat(@xpath,'[not(@point)]')"/>
Expand All @@ -167,32 +193,37 @@
<div class="date-format" data-format="simple">
<div class="date-simple {$hiddenclasssimple} input-group mb-1">
<xed:bind xpath="{$xpathSimple}">
<input type="text" class="form-control" autocomplete="off">
<input type="text" class="form-control {$timeClass}" autocomplete="off">
<xsl:copy-of select="@placeholder" />
</input>
</xed:bind>
<xsl:call-template name="date-selectFormat"/>
<xsl:call-template name="date-selectFormat">
<xsl:with-param name="showDateTimeOption" select="$showDateTimeOption"/>
</xsl:call-template>
</div>
<div class="date-range input-group {$hiddenclassrange} input-daterange">
<xed:bind xpath="{$xpathStart}">
<input type="text" class="form-control startDate" data-point="start">
<input type="text" class="form-control {$dateRangeWithTime} startDate" data-point="start">
<xsl:copy-of select="@placeholder" />
</input>
</xed:bind>
<span class="fas fa-minus input-group-text" aria-hidden="true"></span>
<xed:bind xpath="{$xpathEnd}">
<input type="text" class="form-control endDate" data-point="end">
<input type="text" class="form-control {$dateRangeWithTime} endDate" data-point="end">
<xsl:copy-of select="@placeholder" />
</input>
</xed:bind>
<xsl:if test="not(@onlyRange = 'true') ">
<xsl:call-template name="date-selectFormat"/>
<xsl:call-template name="date-selectFormat">
<xsl:with-param name="showDateTimeOption" select="$showDateTimeOption"/>
</xsl:call-template>
</xsl:if>
</div>
</div>
</xsl:template>

<xsl:template name="date-selectFormat">
<xsl:param name="showDateTimeOption" select="false" />
<div class="input-group-btn date-selectFormat input-group-append">
<button class="btn btn-secondary dropdown-toggle" data-toggle="dropdown"><span class="caret"></span><span class="sr-only">Toggle Dropdown</span></button>
<ul class="dropdown-menu dropdown-menu-right" role="menu">
Expand All @@ -206,7 +237,7 @@
<xsl:value-of select="i18n:translate('mir.date.period')" />
</a>
</li>
<xsl:if test="$MIR.Editor.AddTimeWidget='true'">
<xsl:if test="$showDateTimeOption='true'">
<li>
<a href="#" class="date-timeOption dropdown-item">
<xsl:value-of select="i18n:translate('mir.date.datetime')" />
Expand Down

0 comments on commit ccaef67

Please sign in to comment.