fix: clear buttons in advanced components editors in Libraries (#36752)
This commit is contained in:
@@ -60,13 +60,18 @@ define(
|
||||
|
||||
/**
|
||||
* Returns just the modified metadata values, in the format used to persist to the server.
|
||||
* Set `replaceNullWithDefault` to true to replace null values with the default values
|
||||
*/
|
||||
getModifiedMetadataValues: function() {
|
||||
getModifiedMetadataValues: function(replaceNullWithDefault = false) {
|
||||
var modified_values = {};
|
||||
this.collection.each(
|
||||
function(model) {
|
||||
if (model.isModified()) {
|
||||
modified_values[model.getFieldName()] = model.getValue();
|
||||
let value = model.getValue();
|
||||
if (replaceNullWithDefault && value === null) {
|
||||
value = model.getDisplayValue();
|
||||
}
|
||||
modified_values[model.getFieldName()] = value
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -125,10 +125,11 @@ function($, _, gettext, BaseView, XBlockView, MetadataView, MetadataCollection)
|
||||
/**
|
||||
* Returns the metadata that has changed in the editor. This is a combination of the metadata
|
||||
* modified in the "Settings" editor, as well as any custom metadata provided by the component.
|
||||
* Set `replaceNullWithDefault` to true to replace null values with the default values.
|
||||
*/
|
||||
getChangedMetadata: function() {
|
||||
getChangedMetadata: function(replaceNullWithDefault = false) {
|
||||
var metadataEditor = this.getMetadataEditor();
|
||||
return _.extend(metadataEditor.getModifiedMetadataValues(), this.getCustomMetadata());
|
||||
return _.extend(metadataEditor.getModifiedMetadataValues(replaceNullWithDefault), this.getCustomMetadata());
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -343,7 +343,7 @@
|
||||
$('.save-button', passElement).bind('click', function() {
|
||||
//event.preventDefault();
|
||||
var error_message_div = $('.xblock-editor-error-message', passElement);
|
||||
const modifiedData = editorView.getChangedMetadata();
|
||||
const modifiedData = editorView.getChangedMetadata(true);
|
||||
|
||||
error_message_div.html();
|
||||
error_message_div.css('display', 'none');
|
||||
|
||||
Reference in New Issue
Block a user