This repository has been archived by the owner on May 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix EZP-28657: Link to content object should redirect to the main loc…
…ation of content (#933)
- Loading branch information
Showing
6 changed files
with
198 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
Resources/public/js/views/serverside/ez-linkviewserversideview.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Copyright (C) eZ Systems AS. All rights reserved. | ||
* For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
YUI.add('ez-linkviewserversideview', function (Y) { | ||
"use strict"; | ||
|
||
/** | ||
* Provides the link view server side view | ||
* | ||
* @module ez-linkviewserversideview | ||
*/ | ||
Y.namespace('eZ'); | ||
|
||
var events = { | ||
'.ez-view-link-usage': { | ||
'tap': '_viewLinkUsage' | ||
}, | ||
'.ez-edit-link-usage': { | ||
'tap': '_editLinkUsage' | ||
}, | ||
}, | ||
CONTENT_ID = 'data-content-id', | ||
LANGUAGE_CODE = 'data-language-code'; | ||
|
||
/** | ||
* The link view server side view. | ||
* | ||
* @namespace eZ | ||
* @class LinkViewServerSideView | ||
* @constructor | ||
* @extends eZ.ServerSideView | ||
*/ | ||
Y.eZ.LinkViewServerSideView = Y.Base.create('linkViewServerSideView', Y.eZ.ServerSideView, [], { | ||
initializer: function () { | ||
this._addDOMEventHandlers(events); | ||
}, | ||
|
||
/** | ||
* 'tap' event handler on the content view link. | ||
* | ||
* @method _viewLinkUsage | ||
* @protected | ||
* @param {EventFacade} e | ||
*/ | ||
_viewLinkUsage: function(e) { | ||
var contentId = e.target.getAttribute(CONTENT_ID), | ||
languageCode = e.target.getAttribute(LANGUAGE_CODE); | ||
|
||
e.preventDefault(); | ||
this._fireViewLinkUsage(contentId, languageCode); | ||
}, | ||
|
||
/** | ||
* 'tap' event handler on the content edit button. | ||
* | ||
* @method _viewLinkUsage | ||
* @protected | ||
* @param {EventFacade} e | ||
*/ | ||
_editLinkUsage: function(e) { | ||
var contentId = e.target.getAttribute(CONTENT_ID), | ||
languageCode = e.target.getAttribute(LANGUAGE_CODE); | ||
|
||
e.preventDefault(); | ||
this._fireEditLinkUsage(contentId, languageCode); | ||
}, | ||
|
||
/** | ||
* Fire viewLinkUsage event which redirects user to main location of content. | ||
* | ||
* @method _fireViewLinkUsage | ||
* @protected | ||
* @param {String} contentId | ||
* @param {String} languageCode | ||
*/ | ||
_fireViewLinkUsage: function(contentId, languageCode) { | ||
this.fire('viewLinkUsage', { | ||
contentId: contentId, | ||
languageCode: languageCode | ||
}); | ||
}, | ||
|
||
/** | ||
* Fire editLinkUsage event which redirects user to the content edit form. | ||
* | ||
* @method _fireViewLinkUsage | ||
* @protected | ||
* @param {String} contentId | ||
* @param {String} languageCode | ||
*/ | ||
_fireEditLinkUsage: function(contentId, languageCode) { | ||
this.fire('editLinkUsage', { | ||
contentId: contentId, | ||
languageCode: languageCode | ||
}); | ||
} | ||
}); | ||
}); |
72 changes: 72 additions & 0 deletions
72
Resources/public/js/views/services/ez-linkviewserversideviewservice.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (C) eZ Systems AS. All rights reserved. | ||
* For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
YUI.add('ez-linkviewserversideviewservice', function (Y) { | ||
"use strict"; | ||
|
||
/** | ||
* Provides the link view server side view service class | ||
* | ||
* @method ez-linkviewserversideviewservice | ||
*/ | ||
Y.namespace('eZ'); | ||
|
||
/** | ||
* The Link View Server Side View Service class. | ||
* | ||
* @namespace eZ | ||
* @class LinkViewServerSideViewService | ||
* @constructor | ||
* @extends eZ.ServerSideViewService | ||
*/ | ||
Y.eZ.LinkViewServerSideViewService = Y.Base.create('linkViewServerSideViewService', Y.eZ.ServerSideViewService, [], { | ||
initializer: function () { | ||
this.on('*:viewLinkUsage', this._handleViewLinkUsage); | ||
this.on('*:editLinkUsage', this._handleEditLinkUsage); | ||
}, | ||
|
||
/** | ||
* Redirects user to the main location of content. | ||
* | ||
* @method _handleViewLinkUsage | ||
* @protected | ||
* @param {Object} e event facade | ||
*/ | ||
_handleViewLinkUsage: function(e) { | ||
var app = this.get('app'), | ||
content = null; | ||
|
||
app.set('loading', true); | ||
|
||
content = new Y.eZ.ContentInfo({id: e.contentId}); | ||
content.load({api: this.get('capi')}, function(error, response) { | ||
if (error) { | ||
app.set('loading', false); | ||
return ; | ||
} | ||
|
||
app.navigateTo('viewLocation', { | ||
id: content.get('resources').MainLocation, | ||
languageCode: e.languageCode | ||
}); | ||
}); | ||
}, | ||
|
||
/** | ||
* Redirects user to the content edit form | ||
* | ||
* @method _handleViewLinkUsage | ||
* @protected | ||
* @param {Object} e event facade | ||
*/ | ||
_handleEditLinkUsage: function(e) { | ||
var app = this.get('app'); | ||
|
||
app.navigateTo('editContent', { | ||
id: e.contentId, | ||
languageCode: e.languageCode | ||
}); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters