-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(subscriptions): separate reports and orders view
This will introduce two tabs for Reports and Orders. Content remains the same.
- Loading branch information
Showing
15 changed files
with
281 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { inject as service } from "@ember/service"; | ||
import Component from "@glimmer/component"; | ||
|
||
export default class SubNavItemComponent extends Component { | ||
@service router; | ||
|
||
get isActive() { | ||
return this.router.currentRoute.name.includes(this.args.route); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<li class="uk-child-width-1-1 {{if this.isActive "uk-active"}}" ...attributes> | ||
<LinkTo @route={{@route}}> | ||
{{yield}} | ||
</LinkTo> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<ul class="uk-subnav uk-subnav-divider uk-subnav-pill uk-width-1 uk-child-width-1-{{@children}} uk-text-center uk-padding-small uk-padding-remove-horizontal"> | ||
{{yield}} | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import Controller from "@ember/controller"; | ||
import { get } from "@ember/object"; | ||
import { inject as service } from "@ember/service"; | ||
import { tracked } from "@glimmer/tracking"; | ||
import { task } from "ember-concurrency"; | ||
|
||
export default class SubscriptionsDetailIndexController extends Controller { | ||
@service account; | ||
@service intl; | ||
@service timed; | ||
|
||
@tracked project; | ||
@tracked reports; | ||
@tracked reportsNext; | ||
|
||
@task *fetchNextReports() { | ||
try { | ||
this.reportsPage++; | ||
const reports = yield this.timed.getProjectReports( | ||
this.project.id, | ||
this.reportsPage | ||
); | ||
this.reports.pushObjects(reports.toArray()); | ||
|
||
this.reportsNext = Boolean(get(reports, "links.next")); | ||
} catch (error) { | ||
console.error(error); | ||
this.reportsNext = false; | ||
} | ||
} | ||
|
||
setup(model, transition) { | ||
this.project = model.project; | ||
|
||
this.reports = model.reports.toArray(); | ||
this.reportsPage = 1; | ||
this.reportsNext = Boolean(get(model, "reports.links.next")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Route from "@ember/routing/route"; | ||
import { inject as service } from "@ember/service"; | ||
|
||
export default class SubscriptionsDetailIndexRoute extends Route { | ||
@service timed; | ||
|
||
model() { | ||
return this.modelFor("subscriptions.detail"); | ||
} | ||
|
||
setupController(controller, model) { | ||
super.setupController(...arguments); | ||
|
||
controller.setup(model); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<section class="section"> | ||
<div class="section__inner"> | ||
<div> | ||
{{#if this.reports.length}} | ||
<div class="table"> | ||
<table> | ||
<thead> | ||
<th>{{t "page.subscriptions.detail.reports.table.date"}}</th> | ||
<th>{{t "page.subscriptions.detail.reports.table.duration"}}</th> | ||
<th>{{t "page.subscriptions.detail.reports.table.user"}}</th> | ||
<th>{{t "page.subscriptions.detail.reports.table.comment"}}</th> | ||
</thead> | ||
<tbody> | ||
{{#each this.reports as |report|}} | ||
<tr> | ||
<td>{{moment-format report.date "DD.MM.YYYY"}}</td> | ||
<td>{{format-duration report.duration}}</td> | ||
<td>{{report.user.fullName}}</td> | ||
<td>{{report.comment}}</td> | ||
</tr> | ||
{{/each}} | ||
|
||
{{#if this.reportsNext}} | ||
<tr class="table__fetch-more"> | ||
<td colspan="4"> | ||
<button | ||
{{on "click" (perform this.fetchNextReports)}} | ||
type="button" | ||
class="button" | ||
disabled={{this.fetchNextReports.isRunning}} | ||
> | ||
{{~t "page.subscriptions.detail.reports.more"}} | ||
</button> | ||
</td> | ||
</tr> | ||
{{/if}} | ||
</tbody> | ||
</table> | ||
</div> | ||
{{else}} | ||
<p>{{t "page.subscriptions.detail.reports.empty"}}</p> | ||
{{/if}} | ||
</div> | ||
</div> | ||
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import Controller from "@ember/controller"; | ||
import { get } from "@ember/object"; | ||
import { inject as service } from "@ember/service"; | ||
import { tracked } from "@glimmer/tracking"; | ||
import { task } from "ember-concurrency"; | ||
|
||
export default class SubscriptionsDetailOrdersController extends Controller { | ||
@service account; | ||
@service intl; | ||
@service timed; | ||
|
||
@tracked project; | ||
@tracked orders; | ||
@tracked ordersNext; | ||
@tracked reports; | ||
@tracked reportsNext; | ||
|
||
@task *fetchNextOrders() { | ||
try { | ||
this.ordersPage++; | ||
const orders = yield this.timed.getProjectOrders( | ||
this.project.id, | ||
this.ordersPage | ||
); | ||
this.orders.pushObjects(orders.toArray()); | ||
|
||
this.ordersNext = Boolean(get(orders, "links.next")); | ||
} catch (error) { | ||
console.error(error); | ||
this.ordersNext = false; | ||
} | ||
} | ||
|
||
setup(model, transition) { | ||
this.project = model.project; | ||
|
||
this.orders = model.orders.toArray(); | ||
this.ordersPage = 1; | ||
this.ordersNext = Boolean(get(model, "orders.links.next")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Route from "@ember/routing/route"; | ||
import { inject as service } from "@ember/service"; | ||
|
||
export default class SubscriptionsDetailOrdersRoute extends Route { | ||
@service timed; | ||
|
||
model() { | ||
return this.modelFor("subscriptions.detail"); | ||
} | ||
|
||
setupController(controller, model) { | ||
super.setupController(...arguments); | ||
|
||
controller.setup(model); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<section class="section"> | ||
<div class="section__inner"> | ||
<div> | ||
{{#if this.orders.length}} | ||
<div class="table"> | ||
<table> | ||
<thead> | ||
<th>{{t "page.subscriptions.detail.orders.table.date"}}</th> | ||
<th>{{t "page.subscriptions.detail.orders.table.duration"}}</th> | ||
<th>{{t "page.subscriptions.detail.orders.table.acknowledged"}}</th> | ||
</thead> | ||
<tbody> | ||
{{#each this.orders as |order|}} | ||
<tr> | ||
<td>{{moment-format order.ordered "DD.MM.YYYY"}}</td> | ||
<td>{{format-duration order.duration}}</td> | ||
<td class="order-list--{{if order.acknowledged "acknowledged" "pending"}}"> | ||
<span uk-icon={{if order.acknowledged "check" "clock"}}></span> | ||
</td> | ||
</tr> | ||
{{/each}} | ||
|
||
{{#if this.ordersNext}} | ||
<tr class="table__fetch-more"> | ||
<td colspan="3"> | ||
<button | ||
{{on "click" (perform this.fetchNextOrders)}} | ||
type="button" | ||
class="button" | ||
disabled={{this.fetchNextOrders.isRunning}} | ||
> | ||
{{~t "page.subscriptions.detail.orders.more"}} | ||
</button> | ||
</td> | ||
</tr> | ||
{{/if}} | ||
</tbody> | ||
</table> | ||
</div> | ||
{{else}} | ||
<p>{{t "page.subscriptions.detail.orders.empty"}}</p> | ||
{{/if}} | ||
</div> | ||
</div> | ||
</section> |
Oops, something went wrong.