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

refactor: attendances, progress-tooltip and minor fixes #749

Merged
merged 17 commits into from
Dec 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/analysis/index/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ export default class AnalysisController extends Controller.extend(
@tracked _lastPage = 0;
@tracked selectedReportIds;

@tracked user;
@tracked reviewer;
@tracked customer;
@tracked project;
@tracked task;

get billingTypes() {
return this.store.findAll("billing-type");
}
Expand Down
49 changes: 23 additions & 26 deletions app/components/attendance-slider/component.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import Component from "@ember/component";
import { computed } from "@ember/object";
/**
* @module timed
* @submodule timed-components
* @public
*/

import Component from "@glimmer/component";
import { htmlSafe } from "@ember/string";
import classic from "ember-classic-decorator";
import { task } from "ember-concurrency";
import { padStartTpl } from "ember-pad/utils/pad";
import moment from "moment";
import formatDuration from "timed/utils/format-duration";
import { tracked } from "@glimmer/tracking";
import { dropTask } from "ember-concurrency";

const padTpl2 = padStartTpl(2);

Expand Down Expand Up @@ -42,27 +42,27 @@ const Formatter = {
* @extends Ember.Component
* @public
*/
@classic
export default class AttendanceSlider extends Component {
/**
* The attendance
*
* @property {Attendance} attendance
* @public
*/
attendance = null;
@tracked values;
@tracked tooltips;

/**
* Initialize the component
*
* @method init
* @public
*/
init(...args) {
super.init(...args);
constructor(...args) {
super(...args);

this.set("tooltips", [Formatter, Formatter]);
this.set("values", this.start);
this.tooltips = [Formatter, Formatter];
this.values = this.start;
}

/**
Expand All @@ -71,15 +71,14 @@ export default class AttendanceSlider extends Component {
* @property {Number[]} start
* @public
*/
@computed("attendance.{from,to}")
get start() {
return [
this.get("attendance.from").hour() * 60 +
this.get("attendance.from").minute(),
this.args.attendance.from.hour() * 60 +
this.args.attendance.from.minute(),
// If the end time is 00:00 we need to clarify that this would be 00:00
// of the next day
this.get("attendance.to").hour() * 60 +
this.get("attendance.to").minute() || 24 * 60,
this.args.attendance.to.hour() * 60 + this.args.attendance.to.minute() ||
24 * 60,
];
}

Expand All @@ -89,7 +88,6 @@ export default class AttendanceSlider extends Component {
* @property {String} duration
* @public
*/
@computed("values")
get duration() {
const from = moment({ hour: 0 }).minute(this.values[0]);
const to = moment({ hour: 0 }).minute(this.values[1]);
Expand All @@ -103,7 +101,6 @@ export default class AttendanceSlider extends Component {
* @property {String[]} labels
* @public
*/
@computed
get labels() {
const labels = [];

Expand All @@ -130,27 +127,27 @@ export default class AttendanceSlider extends Component {
* @param {Number[]} values The time in minutes
* @public
*/
@(task(function* ([fromMin, toMin]) {
const attendance = this.attendance;
@dropTask
*save([fromMin, toMin]) {
const attendance = this.args.attendance;

attendance.set(
"from",
moment(attendance.get("from")).hour(0).minute(fromMin)
);
attendance.set("to", moment(attendance.get("to")).hour(0).minute(toMin));

yield this["on-save"](attendance);
}).drop())
save;
yield this.args.onSave(attendance);
}

/**
* Delete the attendance
*
* @method delete
* @public
*/
@(task(function* () {
yield this["on-delete"](this.attendance);
}).drop())
delete;
@dropTask
*delete() {
yield this.args.onDelete(this.args.attendance);
}
}
81 changes: 0 additions & 81 deletions app/components/attendance-slider/styles.scss

This file was deleted.

43 changes: 32 additions & 11 deletions app/components/attendance-slider/template.hbs
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
<RangeSlider @start={{this.start}} @step={{15}} @min={{0}} @max={{1440}} @connect={{true}} @animate={{true}} @behaviour="drag" @tooltips={{this.tooltips}} @on-slide={{action (mut this.values)}} @on-change={{action (perform this.save)}} />
<div class="attendance-slider" ...attributes>
<RangeSlider
@start={{this.start}}
@step={{15}}
@min={{0}}
@max={{1440}}
@connect={{true}}
@animate={{true}}
@behaviour="drag"
@tooltips={{this.tooltips}}
@on-slide={{fn (mut this.values)}}
@on-change={{perform this.save}}
/>

<div class="slider-labels">
{{#each this.labels as |label|}}
<div style={{label.style}} class="slider-label slider-label--{{label.size}}">
<div class="slider-label-text">
{{label.value}}
<div class="slider-labels">
{{#each this.labels as |label|}}
<div
style={{label.style}}
class="slider-label slider-label--{{label.size}}"
>
<div class="slider-label-text">
{{label.value}}
</div>
</div>
</div>
{{/each}}
</div>
{{/each}}
</div>

<div class="slider-title">
<span>{{this.duration}}</span> {{fa-icon 'trash' data-test-delete-attendance=true click=(perform this.delete)}}
<div class="slider-title">
<span>{{this.duration}}</span>
<FaIcon
@icon="trash"
data-test-delete-attendance="true"
{{on "click" (perform this.delete)}}
/>
</div>
</div>
2 changes: 1 addition & 1 deletion app/components/no-mobile-message/template.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="empty">
{{fa-icon 'mobile'}}
<FaIcon @icon="mobile" />
<h3>Sorry, this page doesn't work on mobile!</h3>
<p>
The data on this page is taking up too much space for your currently used
Expand Down
5 changes: 3 additions & 2 deletions app/components/optimized-power-select/options/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
@renderAll={{this.isTesting}}
as |option index|
>
{{!template-lint-disable require-context-role}}
velrest marked this conversation as resolved.
Show resolved Hide resolved
<li
class="ember-power-select-option"
aria-selected="{{ember-power-select-is-selected option @select.selected}}"
Expand All @@ -33,10 +34,10 @@
{{component
(ensure-safe-component @extra.optionTemplate)
option=option
current=(eq option this.select.highlighted)
current=(eq option @select.highlighted)
}}
{{else}}
{{yield option this.select}}
{{yield option @select}}
{{/if}}
</li>
</VerticalCollection>
Expand Down
60 changes: 33 additions & 27 deletions app/components/optimized-power-select/trigger/template.hbs
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
{{#if @select.selected}}
{{#if @selectedItemComponent}}
<div class={{@triggerClass}}>
{{#if @select.selected}}
{{#if @selectedItemComponent}}
{{component
@selectedItemComponent
option=(readonly @select.selected)
select=(readonly @select)
}}
{{else}}
<span class="ember-power-select-selected-item">
{{#if @extra.selectedTemplate}}
{{component
(ensure-safe-component @extra.selectedTemplate)
[email protected]
}}
{{else}}
{{yield @select.selected @select}}
{{/if}}
</span>
{{/if}}
{{#if (and @allowClear (not @select.disabled))}}
<span
role="button"
class="ember-power-select-clear-btn"
{{on "mouseup" this.clear}}
{{on "ontouchend" this.clear}}
>&times;</span>
{{/if}}
{{else}}
{{component
@selectedItemComponent
option=(readonly @select.selected)
select=(readonly @select)
(ensure-safe-component @placeholderComponent)
placeholder=@placeholder
}}
{{else}}
<span class="ember-power-select-selected-item">
{{#if @extra.selectedTemplate}}
{{component (ensure-safe-component @extra.selectedTemplate) [email protected]}}
{{else}}
{{yield @select.selected @select}}
{{/if}}
</span>
{{/if}}
{{#if (and @allowClear (not @select.disabled))}}
<span
class="ember-power-select-clear-btn"
{{on "mousedown" this.clear}}
{{on "ontouchstart" this.clear}}
>&times;</span>
{{/if}}
{{else}}
{{component
(ensure-safe-component @placeholderComponent)
placeholder=@placeholder
}}
{{/if}}
<span class="ember-power-select-status-icon"></span>
<span class="ember-power-select-status-icon"></span>
</div>
Loading