Piotr Labudda 8 лет назад
Родитель
Сommit
06518263fc
2 измененных файлов с 34 добавлено и 36 удалено
  1. 32 1
      SE/se-lib/Route/ViewTableAjax.php
  2. 2 35
      SE/se-lib/TableAjax.php

+ 32 - 1
SE/se-lib/Route/ViewTableAjax.php

@@ -28,7 +28,7 @@ class Route_ViewTableAjax extends RouteBase {
 			$tblLabel = implode(" - ", $tblLabel);
 		}
 		$tbl->setSyncUrl($syncUrl);
-		$tbl->showProcesInitFiltr = true;
+		$tbl->showProcesInitFiltr = $this->getLink("procesInitFiltrAjax", [ 'namespace' => $acl->getNamespace() ]);
 		$tbl->useUserTableFilter = $this->getLink("getUserTableFilterAjax");
 		$tbl->setLabel($tblLabel);
 		$tbl->addRowFunction('edit');
@@ -894,4 +894,35 @@ class Route_ViewTableAjax extends RouteBase {
 		];
 	}
 
+	public function procesInitFiltrAjaxAction() {
+		Response::sendTryCatchJson([$this, 'procesInitFiltrAjax'], $args = $_GET);
+	}
+	public function procesInitFiltrAjax($args) { // ajaxFileRemove
+		$namespace = V::get('namespace', '', $args, 'word');
+		if (!$namespace) throw new Exception("Missing namespace");
+		$acl = Core_AclHelper::getAclByNamespace($namespace, $forceTblAclInit = ('1' == V::get('_force', '', $_GET)));
+
+		$pInitList = User::getAcl()->getTableProcesInitList($acl->getID());
+		DBG::log($pInitList, 'array', "\$pInitList");
+		if (!empty($pInitList)) {
+			$procesIds = array_keys($pInitList);
+			$mapTree = ACL::getProcesInitMapTreeOnlyIds($procesIds);
+			DBG::log($mapTree, 'array', "\$mapTree");
+			DBG::log($pInitList, 'array', "\$pInitList");
+			$pInitListSelected = User::getAcl()->getPermsFiltrProcesId();
+			return [
+				'type' => 'success',
+				'msg' => 'ok',
+				'pInitData' => [
+					'pInitList' => $pInitList,
+					'mapTree' => $mapTree,
+					'pInitListSelected' => $pInitListSelected,
+				],
+			];
+		}
+		return [
+			'type' => 'success'
+		];
+	}
+
 }

+ 2 - 35
SE/se-lib/TableAjax.php

@@ -23,7 +23,7 @@ class TableAjax extends ViewAjax {
 	public $_pageSizes = array();
 	public $_filterInit = null;
 	public $_forceFilterInit = null;
-	public $showProcesInitFiltr = false;
+	public $showProcesInitFiltr = null;
 	public $useUserTableFilter = false;
 	public $syncUrl = null;
 
@@ -234,11 +234,6 @@ class TableAjax extends ViewAjax {
 		return $rowFunctions;
 	}
 
-	private function getProcesInitSelected() {
-		$userAcl = User::getAcl();
-		return $userAcl->getPermsFiltrProcesId();
-	}
-
 	public function allowTreeView() {
 		if ($this->_tbl == 'CRM_LISTA_ZASOBOW') return true;
 		if ($this->_tbl == 'CRM_PROCES') return true;
@@ -450,7 +445,7 @@ class TableAjax extends ViewAjax {
 		$clsName = __CLASS__;
 		UI::inlineJS(__FILE__ . '.procesInitFiltr.js', [
 			'JS_FUNCTION_NAME' => $jsToogleFiltrProcesuFunctionName,
-			'URL_GET_PROCES_INIT_FILTR' => "index-ajax.php?_zasobID={$this->_zasobID}&_cls={$clsName}&_hash={$this->_htmlID}&_task=PROCES_INIT_FILTR",
+			'URL_GET_PROCES_INIT_FILTR' => $this->showProcesInitFiltr,
 			'ID_ZASOB' => $this->_zasobID,
 		]);
 		?>
@@ -4044,10 +4039,6 @@ function hidePopover() {
 				$this->sendAjaxResponseJson('ajaxTheGeomSave', $_REQUEST);
 				break;
 			}
-			case 'PROCES_INIT_FILTR': {
-				$this->sendAjaxResponseJson('ajaxProcesInitFiltr', $_REQUEST);
-				break;
-			}
 			default:
 				$this->sendAjaxResponseJson('ajaxData', $_REQUEST);
 		}
@@ -5919,28 +5910,4 @@ jQuery(document).ready(function(){
 		exit;
 	}
 
-	private function ajaxProcesInitFiltr($args) {// ajax task 'PROCES_INIT_FILTR'
-		$response = new stdClass();
-
-		$pInitList = array();// [proces_init_id] => label (DESC)
-		$userAcl = User::getAcl();
-		$pInitList = $userAcl->getTableProcesInitList($this->_zasobID);
-
-		DBG::log($pInitList, 'array', "\$pInitList");
-		if (!empty($pInitList)) {
-			$procesIds = array_keys($pInitList);
-			$mapTree = ACL::getProcesInitMapTreeOnlyIds($procesIds);
-			DBG::log($mapTree, 'array', "\$mapTree");
-			DBG::log($pInitList, 'array', "\$pInitList");
-			$pInitListSelected = $this->getProcesInitSelected();
-			$response->pInitData = new stdClass();
-			$response->pInitData->pInitList = $pInitList;
-			$response->pInitData->mapTree = $mapTree;
-			$response->pInitData->pInitListSelected = $pInitListSelected;
-		}
-		$response->type = 'success';
-
-		return $response;
-	}
-
 }