Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
chore: lint codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabauke committed Dec 12, 2022
1 parent 3c3ddce commit ae4ebeb
Show file tree
Hide file tree
Showing 303 changed files with 1,617 additions and 1,692 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ module.exports = {
"ember/no-classic-classes": "warn",
"ember/no-get": "warn",
"ember/no-observers": "warn",
"qunit/no-assert-equal": "warn"
}
"qunit/no-assert-equal": "warn",
},
};
2 changes: 1 addition & 1 deletion .template-lintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use strict";

module.exports = {
extends: "recommended"
extends: "recommended",
};
2 changes: 1 addition & 1 deletion app/abilities/absence-credit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Ability } from "ember-can";

const AbsenceCreditAbility = Ability.extend({
canEdit: reads("user.isSuperuser"),
canCreate: reads("user.isSuperuser")
canCreate: reads("user.isSuperuser"),
});

export default AbsenceCreditAbility;
2 changes: 1 addition & 1 deletion app/abilities/overtime-credit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Ability } from "ember-can";

const OvertimeCreditAbility = Ability.extend({
canEdit: reads("user.isSuperuser"),
canCreate: reads("user.isSuperuser")
canCreate: reads("user.isSuperuser"),
});

export default OvertimeCreditAbility;
4 changes: 2 additions & 2 deletions app/abilities/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { Ability } from "ember-can";
export default Ability.extend({
canAccess: computed(
"user.{activeEmployment.isExternal,isReviewer}",
function() {
function () {
return (
!this.get("user.activeEmployment.isExternal") ||
(this.get("user.activeEmployment.isExternal") &&
this.get("user.isReviewer"))
);
}
)
),
});
8 changes: 5 additions & 3 deletions app/abilities/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { Ability } from "ember-can";

export default Ability.extend({
canEdit: computed(
"model.user.{id,supervisors}",
"model.verifiedBy.id",
"model.{billed,customerAssignees,projectAssignees,taskAssignees}",
"user.{id,isSuperuser}",
"model.{user.id,user.supervisors,verifiedBy,billed,taskAssignees,projectAssignees,customerAssignees}",
function() {
function () {
const isEditable =
this.get("user.isSuperuser") ||
(!this.get("model.verifiedBy.id") &&
Expand All @@ -23,5 +25,5 @@ export default Ability.extend({
.includes(this.get("user.id")) && !this.get("model.verifiedBy.id");
return isEditable || isReviewer;
}
)
),
});
8 changes: 3 additions & 5 deletions app/abilities/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ export default Ability.extend({
canRead: computed(
"user.{id,isSuperuser}",
"model.{id,supervisors}",
function() {
function () {
return (
this.get("user.isSuperuser") ||
this.get("user.id") === this.get("model.id") ||
this.get("model.supervisors")
.mapBy("id")
.includes(this.get("user.id"))
this.get("model.supervisors").mapBy("id").includes(this.get("user.id"))
);
}
)
),
});
2 changes: 1 addition & 1 deletion app/adapters/activity-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ export default ApplicationAdapter.extend({
*/
urlForCreateRecord(...args) {
return `${this._super(...args)}?include=activity`;
}
},
});
72 changes: 38 additions & 34 deletions app/analysis/edit/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { task } from "ember-concurrency";
import {
underscoreQueryParams,
serializeParachuteQueryParams,
filterQueryParams
filterQueryParams,
} from "timed/utils/query-params";
import { cleanParams, toQueryString } from "timed/utils/url";
import IntersectionValidations from "timed/validations/intersection";
Expand All @@ -26,12 +26,12 @@ export const AnalysisEditQueryParams = AnalysisQueryParams.extend({
},
deserialize(str) {
return (str && str.split(",")) || [];
}
}
},
},
});
/* eslint-enable ember/avoid-leaking-state-in-ember-objects */

const prepareParams = params =>
const prepareParams = (params) =>
cleanParams(
underscoreQueryParams(
serializeParachuteQueryParams(
Expand Down Expand Up @@ -71,47 +71,53 @@ export default Controller.extend(AnalysisEditQueryParams.Mixin, {
this.intersection.perform();
},

intersection: task(function*() {
intersection: task(function* () {
const res = yield this.ajax.request("/api/v1/reports/intersection", {
method: "GET",
data: {
...prepareParams(this.allQueryParams),
editable: 1,
include: "task,project,customer,user"
}
include: "task,project,customer,user",
},
});

yield this.store.pushPayload("report-intersection", res);

return {
model: this.store.peekRecord("report-intersection", res.data.id),
meta: res.meta
meta: res.meta,
};
}),

_customer: computed("intersectionModel.customer.id", function() {
_customer: computed("intersectionModel.customer.id", "store", function () {
const id = this.get("intersectionModel.customer.id");
return id && this.store.peekRecord("customer", id);
}),

_project: computed("intersectionModel.project.id", function() {
_project: computed("intersectionModel.project.id", "store", function () {
const id = this.get("intersectionModel.project.id");
return id && this.store.peekRecord("project", id);
}),

_task: computed("intersectionModel.task.id", function() {
_task: computed("intersectionModel.task.id", "store", function () {
const id = this.get("intersectionModel.task.id");
return id && this.store.peekRecord("task", id);
}),

hasSelectedOwnReports: computed("intersectionModel.user.id", function() {
return this.get("intersectionModel.user.id") === this.session.data.user.id;
}),
hasSelectedOwnReports: computed(
"intersectionModel.user.id",
"session.data.user.id",
function () {
return (
this.get("intersectionModel.user.id") === this.session.data.user.id
);
}
),

canVerify: computed(
"allQueryParams.reviewer",
"session.data.user",
function() {
"session.data.user.{id,isSuperuser}",
function () {
return (
this.get("allQueryParams.reviewer") ===
this.get("session.data.user.id") ||
Expand All @@ -120,21 +126,19 @@ export default Controller.extend(AnalysisEditQueryParams.Mixin, {
}
),

canBill: computed("session.data.user", function() {
return (
this.get("session.data.user.isAccountant") ||
this.get("session.data.user.isSuperuser")
);
}),
canBill: computed.or(
"session.data.user.isAccountant",
"session.data.user.isSuperuser"
),

needsReview: computed("intersectionModel", function() {
needsReview: computed("intersectionModel.review", function () {
return (
this.get("intersectionModel.review") === null ||
this.get("intersectionModel.review") === true
);
}),

toolTipText: computed("canVerify", "needsReview", function() {
toolTipText: computed("canVerify", "needsReview", function () {
let result = "";
if (this.needsReview && this.canVerify) {
result = TOOLTIP_NEEDS_REVIEW;
Expand All @@ -146,7 +150,7 @@ export default Controller.extend(AnalysisEditQueryParams.Mixin, {
return result;
}),

save: task(function*(changeset) {
save: task(function* (changeset) {
try {
const params = prepareParams(this.allQueryParams);

Expand All @@ -155,27 +159,27 @@ export default Controller.extend(AnalysisEditQueryParams.Mixin, {
yield changeset.execute();

const {
data: { attributes, relationships }
data: { attributes, relationships },
} = this.intersectionModel.serialize();

const data = {
type: "report-bulks",
attributes: filterUnchanged(attributes, changeset.get("changes")),
relationships: filterUnchanged(relationships, changeset.get("changes"))
relationships: filterUnchanged(relationships, changeset.get("changes")),
};

yield this.ajax.request(
`/api/v1/reports/bulk?editable=1&${queryString}`,
{
method: "POST",
data: { data }
data: { data },
}
);

this.transitionToRoute("analysis.index", {
queryParams: {
...this.allQueryParams
}
...this.allQueryParams,
},
});

this.notify.success("Reports were saved");
Expand All @@ -202,8 +206,8 @@ export default Controller.extend(AnalysisEditQueryParams.Mixin, {

this.transitionToRoute("analysis.index", {
queryParams: {
...this.allQueryParams
}
...this.allQueryParams,
},
}).then(() => {
this.set("analysisIndexController.skipResetOnSetup", false);
});
Expand All @@ -216,6 +220,6 @@ export default Controller.extend(AnalysisEditQueryParams.Mixin, {
later(() => {
changeset.rollback();
});
}
}
},
},
});
44 changes: 22 additions & 22 deletions app/analysis/edit/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
</div>
{{else}}
<h1 class="text-center">
{{#unless (eq this.intersection.lastSuccessful.value.meta.count 1)}}
{{#if (eq this.intersection.lastSuccessful.value.meta.count 1)}}
Edit report
{{else}}
Bulk edit
{{this.intersection.lastSuccessful.value.meta.count}}
reports
{{else}}
Edit report
{{/unless}}
{{/if}}
</h1>
<div class="card">
<div class="card-block">
Expand Down Expand Up @@ -59,11 +59,11 @@
{{#unless model.customer}}
<NotIdenticalWarning />
{{/unless}}
{{#unless
(eq f.model.change.customer.id model.customer.id)
{{#if
(not (eq f.model.change.customer.id model.customer.id))
}}
<ChangedWarning />
{{/unless}}
{{/if}}
</label>
<t.customer />
</div>
Expand All @@ -73,11 +73,11 @@
{{#unless model.project}}
<NotIdenticalWarning />
{{/unless}}
{{#unless
(eq f.model.change.project.id model.project.id)
{{#if
(not (eq f.model.change.project.id model.project.id))
}}
<ChangedWarning />
{{/unless}}
{{/if}}
</label>
<t.project />
</div>
Expand All @@ -87,9 +87,9 @@
{{#unless model.task}}
<NotIdenticalWarning />
{{/unless}}
{{#unless (eq f.model.change.task.id model.task.id)}}
{{#if (not (eq f.model.change.task.id model.task.id))}}
<ChangedWarning />
{{/unless}}
{{/if}}
</label>
<t.task />
</div>
Expand All @@ -101,9 +101,9 @@
{{#if (eq model.comment null)}}
<NotIdenticalWarning />
{{/if}}
{{#unless (eq f.model.comment model.comment)}}
{{#if (not (eq f.model.comment model.comment))}}
<ChangedWarning />
{{/unless}}
{{/if}}
</label>
<input
type="text"
Expand Down Expand Up @@ -134,9 +134,9 @@
{{#if (eq model.notBillable null)}}
<NotIdenticalWarning />
{{/if}}
{{#unless (eq f.model.notBillable model.notBillable)}}
{{#if (not (eq f.model.notBillable model.notBillable))}}
<ChangedWarning />
{{/unless}}
{{/if}}
</SyCheckbox>
</f.input>

Expand All @@ -153,9 +153,9 @@
{{#if (eq model.review null)}}
<NotIdenticalWarning />
{{/if}}
{{#unless (eq f.model.review model.review)}}
{{#if (not (eq f.model.review model.review))}}
<ChangedWarning />
{{/unless}}
{{/if}}
</SyCheckbox>
</f.input>

Expand All @@ -173,9 +173,9 @@
{{#if (eq model.billed null)}}
<NotIdenticalWarning />
{{/if}}
{{#unless (eq f.model.billed model.billed)}}
{{#if (not (eq f.model.billed model.billed))}}
<ChangedWarning />
{{/unless}}
{{/if}}
</SyCheckbox>
</f.input>

Expand All @@ -190,9 +190,9 @@
{{#if (eq model.verified null)}}
<NotIdenticalWarning />
{{/if}}
{{#unless (eq f.model.verified model.verified)}}
{{#if (not (eq f.model.verified model.verified))}}
<ChangedWarning />
{{/unless}}
{{/if}}
</SyCheckbox>
</f.input>

Expand Down
Loading

0 comments on commit ae4ebeb

Please sign in to comment.