Commit 53fe05c1 authored by Sebastian Castro's avatar Sebastian Castro

Improve form builder (name uniqueness, contact email uniqueness, trash icon for delete)

parent 06bda8fc
......@@ -96,15 +96,32 @@
});
setInterval(function() {
$('.fld-name').each(function() {
// prevent adding two contat email attributes
$('.input-control[data-type=email]').toggle($('.email-field').length == 0);
// get all input names (used after for uniqueness)
var allNames = [];
$('.fld-name').each(function() {allNames.push($(this).val()); });
$('.fld-name:visible').each(function() {
// Slugify
$(this).val($(this).val().replace(/[^a-z^A-Z^_^0-9]/g, '_'));
// Check names are unique
var count = 0;
for(var i = 0; i < allNames.length; ++i) if (allNames[i] == $(this).val()) count++;
if (count > 1) $(this).val($(this).val() + "_bis");
});
$('#{{ form.vars.id }}').val(JSON.stringify(formBuilder.actions.getData()));
// Changes icons and icones helpers
$('a[type=remove].icon-cancel').removeClass('icon-cancel').addClass('fa fa-trash');
$('a[type=copy].icon-copy').attr('title', 'Dupliquer');
$('a[type=edit].icon-pencil').attr('title', 'Editer/Masquer');
}, 300);
$('input[name="access"]').change(function() {
$(this).find('input[name="roles[]"]').prop('checked', $(this).is(':checked'));
});
});
});
}
</script>
......
Markdown is supported
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