|
1 | 1 | import { service } from "@ember/service";
|
| 2 | +import type { AsyncBelongsTo } from "@ember-data/model"; |
2 | 3 | import Model, { attr, belongsTo } from "@ember-data/model";
|
| 4 | +import type StoreService from "@ember-data/store"; |
| 5 | +import type NotifyService from "ember-notify"; |
| 6 | +import type { Moment } from "moment"; |
3 | 7 | import moment from "moment";
|
4 | 8 | import { all } from "rsvp";
|
| 9 | +import type Task from "timed/models/task"; |
| 10 | +import type User from "timed/models/user"; |
5 | 11 |
|
6 | 12 | export default class Activity extends Model {
|
7 |
| - @attr("django-time") fromTime; |
8 |
| - @attr("django-time") toTime; |
9 |
| - @attr("string", { defaultValue: "" }) comment; |
10 |
| - @attr("django-date") date; |
11 |
| - @attr("boolean", { defaultValue: false }) transferred; |
12 |
| - @attr("boolean", { defaultValue: false }) review; |
13 |
| - @attr("boolean", { defaultValue: false }) notBillable; |
14 |
| - @belongsTo("task", { async: true, inverse: null }) task; |
15 |
| - @belongsTo("user", { async: true, inverse: null }) user; |
16 |
| - |
17 |
| - @service notify; |
18 |
| - @service store; |
| 13 | + @attr("django-time") |
| 14 | + declare fromTime?: Moment; |
| 15 | + @attr("django-time") |
| 16 | + declare toTime?: Moment; |
| 17 | + @attr("string", { defaultValue: "" }) |
| 18 | + declare comment: string; |
| 19 | + @attr("django-date") |
| 20 | + declare date?: Moment; |
| 21 | + @attr("boolean", { defaultValue: false }) |
| 22 | + declare transferred: boolean; |
| 23 | + @attr("boolean", { defaultValue: false }) |
| 24 | + declare review: boolean; |
| 25 | + @attr("boolean", { defaultValue: false }) |
| 26 | + declare notBillable: boolean; |
| 27 | + @belongsTo("task", { async: true, inverse: null }) |
| 28 | + declare task: AsyncBelongsTo<Task>; |
| 29 | + @belongsTo("user", { async: true, inverse: null }) |
| 30 | + declare user: AsyncBelongsTo<User>; |
| 31 | + |
| 32 | + @service declare notify: NotifyService; |
| 33 | + @service declare store: StoreService; |
19 | 34 |
|
20 | 35 | get active() {
|
21 | 36 | return !this.toTime && !!this.id;
|
@@ -137,3 +152,9 @@ export default class Activity extends Model {
|
137 | 152 | }
|
138 | 153 | }
|
139 | 154 | }
|
| 155 | + |
| 156 | +declare module "ember-data/types/registries/model" { |
| 157 | + export default interface ModelRegistry { |
| 158 | + activity: Activity; |
| 159 | + } |
| 160 | +} |
0 commit comments