Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
f573ac5a
Commit
f573ac5a
authored
Jan 06, 2017
by
Piotr Gawron
Browse files
selected background overlay is stored in JS session
parent
e45713db
Changes
8
Hide whitespace changes
Inline
Side-by-side
frontend-js/src/main/js/ServerConnector.js
View file @
f573ac5a
...
...
@@ -49,13 +49,6 @@ ServerConnector.lastActualization = 0;
ServerConnector
.
_customMap
=
null
;
/**
* Set layout that is currently browsed for {@link CustomMap} on the server
* side.
*/
ServerConnector
.
setSelectedLayout
=
function
(
value
)
{
document
.
getElementById
(
ServerConnector
.
formIdentifier
+
'
:selectedLayout
'
).
value
=
""
+
value
;
};
/**
* Sets list of layouts visualized by javascript.
*/
...
...
@@ -63,17 +56,6 @@ ServerConnector.setVisibleLayouts = function(value) {
document
.
getElementById
(
ServerConnector
.
formIdentifier
+
'
:visibleLayouts
'
).
value
=
value
;
};
/**
* Get layout of the {@link CustomMap} which was last browsed.
*/
ServerConnector
.
getSelectedLayout
=
function
()
{
var
result
=
document
.
getElementById
(
ServerConnector
.
formIdentifier
+
'
:selectedLayout
'
).
value
;
if
(
result
===
undefined
)
{
result
=
null
;
}
return
result
;
};
/**
* Sends data about coordinates/zoom level etc. to the server. Method checks if
* the transmition is not done to often (at most once per second)
...
...
frontend-js/src/main/js/SessionData.js
View file @
f573ac5a
...
...
@@ -29,6 +29,18 @@ SessionData.prototype.setShowComments = function(value) {
Cookies
.
set
(
key
,
value
+
""
);
};
SessionData
.
prototype
.
getSelectedBackgroundOverlay
=
function
()
{
var
key
=
this
.
getKey
(
SessionObjectType
.
SELECTED_BACKGROUND_OVERLAY
);
return
Cookies
.
get
(
key
);
};
SessionData
.
prototype
.
setSelectedBackgroundOverlay
=
function
(
value
)
{
var
key
=
this
.
getKey
(
SessionObjectType
.
SELECTED_BACKGROUND_OVERLAY
);
Cookies
.
set
(
key
,
value
+
""
);
};
SessionData
.
prototype
.
setZoomLevel
=
function
(
model
,
value
)
{
var
key
=
this
.
getKey
(
SessionObjectType
.
ZOOM_LEVEL
,
[
model
.
getId
()
]);
Cookies
.
set
(
key
,
value
+
""
);
...
...
frontend-js/src/main/js/SessionObjectType.js
View file @
f573ac5a
"
use strict
"
;
var
SessionObjectType
=
{
CENTER
:
"
CENTER
"
,
SHOW_COMMENT
:
"
SHOW_COMMENT
"
,
SELECTED_BACKGROUND_OVERLAY
:
"
SELECTED_BACKGROUND_OVERLAY
"
,
CENTER
:
"
CENTER
"
,
ZOOM_LEVEL
:
"
ZOOM_LEVEL
"
,
};
...
...
frontend-js/src/main/js/map/CustomMap.js
View file @
f573ac5a
...
...
@@ -723,13 +723,12 @@ CustomMap.prototype.createMapChangedCallbacks = function() {
// listener for changing type of layout
google
.
maps
.
event
.
addListener
(
this
.
getGoogleMap
(),
'
maptypeid_changed
'
,
function
()
{
ServerConnector
.
setSelectedLayout
(
customMapSelf
.
getGoogleMap
().
getMapTypeId
());
ServerConnector
.
actualizeParams
();
sessionData
.
setSelectedBackgroundOverlay
(
customMapSelf
.
getGoogleMap
().
getMapTypeId
());
});
// if we have type of layout stored in the session then restore it
var
mapType
=
ServerConnector
.
getSelectedLayout
();
if
(
mapType
!==
""
&&
mapType
!==
null
&&
mapType
!==
undefined
)
{
var
mapType
=
sessionData
.
getSelectedBackgroundOverlay
();
if
(
mapType
!==
undefined
)
{
this
.
openLayout
(
mapType
);
}
};
...
...
frontend-js/src/test/js/ServerConnector-mock.js
View file @
f573ac5a
...
...
@@ -11,7 +11,8 @@ var ServerConnectorMock = OriginalServerConnector;
ServerConnectorMock
.
init
=
function
()
{
this
.
_customMap
=
null
;
ServerConnectorMock
.
selectedLayout
=
null
;
this
.
_sessionData
=
undefined
;
ServerConnectorMock
.
listeners
=
[];
ServerConnectorMock
.
selectedPolygon
=
null
;
...
...
@@ -83,14 +84,6 @@ ServerConnectorMock.callListeners = function(type, param) {
}
};
ServerConnectorMock
.
setSelectedLayout
=
function
(
value
)
{
this
.
selectedLayout
=
value
;
};
ServerConnectorMock
.
getSelectedLayout
=
function
()
{
return
this
.
selectedLayout
;
};
ServerConnectorMock
.
setSelectedPolygon
=
function
(
value
)
{
this
.
selectedPolygon
=
value
;
};
...
...
frontend-js/src/test/js/minerva-test.js
View file @
f573ac5a
...
...
@@ -73,16 +73,16 @@ describe('minerva global', function() {
assert
.
ok
(
result
);
// input file is not available so it's the background
assert
.
equal
(
result
.
getSelectedLayouts
().
length
,
0
);
assert
.
equal
(
ServerConnector
.
getSe
lectedLayout
(),
"
cv
"
+
layoutId
);
assert
.
equal
(
ServerConnector
.
getSe
ssionData
(
project
).
getSelectedBackgroundOverlay
(),
"
cv
"
+
layoutId
);
assert
.
equal
(
logger
.
getWarnings
().
length
,
1
);
});
});
it
(
'
create with layout 2
'
,
function
()
{
var
project
=
helper
.
createProject
();
var
map
=
helper
.
createGoogleMap
();
var
layout
=
helper
.
createLayout
();
layout
.
setInputDataAvailable
(
true
);
// disable upload of the data from server
...
...
frontend-js/src/test/js/mocha-config.js
View file @
f573ac5a
"
use strict
"
;
var
Promise
=
require
(
"
bluebird
"
);
var
Cookies
=
require
(
'
js-cookie
'
);
// GLOBAL configuration
...
...
@@ -24,11 +25,25 @@ global.navigator = {
var
logger
=
require
(
'
./logger
'
);
function
removeCookies
(){
var
cookies
=
Cookies
.
get
();
for
(
var
cookie
in
cookies
)
{
Cookies
.
remove
(
cookie
);
}
}
beforeEach
(
function
()
{
Promise
.
longStackTraces
();
logger
.
flushBuffer
();
removeCookies
();
ServerConnector
.
init
();
ServerConnector
.
setToken
(
"
MOCK_TOKEN_ID
"
);
GuiConnector
.
init
();
global
.
testDiv
=
document
.
createElement
(
"
div
"
);
global
.
testDiv
.
id
=
"
test
"
;
document
.
body
.
appendChild
(
testDiv
);
...
...
@@ -37,10 +52,6 @@ beforeEach(function() {
global
.
dialogDiv
.
id
=
"
feedbackContent
"
;
document
.
body
.
appendChild
(
global
.
dialogDiv
);
ServerConnector
.
init
();
ServerConnector
.
setToken
(
"
MOCK_TOKEN_ID
"
);
GuiConnector
.
init
();
});
after
(
function
()
{
...
...
web/src/main/webapp/WEB-INF/components/map/map.xhtml
View file @
f573ac5a
...
...
@@ -38,7 +38,6 @@
<h:inputHidden
id=
"selectedDrugPolygon"
value=
"#{drugMB.polygon}"
/>
<p:remoteCommand
name=
"_actualizeParams"
actionListener=
"#{mapMB.actualizeParams}"
/>
<h:inputHidden
id=
"selectedLayout"
value=
"#{mapMB.topModelMapData.selectedLayout}"
/>
<h:panelGroup
layout=
"block"
id=
"submodelDialogGroup"
>
</h:panelGroup>
...
...
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