Skip to content

Commit

Permalink
Fix LinkSet/LinkList issue when editing/creating #478
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf4ood committed Jul 4, 2017
1 parent 9c87de7 commit b93081f
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/app/util/graph/d3-graph/OGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ export class OGraph {

transform(d) {
if(!d) {
console.log("Fuck!");
console.log("Duck!");
}
return "translate(" + d.x + "," + d.y + ")";
}
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/document-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ DocController.controller("DocumentModalController", ['$scope', '$routeParams', '
$scope.database = $scope.db;
$scope.reload = function () {
$scope.doc = DocumentApi.get({database: $scope.db, document: $scope.rid}, function () {
$scope.headers = Database.getPropertyFromDoc($scope.doc);
$scope.headers = Database.getPropertyFromDoc($scope.doc,true);
$scope.onReload();
}, function (error) {
Notification.push({content: JSON.stringify(error)});
Expand Down
7 changes: 4 additions & 3 deletions src/controllers/graph-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,13 @@ GraphModule.controller("VertexEditController", ['$scope', '$injector', '$routePa
if (!$scope.doc) {
$scope.reload();
} else {
$scope.headers = Database.getPropertyFromDoc($scope.doc);
$scope.headers = Database.getPropertyFromDoc($scope.doc, true);

$scope.isGraph = Database.isGraph($scope.doc['@class']);
$scope.incomings = Database.getEdge($scope.doc, 'in_');
$scope.outgoings = Database.getEdge($scope.doc, 'out_');
$scope.exclude = $scope.outgoings.concat($scope.incomings);
$scope.outgoings = $scope.outgoings.concat((Database.getLink($scope.doc, $scope.exclude)));


$scope.label = Database.isEdge($scope.doc['@class']) ? "Edge" : "Vertex";

Expand Down Expand Up @@ -1363,7 +1364,7 @@ GraphModule.controller("VertexAsideController", ['$scope', '$routeParams', '$loc
$scope.icons = data;


$scope.headers = Database.getPropertyFromDoc($scope.doc);
$scope.headers = Database.getPropertyFromDoc($scope.doc,true);
$scope.headers.unshift("@class");
$scope.headers.unshift("@rid");
$scope.active = 'properties';
Expand Down
2 changes: 2 additions & 0 deletions src/directives/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import '../views/widget/string.html';
import '../views/widget/short.html';
import '../views/widget/embedded.html';
import '../views/widget/embeddedmap.html';
import '../views/widget/linklist.html';
import '../views/widget/linkset.html';
import '../views/widget/boolean.html';
import '../views/widget/binary.html';
import '../views/widget/byte.html';
Expand Down
11 changes: 10 additions & 1 deletion src/services/database-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,17 +340,23 @@ database.factory('Database', ["DatabaseApi", "localStorageService", "SchemaServi
* @param {doc} OrientDB Document.
* @return {Array} Property name Array.
*/
getPropertyFromDoc: function (doc) {
getPropertyFromDoc: function (doc, includeLinks) {
var c = doc['@class'];
var isGraph = this.isGraph(c);
var fixedHeader = this.header.concat(this.exclude);


var self = this;
var fields = this.listField(c);
var all = Object.keys(doc).filter(function (element, index, array) {
var type = self.getFieldType(c, element);
if (isGraph) {
return (fixedHeader.indexOf(element) == -1 && (!element.startsWith("in_") && !element.startsWith("out_")) && !self.isLink(type));
} else {

if (includeLinks === true) {
return true;
}
return (fixedHeader.indexOf(element) == -1 && !self.isLink(type));
}
});
Expand All @@ -361,6 +367,9 @@ database.factory('Database', ["DatabaseApi", "localStorageService", "SchemaServi
var bool = true;
if (isGraph) {
bool = (fixedHeader.indexOf(elem) == -1 && (!elem.startsWith("in_") && !elem.startsWith("out_")) && !self.isLink(type));
if (self.isLink(type) && includeLinks === true) {
bool = true;
}
} else {
bool = (fixedHeader.indexOf(elem) == -1 && !self.isLink(type));
}
Expand Down
3 changes: 3 additions & 0 deletions src/views/widget/linklist.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div ng-controller="EmbeddedController">
<div jsontext ui-codemirror="viewerOptions" ng-required='isRequired(header)' ng-model='doc[header]'></div>
</div>
3 changes: 3 additions & 0 deletions src/views/widget/linkset.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div ng-controller="EmbeddedController">
<div jsontext ui-codemirror="viewerOptions" ng-required='isRequired(header)' ng-model='doc[header]'></div>
</div>

0 comments on commit b93081f

Please sign in to comment.