1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-08 06:55:28 +02:00

v12.5 revised add smart section UX

This commit is contained in:
Harvey Kandola 2016-06-12 13:43:23 +01:00
parent 236aa2c7ad
commit 4186117b54
8 changed files with 60 additions and 101 deletions

View file

@ -10,28 +10,13 @@
// https://documize.com // https://documize.com
import Ember from 'ember'; import Ember from 'ember';
import models from '../../utils/model';
import TooltipMixin from '../../mixins/tooltip'; import TooltipMixin from '../../mixins/tooltip';
export default Ember.Component.extend(TooltipMixin, { export default Ember.Component.extend(TooltipMixin, {
sectionService: Ember.inject.service('section'),
documentService: Ember.inject.service('document'), documentService: Ember.inject.service('document'),
document: {}, document: {},
folder: {}, folder: {},
sections: [],
showToc: true,
showSectionList: false,
// didRender() {
// if (this.get('isEditor')) {
// this.addTooltip(document.getElementById("add-section-button"));
// }
// },
// willDestroyElement() {
// this.destroyTooltips();
// },
actions: { actions: {
// Page up - above pages shunt down. // Page up - above pages shunt down.
@ -46,48 +31,6 @@ export default Ember.Component.extend(TooltipMixin, {
gotoPage(id) { gotoPage(id) {
return this.attrs.gotoPage(id); return this.attrs.gotoPage(id);
},
addSection() {
let self = this;
this.get('sectionService').getAll().then(function(sections) {
self.set('sections', sections);
self.set('showToc', false);
self.set('showSectionList', true);
});
},
showToc() {
this.set('showSectionList', false);
this.set('showToc', true);
},
onAddSection(section) {
this.audit.record("added-section");
this.audit.record("added-section-" + section.contentType);
let page = models.PageModel.create({
documentId: this.get('document.id'),
title: `${section.title} Section`,
level: 2,
sequence: 2048,
body: "",
contentType: section.contentType
});
let meta = models.PageMetaModel.create({
documentId: this.get('document.id'),
rawBody: "",
config: ""
});
let model = {
page: page,
meta: meta
};
this.attrs.onAddPage(model);
} }
} }
}); });

View file

@ -13,7 +13,20 @@ import Ember from 'ember';
import NotifierMixin from '../../mixins/notifier'; import NotifierMixin from '../../mixins/notifier';
export default Ember.Component.extend(NotifierMixin, { export default Ember.Component.extend(NotifierMixin, {
didRender() {
let self = this;
Mousetrap.bind('esc', function() {
self.send('onCancel');
return false;
});
},
actions: { actions: {
onCancel() {
this.attrs.onCancel();
},
addSection(section) { addSection(section) {
if (section.preview) { if (section.preview) {

View file

@ -10,18 +10,19 @@ export default Ember.Controller.extend(NotifierMixin, {
this.transitionToRoute('document'); this.transitionToRoute('document');
}, },
onAction(title, contentType) { onAddSection(section) {
this.audit.record("added-page"); let self = this;
let self = this; this.audit.record("added-section");
this.audit.record("added-section-" + section.contentType);
let page = models.PageModel.create({ let page = models.PageModel.create({
documentId: this.get('model.document.id'), documentId: this.get('model.document.id'),
title: title, title: `${section.title} Section`,
level: 2, level: 2,
sequence: 2048, sequence: 2048,
body: "", body: "",
contentType: contentType contentType: section.contentType
}); });
let meta = models.PageMetaModel.create({ let meta = models.PageMetaModel.create({

View file

@ -1 +1 @@
{{document/page-wizard document=model.document folder=model.folder sections=model.sections onCancel=(action 'onCancel') onAction=(action 'onAction')}} {{document/page-wizard document=model.document folder=model.folder sections=model.sections onCancel=(action 'onCancel') onAction=(action 'onAddSection')}}

View file

@ -1,7 +1,9 @@
.section-wizard { .section-wizard {
margin: 30px;
> .canvas { > .canvas {
padding: 0; padding: 0;
margin: 0; margin: 30px 0;
> .list { > .list {
margin: 0; margin: 0;
@ -9,12 +11,14 @@
> .item { > .item {
list-style: none; list-style: none;
float: left;
cursor: pointer; cursor: pointer;
width: 100%; width: 400px;
border: 1px solid transparent; height: 80px;
background-color: $color-white;
border: 1px solid $color-border2;
border-radius: 3px; border-radius: 3px;
margin: 0 0 20px 0; margin: 0 30px 30px 0;
padding: 10px;
&:hover { &:hover {
background-color: $color-card-active; background-color: $color-card-active;
@ -24,32 +28,33 @@
.icon { .icon {
text-align: center; text-align: center;
display: inline-block;
> .img { > .img {
// margin: 17px 10px 0 20px; text-align: center;
display: block; margin: 17px 10px 0 20px;
display: inline-block;
height: 45px; height: 45px;
width: 45px; width: 45px;
} }
} }
> .details { > .details {
display: block; vertical-align: top;
margin-top: 10px; display: inline-block;
> .title { > .title {
font-size: 1rem; font-size: 1rem;
font-weight: bold; font-weight: bold;
color: $color-off-black; color: $color-off-black;
// margin-top: 18px; margin-top: 18px;
margin-right: 10px;
letter-spacing: 0.5px; letter-spacing: 0.5px;
.preview { .preview {
font-size: 0.7rem; font-size: 0.7rem;
color: #cc9933; color: #cc9933;
display: inline-block; display: inline-block;
margin-left: 10px;
} }
} }
@ -57,7 +62,10 @@
color: $color-stroke; color: $color-stroke;
font-size: 0.8rem; font-size: 0.8rem;
margin-top: 5px; margin-top: 5px;
width: 100%; max-width: 300px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
} }
} }
} }

View file

@ -1,27 +1,17 @@
<div class="document-container"> <div class="document-container">
<div class="sidebar hidden-xs hidden-sm"> <div class="sidebar hidden-xs hidden-sm">
{{#if showToc}} {{#if isEditor}}
{{#if isEditor}} <div class="margin-bottom-20 text-center">
<div class="margin-bottom-20 text-center"> {{#link-to 'document.wizard' folder.id folder.slug document.id document.slug}}
<div {{action 'addSection'}} class="regular-button button-green" id="add-section-button" data-tooltip="Add section" data-tooltip-position="top center"> <div class="regular-button button-green" id="add-section-button">
<i class="material-icons">add</i> <i class="material-icons">add</i>
<div class="name">section</div> <div class="name">section</div>
</div> </div>
</div> {{/link-to}}
{{/if}}
{{document/document-sidebar-toc document=model folder=folder pages=pages page=page isEditor=isEditor
changePageSequence=(action 'onPageSequenceChange') changePageLevel=(action 'onPageLevelChange')
gotoPage=(action 'gotoPage')}}
{{/if}}
{{#if showSectionList}}
<div class="margin-bottom-20 pull-right">
<div {{action 'showToc'}} class="flat-button">
Cancel
</div>
</div> </div>
<div class="clearfix" />
{{document/page-wizard document=model folder=folder sections=sections onAction=(action 'onAddSection')}}
{{/if}} {{/if}}
{{document/document-sidebar-toc document=model folder=folder pages=pages page=page isEditor=isEditor
changePageSequence=(action 'onPageSequenceChange') changePageLevel=(action 'onPageLevelChange')
gotoPage=(action 'gotoPage')}}
</div> </div>
</div> </div>

View file

@ -1,4 +1,8 @@
<div class="section-wizard"> <div class="section-wizard">
<div class="buttons pull-right">
<div class="flat-button flat-gray" {{action 'onCancel'}}>Cancel</div>
</div>
<div class="clearfix"></div>
<div class="canvas"> <div class="canvas">
<ul class="list"> <ul class="list">
{{#each sections as |section|}} {{#each sections as |section|}}

View file

@ -30,7 +30,7 @@ const (
// AppVersion does what it says // AppVersion does what it says
// Versioning scheme major.minor where "minor" is optional // Versioning scheme major.minor where "minor" is optional
// e.g. 1, 2, 3, 4.1, 4.2, 5, 6, 7, 7.1, 8, 9, 10, ..... 127, 127.1, 128 // e.g. 1, 2, 3, 4.1, 4.2, 5, 6, 7, 7.1, 8, 9, 10, ..... 127, 127.1, 128
AppVersion = "12.4" AppVersion = "12.5"
) )
var port, certFile, keyFile, forcePort2SSL string var port, certFile, keyFile, forcePort2SSL string