Jelajahi Sumber

added pracownicy label

Piotr Labudda 7 tahun lalu
induk
melakukan
f7d4dba15b
1 mengubah file dengan 39 tambahan dan 6 penghapusan
  1. 39 6
      tools/Bocian.php.view.js

+ 39 - 6
tools/Bocian.php.view.js

@@ -1795,6 +1795,9 @@ function graphFetchData(node, nameSection) {
 			// resolveDepth: 2
 			'ogc:Filter': '<wfs:Query>' + '\n' + [
 				'ID',
+				'imiona',
+				'nazwisko',
+				'miejscowosc',
 				// '*',
 				// 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY_adresy:BI_audit_ENERGA_PRACOWNICY_adresy/*',
 				[
@@ -1875,7 +1878,11 @@ function graphFetchData(node, nameSection) {
 		)
 	).then(function (items) {
 		if(DBG)console.log('p5WFS_GetFeature: items: ', items);
-		graphRender(node, { msg: "Pobrano dane", nameSection: nameSection, items: items })
+		graphRender(node, {
+			msg: "Pobrano dane",
+			typeName: ('pracownicy' === nameSection) ? 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY' : 'default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI:BI_audit_ENERGA_RUM_KONTRAHENCI',
+			items: items
+		})
 	}).catch(function (err) {
 		if(DBG)console.log('p5WFS_GetFeature: err: ', err);
 		// graphRender(node, { msg: "Wystąpiły błędy podczas pobierania danych", nameSection: nameSection, err: err })
@@ -1892,7 +1899,7 @@ function graphRender(wrapNode, props) {
 
 	// var data = parseGraphRec(props.items, props.nameSection)
 	var _todoGraphData = [];
-	parseResponseRec(_todoGraphData, props.items, props.nameSection)
+	parseResponseRec(_todoGraphData, props.items, props.typeName)
 	if(DBG)console.log('_todoGraphData', _todoGraphData)
 	var _nodes = [];
 	var _links = [];
@@ -1947,7 +1954,7 @@ function graphRender(wrapNode, props) {
 	// console.log('DBG:0: _links', _links)
 	// console.log('DBG:1: _nodes', _nodes)
 	_nodes = _nodes.filter(function (node, idx) {
-		if (node.typeName !== 'pracownicy') return true
+		if (node.typeName !== props.typeName) return true
 		for (i=0; i<totalLinks; i++) {
 			var link = _links[i]
 			if (_links[i].source === node.id) return true
@@ -2058,6 +2065,24 @@ function parseResponseRec(_todoGraphData, json, typeName, parentNodeId, level) {
 		else if ("default_db__x3A__BI_audit_KRS:BI_audit_KRS" === typeName) {
 			parseResponseRec__krs(_todoGraphData, json, typeName, parentNodeId, level)
 		}
+		else if ("default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY" === typeName) {
+			nodeObject = dataMakeNode({
+				typeName: typeName,
+				primaryKey: (json['ID']) ? json['ID'] : null, // TODO: get primaryKey from object
+				row: json
+			})
+			_todoGraphData[level].nodes.push(nodeObject)
+			if (parentNodeId) {
+				_todoGraphData[level].edges.push(dataMakeEdge(parentNodeId, nodeObject))
+			}
+			Object.keys(json).filter(function (fieldName) {
+				return (fieldName.indexOf(':') > -1)
+			})
+			.forEach(function (fieldName) {
+				var value = json[fieldName]
+				parseResponseRec(_todoGraphData, value, fieldName, nodeId, level + 1)
+			})
+		}
 		else if ("default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row_object" !== typeName
 			&& "default_db__x3A__BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row:BI_audit_ENERGA_RUM_KONTRAHENCI_POWIAZANIA_row" !== typeName
 		) {
@@ -2072,7 +2097,8 @@ function parseResponseRec(_todoGraphData, json, typeName, parentNodeId, level) {
 				var value = json[fieldName]
 				parseResponseRec(_todoGraphData, value, fieldName, nodeId, level + 1)
 			})
-		} else {
+		}
+		else {
 			Object.keys(json).filter(function (fieldName) {
 				return (fieldName.indexOf(':') > -1)
 			})
@@ -2310,12 +2336,19 @@ function graphAddNodeLabel(graphNode) {
 	// }
 	var label = graphNode.id // TODO: get from schema assert @label attribute
 	label = makeShortLabel(graphNode.id)
-	// <xs:assert test="@default_db__x3A__BI_audit_KRS:label = concat(nazwa, ' ', krs, ' ', S_miejscowosc)" id="I_audit_KRS___d6e76977-1">
 	switch (graphNode.typeName) {
 		case 'default_db__x3A__BI_audit_KRS:BI_audit_KRS': {
-			if (graphNode.row) label = graphNode.row.nazwa + ' ' + graphNode.row.krs + ' ' + graphNode.row.S_miejscowosc;
+			// <xs:assert test="@default_db__x3A__BI_audit_KRS:label = concat(nazwa, ' ', krs, ' ', S_miejscowosc)" id="I_audit_KRS___d6e76977-1">
+			if (graphNode.row) label = [graphNode.row.nazwa, graphNode.row.krs, graphNode.row.S_miejscowosc].filter(function (val) { return val; }).join(' ');
+			label = (label) ? label : makeShortLabel(graphNode.id)
 			label = label + ' (krs)'
 		} break;
+		case 'default_db__x3A__BI_audit_ENERGA_PRACOWNICY:BI_audit_ENERGA_PRACOWNICY': {
+			// <xs:assert id="_PRACOWNICY___d6e76324-1" test="@label = concat(imiona, ' ', nazwisko, ' ', miejscowosc)"/>
+			if (graphNode.row) label = [graphNode.row.imiona, graphNode.row.nazwisko, graphNode.row.miejscowosc].filter(function (val) { return val; }).join(' ');
+			label = (label) ? label : makeShortLabel(graphNode.id)
+			label = label + ' (pracownicy)'
+		} break;
 	}
 	return Object.assign(graphNode, {
 		label: label,