Skip to content

Commit

Permalink
changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
dew326 committed Jun 22, 2016
1 parent 01e1ce4 commit e9f893c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 15 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Platform UI Content on the Fly feature
4. Clear cache and setup assets with `$ composer run-script post-update-cmd`

*(if you use prod env make sure that is set with `$ export SYMFONY_ENV=prod` first)*.
*(if you use prod env make sure that it is set with `$ export SYMFONY_ENV=prod` first)*.


## Configuration
Expand Down Expand Up @@ -62,17 +62,17 @@ parameters:
```

## Default location for content type
If suggested locations are given for content type (or default) the first location in the list will be preselected as location.
If suggested locations are provided for a Content Type (or default) the first location in the list will be preselected.

## Preselected content type
To set the content type you have to provide 'contentTypeIdentifier' in the config of the 'contentDiscover' event.
To set the Content Type you have to provide the 'contentTypeIdentifier' in the config of the 'contentDiscover' event.
Example:
```javascript
/**
* ...
* @param config.visibleMethod {String} which tab should be open. Default: 'browse', possible values: 'browse', 'search', 'create'
* @param config.contentTypeIdentifier {String} content type identifier. Default: none, example values: 'image', 'blog', 'article', 'blog_post'
* config.contentTypeIdentifier is limited to the Create tab, config that works across all tabs will be added in the future
* this parameter is limited to the Create tab, config that works across all tabs will be added in the future
*/
app.fire('contentDiscover', {
config: {
Expand Down
27 changes: 18 additions & 9 deletions bundle/Resources/public/js/views/cof-contentcreationview.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,17 @@ YUI.add('cof-contentcreationview', function (Y) {
* @param event {Object} event facade
*/
_getContentTypes: function (event) {
var eventNewVal = event.newVal,
var displayed = event.newVal,
container = this.get('container'),
contentTypeContainer = container.one(SELECTOR_CONTENT_TYPE),
nextButton = container.one(SELECTOR_NEXT_BUTTON),
restoreFormState = this.get('restoreFormState');

if (!eventNewVal && !restoreFormState) {
if (!displayed && !restoreFormState) {
this._resetFormState();

return;
} else if (eventNewVal && restoreFormState) {
} else if (displayed && restoreFormState) {
this.set('restoreFormState', false);

return;
Expand All @@ -175,6 +175,8 @@ YUI.add('cof-contentcreationview', function (Y) {
/**
* Fetches the content types data.
* Listened in the cof.Plugin.createContentSelectContentType
*
* @event fetchContentTypes
*/
this.fire('fetchContentTypes');
},
Expand Down Expand Up @@ -246,12 +248,14 @@ YUI.add('cof-contentcreationview', function (Y) {
* Fired to save the current state of Discovery Widget.
* Listened in the cof.Plugin.CreateContentUniversalDiscovery
*
* @event saveDiscoveryState
*/
this.fire('saveDiscoveryState');
/**
* Fired to open new Discovery Widget.
* Listened in the cof.Plugin.createContentSelectContentType
* Listened in the cof.Plugin.selectContentType
*
* @event openUniversalDiscoveryWidget
*/
this.fire('openUniversalDiscoveryWidget');

Expand All @@ -266,9 +270,9 @@ YUI.add('cof-contentcreationview', function (Y) {
* @param event {Object} event facade
*/
_updateSelectedLocation: function (event) {
var eventNewVal = event.newVal,
locationPath = eventNewVal.location.get('path'),
contentInfo = eventNewVal.contentInfo,
var selectedLocation = event.newVal,
locationPath = selectedLocation.location.get('path'),
contentInfo = selectedLocation.contentInfo,
selectedName = contentInfo.get('name'),
pathSeparator = '/',
selectedPath = pathSeparator;
Expand All @@ -285,8 +289,10 @@ YUI.add('cof-contentcreationview', function (Y) {
* Fired to set selected location where place the new content.
* Listened in the eZS.Plugin.UniversalDiscoveryWidgetService
*
* @event setParentLocation
* @param selectedLocation {Object} the selected location
*/
this.fire('setParentLocation', {selectedLocation: eventNewVal.location});
this.fire('setParentLocation', {selectedLocation: selectedLocation.location});

this._enableFinishButton();

Expand Down Expand Up @@ -392,6 +398,8 @@ YUI.add('cof-contentcreationview', function (Y) {
* Fired to fetch a list of suggested locations.
* Listened in the cof.Plugin.CreateContentUniversalDiscovery
*
* @event fetchSuggestedLocations
* @param event {eZ.ContentType} the seleceted content type
*/
this.fire('fetchSuggestedLocations', event);

Expand Down Expand Up @@ -538,7 +546,8 @@ YUI.add('cof-contentcreationview', function (Y) {
* Fired to prepare content model for content type.
* Listened in the eZS.Plugin.SelectCreateContent
*
* @param contentType {Object} the content type model
* @event prepareContentModel
* @param contentType {eZ.ContentType} the content type model
*/
contentTypeSelector.fire('prepareContentModel', {contentType: contentType});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ YUI.add('cof-contenttypeselectorview', function (Y) {

/**
* Informs an item is selected.
* Listened in the eZS.CreateContentPopupView
* Listened in the cof.ContentCreationView
*
* @event itemSelected
* @param text {String} text to show on remove button
*/
this.fire('itemSelected', {text: event.text});
Expand Down Expand Up @@ -196,7 +197,8 @@ YUI.add('cof-contenttypeselectorview', function (Y) {
* Fired to prepare content model for content type.
* Listened in the eZS.Plugin.SelectCreateContent
*
* @param contentType {Object} the content type model
* @event prepareContentModel
* @param contentType {eZ.ContentType} the content type model
*/
this.fire('prepareContentModel', {contentType: type});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,22 @@ YUI.add('cof-createcontent-universaldiscoveryplugin', function (Y) {
_closeDiscoveryWidget: function (event) {
var host = this.get('host');

/**
* Fired to confirm selection in the universal discovery widget.
* Listened in the eZ.UniversalDiscoveryView
*
* @event confirmSelectedContent
* @param selection {Object} the selected content
*/
host.fire('confirmSelectedContent', {selection: event});

/**
* Fired to inform thaht content is discovered.
* Listened in the eZ.Plugin.UniversalDiscovery
*
* @event contentDiscovered
* @param selection {Object} the selected content
*/
host.fire('contentDiscovered', {
selection: host.get('selection'),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ YUI.add('cof-selectcontenttypeplugin', function (Y) {
event.target.set('suggestedLocations', result);
})
.catch(function (error) {
/**
* Displays a notification bar with error message.
* Listened by eZ.PlatformUIApp
*
* @event notify
* @param notification {Object} notification data
*/
host.fire('notify', {
notification: {
text: error.message || 'An unexpected error has occurred',
Expand Down

0 comments on commit e9f893c

Please sign in to comment.