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

[WIP] EZP-25137: As an editor, I want to be able to create and embed a Content "on the fly" in the RichText editor #674

Open
wants to merge 11 commits into
base: feature/content-from-dashboard
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Resources/config/css.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ system:
- 'bundles/ezplatformui/css/views/navigationhub.css'
- 'bundles/ezplatformui/css/views/confirmbox.css'
- 'bundles/ezplatformui/css/views/contentcreationwizard.css'
- 'bundles/ezplatformui/css/views/contentcreator.css'
- 'bundles/ezplatformui/css/views/languageselectionbox.css'
- 'bundles/ezplatformui/css/views/notificationhub.css'
- 'bundles/ezplatformui/css/views/notification.css'
Expand Down Expand Up @@ -116,6 +117,7 @@ system:
- 'bundles/ezplatformui/css/theme/views/bar.css'
- 'bundles/ezplatformui/css/theme/views/confirmbox.css'
- 'bundles/ezplatformui/css/theme/views/contentcreationwizard.css'
- 'bundles/ezplatformui/css/theme/views/contentcreator.css'
- 'bundles/ezplatformui/css/theme/views/languageselectionbox.css'
- 'bundles/ezplatformui/css/theme/views/notificationhub.css'
- 'bundles/ezplatformui/css/theme/views/notification.css'
Expand Down
22 changes: 22 additions & 0 deletions Resources/config/yui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ system:
- 'ez-confirmboxview'
- 'ez-contentcreationwizardviewservice'
- 'ez-contentcreationwizardview'
- 'ez-contentcreatorviewservice'
- 'ez-contentcreatorview'
- 'ez-languageselectionboxviewservice'
- 'ez-languageselectionboxview'
- 'ez-notificationhubviewservice'
Expand All @@ -199,6 +201,7 @@ system:
- 'ez-registerlanguagehelpersplugin'
- 'ez-domstateplugin'
- 'ez-universaldiscoveryplugin'
- 'ez-contentcreatorplugin'
- 'ez-confirmboxplugin'
- 'ez-contentcreationwizardplugin'
- 'ez-languageselectionboxplugin'
Expand Down Expand Up @@ -288,6 +291,9 @@ system:
ez-contentcreationwizardviewservice:
requires: ['ez-viewservice', 'ez-sideviewservice']
path: "%ez_platformui.public_dir%/js/views/services/ez-contentcreationwizardviewservice.js"
ez-contentcreatorviewservice:
requires: ['ez-viewservice', 'ez-sideviewservice']
path: "%ez_platformui.public_dir%/js/views/services/ez-contentcreatorviewservice.js"
ez-languageselectionboxviewservice:
requires: ['ez-viewservice', 'ez-sideviewservice']
path: "%ez_platformui.public_dir%/js/views/services/ez-languageselectionboxviewservice.js"
Expand Down Expand Up @@ -512,6 +518,7 @@ system:
- 'universaldiscoveryview-ez-template'
- 'ez-universaldiscoverybrowseview'
- 'ez-universaldiscoverysearchview'
- 'ez-universaldiscoverycreateview'
- 'ez-universaldiscoveryconfirmedlistview'
- 'array-extras'
- 'event-tap'
Expand Down Expand Up @@ -539,6 +546,15 @@ system:
universaldiscoverybrowseview-ez-template:
type: 'template'
path: "%ez_platformui.public_dir%/templates/universaldiscovery/browse.hbt"
ez-universaldiscoverycreateview:
requires:
- 'ez-universaldiscoverymethodbaseview'
- 'universaldiscoverycreateview-ez-template'
- 'ez-contenteditview'
path: "%ez_platformui.public_dir%/js/views/universaldiscovery/ez-universaldiscoverycreateview.js"
universaldiscoverycreateview-ez-template:
type: 'template'
path: "%ez_platformui.public_dir%/templates/universaldiscovery/create.hbt"
ez-universaldiscoverysearchview:
requires:
- 'ez-universaldiscoverymethodbaseview'
Expand Down Expand Up @@ -700,6 +716,9 @@ system:
languageswitcherview-ez-template:
type: 'template'
path: "%ez_platformui.public_dir%/templates/languageswitcher.hbt"
ez-contentcreatorview:
requires: ['ez-view', 'ez-contenteditview']
path: '%ez_platformui.public_dir%/js/views/ez-contentcreatorview.js'
ez-contenteditview:
requires: ['ez-templatebasedview', 'ez-contenteditformview', 'ez-editactionbarview', 'event-tap', 'contenteditview-ez-template']
path: "%ez_platformui.public_dir%/js/views/ez-contenteditview.js"
Expand Down Expand Up @@ -1227,6 +1246,9 @@ system:
ez-universaldiscoveryplugin:
requires: ['plugin', 'base', 'ez-pluginregistry']
path: "%ez_platformui.public_dir%/js/apps/plugins/ez-universaldiscoveryplugin.js"
ez-contentcreatorplugin:
requires: ['plugin', 'base', 'ez-pluginregistry']
path: "%ez_platformui.public_dir%/js/apps/plugins/ez-contentcreatorplugin.js"
ez-domstateplugin:
requires: ['plugin', 'base', 'node', 'ez-pluginregistry']
path: "%ez_platformui.public_dir%/js/apps/plugins/ez-domstateplugin.js"
Expand Down
22 changes: 22 additions & 0 deletions Resources/public/css/theme/views/contentcreator.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Copyright (C) eZ Systems AS. All rights reserved.
* For full copyright and license information view LICENSE file distributed with this source code.
*/

.is-contentcreator-hidden .ez-contentcreator-container {
display: block;

background: rgba(0, 0, 0, 0);
transform: translateY(-100%);
}

.ez-contentcreator-container {
background: rgba(0, 0, 0, 0.6);

transform: translateY(0);
transition: transform 0.3s, background 0.3s;
}

.ez-contentcreator-container .ez-view-contentcreatorview {
background: #f3f3f3;
}
20 changes: 20 additions & 0 deletions Resources/public/css/views/contentcreator.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Copyright (C) eZ Systems AS. All rights reserved.
* For full copyright and license information view LICENSE file distributed with this source code.
*/

.ez-contentcreator-container {
position: fixed;
width: 100%;
height: 100%;
box-sizing: border-box;
padding: 0 0 0 4%;
top: 0;
left: 0;
z-index: 20000;
}

.is-contentcreator-hidden .ez-contentcreator-container {
display: none;
z-index: -10;
}
16 changes: 16 additions & 0 deletions Resources/public/js/apps/ez-platformuiapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ YUI.add('ez-platformuiapp', function (Y) {
* rendered view
* * `hideClass`: a class to add on the application container to hide
* the rendered side view when it's not needed.
* * `service`: a reference to the constructor of a view service
* * [`destroyUnusedView=false`]: a boolean flag. If true, the view
* will be destroyed when the view is not used anymore. As a result,
* when this flag is positionned, the view is recreated and
* rerendered everytime it is used.
*
* The lifecycle of the side views is handled by the `handleSideViews`
* method based on the meta information available in the route.
Expand Down Expand Up @@ -84,6 +89,13 @@ YUI.add('ez-platformuiapp', function (Y) {
container: '.ez-contentcreationwizard-container',
hideClass: 'is-contentcreationwizard-hidden',
},
contentCreator: {
type: Y.eZ.ContentCreatorView,
service: Y.eZ.ContentCreatorViewService,
container: '.ez-contentcreator-container',
hideClass: 'is-contentcreator-hidden',
destroyUnusedView: true,
},
},

views: {
Expand Down Expand Up @@ -651,6 +663,10 @@ YUI.add('ez-platformuiapp', function (Y) {
view = viewInfo.instance;
view.set('active', false);
viewInfo.serviceInstance.removeTarget(this);
if ( viewInfo.destroyUnusedView ) {
view.destroy({remove: true});
delete viewInfo.instance;
}
}
},

Expand Down
50 changes: 50 additions & 0 deletions Resources/public/js/apps/plugins/ez-contentcreatorplugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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-contentcreatorplugin', function (Y) {
"use strict";
/**
* Provides the universal discovery plugin
*
* @module ez-universaldiscoveryplugin
*/
Y.namespace('eZ.Plugin');

/**
* Universal discovery plugin. It connects the PlatformUI app and the
* universal discovery widget by setting the event handlers for the
* `contentDiscover`, `contentDiscovered` and `cancelDiscover` events.
* By triggering those events, any component can control the universal
* discovery widget.
*
* @namespace eZ.Plugin
* @class DiscoveryWidget
* @constructor
* @extends Plugin.Base
*/
Y.eZ.Plugin.ContentCreator = Y.Base.create('contentCreatorPlugin', Y.Plugin.Base, [], {
initializer: function () {
var app = this.get('host');

app.on('*:contentCreatorOpen', function (e) {
var config = Y.merge(e.config);

config.languageCode = app.get('contentCreationDefaultLanguageCode');
app.showSideView('contentCreator', config);
//app.set('routingEnabled', false);
});

app.on(['*:contentCreatorDone', '*:contentCreatorCancelled'], function () {
//app.set('routingEnabled', true);
app.hideSideView('contentCreator');
});
},
}, {
NS: 'contentCreator',
});

Y.eZ.PluginRegistry.registerPlugin(
Y.eZ.Plugin.ContentCreator, ['platformuiApp']
);
});
17 changes: 15 additions & 2 deletions Resources/public/js/extensions/ez-asynchronousview.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ YUI.add('ez-asynchronousview', function (Y) {
* @default this.render
*/

/**
* Holds the attribute name which change event triggers the asynchronous
* process.
*
* @property _triggerAttribute
* @type String
* @protected
* @default 'active'
*/

/**
* Holds the attribute name which stores the data needed to render the
* view. If provided, the asynchronous view will subscribe to the
Expand All @@ -67,9 +77,12 @@ YUI.add('ez-asynchronousview', function (Y) {
if ( !this._errorHandlingMethod ) {
this._errorHandlingMethod = this.render;
}
if ( !this._triggerAttribute ) {
this._triggerAttribute = 'active';
}

this.after('activeChange', function (e) {
if ( this.get('active') ) {
this.after(this._triggerAttribute + 'Change', function (e) {
if ( this.get(this._triggerAttribute) ) {
this._fireMethod(e);
}
});
Expand Down
4 changes: 2 additions & 2 deletions Resources/public/js/models/ez-contenttypegroupmodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ YUI.add('ez-contenttypegroupmodel', function (Y) {
if ( this.get('contentTypes') ) {
return callback();
}
typeService.loadContentTypes(this.get('id'), function (error, response) {
typeService.loadContentTypes(this.get('id'), 'application/vnd.ez.api.ContentTypeList+json', function (error, response) {
var types = [];

if ( error ) {
return callback(error);
}
Y.Array.each(response.document.ContentTypeInfoList.ContentType, function (typeHash) {
Y.Array.each(response.document.ContentTypeList.ContentType, function (typeHash) {
var type = new Y.eZ.ContentType();

type.set('id', typeHash._href);
Expand Down
34 changes: 34 additions & 0 deletions Resources/public/js/models/ez-contenttypemodel.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,40 @@ YUI.add('ez-contenttypemodel', function (Y) {
belongTo: function (contentTypeGroupId) {
return this.get('contentTypeGroupIds').indexOf(contentTypeGroupId) !== -1;
},

/**
* Returns a hash representing the fields with the default values for a
* Content of this type.
*
* @method getDefaultFields
* @return {Object}
*/
getDefaultFields: function () {
var defaultFields = {};

Y.Object.each(this.get('fieldDefinitions'), function (fieldDef, identifier) {
defaultFields[identifier] = {
fieldDefinitionIdentifier: identifier,
fieldValue: fieldDef.defaultValue,
};
});
return defaultFields;
},

/**
* Returns the name of the Content Type in the given `languageCode`, if
* the name in this languageCode does not exist, it returns the first
* available name.
*
* @method getName
* @param {String} languageCode
* @return {String}
*/
getName: function (languageCode) {
var names = this.get('names');

return names[languageCode] || names[Object.keys(names)[0]];
},
}, {
REST_STRUCT_ROOT: 'ContentType',
ATTRS_REST_MAP: [
Expand Down
29 changes: 16 additions & 13 deletions Resources/public/js/views/ez-contentcreationwizardview.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ YUI.add('ez-contentcreationwizardview', function (Y) {
/**
* Provides the content creation wizard view class
*
* @method ez-contentcreationwizardview
* @module ez-contentcreationwizardview
*/

var SELECTED_TYPE_EVT = 'selectedContentType',
Expand Down Expand Up @@ -52,7 +52,7 @@ YUI.add('ez-contentcreationwizardview', function (Y) {
this.after('stepChange', this._uiSetStep);
this.after('activeChange', function (e) {
if ( !this.get('active') ) {
this._resetState();
this.reset();
} else {
this._set('step', STEP_CONTENTTYPE);
this._renderContentTypeSelector();
Expand Down Expand Up @@ -295,17 +295,20 @@ YUI.add('ez-contentcreationwizardview', function (Y) {
);
},

/**
* Resets the state of the view to make it ready for a new run.
*
* @method _resetState
* @protected
*/
_resetState: function () {
this._set('step', undefined);
this._set('selectedContentType', null);
this._set('selectedParentLocation', null);
this.reset('contentTypeGroups');
reset: function (name) {
if ( name === 'contentTypeSelectorView' ) {
this.get('contentTypeSelectorView').reset();
return;
}
if ( name === 'step' ) {
this._set('step', undefined);
return;
}
if ( name === 'selectedContentType' || name === 'selectedParentLocation' ) {
this._set(name, null);
return;
}
this.constructor.superclass.reset.apply(this, arguments);
},
}, {
ATTRS: {
Expand Down
Loading