Unverified Commit 9d51b31f authored by Jerome Boucher's avatar Jerome Boucher
Browse files

feat/16380 : fix datepicker and datetimepicker

parent e2d1f726
Pipeline #12448 failed with stages
in 43 seconds
......@@ -147,4 +147,9 @@ EOS;
$variableScript->appendChild($variableCdataSection);
$this->element->ownerDocument->getContainer()->appendChild($variableScript);
}
public function getParameters()
{
return json_encode($this->parameters);
}
}
......@@ -103,6 +103,10 @@ class archive
$descriptionSchemeName->translateType = $this->translator->getText($descriptionSchemeName->type);
}
$dateTimePickerPlugin = \laabs::newService('dependency/html/plugins/dateTimePicker/dateTimePicker', $this->view->getContainer());
$dateTimePickerPlugin->translate();
$this->view->setSource('dateTimePickerParams', $dateTimePickerPlugin->getParameters());
$this->view->setSource("maxResults", $maxResults);
$this->view->setSource("retentionRules", $retentionRules);
$this->view->setSource("emptyRole", $emptyRole);
......
......@@ -80,6 +80,7 @@
<!-- Message usage -->
<input type="hidden" id="useRestitutionMessages" value="[?merge useRestitutionMessages ?]">
<input type="hidden" id="useDestructionMessages" value="[?merge useDestructionMessages ?]">
<input type="hidden" id="datetimePickerParams" value="[?merge dateTimePickerParams ?]">
<div class="container-fluid" id="archive_searchResult"></div>
</div>
......@@ -250,29 +251,32 @@
case 'date':
var helperMin = $('<li/>').addClass("startDate helperContent col-sm-4 padding-5").appendTo(row);
var helperMax = $('<li/>').addClass("endDate helperContent col-sm-4 padding-5").appendTo(row);
$('#helperValueMin').clone().attr('type','date').attr('data-range','start').attr('name', helperName).appendTo(helperMin).prev().remove();
$('#helperValueMax').clone().attr('type','date').attr('data-range','end').attr('name', helperName).appendTo(helperMax).prev().remove();
var valueMinIdentifier = generateUniqIdentifier();
var valueMaxIdentifier = generateUniqIdentifier();
$('#helperValueMin').clone().attr('type','text').attr('data-range','start').attr('name', helperName).attr('id', valueMinIdentifier).addClass('datePicker').appendTo(helperMin).prev().remove();
$('#helperValueMax').clone().attr('type','text').attr('data-range','end').attr('name', helperName).attr('id', valueMaxIdentifier).appendTo(helperMax).prev().remove();
$('#' + valueMinIdentifier).datepicker();
$('#' + valueMaxIdentifier).datepicker();
break;
case 'datetime':
//TODO find a workaround for firefox (type datetime-local not compatible)
var helperMin = $('<li/>').addClass("startDate DateTimePicker helperContent col-sm-4 padding-5").appendTo(row);
var helperMax = $('<li/>').addClass("endDate DateTimePicker helperContent col-sm-4 padding-5").appendTo(row);
var helperMin = $('<li/>').addClass("startDate helperContent col-sm-4 padding-5").appendTo(row);
var helperMax = $('<li/>').addClass("endDate helperContent col-sm-4 padding-5").appendTo(row);
var dateNow = new Date();
$('#helperValueMin').datetimepicker({
format:'DD/MM/YYYY HH:mm:ss',
useCurrent: false,
defaultDate: dateNow
});
$('#helperValueMin').clone().attr('type','datetime-local').attr('data-range','start').attr('name', helperName).appendTo(helperMin).prev().remove();
$('#helperValueMax').datetimepicker({
format:'DD/MM/YYYY HH:mm:ss',
useCurrent: false,
defaultDate: dateNow
});
var valueMinIdentifier = generateUniqIdentifier();
var valueMaxIdentifier = generateUniqIdentifier();
$('#helperValueMin').clone().attr('type','text').attr('data-range','start').attr('name', helperName).attr('id', valueMinIdentifier).appendTo(helperMin).prev().remove();
$('#helperValueMax').clone().attr('type','text').attr('data-range','end').attr('name', helperName).attr('id', valueMaxIdentifier).appendTo(helperMax).prev().remove();
$('#helperValueMax').clone().attr('type','datetime-local').attr('data-range','end').attr('name', helperName).appendTo(helperMax).prev().remove();
dateTimePickerParams = JSON.parse($('#datetimePickerParams').val());
$('#' + valueMinIdentifier).datetimepicker(dateTimePickerParams);
$('#' + valueMaxIdentifier).datetimepicker(dateTimePickerParams);
break;
......@@ -374,6 +378,13 @@
$('#archive_searchResult').empty();
});
function generateUniqIdentifier () {
var randLetter = String.fromCharCode(65 + Math.floor(Math.random() * 26));
var uniqid = randLetter + Date.now();
return uniqid;
};
function getTypeahead () {
$.each(this.$("#helperList").find(".externalRefField"), function() {
var field = $(this);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment