Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan-Hendrik Willms
Stud.IP
Commits
05d62294
Commit
05d62294
authored
3 years ago
by
David Siegfried
Committed by
Jan-Hendrik Willms
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix js-error and cleanup, refs #225
parent
effa3b22
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
lib/classes/sidebar/RoomSearchWidget.class.php
+13
-60
13 additions, 60 deletions
lib/classes/sidebar/RoomSearchWidget.class.php
resources/assets/javascripts/lib/resources.js
+22
-24
22 additions, 24 deletions
resources/assets/javascripts/lib/resources.js
with
35 additions
and
84 deletions
lib/classes/sidebar/RoomSearchWidget.class.php
+
13
−
60
View file @
05d62294
...
@@ -11,7 +11,6 @@ class RoomSearchWidget extends SidebarWidget
...
@@ -11,7 +11,6 @@ class RoomSearchWidget extends SidebarWidget
protected
$selected_criteria
;
protected
$selected_criteria
;
protected
$defined_properties
;
protected
$defined_properties
;
protected
function
setupSearchParameters
()
protected
function
setupSearchParameters
()
{
{
$this
->
defined_properties
=
RoomManager
::
getAllRoomPropertyDefinitions
(
$this
->
defined_properties
=
RoomManager
::
getAllRoomPropertyDefinitions
(
...
@@ -47,32 +46,6 @@ class RoomSearchWidget extends SidebarWidget
...
@@ -47,32 +46,6 @@ class RoomSearchWidget extends SidebarWidget
];
];
}
}
$locations
=
Location
::
findAll
();
$location_options
=
[
[
'id'
=>
''
,
'name'
=>
_
(
'Alle Standorte und Gebäude'
),
'sub_options'
=>
[]
]
];
if
(
$locations
)
{
foreach
(
$locations
as
$location
)
{
$buildings
=
Building
::
findByLocation
(
$location
->
id
);
$sub_options
=
[];
foreach
(
$buildings
as
$building
)
{
$sub_options
[]
=
[
'id'
=>
'building_'
.
$building
->
id
,
'name'
=>
$building
->
name
];
}
$location_options
[]
=
[
'id'
=>
'location_'
.
$location
->
id
,
'name'
=>
$location
->
name
,
'sub_options'
=>
$sub_options
];
}
}
$this
->
criteria
=
[];
$this
->
criteria
=
[];
if
(
$this
->
defined_properties
)
{
if
(
$this
->
defined_properties
)
{
...
@@ -126,7 +99,6 @@ class RoomSearchWidget extends SidebarWidget
...
@@ -126,7 +99,6 @@ class RoomSearchWidget extends SidebarWidget
'title'
=>
_
(
'Standort / Gebäude'
),
'title'
=>
_
(
'Standort / Gebäude'
),
'type'
=>
'hidden'
,
'type'
=>
'hidden'
,
'range_search'
=>
false
,
'range_search'
=>
false
,
//'options' => $location_options,
'switch'
=>
false
,
'switch'
=>
false
,
'value'
=>
''
,
'value'
=>
''
,
'optional'
=>
false
'optional'
=>
false
...
@@ -141,7 +113,6 @@ class RoomSearchWidget extends SidebarWidget
...
@@ -141,7 +113,6 @@ class RoomSearchWidget extends SidebarWidget
'title'
=>
_
(
'Standort / Gebäude'
),
'title'
=>
_
(
'Standort / Gebäude'
),
'type'
=>
'disabled_text'
,
'type'
=>
'disabled_text'
,
'range_search'
=>
false
,
'range_search'
=>
false
,
//'options' => $location_options,
'switch'
=>
false
,
'switch'
=>
false
,
'value'
=>
$selected_res
->
name
,
'value'
=>
$selected_res
->
name
,
'optional'
=>
false
'optional'
=>
false
...
@@ -302,7 +273,7 @@ class RoomSearchWidget extends SidebarWidget
...
@@ -302,7 +273,7 @@ class RoomSearchWidget extends SidebarWidget
);
);
}
}
}
}
}
elseif
(
(
$data
[
'type'
]
==
'num'
)
and
$data
[
'range_search'
])
{
}
elseif
(
$data
[
'type'
]
==
=
'num'
&&
$data
[
'range_search'
])
{
if
(
Request
::
submitted
(
$name
.
'_min'
)
if
(
Request
::
submitted
(
$name
.
'_min'
)
||
Request
::
submitted
(
$name
.
'_max'
))
{
||
Request
::
submitted
(
$name
.
'_max'
))
{
$this
->
selected_criteria
[
$name
]
=
$data
;
$this
->
selected_criteria
[
$name
]
=
$data
;
...
@@ -324,7 +295,6 @@ class RoomSearchWidget extends SidebarWidget
...
@@ -324,7 +295,6 @@ class RoomSearchWidget extends SidebarWidget
$this
->
selected_criteria
;
$this
->
selected_criteria
;
}
}
protected
function
restoreSearchFromSession
()
protected
function
restoreSearchFromSession
()
{
{
if
(
is_array
(
$_SESSION
[
'room_search_criteria'
][
'room_search'
]))
{
if
(
is_array
(
$_SESSION
[
'room_search_criteria'
][
'room_search'
]))
{
...
@@ -335,7 +305,6 @@ class RoomSearchWidget extends SidebarWidget
...
@@ -335,7 +305,6 @@ class RoomSearchWidget extends SidebarWidget
}
}
}
}
protected
function
search
()
protected
function
search
()
{
{
//The properties array is a "simplified" version of the
//The properties array is a "simplified" version of the
...
@@ -492,7 +461,7 @@ class RoomSearchWidget extends SidebarWidget
...
@@ -492,7 +461,7 @@ class RoomSearchWidget extends SidebarWidget
)
)
);
);
}
}
$begin
->
setTime
(
0
,
0
,
0
);
$begin
->
setTime
(
0
,
0
);
$end
=
clone
$begin
;
$end
=
clone
$begin
;
$end
=
$end
->
add
(
$end
=
$end
->
add
(
new
DateInterval
(
'P1D'
)
new
DateInterval
(
'P1D'
)
...
@@ -523,14 +492,12 @@ class RoomSearchWidget extends SidebarWidget
...
@@ -523,14 +492,12 @@ class RoomSearchWidget extends SidebarWidget
);
);
}
}
public
function
resetSearch
()
public
function
resetSearch
()
{
{
$this
->
selected_criteria
=
[];
$this
->
selected_criteria
=
[];
$_SESSION
[
'room_search_criteria'
][
'room_search'
]
=
[];
$_SESSION
[
'room_search_criteria'
][
'room_search'
]
=
[];
}
}
public
function
__construct
(
$action_link
=
''
)
public
function
__construct
(
$action_link
=
''
)
{
{
parent
::
__construct
();
parent
::
__construct
();
...
@@ -555,25 +522,21 @@ class RoomSearchWidget extends SidebarWidget
...
@@ -555,25 +522,21 @@ class RoomSearchWidget extends SidebarWidget
}
}
}
}
public
function
searchRequested
()
public
function
searchRequested
()
{
{
return
Request
::
submitted
(
'room_search'
);
return
Request
::
submitted
(
'room_search'
);
}
}
public
function
searchResetRequested
()
public
function
searchResetRequested
()
{
{
return
Request
::
submitted
(
'room_search_reset'
);
return
Request
::
submitted
(
'room_search_reset'
);
}
}
public
function
getResults
()
public
function
getResults
()
{
{
return
$this
->
rooms
;
return
$this
->
rooms
;
}
}
public
function
setActionLink
(
$action_link
=
''
)
public
function
setActionLink
(
$action_link
=
''
)
{
{
if
(
!
$action_link
)
{
if
(
!
$action_link
)
{
...
@@ -595,27 +558,17 @@ class RoomSearchWidget extends SidebarWidget
...
@@ -595,27 +558,17 @@ class RoomSearchWidget extends SidebarWidget
public
function
render
(
$variables
=
[])
public
function
render
(
$variables
=
[])
{
{
$variables
[
'title'
]
=
_
(
'Suchkriterien für Räume'
);
$variables
=
array_merge
(
$variables
,
[
'title'
=>
_
(
'Suchkriterien für Räume'
),
$template
=
$GLOBALS
[
'template_factory'
]
->
open
(
'criteria'
=>
$this
->
criteria
,
$this
->
template
'selected_criteria'
=>
$this
->
selected_criteria
,
);
'action_link'
=>
$this
->
action_link
,
]);
$template
->
set_layout
(
'widgets/widget-layout'
);
return
$GLOBALS
[
'template_factory'
]
->
render
(
$template
->
set_attributes
(
$variables
);
$this
->
template
,
$variables
,
$template
->
set_attribute
(
'widgets/widget-layout'
'criteria'
,
$this
->
criteria
);
);
$template
->
set_attribute
(
'action_link'
,
$this
->
action_link
);
$template
->
set_attribute
(
'selected_criteria'
,
$this
->
selected_criteria
);
return
$template
->
render
();
}
}
}
}
This diff is collapsed.
Click to expand it.
resources/assets/javascripts/lib/resources.js
+
22
−
24
View file @
05d62294
...
@@ -212,23 +212,23 @@ class Resources
...
@@ -212,23 +212,23 @@ class Resources
return
;
return
;
}
}
var
selected_option
=
jQuery
(
select_node
).
find
(
"
:selected
"
)[
0
];
let
selected_option
=
jQuery
(
select_node
).
find
(
"
:selected
"
)[
0
];
if
(
!
selected_option
)
{
if
(
!
selected_option
)
{
return
;
return
;
}
}
var
option_value
=
jQuery
(
selected_option
).
val
();
let
option_value
=
jQuery
(
selected_option
).
val
();
if
(
!
option_value
)
{
if
(
!
option_value
)
{
//The first option which is left blank intentionally
//The first option which is left blank intentionally
//has been selected.
//has been selected.
return
;
return
;
}
}
var
option_title
=
jQuery
(
selected_option
).
attr
(
'
data-title
'
);
let
option_title
=
jQuery
(
selected_option
).
data
(
'
title
'
);
var
option_type
=
jQuery
(
selected_option
).
attr
(
'
data-type
'
);
let
option_type
=
jQuery
(
selected_option
).
data
(
'
type
'
);
var
option_select_options
=
jQuery
(
selected_option
).
attr
(
'
data-select_options
'
).
split
(
'
;;
'
);
let
option_select_options
=
jQuery
(
selected_option
).
data
(
'
select_options
'
).
split
(
'
;;
'
);
var
option_range_search
=
jQuery
(
selected_option
).
attr
(
'
data-range-search
'
);
let
option_range_search
=
jQuery
(
selected_option
).
data
(
'
range-search
'
);
let
template
=
undefined
;
var
template
=
undefined
;
if
(
option_type
===
'
bool
'
)
{
if
(
option_type
===
'
bool
'
)
{
template
=
jQuery
(
select_node
).
parent
().
parent
().
find
(
template
=
jQuery
(
select_node
).
parent
().
parent
().
find
(
'
.criteria-list .template[data-template-type="
'
'
.criteria-list .template[data-template-type="
'
...
@@ -269,43 +269,41 @@ class Resources
...
@@ -269,43 +269,41 @@ class Resources
return
;
return
;
}
}
var
criteria_list
=
jQuery
(
template
).
parent
();
let
criteria_list
=
jQuery
(
template
).
parent
();
let
new_criteria
=
jQuery
(
template
).
clone
();
var
new_criteria
=
jQuery
(
template
).
clone
();
jQuery
(
new_criteria
).
attr
(
'
class
'
,
'
item
'
);
jQuery
(
new_criteria
).
attr
(
'
class
'
,
'
item
'
);
jQuery
(
new_criteria
).
attr
(
'
data-criteria
'
,
option_value
);
jQuery
(
new_criteria
).
attr
(
'
data-criteria
'
,
option_value
);
var
new_criteria_text_field
=
jQuery
(
new_criteria
).
find
(
'
span
'
)[
0
];
let
new_criteria_text_field
=
jQuery
(
new_criteria
).
find
(
'
span
'
)[
0
];
jQuery
(
new_criteria_text_field
).
text
(
option_title
);
jQuery
(
new_criteria_text_field
).
text
(
option_title
);
if
(
option_type
===
'
bool
'
)
{
if
(
option_type
===
'
bool
'
)
{
var
new_criteria_input
=
jQuery
(
new_criteria
).
find
(
'
input
'
);
let
new_criteria_input
=
jQuery
(
new_criteria
).
find
(
'
input
'
);
jQuery
(
new_criteria_input
).
attr
(
'
name
'
,
option_value
);
jQuery
(
new_criteria_input
).
attr
(
'
name
'
,
option_value
);
}
else
if
(
option_type
===
'
select
'
)
{
}
else
if
(
option_type
===
'
select
'
)
{
var
new_criteria_select
=
jQuery
(
new_criteria
).
find
(
'
select
'
)[
0
];
let
new_criteria_select
=
jQuery
(
new_criteria
).
find
(
'
select
'
)[
0
];
jQuery
(
new_criteria_select
).
attr
(
'
name
'
,
option_value
);
jQuery
(
new_criteria_select
).
attr
(
'
name
'
,
option_value
);
//Build the option elements from the data-options field:
//Build the option elements from the data-options field:
if
(
!
option_select_options
)
{
if
(
!
option_select_options
)
{
//Something is wrong.
//Something is wrong.
return
;
return
;
}
}
var
options_html
=
''
;
let
options_html
=
''
;
for
(
option
of
option_select_options
)
{
for
(
let
option
of
option_select_options
)
{
var
splitted_option
=
option
.
split
(
'
~~
'
);
let
splitted_option
=
option
.
split
(
'
~~
'
);
options_html
+=
'
<option value="
'
+
splitted_option
[
0
]
+
'
">
'
options_html
+=
'
<option value="
'
+
splitted_option
[
0
]
+
'
">
'
+
splitted_option
[
1
]
+
splitted_option
[
1
]
+
'
</option>
'
;
+
'
</option>
'
;
}
}
jQuery
(
new_criteria_select
).
html
(
options_html
);
}
else
if
(
option_type
===
'
date
'
)
{
}
else
if
(
option_type
===
'
date
'
)
{
var
time_inputs
=
jQuery
(
new_criteria
).
find
(
'
input[data-time="yes"]
'
);
let
time_inputs
=
jQuery
(
new_criteria
).
find
(
'
input[data-time="yes"]
'
);
var
date_inputs
=
jQuery
(
new_criteria
).
find
(
'
input[type="date"]
'
);
let
date_inputs
=
jQuery
(
new_criteria
).
find
(
'
input[type="date"]
'
);
if
(
time_inputs
.
length
<
2
)
{
if
(
time_inputs
.
length
<
2
)
{
//Something is wrong with the HTML.
//Something is wrong with the HTML.
return
;
return
;
}
}
var
now
=
new
Date
();
let
now
=
new
Date
();
jQuery
(
time_inputs
[
0
]).
attr
(
'
name
'
,
option_value
+
'
_begin_time
'
);
jQuery
(
time_inputs
[
0
]).
attr
(
'
name
'
,
option_value
+
'
_begin_time
'
);
jQuery
(
time_inputs
[
1
]).
attr
(
'
name
'
,
option_value
+
'
_end_time
'
);
jQuery
(
time_inputs
[
1
]).
attr
(
'
name
'
,
option_value
+
'
_end_time
'
);
...
@@ -351,10 +349,10 @@ class Resources
...
@@ -351,10 +349,10 @@ class Resources
}
else
{
}
else
{
if
(
option_type
===
'
num
'
&&
option_range_search
)
{
if
(
option_type
===
'
num
'
&&
option_range_search
)
{
var
new_criteria_inputs
=
jQuery
(
new_criteria
).
find
(
'
input
'
);
let
new_criteria_inputs
=
jQuery
(
new_criteria
).
find
(
'
input
'
);
jQuery
(
new_criteria_inputs
[
0
]).
attr
(
'
name
'
,
option_value
);
jQuery
(
new_criteria_inputs
[
0
]).
attr
(
'
name
'
,
option_value
);
var
min_input
=
new_criteria_inputs
[
1
];
let
min_input
=
new_criteria_inputs
[
1
];
var
max_input
=
new_criteria_inputs
[
2
];
let
max_input
=
new_criteria_inputs
[
2
];
jQuery
(
min_input
).
attr
(
'
name
'
,
option_value
+
'
_min
'
);
jQuery
(
min_input
).
attr
(
'
name
'
,
option_value
+
'
_min
'
);
jQuery
(
min_input
).
attr
(
'
type
'
,
'
number
'
);
jQuery
(
min_input
).
attr
(
'
type
'
,
'
number
'
);
jQuery
(
max_input
).
attr
(
'
name
'
,
option_value
+
'
_max
'
);
jQuery
(
max_input
).
attr
(
'
name
'
,
option_value
+
'
_max
'
);
...
@@ -362,7 +360,7 @@ class Resources
...
@@ -362,7 +360,7 @@ class Resources
jQuery
(
min_input
).
val
(
Math
.
round
(
parseInt
(
min_input
)
*
1.25
));
jQuery
(
min_input
).
val
(
Math
.
round
(
parseInt
(
min_input
)
*
1.25
));
jQuery
(
max_input
).
val
(
Math
.
round
(
parseInt
(
max_input
)
*
0.75
));
jQuery
(
max_input
).
val
(
Math
.
round
(
parseInt
(
max_input
)
*
0.75
));
}
else
{
}
else
{
var
new_criteria_input
=
jQuery
(
new_criteria
).
find
(
'
input
'
)[
0
];
let
new_criteria_input
=
jQuery
(
new_criteria
).
find
(
'
input
'
)[
0
];
jQuery
(
new_criteria_input
).
attr
(
'
name
'
,
option_value
);
jQuery
(
new_criteria_input
).
attr
(
'
name
'
,
option_value
);
if
(
option_type
===
'
num
'
)
{
if
(
option_type
===
'
num
'
)
{
jQuery
(
new_criteria_input
).
attr
(
'
type
'
,
'
number
'
);
jQuery
(
new_criteria_input
).
attr
(
'
type
'
,
'
number
'
);
...
...
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