mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
export presets mostly done, still need testing and tweaking...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
2629c25406
commit
ca34894f22
@ -3105,21 +3105,12 @@ var FileSystemWriterUIActions = actions.Actions({
|
|||||||
'exportDialog: "images"'],
|
'exportDialog: "images"'],
|
||||||
|
|
||||||
|
|
||||||
// XXX ASAP BUG: affecting preset name will delete on dialog close...
|
// XXX BUG: changing values from history (button) changes the default
|
||||||
// to reproduce:
|
// and not the current preset...
|
||||||
// - open dialog
|
// ...bug in exportDialog(..)
|
||||||
// - edit preset changing path
|
|
||||||
// - close
|
|
||||||
// result:
|
|
||||||
// .config['export-presets'] will contain undefined instead
|
|
||||||
// of last preset
|
|
||||||
// likely cause:
|
|
||||||
// - inconsistent keys and on .close(..) we can't get the
|
|
||||||
// correct preset...
|
|
||||||
// XXX ASAP BUG: running a preset from the editor will use the default
|
// XXX ASAP BUG: running a preset from the editor will use the default
|
||||||
// settings and not the loaded preset...
|
// settings and not the loaded preset...
|
||||||
// ...can't reproduce... (revise)
|
// ...can't reproduce... (revise)
|
||||||
// XXX ASAP handle presets with repeating titles...
|
|
||||||
// XXX UI:
|
// XXX UI:
|
||||||
// - element format:
|
// - element format:
|
||||||
// TITLE
|
// TITLE
|
||||||
@ -3128,6 +3119,7 @@ var FileSystemWriterUIActions = actions.Actions({
|
|||||||
// - button shortcuts...
|
// - button shortcuts...
|
||||||
// XXX add a 'name' field to the exportDialog(..) (???)
|
// XXX add a 'name' field to the exportDialog(..) (???)
|
||||||
// XXX would be nice to mark/title sections -- presets / history... (???)
|
// XXX would be nice to mark/title sections -- presets / history... (???)
|
||||||
|
// XXX use UniqueKeyMap(..) in browse2's listers...
|
||||||
exportPresets: ['- File/Export presets and history...',
|
exportPresets: ['- File/Export presets and history...',
|
||||||
core.doc`
|
core.doc`
|
||||||
`,
|
`,
|
||||||
@ -3135,13 +3127,6 @@ var FileSystemWriterUIActions = actions.Actions({
|
|||||||
var that = this
|
var that = this
|
||||||
var logger = this.logger && this.logger.push('exportPresets')
|
var logger = this.logger && this.logger.push('exportPresets')
|
||||||
|
|
||||||
|
|
||||||
// XXX use this as index...
|
|
||||||
// XXX use this in browse2...
|
|
||||||
var index = containers.UniqueKeyMap()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var getName = function(preset){
|
var getName = function(preset){
|
||||||
var date = preset.date
|
var date = preset.date
|
||||||
&& Date.fromTimeStamp(preset.date).toShortDate()
|
&& Date.fromTimeStamp(preset.date).toShortDate()
|
||||||
@ -3157,40 +3142,42 @@ var FileSystemWriterUIActions = actions.Actions({
|
|||||||
`${ preset.mode }: `
|
`${ preset.mode }: `
|
||||||
+`"${ preset['preview-name-pattern'] }" → "${ preset.path }"${ clean }`
|
+`"${ preset['preview-name-pattern'] }" → "${ preset.path }"${ clean }`
|
||||||
: `${ preset.mode }: → "${ preset.path }"${ clean }`)) }
|
: `${ preset.mode }: → "${ preset.path }"${ clean }`)) }
|
||||||
|
var buildIndex = function(source){
|
||||||
var buildIndex = function(presets){
|
|
||||||
var index
|
var index
|
||||||
return [
|
return [
|
||||||
// index...
|
index = containers.UniqueKeyMap(source
|
||||||
(index = presets
|
.map(function(e){
|
||||||
.reduce(function(res, e, i){
|
return [getName(e), e] })),
|
||||||
res[getName(e)] = i
|
[...index.keys()], ] }
|
||||||
return res }, {})),
|
|
||||||
// keys...
|
|
||||||
Object.keys(index), ] }
|
|
||||||
var getPreset = function(title, presets, index){
|
|
||||||
return presets[index[title]] }
|
|
||||||
// presets...
|
// presets...
|
||||||
var presets = that.config['export-presets'] || []
|
var presets = that.config['export-presets'] || []
|
||||||
var [index, keys] = buildIndex(presets)
|
var [preset_index, preset_keys] = buildIndex(presets)
|
||||||
|
|
||||||
var updateIndex = function(){
|
var updateIndex = function(full=false){
|
||||||
var [idx, k] = buildIndex(presets)
|
var k
|
||||||
index = idx
|
;[preset_index, k] = full ?
|
||||||
// NOTE: keys must be updated in-place...
|
buildIndex(presets)
|
||||||
keys.splice(0, keys.length, ...k) }
|
: [preset_index, [...preset_index.keys()]]
|
||||||
|
// NOTE: preset_keys must be updated in-place...
|
||||||
|
preset_keys.splice(0, preset_keys.length, ...k) }
|
||||||
|
var renamePreset = function(from, to){
|
||||||
|
to = preset_index.rename(from, to, true)
|
||||||
|
// update keys...
|
||||||
|
preset_keys[preset_keys.indexOf(from)] = to
|
||||||
|
return to }
|
||||||
|
|
||||||
// history...
|
// history...
|
||||||
// NOTE: history is reversed in view...
|
// NOTE: history is reversed in view...
|
||||||
var history = (that.config['export-history'] || [])
|
var history = (that.config['export-history'] || [])
|
||||||
.slice()
|
.slice()
|
||||||
.reverse()
|
.reverse()
|
||||||
var [history_index, history_keys] = buildIndex(history)
|
var [history_index, history_keys] = buildIndex(history)
|
||||||
|
|
||||||
return browse.makeLister(null, function(path, make){
|
return browse.makeLister(null, function(path, make){
|
||||||
// preset list...
|
// preset list...
|
||||||
keys.length > 0
|
preset_keys.length > 0
|
||||||
&& make.EditableList(keys, {
|
&& make.EditableList(preset_keys, {
|
||||||
list_id: 'presets',
|
list_id: 'presets',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
update_merge: 'live',
|
update_merge: 'live',
|
||||||
@ -3198,17 +3185,18 @@ var FileSystemWriterUIActions = actions.Actions({
|
|||||||
// saving an empty string on item edit will clear .name...
|
// saving an empty string on item edit will clear .name...
|
||||||
allow_empty: true,
|
allow_empty: true,
|
||||||
itemedit: function(evt, from, to){
|
itemedit: function(evt, from, to){
|
||||||
var preset = getPreset(from, presets, index)
|
var preset = preset_index.get(from)
|
||||||
// reset...
|
// reset...
|
||||||
if(to.trim() == ''){
|
if(to.trim() == ''){
|
||||||
delete preset.name
|
delete preset.name
|
||||||
to = keys[keys.indexOf(from)] = getName(preset)
|
// XXX need to ignore .date here...
|
||||||
|
to = getName(preset)
|
||||||
// set...
|
// set...
|
||||||
} else {
|
} else {
|
||||||
to = preset.name = to.trim() }
|
to = preset.name = to.trim() }
|
||||||
// update index...
|
|
||||||
index[to] = index[from]
|
to = renamePreset(from, to)
|
||||||
delete index[from]
|
|
||||||
// select item...
|
// select item...
|
||||||
// NOTE: this is not done automatically because
|
// NOTE: this is not done automatically because
|
||||||
// we are changing the title .EditableList(..)
|
// we are changing the title .EditableList(..)
|
||||||
@ -3220,35 +3208,34 @@ var FileSystemWriterUIActions = actions.Actions({
|
|||||||
// edit...
|
// edit...
|
||||||
['<small class="show-on-hover">edit</small>',
|
['<small class="show-on-hover">edit</small>',
|
||||||
function(title){
|
function(title){
|
||||||
var preset = getPreset(title, presets, index)
|
var preset = preset_index.get(title)
|
||||||
|
var o = getName(preset)
|
||||||
that.exportDialog(preset)
|
that.exportDialog(preset)
|
||||||
.close(function(){
|
.close(function(){
|
||||||
var n = getName(preset)
|
var n = getName(preset)
|
||||||
// update the list if name is affected...
|
// update the list if name is affected...
|
||||||
if(n != title){
|
if(n != o){
|
||||||
keys[keys.indexOf(title)] = n
|
n = renamePreset(o, n)
|
||||||
index[n] = index[title]
|
|
||||||
delete index[title]
|
|
||||||
make.dialog.select(n)
|
make.dialog.select(n)
|
||||||
make.dialog.update() } })}],
|
make.dialog.update() } })}],
|
||||||
// duplicate...
|
// duplicate...
|
||||||
//['<span class="show-on-hover">❏</span>',
|
//['<span class="show-on-hover">❏</span>',
|
||||||
['<small class="show-on-hover">clone</small>',
|
['<small class="show-on-hover">clone</small>',
|
||||||
function(title){
|
function(title){
|
||||||
|
// clone...
|
||||||
var preset = JSON.parse(
|
var preset = JSON.parse(
|
||||||
JSON.stringify(
|
JSON.stringify( preset_index.get(title) ))
|
||||||
getPreset(title, presets, index) ))
|
|
||||||
preset.name = title + ' (copy)'
|
preset.name = title + ' (copy)'
|
||||||
// place preset in list...
|
// place new preset in list...
|
||||||
var i = index[preset.name] = index[title]+1
|
presets.splice(preset_keys.indexOf(title)+1, 0, preset)
|
||||||
presets.splice(i, 0, preset)
|
updateIndex(true)
|
||||||
keys.splice(keys.indexOf(title)+1, 0, preset.name)
|
|
||||||
make.dialog.update() }],
|
make.dialog.update() }],
|
||||||
['♦', 'TO_TOP'],
|
['♦', 'TO_TOP'],
|
||||||
'REMOVE'],
|
'REMOVE'],
|
||||||
// export...
|
// export...
|
||||||
open: function(evt, title){
|
open: function(evt, title){
|
||||||
var preset = getPreset(title, presets, index)
|
var preset = preset_index.get(title)
|
||||||
// export only if we get a good preset...
|
// export only if we get a good preset...
|
||||||
if(preset && getName(preset) == title){
|
if(preset && getName(preset) == title){
|
||||||
console.log('>>>>>>>>>', preset)
|
console.log('>>>>>>>>>', preset)
|
||||||
@ -3265,7 +3252,7 @@ var FileSystemWriterUIActions = actions.Actions({
|
|||||||
that.exportDialog()
|
that.exportDialog()
|
||||||
// new preset saved...
|
// new preset saved...
|
||||||
.on('save-preset', function(){
|
.on('save-preset', function(){
|
||||||
updateIndex()
|
updateIndex(true)
|
||||||
make.dialog.update() })
|
make.dialog.update() })
|
||||||
// close dialog on export...
|
// close dialog on export...
|
||||||
.close(function(evt, reason){
|
.close(function(evt, reason){
|
||||||
@ -3285,14 +3272,14 @@ var FileSystemWriterUIActions = actions.Actions({
|
|||||||
// view...
|
// view...
|
||||||
['<small class="show-on-hover">view</small>',
|
['<small class="show-on-hover">view</small>',
|
||||||
function(title){
|
function(title){
|
||||||
var preset = getPreset(title, history, history_index)
|
var preset = history_index.get(title)
|
||||||
preset
|
preset
|
||||||
&& that.exportDialog(
|
&& that.exportDialog(
|
||||||
// prevent editing history...
|
// prevent editing history...
|
||||||
JSON.parse(JSON.stringify( preset )) )
|
JSON.parse(JSON.stringify( preset )) )
|
||||||
// new preset saved...
|
// new preset saved...
|
||||||
.on('save-preset', function(){
|
.on('save-preset', function(){
|
||||||
updateIndex()
|
updateIndex(true)
|
||||||
make.dialog.update() })
|
make.dialog.update() })
|
||||||
// close dialog on export...
|
// close dialog on export...
|
||||||
.close(function(evt, reason){
|
.close(function(evt, reason){
|
||||||
@ -3301,16 +3288,16 @@ var FileSystemWriterUIActions = actions.Actions({
|
|||||||
// to preset...
|
// to preset...
|
||||||
['<small class="show-on-hover">save</small>',
|
['<small class="show-on-hover">save</small>',
|
||||||
function(title){
|
function(title){
|
||||||
var preset = getPreset(title, history, history_index)
|
var preset = history_index.get(title)
|
||||||
if(preset){
|
if(preset){
|
||||||
that.exportPresetSave(preset)
|
that.exportPresetSave(preset)
|
||||||
updateIndex()
|
updateIndex(true)
|
||||||
make.dialog.update() } }],
|
make.dialog.update() } }],
|
||||||
'REMOVE',
|
'REMOVE',
|
||||||
],
|
],
|
||||||
// export...
|
// export...
|
||||||
open: function(evt, title){
|
open: function(evt, title){
|
||||||
var preset = getPreset(title, history, history_index)
|
var preset = history_index.get(title)
|
||||||
// export only if we get a good preset...
|
// export only if we get a good preset...
|
||||||
if(preset && getName(preset) == title){
|
if(preset && getName(preset) == title){
|
||||||
console.log('>>>>>>>>>', preset)
|
console.log('>>>>>>>>>', preset)
|
||||||
@ -3331,15 +3318,15 @@ var FileSystemWriterUIActions = actions.Actions({
|
|||||||
// save things after we are done...
|
// save things after we are done...
|
||||||
.close(function(){
|
.close(function(){
|
||||||
// update preset order and count...
|
// update preset order and count...
|
||||||
that.config['export-presets'] = keys
|
that.config['export-presets'] = preset_keys
|
||||||
.map(function(e){
|
.map(function(e){
|
||||||
return getPreset(e, presets, index) })
|
return preset_index.get(e) })
|
||||||
// handle history delete...
|
// handle history delete...
|
||||||
history.length != that.config['export-history']
|
history.length != that.config['export-history']
|
||||||
&& (that.config['export-history'] = history_keys
|
&& (that.config['export-history'] = history_keys
|
||||||
.reverse()
|
.reverse()
|
||||||
.map(function(e){
|
.map(function(e){
|
||||||
return getPreset(e, history, history_index) })) }) })],
|
return history_index.get(e) })) }) })],
|
||||||
|
|
||||||
// XXX these do note need the ui -- move to a separate feature...
|
// XXX these do note need the ui -- move to a separate feature...
|
||||||
// XXX these are essentially the same as the history API, make a
|
// XXX these are essentially the same as the history API, make a
|
||||||
|
|||||||
6
Viewer/package-lock.json
generated
6
Viewer/package-lock.json
generated
@ -1112,9 +1112,9 @@
|
|||||||
"integrity": "sha512-EzT4CP6d6lI8bnknNgT3W8mUQhSVXflO0yPbKD4dKsFcINiC6npjoEBz+8m3VQmWJhc+36pXD4JLwNxUEgzi+Q=="
|
"integrity": "sha512-EzT4CP6d6lI8bnknNgT3W8mUQhSVXflO0yPbKD4dKsFcINiC6npjoEBz+8m3VQmWJhc+36pXD4JLwNxUEgzi+Q=="
|
||||||
},
|
},
|
||||||
"ig-types": {
|
"ig-types": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/ig-types/-/ig-types-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/ig-types/-/ig-types-2.0.4.tgz",
|
||||||
"integrity": "sha512-hiNlUxNvfgoSoH6r2P7Qn3v+W5IEuVIian7UqNK3zjCkZNiOn8XN6hNu7iHnFBoZcxT19+B4nQ6OnwXogGISag==",
|
"integrity": "sha512-yIeuVShcgZZsK5wMWO/u24jmKJ1hKpXk53x+YpCK3vmI5IzdI8Q34Vk2bZBIiveSFZ4kwHzfBHEvFNbkUpjmYw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"ig-object": "^5.2.8",
|
"ig-object": "^5.2.8",
|
||||||
"object-run": "^1.0.1"
|
"object-run": "^1.0.1"
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
"ig-argv": "^2.15.0",
|
"ig-argv": "^2.15.0",
|
||||||
"ig-features": "^3.4.2",
|
"ig-features": "^3.4.2",
|
||||||
"ig-object": "^5.2.8",
|
"ig-object": "^5.2.8",
|
||||||
"ig-types": "^2.0.1",
|
"ig-types": "^2.0.4",
|
||||||
"moment": "^2.29.0",
|
"moment": "^2.29.0",
|
||||||
"object-run": "^1.0.1",
|
"object-run": "^1.0.1",
|
||||||
"requirejs": "^2.3.6",
|
"requirejs": "^2.3.6",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user