import items
This commit is contained in:
parent
e41942ea99
commit
823ae2a676
11 changed files with 181 additions and 36 deletions
117
static/js/importDialog.js
Normal file
117
static/js/importDialog.js
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
'use strict';
|
||||
|
||||
oml.ui.importDialog = function() {
|
||||
|
||||
var ui = oml.user.ui,
|
||||
username = oml.user.preferences.username,
|
||||
|
||||
lists = ui._lists.filter(function(list) {
|
||||
return list.user == username && list.type == 'static';
|
||||
}),
|
||||
items = [
|
||||
{id: ':', title: Ox._('Library')}
|
||||
].concat(
|
||||
lists.length ? [{}] : []
|
||||
).concat(
|
||||
lists.map(function(list) {
|
||||
return {id: list.id, title: list.name};
|
||||
})
|
||||
).concat([
|
||||
{},
|
||||
{id: '', title: Ox._('New List...')}
|
||||
]),
|
||||
|
||||
listNames = ui._lists.filter(function(list) {
|
||||
return list.user == username;
|
||||
}).map(function(list) {
|
||||
return list.name;
|
||||
}),
|
||||
|
||||
$form = Ox.Form({
|
||||
items: [
|
||||
Ox.Input({
|
||||
changeOnKeypress: true,
|
||||
id: 'path',
|
||||
label: 'Source Path',
|
||||
labelWidth: 128,
|
||||
width: 480
|
||||
}),
|
||||
Ox.SelectInput({
|
||||
id: 'list',
|
||||
inputValue: oml.validateName(Ox._('Untitled'), listNames),
|
||||
inputWidth: 224,
|
||||
items: items,
|
||||
label: 'Destination',
|
||||
labelWidth: 128,
|
||||
max: 1,
|
||||
min: 1,
|
||||
value: ':',
|
||||
width: 480
|
||||
}),
|
||||
Ox.Select({
|
||||
id: 'action',
|
||||
items: [
|
||||
{id: 'copy', title: Ox._('Keep files in source path')},
|
||||
{id: 'move', title: Ox._('Remove files from source path')}
|
||||
],
|
||||
label: Ox._('Import Mode'),
|
||||
labelWidth: 128,
|
||||
width: 480
|
||||
})
|
||||
]
|
||||
})
|
||||
.css({margin: '16px'})
|
||||
.bindEvent({
|
||||
change: function(data) {
|
||||
var values = $form.values();
|
||||
Ox.print('FORM CHANGE', data);
|
||||
if (data.id == 'list') {
|
||||
// FIXME: WRONG
|
||||
if (data.data.value[0] != ':') {
|
||||
$form.values('list', oml.validateName(data.data.value, listNames))
|
||||
}
|
||||
}
|
||||
that[
|
||||
values.path && values.list ? 'enableButton' : 'disableButton'
|
||||
]('import');
|
||||
}
|
||||
}),
|
||||
|
||||
that = Ox.Dialog({
|
||||
buttons: [
|
||||
Ox.Button({
|
||||
id: 'dontimport',
|
||||
title: Ox._('No, Don\'t Import')
|
||||
})
|
||||
.bindEvent({
|
||||
click: function() {
|
||||
that.close();
|
||||
}
|
||||
}),
|
||||
Ox.Button({
|
||||
disabled: true,
|
||||
id: 'import',
|
||||
title: Ox._('Yes, Import')
|
||||
})
|
||||
.bindEvent({
|
||||
click: function() {
|
||||
var data = $form.values();
|
||||
oml.api.import({
|
||||
path: data.path,
|
||||
list: data.list == ':' ? null : data.list
|
||||
}, function() {
|
||||
// ...
|
||||
})
|
||||
that.close();
|
||||
}
|
||||
})
|
||||
],
|
||||
content: $form,
|
||||
height: 128,
|
||||
title: Ox._('Import Books'),
|
||||
width: 512
|
||||
});
|
||||
|
||||
return that;
|
||||
|
||||
};
|
||||
|
|
@ -370,6 +370,8 @@ oml.ui.mainMenu = function() {
|
|||
oml.ui.listDialog.open();
|
||||
} else if (id == 'deletelist') {
|
||||
oml.ui.deleteListDialog().open();
|
||||
} else if (id == 'import') {
|
||||
oml.ui.importDialog().open();
|
||||
} else if (id == 'selectall') {
|
||||
oml.$ui.list.selectAll();
|
||||
} else if (id == 'selectnone') {
|
||||
|
|
@ -545,11 +547,11 @@ oml.ui.mainMenu = function() {
|
|||
title: Ox._('Edit'),
|
||||
items: [
|
||||
{
|
||||
id: 'importitems',
|
||||
id: 'import',
|
||||
title: Ox._('Import Books...')
|
||||
},
|
||||
{
|
||||
id: 'exportitems',
|
||||
id: 'export',
|
||||
title: Ox._('Export Books...')
|
||||
},
|
||||
{},
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
"gridView.js",
|
||||
"iconDialog.js",
|
||||
"identifyDialog.js",
|
||||
"importDialog.js",
|
||||
"info.js",
|
||||
"infoView.js",
|
||||
"itemInnerPanel.js",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue