Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Specify persistence feature #11

Closed
mar10 opened this issue May 12, 2013 · 12 comments
Closed

RFC: Specify persistence feature #11

mar10 opened this issue May 12, 2013 · 12 comments
Labels
Milestone

Comments

@mar10
Copy link
Owner

mar10 commented May 12, 2013

Discuss and finalize this RFC:

https://github.com/mar10/fancytree/wiki/SpecPersistence

@mar10
Copy link
Owner Author

mar10 commented Mar 3, 2014

Closing RFC issues, because they should not appear as Open Issue.

This thread is still open for discussion!

@mar10 mar10 closed this as completed Mar 3, 2014
@mar10 mar10 added this to the 2.0.0beta milestone May 11, 2014
@evgrezanov
Copy link

Hi, pls tell me i can use persist option with link ?
i not see this in demo

@dailyherold
Copy link

Regarding "When node is re-activated, should the activate event be fired again?" from SpecPersistence, any tweaks I can make locally so the activate event is not fired?

@wgaber
Copy link

wgaber commented Apr 26, 2017

Hi!
Restore without extract nodes animation?
Thx.

@mar10
Copy link
Owner Author

mar10 commented Apr 27, 2017

@wgaber Thanks for contributing!
you mean expand animation? This will be addressed in #730

@244958898
Copy link

Can I restore the new node rather than status that i add so that I can see it after the page refreshing?

@mar10
Copy link
Owner Author

mar10 commented Aug 20, 2017

@244958898 sorry, but I do not understand your question

@mafar
Copy link

mafar commented Nov 23, 2017

@mar10
I need help please. Can you help me find a solution for my problem. I need to know how I can achieve this with fancytree. See below

  • I am using fancytree in electron application based on node.js
  • My requirements are store and load persistence information in local configuration file instead of using cookie or storage.

Reference:
To explain, I will be using layout.jquery as reference because it has options for what I exactly need to do as they support persistence too by name stateManagement.
demo_saved_state

DEFAULT OPTIONS layout.jquery

stateManagement: {
 enabled: false,
 // true = enable state-management, even if not using cookies
 // needed when autoSave or autoLoad are functions not boolean
 autoSave: true,
 // autoSave:boolean ==> Save state using cookie
 // autoSave:function ==>  use your own method to save it
 autoLoad: true,
 // autoLoad:boolean ==> Load state using cookie at init
 // autoLoad:function ==> use your own method to load state options at init and return it 
}

PRACTICAL EXAMPLE layout.jquery electron nconf

// Save and Load state from file instead of cookies-built-in-method
// in node.js/electron environment using library nconf
stateManagement: {
 enabled: true,
 autoLoad: function () {
   // load instance_state at init
   // get instance_state from anywhere like a file (if in electron),cookie,store.js whatever
   // get from local file using nconf/node.js 
   return nconf.get('layout-state');
 },
 autoSave: function (instance, instance_state, instance_options) {
   // save instance_state whereever you want
   // save to local file using nconf/node.js
   nconf.set('layout-state', instance_state).save();
 }
}

Question:
How can i do this with fancytree ?

  1. Enable fancytree persistence
  2. Save persistence data with my own method, Instead of built-in methods
  3. Load persistence data with my own method, Instead of built-in methods
  4. I should be able to do all above whether I am using web or node.js env like electron

@mafar
Copy link

mafar commented Nov 24, 2017

By looking at source code in jquery.fancytree.persist where

if (typeof Cookies === "function") {
  cookieSetter = Cookies.set;
  cookieGetter = Cookies.get;
  cookieRemover = Cookies.remove;
} else {
  cookieSetter = cookieGetter = $.cookie;
  cookieRemover = $.removeCookie;
}

It would be nice if it had object support so that I could use it like

// object support
if (typeof Cookies === "function" || "object") {
  cookieSetter = Cookies.set;
  cookieGetter = Cookies.get;
  cookieRemover = Cookies.remove;
}   else {
  cookieSetter = cookieGetter = $.cookie;
  cookieRemover = $.removeCookie;
}

Usage:

var customObject = {
  get: myGetter,
  set: mySetter,
  remove: myRemover
};
//
$("#tree").fancytree({
  extensions: ["persist"],
  checkbox: true,
  persist: {
    cookie: customObject, // use custom object
    store: "cookie", // use custom function
  }
});

@mafar
Copy link

mafar commented Nov 24, 2017

@mar10
Can you please make it configurable so that custom cookieSetter,cookieGetter, cookieRemover can be defined

@mar10
Copy link
Owner Author

mar10 commented Nov 24, 2017

@mafar Good suggestion.
Would you like to open a separate issue for this feature?
(this one is for general extension discussion)
Thanks!

@mafar
Copy link

mafar commented Nov 25, 2017

@mar10
Ok I will open new issue as improvement
#808

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants