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
Marcus Eibrink-Lunzenauer
Stud.IP
Commits
7ba5c83b
Commit
7ba5c83b
authored
3 years ago
by
David Siegfried
Browse files
Options
Downloads
Patches
Plain Diff
fix js-error and cleanup, refs #225
parent
c212719b
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 @
7ba5c83b
...
...
@@ -11,7 +11,6 @@ class RoomSearchWidget extends SidebarWidget
protected
$selected_criteria
;
protected
$defined_properties
;
protected
function
setupSearchParameters
()
{
$this
->
defined_properties
=
RoomManager
::
getAllRoomPropertyDefinitions
(
...
...
@@ -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
=
[];
if
(
$this
->
defined_properties
)
{
...
...
@@ -126,7 +99,6 @@ class RoomSearchWidget extends SidebarWidget
'title'
=>
_
(
'Standort / Gebäude'
),
'type'
=>
'hidden'
,
'range_search'
=>
false
,
//'options' => $location_options,
'switch'
=>
false
,
'value'
=>
''
,
'optional'
=>
false
...
...
@@ -141,7 +113,6 @@ class RoomSearchWidget extends SidebarWidget
'title'
=>
_
(
'Standort / Gebäude'
),
'type'
=>
'disabled_text'
,
'range_search'
=>
false
,
//'options' => $location_options,
'switch'
=>
false
,
'value'
=>
$selected_res
->
name
,
'optional'
=>
false
...
...
@@ -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'
)
||
Request
::
submitted
(
$name
.
'_max'
))
{
$this
->
selected_criteria
[
$name
]
=
$data
;
...
...
@@ -324,7 +295,6 @@ class RoomSearchWidget extends SidebarWidget
$this
->
selected_criteria
;
}
protected
function
restoreSearchFromSession
()
{
if
(
is_array
(
$_SESSION
[
'room_search_criteria'
][
'room_search'
]))
{
...
...
@@ -335,7 +305,6 @@ class RoomSearchWidget extends SidebarWidget
}
}
protected
function
search
()
{
//The properties array is a "simplified" version of the
...
...
@@ -492,7 +461,7 @@ class RoomSearchWidget extends SidebarWidget
)
);
}
$begin
->
setTime
(
0
,
0
,
0
);
$begin
->
setTime
(
0
,
0
);
$end
=
clone
$begin
;
$end
=
$end
->
add
(
new
DateInterval
(
'P1D'
)
...
...
@@ -523,14 +492,12 @@ class RoomSearchWidget extends SidebarWidget
);
}
public
function
resetSearch
()
{
$this
->
selected_criteria
=
[];
$_SESSION
[
'room_search_criteria'
][
'room_search'
]
=
[];
}
public
function
__construct
(
$action_link
=
''
)
{
parent
::
__construct
();
...
...
@@ -555,25 +522,21 @@ class RoomSearchWidget extends SidebarWidget
}
}
public
function
searchRequested
()
{
return
Request
::
submitted
(
'room_search'
);
}
public
function
searchResetRequested
()
{
return
Request
::
submitted
(
'room_search_reset'
);
}
public
function
getResults
()
{
return
$this
->
rooms
;
}
public
function
setActionLink
(
$action_link
=
''
)
{
if
(
!
$action_link
)
{
...
...
@@ -595,27 +558,17 @@ class RoomSearchWidget extends SidebarWidget
public
function
render
(
$variables
=
[])
{
$variables
[
'title'
]
=
_
(
'Suchkriterien für Räume'
);
$template
=
$GLOBALS
[
'template_factory'
]
->
open
(
$this
->
template
);
$template
->
set_layout
(
'widgets/widget-layout'
);
$template
->
set_attributes
(
$variables
);
$template
->
set_attribute
(
'criteria'
,
$this
->
criteria
$variables
=
array_merge
(
$variables
,
[
'title'
=>
_
(
'Suchkriterien für Räume'
),
'criteria'
=>
$this
->
criteria
,
'selected_criteria'
=>
$this
->
selected_criteria
,
'action_link'
=>
$this
->
action_link
,
]);
return
$GLOBALS
[
'template_factory'
]
->
render
(
$this
->
template
,
$variables
,
'widgets/widget-layout'
);
$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 @
7ba5c83b
...
...
@@ -212,23 +212,23 @@ class Resources
return
;
}
var
selected_option
=
jQuery
(
select_node
).
find
(
"
:selected
"
)[
0
];
let
selected_option
=
jQuery
(
select_node
).
find
(
"
:selected
"
)[
0
];
if
(
!
selected_option
)
{
return
;
}
var
option_value
=
jQuery
(
selected_option
).
val
();
let
option_value
=
jQuery
(
selected_option
).
val
();
if
(
!
option_value
)
{
//The first option which is left blank intentionally
//has been selected.
return
;
}
var
option_title
=
jQuery
(
selected_option
).
attr
(
'
data-title
'
);
var
option_type
=
jQuery
(
selected_option
).
attr
(
'
data-type
'
);
var
option_select_options
=
jQuery
(
selected_option
).
attr
(
'
data-select_options
'
).
split
(
'
;;
'
);
var
option_range_search
=
jQuery
(
selected_option
).
attr
(
'
data-range-search
'
);
let
option_title
=
jQuery
(
selected_option
).
data
(
'
title
'
);
let
option_type
=
jQuery
(
selected_option
).
data
(
'
type
'
);
let
option_select_options
=
jQuery
(
selected_option
).
data
(
'
select_options
'
).
split
(
'
;;
'
);
let
option_range_search
=
jQuery
(
selected_option
).
data
(
'
range-search
'
);
let
template
=
undefined
;
var
template
=
undefined
;
if
(
option_type
===
'
bool
'
)
{
template
=
jQuery
(
select_node
).
parent
().
parent
().
find
(
'
.criteria-list .template[data-template-type="
'
...
...
@@ -269,43 +269,41 @@ class Resources
return
;
}
var
criteria_list
=
jQuery
(
template
).
parent
();
var
new_criteria
=
jQuery
(
template
).
clone
();
let
criteria_list
=
jQuery
(
template
).
parent
();
let
new_criteria
=
jQuery
(
template
).
clone
();
jQuery
(
new_criteria
).
attr
(
'
class
'
,
'
item
'
);
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
);
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
);
}
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
);
//Build the option elements from the data-options field:
if
(
!
option_select_options
)
{
//Something is wrong.
return
;
}
var
options_html
=
''
;
for
(
option
of
option_select_options
)
{
var
splitted_option
=
option
.
split
(
'
~~
'
);
let
options_html
=
''
;
for
(
let
option
of
option_select_options
)
{
let
splitted_option
=
option
.
split
(
'
~~
'
);
options_html
+=
'
<option value="
'
+
splitted_option
[
0
]
+
'
">
'
+
splitted_option
[
1
]
+
'
</option>
'
;
}
jQuery
(
new_criteria_select
).
html
(
options_html
);
}
else
if
(
option_type
===
'
date
'
)
{
var
time_inputs
=
jQuery
(
new_criteria
).
find
(
'
input[data-time="yes"]
'
);
var
date_inputs
=
jQuery
(
new_criteria
).
find
(
'
input[type="date"]
'
);
let
time_inputs
=
jQuery
(
new_criteria
).
find
(
'
input[data-time="yes"]
'
);
let
date_inputs
=
jQuery
(
new_criteria
).
find
(
'
input[type="date"]
'
);
if
(
time_inputs
.
length
<
2
)
{
//Something is wrong with the HTML.
return
;
}
var
now
=
new
Date
();
let
now
=
new
Date
();
jQuery
(
time_inputs
[
0
]).
attr
(
'
name
'
,
option_value
+
'
_begin_time
'
);
jQuery
(
time_inputs
[
1
]).
attr
(
'
name
'
,
option_value
+
'
_end_time
'
);
...
...
@@ -351,10 +349,10 @@ class Resources
}
else
{
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
);
var
min_input
=
new_criteria_inputs
[
1
];
var
max_input
=
new_criteria_inputs
[
2
];
let
min_input
=
new_criteria_inputs
[
1
];
let
max_input
=
new_criteria_inputs
[
2
];
jQuery
(
min_input
).
attr
(
'
name
'
,
option_value
+
'
_min
'
);
jQuery
(
min_input
).
attr
(
'
type
'
,
'
number
'
);
jQuery
(
max_input
).
attr
(
'
name
'
,
option_value
+
'
_max
'
);
...
...
@@ -362,7 +360,7 @@ class Resources
jQuery
(
min_input
).
val
(
Math
.
round
(
parseInt
(
min_input
)
*
1.25
));
jQuery
(
max_input
).
val
(
Math
.
round
(
parseInt
(
max_input
)
*
0.75
));
}
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
);
if
(
option_type
===
'
num
'
)
{
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