Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#14 make the test suite green #22

Merged
merged 5 commits into from
Mar 27, 2019
Merged
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
5 changes: 4 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ version: 2
jobs:
build:
docker:
- image: circleci/node:lts-browsers
- image: circleci/node:8.10-browsers
environment:
JOBS: 2
parallelism: 1
working_directory: ~/repo
steps:
- checkout
Expand Down
22 changes: 19 additions & 3 deletions addon/components/printable-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { inject as service } from "@ember/service";
import { alias } from "@ember/object/computed";
import { next } from "@ember/runloop";
import { task } from "ember-concurrency";
import { Promise } from "rsvp";

export default Component.extend({
layout,
Expand All @@ -28,19 +29,34 @@ export default Component.extend({
// TASKS
renderStartTask: task(function*(currentPage) {
if (this.onRenderStart) {
next(() => this.onRenderStart(currentPage));
yield new Promise(resolve => {
next(() => {
this.onRenderStart(currentPage);
resolve();
});
});
}
}).keepLatest(),

renderProgressTask: task(function*() {
if (this.onRenderProgress) {
next(() => this.onRenderProgress(this.reportObject.lastPage));
yield new Promise(resolve => {
next(() => {
this.onRenderProgress(this.reportObject.lastPage);
resolve();
});
});
}
}).keepLatest(),

reportIfCompleteTask: task(function*() {
if (this.reportObject.isFinishedRendering && this.onRenderComplete) {
next(() => this.onRenderComplete(this.reportObject.lastPage));
yield new Promise(resolve => {
next(() => {
this.onRenderComplete(this.reportObject.lastPage);
resolve();
});
});
}
}).keepLatest(),

Expand Down
6 changes: 4 additions & 2 deletions addon/components/printable-pages/section.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Component from "@ember/component";
import layout from "../../templates/components/printable-pages/section";
import { getBy, array, sum, raw } from "ember-awesome-macros";
import { alias } from "@ember/object/computed";
import { htmlSafe } from "@ember/template";

export default Component.extend({
Expand All @@ -18,7 +17,10 @@ export default Component.extend({
this._super(...arguments);
if (!this.shouldRender) return;

let id = this.register({data: this.data || [], columnCount: this.columnCount});
let id = this.register({
data: this.data || [],
columnCount: this.columnCount
});
this.set("id", id);
},

Expand Down
2 changes: 1 addition & 1 deletion addon/services/document-data.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Service from "@ember/service";
import EmberObject, { computed } from "@ember/object";
import { A } from "@ember/array";
import { array, equal, raw, difference } from "ember-awesome-macros";
import { array, equal, difference } from "ember-awesome-macros";
import { alias } from "@ember/object/computed";
import { run } from "@ember/runloop";

Expand Down
10 changes: 5 additions & 5 deletions addon/templates/components/printable-pages.hbs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{{yield (hash
title-page=(component 'printable-pages/title-page'
title-page=(component "printable-pages/title-page"
pageLayout=this.pageLayout
pageCount=this.reportObject.lastPage
)
chapter=(component 'printable-pages/chapter'
chapter=(component "printable-pages/chapter"
chapters=this.chapters
lastReportPage=this.reportObject.lastPage
pageLayout=this.pageLayout
register=(action 'registerChapter')
registerSection=(action 'registerSection' this.elementId)
addPage=(action 'addPage')
register=(action "registerChapter")
registerSection=(action "registerSection" this.elementId)
addPage=(action "addPage")
checkIfComplete=(perform this.reportIfCompleteTask)
)
)}}
22 changes: 12 additions & 10 deletions addon/templates/components/printable-pages/chapter-page.hbs
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
{{yield (hash
block='header'
meta=@pageMeta
block="header"
meta=pageMeta
)}}

<div class='PrintablePages-pageBody js-page-body' style={{{this.bodyStyles}}}>
{{! template-lint-disable no-inline-styles }}
<div class="PrintablePages-pageBody js-page-body" style={{this.bodyStyles}}>
{{yield (hash
block='body'
block="body"
element=this.element
meta=@pageMeta
registerSection=(action 'registerSection')
onReadyForNextItem=(action 'onReadyForNextItem')
meta=pageMeta
registerSection=(action "registerSection")
onReadyForNextItem=(action "onReadyForNextItem")
)
}}

{{! element used to check if the content has overflowed page body}}
<div class='js-visibility-tail' style="height: 1px;"></div>
<div class="js-visibility-tail" style="height: 1px;"></div>
</div>
{{! template-lint-enable no-inline-styles }}

{{yield (hash
block='footer'
meta=@pageMeta
block="footer"
meta=pageMeta
)}}

<div class="js-page-break-after u-page-break-after"></div>
34 changes: 17 additions & 17 deletions addon/templates/components/printable-pages/chapter.hbs
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
{{#each this.pages as |page pageIndexInChapter|}}
{{#printable-pages/page-layout pageLayout=@pageLayout}}
{{#printable-pages/page-layout pageLayout=pageLayout}}
{{#printable-pages/chapter-page
pageIndexInChapter=pageIndexInChapter
pageMeta=(hash
current=(add this.startPage pageIndexInChapter)
chapterNumber=(inc this.chapter.index)
total=@lastReportPage
total=lastReportPage
isFirst=(eq page.number 1)
isFirstInChapter=(eq page.number this.startPage)
isLast=(eq page.number @lastReportPage)
isLast=(eq page.number lastReportPage)
isLastInChapter=(eq page.number this.endPage)
)

registerSection=(action this.registerSection this.elementId)
renderNextItem=(action 'renderNextItem' pageIndexInChapter)
onPageOverflow=(action 'onPageOverflow' pageIndexInChapter)
renderNextItem=(action "renderNextItem" pageIndexInChapter)
onPageOverflow=(action "onPageOverflow" pageIndexInChapter)
as |pageComponent|
}}
{{#if (eq pageComponent.block 'header')}}
{{#if (eq pageComponent.block "header")}}
{{yield (hash
page-header=(component 'printable-pages/page-header' pageMeta=pageComponent.meta)
section=(component 'printable-pages/section' shouldRender=false)
page-footer=(component 'printable-pages/page-footer' shouldRender=false)
page-header=(component "printable-pages/page-header" pageMeta=pageComponent.meta)
section=(component "printable-pages/section" shouldRender=false)
page-footer=(component "printable-pages/page-footer" shouldRender=false)
)}}
{{/if}}

{{#if (eq pageComponent.block 'body')}}
{{#if (eq pageComponent.block "body")}}
{{yield (hash
number=pageComponent.meta

page-header=(component 'printable-pages/page-header' shouldRender=false)
page-footer=(component 'printable-pages/page-footer' shouldRender=false)
page-header=(component "printable-pages/page-header" shouldRender=false)
page-footer=(component "printable-pages/page-footer" shouldRender=false)

section=(component 'printable-pages/section'
section=(component "printable-pages/section"
sectionMap=this.chapter.sectionMap
pageIndexInChapter=pageIndexInChapter
pageElement=pageComponent.element
Expand All @@ -43,11 +43,11 @@
)}}
{{/if}}

{{#if (eq pageComponent.block 'footer')}}
{{#if (eq pageComponent.block "footer")}}
{{yield (hash
page-header=(component 'printable-pages/page-header' shouldRender=false)
section=(component 'printable-pages/section' shouldRender=false)
page-footer=(component 'printable-pages/page-footer' pageMeta=pageComponent.meta)
page-header=(component "printable-pages/page-header" shouldRender=false)
section=(component "printable-pages/section" shouldRender=false)
page-footer=(component "printable-pages/page-footer" pageMeta=pageComponent.meta)
)}}
{{/if}}
{{/printable-pages/chapter-page}}
Expand Down
4 changes: 2 additions & 2 deletions addon/templates/components/printable-pages/page-footer.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#if shouldRender}}
<div class='PrintablePages-pageFooter'>
{{yield (hash pageMeta=@pageMeta)}}
<div class="PrintablePages-pageFooter">
{{yield (hash pageMeta=pageMeta)}}
</div>
{{/if}}
4 changes: 2 additions & 2 deletions addon/templates/components/printable-pages/page-header.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#if shouldRender}}
<div class='PrintablePages-pageHeader'>
{{yield (hash pageMeta=@pageMeta)}}
<div class="PrintablePages-pageHeader">
{{yield (hash pageMeta=pageMeta)}}
</div>
{{/if}}
2 changes: 2 additions & 0 deletions addon/templates/components/printable-pages/page-layout.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{! template-lint-disable no-inline-styles }}
<section class="PrintablePages-page" style={{pageStyles}}>
{{yield}}
</section>
{{! template-lint-enable no-inline-styles }}
4 changes: 3 additions & 1 deletion addon/templates/components/printable-pages/section.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{#if (and this.shouldRender this.page)}}
<div class='PrintablePages-section' style={{{this.style}}}>
{{! template-lint-disable no-inline-styles }}
<div class="PrintablePages-section" style={{this.style}}>
{{#each this.items as |item index|}}
{{#printable-pages/section-item section=this.section}}
{{yield (hash
Expand All @@ -9,4 +10,5 @@
{{/printable-pages/section-item}}
{{/each}}
</div>
{{! template-lint-enable no-inline-styles }}
{{/if}}
4 changes: 2 additions & 2 deletions addon/templates/components/printable-pages/title-page.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{{#printable-pages/page-layout pageLayout=@pageLayout}}
{{#printable-pages/page-layout pageLayout=pageLayout}}
<div class="PrintablePages-titlePage">
{{yield (hash
pageMeta=(hash
total=@pageCount
total=pageCount
)
)}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/controllers/demos/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default Controller.extend({
updateProgress(currentPage) {
this.set("currentPage", currentPage);
},
complete(currentPage) {
complete() {
this.set("renderTime", (new Date() - this.startTimeStamp) / 1000);
this.set("isRunning", false);
this.set("isComplete", true);
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/templates/components/app-topbar.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{#docs-header as |header|}}
{{#header.link 'demos'}}
{{#header.link "demos"}}
Demos
{{/header.link}}
{{/docs-header}}
6 changes: 3 additions & 3 deletions tests/dummy/app/templates/demos/default.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
}}

{{#printable-pages
onRenderStart=(action 'start')
onRenderProgress=(action 'updateProgress')
onRenderComplete=(action 'complete')
onRenderStart=(action "start")
onRenderProgress=(action "updateProgress")
onRenderComplete=(action "complete")
as |document|
}}
{{#document.chapter as |chapter|}}
Expand Down
6 changes: 3 additions & 3 deletions tests/dummy/app/templates/demos/page-layout.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
{{#if (eq layout this.pageSize)}}
<option selected value={{layout}}>{{layout}}</option>
{{else}}
<option value={{layout}}>{{layout}}</option>
{{/if}}
<option value={{layout}}>{{layout}}</option>
{{/if}}
{{/each}}
</select>
{{input type="text" value=this.marginSize}}
<input type='submit' value="Update" />
<input type="submit" value="Update">
</form>

{{#unless hidePages}}
Expand Down
8 changes: 4 additions & 4 deletions tests/dummy/app/templates/demos/title-page.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

{{#printable-pages as |document|}}

<!-- Document Title Page -->
{{! Document Title Page }}
{{#document.title-page as |titlePage|}}
<div style="text-align:center;">As of March 2019</div>
<div>As of March 2019</div>
<div class="TitlePage-hero">
<h1>This is the document title page</h1>
</div>
<div style="text-align:center;">
<div>
©2019 Forge 512, LLC | {{titlePage.pageMeta.total}}
</div>
{{/document.title-page}}

<!-- Chapters -->
{{! Chapters }}
{{#document.chapter as |chapter|}}
{{#chapter.page-header as |header|}}
<div>
Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/app/templates/docs.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

{{#docs-viewer as |viewer|}}
{{#viewer.nav as |nav|}}
{{nav.item 'Introduction' 'docs.index'}}
{{nav.item 'Example' 'docs.example'}}
{{nav.item "Introduction" "docs.index"}}
{{nav.item "Example" "docs.example"}}
{{/viewer.nav}}

{{#viewer.main}}
Expand Down
10 changes: 5 additions & 5 deletions tests/dummy/app/templates/index.hbs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{{app-topbar}}

{{docs-hero
logo='ember'
slimHeading='My'
strongHeading='Addon'
byline='My addon demo/marketing page.'}}
logo="ember"
slimHeading="My"
strongHeading="Addon"
byline="My addon demo/marketing page."}}

{{#docs-demo as |demo|}}
{{#demo.example name='my-demo.hbs'}}
{{#demo.example name="my-demo.hbs"}}
<p>Make sure to read up on the DocsDemo component before building out this page.</p>
{{/demo.example}}
{{/docs-demo}}
2 changes: 1 addition & 1 deletion tests/dummy/app/templates/not-found.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{#viewer.main}}
<div class="docs-container">
<h1>Not found</h1>
<p>This page doesn't exist. {{#link-to 'index'}}Head home?{{/link-to}}</p>
<p>This page doesn't exist. {{#link-to "index"}}Head home?{{/link-to}}</p>
</div>
{{/viewer.main}}
{{/docs-viewer}}
Loading