find
This commit is contained in:
parent
a9c5fb43fe
commit
e41942ea99
28 changed files with 240 additions and 84 deletions
|
|
@ -37,8 +37,8 @@ oml.ui.appDialog = function() {
|
|||
.css({
|
||||
position: 'absolute',
|
||||
left: '16px',
|
||||
right: '24px',
|
||||
top: '24px',
|
||||
right: '16px',
|
||||
top: '16px',
|
||||
overflowY: 'auto'
|
||||
})
|
||||
.html(
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ oml.ui.identifyDialog = function(data) {
|
|||
|
||||
originalData = Ox.clone(data, true),
|
||||
|
||||
editedData,
|
||||
idValue, titleValue,
|
||||
|
||||
$idInputs, $idButtons = {},
|
||||
|
||||
|
|
@ -125,12 +125,17 @@ oml.ui.identifyDialog = function(data) {
|
|||
var edit = Ox.extend(
|
||||
{id: data.id},
|
||||
$innerPanel.options('selected') == 'id'
|
||||
? Ox.extend({}, 'foo', 'bar')
|
||||
: {olid: $list.value($list.options('selected'), 'olid')}
|
||||
? idValue
|
||||
: titleValue
|
||||
);
|
||||
that.options({content: Ox.LoadingScreen().start()});
|
||||
oml.api.edit(edit, function() {
|
||||
that.disableButtons();
|
||||
oml.api.edit(edit, function(result) {
|
||||
that.close();
|
||||
Ox.Request.clearCache('find');
|
||||
oml.$ui.browser.reloadList(true);
|
||||
Ox.Request.clearCache(data.id);
|
||||
oml.$ui.infoView.update(result.data);
|
||||
});
|
||||
}
|
||||
})
|
||||
|
|
@ -227,7 +232,7 @@ oml.ui.identifyDialog = function(data) {
|
|||
var value = $idInputs[index].options('elements')[1].value();
|
||||
if (data.value) {
|
||||
if (value) {
|
||||
editedData = Ox.extend({}, id.id, value);
|
||||
idValue = Ox.extend({}, id.id, value);
|
||||
$idInputs.forEach(function($input, i) {
|
||||
if (i != index) {
|
||||
$input.options('elements')[0].value(false);
|
||||
|
|
@ -251,7 +256,7 @@ oml.ui.identifyDialog = function(data) {
|
|||
.bindEvent({
|
||||
submit: function(data) {
|
||||
if (data.value) {
|
||||
editedData = Ox.extend({}, id.id, data.value);
|
||||
idValue = Ox.extend({}, id.id, data.value);
|
||||
$idInputs.forEach(function($input, i) {
|
||||
$input.options('elements')[0].options({
|
||||
disabled: true,
|
||||
|
|
@ -336,54 +341,53 @@ oml.ui.identifyDialog = function(data) {
|
|||
}
|
||||
|
||||
function renderResults(items) {
|
||||
items = [Ox.extend({index: '0'}, data)].concat(items);
|
||||
Ox.print('LIST ITEMS::::', items);
|
||||
var $list = Ox.TableList({
|
||||
columns: [{
|
||||
format: function(value, data) {
|
||||
return (data.title || '') + (
|
||||
data.author
|
||||
? ' <span class="OxLight">'
|
||||
+ data.author.join(', ') + '</span>'
|
||||
: ''
|
||||
);
|
||||
columns: [
|
||||
{
|
||||
format: function(value) {
|
||||
return Ox.getObjectById(ids, value).title;
|
||||
},
|
||||
id: 'mainid',
|
||||
visible: true,
|
||||
width: 64
|
||||
},
|
||||
id: 'index',
|
||||
visible: true,
|
||||
width: 192 - Ox.UI.SCROLLBAR_SIZE
|
||||
}],
|
||||
{
|
||||
format: function(value, data) {
|
||||
return data[data.mainid];
|
||||
},
|
||||
id: 'index',
|
||||
visible: true,
|
||||
width: 128 - Ox.UI.SCROLLBAR_SIZE
|
||||
}
|
||||
],
|
||||
items: items,
|
||||
keys: ['author', 'title', 'olid'],
|
||||
keys: ['mainid', 'isbn10', 'isbn13'],
|
||||
min: 1,
|
||||
max: 1,
|
||||
scrollbarVisible: true,
|
||||
selected: ['0'],
|
||||
sort: [{key: 'index', operator: '+'}],
|
||||
sort: [{key: 'mainid', operator: '+'}],
|
||||
unique: 'index'
|
||||
})
|
||||
.bindEvent({
|
||||
select: function(data) {
|
||||
var index = data.ids[0], olid;
|
||||
if (index == '0') {
|
||||
$results.replaceElement(1, oml.ui.infoView(data));
|
||||
} else {
|
||||
olid = $list.value(index, 'olid');
|
||||
editedData = {olid: olid};
|
||||
$results.replaceElement(1, Ox.LoadingScreen().start());
|
||||
oml.api.getMetadata({olid: olid}, function(result) {
|
||||
if (index == $list.options('selected')[0]) {
|
||||
$results.replaceElement(1, oml.ui.infoView(result.data));
|
||||
that.options('buttons')[1].options({disabled: false});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var index = data.ids[0], mainid;
|
||||
mainid = $list.value(index, 'mainid');
|
||||
Ox.print('MAINID', mainid)
|
||||
titleValue = Ox.extend({}, mainid, $list.value(index, mainid));
|
||||
$results.replaceElement(1, Ox.LoadingScreen().start());
|
||||
oml.api.getMetadata(titleValue, function(result) {
|
||||
if (index == $list.options('selected')[0]) {
|
||||
$results.replaceElement(1, oml.ui.infoView(result.data));
|
||||
that.options('buttons')[1].options({disabled: false});
|
||||
}
|
||||
});
|
||||
}
|
||||
}),
|
||||
$results = Ox.SplitPanel({
|
||||
elements: [
|
||||
{element: $list, size: 192},
|
||||
{element: oml.ui.infoView(items[0])}
|
||||
{element: Ox.Element()}
|
||||
],
|
||||
orientation: 'horizontal'
|
||||
});
|
||||
|
|
@ -480,7 +484,7 @@ oml.ui.identifyDialog = function(data) {
|
|||
$idButtons.clear.options({disabled: empty});
|
||||
$idButtons.reset.options({disabled: original});
|
||||
$idButtons.find.options({disabled: empty});
|
||||
that.options('buttons')[1].options({disabled: original});
|
||||
that[original ? 'disableButton' : 'enableButton']('update');
|
||||
}
|
||||
|
||||
function updateTitleButtons() {
|
||||
|
|
@ -493,7 +497,7 @@ oml.ui.identifyDialog = function(data) {
|
|||
$titleButtons.clear.options({disabled: empty});
|
||||
$titleButtons.reset.options({disabled: original});
|
||||
$titleButtons.find.options({disabled: empty});
|
||||
that.options('buttons')[1].options({disabled: original});
|
||||
that[original ? 'disableButton' : 'enableButton']('update');
|
||||
}
|
||||
|
||||
return that;
|
||||
|
|
|
|||
|
|
@ -66,6 +66,12 @@ oml.ui.infoView = function(identifyData) {
|
|||
return '<span class="OxLight">' + str + '</span>';
|
||||
}
|
||||
|
||||
function formatKey(key) {
|
||||
var item = Ox.getObjectById(oml.config.itemKeys, key);
|
||||
return '<span style="font-weight: bold">'
|
||||
+ Ox._(Ox.toTitleCase(key)) + ': </span> ';
|
||||
}
|
||||
|
||||
function formatValue(value, key) {
|
||||
return (Ox.isArray(value) ? value : [value]).map(function(value) {
|
||||
return key ?
|
||||
|
|
@ -234,6 +240,7 @@ oml.ui.infoView = function(identifyData) {
|
|||
$elements = $elements
|
||||
? Ox.makeArray($elements)
|
||||
: [$cover, $info, $data];
|
||||
Ox.print('DEBUG, $ELEMENTS', $elements);
|
||||
|
||||
(data ? Ox.noop : oml.api.get)({
|
||||
id: id,
|
||||
|
|
@ -308,8 +315,9 @@ oml.ui.infoView = function(identifyData) {
|
|||
Ox.EditableContent({
|
||||
clickLink: oml.clickLink,
|
||||
editable: isEditable,
|
||||
placeholder: formatLight(Ox._('Unknown Title')),
|
||||
tooltip: isEditable ? oml.getEditTooltip() : '',
|
||||
value: data.title
|
||||
value: data.title || ''
|
||||
})
|
||||
.css({
|
||||
fontSize: '13px',
|
||||
|
|
@ -330,7 +338,9 @@ oml.ui.infoView = function(identifyData) {
|
|||
clickLink: oml.clickLink,
|
||||
editable: isEditable,
|
||||
format: function(value) {
|
||||
return formatValue(value.split(', '), 'author');
|
||||
return !identifyData
|
||||
? formatValue(value.split(', '), 'author')
|
||||
: value;
|
||||
},
|
||||
placeholder: formatLight(Ox._('Unknown Author')),
|
||||
tooltip: isEditable ? oml.getEditTooltip() : '',
|
||||
|
|
@ -340,23 +350,65 @@ oml.ui.infoView = function(identifyData) {
|
|||
fontSize: '13px',
|
||||
fontWeight: 'bold'
|
||||
})
|
||||
.bindEvent({
|
||||
// ...
|
||||
})
|
||||
)
|
||||
.appendTo($info);
|
||||
}
|
||||
|
||||
if (!isEditable) {
|
||||
$('<div>')
|
||||
.css({
|
||||
marginTop: '8px'
|
||||
})
|
||||
.text(
|
||||
(data.place || '')
|
||||
+ (data.place && (data.publisher || data.date) ? ' : ' : '')
|
||||
+ (data.publisher || '')
|
||||
+ (data.publisher && data.date ? ', ' : '')
|
||||
+ (data.date || '')
|
||||
)
|
||||
.appendTo($info);
|
||||
} else {
|
||||
var $div = $('<div>')
|
||||
.addClass('OxSelectable')
|
||||
.css({marginTop: '8px'})
|
||||
.appendTo($info);
|
||||
['edition', 'publisher', 'date'].forEach(function(key, index) {
|
||||
index && $('<div>').css({float: 'left'}).html('; ').appendTo($div);
|
||||
$('<div>')
|
||||
.css({float: 'left'})
|
||||
.html(formatKey(key))
|
||||
.appendTo($div);
|
||||
Ox.EditableContent({
|
||||
clickLink: oml.clickLink,
|
||||
format: function(value) {
|
||||
return formatValue(value.split(', '), key)
|
||||
},
|
||||
placeholder: formatLight('unknown'),
|
||||
tooltip: oml.getEditTooltip(),
|
||||
value: data[key] || ''
|
||||
})
|
||||
.css({float: 'left'})
|
||||
.bindEvent({
|
||||
submit: function(event) {
|
||||
editMetadata(key, event.value);
|
||||
}
|
||||
})
|
||||
.appendTo($div);
|
||||
});
|
||||
}
|
||||
|
||||
$('<div>')
|
||||
.css({
|
||||
marginTop: '8px'
|
||||
})
|
||||
.text(
|
||||
(data.place || '')
|
||||
+ (data.place && (data.publisher || data.date) ? ' : ' : '')
|
||||
+ (data.publisher || '')
|
||||
+ (data.publisher && data.date ? ', ' : '')
|
||||
+ (data.date || '')
|
||||
)
|
||||
.appendTo($info);
|
||||
if (data.classification) {
|
||||
$('<div>')
|
||||
.css({
|
||||
marginTop: '8px',
|
||||
textAlign: 'justify'
|
||||
})
|
||||
.html(Ox.encodeHTMLEntities(data.classification))
|
||||
.appendTo($info);
|
||||
}
|
||||
|
||||
if (data.description) {
|
||||
$('<div>')
|
||||
|
|
@ -445,11 +497,14 @@ oml.ui.infoView = function(identifyData) {
|
|||
|
||||
});
|
||||
|
||||
// FIXME: identify dialog should call this too
|
||||
function editMetadata(key, value) {
|
||||
var edit;
|
||||
if (value != data[key]) {
|
||||
edit = Ox.extend({id: ui.item}, key, value);
|
||||
oml.api.edit(edit, function(result) {
|
||||
Ox.Request.clearCache('find');
|
||||
oml.$ui.browser.reloadList();
|
||||
that.update(result.data, $data);
|
||||
});
|
||||
}
|
||||
|
|
@ -469,7 +524,7 @@ oml.ui.infoView = function(identifyData) {
|
|||
transfer: function(data) {
|
||||
if (data.id == ui.item && data.progress == 1) {
|
||||
Ox.Request.clearCache(); // FIXME: too much
|
||||
that.update(ui.item, $data);
|
||||
that.update(ui.item, [$info, $data]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -254,8 +254,20 @@ oml.ui.usersDialog = function() {
|
|||
width: 480
|
||||
})
|
||||
.bindEvent({
|
||||
change: function() {
|
||||
// ...
|
||||
change: function(data) {
|
||||
var value = oml.validateName(
|
||||
data.value,
|
||||
users.map(function(user) {
|
||||
return user.nickname;
|
||||
})
|
||||
);
|
||||
this.value(value);
|
||||
oml.api.editUser({
|
||||
id: user.id,
|
||||
nickname: value
|
||||
}, function() {
|
||||
// ...
|
||||
});
|
||||
}
|
||||
})
|
||||
.appendTo($form);
|
||||
|
|
@ -480,6 +492,10 @@ oml.ui.usersDialog = function() {
|
|||
}
|
||||
}
|
||||
|
||||
function updateUsers() {
|
||||
// ...
|
||||
}
|
||||
|
||||
that.update = function() {
|
||||
|
||||
that.options({
|
||||
|
|
@ -503,7 +519,6 @@ oml.ui.usersDialog = function() {
|
|||
);
|
||||
});
|
||||
|
||||
Ox.print('FOLDERS::', folders)
|
||||
folders.forEach(function(folder, index) {
|
||||
$lists.push(
|
||||
(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue