Skip to content

feat: add quick shift buttons to timeline and autocomplete end date from start #649

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 2 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
69 changes: 67 additions & 2 deletions src/components/InputTimeInterval.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,55 @@
td.pr-2
label.col-form-label.col-form-label-sm Show from
td
input.form-control.form-control-sm.d-inline-block.p-1(type="date", v-model="start", style="height: auto; width: auto;")
input.form-control.form-control-sm.d-inline-block.p-1(
type="date",
v-model="start",
style="height: auto; width: auto;"
)
label.col-form-label.col-form-label-sm.px-2 to
input.form-control.form-control-sm.d-inline.p-1(type="date", v-model="end", style="height: auto; width: auto")
input.form-control.form-control-sm.d-inline.p-1(
type="date",
v-model="end",
style="height: auto; width: auto"
)
td.text-right
button.ml-2.btn.btn-outline-dark.btn-sm(
type="button",
:disabled="invalidDaterange || emptyDaterange || daterangeTooLong",
@click="applyRange"
) Apply

tr
td.pr-2
label.col-form-label.col-form-label-sm Shift date
td
.btn-group.show-day-group(role="group")
input.btn.btn-light.btn-sm(
type="button",
value="-1w",
@click="shiftDay(-7); $event.target.blur()"
)
input.btn.btn-light.btn-sm(
type="button",
value="-1d",
@click="shiftDay(-1); $event.target.blur()"
)
input.btn.btn-light.btn-sm(
type="button",
value="Today",
@click="setToday(); $event.target.blur()"
)
input.btn.btn-light.btn-sm(
type="button",
value="+1d",
@click="shiftDay(1); $event.target.blur()"
)
input.btn.btn-light.btn-sm(
type="button",
value="+1w",
@click="shiftDay(7); $event.target.blur()"
)

div.text-muted.d-none.d-md-block(style="text-align:right" v-if="showUpdate")
b-button.mt-2.px-2(@click="refresh()", variant="outline-dark", size="sm", style="opacity: 0.7")
icon(name="sync")
Expand Down Expand Up @@ -114,6 +153,13 @@
return moment(this.start).add(this.maxDuration, 'seconds').isBefore(moment(this.end));
},
},
watch: {
start(newStart) {
if (!this.end) {
this.end = newStart;
}
},
},
mounted() {
this.duration = this.defaultDuration;
this.valueChanged();
Expand Down Expand Up @@ -154,6 +200,25 @@
this.mode = 'last_duration';
this.valueChanged();
},
setToday() {
const today = moment().format('YYYY-MM-DD');
this.start = today;
this.end = today;
this.mode = 'range';
this.duration = 0;
this.valueChanged();
},
shiftDay(days:number) {

Check warning on line 211 in src/components/InputTimeInterval.vue

View workflow job for this annotation

GitHub Actions / lint (20.x)

Insert `·`

Check warning on line 211 in src/components/InputTimeInterval.vue

View workflow job for this annotation

GitHub Actions / Build webpack (node-20)

Insert `·`
let currentStart = this.start ? moment(this.start, 'YYYY-MM-DD') : moment();

Check warning on line 212 in src/components/InputTimeInterval.vue

View workflow job for this annotation

GitHub Actions / lint (20.x)

'currentStart' is never reassigned. Use 'const' instead

Check warning on line 212 in src/components/InputTimeInterval.vue

View workflow job for this annotation

GitHub Actions / Build webpack (node-20)

'currentStart' is never reassigned. Use 'const' instead
let currentEnd = this.end ? moment(this.end, 'YYYY-MM-DD') : moment();

Check warning on line 213 in src/components/InputTimeInterval.vue

View workflow job for this annotation

GitHub Actions / lint (20.x)

'currentEnd' is never reassigned. Use 'const' instead

Check warning on line 213 in src/components/InputTimeInterval.vue

View workflow job for this annotation

GitHub Actions / Build webpack (node-20)

'currentEnd' is never reassigned. Use 'const' instead
const newStart = currentStart.add(days, 'days').format('YYYY-MM-DD');
const newEnd = currentEnd.add(days, 'days').format('YYYY-MM-DD');
this.start = newStart;
this.end = newEnd;
this.mode = 'range';
this.duration = 0;
this.valueChanged();
},
},
};
</script>
Loading