1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-05 05:25:27 +02:00

add section empty state

This commit is contained in:
Harvey Kandola 2017-03-04 16:54:04 +00:00
parent a7ac034d2c
commit 8d2dcf376f
12 changed files with 80 additions and 248 deletions

View file

@ -21,7 +21,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
didReceiveAttrs() {
let toEdit = this.get('toEdit');
if (toEdit === this.get('page.id')) {
if (toEdit === this.get('page.id') && this.get('isEditor')) {
this.send('onEdit');
}
},

View file

@ -22,7 +22,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
sectionService: Ember.inject.service('section'),
appMeta: Ember.inject.service(),
link: Ember.inject.service(),
hasPages: computed.notEmpty('pages'),
newSectionName: '',
newSectionNameMissing: computed.empty('newSectionName'),
newSectionLocation: '',
@ -38,6 +38,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
this.set('blocks', blocks);
this.set('hasBlocks', blocks.get('length') > 0);
// to test
blocks.forEach((b) => {
b.set('deleteId', `delete-block-button-${b.id}`);
});
@ -54,12 +55,12 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
},
didInsertElement() {
$(".start-section").hoverIntent({interval: 100, over: function() {
$(".start-section:not(.start-section-empty-state)").hoverIntent({interval: 100, over: function() {
// in
$(this).find('.start-button').css("display", "block").removeClass('fadeOut').addClass('fadeIn');
$(this).find('.start-button').velocity("transition.slideDownIn", {duration: 300});
}, out: function() {
//out
$(this).find('.start-button').css("display", "none").removeClass('fadeIn').addClass('fadeOut');
// out
$(this).find('.start-button').velocity("transition.slideUpOut", {duration: 300});
} });
},
@ -109,12 +110,15 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
if (is.not.null(beforePage)) {
// get any page before the beforePage so we can insert this new section between them
let index = _.findIndex(this.get('pages'), function(p) { return p.get('id') === beforePage.get('id'); });
let beforeBeforePage = this.get('pages')[index-1];
if (is.not.undefined(beforeBeforePage)) {
sequence = (beforePage.get('sequence') + beforeBeforePage.get('sequence')) / 2;
} else {
sequence = beforePage.get('sequence') / 2;
if (index !== -1) {
let beforeBeforePage = this.get('pages')[index-1];
if (is.not.undefined(beforeBeforePage)) {
sequence = (beforePage.get('sequence') + beforeBeforePage.get('sequence')) / 2;
} else {
sequence = beforePage.get('sequence') / 2;
}
}
}
@ -124,7 +128,7 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
const promise = this.get('onInsertSection')(model);
promise.then((id) => {
if (model.page.contentType === 'section') {
if (model.page.pageType === 'section') {
this.set('toEdit', id);
} else {
this.get('onEditSection')(id);
@ -154,17 +158,26 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
},
// Section wizard related
onShowSectionWizard(page) {
let beforePage = this.get('beforePage');
if (is.undefined(page)) {
page = { id: '0' };
}
let beforePage = this.get('beforePage');
if (is.not.null(beforePage) && $("#new-section-wizard").is(':visible') && beforePage.get('id') === page.id) {
this.send('onHideSectionWizard');
return;
}
this.set('newSectionLocation', page.id);
this.set('beforePage', page);
if (page.id === '0') {
// this handles add section at the end of the document
// because we are not before another page
this.set('beforePage', null);
} else {
this.set('beforePage', page);
}
$("#new-section-wizard").insertAfter(`#add-section-button-${page.id}`);
$("#new-section-wizard").velocity("transition.slideDownIn", {duration: 300, complete:
@ -250,7 +263,6 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, {
// to test
onDeleteBlock(id) {
this.attrs.onDeleteBlock(id);
},
}
}
});

View file

@ -1,67 +0,0 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
import Ember from 'ember';
import NotifierMixin from '../../mixins/notifier';
export default Ember.Component.extend(NotifierMixin, {
display: 'section', // which CSS to use
hasTemplates: false,
hasBlocks: false,
blockMode: false,
didReceiveAttrs() {
let blocks = this.get('blocks');
let blockMode = is.not.undefined(blocks);
this.set('blockMode', blockMode);
if (!blockMode) {
return;
}
this.set('hasBlocks', blocks.get('length') > 0);
blocks.forEach((b) => {
b.set('deleteId', `delete-block-button-${b.id}`);
});
},
didRender() {
let self = this;
Mousetrap.bind('esc', function () {
if (self.get('isDestroyed') || self.get('isDestroying')) {
return;
}
self.send('onCancel');
return false;
});
},
actions: {
onCancel() {
this.attrs.onCancel();
},
addSection(section) {
this.attrs.onAddSection(section);
},
onDeleteBlock(id) {
this.attrs.onDeleteBlock(id);
},
onInsertBlock(block) {
this.attrs.onInsertBlock(block);
}
}
});