Skip to content

track the history of a $firebaseObject, store version in firebase, do rollback, go to prev version, undo, redo, go to a specific version and etc...

License

Notifications You must be signed in to change notification settings

cubissimo/AngularFire-Transaction-manager

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Firebase Transaction Manager

Angularjs Module that depends from AngularFire allows to make snapshots of an $firebaseObject, store versions in firebase, do rollback, go to prev version, undo, redo, go to a specific version and much more...

this repo is a fork of awesome https://github.com/marco64bit/Angular-Transaction-manager

Install

Bower

```sh bower install AngularFire-Transaction-manager --save ```

include firebase.transactionManager.js in your application

 <script src="scripts/transactionManager.js"></script>

add firebase.transactionManager to your angular module

var app = angular.module('myApp', ['firebase.transactionManager']);

try online demo

not yet.. comming...

or Open example folder and run

 npm install
 grunt install
 bower install

run grunt server in example folder

//////// doc deprecated... to be updated. ////////

API

works only with $firebaseObject (not with primitives) like this

var obj = $firebaseObject(ref);

TransactionManager.snapshot save the actual state of passed object ```js $scope.foo = {a: 1, b: "test"}; TransactionManager.snapshot($scope.foo); ``` the result object contains a key snapshot ```js {a: 1, b: "test", snapshot: [{a: 1, b: "test"}]} ``` you can call snapshot() more than 1 time, the result object will contain a list of all snapshot ```js $scope.foo = {a: 1, b: "test"}; TransactionManager.snapshot($scope.foo); $scope.foo.b = "changed"; TransactionManager.snapshot($scope.foo); // $scope.foo will be: //{a: 1, b: "test", snapshot: [{a: 1, b: "test"}, {a: 1, b: "changed"}]} ```
TransactionManager.rollback applies the last snapshot ```js $scope.foo = {a: 1, b: "test"}; TransactionManager.snapshot($scope.foo); $scope.foo.b = "test2"; // now foo is -> {a: 1, b: "test2"} TransactionManager.rollback($scope.foo); // now foo is -> {a: 1, b: "test"} ```
TransactionManager.canRollback returns true in case it has a snapshot and actual state is different from last snapshot ```js TransactionManager.canRollback($scope.foo); ```
TransactionManager.canRestorePrevious return true if passed object has a previous snapshot (old TransactionManager.prevVersion) ```js TransactionManager.canRestorePrevious($scope.foo); ```
TransactionManager.restorePrevious Restore to the state of previous snapshot version. ```js $scope.foo = {a: 1, b: "test"}; TransactionManager.snapshot($scope.foo); // now foo is -> {a: 1, b: "test"} $scope.foo.b = "test2"; TransactionManager.snapshot($scope.foo); // now foo is -> {a: 1, b: "test2"} TransactionManager.restorePrevious($scope.foo); // now foo is -> {a: 1, b: "test"} ```
TransactionManager.clear Remove all snapshots ```js TransactionManager.clear($scope.foo); ```
TransactionManager.hasSnapshot returns true if passed object has at least 1 snapshot ```js TransactionManager.hasSnapshot($scope.foo); ```

About

track the history of a $firebaseObject, store version in firebase, do rollback, go to prev version, undo, redo, go to a specific version and etc...

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • ApacheConf 56.7%
  • JavaScript 24.4%
  • HTML 18.0%
  • CSS 0.9%