mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 15:32:13 +00:00
use jquery validation
This commit is contained in:
parent
8f5a699f0c
commit
13d1e92434
|
@ -33,34 +33,22 @@ class SeedDMS_View_WorkflowStatesMgr extends SeedDMS_Theme_Style {
|
|||
|
||||
function js() { /* {{{ */
|
||||
header('Content-Type: application/javascript; charset=UTF-8');
|
||||
parent::jsTranslations(array('js_form_error', 'js_form_errors'));
|
||||
?>
|
||||
|
||||
function checkForm(num)
|
||||
{
|
||||
msg = new Array();
|
||||
|
||||
if($("#name").val() == "") msg.push("<?php printMLText("js_no_name");?>");
|
||||
if (msg != "")
|
||||
{
|
||||
noty({
|
||||
text: msg.join('<br />'),
|
||||
type: 'error',
|
||||
dismissQueue: true,
|
||||
layout: 'topRight',
|
||||
theme: 'defaultTheme',
|
||||
_timeout: 1500,
|
||||
});
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return true;
|
||||
function runValidation() {
|
||||
$("#form1").validate({
|
||||
rules: {
|
||||
name: {
|
||||
required: true
|
||||
},
|
||||
},
|
||||
messages: {
|
||||
name: "<?php printMLText("js_no_name");?>",
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$('body').on('submit', '#form1', function(ev){
|
||||
if(checkForm()) return;
|
||||
ev.preventDefault();
|
||||
});
|
||||
$( "#selector" ).change(function() {
|
||||
$('div.ajax').trigger('update', {workflowstateid: $(this).val()});
|
||||
});
|
||||
|
@ -107,21 +95,13 @@ $(document).ready(function() {
|
|||
$selworkflowstate = $this->params['selworkflowstate'];
|
||||
|
||||
if($selworkflowstate && !$selworkflowstate->isUsed()) {
|
||||
?>
|
||||
<div class="btn-group">
|
||||
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
<?php echo getMLText('action'); ?>
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<?php
|
||||
if(!$selworkflowstate->isUsed()) {
|
||||
echo '<li><a href="../op/op.RemoveWorkflowState.php?workflowstateid='.$selworkflowstate->getID().'&formtoken='.createFormKey('removeworkflowstate').'"><i class="fa fa-remove"></i> '.getMLText("rm_workflow_state").'</a><li>';
|
||||
}
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
$button = array(
|
||||
'label'=>getMLText('action'),
|
||||
'menuitems'=>array(
|
||||
)
|
||||
);
|
||||
$button['menuitems'][] = array('label'=>'<i class="fa fa-remove"></i> '.getMLText("rm_workflow_state"), 'link'=>'../op/op.RemoveWorkflowState.php?workflowstateid='.$selworkflowstate->getID().'&formtoken='.createFormKey('removeworkflowstate'));
|
||||
self::showButtonwithMenu($button);
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
|
@ -132,7 +112,7 @@ $(document).ready(function() {
|
|||
}
|
||||
}
|
||||
?>
|
||||
<form action="../op/op.WorkflowStatesMgr.php" method="post" class="form-horizontal">
|
||||
<form action="../op/op.WorkflowStatesMgr.php" method="post" class="form-horizontal" id="form1" name="form1">
|
||||
<?php
|
||||
if($state) {
|
||||
echo createHiddenFieldWithKey('editworkflowstate');
|
||||
|
@ -189,6 +169,9 @@ $(document).ready(function() {
|
|||
|
||||
$workflowstates = $dms->getAllWorkflowStates();
|
||||
|
||||
$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->globalNavigation();
|
||||
$this->contentStart();
|
||||
|
@ -222,7 +205,7 @@ $(document).ready(function() {
|
|||
$this->columnEnd();
|
||||
$this->columnStart(8);
|
||||
?>
|
||||
<div class="ajax" data-view="WorkflowStatesMgr" data-action="form" <?php echo ($selworkflowstate ? "data-query=\"workflowstateid=".$selworkflowstate->getID()."\"" : "") ?>></div>
|
||||
<div class="ajax" data-view="WorkflowStatesMgr" data-action="form" data-afterload="()=>{runValidation();}" <?php echo ($selworkflowstate ? "data-query=\"workflowstateid=".$selworkflowstate->getID()."\"" : "") ?>></div>
|
||||
<?php
|
||||
$this->columnEnd();
|
||||
$this->rowEnd();
|
||||
|
|
Loading…
Reference in New Issue
Block a user