use jquery validation

This commit is contained in:
Uwe Steinmann 2021-05-31 19:38:26 +02:00
parent 9ae4a01705
commit 4d931b74e5

View File

@ -33,33 +33,22 @@ class SeedDMS_View_WorkflowActionsMgr extends SeedDMS_Theme_Style {
function js() { /* {{{ */ function js() { /* {{{ */
header('Content-Type: application/javascript; charset=UTF-8'); header('Content-Type: application/javascript; charset=UTF-8');
parent::jsTranslations(array('js_form_error', 'js_form_errors'));
?> ?>
function checkForm(num) function runValidation() {
{ $("#form1").validate({
msg = new Array() rules: {
name: {
if($("#name").val() == "") msg.push("<?php printMLText("js_no_name");?>"); required: true
if (msg != "") },
{ },
noty({ messages: {
text: msg.join('<br />'), name: "<?php printMLText("js_no_name");?>",
type: 'error', }
dismissQueue: true, });
layout: 'topRight',
theme: 'defaultTheme',
_timeout: 1500,
});
return false;
}
else
return true;
} }
$(document).ready( function() { $(document).ready( function() {
$('body').on('submit', '#form', function(ev){
if(checkForm()) return;
ev.preventDefault();
});
$( "#selector" ).change(function() { $( "#selector" ).change(function() {
$('div.ajax').trigger('update', {workflowactionid: $(this).val()}); $('div.ajax').trigger('update', {workflowactionid: $(this).val()});
}); });
@ -106,21 +95,13 @@ $(document).ready( function() {
$selworkflowaction = $this->params['selworkflowaction']; $selworkflowaction = $this->params['selworkflowaction'];
if($selworkflowaction && !$selworkflowaction->isUsed()) { if($selworkflowaction && !$selworkflowaction->isUsed()) {
?> $button = array(
<div class="btn-group"> 'label'=>getMLText('action'),
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> 'menuitems'=>array(
<?php echo getMLText('action'); ?> )
<span class="caret"></span> );
</a> $button['menuitems'][] = array('label'=>'<i class="fa fa-remove"></i> '.getMLText("rm_workflow_action"), 'link'=>'../op/op.RemoveWorkflowAction.php?workflowactionid='.$selworkflowaction->getID().'&formtoken='.createFormKey('removeworkflowaction'));
<ul class="dropdown-menu"> self::showButtonwithMenu($button);
<?php
if(!$selworkflowaction->isUsed()) {
echo '<li><a href="../op/op.RemoveWorkflowAction.php?workflowactionid='.$selworkflowaction->getID().'&formtoken='.createFormKey('removeworkflowaction').'"><i class="fa fa-remove"></i> '.getMLText("rm_workflow_action").'</a><li>';
}
?>
</ul>
</div>
<?php
} }
} /* }}} */ } /* }}} */
@ -131,7 +112,7 @@ $(document).ready( function() {
} }
} }
?> ?>
<form action="../op/op.WorkflowActionsMgr.php" method="post" class="form-horizontal"> <form action="../op/op.WorkflowActionsMgr.php" method="post" class="form-horizontal" id="form1" name="form1">
<?php <?php
if($action) { if($action) {
echo createHiddenFieldWithKey('editworkflowaction'); echo createHiddenFieldWithKey('editworkflowaction');
@ -176,6 +157,9 @@ $(document).ready( function() {
$workflowactions = $dms->getAllWorkflowActions(); $workflowactions = $dms->getAllWorkflowActions();
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/vendors/jquery-validation/jquery.validate.js"></script>'."\n", 'js');
$this->htmlAddHeader('<script type="text/javascript" src="../views/'.$this->theme.'/styles/validation-default.js"></script>'."\n", 'js');
$this->htmlStartPage(getMLText("admin_tools")); $this->htmlStartPage(getMLText("admin_tools"));
$this->globalNavigation(); $this->globalNavigation();
$this->contentStart(); $this->contentStart();
@ -209,7 +193,7 @@ $(document).ready( function() {
$this->columnEnd(); $this->columnEnd();
$this->columnStart(8); $this->columnStart(8);
?> ?>
<div class="ajax" data-view="WorkflowActionsMgr" data-action="form" <?php echo ($selworkflowaction ? "data-query=\"workflowactionid=".$selworkflowaction->getID()."\"" : "") ?>></div> <div class="ajax" data-view="WorkflowActionsMgr" data-action="form" data-afterload="()=>{runValidation();}" <?php echo ($selworkflowaction ? "data-query=\"workflowactionid=".$selworkflowaction->getID()."\"" : "") ?>></div>
</div> </div>
</div> </div>