Skip to content

Commit

Permalink
draft: stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
c0rydoras committed Sep 4, 2024
1 parent bf7019e commit 077d4be
Show file tree
Hide file tree
Showing 36 changed files with 186 additions and 41 deletions.
12 changes: 0 additions & 12 deletions frontend/app/models/absence-balance.js

This file was deleted.

47 changes: 47 additions & 0 deletions frontend/app/models/absence-balance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<<<<<<< HEAD
import Model, {
attr,
belongsTo,
hasMany,
type AsyncHasMany,
} from "@ember-data/model";
import type { Duration } from "moment";

import type AbsenceCredit from "./absence-credit";
import type AbsenceType from "./absence-type";
import type User from "./user";
=======
import Model, { attr, belongsTo, hasMany } from "@ember-data/model";
>>>>>>> 5c1741fc (cheklflasdjf)

export default class AbsenceBalance extends Model {
@attr("number")
declare credit: number;

@attr("number")
declare usedDays: number;

<<<<<<< HEAD
@attr("django-duration")
declare usedDuration: Duration;

@attr("number")
declare balance: number;

@belongsTo("user", { async: false, inverse: "absenceBalances" })
declare user: User;

@belongsTo("absence-type", { async: false, inverse: "absenceBalances" })
declare absenceType: AbsenceType;

@hasMany("absence-credit", { async: true, inverse: null })
declare absenceCredits: AsyncHasMany<AbsenceCredit>;
=======
@attr("django-duration") usedDuration;
@attr("number") balance;
@belongsTo("user", { async: false, inverse: "absenceBalances" }) user;
@belongsTo("absence-type", { async: false, inverse: "absenceBalances" })
absenceType;
@hasMany("absence-credit", { async: true, inverse: null }) absenceCredits;
>>>>>>> 5c1741fc (cheklflasdjf)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
* @public
*/
import Model, { attr, belongsTo } from "@ember-data/model";
<<<<<<< HEAD
import type { Moment } from "moment";

import type AbsenceType from "./absence-type";
import type User from "./user";
=======
>>>>>>> 5c1741fc (cheklflasdjf)

/**
* The absence credit model
Expand All @@ -13,6 +20,28 @@ import Model, { attr, belongsTo } from "@ember-data/model";
* @public
*/
export default class AbsenceCredit extends Model {
<<<<<<< HEAD
@attr("number")
declare days: number;

@attr("django-date")
declare date: Moment;

@attr("string", { defaultValue: "" })
declare comment: string;

/**
* The absence type for which this credit counts
*/
@belongsTo("absence-type", { async: false, inverse: null })
declare absenceType: AbsenceType;

/**
* The user to which this credit belongs to
*/
@belongsTo("user", { async: false, inverse: null })
declare user: User;
=======
/**
* The days
*
Expand Down Expand Up @@ -52,4 +81,5 @@ export default class AbsenceCredit extends Model {
* @public
*/
@belongsTo("user", { async: false, inverse: null }) user;
>>>>>>> 5c1741fc (cheklflasdjf)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
* @submodule timed-models
* @public
*/
<<<<<<< HEAD
import Model, { attr, hasMany, type AsyncHasMany } from "@ember-data/model";

import type AbsenceBalance from "./absence-balance";

=======
import Model, { attr, hasMany } from "@ember-data/model";

/**
Expand All @@ -12,11 +18,23 @@ import Model, { attr, hasMany } from "@ember-data/model";
* @extends DS.Model
* @public
*/
>>>>>>> 5c1741fc (cheklflasdjf)
export default class AbsenceType extends Model {
/**
* The name of the absence type
*
* E.g Military, Holiday or Sickness
<<<<<<< HEAD
*/
@attr("string")
declare name: string;

/**
* Whether the absence type only fills the worktime
*/
@attr("boolean")
declare fillWorktime: boolean;
=======
*
* @property {String} name
* @public
Expand All @@ -30,6 +48,7 @@ export default class AbsenceType extends Model {
* @public
*/
@attr("boolean") fillWorktime;
>>>>>>> 5c1741fc (cheklflasdjf)

/**
* The balances for this type
Expand All @@ -38,5 +57,9 @@ export default class AbsenceType extends Model {
* @public
*/
@hasMany("absence-balance", { async: true, inverse: "absenceType" })
<<<<<<< HEAD
declare absenceBalances: AsyncHasMany<AbsenceBalance>;
=======
absenceBalances;
>>>>>>> 5c1741fc (cheklflasdjf)
}
26 changes: 26 additions & 0 deletions frontend/app/models/absence.js → frontend/app/models/absence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
* @submodule timed-models
* @public
*/
<<<<<<< HEAD
import Model, { attr, belongsTo, type AsyncBelongsTo } from "@ember-data/model";
import moment, { type Duration, type Moment } from "moment";

import type AbsenceType from "./absence-type";
import type User from "./user";

export default class Absence extends Model {
@attr("string", { defaultValue: "" })
declare comment: string;

@attr("django-duration", { defaultValue: () => moment.duration() })
declare duration: Duration;
=======
import Model, { attr, belongsTo } from "@ember-data/model";
import moment from "moment";

Expand All @@ -29,13 +43,24 @@ export default class Absence extends Model {
* @public
*/
@attr("django-duration", { defaultValue: () => moment.duration() }) duration;
>>>>>>> 5c1741fc (cheklflasdjf)

/**
* The date
*
* @property {moment} date
* @public
*/
<<<<<<< HEAD
@attr("django-date")
declare date: Moment;

@belongsTo("absence-type", { async: false, inverse: null })
declare absenceType: AbsenceType;

@belongsTo("user", { async: true, inverse: null })
declare user: AsyncBelongsTo<User>;
=======
@attr("django-date") date;

/**
Expand All @@ -53,4 +78,5 @@ export default class Absence extends Model {
* @public
*/
@belongsTo("user", { async: true, inverse: null }) user;
>>>>>>> 5c1741fc (cheklflasdjf)
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
import { service } from "@ember/service";
import Model, { attr, belongsTo } from "@ember-data/model";
<<<<<<< HEAD
import moment, { type Moment } from "moment";
import { all } from "rsvp";

export default class Activity extends Model {
@attr("django-time")
declare fromTime: Moment;
@attr("django-time")
declare toTime: Moment;

@attr("string", { defaultValue: "" }) comment;

=======
import moment from "moment";
import { all } from "rsvp";

export default class Activity extends Model {
@attr("django-time") fromTime;
@attr("django-time") toTime;
@attr("string", { defaultValue: "" }) comment;
>>>>>>> 5c1741fc (cheklflasdjf)
@attr("django-date") date;
@attr("boolean", { defaultValue: false }) transferred;
@attr("boolean", { defaultValue: false }) review;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@ export default class DjangoDateTransform extends MomentTransform {
* @property {String} format
* @public
*/
format = "YYYY-MM-DD";
override format = "YYYY-MM-DD";
}

declare module "ember-data/types/registries/transform" {
export default interface TransformRegistry {
"django-date": DjangoDateTransform;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@ export default class DjangoDatetimeTransform extends MomentTransform {
* @property {String} format
* @public
*/
format = "YYYY-MM-DDTHH:mm:ss.SSSSZ";
override format = "YYYY-MM-DDTHH:mm:ss.SSSSZ";
}

declare module "ember-data/types/registries/transform" {
export default interface TransformRegistry {
"django-datetime": DjangoDatetimeTransform;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class DjangoDurationTransform extends Transform {
* @return {moment.duration} The deserialized moment duration
* @public
*/
deserialize(serialized) {
deserialize(serialized: string) {
return parseDjangoDuration(serialized);
}

Expand All @@ -46,7 +46,7 @@ export default class DjangoDurationTransform extends Transform {
* @returns {Object} An object containing all needed components as number
* @private
*/
_getDurationComponentsTimedeltaLike(duration) {
_getDurationComponentsTimedeltaLike(duration: Duration): object {
const days = Math.floor(duration.asDays());
const milliseconds = Math.abs(moment.duration({ days }) - duration);

Expand Down Expand Up @@ -90,3 +90,9 @@ export default class DjangoDurationTransform extends Transform {
return string;
}
}

declare module "ember-data/types/registries/transform" {
export default interface TransformRegistry {
"django-duration": DjangoDurationTransform;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ export default class DjangoTimeTransform extends MomentTransform {
*/
format = "HH:mm:ss";
}

declare module "ember-data/types/registries/transform" {
export default interface TransformRegistry {
"django-time": DjangoTimeTransform;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,21 @@ import Transform from "@ember-data/serializer/transform";
export default class DjangoWorkdaysTransform extends Transform {
/**
* Deserialize the string separated by comma into an array of numbers
*
* @method deserialize
* @param {String} serialized The string
* @return {Number[]} The deserialized array
* @public
*/
deserialize(serialized) {
deserialize(serialized: string) {
return serialized.split(",").map(Number);
}

/**
* Serialize the array of numbers into a string separated by comma
*
* @method serialize
* @param {Number[]} deserialized The number array
* @return {String} The serialized string
* @public
*/
serialize(deserialized) {
serialize(deserialized: number[]) {
return deserialized.join();
}
}

declare module "ember-data/types/registries/transform" {
export default interface TransformRegistry {
"django-workdays": DjangoWorkdaysTransform;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Transform from "@ember-data/serializer/transform";
import moment from "moment";
import moment, { type Moment } from "moment";

/**
* The moment transform
Expand All @@ -21,27 +21,23 @@ export default class MomentTransform extends Transform {

/**
* Deserialize the string into a moment object
*
* @method deserialize
* @param {String} serialized The date string
* @return {moment.duration} The deserialized moment object
* @public
*/
deserialize(serialized) {
deserialize(serialized: string) {
return serialized ? moment(serialized, this.format) : null;
}

/**
* Serialize the moment object into a string
*
* @method serialize
* @param {String} deserialized The moment object
* @return {moment.duration} The serialized date string
* @public
*/
serialize(deserialized) {
serialize(deserialized: Moment) {
return deserialized && deserialized.isValid()
? deserialized.format(this.format)
: null;
}
}

declare module "ember-data/types/registries/transform" {
export default interface TransformRegistry {
"django-workdays": MomentTransform;
}
}
1 change: 1 addition & 0 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// layout, which is not resolvable with the Node resolution algorithm, to
// work with TypeScript.
"allowJs": true,
"noImplicitOverride": false,
"baseUrl": ".",
"paths": {
"timed/tests/*": [
Expand Down

0 comments on commit 077d4be

Please sign in to comment.