#325 Some more progress made on manage permission templates validation
This commit is contained in:
parent
0dd5bff109
commit
448d7894ff
@ -193,7 +193,7 @@ function createEditModal($template, $features, $categories)
|
||||
aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<form action="manage_permission_templates.php" role="form" method="post" id="form">
|
||||
<form action="manage_permission_templates.php" role="form" method="post" id="form-<?php echo $template['id']; ?>">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
|
||||
aria-hidden="true">×</span></button>
|
||||
@ -206,6 +206,7 @@ function createEditModal($template, $features, $categories)
|
||||
<i class="fa fa-info-circle"></i> <?php echo $hesklang['template_is_admin_cannot_change']; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2">
|
||||
<label for="name"
|
||||
class="control-label"><?php echo $hesklang['template_name']; ?></label>
|
||||
@ -219,13 +220,14 @@ function createEditModal($template, $features, $categories)
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<h4><?php echo $hesklang['menu_cat']; ?></h4>
|
||||
|
||||
<div class="footerWithBorder blankSpace"></div>
|
||||
<?php foreach ($categories as $category): ?>
|
||||
<div class="form-group">
|
||||
<?php foreach ($categories as $category): ?>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<?php
|
||||
@ -233,33 +235,37 @@ function createEditModal($template, $features, $categories)
|
||||
if (in_array($category['id'], $enabledCategories) && !$showNotice) {
|
||||
$checked = 'checked';
|
||||
} ?>
|
||||
<input type="checkbox" name="categories[]"
|
||||
<input type="checkbox" name="categories[]" data-modal="<?php echo $template['id']; ?>-categories"
|
||||
data-checkbox="categories"
|
||||
value="<?php echo $category['id']; ?>" <?php echo $checked . $disabled; ?>>
|
||||
<?php echo $category['name']; ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<h4><?php echo $hesklang['allow_feat']; ?></h4>
|
||||
|
||||
<div class="footerWithBorder blankSpace"></div>
|
||||
<?php foreach ($features as $feature): ?>
|
||||
<div class="form-group">
|
||||
<?php foreach ($features as $feature): ?>
|
||||
<div class="checkbox">
|
||||
<label><?php
|
||||
$checked = '';
|
||||
if (in_array($feature, $enabledFeatures) && !$showNotice) {
|
||||
$checked = 'checked';
|
||||
} ?>
|
||||
<input type="checkbox" name="features[]"
|
||||
<input type="checkbox" name="features[]" data-modal="<?php echo $template['id']; ?>-features"
|
||||
data-checkbox="features"
|
||||
value="<?php echo $feature; ?>" <?php echo $checked . $disabled; ?>>
|
||||
<?php echo $hesklang[$feature]; ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -278,7 +284,9 @@ function createEditModal($template, $features, $categories)
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
$('#form').validator();
|
||||
buildValidatorForExistingPermissionTemplate('form-<?php echo $template['id']; ?>',
|
||||
'<?php echo $hesklang['select_at_least_one_value']; ?>',
|
||||
'<?php echo $template['id']; ?>')
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
@ -294,7 +302,7 @@ function buildCreateModal($features, $categories)
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<form action="manage_permission_templates.php" role="form" method="post">
|
||||
<form action="manage_permission_templates.php" role="form" method="post" id="create-form">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
|
||||
aria-hidden="true">×</span></button>
|
||||
@ -302,13 +310,16 @@ function buildCreateModal($features, $categories)
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2">
|
||||
<label for="name"
|
||||
class="control-label"><?php echo $hesklang['template_name']; ?></label>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" name="name"
|
||||
placeholder="<?php echo $hesklang['template_name']; ?>">
|
||||
placeholder="<?php echo $hesklang['template_name']; ?>" required>
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@ -316,33 +327,39 @@ function buildCreateModal($features, $categories)
|
||||
<h4><?php echo $hesklang['menu_cat']; ?></h4>
|
||||
|
||||
<div class="footerWithBorder blankSpace"></div>
|
||||
<?php foreach ($categories as $category): ?>
|
||||
<div class="form-group">
|
||||
<?php foreach ($categories as $category): ?>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="categories[]"
|
||||
data-modal="new-categories"
|
||||
data-checkbox="categories"
|
||||
value="<?php echo $category['id']; ?>">
|
||||
<?php echo $category['name']; ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<h4><?php echo $hesklang['allow_feat']; ?></h4>
|
||||
|
||||
<div class="footerWithBorder blankSpace"></div>
|
||||
<?php foreach ($features as $feature): ?>
|
||||
<div class="form-group">
|
||||
<?php foreach ($features as $feature): ?>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" name="features[]"
|
||||
data-modal="new-features"
|
||||
data-checkbox="features"
|
||||
value="<?php echo $feature; ?>">
|
||||
<?php echo $hesklang[$feature]; ?>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<div class="help-block with-errors"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -357,6 +374,9 @@ function buildCreateModal($features, $categories)
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
buildValidatorForPermissionTemplates('create-form', '<?php echo $hesklang['select_at_least_one_value']; ?>');
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -36,3 +36,43 @@ function buildValidatorForTicketSubmission(formName, validationText) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function buildValidatorForExistingPermissionTemplate(formId, validationText, templateId) {
|
||||
$('#' + formId).validator({
|
||||
custom: {
|
||||
checkbox: function($el) {
|
||||
var checkboxes = $('input[data-modal="' + templateId + '-' + $el.attr('data-checkbox') + '"]');
|
||||
|
||||
for (var checkbox in checkboxes) {
|
||||
if (checkboxes[checkbox].checked) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
errors: {
|
||||
checkbox: validationText
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function buildValidatorForPermissionTemplates(formId, validationText) {
|
||||
$('#' + formId).validator({
|
||||
custom: {
|
||||
checkbox: function($el) {
|
||||
var checkboxes = $('input[data-modal="new-' + $el.attr('data-checkbox') + '"]');
|
||||
|
||||
for (var checkbox in checkboxes) {
|
||||
if (checkboxes[checkbox].checked) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
errors: {
|
||||
checkbox: validationText
|
||||
}
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user