mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 02:10:08 +00:00
some refactoring and generalization...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
754094e6b3
commit
24f8cbbcec
@ -1274,7 +1274,6 @@ module.AutoCollections = core.ImageGridFeatures.Feature({
|
|||||||
// XXX show collections in image metadata... (???)
|
// XXX show collections in image metadata... (???)
|
||||||
var UICollectionActions = actions.Actions({
|
var UICollectionActions = actions.Actions({
|
||||||
config: {
|
config: {
|
||||||
|
|
||||||
// Global default collections...
|
// Global default collections...
|
||||||
//
|
//
|
||||||
// NOTE: delete or set to null for none...
|
// NOTE: delete or set to null for none...
|
||||||
@ -1282,28 +1281,20 @@ var UICollectionActions = actions.Actions({
|
|||||||
},
|
},
|
||||||
|
|
||||||
editDefaultCollections: ['Interface/Edit default collections...',
|
editDefaultCollections: ['Interface/Edit default collections...',
|
||||||
widgets.makeUIDialog(function(action){
|
widgets.makeConfigListEditorDialog(
|
||||||
var defaults =
|
'default-collections',
|
||||||
this.config['default-collections'] =
|
{
|
||||||
(this.config['default-collections'] || []).slice()
|
cls: 'collection-list',
|
||||||
|
|
||||||
return browse.makeLister(null,
|
unique: true,
|
||||||
function(path, make){
|
sortable: 'y',
|
||||||
make.EditableList(defaults,
|
|
||||||
{
|
|
||||||
unique: true,
|
|
||||||
sortable: 'y',
|
|
||||||
|
|
||||||
normalize: function(title){
|
normalize: function(title){
|
||||||
return title.trim() },
|
return title.trim() },
|
||||||
check: function(title){
|
check: function(title){
|
||||||
return title.length > 0
|
return title.length > 0
|
||||||
&& title != MAIN_COLLECTION_TITLE },
|
&& title != MAIN_COLLECTION_TITLE },
|
||||||
})
|
})],
|
||||||
}, {
|
|
||||||
cls: 'collection-list',
|
|
||||||
})
|
|
||||||
})],
|
|
||||||
|
|
||||||
browseCollections: ['Collections/$Collec$tions...',
|
browseCollections: ['Collections/$Collec$tions...',
|
||||||
core.doc`Collection list...
|
core.doc`Collection list...
|
||||||
|
|||||||
@ -324,8 +324,6 @@ function(actions, list, list_key, value_key, options){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
// Dialogs and containers...
|
// Dialogs and containers...
|
||||||
|
|
||||||
@ -458,7 +456,6 @@ module.makeUIDialog = function(a, b){
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var makeDrawer = function(direction){
|
var makeDrawer = function(direction){
|
||||||
return makeUIContainer(function(dialog, options){
|
return makeUIContainer(function(dialog, options){
|
||||||
var that = this
|
var that = this
|
||||||
@ -485,6 +482,88 @@ var makeDrawer = function(direction){
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
// Higher level dialog action constructors...
|
||||||
|
|
||||||
|
// Make list editor dialog...
|
||||||
|
//
|
||||||
|
// makeListEditorDialog(list[, options])
|
||||||
|
// -> action
|
||||||
|
//
|
||||||
|
// makeListEditorDialog(function[, options])
|
||||||
|
// -> action
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
// someAction: [
|
||||||
|
// makeListEditorDialog(
|
||||||
|
// // list of items to edit or list getter function...
|
||||||
|
// // NOTE: this is edited in place...
|
||||||
|
// [ 'item', .. ] | function(){ .. },
|
||||||
|
// // options compatible with browse's Items.EditableList(..)
|
||||||
|
// { .. })],
|
||||||
|
//
|
||||||
|
// XXX should these replace the makeConfigListEditor/makeNestedConfigListEditor???
|
||||||
|
var makeListEditorDialog =
|
||||||
|
module.makeListEditorDialog =
|
||||||
|
function makeConfigListEditorDialog(list, options){
|
||||||
|
options = options || {}
|
||||||
|
|
||||||
|
return makeUIDialog(function(){
|
||||||
|
var lst = list instanceof Function ?
|
||||||
|
list.call(this)
|
||||||
|
: list
|
||||||
|
|
||||||
|
// NOTE: this will edit the list in place...
|
||||||
|
return browse.makeLister(null,
|
||||||
|
function(_, make){
|
||||||
|
make.EditableList(lst, options)
|
||||||
|
}, {
|
||||||
|
cls: options.cls,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make .config list editor dialog...
|
||||||
|
//
|
||||||
|
// makeConfigListEditorDialog(path[, options])
|
||||||
|
// -> action
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Example:
|
||||||
|
// someAction: [
|
||||||
|
// makeConfigListEditorDialog(
|
||||||
|
// // path to list in .config
|
||||||
|
// 'path.to.list',
|
||||||
|
// // options compatible with browse's Items.EditableList(..)
|
||||||
|
// { .. })],
|
||||||
|
//
|
||||||
|
// NOTE: see collections.editDefaultCollections(..) for a live example.
|
||||||
|
var makeConfigListEditorDialog =
|
||||||
|
module.makeConfigListEditorDialog =
|
||||||
|
function makeConfigListEditorDialog(path, options){
|
||||||
|
path = path.split('.')
|
||||||
|
var key = path.pop()
|
||||||
|
|
||||||
|
return makeListEditorDialog(function(){
|
||||||
|
var p = path.slice()
|
||||||
|
|
||||||
|
// get the path...
|
||||||
|
var cur = this.config
|
||||||
|
while(p.length > 0){
|
||||||
|
var k = p.shift()
|
||||||
|
cur = cur[k] = cur[k] || {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// the actual list we'll be editing...
|
||||||
|
var list =
|
||||||
|
cur[key] =
|
||||||
|
(cur[key] || []).slice()
|
||||||
|
|
||||||
|
return list
|
||||||
|
}, options)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user