From 10638029336c03e7c124e0c93846ea15eff5da5e Mon Sep 17 00:00:00 2001 From: qronald Date: Wed, 24 May 2017 08:39:04 -0400 Subject: [PATCH] up observations --- .../engine/methods/groups/groups_Ajax.php | 25 ++++++++----------- .../engine/templates/groups/groupsList.js | 22 ++++++---------- 2 files changed, 18 insertions(+), 29 deletions(-) diff --git a/workflow/engine/methods/groups/groups_Ajax.php b/workflow/engine/methods/groups/groups_Ajax.php index 867a575df..5a671195c 100644 --- a/workflow/engine/methods/groups/groups_Ajax.php +++ b/workflow/engine/methods/groups/groups_Ajax.php @@ -125,24 +125,19 @@ switch ($_POST['action']) { $result->success = true; $result->groups = $arrData; $result->total_groups = $data['totalCount']; - + G::header('Content-Type: application/json'); echo G::json_encode( $result ); break; case 'exitsGroupName': - $groupName = strip_tags($_POST['GRP_NAME']); - if ($groupName) { - require_once 'classes/model/Groupwf.php'; - G::LoadClass('Groupswf'); - $oGroup = new Groupwf(); - $oCriteria = $oGroup->loadByGroupname($_POST['GRP_NAME']); - $oDataset = GroupwfPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - $aRow = $oDataset->getRow(); - $response = ($aRow) ? \G::json_encode(['success' => true]) : \G::json_decode(['success' => false]); - } else { - $response = \G::json_encode(['success' => true, 'msg' => \G::LoadTranslation('ID_FIELD_INVALID')]); - } + require_once 'classes/model/Groupwf.php'; + G::LoadClass( 'Groupswf' ); + $oGroup = new Groupwf(); + $oCriteria = $oGroup->loadByGroupname( $_POST['GRP_NAME'] ); + $oDataset = GroupwfPeer::doSelectRS( $oCriteria ); + $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); + $oDataset->next(); + $aRow = $oDataset->getRow(); + $response = ($aRow) ? 'true' : 'false'; echo $response; break; case 'saveNewGroup': diff --git a/workflow/engine/templates/groups/groupsList.js b/workflow/engine/templates/groups/groupsList.js index 6833a45e8..c4cb48656 100644 --- a/workflow/engine/templates/groups/groupsList.js +++ b/workflow/engine/templates/groups/groupsList.js @@ -182,13 +182,7 @@ Ext.onReady(function(){ text: _("ID_SAVE"), handler: function (btn, ev) { - var reg = new RegExp(/(<([^>]+)>)/ig), - nameGroups = newForm.getForm().findField('name').getValue(); - if (reg.test(nameGroups)){ - Ext.Msg.alert(_('ID_WARNING'), _("ID_FIELD_INVALID", _("ID_GROUP_NAME"))); - newForm.getForm().findField('name').setValue(""); - return false; - } else if (nameGroups.trim() == "") { + if( newForm.getForm().findField('name').getValue().trim() == "") { Ext.Msg.alert(_('ID_WARNING'), _("ID_FIELD_REQUIRED", _("ID_GROUP_NAME"))); newForm.getForm().findField('name').setValue(""); return false; @@ -440,8 +434,8 @@ CheckGroupName = function(grp_name, function_success, function_failure){ params: {action: 'exitsGroupName', GRP_NAME: grp_name}, success: function(resp, opt){ viewport.getEl().unmask(); - var response = JSON.parse(resp.responseText); - (!response.success) ? function_success() : function_failure(response.msg); + var checked = eval(resp.responseText); + (!checked) ? function_success() : function_failure(); }, failure: function(r,o) { viewport.getEl().unmask(); @@ -458,11 +452,11 @@ SaveNewGroupAction = function(){ }; //Show Duplicate Group Name Message -DuplicateGroupName = function (msg) { - Ext.getCmp("btnCreateSave").setDisabled(false); - Ext.getCmp("btnUpdateSave").setDisabled(false); - newForm.getForm().findField('name').setValue(""); - PMExt.warning(_('ID_GROUPS'), msg ? msg : _('ID_MSG_GROUP_NAME_EXISTS')); +DuplicateGroupName = function(){ + Ext.getCmp("btnCreateSave").setDisabled(false); + Ext.getCmp("btnUpdateSave").setDisabled(false); + + PMExt.warning(_('ID_GROUPS'), _('ID_MSG_GROUP_NAME_EXISTS')); }; //Save New Group