Skip to content

Commit 522f3d1

Browse files
szeidlerbriancwald
authored andcommitted
Issue #2936441 by szeidler, Bcwald, robin.ingelbrecht: Use a year select list for the datepicker to make past years easier selectable
1 parent eee6f48 commit 522f3d1

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

config/install/material_admin.settings.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ material_admin_jqueryui_dialog_close: true
1919
material_admin_collapse_module_list: true
2020
material_admin_message_length: 88
2121
material_admin_message_prompt: true
22+
material_admin_datepicker_select_years: 20

config/schema/material_admin.schema.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ material_admin.settings:
1616
type: integer
1717
material_admin_message_prompt:
1818
type: boolean
19+
material_admin_datepicker_select_years:
20+
type: integer

inc/alters.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ function material_admin_page_attachments_alter(&$page) {
1515
$page['#attached']['drupalSettings']['material_admin']['material_admin_message_length'] = theme_get_setting('material_admin_message_length');
1616
$page['#attached']['drupalSettings']['material_admin']['material_admin_jqueryui_dialog_background'] = theme_get_setting('material_admin_jqueryui_dialog_background');
1717
$page['#attached']['drupalSettings']['material_admin']['material_admin_jqueryui_dialog_close'] = theme_get_setting('material_admin_jqueryui_dialog_close');
18+
$page['#attached']['drupalSettings']['material_admin']['material_admin_datepicker_select_years'] = theme_get_setting('material_admin_datepicker_select_years');
1819
}

js/date-time-picker.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
(function ($, Drupal) {
88

99
Drupal.behaviors.material_pickadate = {
10-
attach: function (context) {
10+
attach: function (context, settings) {
11+
var selectYears = drupalSettings.material_admin.material_admin_datepicker_select_years;
1112
$(context).find('.form-date').once('material_pickadate').each(function () {
1213
$(this).pickadate({
13-
selectYears: 20,
14+
selectYears: selectYears,
1415
selectMonths: true, // Creates a dropdown to control month
1516
formatSubmit: 'yyyy-mm-dd',
1617
format:'yyyy-mm-dd',

theme-settings.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,11 @@ function material_admin_form_system_theme_settings_alter(&$form, $form_state) {
7575
'#description' => t('If checked, a long message will skip the toast notice and only show up in the bottom drawer'),
7676
'#default_value' => theme_get_setting('material_admin_message_prompt'),
7777
);
78+
79+
$form['theme_ui_options']['material_admin_datepicker_select_years'] = array(
80+
'#type' => 'number',
81+
'#title' => t('Number of years in datepicker'),
82+
'#description' => t('Defines the number of years, that will be available in the datepicker dropdown.'),
83+
'#default_value' => theme_get_setting('material_admin_datepicker_select_years'),
84+
);
7885
}

0 commit comments

Comments
 (0)