diff --git a/app/app/components/document/document-sidebar.js b/app/app/components/document/document-sidebar.js index 3da1ee56..c91de379 100644 --- a/app/app/components/document/document-sidebar.js +++ b/app/app/components/document/document-sidebar.js @@ -10,10 +10,28 @@ // https://documize.com import Ember from 'ember'; +import models from '../../utils/model'; +import TooltipMixin from '../../mixins/tooltip'; + +export default Ember.Component.extend(TooltipMixin, { + sectionService: Ember.inject.service('section'), + documentService: Ember.inject.service('document'), -export default Ember.Component.extend({ document: {}, folder: {}, + sections: [], + showToc: true, + showSectionList: false, + + // didRender() { + // if (this.get('isEditor')) { + // this.addTooltip(document.getElementById("add-section-button")); + // } + // }, + + // willDestroyElement() { + // this.destroyTooltips(); + // }, actions: { // Page up - above pages shunt down. @@ -21,7 +39,7 @@ export default Ember.Component.extend({ this.attrs.changePageSequence(pendingChanges); }, - // Move down -- pages below shift up. + // Move down - pages below shift up. onPageLevelChange(pendingChanges) { this.attrs.changePageLevel(pendingChanges); }, @@ -29,5 +47,47 @@ export default Ember.Component.extend({ 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); + } } }); \ No newline at end of file diff --git a/app/app/components/document/document-toolbar.js b/app/app/components/document/document-toolbar.js index 077bde0f..5caf1462 100644 --- a/app/app/components/document/document-toolbar.js +++ b/app/app/components/document/document-toolbar.js @@ -24,7 +24,6 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { didRender() { if (this.get('isEditor')) { - this.addTooltip(document.getElementById("add-section-button")); this.addTooltip(document.getElementById("attachment-button")); this.addTooltip(document.getElementById("save-template-button")); this.addTooltip(document.getElementById("set-meta-button")); diff --git a/app/app/components/document/page-wizard.js b/app/app/components/document/page-wizard.js index 6faca932..15467b08 100644 --- a/app/app/components/document/page-wizard.js +++ b/app/app/components/document/page-wizard.js @@ -13,55 +13,15 @@ import Ember from 'ember'; import NotifierMixin from '../../mixins/notifier'; export default Ember.Component.extend(NotifierMixin, { - title: "New Section", - contentType: "", - - didReceiveAttrs() { - let section = this.get("sections").get('firstObject'); - section.set("selected", true); - }, - - didInsertElement() { - $("#page-title").removeClass("error").focus(); - }, - actions: { - setOption(id) { - let sections = this.get("sections"); - - sections.forEach(function(option) { - Ember.set(option, 'selected', option.id === id); - }); - - this.set("sections", sections); - - // if (this.session.get('popupBlocked')) { - // this.showNotification("Hmm, looks like your browser is blocking popups..."); - // } - }, - - onCancel() { - this.attrs.onCancel(); - }, - - onAction() { - let title = this.get("title"); - let section = this.get("sections").findBy("selected", true); - let contentType = section.contentType; + addSection(section) { if (section.preview) { this.showNotification("Coming soon!"); return; } - if (is.empty(title)) { - $("#page-title").addClass("error").focus(); - return; - } - - this.audit.record('added section ' + section.contentType); - - this.attrs.onAction(title, contentType); + this.attrs.onAction(section); } } }); \ No newline at end of file diff --git a/app/app/pods/document/index/controller.js b/app/app/pods/document/index/controller.js index f6d0c84f..04b86079 100644 --- a/app/app/pods/document/index/controller.js +++ b/app/app/pods/document/index/controller.js @@ -175,6 +175,19 @@ export default Ember.Controller.extend(NotifierMixin, { this.get('documentService').save(doc).then(function() { self.set('model', doc); }); + }, + + onAddPage(page) { + let self = this; + + this.get('documentService').addPage(this.get('model.id'), page).then(function(newPage) { + self.transitionToRoute('document.edit', + self.get('folder.id'), + self.get('folder.slug'), + self.get('model.id'), + self.get('model.slug'), + newPage.id); + }); } } }); \ No newline at end of file diff --git a/app/app/pods/document/index/template.hbs b/app/app/pods/document/index/template.hbs index 23c3ee58..00596de4 100644 --- a/app/app/pods/document/index/template.hbs +++ b/app/app/pods/document/index/template.hbs @@ -8,7 +8,7 @@
- {{document/document-sidebar document=model meta=meta folder=folder pages=pages page=page isEditor=isEditor changePageSequence=(action 'onPageSequenceChange') changePageLevel=(action 'onPageLevelChange') gotoPage=(action 'gotoPage')}} + {{document/document-sidebar document=model meta=meta folder=folder pages=pages page=page isEditor=isEditor onAddPage=(action 'onAddPage') changePageSequence=(action 'onPageSequenceChange') changePageLevel=(action 'onPageLevelChange') gotoPage=(action 'gotoPage')}}
{{document/document-view document=model pages=pages attachments=attachments folder=folder folders=folders isEditor=isEditor onAttachmentDeleted=(action 'onAttachmentDeleted') onDeletePage=(action 'onPageDeleted')}} diff --git a/app/app/styles/view/document/wizard.scss b/app/app/styles/view/document/wizard.scss index 015ea1af..322e4ced 100644 --- a/app/app/styles/view/document/wizard.scss +++ b/app/app/styles/view/document/wizard.scss @@ -1,76 +1,55 @@ -.page-wizard { - > .toolbar { - @extend .z-depth-tiny; - background-color: $color-white; - width: 100%; - padding: 20px 40px; - - > .title { - width: 50%; - - > .input-control { - margin: 0; - - > input { - margin: 0 0 5px 0; - } - } - } - - > .buttons { - margin-top: 10px; - } - } - +.section-wizard { > .canvas { - padding: 40px 40px; - + padding: 0; + margin: 0; + > .list { margin: 0; padding: 0; > .item { list-style: none; - float: left; cursor: pointer; - width: 400px; - height: 80px; - background-color: $color-white; - border: 1px solid $color-border2; + width: 100%; + border: 1px solid transparent; border-radius: 3px; - margin: 0 30px 30px 0; + margin: 0 0 20px 0; + padding: 10px; &:hover { - @extend .z-depth-half; background-color: $color-card-active; - border-color: $color-card-active; + border: 1px solid $color-border2; transition: 0.2s all ease; } - > .img { + .icon { text-align: center; - margin: 17px 10px 0 20px; - display: inline-block; - height: 45px; - width: 45px; + + > .img { + // margin: 17px 10px 0 20px; + display: block; + height: 45px; + width: 45px; + } } + > .details { - vertical-align: top; - display: inline-block; + display: block; + margin-top: 10px; > .title { font-size: 1rem; font-weight: bold; color: $color-off-black; - margin-top: 18px; + // margin-top: 18px; + margin-right: 10px; letter-spacing: 0.5px; .preview { font-size: 0.7rem; color: #cc9933; display: inline-block; - margin-left: 10px; } } @@ -78,18 +57,10 @@ color: $color-stroke; font-size: 0.8rem; margin-top: 5px; - max-width: 300px; - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; + width: 100%; } } } - - > .selected { - background-color: $color-card-active; - border: 1px dotted $color-link; - } } } } diff --git a/app/app/templates/components/document/document-sidebar.hbs b/app/app/templates/components/document/document-sidebar.hbs index 0a5a3af0..3e3276a6 100644 --- a/app/app/templates/components/document/document-sidebar.hbs +++ b/app/app/templates/components/document/document-sidebar.hbs @@ -1,7 +1,27 @@
diff --git a/app/app/templates/components/document/document-toolbar.hbs b/app/app/templates/components/document/document-toolbar.hbs index 469b8f69..5ae70459 100644 --- a/app/app/templates/components/document/document-toolbar.hbs +++ b/app/app/templates/components/document/document-toolbar.hbs @@ -39,12 +39,6 @@