Lines 104-109 can be replaced with:
if (metadataEditor) {
      data.metadata = _.extend(data.metadata || {}, this.getChangedMetadata());
}