Skip to content

Commit

Permalink
Merge pull request ezsystems#208 from ezsystems/ezp-23788_update_imag…
Browse files Browse the repository at this point in the history
…e_alt_text

EZP-23788: Fix the field value when trying to update only the alt text
  • Loading branch information
dpobel committed Mar 20, 2015
2 parents 9f7781e + 149edb3 commit 6ea6776
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Resources/public/js/views/fields/ez-binarybase-editview.js
Expand Up @@ -125,9 +125,8 @@ YUI.add('ez-binarybase-editview', function (Y) {
}
this._trackVersionSave();

fieldValue = {
fileName: file.name,
};
fieldValue = Y.merge(this.get('field').fieldValue);
fieldValue.fileName = file.name;
if ( file.data ) {
fieldValue.data = file.data;
}
Expand Down
1 change: 1 addition & 0 deletions Resources/public/js/views/fields/ez-image-editview.js
Expand Up @@ -218,6 +218,7 @@ YUI.add('ez-image-editview', function (Y) {
*/
_completeFieldValue: function (fieldValue) {
fieldValue.alternativeText = this.get('alternativeText');
delete fieldValue.variations;
return fieldValue;
},

Expand Down
5 changes: 5 additions & 0 deletions Tests/js/views/fields/assets/ez-binaryfile-editview-tests.js
Expand Up @@ -218,6 +218,11 @@ YUI.add('ez-binaryfile-editview-tests', function (Y) {
},

_assertCorrectFieldValue: function (fieldValue, msg) {
Assert.areNotSame(
this.view.get('field').fieldValue,
fieldValue,
"The original field value should be cloned"
);
Assert.areEqual(this.newValue.name, fieldValue.fileName, msg);
Assert.areEqual(this.newValue.size, fieldValue.fileSize, msg);
Assert.areEqual(this.newValue.data, fieldValue.data, msg);
Expand Down
10 changes: 10 additions & 0 deletions Tests/js/views/fields/assets/ez-image-editview-tests.js
Expand Up @@ -437,6 +437,7 @@ YUI.add('ez-image-editview-tests', function (Y) {
fieldValue: {
fileName: "original.jpg",
alternativeText: "Alt text",
variations: {},
},
newValue: {
name: "me.jpg",
Expand Down Expand Up @@ -467,6 +468,15 @@ YUI.add('ez-image-editview-tests', function (Y) {
},

_assertCorrectFieldValue: function (fieldValue, msg) {
Assert.areNotSame(
this.view.get('field').fieldValue,
fieldValue,
"The original field value should be cloned"
);
Assert.isUndefined(
fieldValue.variations,
"The variations object should be removed from the field value"
);
Assert.areEqual(this.newValue.name, fieldValue.fileName, msg);
Assert.areEqual(this.newValue.size, fieldValue.fileSize, msg);
Assert.areEqual(this.newValue.data, fieldValue.data, msg);
Expand Down
5 changes: 5 additions & 0 deletions Tests/js/views/fields/assets/ez-media-editview-tests.js
Expand Up @@ -334,6 +334,11 @@ YUI.add('ez-media-editview-tests', function (Y) {
},

_assertCorrectFieldValue: function (fieldValue, msg) {
Assert.areNotSame(
this.view.get('field').fieldValue,
fieldValue,
"The original field value should be cloned"
);
Assert.areEqual(this.newValue.name, fieldValue.fileName, msg);
Assert.areEqual(this.newValue.size, fieldValue.fileSize, msg);
Assert.areEqual(this.newValue.data, fieldValue.data, msg);
Expand Down

0 comments on commit 6ea6776

Please sign in to comment.