Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
year
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
year
Commits
8d73ab13
Commit
8d73ab13
authored
2 years ago
by
Michael Caldwell
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3183616
: Invert List of Year from recent to older in the Year Views dropdown
parent
1f1767b0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
year_views/config/schema/year_views.schema.yml
+9
-0
9 additions, 0 deletions
year_views/config/schema/year_views.schema.yml
year_views/src/Plugin/views/filter/YearField.php
+21
-2
21 additions, 2 deletions
year_views/src/Plugin/views/filter/YearField.php
with
30 additions
and
2 deletions
year_views/config/schema/year_views.schema.yml
+
9
−
0
View file @
8d73ab13
...
...
@@ -5,3 +5,12 @@ views.filter.year_field:
reduce_duplicates
:
type
:
boolean
label
:
'
Reduce
duplicate'
year_from
:
type
:
string
label
:
'
Start
year'
year_to
:
type
:
string
label
:
'
End
year'
sort_order
:
type
:
string
label
:
'
Sort
order'
This diff is collapsed.
Click to expand it.
year_views/src/Plugin/views/filter/YearField.php
+
21
−
2
View file @
8d73ab13
...
...
@@ -24,6 +24,12 @@ class YearField extends ManyToOne {
// Set the options based on extra settings.
$range
=
range
(
$this
->
calculateYear
(
$this
->
options
[
'year_from'
]),
$this
->
calculateYear
(
$this
->
options
[
'year_to'
]));
// Reverse the sort order if needed.
if
(
$this
->
options
[
'sort_order'
]
==
'desc'
)
{
$range
=
array_reverse
(
$range
,
TRUE
);
}
$this
->
valueOptions
=
array_combine
(
$range
,
$range
);
}
...
...
@@ -64,6 +70,7 @@ class YearField extends ManyToOne {
$options
=
parent
::
defineOptions
();
$options
[
'year_from'
]
=
[
'default'
=>
'-30 years'
];
$options
[
'year_to'
]
=
[
'default'
=>
'+15 years'
];
$options
[
'sort_order'
]
=
[
'default'
=>
'asc'
];
return
$options
;
}
...
...
@@ -85,7 +92,7 @@ class YearField extends ManyToOne {
$form
[
'year_from'
]
=
[
'#type'
=>
'textfield'
,
'#title'
=>
$this
->
t
(
'From
Y
ear'
),
'#title'
=>
$this
->
t
(
'From
y
ear'
),
'#required'
=>
TRUE
,
'#default_value'
=>
$this
->
options
[
'year_from'
],
'#description'
=>
$this
->
t
(
"Enter a starting year"
),
...
...
@@ -94,12 +101,24 @@ class YearField extends ManyToOne {
$form
[
'year_to'
]
=
[
'#type'
=>
'textfield'
,
'#title'
=>
$this
->
t
(
'To
Y
ear'
),
'#title'
=>
$this
->
t
(
'To
y
ear'
),
'#required'
=>
TRUE
,
'#default_value'
=>
$this
->
options
[
'year_to'
],
'#description'
=>
$this
->
t
(
"Enter an end year."
),
'#weight'
=>
2
,
];
$form
[
'sort_order'
]
=
[
'#type'
=>
'radios'
,
'#title'
=>
$this
->
t
(
'Sort order'
),
'#required'
=>
TRUE
,
'#default_value'
=>
$this
->
options
[
'sort_order'
],
'#options'
=>
[
'asc'
=>
$this
->
t
(
'Ascending'
),
'desc'
=>
$this
->
t
(
'Descending'
),
],
'#weight'
=>
2
,
];
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment