From ae4ebeb063c0ca14b1f6c91abb3b4eb75fe95c2c Mon Sep 17 00:00:00 2001 From: Falk Date: Mon, 5 Dec 2022 19:26:33 +0100 Subject: [PATCH] chore: lint codebase --- .eslintrc.js | 4 +- .template-lintrc.js | 2 +- app/abilities/absence-credit.js | 2 +- app/abilities/overtime-credit.js | 2 +- app/abilities/page.js | 4 +- app/abilities/report.js | 8 +- app/abilities/user.js | 8 +- app/adapters/activity-block.js | 2 +- app/analysis/edit/controller.js | 72 +++--- app/analysis/edit/template.hbs | 44 ++-- app/analysis/index/controller.js | 159 ++++++------- app/analysis/index/template.hbs | 10 +- app/breakpoints.js | 2 +- app/components/async-list/component.js | 4 +- app/components/attendance-slider/component.js | 29 +-- app/components/attendance-slider/template.hbs | 2 +- app/components/balance-donut/component.js | 13 +- app/components/changed-warning/component.js | 8 +- .../customer-visible-icon/component.js | 2 +- app/components/date-buttons/component.js | 42 +--- app/components/date-buttons/template.hbs | 2 +- app/components/duration-since/component.js | 6 +- app/components/filter-sidebar/component.js | 2 +- .../filter-sidebar/filter/component.js | 4 +- .../filter-sidebar/filter/template.hbs | 3 +- .../filter-sidebar/group/component.js | 2 +- .../filter-sidebar/label/component.js | 2 +- app/components/filter-sidebar/template.hbs | 5 +- app/components/in-viewport/component.js | 6 +- app/components/loading-icon/component.js | 2 +- app/components/no-permission/component.js | 2 +- .../not-identical-warning/component.js | 8 +- .../options/component.js | 2 +- app/components/page-permission/component.js | 2 +- .../paginated-table/body/component.js | 2 +- app/components/paginated-table/component.js | 2 +- .../paginated-table/foot/component.js | 2 +- .../paginated-table/head/component.js | 2 +- app/components/pagination-limit/component.js | 2 +- app/components/progress-tooltip/component.js | 14 +- app/components/record-button/component.js | 8 +- .../report-review-warning/component.js | 4 +- app/components/sort-header/component.js | 8 +- .../statistic-list/bar/component.js | 6 +- .../statistic-list/column/component.js | 2 +- app/components/statistic-list/component.js | 30 +-- app/components/statistic-list/template.hbs | 8 +- app/components/sy-modal/overlay/component.js | 26 +-- app/components/sy-topnav/component.js | 12 +- app/components/sy-topnav/template.hbs | 2 +- app/components/timed-clock/component.js | 4 +- app/components/tracking-bar/component.js | 2 +- app/components/tracking-bar/template.hbs | 4 +- app/components/user-selection/component.js | 6 +- .../vertical-collection/component.js | 2 +- .../weekly-overview-day/component.js | 4 +- app/components/weekly-overview/component.js | 62 ++--- app/components/welcome-modal/component.js | 2 +- app/components/welcome-modal/template.hbs | 4 +- .../worktime-balance-chart/component.js | 40 ++-- app/helpers/format-duration.js | 2 +- app/helpers/humanize-duration.js | 2 +- app/helpers/parse-django-duration.js | 2 +- app/index/activities/template.hbs | 12 +- app/index/attendances/controller.js | 12 +- app/index/attendances/route.js | 10 +- app/index/attendances/template.hbs | 2 +- .../inject-user-into-abilities.js | 4 +- app/initializers/responsive.js | 2 +- app/mixins/route-autostart-tour.js | 4 +- app/projects/controller.js | 31 +-- app/projects/route.js | 2 +- app/projects/template.hbs | 10 +- app/router.js | 20 +- app/serializers/attendance.js | 4 +- app/serializers/employment.js | 4 +- app/services/ajax.js | 2 +- app/services/unverified-reports.js | 2 +- app/statistics/controller.js | 101 ++++---- app/tours/index/activities.js | 8 +- app/tours/index/attendances.js | 6 +- app/tours/index/reports.js | 12 +- app/transforms/django-date.js | 2 +- app/transforms/django-datetime.js | 2 +- app/transforms/django-time.js | 2 +- app/users/edit/controller.js | 31 ++- .../absence-credits/edit/controller.js | 28 +-- .../credits/absence-credits/edit/route.js | 2 +- .../edit/credits/absence-credits/new/route.js | 2 +- app/users/edit/credits/index/controller.js | 34 ++- .../overtime-credits/edit/controller.js | 20 +- .../credits/overtime-credits/edit/route.js | 2 +- .../credits/overtime-credits/new/route.js | 2 +- app/users/edit/index/controller.js | 12 +- app/users/edit/responsibilities/controller.js | 14 +- app/users/edit/route.js | 2 +- app/users/index/controller.js | 33 +-- app/users/index/template.hbs | 16 +- app/utils/parse-django-duration.js | 4 +- app/utils/query-params.js | 4 +- app/utils/url.js | 10 +- app/validations/absence-credit.js | 4 +- app/validations/absence.js | 2 +- app/validations/activity.js | 2 +- app/validations/attendance.js | 2 +- app/validations/intersection.js | 2 +- app/validations/multiple-absence.js | 6 +- app/validations/overtime-credit.js | 2 +- app/validations/report.js | 2 +- app/validations/task.js | 2 +- app/validators/intersection-task.js | 2 +- app/validators/moment.js | 2 +- config/coverage.js | 4 +- config/deprecation-workflow.js | 3 +- config/targets.js | 2 +- mirage/config.js | 215 +++++++++--------- mirage/factories/absence-balance.js | 6 +- mirage/factories/absence-credit.js | 2 +- mirage/factories/absence-type.js | 2 +- mirage/factories/absence.js | 4 +- mirage/factories/activity.js | 10 +- mirage/factories/attendance.js | 6 +- mirage/factories/billing-type.js | 2 +- mirage/factories/cost-center.js | 2 +- mirage/factories/customer-statistic.js | 2 +- mirage/factories/customer.js | 2 +- mirage/factories/employment.js | 4 +- mirage/factories/location.js | 2 +- mirage/factories/month-statistic.js | 6 +- mirage/factories/overtime-credit.js | 2 +- mirage/factories/project-assignee.js | 2 +- mirage/factories/project-statistic.js | 2 +- mirage/factories/project.js | 2 +- mirage/factories/public-holiday.js | 2 +- mirage/factories/report-intersection.js | 4 +- mirage/factories/report.js | 2 +- mirage/factories/task-statistic.js | 2 +- mirage/factories/task.js | 2 +- mirage/factories/user-statistic.js | 2 +- mirage/factories/user.js | 8 +- mirage/factories/worktime-balance.js | 2 +- mirage/factories/year-statistic.js | 4 +- mirage/fixtures/absence-types.js | 2 +- mirage/scenarios/default.js | 6 +- mirage/serializers/application.js | 2 +- testem.js | 8 +- tests/.eslintrc.js | 8 +- tests/acceptance/analysis-edit-test.js | 39 ++-- tests/acceptance/analysis-test.js | 40 ++-- tests/acceptance/auth-test.js | 12 +- tests/acceptance/external-employee-test.js | 18 +- .../acceptance/index-activities-edit-test.js | 22 +- tests/acceptance/index-activities-test.js | 46 ++-- tests/acceptance/index-attendances-test.js | 14 +- tests/acceptance/index-reports-test.js | 24 +- tests/acceptance/index-test.js | 34 +-- tests/acceptance/notfound-test.js | 4 +- tests/acceptance/project-test.js | 30 +-- tests/acceptance/statistics-test.js | 54 ++--- tests/acceptance/tour-test.js | 16 +- .../users-edit-credits-absence-credit-test.js | 16 +- ...users-edit-credits-overtime-credit-test.js | 16 +- tests/acceptance/users-edit-credits-test.js | 38 +--- .../users-edit-responsibilities-test.js | 6 +- tests/acceptance/users-edit-test.js | 10 +- tests/acceptance/users-test.js | 14 +- tests/helpers/responsive.js | 8 +- tests/helpers/task-select.js | 5 +- tests/helpers/user-select.js | 2 +- .../components/async-list/component-test.js | 12 +- .../attendance-slider/component-test.js | 16 +- .../balance-donut/component-test.js | 20 +- .../changed-warning/component-test.js | 6 +- .../customer-visible-icon/component-test.js | 6 +- .../components/date-buttons/component-test.js | 54 +---- .../duration-since/component-test.js | 22 +- .../filter-sidebar/component-test.js | 8 +- .../filter-sidebar/filter/component-test.js | 26 +-- .../filter-sidebar/group/component-test.js | 8 +- .../filter-sidebar/label/component-test.js | 6 +- .../components/in-viewport/component-test.js | 6 +- .../components/loading-icon/component-test.js | 6 +- .../no-mobile-message/component-test.js | 6 +- .../no-permission/component-test.js | 6 +- .../not-identical-warning/component-test.js | 6 +- .../paginated-table/body/component-test.js | 6 +- .../paginated-table/component-test.js | 6 +- .../paginated-table/foot/component-test.js | 6 +- .../paginated-table/head/component-test.js | 6 +- .../pagination-limit/component-test.js | 8 +- .../components/power-select/component-test.js | 12 +- .../components/progress-bar/component-test.js | 6 +- .../record-button/component-test.js | 10 +- .../report-review-warning/component-test.js | 6 +- .../components/report-row/component-test.js | 18 +- .../components/sort-header/component-test.js | 10 +- .../statistic-list/bar/component-test.js | 11 +- .../statistic-list/column/component-test.js | 6 +- .../statistic-list/component-test.js | 14 +- .../sy-durationpicker-day/component-test.js | 6 +- .../sy-modal/body/component-test.js | 6 +- .../sy-modal/footer/component-test.js | 6 +- .../sy-modal/header/component-test.js | 8 +- .../sy-modal/overlay/component-test.js | 10 +- .../sy-timepicker/component-test.js | 104 +++++---- .../components/sy-topnav/component-test.js | 6 +- .../components/timed-clock/component-test.js | 6 +- .../components/tracking-bar/component-test.js | 14 +- .../user-selection/component-test.js | 12 +- .../component-test.js | 10 +- .../weekly-overview/component-test.js | 10 +- .../welcome-modal/component-test.js | 6 +- tests/unit/abilities/report-test.js | 22 +- tests/unit/analysis/edit/controller-test.js | 4 +- tests/unit/analysis/edit/route-test.js | 4 +- tests/unit/analysis/index/controller-test.js | 4 +- tests/unit/analysis/index/route-test.js | 4 +- tests/unit/analysis/route-test.js | 4 +- .../statistic-list/component-test.js | 37 ++- .../worktime-balance-chart/component-test.js | 16 +- .../helpers/balance-highlight-class-test.js | 10 +- tests/unit/helpers/format-duration-test.js | 10 +- tests/unit/helpers/humanize-duration-test.js | 10 +- .../helpers/parse-django-duration-test.js | 6 +- .../unit/index/activities/controller-test.js | 4 +- .../index/activities/edit/controller-test.js | 4 +- .../unit/index/activities/edit/route-test.js | 4 +- tests/unit/index/activities/route-test.js | 4 +- .../unit/index/attendances/controller-test.js | 4 +- tests/unit/index/attendances/route-test.js | 4 +- tests/unit/index/controller-test.js | 6 +- tests/unit/index/reports/controller-test.js | 4 +- tests/unit/index/reports/route-test.js | 4 +- tests/unit/index/route-test.js | 4 +- tests/unit/login/route-test.js | 4 +- .../unit/mixins/route-autostart-tour-test.js | 16 +- tests/unit/models/absence-balance-test.js | 4 +- tests/unit/models/activity-test.js | 4 +- tests/unit/models/attendance-test.js | 12 +- tests/unit/models/billing-type-test.js | 4 +- tests/unit/models/cost-center-test.js | 4 +- tests/unit/models/customer-statistic-test.js | 4 +- tests/unit/models/customer-test.js | 4 +- tests/unit/models/employment-test.js | 4 +- tests/unit/models/location-test.js | 4 +- tests/unit/models/month-statistic-test.js | 4 +- tests/unit/models/overtime-credit-test.js | 4 +- tests/unit/models/project-statistic-test.js | 4 +- tests/unit/models/project-test.js | 4 +- tests/unit/models/public-holiday-test.js | 4 +- tests/unit/models/report-intersection-test.js | 4 +- tests/unit/models/report-test.js | 4 +- tests/unit/models/task-statistic-test.js | 4 +- tests/unit/models/task-test.js | 4 +- tests/unit/models/user-statistic-test.js | 4 +- tests/unit/models/user-test.js | 20 +- tests/unit/models/worktime-balance-test.js | 4 +- tests/unit/models/year-statistic-test.js | 4 +- tests/unit/no-access/route-test.js | 4 +- tests/unit/notfound/route-test.js | 4 +- tests/unit/projects/controller-test.js | 4 +- tests/unit/projects/route-test.js | 4 +- tests/unit/protected/controller-test.js | 4 +- tests/unit/protected/route-test.js | 4 +- tests/unit/serializers/attendance-test.js | 4 +- tests/unit/serializers/employment-test.js | 4 +- tests/unit/services/ajax-test.js | 8 +- tests/unit/services/autostart-tour-test.js | 10 +- tests/unit/services/metadata-fetcher-test.js | 4 +- tests/unit/services/tracking-test.js | 4 +- .../unit/services/unverified-reports-test.js | 4 +- tests/unit/statistics/controller-test.js | 4 +- tests/unit/statistics/route-test.js | 4 +- tests/unit/transforms/django-date-test.js | 8 +- tests/unit/transforms/django-datetime-test.js | 10 +- tests/unit/transforms/django-duration-test.js | 18 +- tests/unit/transforms/django-time-test.js | 10 +- tests/unit/transforms/django-workdays-test.js | 6 +- tests/unit/users/edit/controller-test.js | 4 +- .../absence-credits/edit/controller-test.js | 23 +- .../absence-credits/edit/route-test.js | 23 +- .../credits/absence-credits/new/route-test.js | 23 +- .../edit/credits/index/controller-test.js | 4 +- .../users/edit/credits/index/route-test.js | 4 +- .../overtime-credits/edit/controller-test.js | 23 +- .../overtime-credits/edit/route-test.js | 23 +- .../overtime-credits/new/route-test.js | 23 +- tests/unit/users/edit/credits/route-test.js | 4 +- .../unit/users/edit/index/controller-test.js | 4 +- tests/unit/users/edit/index/route-test.js | 4 +- .../edit/responsibilities/controller-test.js | 4 +- .../users/edit/responsibilities/route-test.js | 4 +- tests/unit/users/edit/route-test.js | 4 +- tests/unit/users/index/controller-test.js | 4 +- tests/unit/users/index/route-test.js | 4 +- tests/unit/users/route-test.js | 4 +- tests/unit/utils/format-duration-test.js | 26 +-- tests/unit/utils/humanize-duration-test.js | 22 +- .../unit/utils/parse-django-duration-test.js | 16 +- tests/unit/utils/query-params-test.js | 16 +- tests/unit/utils/url-test.js | 12 +- tests/unit/validators/moment-test.js | 22 +- .../unit/validators/null-or-not-blank-test.js | 4 +- 303 files changed, 1617 insertions(+), 1692 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index d64dec731..186f735b9 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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", + }, }; diff --git a/.template-lintrc.js b/.template-lintrc.js index dcc69a1e7..d1311e116 100644 --- a/.template-lintrc.js +++ b/.template-lintrc.js @@ -1,5 +1,5 @@ "use strict"; module.exports = { - extends: "recommended" + extends: "recommended", }; diff --git a/app/abilities/absence-credit.js b/app/abilities/absence-credit.js index 8e627b5c7..5f44a8e75 100644 --- a/app/abilities/absence-credit.js +++ b/app/abilities/absence-credit.js @@ -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; diff --git a/app/abilities/overtime-credit.js b/app/abilities/overtime-credit.js index 4de5a506f..919151f8c 100644 --- a/app/abilities/overtime-credit.js +++ b/app/abilities/overtime-credit.js @@ -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; diff --git a/app/abilities/page.js b/app/abilities/page.js index ed3f43676..8d8c19c38 100644 --- a/app/abilities/page.js +++ b/app/abilities/page.js @@ -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")) ); } - ) + ), }); diff --git a/app/abilities/report.js b/app/abilities/report.js index 08637af0c..3fb548ff4 100644 --- a/app/abilities/report.js +++ b/app/abilities/report.js @@ -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") && @@ -23,5 +25,5 @@ export default Ability.extend({ .includes(this.get("user.id")) && !this.get("model.verifiedBy.id"); return isEditable || isReviewer; } - ) + ), }); diff --git a/app/abilities/user.js b/app/abilities/user.js index 6ab75ad1e..4a97aef91 100644 --- a/app/abilities/user.js +++ b/app/abilities/user.js @@ -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")) ); } - ) + ), }); diff --git a/app/adapters/activity-block.js b/app/adapters/activity-block.js index 66553fc37..ae5488ce2 100644 --- a/app/adapters/activity-block.js +++ b/app/adapters/activity-block.js @@ -39,5 +39,5 @@ export default ApplicationAdapter.extend({ */ urlForCreateRecord(...args) { return `${this._super(...args)}?include=activity`; - } + }, }); diff --git a/app/analysis/edit/controller.js b/app/analysis/edit/controller.js index f6c0694b5..294d76c1f 100644 --- a/app/analysis/edit/controller.js +++ b/app/analysis/edit/controller.js @@ -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"; @@ -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( @@ -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") || @@ -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; @@ -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); @@ -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"); @@ -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); }); @@ -216,6 +220,6 @@ export default Controller.extend(AnalysisEditQueryParams.Mixin, { later(() => { changeset.rollback(); }); - } - } + }, + }, }); diff --git a/app/analysis/edit/template.hbs b/app/analysis/edit/template.hbs index 729cd43ea..105efb094 100644 --- a/app/analysis/edit/template.hbs +++ b/app/analysis/edit/template.hbs @@ -8,13 +8,13 @@ {{else}}

- {{#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}}

@@ -59,11 +59,11 @@ {{#unless model.customer}} {{/unless}} - {{#unless - (eq f.model.change.customer.id model.customer.id) + {{#if + (not (eq f.model.change.customer.id model.customer.id)) }} - {{/unless}} + {{/if}}
@@ -73,11 +73,11 @@ {{#unless model.project}} {{/unless}} - {{#unless - (eq f.model.change.project.id model.project.id) + {{#if + (not (eq f.model.change.project.id model.project.id)) }} - {{/unless}} + {{/if}}
@@ -87,9 +87,9 @@ {{#unless model.task}} {{/unless}} - {{#unless (eq f.model.change.task.id model.task.id)}} + {{#if (not (eq f.model.change.task.id model.task.id))}} - {{/unless}} + {{/if}} @@ -101,9 +101,9 @@ {{#if (eq model.comment null)}} {{/if}} - {{#unless (eq f.model.comment model.comment)}} + {{#if (not (eq f.model.comment model.comment))}} - {{/unless}} + {{/if}} {{/if}} - {{#unless (eq f.model.notBillable model.notBillable)}} + {{#if (not (eq f.model.notBillable model.notBillable))}} - {{/unless}} + {{/if}} @@ -153,9 +153,9 @@ {{#if (eq model.review null)}} {{/if}} - {{#unless (eq f.model.review model.review)}} + {{#if (not (eq f.model.review model.review))}} - {{/unless}} + {{/if}} @@ -173,9 +173,9 @@ {{#if (eq model.billed null)}} {{/if}} - {{#unless (eq f.model.billed model.billed)}} + {{#if (not (eq f.model.billed model.billed))}} - {{/unless}} + {{/if}} @@ -190,9 +190,9 @@ {{#if (eq model.verified null)}} {{/if}} - {{#unless (eq f.model.verified model.verified)}} + {{#if (not (eq f.model.verified model.verified))}} - {{/unless}} + {{/if}} diff --git a/app/analysis/index/controller.js b/app/analysis/index/controller.js index d864e0530..a6a78e53d 100644 --- a/app/analysis/index/controller.js +++ b/app/analysis/index/controller.js @@ -13,100 +13,100 @@ import { Promise } from "rsvp"; import parseDjangoDuration from "timed/utils/parse-django-duration"; import { underscoreQueryParams, - serializeParachuteQueryParams + serializeParachuteQueryParams, } from "timed/utils/query-params"; import { cleanParams, toQueryString } from "timed/utils/url"; import config from "../../config/environment"; const rAF = () => { - return new Promise(resolve => { + return new Promise((resolve) => { window.requestAnimationFrame(resolve); }); }; const DATE_FORMAT = "YYYY-MM-DD"; -const serializeMoment = momentObject => +const serializeMoment = (momentObject) => (moment.isMoment(momentObject) && momentObject.format(DATE_FORMAT)) || null; -const deserializeMoment = momentString => +const deserializeMoment = (momentString) => (momentString && moment(momentString, DATE_FORMAT)) || null; export const AnalysisQueryParams = new QueryParams({ customer: { defaultValue: null, replace: true, - refresh: true + refresh: true, }, project: { defaultValue: null, replace: true, - refresh: true + refresh: true, }, task: { defaultValue: null, replace: true, - refresh: true + refresh: true, }, user: { defaultValue: null, replace: true, - refresh: true + refresh: true, }, reviewer: { defaultValue: null, replace: true, - refresh: true + refresh: true, }, billingType: { defaultValue: null, replace: true, - refresh: true + refresh: true, }, costCenter: { defaultValue: null, replace: true, - refresh: true + refresh: true, }, fromDate: { defaultValue: null, replace: true, refresh: true, serialize: serializeMoment, - deserialize: deserializeMoment + deserialize: deserializeMoment, }, toDate: { defaultValue: null, replace: true, refresh: true, serialize: serializeMoment, - deserialize: deserializeMoment + deserialize: deserializeMoment, }, review: { defaultValue: "", replace: true, - refresh: true + refresh: true, }, notBillable: { defaultValue: "", replace: true, - refresh: true + refresh: true, }, verified: { defaultValue: "", replace: true, - refresh: true + refresh: true, }, editable: { defaultValue: "", replace: true, - refresh: true + refresh: true, }, billed: { defaultValue: "", replace: true, - refresh: true + refresh: true, }, ordering: { defaultValue: "-date", @@ -117,21 +117,23 @@ export const AnalysisQueryParams = new QueryParams({ }, deserialize(val) { return val.replace(",id", ""); - } - } + }, + }, }); const AnalysisController = Controller.extend(AnalysisQueryParams.Mixin, { billingTypes: computed( "prefetchData.lastSuccessful.value.billingTypes", - function() { + "store", + function () { return this.store.findAll("billing-type"); } ), costCenters: computed( "prefetchData.lastSuccessful.value.costCenters", - function() { + "store", + function () { return this.store.findAll("cost-center"); } ), @@ -139,56 +141,60 @@ const AnalysisController = Controller.extend(AnalysisQueryParams.Mixin, { selectedCustomer: computed( "customer", "prefetchData.lastSuccessful.value.customer", - function() { + "store", + function () { return this.customer && this.store.peekRecord("customer", this.customer); } ), selectedProject: computed( - "project", "prefetchData.lastSuccessful.value.project", - function() { + "project", + "store", + function () { return this.project && this.store.peekRecord("project", this.project); } ), selectedTask: computed( - "task", "prefetchData.lastSuccessful.value.task", - function() { + "store", + "task", + function () { return this.task && this.store.peekRecord("task", this.task); } ), selectedUser: computed( - "user", "prefetchData.lastSuccessful.value.user", - function() { + "store", + "user", + function () { return this.user && this.store.peekRecord("user", this.user); } ), selectedReviewer: computed( - "reviewer", "prefetchData.lastSuccessful.value.reviewer", - function() { + "reviewer", + "store", + function () { return this.reviewer && this.store.peekRecord("user", this.reviewer); } ), - exportLimitExceeded: computed("totalItems", function() { + exportLimitExceeded: computed("exportLimit", "totalItems", function () { return this.totalItems > this.exportLimit; }), - exportLimitMessage: computed("exportLimit", function() { + exportLimitMessage: computed("exportLimit", function () { return `The export limit is ${this.exportLimit}. Please use filters to reduce the amount of reports.`; }), - canBill: computed("session.data.user", function() { - return ( - this.session.data.user.isAccountant || this.session.data.user.isSuperuser - ); - }), + canBill: computed.or( + "session.data.user.isAccountant", + "session.data.user.isSuperuser" + ), exportLinks: config.APP.REPORTEXPORTS, @@ -228,7 +234,7 @@ const AnalysisController = Controller.extend(AnalysisQueryParams.Mixin, { _canLoadMore: true, _shouldLoadMore: false, _dataCache: A(), - selectedReportIds: A() + selectedReportIds: A(), }); this.data.perform(); @@ -244,19 +250,19 @@ const AnalysisController = Controller.extend(AnalysisQueryParams.Mixin, { _canLoadMore: true, _lastPage: 0, - appliedFilters: computed("queryParamsState", function() { - return Object.keys(this.queryParamsState).filter(key => { + appliedFilters: computed("queryParamsState", function () { + return Object.keys(this.queryParamsState).filter((key) => { return key !== "ordering" && this.get(`queryParamsState.${key}.changed`); }); }), - prefetchData: task(function*() { + prefetchData: task(function* () { const { customer: customerId, project: projectId, task: taskId, user: userId, - reviewer: reviewerId + reviewer: reviewerId, } = this.allQueryParams; return yield hash({ @@ -266,11 +272,11 @@ const AnalysisController = Controller.extend(AnalysisQueryParams.Mixin, { user: userId && this.store.findRecord("user", userId), reviewer: reviewerId && this.store.findRecord("user", reviewerId), billingTypes: this.store.findAll("billing-type"), - costCenters: this.store.findAll("cost-center") + costCenters: this.store.findAll("cost-center"), }); }), - data: task(function*() { + data: task(function* () { const params = underscoreQueryParams( serializeParachuteQueryParams(this.allQueryParams, AnalysisQueryParams) ); @@ -278,32 +284,33 @@ const AnalysisController = Controller.extend(AnalysisQueryParams.Mixin, { const data = yield this.store.query("report", { page: { number: this._lastPage + 1, - size: 20 + size: 20, }, ...params, - include: "task,task.project,task.project.customer,user" + include: "task,task.project,task.project.customer,user", }); const assignees = yield this.fetchAssignees.perform(data); - const mappedReports = data.map(report => { + const mappedReports = data.map((report) => { report.set( "taskAssignees", assignees.taskAssignees.filter( - taskAssignee => report.get("task.id") === taskAssignee.get("task.id") + (taskAssignee) => + report.get("task.id") === taskAssignee.get("task.id") ) ); report.set( "projectAssignees", assignees.projectAssignees.filter( - projectAssignee => + (projectAssignee) => report.get("task.project.id") === projectAssignee.get("project.id") ) ); report.set( "customerAssignees", assignees.customerAssignees.filter( - customerAssignee => + (customerAssignee) => report.get("task.project.customer.id") === customerAssignee.get("customer.id") ) @@ -316,7 +323,7 @@ const AnalysisController = Controller.extend(AnalysisQueryParams.Mixin, { totalItems: parseInt(data.get("meta.pagination.count")), _canLoadMore: data.get("meta.pagination.pages") !== data.get("meta.pagination.page"), - _lastPage: data.get("meta.pagination.page") + _lastPage: data.get("meta.pagination.page"), }); this._dataCache.pushObjects(mappedReports.toArray()); @@ -324,46 +331,46 @@ const AnalysisController = Controller.extend(AnalysisQueryParams.Mixin, { return this._dataCache; }).enqueue(), - fetchAssignees: task(function*(data) { + fetchAssignees: task(function* (data) { const projectIds = data - .map(report => report.get("task.project.id")) + .map((report) => report.get("task.project.id")) .uniq() .join(","); const taskIds = data - .map(report => report.get("task.id")) + .map((report) => report.get("task.id")) .uniq() .join(","); const customerIds = data - .map(report => report.get("task.project.customer.id")) + .map((report) => report.get("task.project.customer.id")) .uniq() .join(","); const projectAssignees = projectIds.length - ? (yield this.store.query("project-assignee", { + ? yield this.store.query("project-assignee", { is_reviewer: 1, projects: projectIds, - include: "project,user" - })) + include: "project,user", + }) : []; const taskAssignees = taskIds.length - ? (yield this.store.query("task-assignee", { + ? yield this.store.query("task-assignee", { is_reviewer: 1, tasks: taskIds, - include: "task,user" - })) + include: "task,user", + }) : []; const customerAssignees = customerIds.length - ? (yield this.store.query("customer-assignee", { + ? yield this.store.query("customer-assignee", { is_reviewer: 1, customers: customerIds, - include: "customer,user" - })) + include: "customer,user", + }) : []; return { projectAssignees, taskAssignees, customerAssignees }; }), - loadNext: task(function*() { + loadNext: task(function* () { this.set("_shouldLoadMore", true); while (this._shouldLoadMore && this._canLoadMore) { @@ -388,15 +395,15 @@ const AnalysisController = Controller.extend(AnalysisQueryParams.Mixin, { ...serializeParachuteQueryParams( allQueryParams, AnalysisQueryParams - ) + ), }) ) ); const res = yield fetch(`${url}?${queryString}`, { headers: { - Authorization: `Bearer ${jwt}` - } + Authorization: `Bearer ${jwt}`, + }, }); /* istanbul ignore next */ @@ -434,7 +441,7 @@ const AnalysisController = Controller.extend(AnalysisQueryParams.Mixin, { "Error while downloading, try again or try reducing results" ); } - } + }, }), actions: { @@ -442,8 +449,8 @@ const AnalysisController = Controller.extend(AnalysisQueryParams.Mixin, { this.transitionToRoute("analysis.edit", { queryParams: { id: ids, - ...this.allQueryParams - } + ...this.allQueryParams, + }, }); }, @@ -454,7 +461,7 @@ const AnalysisController = Controller.extend(AnalysisQueryParams.Mixin, { if (selected.includes(report.id)) { this.set( "selectedReportIds", - A([...selected.filter(id => id !== report.id)]) + A([...selected.filter((id) => id !== report.id)]) ); } else { this.set("selectedReportIds", A([...selected, report.id])); @@ -468,10 +475,10 @@ const AnalysisController = Controller.extend(AnalysisQueryParams.Mixin, { reset() { this.resetQueryParams( - Object.keys(this.allQueryParams).filter(k => k !== "ordering") + Object.keys(this.allQueryParams).filter((k) => k !== "ordering") ); - } - } + }, + }, }); export default AnalysisController; diff --git a/app/analysis/index/template.hbs b/app/analysis/index/template.hbs index f94bcaee7..5e6d52216 100644 --- a/app/analysis/index/template.hbs +++ b/app/analysis/index/template.hbs @@ -221,7 +221,7 @@ class="btn btn-success" {{on "click" (fn this.edit this.selectedReportIds)}} > - Edit {{this.selectedReportIds.length}} selected report{{unless (eq this.selectedReportIds.length 1) 's'}} + Edit {{this.selectedReportIds.length}} selected report{{if (not (eq this.selectedReportIds.length 1)) 's'}} {{/if}} + {{/each}} diff --git a/app/components/duration-since/component.js b/app/components/duration-since/component.js index 5aee2911d..ca35c3c2a 100644 --- a/app/components/duration-since/component.js +++ b/app/components/duration-since/component.js @@ -81,7 +81,7 @@ const DurationSinceComponent = Component.extend({ * @proprety {*} timer * @public */ - timer: task(function*() { + timer: task(function* () { for (;;) { this._compute(); @@ -93,11 +93,11 @@ const DurationSinceComponent = Component.extend({ /* istanbul ignore next */ yield timeout(1000); } - }).on("init") + }).on("init"), }); DurationSinceComponent.reopenClass({ - positionalParams: ["from"] + positionalParams: ["from"], }); export default DurationSinceComponent; diff --git a/app/components/filter-sidebar/component.js b/app/components/filter-sidebar/component.js index 641e7a3d1..0186cee1e 100644 --- a/app/components/filter-sidebar/component.js +++ b/app/components/filter-sidebar/component.js @@ -1,6 +1,6 @@ -import classic from "ember-classic-decorator"; import { tagName } from "@ember-decorators/component"; import Component from "@ember/component"; +import classic from "ember-classic-decorator"; @classic @tagName("") diff --git a/app/components/filter-sidebar/filter/component.js b/app/components/filter-sidebar/filter/component.js index 0c0cced76..a55b33995 100644 --- a/app/components/filter-sidebar/filter/component.js +++ b/app/components/filter-sidebar/filter/component.js @@ -1,11 +1,11 @@ -import classic from "ember-classic-decorator"; import Component from "@ember/component"; +import classic from "ember-classic-decorator"; @classic class FilterSidebarFilterComponent extends Component {} FilterSidebarFilterComponent.reopenClass({ - positionalParams: ["type"] + positionalParams: ["type"], }); export default FilterSidebarFilterComponent; diff --git a/app/components/filter-sidebar/filter/template.hbs b/app/components/filter-sidebar/filter/template.hbs index 5d79a2e9c..d41239a86 100644 --- a/app/components/filter-sidebar/filter/template.hbs +++ b/app/components/filter-sidebar/filter/template.hbs @@ -2,8 +2,7 @@
{{#each this.options as |opt|}} diff --git a/app/components/filter-sidebar/group/component.js b/app/components/filter-sidebar/group/component.js index 9690a998a..9148b2d55 100644 --- a/app/components/filter-sidebar/group/component.js +++ b/app/components/filter-sidebar/group/component.js @@ -1,6 +1,6 @@ -import classic from "ember-classic-decorator"; import { classNames, classNameBindings } from "@ember-decorators/component"; import Component from "@ember/component"; +import classic from "ember-classic-decorator"; @classic @classNames("filter-sidebar-group") diff --git a/app/components/filter-sidebar/label/component.js b/app/components/filter-sidebar/label/component.js index 29a575a76..7b9b3e33e 100644 --- a/app/components/filter-sidebar/label/component.js +++ b/app/components/filter-sidebar/label/component.js @@ -1,6 +1,6 @@ -import classic from "ember-classic-decorator"; import { tagName } from "@ember-decorators/component"; import Component from "@ember/component"; +import classic from "ember-classic-decorator"; @classic @tagName("label") diff --git a/app/components/filter-sidebar/template.hbs b/app/components/filter-sidebar/template.hbs index 5c46ab050..54e04737a 100644 --- a/app/components/filter-sidebar/template.hbs +++ b/app/components/filter-sidebar/template.hbs @@ -2,7 +2,7 @@