Skip to content
This repository has been archived by the owner on May 4, 2019. It is now read-only.

Commit

Permalink
Fix cache issue when adding a property
Browse files Browse the repository at this point in the history
Closes #27
  • Loading branch information
RobinBressan committed Apr 5, 2014
1 parent 94c9a4b commit c848d49
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
19 changes: 3 additions & 16 deletions web/assets/js/browser/controllers/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@
};

var reloadProperties = function() {
rawProperties = $scope.currentNode.getProperties();
$scope.properties = normalize(rawProperties);
$scope.currentNode.getProperties(false).then(function(rawProperties) {
$scope.properties = normalize(rawProperties);
});
};

$scope.deleteProperty = function(name, path) {
Expand Down Expand Up @@ -119,20 +120,6 @@
};

$scope.restoreProperty = function() {
// if ($scope.backup.path && $scope.backup.path !== '/') {
// $scope.backup.path = $scope.backup.path.split('/');
// $scope.backup.path.pop();
// $scope.backup.path = $scope.backup.path.join('/');
// return rawProperties[$scope.backup.name].insert($scope.backup.path, $scope.backup.value).then(function() {
// reloadProperties();
// $scope.backup = null;
// $log.log('Property restored.');
// }, function(err) {
// if (err.data && err.data.message) { return $log.error(err, err.data.message); }
// $log.error(err);
// });
// }

$scope.createProperty($scope.backup.name, $scope.backup.value, $scope.backup.type);
$scope.backup = null;
};
Expand Down
24 changes: 22 additions & 2 deletions web/assets/js/browser/services/node-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,28 @@
return this._finder('/' + this.getWorkspace().getRepository().getName() + '/' + this.getWorkspace().getName() + '/' + components.join('/'));
};

Node.prototype.getProperties = function() {
return this._properties;
Node.prototype.getProperties = function(cache) {
var deferred = $q.defer(), self = this;
if (cache !==undefined && !cache) {
ApiFoundation.getNode(
this.getWorkspace().getRepository().getName(),
this.getWorkspace().getName(),
this.getPath(),
{cache: false})
.then(function(node) {
self._properties = {};
for (var p in node.properties) {
node.properties[p].name = p;
if (SmartProperty.accept(node.properties[p])) {
self._properties[p] = SmartProperty.build(node.properties[p], this);
}
}
deferred.resolve(self._properties);
}, function(err) {
deferred.reject(err);
});
} else { deferred.resolve(this._properties); }
return deferred.promise;
};

Node.prototype.setProperty = function(name, value, type) {
Expand Down

0 comments on commit c848d49

Please sign in to comment.