From 5a3b3e735d28f7a875922bd135e4a7c560a8a1c8 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 12 Apr 2018 01:40:26 +0300 Subject: [PATCH] experementing with changes browser... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/core.js | 4 ++ ui (gen4)/features/examples.js | 2 +- ui (gen4)/features/experimental.js | 69 +++++++++++++++++++++++------- ui (gen4)/features/meta.js | 2 +- ui (gen4)/features/ui-widgets.js | 1 + 5 files changed, 61 insertions(+), 17 deletions(-) diff --git a/ui (gen4)/features/core.js b/ui (gen4)/features/core.js index 924ad06d..3a96caca 100755 --- a/ui (gen4)/features/core.js +++ b/ui (gen4)/features/core.js @@ -1478,6 +1478,9 @@ var ChangesActions = actions.Actions({ // NOTE: in the complex format all fields ar optional; if a field // is not included it is not written (same as when set to false) // NOTE: .current is written always. + // + // XXX this should be a prop to enable correct changes tracking via + // events... chages: null, clone: [function(full){ @@ -1489,6 +1492,7 @@ var ChangesActions = actions.Actions({ } }], + // XXX this should also track .changes... markChanged: ['- System/', doc`Mark data sections as changed... diff --git a/ui (gen4)/features/examples.js b/ui (gen4)/features/examples.js index 64d3d028..8ddf4949 100755 --- a/ui (gen4)/features/examples.js +++ b/ui (gen4)/features/examples.js @@ -74,7 +74,7 @@ var ExampleActions = actions.Actions({ }], exampleAsyncAction: ['- Test/', {await: false}, - function(t){ + function(t){ return new Promise(function(resolve){ setTimeout(function(){ resolve() }, t || 1000) }) }], diff --git a/ui (gen4)/features/experimental.js b/ui (gen4)/features/experimental.js index b8962575..458761eb 100755 --- a/ui (gen4)/features/experimental.js +++ b/ui (gen4)/features/experimental.js @@ -7,22 +7,69 @@ (function(require){ var module={} // make module AMD/node compatible... /*********************************************************************/ +var toggler = require('lib/toggler') var actions = require('lib/actions') var features = require('lib/features') var core = require('features/core') +var widgets = require('features/ui-widgets') + +var widget = require('lib/widget/widget') +var browse = require('lib/widget/browse') +var overlay = require('lib/widget/overlay') +var drawer = require('lib/widget/drawer') + +var browseWalk = require('lib/widget/browse-walk') /*********************************************************************/ var ExperimentActions = actions.Actions({ - /* trying an argument mutation method... (FAILED: arguments is mutable) - argumentMutation: [ - function(a, b){ - console.log('ACTIONS ARGS:', a, b) - }], - */ + // XXX depends on ui, ... + // XXX should we add ability to pick and chose the changes??? + // XXX would be nice to have a universal .save() action... + browseChanges: ['Experimental/$Changes...', + {dialogTitle: 'Unsaved changes'}, + widgets.makeUIDialog(function(path){ + var that = this + var handlers_setup = false + return browse.makeLister(null, function(_, make){ + var keys = Object.keys(that.changes || {}) + if(keys.length == 0){ + make.Empty('No changes...') + + } else { + keys + .forEach(function(key){ + make(key) + }) + + make('---') + make('Save', { + open: function(){ + that.saveIndexHere + && that.saveIndexHere() + }, + close: function(){ + that.off('markChanged', 'changes-dialog-updater') + } + }) + + if(!handlers_setup){ + // XXX this needs to be triggered after save + // is done in a more universal way... + // ...also unbind on error/close... + // XXX need to clean this up in a better way... + // XXX this should also track .changes... + that.on('markChanged', 'changes-dialog-updater', function(){ + make.dialog.update() + }) + handlers_setup = true + } + } + }) + })], }) var ExperimentFeature = @@ -32,19 +79,11 @@ module.ExperimentFeature = core.ImageGridFeatures.Feature({ tag: 'experiments', - isApplicable: function(actions){ return actions.experimental }, + //isApplicable: function(actions){ return actions.experimental }, actions: ExperimentActions, handlers: [ - /* trying an argument mutation method... (FAILED: arguments is mutable) - ['argumentMutation.pre', - function(a, b){ - console.log('EVENT ARGS:', a, b) - arguments[0] += 1 - arguments[1] += 1 - }], - */ ], }) diff --git a/ui (gen4)/features/meta.js b/ui (gen4)/features/meta.js index 170c6138..f67de4e0 100755 --- a/ui (gen4)/features/meta.js +++ b/ui (gen4)/features/meta.js @@ -173,8 +173,8 @@ core.ImageGridFeatures.Feature('imagegrid-testing', [ //----------------------------------------------------- testing --- + 'experiments', '-tests', - '-experiments', // missing suggested feature test -- should show up in .features.missing... 'missing-feature', diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index d15e435d..f3ffba4f 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -1363,6 +1363,7 @@ var BrowseActionsActions = actions.Actions({ '-70:$Help', '-80:---', '-90:Development', + '-90:Experimental', '-90:Test', ],