Skip to content
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

Date picker fix #906 #1026

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
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
4 changes: 2 additions & 2 deletions assets/js/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import {
registerBbContext,
registerClipboardContext,
registerDataTableContext,
registerFlatpickrContext,
registerFormulierContext,
registerGlobalContext,
registerGrafiekContext,
registerKnopContext,
registerLidInstellingenContext,
} from './context';
import { init } from './ctx';
import { ketzerAjax } from './lib/ajax';
Expand Down Expand Up @@ -119,7 +119,7 @@ Dropzone.autoDiscover = false;
registerKnopContext(),
registerDataTableContext(),
registerBbContext(),
registerFlatpickrContext(),
registerLidInstellingenContext(),
]);

docReady(() => {
Expand Down
16 changes: 8 additions & 8 deletions assets/js/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ export const registerGlobalContext = async (): Promise<void> => {
});
};

export const registerFlatpickrContext = async (): Promise<void> => {
const { initDateTimePicker, initDatePicker } = await import(
'./lib/datepicker'
);
export const registerLidInstellingenContext = async (): Promise<void> => {
const { instellingOpslaan } = await import('./page/instellingen');

ctx.addHandlers({
'.DateTimeField': initDateTimePicker,
'.DateField': initDatePicker,
});
ctx.addHandler('.instellingKnop', (el) =>
el.addEventListener('click', instellingOpslaan)
);
ctx.addHandler('.change-opslaan', (el) =>
el.addEventListener('change', instellingOpslaan)
);
};
53 changes: 0 additions & 53 deletions assets/js/lib/datepicker.ts

This file was deleted.

2 changes: 1 addition & 1 deletion assets/js/page/instellingen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const checkPushAvailability = async () => {
};
checkPushAvailability();

const instellingOpslaan = async (ev: Event) => {
export const instellingOpslaan = async (ev: Event) => {
ev.preventDefault();

const input = ev.target as HTMLElement;
Expand Down
6 changes: 0 additions & 6 deletions assets/scss/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
@import "module/profiel";
@import "module/stamboom";

@import "~flatpickr/dist/flatpickr.css";

:root {
accent-color: $primary;
}

body {
height: auto;
position: relative;
Expand Down
1 change: 0 additions & 1 deletion assets/scss/thema/dies.scss
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ $card-border-color: rgba(0, 0, 0, 0.3) !default;

/* importeer basis */
@import "../base";
@import "~flatpickr/dist/themes/dark.css";

:root {
color-scheme: dark;
Expand Down
1 change: 0 additions & 1 deletion assets/scss/thema/donker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ $card-border-color: rgba(0, 0, 0, 0.3) !default;

/* importeer basis */
@import "../base";
@import "~flatpickr/dist/themes/dark.css";

:root {
color-scheme: dark;
Expand Down
23 changes: 14 additions & 9 deletions lib/view/formulier/keuzevelden/DateField.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
class DateField extends InputField
{
protected $date_value;
protected $max_jaar;
protected $min_jaar;

Expand All @@ -28,7 +29,10 @@ public function __construct(
$maxyear = null,
$minyear = null
) {
parent::__construct($name, $value, $description);
parent::__construct($name, null, $description);

$this->date_value = date('Y-m-d', strtotime($value));

if (is_int($maxyear)) {
$this->max_jaar = $maxyear;
} else {
Expand Down Expand Up @@ -82,12 +86,9 @@ public function validate()
public function getHtml()
{
$attributes = $this->getInputAttribute([
'type',
'id',
'name',
'class',
'value',
'origvalue',
'disabled',
'readonly',
'maxlength',
Expand All @@ -96,21 +97,25 @@ public function getHtml()
]);

$minValue = $maxValue = null;
// $value = $this->date_value;

if ($this->min_jaar) {
$minValue = $this->min_jaar . '-01-01 00:00';
$minValue = $this->min_jaar . '-01-01';
}

if ($this->max_jaar) {
$maxValue = $this->max_jaar + 1 . '-01-01 00:00';
$maxValue = $this->max_jaar + 1 . '-01-01';
}

return <<<HTML
<input
{$attributes}
data-min-date="{$minValue}"
data-max-date="{$maxValue}"
data-readonly="{$this->readonly}"
type="date"
value="{$this->date_value}"
origvalue="{$this->date_value}"
min="{$minValue}"
max="{$maxValue}"
pattern="[0-9]{4}-[0-9]{2}-[0-9]{2}"
/>
HTML;
}
Expand Down
22 changes: 15 additions & 7 deletions lib/view/formulier/keuzevelden/DateTimeField.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
class DateTimeField extends TextField
{
protected $datetime_value;
public $from_datetime;
public $to_datetime;
protected $max_jaar;
Expand All @@ -26,7 +27,14 @@ public function __construct(
$maxyear = null,
$minyear = null
) {
parent::__construct($name, $value, $description);
parent::__construct($name, null, $description);

if ($value == '0000-00-00' or empty($value)) {
$this->datetime_value = null;
} else {
$this->datetime_value = date('Y-m-d H:i', strtotime($value));
}

if (is_int($maxyear)) {
$this->max_jaar = $maxyear;
} else {
Expand Down Expand Up @@ -85,12 +93,9 @@ public function validate()
public function getHtml()
{
$attributes = $this->getInputAttribute([
'type',
'id',
'name',
'class',
'value',
'origvalue',
'disabled',
'readonly',
'maxlength',
Expand Down Expand Up @@ -121,11 +126,14 @@ public function getHtml()
return <<<HTML
<input
{$attributes}
data-min-date="{$minValue}"
data-max-date="{$maxValue}"
type="datetime-local"
value="{$this->datetime_value}"
origvalue="{$this->datetime_value}"
min="{$minValue}"
max="{$maxValue}"
pattern="[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}"
data-after="{$after}"
data-before="{$before}"
data-readonly="{$this->readonly}"
/>
HTML;
}
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@
"datatables.net-select": "^1.3.3",
"datatables.net-select-dt": "^1.3.0",
"dropzone": "^5.5.0",
"flatpickr": "^4.6.6",
"fslightbox": "^3.3.1",
"get-video-id": "^3.2.0",
"google-palette": "^1.1.0",
Expand Down
8 changes: 0 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3018,13 +3018,6 @@ __metadata:
languageName: node
linkType: hard

"flatpickr@npm:^4.6.6":
version: 4.6.6
resolution: "flatpickr@npm:4.6.6"
checksum: 2bf4c28b29bb10962e557ce0ca55976f605e736218ecf759dda34439ac74adb6973f041ebbcf02497efb029350894f325c1e31a55777659eef8913283ba41342
languageName: node
linkType: hard

"flatted@npm:^3.1.0":
version: 3.2.7
resolution: "flatted@npm:3.2.7"
Expand Down Expand Up @@ -5812,7 +5805,6 @@ fsevents@~2.3.1:
eslint-plugin-prettier: ^4.2.1
eslint-plugin-vue: ^9.9.0
eslint-webpack-plugin: ^4.0.0
flatpickr: ^4.6.6
fslightbox: ^3.3.1
get-video-id: ^3.2.0
google-palette: ^1.1.0
Expand Down
Loading