Skip to content

Firefly III: a personal finances manager

Add popup for range.

James Cole85300b38f443
diff --git a/app/View/Components/Layout/Range.php b/app/View/Components/Layout/Range.php
new file mode 100644
index 0000000000..a747cd83f7
--- /dev/null
+++ b/app/View/Components/Layout/Range.php
@@ -0,0 +1,26 @@
+<?php
+
+namespace FireflyIII\View\Components\Layout;
+
+use Closure;
+use Illuminate\Contracts\View\View;
+use Illuminate\View\Component;
+
+class Range extends Component
+{
+ /**
+ * Create a new component instance.
+ */
+ public function __construct()
+ {
+ //
+ }
+
+ /**
+ * Get the view / contents that represent the component.
+ */
+ public function render(): View|Closure|string
+ {
+ return view('components.layout.range');
+ }
+}
diff --git a/package-lock.json b/package-lock.json
index b4bf43fff6..81fe96c153 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -3542,6 +3542,12 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/atomico": {
+ "version": "1.79.2",
+ "resolved": "https://registry.npmjs.org/atomico/-/atomico-1.79.2.tgz",
+ "integrity": "sha512-mshhLRMeIltNYbnQnqgnrvJ/uDa8XDfTQcjw3ymOygQqwHIQ4Sp0LcNYMCbACkV3DtV+eDXb9szwU4qMUuGwYQ==",
+ "license": "MIT"
+ },
"node_modules/autoprefixer": {
"version": "10.5.0",
"resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.5.0.tgz",
@@ -4120,6 +4126,15 @@
"node": ">=6"
}
},
+ "node_modules/cally": {
+ "version": "0.9.2",
+ "resolved": "https://registry.npmjs.org/cally/-/cally-0.9.2.tgz",
+ "integrity": "sha512-zY/Ueh+p6O+LKPYqNB13dATgNuazAHS0n3JbtKyUmMoQfRq5mC2/zFI3UV2X3g+2lZn2BBwr1Z+HxyG9Dt/6lw==",
+ "license": "MIT",
+ "dependencies": {
+ "atomico": "^1.79.2"
+ }
+ },
"node_modules/camel-case": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz",
@@ -12352,7 +12367,8 @@
"@eonasdan/tempus-dominus": "^6.10.4",
"@popperjs/core": "^2.11.8",
"admin-lte": "^4.0.0",
- "alpinejs": "^3.15.12"
+ "alpinejs": "^3.15.12",
+ "cally": "^0.9.2"
},
"devDependencies": {
"concurrently": "^9.0.1",
diff --git a/resources/assets/v3/js/boot/bootstrap.js b/resources/assets/v3/js/boot/bootstrap.js
index 5e4fda4937..d8de7a57ce 100644
--- a/resources/assets/v3/js/boot/bootstrap.js
+++ b/resources/assets/v3/js/boot/bootstrap.js
@@ -24,6 +24,7 @@ import "admin-lte"
import Alpine from 'alpinejs'
import store from "store";
import axios from 'axios';
+import "cally";
import observePlugin from 'store/plugins/observe';
import {getFreshVariable} from "v2/src/store/get-fresh-variable.js";
import {getVariable} from "v2/src/store/get-variable.js";
diff --git a/resources/assets/v3/package.json b/resources/assets/v3/package.json
index 6e8ab48612..7eaafc7170 100644
--- a/resources/assets/v3/package.json
+++ b/resources/assets/v3/package.json
@@ -6,7 +6,8 @@
"@eonasdan/tempus-dominus": "^6.10.4",
"@popperjs/core": "^2.11.8",
"admin-lte": "^4.0.0",
- "alpinejs": "^3.15.12"
+ "alpinejs": "^3.15.12",
+ "cally": "^0.9.2"
},
"type": "module",
"scripts": {
diff --git a/resources/views/components/layout/range.blade.php b/resources/views/components/layout/range.blade.php
new file mode 100644
index 0000000000..6b4ae36c5a
--- /dev/null
+++ b/resources/views/components/layout/range.blade.php
@@ -0,0 +1,52 @@
+<li class="nav-item dropdown" x-data="dates">
+ <a
+ href="#"
+ class="nav-link"
+ data-bs-toggle="dropdown"
+ aria-expanded="false"
+ id="date-range"
+ >
+ <em class="bi bi-calendar"></em>
+ <span class="daterange-holder"></span>
+ </a>
+ <ul
+ class="dropdown-menu"
+ aria-labelledby="date-range"
+ style="--bs-dropdown-min-width: 8rem"
+ >
+ <li>
+ <a href="#" class="dropdown-item daterange-current" @click="changeDateRange">current</a>
+ </li>
+ <li>
+ <a href="#" @click="changeDateRange" class="dropdown-item daterange-next">next</a>
+ </li>
+ <li>
+ <a href="#" class="dropdown-item daterange-prev" @click="changeDateRange">prev</a>
+ </li>
+ <li>
+ <a href="#" class="dropdown-item daterange-7d" @click="changeDateRange">{{ __('firefly.last_seven_days') }}</a>
+ </li>
+ <li>
+ <a href="#" class="dropdown-item daterange-30d" @click="changeDateRange">
+ {{ __('firefly.last_thirty_days') }}
+ </a>
+ </li>
+ <li>
+ <a href="#" class="dropdown-item daterange-mtd" @click="changeDateRange">
+ {{ __('firefly.month_to_date') }}
+ </a>
+ </li>
+ <li>
+ <a href="#" class="dropdown-item daterange-ytd" @click="changeDateRange">
+ {{ __('firefly.year_to_date') }}
+ </a>
+ </li>
+ <li>
+ <a href="#" type="button" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#customDateRangeModal">
+ {{ __('firefly.customRange') }}
+ </a>
+ </li>
+ </ul>
+</li>
+
+
diff --git a/resources/views/layout/v3/session.blade.php b/resources/views/layout/v3/session.blade.php
index 00ab61f434..05772a8f8f 100644
--- a/resources/views/layout/v3/session.blade.php
+++ b/resources/views/layout/v3/session.blade.php
@@ -94,72 +94,11 @@
</li>
<!--end::Fullscreen Toggle-->
- <li class="nav-item dropdown" x-data="dates">
- <div class="modal fade" tabindex="-1" role="dialog" id="customDateRangeModal" aria-labelledby="exampleModalLabel" aria-hidden="true">
- <div class="modal-dialog modal-lg">
- <div class="modal-content">
- <div class="modal-header">
- <h4 class="modal-title">Bla bla date modal</h4>
- </div>
- <div class="modal-body">Bla bla title</div>
- <div class="modal-footer">
- <small class="pull-left">
- {{ trans('firefly.submit') }}
- </small>
- <button type="button" class="btn btn-default" data-dismiss="modal">{{ __('firefly.close') }}</button>
- </div>
- </div>
- </div>
- </div>
- <a
- href="#"
- class="nav-link"
- data-bs-toggle="dropdown"
- aria-expanded="false"
- id="date-range"
- >
- <em class="bi bi-calendar"></em>
- <span class="daterange-holder"></span>
- </a>
- <ul
- class="dropdown-menu"
- aria-labelledby="date-range"
- style="--bs-dropdown-min-width: 8rem"
- >
- <li>
- <a href="#" class="dropdown-item daterange-current" @click="changeDateRange">current</a>
- </li>
- <li>
- <a href="#" @click="changeDateRange" class="dropdown-item daterange-next">next</a>
- </li>
- <li>
- <a href="#" class="dropdown-item daterange-prev" @click="changeDateRange">prev</a>
- </li>
- <li>
- <a href="#" class="dropdown-item daterange-7d" @click="changeDateRange">{{ __('firefly.last_seven_days') }}</a>
- </li>
- <li>
- <a href="#" class="dropdown-item daterange-30d" @click="changeDateRange">
- {{ __('firefly.last_thirty_days') }}
- </a>
- </li>
- <li>
- <a href="#" class="dropdown-item daterange-mtd" @click="changeDateRange">
- {{ __('firefly.month_to_date') }}
- </a>
- </li>
- <li>
- <a href="#" class="dropdown-item daterange-ytd" @click="changeDateRange">
- {{ __('firefly.year_to_date') }}
- </a>
- </li>
- <li>
- <a href="#" type="button" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#customDateRangeModal">
- {{ __('firefly.customRange') }}
- </a>
- </li>
- </ul>
- </li>
+ <!-- start: date range selector -->
+ <x-layout.range />
+ <!-- end: date range selector -->
+
+
<!-- anonymous -->
@@ -498,6 +437,107 @@
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
</form>
+<div class="modal fade" tabindex="-1" role="dialog" id="customDateRangeModal" aria-hidden="true" x-data="dates">
+ <div class="modal-dialog modal-lg">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h4 class="modal-title">Bla bla date modal</h4>
+ </div>
+ <div class="modal-body">
+ <style>
+ calendar-range {
+ svg {
+ height: 16px;
+ width: 16px;
+ fill: none;
+ stroke: currentColor;
+ stroke-width: 1.5;
+ }
+
+ path {
+ stroke-linecap: round;
+ stroke-linejoin: round;
+ }
+
+ &::part(months) {
+ display: flex;
+ gap: 1.5em;
+ flex-wrap: wrap;
+ justify-content: center;
+ }
+
+ &::part(button) {
+ border: 1px solid #adb5bd;
+ border-radius: 3px;
+ width: 26px;
+ height: 26px;
+ }
+
+ &::part(button):focus-visible {
+ outline: 2px solid #7048e8;
+ }
+ }
+
+ calendar-month {
+ --color-accent: #7048e8;
+ --color-text-on-accent: #ffffff;
+
+ &::part(button) {
+ border-radius: 3px;
+ }
+
+ &::part(range-inner) {
+ border-radius: 0;
+ background-color: #845ef7;
+ }
+
+ &::part(range-start) {
+ border-start-end-radius: 0;
+ border-end-end-radius: 0;
+ }
+
+ &::part(range-end) {
+ border-start-start-radius: 0;
+ border-end-start-radius: 0;
+ }
+
+ &::part(range-start range-end) {
+ border-radius: 3px;
+ }
+ }
+ </style>
+ <div class="row">
+ <div class="col" style="content-align:center;width:100%;display:flex;justify-content:center;">
+ <calendar-range months="2">
+ <svg
+ aria-label="Previous"
+ slot="previous"
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 24 24"
+ >
+ <path d="M15.75 19.5 8.25 12l7.5-7.5"></path>
+ </svg>
+ <svg
+ aria-label="Next"
+ slot="next"
+ xmlns="http://www.w3.org/2000/svg"
+ viewBox="0 0 24 24"
+ >
+ <path d="m8.25 4.5 7.5 7.5-7.5 7.5"></path>
+ </svg>
+ <calendar-month></calendar-month>
+ <calendar-month offset="1"></calendar-month>
+ </calendar-range>
+ </div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">{{ __('firefly.close') }}</button>
+ <button type="button" class="btn btn-primary">{{ trans('firefly.submit') }}</button>
+ </div>
+ </div>
+ </div>
+</div>
<div class="modal fade" tabindex="-1" role="dialog" id="helpModal">
@@ -515,7 +555,7 @@
<small class="pull-left">
{!! trans('firefly.reenable_intro_text') !!}
</small>
- <button type="button" class="btn btn-primary" data-dismiss="modal">{{ trans('firefly.close') }}</button>
+ <button type="button" class="btn btn-primary" data-bs-dismiss="modal">{{ trans('firefly.close') }}</button>
</div>
</div>
</div>