Skip to content

Commit

Permalink
Merge pull request #6 from dew326/ezs-703-create-content-from-dashboard
Browse files Browse the repository at this point in the history
EZS-703: As a user, I want to create content from the Dashboard
  • Loading branch information
lserwatka authored Jun 21, 2016
2 parents 3c99039 + b0717b6 commit 2e88c17
Show file tree
Hide file tree
Showing 17 changed files with 456 additions and 20 deletions.
4 changes: 4 additions & 0 deletions bundle/Resources/config/css.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ system:
- '@ContentOnTheFlyBundle/Resources/public/css/views/content-creation.css'
- '@ContentOnTheFlyBundle/Resources/public/css/views/discovery-create.css'
- '@ContentOnTheFlyBundle/Resources/public/css/views/content-type.css'
- '@ContentOnTheFlyBundle/Resources/public/css/views/create-content-button.css'
- '@ContentOnTheFlyBundle/Resources/public/css/views/create-content-popup.css'
- '@ContentOnTheFlyBundle/Resources/public/css/theme/views/content-creation.css'
- '@ContentOnTheFlyBundle/Resources/public/css/theme/views/discovery-create.css'
- '@ContentOnTheFlyBundle/Resources/public/css/theme/views/content-type.css'
- '@ContentOnTheFlyBundle/Resources/public/css/theme/views/discovery-create.css'
- '@ContentOnTheFlyBundle/Resources/public/css/theme/views/create-content-popup.css'
29 changes: 27 additions & 2 deletions bundle/Resources/config/yui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@ system:
- 'ez-contentcreateplugin'
- 'ez-pluginregistry'
- 'ez-viewservicebaseplugin'
dependencyOf: ['ez-universaldiscoveryviewservice']
dependencyOf: ['ez-universaldiscoveryviewservice', ez-dashboardblocksviewservice]
path: %ezcontentonthefly.public_dir%/js/views/plugins/cof-createcontent-universaldiscoveryserviceplugin.js
cof-selectcontenttypeplugin:
requires: ['ez-contentcreateplugin', 'ez-locationmodel']
dependencyOf: ['ez-universaldiscoveryviewservice']
dependencyOf: ['ez-universaldiscoveryviewservice', 'ez-dashboardblocksviewservice']
path: %ezcontentonthefly.public_dir%/js/views/plugins/cof-selectcontenttypeplugin.js
cof-createcontent-dashboardblocksplugin:
requires:
- 'plugin'
- 'ez-pluginregistry'
- 'cof-createcontentbuttonview'
dependencyOf: ['ez-dashboardblocksview']
path: %ezcontentonthefly.public_dir%/js/views/plugins/cof-createcontent-dashboardblocksplugin.js
cof-universaldiscoverycreateview:
requires:
- 'ez-universaldiscoverymethodbaseview'
Expand Down Expand Up @@ -55,3 +62,21 @@ system:
contenttypeselectorview-ez-template:
type: 'template'
path: %ez_platformui.public_dir%/templates/contenttypeselector.hbt
cof-createcontentbuttonview:
requires:
- 'ez-templatebasedview'
- 'cof-createcontentpopupview'
- 'createcontentbuttonview-ez-template'
path: %ezcontentonthefly.public_dir%/js/views/cof-createcontentbuttonview.js
createcontentbuttonview-ez-template:
type: 'template'
path: %ezcontentonthefly.public_dir%/templates/create-content-button.hbt
cof-createcontentpopupview:
requires:
- 'ez-templatebasedview'
- 'cof-contentcreationview'
- 'createcontentpopupview-ez-template'
path: %ezcontentonthefly.public_dir%/js/views/cof-createcontentpopupview.js
createcontentpopupview-ez-template:
type: 'template'
path: %ezcontentonthefly.public_dir%/templates/create-content-popup.hbt
43 changes: 43 additions & 0 deletions bundle/Resources/public/css/modules/buttons.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,46 @@
background: #bbb;
cursor: not-allowed;
}

.cof-btn.cof-btn--create {
text-transform: uppercase;
color: #fff;
font-size: .875rem;
font-weight: 700;
background: #3FB499;
padding: .7rem 2rem .7rem 2.6rem;
position: relative;
}

.cof-btn--create:before {
color: #fff;
font-family: "ez-platformui-icomoon";
content: "\E61D";
position: absolute;
top: 50%;
left: 1rem;
transform: translateY(-50%);
}

.cof-btn--close {
background: none;
}

.cof-btn--close:before,
.cof-btn--close:after {
content: '';
width: 1px;
height: 100%;
background: #aaa;
position: absolute;
top: 50%;
left: 50%;
}

.cof-btn--close:before {
transform: translate(-50%, -50%) rotate(45deg);
}

.cof-btn--close:after {
transform: translate(-50%, -50%) rotate(-45deg);
}
17 changes: 17 additions & 0 deletions bundle/Resources/public/css/theme/views/create-content-popup.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright (C) eZ Systems AS. All rights reserved.
* For full copyright and license information view LICENSE file distributed with this source code.
*/

.ez-view-createcontentpopupview {
background: rgba(0, 0, 0, .6);
}

.ez-view-createcontentpopupview .cof-create-popup {
background: #d8d8d8;
border-radius: .5rem;
}

.ez-view-createcontentpopupview .cof-content-creation__tooltip:before {
border-color: transparent #bbb transparent transparent;
}
1 change: 0 additions & 1 deletion bundle/Resources/public/css/views/content-type.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
.ez-view-contenttypeselectorview .cof-content-creation__tooltip {
width: 15rem;
position: fixed;
left: 28rem;
padding: 1rem;
transform: translateY(-50%);
}
10 changes: 10 additions & 0 deletions bundle/Resources/public/css/views/create-content-button.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Copyright (C) eZ Systems AS. All rights reserved.
* For full copyright and license information view LICENSE file distributed with this source code.
*/

.ez-view-createcontentbuttonview {
position: absolute;
top: 2vh;
right: 6rem;
}
35 changes: 35 additions & 0 deletions bundle/Resources/public/css/views/create-content-popup.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Copyright (C) eZ Systems AS. All rights reserved.
* For full copyright and license information view LICENSE file distributed with this source code.
*/

.ez-view-createcontentpopupview {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 300;
}

.ez-view-createcontentpopupview .ez-view-contentcreationview {
height: 40rem;
}

.ez-view-createcontentpopupview .cof-create-popup {
position: absolute;
top: 3rem;
left: calc(50% - 12.5rem);
}

.ez-view-createcontentpopupview .cof-btn--close {
position: absolute;
z-index: 2;
top: 2rem;
right: 2rem;
height: 2rem;
width: 2rem;
border: 0 none;
padding: 0;
overflow: hidden;
}
16 changes: 10 additions & 6 deletions bundle/Resources/public/css/views/general.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
* For full copyright and license information view LICENSE file distributed with this source code.
*/

.cof-is-hidden {
display: none !important;
}
.cof-is-hidden {
display: none !important;
}

.cof-invisible {
opacity: 0 !important;
}
.cof-invisible {
opacity: 0 !important;
}

.cof-index-reset {
z-index: auto !important;
}
36 changes: 36 additions & 0 deletions bundle/Resources/public/js/views/cof-contentcreationview.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,20 @@ YUI.add('cof-contentcreationview', function (Y) {
return;
}

if (this.get('redirectionPrevented')) {
/**
* Fired to create a new content of a given type
*
* @event createContent
* @param contentType {eZ.ContentType} content type
*/
this.fire('createContent', {
contentType: contentTypeSelector.get('selectedContentType')
});

return;
}

createContentView = new CreateContentConstructor({
content: contentTypeSelector.get('content'),
version: contentTypeSelector.get('version'),
Expand Down Expand Up @@ -569,6 +583,28 @@ YUI.add('cof-contentcreationview', function (Y) {
suggestedItemTemplate: {
value: '<li class="' + CLASS_SUGGESTED_LOCATIONS_ITEM + '" data-id="<%= data.id %>"><abbr title=" <%= data.path %> "><%= data.path %></abbr></li>'
},

/**
* Should prevent from closing discovery widget?
*
* @attribute closingDiscoveryWidgetPrevented
* @type Boolean
* @default true
*/
closingDiscoveryWidgetPrevented: {
value: true
},

/**
* Should redirect to create content?
*
* @attribute redirectionPrevented
* @type Boolean
* @default false
*/
redirectionPrevented: {
value: false
},
}
});
});
17 changes: 10 additions & 7 deletions bundle/Resources/public/js/views/cof-contenttypeselectorview.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ YUI.add('cof-contenttypeselectorview', function (Y) {
SELECTOR_TOOLTIP = '.cof-content-creation__tooltip',
ATTR_ID = 'data-id',
ATTR_DESCRIPTION = 'data-description',
PX = 'px',
SCROLL_TIMEOUT = 100;

/**
Expand Down Expand Up @@ -78,6 +79,8 @@ YUI.add('cof-contenttypeselectorview', function (Y) {
* @param text {String} text to show on remove button
*/
this.fire('itemSelected', {text: event.text});

this._correctTooltipPosition();
},

/**
Expand All @@ -89,7 +92,6 @@ YUI.add('cof-contenttypeselectorview', function (Y) {
this._toggleTooltip(true);

this._setCorrectTooltipPositionOnScroll();
this._correctTooltipPosition();
},

/**
Expand Down Expand Up @@ -154,22 +156,23 @@ YUI.add('cof-contenttypeselectorview', function (Y) {
_correctTooltipPosition: function () {
var container = this.get('container'),
selectedItem = container.one(SELECTOR_ITEM_SELECTED),
selectedItemRect,
contentTypeListRect = container.one(SELECTOR_CONTENT_TYPE_LIST).getDOMNode().getBoundingClientRect(),
contentTypeListRectTop = contentTypeListRect.top,
tooltip = container.one(SELECTOR_TOOLTIP),
selectedItemRectTop;
tooltipSpace = 40,
tooltip = container.one(SELECTOR_TOOLTIP);

if (!selectedItem) {
return;
}

selectedItemRectTop = selectedItem.getDOMNode().getBoundingClientRect().top;
selectedItemRect = selectedItem.getDOMNode().getBoundingClientRect();

if (selectedItemRectTop < contentTypeListRectTop || selectedItemRectTop > contentTypeListRectTop + contentTypeListRect.height) {
if (selectedItemRect.top < contentTypeListRect.top || selectedItemRect.top > contentTypeListRect.top + contentTypeListRect.height) {
tooltip.addClass(CLASS_INVISIBLE);
} else {
tooltip.removeClass(CLASS_INVISIBLE);
tooltip.setStyle('top', selectedItemRectTop);
tooltip.setStyle('top', selectedItemRect.top + PX);
tooltip.setStyle('left', selectedItemRect.left + selectedItemRect.width + tooltipSpace + PX);
}
},

Expand Down
69 changes: 69 additions & 0 deletions bundle/Resources/public/js/views/cof-createcontentbuttonview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright (C) eZ Systems AS. All rights reserved.
* For full copyright and license information view LICENSE file distributed with this source code.
*/
YUI.add('cof-createcontentbuttonview', function (Y) {
'use strict';

/**
* Provides the Create Action view class
*
* @module cof-createcontentbuttonview
*/
Y.namespace('cof');

var SELECTOR_BTN_CREATE = '.cof-btn--create',
EVENTS = {};

EVENTS[SELECTOR_BTN_CREATE] = {'tap': '_showPopup'};

/**
* The Create Content Button View
*
* @namespace cof
* @class createContentButtonView
* @constructor
* @extends eZ.TemplateBasedView
*/
Y.cof.CreateContentButtonView = Y.Base.create('createContentButtonView', Y.eZ.TemplateBasedView, [], {
events: EVENTS,

initializer: function () {
this.get('createContentPopupView').on('displayedChange', this._toggleOverlay, this);
},

render: function () {
this.get('container')
.setHTML(this.template())
.append(this.get('createContentPopupView').render().get('container'));

return this;
},

/**
* Shows the create content popup
*
* @protected
* @method _showPopup
*/
_showPopup: function () {
this.get('createContentPopupView').set('displayed', true);
},
}, {
ATTRS: {
/**
* The create content popup view instance
*
* @attribute createContentPopupView
* @type cof.CreateContentPopupView
*/
createContentPopupView: {
valueFn: function () {
return new Y.cof.CreateContentPopupView({
bubbleTargets: this
});
}
},
}
});
});
Loading

0 comments on commit 2e88c17

Please sign in to comment.