From dc93052a934e29ae396226061e680c8b57794c0b Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 4 May 2016 21:28:46 +0300 Subject: [PATCH] added spinners to save history and sub-index list + some tweaking and fxes... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/filesystem.js | 66 ++++++++++++++++-- ui (gen4)/features/keyboard.js | 2 +- ui (gen4)/features/metadata.js | 112 +++++++++++++++---------------- ui (gen4)/lib/widget/browse.js | 20 +----- 4 files changed, 121 insertions(+), 79 deletions(-) diff --git a/ui (gen4)/features/filesystem.js b/ui (gen4)/features/filesystem.js index ef9b5cb9..6440e993 100755 --- a/ui (gen4)/features/filesystem.js +++ b/ui (gen4)/features/filesystem.js @@ -549,20 +549,69 @@ var FileSystemLoaderUIActions = actions.Actions({ browseIndex: ['File/Load index...', makeBrowseProxy('loadIndex')], browseImages: ['File/Load images...', makeBrowseProxy('loadImages')], - // XXX add dialog to list sub-indexes... - // XXX + browseSubIndexes: ['File/List sub-indexes...', + widgets.makeUIDialog(function(){ + var that = this + var index_dir = this.config['index-dir'] + + var o = browse.makeLister(null, function(path, make){ + var dialog = this + var path = that.location.path + + if(that.location.method != 'loadIndex'){ + make('No indexes loaded...', null, true) + return + } + + // indicate that we are working... + var spinner = make($('
')) + + // XXX we do not need to actually read anything.... + //file.loadIndex(path, that.config['index-dir'], this.logger) + // XXX we need to prune the indexes -- avoid loading nested indexes... + file.listIndexes(path, index_dir) + .on('end', function(res){ + + // we got the data, we can now remove the spinner... + spinner.remove() + + res.forEach(function(p){ + // trim local paths and keep external paths as-is... + p = p.split(index_dir)[0] + var txt = p.split(path).pop() + txt = txt != p ? './'+pathlib.join('.', txt) : txt + + make(txt) + .on('open', function(){ + that.loadIndex(p) + }) + }) + }) + }) + .on('open', function(){ + o.parent.close() + }) + + return o + })], // NOTE: for multiple indexes this will show the combined history // and selecting a postion will load all the participating // indexes to that date. // NOTE: this will show nothing if .location.method is not loadIndex.. // + // XXX should this affect .changes ??? // XXX handle named saves... // XXX add ability to name a save... - // XXX need to handle saves when loaded a specific history position... + // XXX need to handle saves (saveIndex(..) and friends) when loaded + // a specific history position... + // ...in theory saving and old index will create an incremental + // save which should not damage the history and can be fixed + // either by removing the actual .json files or simply loading + // from a previous position and re-saving... (XXX test) // XXX should this also list journal stuff or have the ability for // extending??? - listSaveHistoryDialog: ['File/History...', + listSaveHistory: ['File/History...', widgets.makeUIDialog(function(){ var that = this @@ -585,6 +634,9 @@ var FileSystemLoaderUIActions = actions.Actions({ make('---') + // indicate that we are working... + var spinner = make($('
')) + that.loadSaveHistoryList() .catch(function(err){ // XXX @@ -593,6 +645,9 @@ var FileSystemLoaderUIActions = actions.Actions({ .then(function(data){ var list = [] + // got the data, remove the spinner... + spinner.remove() + Object.keys(data).forEach(function(path){ Object.keys(data[path]).forEach(function(d){ list.push(d) @@ -618,8 +673,9 @@ var FileSystemLoaderUIActions = actions.Actions({ // NOTE: here we will select 'Latest' if nothing // was selected... - o.select() + dialog.select() .addClass('highlighted') + }) }) .on('open', function(){ diff --git a/ui (gen4)/features/keyboard.js b/ui (gen4)/features/keyboard.js index fcda7f2f..fd07fd8d 100755 --- a/ui (gen4)/features/keyboard.js +++ b/ui (gen4)/features/keyboard.js @@ -140,7 +140,7 @@ module.GLOBAL_KEYBOARD = { H: { default: 'flipHorizontal', ctrl: 'listURLHistory', - 'ctrl+shift': 'listSaveHistoryDialog', + 'ctrl+shift': 'listSaveHistory', alt: 'browseActions: "/History/" -- Open history menu', }, V: 'flipVertical', diff --git a/ui (gen4)/features/metadata.js b/ui (gen4)/features/metadata.js index ac2bbac0..7e4194fd 100755 --- a/ui (gen4)/features/metadata.js +++ b/ui (gen4)/features/metadata.js @@ -25,6 +25,7 @@ var keyboard = require('lib/keyboard') var actions = require('lib/actions') var core = require('features/core') var base = require('features/base') +var widgets = require('features/ui-widgets') var browse = require('lib/widget/browse') var overlay = require('lib/widget/overlay') @@ -327,7 +328,8 @@ var MetadataUIActions = actions.Actions({ // XXX should we replace 'mode' with nested set of metadata??? // XXX make this support multiple images... showMetadata: ['Image/Show metadata', - function(image, mode){ + widgets.makeUIDialog(function(image, mode){ + //function(image, mode){ var that = this image = this.data.getImage(image) mode = mode || 'disabled' @@ -445,65 +447,65 @@ var MetadataUIActions = actions.Actions({ } // XXX might be a good idea to directly bind ctrl-c to copy value... - var o = overlay.Overlay(this.ribbons.viewer, - browse.makeList( - null, - _buildInfoList(image, metadata), - { - showDisabled: false, - }) - // select value of current item... - .on('select', function(evt, elem){ - if(that.config['metadata-auto-select-mode'] == 'on select'){ - $(elem).find('.text').last().selectText() - } + var o = browse.makeList( + null, + _buildInfoList(image, metadata), + { + showDisabled: false, }) - // XXX start editing onkeydown... - .on('keydown', function(){ - // XXX Enter + editable -> edit (only this???) - }) - // path selected... - .open(function(evt, path){ - var editable = RegExp(that.config['metadata-editable-fields'] - .map(function(f){ return util.quoteRegExp(f) }) - .join('|')) + // select value of current item... + .on('select', function(evt, elem){ + if(that.config['metadata-auto-select-mode'] == 'on select'){ + $(elem).find('.text').last().selectText() + } + }) + // XXX start editing onkeydown... + .on('keydown', function(){ + // XXX Enter + editable -> edit (only this???) + }) + // path selected... + .open(function(evt, path){ + var editable = RegExp(that.config['metadata-editable-fields'] + .map(function(f){ return util.quoteRegExp(f) }) + .join('|')) - var elem = o.client.filter(path).find('.text').last() + var elem = o.filter(path).find('.text').last() - // handle select... - if(that.config['metadata-auto-select-mode'] == 'on open'){ - elem.selectText() - } + // handle select... + if(that.config['metadata-auto-select-mode'] == 'on open'){ + elem.selectText() + } - // skip non-editable fields... - if(editable.test(path)){ - elem - .prop('contenteditable', true) - .focus() - .keydown(function(){ - event.stopPropagation() + // skip non-editable fields... + if(editable.test(path)){ + elem + .prop('contenteditable', true) + .focus() + .keydown(function(){ + event.stopPropagation() - var n = keyboard.toKeyName(event.keyCode) + var n = keyboard.toKeyName(event.keyCode) - // reset to original value... - if(n == 'Esc'){ - // XXX + // reset to original value... + if(n == 'Esc'){ + // XXX - // save value... - } else if(n == 'Enter' && event.ctrlKey){ - event.preventDefault() + // save value... + } else if(n == 'Enter' && event.ctrlKey){ + event.preventDefault() - // XXX - } - }) - } - })) - .close(function(){ - // XXX - }) - o.client.dom.addClass('metadata-view') + // XXX + } + }) + } + }) + .on('close', function(){ + // XXX + }) - o.client.updateMetadata = function(metadata){ + o.dom.addClass('metadata-view') + + o.updateMetadata = function(metadata){ metadata = metadata || that.getMetadata() // build new data set and update view... @@ -514,7 +516,7 @@ var MetadataUIActions = actions.Actions({ } return o - }] + })] }) var MetadataUI = @@ -556,14 +558,12 @@ module.MetadataFSUI = core.ImageGridFeatures.Feature({ var that = this var reader = this.readMetadata(image) - return reader && function(overlay){ - var client = overlay.client + return reader && function(client){ var data = client.options.data // add a loading indicator... - // NOTE: this will get removed when calling .updateMetadata() + // NOTE: this will get overwritten when calling .updateMetadata() data.push('---') - //data.push($('
Loading...
')) data.push($('
')) client.update() diff --git a/ui (gen4)/lib/widget/browse.js b/ui (gen4)/lib/widget/browse.js index 9765559f..c0c8bac2 100755 --- a/ui (gen4)/lib/widget/browse.js +++ b/ui (gen4)/lib/widget/browse.js @@ -551,23 +551,9 @@ var BrowserPrototype = { var skip = false return this.dom.find('.path .dir:not(.cur)') .map(function(i, e){ return $(e).text() }) - .toArray() - }, + .toArray() }, set path(value){ - this.update(value) - - /* - // XXX check if path has changed... - value = this.path2list(value) - var cur = this.path - - // update only if path is different... - value.length == cur.length - && cur - .filter(function(e, i){ return e == value[i] }).length != cur.length - && this.update(value) - */ - }, + this.update(value) }, // String path... // @@ -960,7 +946,7 @@ var BrowserPrototype = { .click(function(){ if(!$(this).hasClass('disabled')){ //that.push(quoteWS($(this).find('.text').text())) - that.push($(this).find('.text').text()) + that.push('"'+ $(this).find('.text').text() +'"') } }) // append text elements...