Skip to content

Commit

Permalink
Fixed issue #09454: Token edit fails after mandatory have been added …
Browse files Browse the repository at this point in the history
…(and left blank)

Dev Added a jqGrid "editrules" option for mandatory attributes (prevents saving the row if madatory attributes are left blank)
  • Loading branch information
tpartner committed Feb 28, 2015
1 parent 9560573 commit 03bfb76
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
13 changes: 12 additions & 1 deletion application/views/admin/token/browse.php
Expand Up @@ -46,7 +46,11 @@
{
foreach ($attributes as $sFieldname=>$aData)
{
$uidNames[] = '{ "name":"' . $sFieldname . '", "index":"' . $sFieldname . '", "sorttype":"string", "sortable": true, "align":"left", "editable":true, "width":75}';
$customEdit = '';
if($aData['mandatory'] == 'Y'){
$customEdit = ', editrules:{custom:true, custom_func:checkMandatoryAttr}';
}
$uidNames[] = '{ "name":"' . $sFieldname . '", "index":"' . $sFieldname . '", "sorttype":"string", "sortable": true, "align":"left", "editable":true, "width":75' . $customEdit . '}';
$aColumnHeaders[]=$aData['description'];
}
$columnNames='"'.implode('","',$aColumnHeaders).'"';
Expand Down Expand Up @@ -133,6 +137,13 @@
{ "name":"validuntil", "index":"validuntil","align":"left", "sorttype":"int", "sortable": true,"width":160,"editable":true}
<?php if (count($uidNames)) echo ','.implode(",\n", $uidNames); ?>];
var colInformation=<?php echo $sJsonColumnInformation ?>

function checkMandatoryAttr(value, colname) {
if (value == '')
return [false, 'Please enter a value for <strong>'+colname+'</strong>'];
else
return [true,''];
}
</script>
<div class='menubar'>
<div class='menubar-title ui-widget-header'>
Expand Down
13 changes: 11 additions & 2 deletions scripts/admin/tokens.js
Expand Up @@ -193,8 +193,7 @@ $(document).ready(function() {
.appendTo(jQuery(this).parent().parent())
.click(function()
{
jQuery('#displaytokens').saveRow(row.attr('id'));
func();
jQuery('#displaytokens').saveRow(row.attr('id'), null, null, {}, function(){func();});
});
});
updatePageAfterGrid();
Expand Down Expand Up @@ -423,8 +422,18 @@ $(document).ready(function() {
reloadAfterSubmit: true,
closeOnEspace:true
});
// Center modal dialogs
$.jgrid.jqModal = $.extend($.jgrid.jqModal || {}, {
beforeOpen: centerInfoDialog
});
});

function centerInfoDialog() {
var infoDialog = $("#info_dialog");
var dialogparent = infoDialog.parent();
infoDialog.css({ 'left': Math.round((dialogparent.width() - infoDialog.width()) / 2)+'px' });
}

function updatePageAfterGrid(){
var oGrid=$("#displaytokens");
var iLastPage=parseInt(oGrid.jqGrid('getGridParam', 'lastpage'));
Expand Down

0 comments on commit 03bfb76

Please sign in to comment.