update placeholder after setting a mixed field to an empty value

This commit is contained in:
j 2019-01-31 11:03:18 +05:30
parent 8866960009
commit aaa9a4a538

View file

@ -8,6 +8,8 @@ oml.ui.infoView = function(externalData, isMixed) {
arrayKeys = ['author', 'place', 'publisher', 'language', 'categories'], arrayKeys = ['author', 'place', 'publisher', 'language', 'categories'],
editables = {},
iconSize = externalData ? 256 : ui.iconSize, iconSize = externalData ? 256 : ui.iconSize,
isMultiple = arguments.length == 2, isMultiple = arguments.length == 2,
@ -484,7 +486,7 @@ oml.ui.infoView = function(externalData, isMixed) {
marginTop: '-2px' marginTop: '-2px'
}) })
.append( .append(
Ox.EditableContent({ editables['title'] = Ox.EditableContent({
clickLink: oml.clickLink, clickLink: oml.clickLink,
editable: isEditable, editable: isEditable,
placeholder: formatLight(Ox._( placeholder: formatLight(Ox._(
@ -512,7 +514,7 @@ oml.ui.infoView = function(externalData, isMixed) {
marginTop: '2px' marginTop: '2px'
}) })
.append( .append(
Ox.EditableContent({ editables['author'] = Ox.EditableContent({
clickLink: oml.clickLink, clickLink: oml.clickLink,
editable: isEditable, editable: isEditable,
format: function(value) { format: function(value) {
@ -557,7 +559,7 @@ oml.ui.infoView = function(externalData, isMixed) {
$('<span>') $('<span>')
.html(formatKey(key)) .html(formatKey(key))
.appendTo($div); .appendTo($div);
Ox.EditableContent({ editables[key] = Ox.EditableContent({
clickLink: oml.clickLink, clickLink: oml.clickLink,
editable: isEditable, editable: isEditable,
format: function(value) { format: function(value) {
@ -599,7 +601,7 @@ oml.ui.infoView = function(externalData, isMixed) {
$('<span>') $('<span>')
.html(formatKey(key)) .html(formatKey(key))
.appendTo($div); .appendTo($div);
Ox.EditableContent({ editables[key] = Ox.EditableContent({
clickLink: oml.clickLink, clickLink: oml.clickLink,
editable: isEditable, editable: isEditable,
format: function(value) { format: function(value) {
@ -641,7 +643,7 @@ oml.ui.infoView = function(externalData, isMixed) {
$('<span>') $('<span>')
.html(formatKey('categories')) .html(formatKey('categories'))
.appendTo($div); .appendTo($div);
Ox.EditableContent({ editables['categories'] = Ox.EditableContent({
clickLink: oml.clickLink, clickLink: oml.clickLink,
editable: isEditable, editable: isEditable,
format: function(value) { format: function(value) {
@ -672,7 +674,7 @@ oml.ui.infoView = function(externalData, isMixed) {
$('<span>') $('<span>')
.html(formatKey('isbn')) .html(formatKey('isbn'))
.appendTo($div); .appendTo($div);
Ox.EditableContent({ editables['isbn'] = Ox.EditableContent({
editable: isEditable, editable: isEditable,
format: function(value) { format: function(value) {
return (value ? [ return (value ? [
@ -709,7 +711,7 @@ oml.ui.infoView = function(externalData, isMixed) {
textAlign: 'justify' textAlign: 'justify'
}) })
.append( .append(
Ox.EditableContent({ editables[key] = Ox.EditableContent({
clickLink: oml.clickLink, clickLink: oml.clickLink,
editable: isEditable, editable: isEditable,
format: function(value) { format: function(value) {
@ -798,6 +800,13 @@ oml.ui.infoView = function(externalData, isMixed) {
if (!Ox.isEqual(edit[key], data[key])) { if (!Ox.isEqual(edit[key], data[key])) {
data[key] = edit[key]; data[key] = edit[key];
oml.api.edit(edit, function(result) { oml.api.edit(edit, function(result) {
if (isMixed[key]) {
isMixed[key] = false
var placeholder = editables[key].options('placeholder').replace('Mixed', 'Unknown').replace('mixed', 'unknown')
editables[key].options({
placeholder: placeholder
})
}
if (!isMultiple || ui.updateResults) { if (!isMultiple || ui.updateResults) {
Ox.Request.clearCache(); Ox.Request.clearCache();
if (Ox.contains(['title', 'author', 'description'], key)) { if (Ox.contains(['title', 'author', 'description'], key)) {
@ -815,7 +824,7 @@ oml.ui.infoView = function(externalData, isMixed) {
result.data.id, key, result.data[key] result.data.id, key, result.data[key]
); );
} }
that.updateElement(result.data, [$data]); $data && that.updateElement(result.data, [$data]);
that.triggerEvent('change', Ox.extend({}, key, value)); that.triggerEvent('change', Ox.extend({}, key, value));
}); });
} }