Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
Merge branch '1.13' into 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerom committed Jan 22, 2018
2 parents edf2f9b + 4f30ee4 commit f9b1bf6
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 46 deletions.
2 changes: 1 addition & 1 deletion Resources/public/css/views/userprofile.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
position: absolute;
top: 5px;
right: 0;
height: 100%;
height: 4em;
}

.ez-view-userprofileview.is-menu-displayed {
Expand Down
3 changes: 1 addition & 2 deletions Resources/public/js/views/fields/ez-relation-editview.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ YUI.add('ez-relation-editview', function (Y) {
_fireLoadFieldRelatedContent: function () {
if ( !this._isFieldEmpty() ) {
this.fire('loadFieldRelatedContent', {
fieldDefinitionIdentifier: this.get('fieldDefinition').identifier,
content: this.get('content'),
destinationContentId: this.get('field').fieldValue.destinationContentHref
});
}
},
Expand Down
4 changes: 1 addition & 3 deletions Resources/public/js/views/fields/ez-relationlist-editview.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ YUI.add('ez-relationlist-editview', function (Y) {
_fireLoadObjectRelations: function () {
if ( !this._isFieldEmpty() ) {
this.fire('loadObjectRelations', {
relationType: 'ATTRIBUTE',
fieldDefinitionIdentifier: this.get('fieldDefinition').identifier,
content: this.get('content'),
destinationContentIds: this.get('field').fieldValue.destinationContentHrefs
});
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,25 @@ YUI.add('ez-objectrelationloadplugin', function (Y) {
_loadFieldRelatedContent: function (e) {
var loadOptions = {api: this.get('host').get('capi')},
relatedContent = this.get('relatedContent'),
destinationContentId = e.destinationContentId,
sourceContent = e.content,
contentDestination;

if ( !sourceContent ) {
console.log('[DEPRECATED] loadFieldRelatedContent event without a source content is deprecated');
console.log('[DEPRECATED] Please provide a source Content item in the event facade under the `content` identifier');
console.log('[DEPRECATED] This feature will be removed from PlatformUI 2.0');
sourceContent = this.get('host').get('content');
if ( !destinationContentId ) {
if ( !sourceContent ) {
console.log('[DEPRECATED] loadFieldRelatedContent event without a source content is deprecated');
console.log('[DEPRECATED] Please provide a source Content item in the event facade under the `content` identifier');
console.log('[DEPRECATED] This feature will be removed from PlatformUI 2.0');
sourceContent = this.get('host').get('content');
}
contentDestination = sourceContent.relations(
'ATTRIBUTE', e.fieldDefinitionIdentifier
).shift();

destinationContentId = contentDestination.destination;
}
contentDestination = sourceContent.relations(
'ATTRIBUTE', e.fieldDefinitionIdentifier
).shift();

relatedContent.set('id', contentDestination.destination);
relatedContent.set('id', destinationContentId);
relatedContent.load(loadOptions, function (error) {
if (error) {
e.target.set("loadingError", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ YUI.add('ez-objectrelationsloadplugin', function (Y) {
loadedRelation = {},
loadingError = false,
sourceContent = e.content,
destinationContentIds = e.destinationContentIds,
contentDestinations,
end = stack.add(function (error, struct) {
if (error) {
Expand All @@ -57,24 +58,29 @@ YUI.add('ez-objectrelationsloadplugin', function (Y) {
}
});

if ( !sourceContent ) {
console.log('[DEPRECATED] loadObjectRelations event without a source content is deprecated');
console.log('[DEPRECATED] Please provide a source Content item in the event facade under the `content` identifier');
console.log('[DEPRECATED] This feature will be removed from PlatformUI 2.0');
sourceContent = this.get('host').get('content');
if ( !destinationContentIds ) {
if ( !sourceContent ) {
console.log('[DEPRECATED] loadObjectRelations event without a source content is deprecated');
console.log('[DEPRECATED] Please provide a source Content item in the event facade under the `content` identifier');
console.log('[DEPRECATED] This feature will be removed from PlatformUI 2.0');
sourceContent = this.get('host').get('content');
}
contentDestinations = sourceContent.relations(
e.relationType, e.fieldDefinitionIdentifier
);
destinationContentIds = Y.Array.map(contentDestinations, function (value) {
return value.destination;
});
}
contentDestinations = sourceContent.relations(
e.relationType, e.fieldDefinitionIdentifier
);

Y.Array.each(contentDestinations, function (value) {
if (!loadedRelation[value.destination]) {
loadedRelation[value.destination] = true;
Y.Array.each(destinationContentIds, function (value) {
if (!loadedRelation[value]) {
loadedRelation[value] = true;

if (e.loadLocation || e.loadLocationPath) {
this._loadContentStruct(value.destination, e.loadLocation, e.loadLocationPath, end);
this._loadContentStruct(value, e.loadLocation, e.loadLocationPath, end);
} else {
this._loadContent(value.destination, end);
this._loadContent(value, end);
}
}
}, this);
Expand Down
18 changes: 9 additions & 9 deletions Tests/js/views/fields/assets/ez-relation-editview-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ YUI.add('ez-relation-editview-tests', function (Y) {
isRequired: false,
fieldSettings: {},
};
this.field = {fieldValue: {destinationContentId: 45}};
this.field = {
fieldValue: {
destinationContentId: 45,
destinationContentHref: '/api/ezp/v2/content/objects/45',
}
};

this.jsonContent = {};
this.jsonContentType = {};
Expand Down Expand Up @@ -181,14 +186,9 @@ YUI.add('ez-relation-editview-tests', function (Y) {

this.view.on('loadFieldRelatedContent', Y.bind(function (e) {
Y.Assert.areSame(
this.fieldDefinitionIdentifier,
e.fieldDefinitionIdentifier,
"fieldDefinitionIdentifier is the same than the one in the field"
);
Y.Assert.areSame(
this.content,
e.content,
"The content should be provided in the event facade"
this.field.fieldValue.destinationContentHref,
e.destinationContentId,
"destinationContentId is the same than the one in the field"
);

loadContentEvent = true;
Expand Down
21 changes: 12 additions & 9 deletions Tests/js/views/fields/assets/ez-relationlist-editview-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ YUI.add('ez-relationlist-editview-tests', function (Y) {
identifier: this.fieldDefinitionIdentifier,
isRequired: false
};
this.field = {fieldValue: {destinationContentIds: [45, 42]}};
this.field = {
fieldValue: {
destinationContentIds: [45, 42],
destinationContentHrefs: [
'/api/ezp/v2/content/objects/45',
'/api/ezp/v2/content/objects/42',
]
}
};

this.jsonContent = {};
this.jsonContentType = {};
Expand Down Expand Up @@ -651,14 +659,9 @@ YUI.add('ez-relationlist-editview-tests', function (Y) {

this.view.on('loadObjectRelations', Y.bind(function (e) {
Y.Assert.areSame(
this.fieldDefinitionIdentifier,
e.fieldDefinitionIdentifier,
"fieldDefinitionIdentifier is the same than the one in the field"
);
Y.Assert.areSame(
this.content,
e.content,
"The content should be provided in the event facade"
this.field.fieldValue.destinationContentHrefs,
e.destinationContentIds,
"destinationContentIds is the same than the one in the field"
);

loadContentEvent = true;
Expand Down

0 comments on commit f9b1bf6

Please sign in to comment.