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

Commit

Permalink
EZP-28577: "Last contributor" shouldn't show error when "Creator" is …
Browse files Browse the repository at this point in the history
…removed (#937)

* Fix EZP-28577: "Last contributor" shouldn't show error when "Creator" is removed

* fixup! Fix EZP-28577: "Last contributor" shouldn't show error when "Creator" is removed

* fixup! Fix EZP-28577: "Last contributor" shouldn't show error when "Creator" is removed
  • Loading branch information
adamwojs authored and Łukasz Serwatka committed Jan 8, 2018
1 parent 02623a4 commit 7961a9e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ YUI.add('ez-userloadplugin', function (Y) {
var loadOptions = {api: this.get('host').get('capi')},
User = this.get('userModelConstructor'),
loadedUser = new User(),
attribute = e.attributeName;
attribute = e.attributeName,
loadingErrorAttributeName = e.loadingErrorAttributeName || 'loadingError';

loadedUser.set('id', e.userId);
loadedUser.load(loadOptions, function(error) {
if (error) {
e.target.set('loadingError', true);
e.target.set(loadingErrorAttributeName, true);
} else {
e.target.set(attribute, loadedUser);
}
Expand Down
30 changes: 28 additions & 2 deletions Resources/public/js/views/tabs/ez-locationviewdetailstabview.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ YUI.add('ez-locationviewdetailstabview', function (Y) {

this._fireMethod = this._fireLoadUser;

this.after(['creatorChange', 'ownerChange'], function (e) {
this.after(['creatorChange', 'creatorLoadingErrorChange', 'ownerChange', 'ownerLoadingErrorChange'], function (e) {
this.render();
});
this._addDOMEventHandlers(events);
Expand Down Expand Up @@ -80,7 +80,8 @@ YUI.add('ez-locationviewdetailstabview', function (Y) {
"contentCreator": owner,
"translationsList": translationsList,
"languageCount": translationsList.length,
"loadingError": this.get('loadingError'),
"lastContributorLoadingError": this.get('creatorLoadingError'),
"contentCreatorLoadingError": this.get('ownerLoadingError'),
"sortFields": this._getSortFields(),
"isAscendingOrder": (this.get('sortOrder') === 'ASC')
}));
Expand Down Expand Up @@ -169,16 +170,21 @@ YUI.add('ez-locationviewdetailstabview', function (Y) {
this.fire('loadUser', {
userId: creatorId,
attributeName: 'creator',
loadingErrorAttributeName: 'creatorLoadingError'
});

if (creatorId === ownerId) {
this.onceAfter('creatorChange', function (e) {
this.set('owner', this.get('creator'));
});
this.onceAfter('creatorLoadingErrorChange', function (e) {
this.set('ownerLoadingError', this.get('creatorLoadingError'));
});
} else {
this.fire('loadUser', {
userId: ownerId,
attributeName: 'owner',
loadingErrorAttributeName: 'ownerLoadingError'
});
}
},
Expand Down Expand Up @@ -219,6 +225,16 @@ YUI.add('ez-locationviewdetailstabview', function (Y) {
*/
creator: {},

/**
* Indicates error while loading creator of the content
*
* @attribute creatorLoadingError
* @type {Boolean}
*/
creatorLoadingError: {
value: false
},

/**
* The owner of the content
*
Expand All @@ -227,6 +243,16 @@ YUI.add('ez-locationviewdetailstabview', function (Y) {
*/
owner: {},

/**
* Indicates error while loading owner of the content
*
* @attribute ownerLoadingError
* @type {Boolean}
*/
ownerLoadingError: {
value: false
},

/**
* The content being displayed
*
Expand Down
4 changes: 2 additions & 2 deletions Resources/public/templates/tabs/details.hbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<dl class="ez-details-box-list ez-details-authors ez-asynchronousview pure-g"">
<dt class="ez-details-name pure-u-1-3">{{ translate 'locationview.details.creator' 'locationview'}}</dt>
<dd class="ez-details-value pure-u-2-3">
{{#if loadingError}}
{{#if contentCreatorLoadingError}}
<p class="ez-asynchronousview-error ez-font-icon">
{{ translate 'locationview.details.errorcreator' 'locationview'}}
<button class="ez-asynchronousview-retry ez-button ez-font-icon pure-button">
Expand All @@ -24,7 +24,7 @@

<dt class="ez-details-name pure-u-1-3">{{ translate 'locationview.details.lastcontributor' 'locationview' }}</dt>
<dd class="ez-details-value pure-u-2-3">
{{#if loadingError}}
{{#if lastContributorLoadingError}}
<p class="ez-asynchronousview-error ez-font-icon">
{{ translate 'locationview.details.errorcontributor' 'locationview'}}
<button class="ez-asynchronousview-retry ez-button ez-font-icon pure-button">
Expand Down

0 comments on commit 7961a9e

Please sign in to comment.