Commit 4570fb1c authored by Benjamin Rousselière's avatar Benjamin Rousselière
Browse files

feat/13541 : refactor object type buttons

parent 8d9944a9
Pipeline #8153 failed with stages
......@@ -1104,6 +1104,9 @@ msgstr "Cliquer pour modifier '%1$s'"
msgid "* At least one field must be filled in."
msgstr "* Au moins un champ doit être renseigné."
msgid "You must fill all required fields (*)"
msgstr "Vous devez remplir tous les champs requis (*)"
msgid "Export to "
msgstr "Exporter en "
......
......@@ -53,7 +53,7 @@
<label class="btn btn-default col-sm-4" title="Tout">
<input class="form-control" type="radio" name="hasParent" value="" checked/> Tout
</label>
<label class="btn btn-info active col-sm-4" title="Archive">
<label class="btn btn-default btn-info active col-sm-4" title="Archive">
<input class="form-control" type="radio" name="hasParent" value="0" checked/> Archive
</label>
<label class="btn btn-default col-sm-4" title="Objet d'archive">
......
......@@ -81,12 +81,18 @@
$("#archive_search").click();
}
});
// radio button
$("#archive_searchForm").on('click', 'label.btn', function () {
console.log($(this));
$(this).parent().find(".btn-info").removeClass('btn-info').addClass('btn-default');
$(this).addClass('btn-info');
if ($(this).find('.hasParent').length) {
if ($(this).hasClass("btn-info")) {
$(this).removeClass("btn-info").addClass("btn-default");
} else {
$(this).addClass("btn-info");
}
return;
}
$(this).parent().find(".btn-info").removeClass('btn-info').addClass('btn-default').removeClass("active");
$(this).removeClass("btn-default").addClass('btn-info');
})
$('#archive_searchByIdentifier').on('click', function () {
......@@ -109,6 +115,9 @@
$('#archive_search').on('click', function () {
var data = searchFormSerialize();
if (data == -1)
return;
$('#archive_search').prop('disabled', true);
$('#archive_searchForm').find('[name="archiveIdentifier"]').val('');
......@@ -116,7 +125,7 @@
type : 'GET',
url : '/recordsManagement/archives',
//data : $("#archive_searchForm").serialize(),
data : searchFormSerialize(),
data : data,
dataType : 'html',
success : function (response) {
$('#archive_searchResult').empty().html(response);
......@@ -133,7 +142,9 @@
$("#archive_resetForm").on("click", function () {
$('#archive_searchForm').find('input[type="text"], select').val('');
$('#archive_searchForm').find("input[name='archiveExpired'][value='']").parent().click();
$('#archive_searchForm').find('input[type="checkbox"]').bootstrapToggle('off');
$('#archive_searchForm').find('input[type="checkbox"][name!="hasParent"]').bootstrapToggle('off');
$("#archive_searchForm").find('input.hasParent').parent().removeClass('btn-info').addClass('btn-default').removeClass("active");
$("#archive_searchForm").find('input.hasParent[value!="2"]').click();
$('#originatorOrgInfo').hide();
delete $("#archive_searchForm [name=depositStartDate]").data('datepicker').setDates();
......@@ -153,16 +164,29 @@
parameters[$(this).attr('name')] = $(this).val();
}
});
var hasParent = [];
$('#archive_searchForm').find('input[type="checkbox"]').each(function(){
parameters[$(this).attr('name')] = $(this).prop("checked");
if ($(this).attr('name') != "hasParent") {
parameters[$(this).attr('name')] = $(this).prop("checked");
return;
}
if ($(this).parent().hasClass("btn-info"))
hasParent.push($(this).val());
});
if (hasParent.length == 0) {
gritter.show($("#required_fields").text(), false);
return -1;
}
if (hasParent.length == 1)
parameters.hasParent = hasParent[0];
parameters.archiveExpired = $("#archive_searchForm [name=archiveExpired]:checked").val();
parameters.depositStartDate = $("#archive_searchForm [name=depositStartDate]").data('datepicker').getFormattedDate('yyyy-mm-dd');
parameters.depositEndDate = $("#archive_searchForm [name=depositEndDate]").data('datepicker').getFormattedDate('yyyy-mm-dd');
$hasParent = $("#archive_searchForm [name=hasParent]:checked").val();
if ($hasParent != "") {
parameters.hasParent = $hasParent;
}
//parameters.originatingStartDate = $("#archive_searchForm [name=originatingStartDate]").data('datepicker').getFormattedDate('yyyy-mm-dd');
//parameters.originatingEndDate = $("#archive_searchForm [name=originatingEndDate]").data('datepicker').getFormattedDate('yyyy-mm-dd');
......
......@@ -207,20 +207,17 @@
<!-- OBJECT TYPE -->
<div class="col-md-4">
<div class="form-group">
<label class="col-sm-4 control-label">Type d'objet</label>
<label class="col-sm-4 control-label">Type d'objet <span style="color : red">*</span></label>
<div class="btn-group col-sm-8" data-toggle="buttons">
<label class="btn btn-default col-sm-[?merge isPublicArchive.bool().then(3, 4) ?]" title="Tout">
<input type="radio" name="hasParent" value=""/> Tout
<label class="btn btn-info active col-sm-[?merge isPublicArchive.bool().then(4, 6) ?]" title="Archive">
<input type="checkbox" class="hasParent" name="hasParent" value="0" checked/> Archive
</label>
<label class="btn btn-info active col-sm-[?merge isPublicArchive.bool().then(3, 4) ?]" title="Archive">
<input type="radio" name="hasParent" value="0" checked/> Archive
</label>
<label class="btn btn-default col-sm-[?merge isPublicArchive.bool().then(3, 4) ?]" title="Objet d'archive">
<input type="radio" name="hasParent" value="1"/> Objet
<label class="btn [?merge isPublicArchive.bool().then('btn-default', 'btn-info active') ?] col-sm-[?merge isPublicArchive.bool().then(4, 6) ?]" title="Objet d'archive">
<input type="checkbox" class="hasParent" name="hasParent" value="1"/> Objet
</label>
<?merge isPublicArchive.bool() ?>
<label class="btn btn-default col-sm-3" title="Document">
<input type="radio" name="hasParent" value="2"/> Document
<label class="btn btn-default col-sm-4" title="Document">
<input type="checkbox" class="hasParent" name="hasParent" value="2"/> Document
</label>
</div>
</div>
......@@ -248,4 +245,5 @@
<div class="col-md-12">
<hr style="height:1px;border:none;color:gray;background-color:gray;">
</div>
<span class="hide" id="required_fields">You must fill all required fields (*)</span>
</div>
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