Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
whats-open-web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Nicholas J Anderson
whats-open-web
Commits
78966b20
Commit
78966b20
authored
Dec 17, 2017
by
Mattias J Duffy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
favorites sorting
parent
cd3bee3c
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
65 additions
and
26 deletions
+65
-26
public/index.html
public/index.html
+3
-0
src/actions/action-types.js
src/actions/action-types.js
+2
-1
src/actions/api.js
src/actions/api.js
+6
-2
src/components/CardContainer.js
src/components/CardContainer.js
+2
-1
src/containers/Layout.js
src/containers/Layout.js
+14
-7
src/containers/SearchBar.js
src/containers/SearchBar.js
+2
-1
src/reducers/api.js
src/reducers/api.js
+28
-7
src/reducers/index.js
src/reducers/index.js
+4
-4
src/styles/components/facilityStatus.scss
src/styles/components/facilityStatus.scss
+1
-1
src/styles/containers/layout.scss
src/styles/containers/layout.scss
+3
-2
No files found.
public/index.html
View file @
78966b20
...
...
@@ -4,6 +4,9 @@
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, shrink-to-fit=no"
>
<meta
name=
"theme-color"
content=
"#000000"
>
<meta
name=
"apple-mobile-web-app-title"
content=
"What's Open"
>
<meta
name=
"apple-mobile-web-app-capable"
content=
"yes"
>
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
...
...
src/actions/action-types.js
View file @
78966b20
...
...
@@ -6,4 +6,5 @@ export const SET_SELECTED_FACILITY = 'SET_SELECTED_FACILITY';
export
const
SET_SEARCH_TERM
=
'
SET_SEARCH_TERM
'
;
export
const
ADD_FAVORITE_FACILITY
=
'
ADD_FAVORITE_FACILITY
'
;
export
const
REMOVE_FAVORITE_FACILITY
=
'
REMOVE_FAVORITE_FACILITY
'
;
export
const
SET_ALL_FAVORITES
=
'
SET_ALL_FAVORITES
'
;
\ No newline at end of file
export
const
SET_ALL_FAVORITES
=
'
SET_ALL_FAVORITES
'
;
export
const
SORT_BY_FAVORITES
=
'
SORT_BY_FAVORITES
'
;
\ No newline at end of file
src/actions/api.js
View file @
78966b20
import
{
GET_FACILITIES
,
SET_FACILITIES
}
from
'
./action-types
'
import
{
GET_FACILITIES
,
SET_FACILITIES
,
SORT_BY_FAVORITES
}
from
'
./action-types
'
export
const
apiTest
=
()
=>
{
return
(
dispatch
)
=>
{
...
...
@@ -41,4 +41,8 @@ export const setFacilities = (facilities) => {
type
:
SET_FACILITIES
,
facilities
:
JSON
.
parse
(
facilities
)
}
};
\ No newline at end of file
};
export
const
sortByFavorites
=
()
=>
({
type
:
SORT_BY_FAVORITES
})
\ No newline at end of file
src/components/CardContainer.js
View file @
78966b20
...
...
@@ -7,7 +7,8 @@ const CardContainer = ({searchTerm, facilities}) => {
const
filterCards
=
(
facility
)
=>
{
const
name
=
facility
.
facility_name
.
toLowerCase
()
return
name
.
includes
(
searchTerm
.
toLowerCase
())
}
}
// console.log(facilities)
return
(
<
Grid
container
className
=
{
'
card-container-root
'
}
spacing
=
{
24
}
justify
=
{
'
center
'
}
alignItems
=
{
'
flex-end
'
}
>
{
facilities
.
filter
(
filterCards
).
map
(
item
=>
{
...
...
src/containers/Layout.js
View file @
78966b20
...
...
@@ -3,7 +3,7 @@ import {connect} from 'react-redux';
import
{
setAllFavorites
,
toggleSidebar
,
toggleSidebarMap
}
from
'
../actions/ui
'
;
import
AppBar
from
'
../components/AppBar
'
;
import
Sidebar
from
'
../components/Sidebar
'
;
import
{
getFacilities
,
setFacilities
}
from
'
../actions/api
'
;
import
{
getFacilities
,
setFacilities
,
sortByFavorites
}
from
'
../actions/api
'
;
import
CardContainer
from
'
../components/CardContainer
'
;
import
SearchBar
from
'
./SearchBar
'
;
import
KeyboardArrowLeft
from
'
material-ui-icons/KeyboardArrowLeft
'
;
...
...
@@ -15,13 +15,15 @@ class Layout extends React.Component {
super
(
props
);
}
componentWillMount
()
{
componentWillMount
=
()
=>
{
/*
This is done in order to immediately load the page (retrieving from local storage is faster
than an API call). After retrieving from local storage, then call the API to see if there
are any updates.
*/
try
{
localStorage
=
window
.
localStorage
;
if
(
localStorage
.
getItem
(
'
facilities
'
))
{
const
facilities
=
localStorage
.
getItem
(
'
facilities
'
);
this
.
props
.
setFacilities
(
facilities
)
...
...
@@ -30,6 +32,7 @@ class Layout extends React.Component {
const
favorites
=
JSON
.
parse
(
localStorage
.
getItem
(
'
favorites
'
));
this
.
props
.
setAllFavorites
(
favorites
);
}
this
.
props
.
sortByFavorites
()
}
catch
(
e
)
{
console
.
log
(
'
you should enable cookies so we can remember what places you favorite
'
)
}
...
...
@@ -38,7 +41,7 @@ class Layout extends React.Component {
};
render
()
{
const
{
isSidebarOpen
,
isSidebarMapOpen
,
toggleSidebar
,
toggleSidebarMap
,
getFacilities
,
selectedFacility
}
=
this
.
props
;
const
{
isSidebarOpen
,
isSidebarMapOpen
,
toggleSidebar
,
toggleSidebarMap
,
getFacilities
,
selectedFacility
,
facilities
,
searchTerm
,
sortByFavorites
,
favorites
}
=
this
.
props
;
return
(
<
div
className
=
{
'
layout-root
'
}
>
<
AppBar
isOpen
=
{
false
}
handleMenuClick
=
{()
=>
{
...
...
@@ -47,8 +50,8 @@ class Layout extends React.Component {
<
div
className
=
{
'
layout-main-content
'
}
>
<
SearchBar
suggestions
=
{{}}
/
>
<
div
className
=
{
'
layout-card-container
'
}
>
<
CardContainer
styles
=
{
'
layout-card-container
'
}
searchTerm
=
{
this
.
props
.
searchTerm
}
facilities
=
{
this
.
props
.
facilities
}
/
>
<
CardContainer
styles
=
{
'
layout-card-container
'
}
searchTerm
=
{
searchTerm
}
facilities
=
{
facilities
}
/
>
<
/div
>
<
/div
>
<
div
className
=
{
'
layout-sidebar-toggle-container
'
}
>
...
...
@@ -61,7 +64,8 @@ class Layout extends React.Component {
}
<
/button
>
<
/div
>
<
Sidebar
facilities
=
{
this
.
props
.
facilities
}
facility
=
{
selectedFacility
}
isSidebarOpen
=
{
isSidebarOpen
}
<
button
onClick
=
{
sortByFavorites
}
>
Text
<
/button
>
<
Sidebar
facilities
=
{
facilities
}
facility
=
{
selectedFacility
}
isSidebarOpen
=
{
isSidebarOpen
}
isSidebarMapOpen
=
{
isSidebarMapOpen
}
toggleSidebarMap
=
{
toggleSidebarMap
}
/
>
<
/div
>
<
/div
>
...
...
@@ -70,6 +74,8 @@ class Layout extends React.Component {
}
function
mapStateToProps
(
state
)
{
console
.
log
(
'
sorted
'
)
console
.
log
(
state
.
facilities
.
data
)
return
{
facilities
:
state
.
facilities
.
data
,
favorites
:
state
.
ui
.
favorites
,
...
...
@@ -86,5 +92,6 @@ export default connect(mapStateToProps, {
toggleSidebarMap
,
getFacilities
,
setFacilities
,
setAllFavorites
setAllFavorites
,
sortByFavorites
})(
Layout
);
src/containers/SearchBar.js
View file @
78966b20
...
...
@@ -142,7 +142,8 @@ const styles = theme => ({
},
searchIcon
:{
display
:
'
block
'
,
opacity
:.
54
,
// opacity:.54,
color
:
'
rgba(0,0,0,0.54)
'
},
noSuggestInput
:{
display
:
'
flex
'
,
...
...
src/reducers/api.js
View file @
78966b20
import
{
SET_FACILITIES
,
GET_FACILITIES
}
from
'
../actions/action-types
'
import
{
SET_FACILITIES
,
GET_FACILITIES
,
SORT_BY_FAVORITES
}
from
'
../actions/action-types
'
import
cloneDeep
from
'
lodash/cloneDeep
'
;
const
defaultState
=
{
isLoading
:
false
,
data
:[]
};
export
const
facilities
=
(
state
=
defaultState
,
action
)
=>
{
export
const
facilities
=
(
state
=
defaultState
,
action
,
ui
)
=>
{
const
sortFunc
=
(
a
,
b
)
=>
{
const
favoriteCheck
=
ui
.
favorites
.
includes
(
b
.
slug
)
-
ui
.
favorites
.
includes
(
a
.
slug
)
if
(
favoriteCheck
==
0
){
if
(
a
.
slug
<
b
.
slug
)
{
return
-
1
;
}
if
(
a
.
slug
>
b
.
slug
)
{
return
1
;
}
return
0
}
else
{
return
ui
.
favorites
.
includes
(
b
.
slug
)
-
ui
.
favorites
.
includes
(
a
.
slug
);
}
}
switch
(
action
.
type
){
case
GET_FACILITIES
:
return
Object
.
assign
({},
state
,{
isLoading
:
true
,
});
case
SET_FACILITIES
:
return
{
data
:
action
.
facilities
,
isLoading
:
false
};
return
Object
.
assign
({},
state
,{
data
:
action
.
facilities
.
sort
(
sortFunc
),
isLoading
:
false
,
});
case
SORT_BY_FAVORITES
:
const
newData
=
cloneDeep
(
state
.
data
);
return
Object
.
assign
({},
state
,{
data
:
newData
.
sort
(
sortFunc
),
});
default
:
return
state
}
...
...
src/reducers/index.js
View file @
78966b20
...
...
@@ -3,10 +3,10 @@ import { routerReducer } from 'react-router-redux';
import
ui
from
'
./ui
'
;
import
{
facilities
}
from
'
./api
'
const
reducers
=
combineReducers
({
router
:
routerReducer
,
ui
,
facilities
,
const
reducers
=
(
state
=
{},
action
)
=>
({
router
:
routerReducer
(
state
.
router
,
action
)
,
ui
:
ui
(
state
.
ui
,
action
)
,
facilities
:
facilities
(
state
.
facilities
,
action
,
state
.
ui
)
,
})
export
default
reducers
;
src/styles/components/facilityStatus.scss
View file @
78966b20
...
...
@@ -5,7 +5,7 @@
border
:
1
.5px
solid
;
border-radius
:
3px
;
padding
:
5px
;
font-weight
:
bold
!
important
;
//
font-weight: bold !important;
&
.facility-status-closed
{
color
:
white
;
...
...
src/styles/containers/layout.scss
View file @
78966b20
...
...
@@ -31,7 +31,7 @@
.layout-sidebar-toggle-btn
{
width
:
24px
;
height
:
48
px
;
height
:
54
px
;
position
:
absolute
;
top
:
16px
;
right
:
-1px
;
...
...
@@ -44,8 +44,9 @@
.layout-arrow-icon
{
position
:
absolute
;
top
:
1
2
px
;
top
:
1
6
px
;
right
:
0
;
color
:rgba
(
0
,
0
,
0
,
0
.54
)
;
width
:
24px
!
important
;
height
:
24px
!
important
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment