Преглед изворни кода

added getItem from AclQueryFeatures in TableAjax, small updates

Piotr Labudda пре 9 година
родитељ
комит
4110f2389c

+ 47 - 0
SE/schema/ant-object/default_db.CRM_WSKAZNIK/CRM_WSKAZNIK/CRM_WSKAZNIK.xsd

@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+          xmlns:gml="http://www.opengis.net/gml"
+          xmlns:p5="https://biuro.biall-net.pl/wfs"
+          xmlns:default_db="https://biuro.biall-net.pl/wfs/default_db"
+          xmlns:default_objects="https://biuro.biall-net.pl/wfs/default_objects"
+          xmlns:p5_objects="https://biuro.biall-net.pl/wfs/objects"
+          xmlns:default_db__x3A__CRM_WSKAZNIK="https://biuro.biall-net.pl/wfs/default_db/table/CRM_WSKAZNIK.xsd"
+          elementFormDefault="qualified"
+          targetNamespace="https://biuro.biall-net.pl/wfs/default_db/table/CRM_WSKAZNIK.xsd"
+          version="1.0.0">
+ <xsd:import namespace="http://www.opengis.net/gml" schemaLocation="https://biuro.biall-net.pl/dev-pl/se-master/schema/gml/2.1.2/feature.xsd"/>
+ <!--typeName 'default_db:CRM_WSKAZNIK'-->
+ <xsd:complexType name="CRM_WSKAZNIKType" p5:web_link="https://biuro.biall-net.pl/dev-pl/se-master/index.php?_route=ViewTableAjax&amp;namespace=default_db/CRM_WSKAZNIK/CRM_WSKAZNIK" p5:last_update_date="2017-05-29T18:34:00" xmlns:p5="https://biuro.biall-net.pl/wfs">
+  <xsd:complexContent>
+   <xsd:extension base="gml:AbstractFeatureType">
+    <xsd:sequence>
+     <xsd:element minOccurs="1" maxOccurs="1" name="ID" type="xsd:integer" nillable="true" p5:id_zasob="1514" p5:label="Nr" p5:description="Numer unikalny wskaźnika" xmlns:p5="https://biuro.biall-net.pl/wfs"/>
+     <xsd:element minOccurs="0" maxOccurs="1" name="ID_PROCES" type="xsd:integer" nillable="true" p5:id_zasob="1516" p5:label="nr proc" p5:description="Numer skojarzonego ze wskaźnikiem procesu, do którego powiązywany jest zasób." p5:allow_write="true" p5:allow_create="true" xmlns:p5="https://biuro.biall-net.pl/wfs"/>
+     <xsd:element minOccurs="0" maxOccurs="1" name="ID_ZASOB" type="xsd:integer" nillable="true" p5:id_zasob="1517" p5:label="Nr zasobu" p5:description="Numer powiązanego zasobu do danego procesu. " p5:allow_write="true" p5:allow_create="true" xmlns:p5="https://biuro.biall-net.pl/wfs"/>
+     <xsd:element minOccurs="0" maxOccurs="1" name="OPIS_ZASOB" type="xsd:string" nillable="true" p5:id_zasob="1518" p5:label="opis" p5:description="Dodatkowy opcjonalny opis w jaki sposób należy używać zasobu. Np. &lt;i&gt;ustaw na termostacie żądaną temperaturę.&lt;/i&gt;" p5:allow_write="true" p5:allow_create="true" xmlns:p5="https://biuro.biall-net.pl/wfs"/>
+     <xsd:element minOccurs="0" maxOccurs="1" name="ID_PRZYPADEK" type="xsd:integer" nillable="true" p5:id_zasob="1520" p5:label="uprawnienie" p5:description="Uprawnienie/przypadek użycia danego zasobu. W zależności od ustawienia w tym polu system może zapewniać np. R - odczyt, W - edycję, C - tworzenie nowego rekordu, V - widzenie wszystkich rekordów nie tylko tych, ze swojej grupy , S - edycje wszystkich rekordów - nie tylko ze swojej grupy uprawnień, O - widzenie rekordów tylko tych, do których ma się prawo zapisu." p5:allow_write="true" p5:allow_create="true" xmlns:p5="https://biuro.biall-net.pl/wfs"/>
+     <xsd:element minOccurs="0" maxOccurs="1" name="A_RECORD_CREATE_AUTHOR" type="xsd:string" nillable="true" p5:id_zasob="1521" p5:label="Autor" p5:description="Import" xmlns:p5="https://biuro.biall-net.pl/wfs"/>
+     <xsd:element minOccurs="0" maxOccurs="1" name="A_RECORD_CREATE_DATE" type="xsd:string" nillable="true" p5:id_zasob="1522" p5:label="Utworzono" p5:description="Import" xmlns:p5="https://biuro.biall-net.pl/wfs"/>
+     <xsd:element minOccurs="0" maxOccurs="1" name="A_RECORD_UPDATE_AUTHOR" type="xsd:string" nillable="true" p5:id_zasob="1523" p5:label="Zaktualizował" p5:description="Import" xmlns:p5="https://biuro.biall-net.pl/wfs"/>
+     <xsd:element minOccurs="0" maxOccurs="1" name="A_RECORD_UPDATE_DATE" type="xsd:string" nillable="true" p5:id_zasob="1524" p5:label="Zaktualizowano" p5:description="Import" xmlns:p5="https://biuro.biall-net.pl/wfs"/>
+     <xsd:element minOccurs="0" maxOccurs="1" name="SORT_PRIO" type="xsd:integer" nillable="true" p5:id_zasob="1525" p5:label="sort." p5:description="Waga sortowania. W zależności od wagi w tym polu system wykonuje polecenia przez wszystkie wskaźniki w danym kroku procesu oraz tak samo je wyświetla w drzewie procesów." p5:allow_write="true" p5:allow_create="true" xmlns:p5="https://biuro.biall-net.pl/wfs"/>
+     <xsd:element minOccurs="0" maxOccurs="1" name="A_ADM_COMPANY" type="xsd:string" nillable="true" p5:id_zasob="1526" p5:label="Zapis dla" p5:description="Import" p5:allow_write="true" xmlns:p5="https://biuro.biall-net.pl/wfs"/>
+     <xsd:element minOccurs="0" maxOccurs="1" name="A_CLASSIFIED" type="xsd:string" nillable="true" p5:id_zasob="20415" p5:label="odczyt&lt;br&gt;dla" p5:description="Grupa do odczytu danego rekordu" p5:allow_write="true" xmlns:p5="https://biuro.biall-net.pl/wfs"/>
+     <xsd:element minOccurs="0" maxOccurs="1" name="A_STATUS" type="default_db__x3A__CRM_WSKAZNIK:A_STATUSType" nillable="true" p5:id_zasob="6399" p5:label="status" p5:description="Status aktualności danego wskaźnika. Jeżeli ustawiony na SKASOWANY ( DELETED ) to nie jest brany pod uwagę. " p5:allow_write="true" p5:allow_create="true" xmlns:p5="https://biuro.biall-net.pl/wfs"/>
+    </xsd:sequence>
+   </xsd:extension>
+  </xsd:complexContent>
+ </xsd:complexType>
+ <xsd:element name="CRM_WSKAZNIK" type="default_db__x3A__CRM_WSKAZNIK:CRM_WSKAZNIKType" substitutionGroup="gml:_Feature"/>
+ <xsd:simpleType name="A_STATUSType">
+  <xsd:restriction base="xsd:string">
+   <xsd:enumeration value="DELETED"/>
+   <xsd:enumeration value="MONITOR"/>
+   <xsd:enumeration value="NORMAL"/>
+   <xsd:enumeration value="OFF_HARD"/>
+   <xsd:enumeration value="OFF_SOFT"/>
+   <xsd:enumeration value="WAITING"/>
+   <xsd:enumeration value="WARNING"/>
+  </xsd:restriction>
+ </xsd:simpleType>
+</xsd:schema>

+ 0 - 0
SE/schema/ant-object/default_db.CRM_WSKAZNIK/CRM_WSKAZNIK/build.xml


+ 0 - 5
SE/se-lib/AntAclBase.php

@@ -179,11 +179,6 @@ class AntAclBase extends Core_AclBase {
       ->limit($limit)
       ->offset($offset)
       ->execute();
-    return DB::getPDO()->fetchAll(" -- getItems({$this->_namespace})
-      select t.*
-      from `{$this->_rootTableName}` t
-        join `{$instanceTable}` i on(i.pk = t.{$sqlPrimaryKey} and i.idInstance = {$idInstance})
-    ");
   }
 
   public static function buildInstance($idZasob, $conf = []) {

+ 2 - 0
SE/se-lib/Core/AclHelper.php

@@ -57,6 +57,8 @@ class Core_AclHelper {// Helper class for Acl
         'AntAcl',
       ])) throw new Exception("Not Implemented acl type '{$objItem['_type']}'");
       // TODO: check if isActive and isStructInstalled // TODO: modify Acl.isActive to admin settings
+      if (!$objItem['isStructInstalled']) throw new Exception("namespace struct not installed '{$namespace}'");
+      if (!$objItem['isActive']) throw new Exception("namespace is not activated '{$namespace}'");
 
       Lib::loadClass('AntAclBase');
       $acl = AntAclBase::buildInstance($objItem['idZasob'], $objItem);

+ 13 - 8
SE/se-lib/Route/ViewTableAjax.php

@@ -375,14 +375,19 @@ class Route_ViewTableAjax extends RouteBase {
 	}
 
 	public function editFormAction() {// namespace, _hash, _primaryKey
-		$args = $_REQUEST;
-		$id = V::get('_primaryKey', 0, $args, 'int');
-		if ($id <= 0) throw new HttpException("Bad Request - missing primaryKey", 400);
-		$namespace = V::get('namespace', '', $args, 'word');
-		if (!$namespace) throw new HttpException("Bad Request - missing namespace", 400);
-		$acl = Core_AclHelper::getAclByNamespace($namespace);
-		$tbl = $this->getTableAjaxWidget($acl);
-		$tbl->sendAjaxEdit($id, $args);
+		try {
+			$args = $_REQUEST;
+			$id = V::get('_primaryKey', 0, $args, 'int');
+			if ($id <= 0) throw new HttpException("Bad Request - missing primaryKey", 400);
+			$namespace = V::get('namespace', '', $args, 'word');
+			if (!$namespace) throw new HttpException("Bad Request - missing namespace", 400);
+			$acl = Core_AclHelper::getAclByNamespace($namespace);
+			$tbl = $this->getTableAjaxWidget($acl);
+			$tbl->sendAjaxEdit($id, $args);
+		} catch (Exception $e) {
+			DBG::log($e);
+			throw $e;
+		}
 	}
 	public function editSaveAjaxAction() {
 		Response::sendTryCatchJson(array($this, 'editSaveAjax'), $args = 'JSON_FROM_REQUEST_BODY');

+ 21 - 21
SE/se-lib/TableAjax.php

@@ -1126,13 +1126,14 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
 						// console.log('FieldWidget: generate function to render field('+_fieldName+') fieldProps: ', fieldProps);
 						return function(val, fieldPK, row) {
 							// console.log('FieldWidget: pk('+fieldPK+') run function to render field('+_fieldName+') with value: ', val, ', fieldProps: ', fieldProps);
+							// if (val.length > 5) return '('+val.length+')' + printFirst5 + '...' => open more info
 							return _.map(val, function(v) {
 								if (!v || !v.xlink) return '';
 								var idRemote = v.xlink.split('.').pop()
 								var nsRemote = v.xlink.split(':').pop().split('.').shift()
-								var seLink = '<?= Request::getPathUri(); ?>index.php?_route=ViewTableAjax&namespace=' + fieldProps.xsdRefNsPrefix + '/' + nsRemote + '#EDIT/' + idRemote;
+								var seLink = '<?= Request::getPathUri(); ?>index.php?_route=ViewTableAjax&namespace=' + fieldProps.xsdRefNsPrefix.replace(/__x3A__/g, '/') + '/' + nsRemote + '#EDIT/' + idRemote;
 								var wfsLink = fieldProps.xsdRefUri + '#' + fieldProps.xsdRefType + '.' + idRemote;
-								return '<a href="' + seLink + '" title="' + wfsLink + '">' + v.xlink + '</a>';
+								return '<a class="btn btn-xs btn-default" href="' + seLink + '" title="' + wfsLink + '">' + idRemote + '</a>';
 							}).join(' ');
 						}
 					}(fldName, fieldProps));
@@ -1158,8 +1159,7 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
 
 		priv.renderRow = function(props) {
 			var rowNode = $('<tr></tr>'),
-					uniqueColName = _state.primaryKey,
-					rowPK = (uniqueColName in props)? props[uniqueColName] : null,
+					rowPK = (_state.primaryKey in props) ? props[_state.primaryKey] : null,
 					cellNode,
 					columnName, columnProps, val, cellCnt, format, showTooltip, fldWidgetNode,
 					dbg = priv.options.debug
@@ -1179,7 +1179,7 @@ var p5UI_TableAjax_generateFunctionNode = function(funObj, rowPK, props) {
 				$(p5Utils__format('<input class="unique" {0} {1} type="checkbox" />', [check, checkable])).appendTo(cellNode);
 			}
 
-			if (uniqueColName) rowNode.data('unique', rowPK);
+			if (_state.primaryKey) rowNode.data('unique', rowPK);
 
 			//create cells
 			for (var i = 0; i < _state.colsSorted.length; i++) {
@@ -4283,7 +4283,7 @@ function <?php echo $jsToogleFiltrProcesuFunctionName; ?>(n) {
 
 		if ($DBG) echo "fieldID: {$fieldID}\n";
 
-		$row = $this->_acl->getItem($rowID);
+		$row = $this->_acl->buildQuery([])->getItem($rowID);
 		if (!$row) {
 			echo "404: No item ID({$rowID})";
 			exit;
@@ -4389,7 +4389,7 @@ function <?php echo $jsToogleFiltrProcesuFunctionName; ?>(n) {
 		$fieldID = $this->_acl->getFieldIdByName($fieldName);
 		if (!$fieldID) throw new HttpException("Field not exists!", 404);
 
-		$item = $this->_acl->getItem($primaryKey);
+		$item = $this->_acl->buildQuery([])->getItem($primaryKey);
 		if (!$item) throw new HttpException("Item not exists!", 404);
 
 		$itemFromUser = $this->_acl->convertObjectFromUserInput($args, $type = 'array_by_id', $prefix = 'f');
@@ -4410,7 +4410,7 @@ function <?php echo $jsToogleFiltrProcesuFunctionName; ?>(n) {
 				$response->type = 'info';
 				$response->msg = "Nie wprowadzono żadnych zmian";
 			}
-			$response->record = $this->_acl->getItem($primaryKey);
+			$response->record = $this->_acl->buildQuery([])->getItem($primaryKey);
 		}
 		catch (Exception $e) {
 			$response->type = 'error';
@@ -4424,7 +4424,7 @@ function <?php echo $jsToogleFiltrProcesuFunctionName; ?>(n) {
 		$DBG = ('1' == V::get('DBG', '', $_REQUEST));
 		$acl = $this->_acl;
 
-		$record = (array)$acl->getItem($id);
+		$record = $acl->buildQuery([])->getItem($id);
 		if (!$acl->canWriteRecord($record) && !$acl->hasPermSuperWrite()) {
 			UI::alert('danger', "Brak dostępu do rekordu");// TODO: more info - reason
 			return;
@@ -4887,7 +4887,7 @@ jQuery(document).ready(function(){
 				$response->type = 'success';
 				$response->msg = "Utworzono pomyślnie rekord nr {$createdId}";
 				$response->id = $createdId;
-				$response->record = $this->_acl->getItem($createdId);
+				$response->record = $this->_acl->buildQuery([])->getItem($createdId);
 			}
 			else {
 				$response->type = 'error';
@@ -4908,7 +4908,7 @@ jQuery(document).ready(function(){
 			throw new HttpException("Wrong param ID!", 404);
 		}
 
-		$item = $this->_acl->getItem($id);
+		$item = $this->_acl->buildQuery([])->getItem($id);
 		if (!$item) {
 			throw new HttpException("Item '{$id}' not exists!", 404);
 		}
@@ -4925,7 +4925,7 @@ jQuery(document).ready(function(){
 				$response->type = 'success';
 				$response->msg = "Rekord skopiowany pomyślnie - utworzono rekord nr {$createdId}";
 				$response->id = $createdId;
-				$response->record = $this->_acl->getItem($createdId);
+				$response->record = $this->_acl->buildQuery([])->getItem($createdId);
 			}
 			else {
 				$response->type = 'error';
@@ -4944,7 +4944,7 @@ jQuery(document).ready(function(){
 		$jsonResponse = array();
 		$id = V::get('ID', 0, $args, 'int');
 		$acl = $this->_acl;
-		$record = $acl->getItem($id);
+		$record = $acl->buildQuery([])->getItem($id);
 		if (!$record) throw new HttpException("404: No item ID({$id})", 404);
 
 		$visibleCols = $acl->getRealFieldList();
@@ -5010,7 +5010,7 @@ jQuery(document).ready(function(){
 		$dbID = $this->_acl->getDB();
 		$db = DB::getDB($dbID);
 		if (!$db) throw new HttpException("No DB ({$dbID})", 406);
-		$record = $this->_acl->getItem($id);
+		$record = $this->_acl->buildQuery([])->getItem($id);
 		if (!$record) throw new HttpException("No item ID({$rowID})", 404);
 		if (!$this->_acl->canReadRecord($record)) throw new Exception("Brak uprawnień do odczytu");
 		if (!$this->_acl->canWriteRecord($record)) throw new Exception("Brak uprawnień do zapisu");
@@ -5060,7 +5060,7 @@ jQuery(document).ready(function(){
 		$dbID = $this->_acl->getDB();
 		$db = DB::getDB($dbID);
 		if (!$db) throw new HttpException("No DB ({$dbID})", 406);
-		$record = $this->_acl->getItem($id);
+		$record = $this->_acl->buildQuery([])->getItem($id);
 		if (!$record) throw new HttpException("No item ID({$rowID})", 404);
 		if (!$this->_acl->canReadRecord($record)) throw new Exception("Brak uprawnień do odczytu");
 		if (!$this->_acl->canWriteRecord($record)) throw new Exception("Brak uprawnień do zapisu");
@@ -5089,7 +5089,7 @@ jQuery(document).ready(function(){
 		$dbID = $this->_acl->getDB();
 		$db = DB::getDB($dbID);
 		if (!$db) throw new HttpException("No DB ({$dbID})", 406);
-		$record = $this->_acl->getItem($id);
+		$record = $this->_acl->buildQuery([])->getItem($id);
 		if (!$record) throw new HttpException("No item ID({$rowID})", 404);
 		if (!$this->_acl->canReadRecord($record)) throw new Exception("Brak uprawnień do odczytu");
 		$tblName = $this->_acl->getName();
@@ -5117,7 +5117,7 @@ jQuery(document).ready(function(){
 		$db = DB::getDB($dbID);
 		if (!$db) throw new HttpException("No DB", 406);
 
-		$record = $this->_acl->getItem($id);
+		$record = $this->_acl->buildQuery([])->getItem($id);
 		if (!$record) throw new Exception("No item ID({$rowID})", 404);
 
 		$tblName = $this->_acl->getName();
@@ -5228,7 +5228,7 @@ jQuery(document).ready(function(){
 			exit;
 		}
 
-		$record = $this->_acl->getItem($id);
+		$record = $this->_acl->buildQuery([])->getItem($id);
 		if (!$record) {
 			header('HTTP/1.0 404 Not Found');
 			echo 'No item ID(' . $rowID . ')';
@@ -5359,7 +5359,7 @@ jQuery(document).ready(function(){
 		$db = DB::getDB($dbID);
 		if (!$db) throw new HttpException("", 406);
 
-		$record = $this->_acl->getItem($id);
+		$record = $this->_acl->buildQuery([])->getItem($id);
 		if (!$record) throw new HttpException("404: No item ID({$rowID})", 404);
 
 		if (!$this->_acl->canReadRecord($record)) throw new Exception("Brak uprawnień do odczytu");
@@ -6388,7 +6388,7 @@ jQuery(document).ready(function(){
 		}
 		// TODO: validate polygon - ex.: POLYGON((2072030.2315435 7234115.910678,2072029.4815435 7234093.660678,2072115.2315435 7234091.160678,2072115.4815435 7234113.660678,2072115.2315435 7234113.660678,2072094.2315435 7234113.910678,2072030.2315435 7234115.910678)))
 
-		$record = $this->_acl->getItem($primaryKey);
+		$record = $this->_acl->buildQuery([])->getItem($primaryKey);
 		if (!$this->_acl->canWriteRecord($record) && !$this->_acl->hasPermSuperWrite()) {
 			throw new HttpException("Brak dostępu do rekordu", 403);
 		}
@@ -6412,7 +6412,7 @@ jQuery(document).ready(function(){
 				$response->type = 'info';
 				$response->msg = "Nie wprowadzono żadnych zmian";
 			}
-			$response->record = $this->_acl->getItem($primaryKey);
+			$response->record = $this->_acl->buildQuery([])->getItem($primaryKey);
 		}
 		catch (Exception $e) {
 			$response->type = 'error';