info view: make unique on split; compare correctly on edit
This commit is contained in:
parent
d54f524953
commit
d3de45766d
1 changed files with 21 additions and 12 deletions
|
@ -285,10 +285,14 @@ oml.ui.infoView = function(externalData, isMixed) {
|
|||
&& Ox.decodeHTMLEntities(value).split(separator).some(function(value) {
|
||||
return Ox.endsWith(value, ' (Ed.)');
|
||||
});
|
||||
return Ox.decodeHTMLEntities(value).split(separator).map(function(value) {
|
||||
return Ox.encodeHTMLEntities(value).replace(/ \(Ed\.\)/, '')
|
||||
+ (isEditor ? ' (Ed.)' : '');
|
||||
});
|
||||
return Ox.unique(
|
||||
Ox.decodeHTMLEntities(value).split(separator).map(function(value) {
|
||||
value = Ox.encodeHTMLEntities(value);
|
||||
return isEditor
|
||||
? value.replace(/ \(Ed\.\)$/, '') + ' (Ed.)'
|
||||
: value;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
function toggleCoverSize(ratio) {
|
||||
|
@ -470,7 +474,11 @@ oml.ui.infoView = function(externalData, isMixed) {
|
|||
)),
|
||||
tooltip: isEditable ? oml.getEditTooltip() : '',
|
||||
value: Ox.encodeHTMLEntities(
|
||||
(data.author || []).join(separator)
|
||||
(data.author || []).map(function(value, index) {
|
||||
return index < data.author.length - 1
|
||||
? value.replace(/ \(Ed\.\)$/, '')
|
||||
: value;
|
||||
}).join(separator)
|
||||
)
|
||||
})
|
||||
.css({
|
||||
|
@ -727,13 +735,14 @@ oml.ui.infoView = function(externalData, isMixed) {
|
|||
});
|
||||
|
||||
function editMetadata(key, value) {
|
||||
if (value != data[key]) {
|
||||
var edit = {id: !isMultiple ? data.id : ui.listSelection};
|
||||
edit[key] = key == 'author'
|
||||
? splitValue(value || [], 'author')
|
||||
: Ox.contains(arrayKeys, key)
|
||||
? value ? value.split(separator) : []
|
||||
: value;
|
||||
var edit = Ox.extend(
|
||||
{id: !isMultiple ? data.id : ui.listSelection},
|
||||
key,
|
||||
Ox.contains(arrayKeys, key)
|
||||
? splitValue(value || '', key)
|
||||
: value
|
||||
);
|
||||
if (!Ox.isEqual(edit[key], data[key])) {
|
||||
data[key] = edit[key];
|
||||
oml.api.edit(edit, function(result) {
|
||||
if (!isMultiple || ui.updateResults) {
|
||||
|
|
Loading…
Reference in a new issue