Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Géocontrib Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
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
externe Matthieu
Géocontrib Frontend
Commits
17287c2a
Commit
17287c2a
authored
3 years ago
by
Timothee P
Browse files
Options
Downloads
Patches
Plain Diff
add back code for geojson on map
parent
c1336d8d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/views/feature/Feature_list.vue
+89
-46
89 additions, 46 deletions
src/views/feature/Feature_list.vue
with
89 additions
and
46 deletions
src/views/feature/Feature_list.vue
+
89
−
46
View file @
17287c2a
...
@@ -22,7 +22,7 @@
...
@@ -22,7 +22,7 @@
>
<i
class=
"map fitted icon"
></i
>
<i
class=
"map fitted icon"
></i
></a>
></a>
<a
<a
@
click=
"show
Map = fals
e"
@
click=
"show
Tabl
e"
:class=
"['item no-margin',
{ active: !showMap }]"
:class=
"['item no-margin',
{ active: !showMap }]"
data-tab="list"
data-tab="list"
data-tooltip="Liste"
data-tooltip="Liste"
...
@@ -30,7 +30,10 @@
...
@@ -30,7 +30,10 @@
></a>
></a>
<div
class=
"item"
>
<div
class=
"item"
>
<h4>
<h4>
{{
featuresCount
}}
signalement
{{
featuresCount
>
1
?
"
s
"
:
""
}}
<!--
{{
featuresCount
}}
signalement
{{
featuresCount
>
1
?
"
s
"
:
""
}}
-->
{{
geojsonFeatures
.
length
}}
signalement
{{
geojsonFeatures
.
length
>
1
?
"
s
"
:
""
}}
</h4>
</h4>
</div>
</div>
...
@@ -119,7 +122,7 @@
...
@@ -119,7 +122,7 @@
type=
"text"
type=
"text"
name=
"title"
name=
"title"
v-model=
"form.title"
v-model=
"form.title"
@
input=
"
update
Features"
@
input=
"
fetchPaged
Features"
/>
/>
<button
<button
type=
"button"
type=
"button"
...
@@ -145,7 +148,7 @@
...
@@ -145,7 +148,7 @@
<FeatureListTable
<FeatureListTable
v-show=
"!showMap"
v-show=
"!showMap"
v-on:update:page=
"handlePageChange"
v-on:update:page=
"handlePageChange"
:geojsonFeatures=
"geojsonFeatures"
:geojsonFeatures=
"geojsonFeatures
Paginated
"
:checkedFeatures.sync=
"checkedFeatures"
:checkedFeatures.sync=
"checkedFeatures"
:featuresCount=
"featuresCount"
:featuresCount=
"featuresCount"
:pagination=
"pagination"
:pagination=
"pagination"
...
@@ -244,6 +247,7 @@ export default {
...
@@ -244,6 +247,7 @@ export default {
},
},
geojsonFeatures
:
[],
geojsonFeatures
:
[],
geojsonFeaturesPaginated
:
[],
baseUrl
:
this
.
$store
.
state
.
configuration
.
BASE_URL
,
baseUrl
:
this
.
$store
.
state
.
configuration
.
BASE_URL
,
map
:
null
,
map
:
null
,
zoom
:
null
,
zoom
:
null
,
...
@@ -264,6 +268,7 @@ export default {
...
@@ -264,6 +268,7 @@ export default {
next
:
null
,
next
:
null
,
showMap
:
true
,
showMap
:
true
,
showAddFeature
:
false
,
showAddFeature
:
false
,
paginatedFeaturesDone
:
true
,
};
};
},
},
...
@@ -296,6 +301,14 @@ export default {
...
@@ -296,6 +301,14 @@ export default {
},
},
methods
:
{
methods
:
{
showTable
()
{
if
(
this
.
paginatedFeaturesDone
)
{
this
.
fetchPagedFeatures
();
this
.
paginatedFeaturesDone
=
false
;
}
this
.
showMap
=
false
;
},
modalAllDelete
()
{
modalAllDelete
()
{
this
.
modalAllDeleteOpen
=
!
this
.
modalAllDeleteOpen
;
this
.
modalAllDeleteOpen
=
!
this
.
modalAllDeleteOpen
;
},
},
...
@@ -311,7 +324,8 @@ export default {
...
@@ -311,7 +324,8 @@ export default {
project_slug
:
this
.
project
.
slug
,
project_slug
:
this
.
project
.
slug
,
})
})
.
then
(()
=>
{
.
then
(()
=>
{
this
.
updateFeatures
();
this
.
fetchPagedFeatures
();
this
.
getNloadGeojsonFeatures
();
this
.
checkedFeatures
.
splice
(
feature_id
);
this
.
checkedFeatures
.
splice
(
feature_id
);
});
});
}
}
...
@@ -379,7 +393,8 @@ export default {
...
@@ -379,7 +393,8 @@ export default {
});
});
// --------- End sidebar events ----------
// --------- End sidebar events ----------
this
.
updateFeatures
();
//this.fetchPagedFeatures();
this
.
getNloadGeojsonFeatures
();
setTimeout
(()
=>
{
setTimeout
(()
=>
{
const
project_id
=
this
.
$route
.
params
.
slug
.
split
(
"
-
"
)[
0
];
const
project_id
=
this
.
$route
.
params
.
slug
.
split
(
"
-
"
)[
0
];
...
@@ -394,6 +409,62 @@ export default {
...
@@ -394,6 +409,62 @@ export default {
},
1000
);
},
1000
);
},
},
getNloadGeojsonFeatures
()
{
console
.
log
(
"
getNloadGeojsonFeatures
"
);
const
url
=
`
${
this
.
$store
.
state
.
configuration
.
VUE_APP_DJANGO_API_BASE
}
projects/
${
this
.
$route
.
params
.
slug
}
/feature/?output=geojson`
;
this
.
$store
.
commit
(
"
DISPLAY_LOADER
"
,
"
Récupération des signalements en cours...
"
);
axios
.
get
(
url
)
.
then
((
response
)
=>
{
console
.
log
(
response
);
if
(
response
.
status
===
200
&&
response
.
data
.
features
.
length
>
0
)
{
this
.
geojsonFeatures
=
response
.
data
.
features
;
this
.
loadFeatures
();
}
this
.
$store
.
commit
(
"
DISCARD_LOADER
"
);
})
.
catch
((
error
)
=>
{
this
.
$store
.
commit
(
"
DISCARD_LOADER
"
);
throw
error
;
});
},
loadFeatures
()
{
const
urlParams
=
new
URLSearchParams
(
window
.
location
.
search
);
const
featureType
=
urlParams
.
get
(
"
feature_type
"
);
const
featureStatus
=
urlParams
.
get
(
"
status
"
);
const
featureTitle
=
urlParams
.
get
(
"
title
"
);
this
.
featureGroup
=
mapUtil
.
addFeatures
(
this
.
geojsonFeatures
,
{
featureType
,
featureStatus
,
featureTitle
,
},
true
,
this
.
feature_types
);
// Fit the map to bound only if no initial zoom and center are defined
if
(
(
this
.
lat
===
""
||
this
.
lng
===
""
||
this
.
zoom
===
""
)
&&
this
.
geojsonFeatures
.
length
>
0
)
{
mapUtil
.
getMap
()
.
fitBounds
(
this
.
featureGroup
.
getBounds
(),
{
padding
:
[
25
,
25
]
});
}
this
.
form
.
type
.
choices
=
[
//* converting Set to an Array with spread "..."
...
new
Set
(
this
.
geojsonFeatures
.
map
((
el
)
=>
el
.
properties
.
feature_type
.
title
)
),
//* use Set to eliminate duplicate values
];
},
//* Paginated Features for table *//
getFeatureTypeSlug
(
title
)
{
getFeatureTypeSlug
(
title
)
{
const
featureType
=
this
.
feature_types
.
find
((
el
)
=>
el
.
title
===
title
);
const
featureType
=
this
.
feature_types
.
find
((
el
)
=>
el
.
title
===
title
);
return
featureType
?
featureType
.
slug
:
null
;
return
featureType
?
featureType
.
slug
:
null
;
...
@@ -458,14 +529,16 @@ export default {
...
@@ -458,14 +529,16 @@ export default {
updateTypeFeatures
(
filterValue
)
{
updateTypeFeatures
(
filterValue
)
{
//* only update:selection custom event can trigger the filter update,
//* only update:selection custom event can trigger the filter update,
//* but it happens before the value is updated, thus using selected value from event to update query
//* but it happens before the value is updated, thus using selected value from event to update query
this
.
update
Features
({
filterType
:
"
featureType
"
,
filterValue
});
this
.
fetchPaged
Features
({
filterType
:
"
featureType
"
,
filterValue
});
},
},
updateStatusFeatures
(
filterValue
)
{
updateStatusFeatures
(
filterValue
)
{
this
.
update
Features
({
filterType
:
"
status
"
,
filterValue
});
this
.
fetchPaged
Features
({
filterType
:
"
status
"
,
filterValue
});
},
},
updateFeatures
(
params
)
{
fetchPagedFeatures
(
params
)
{
this
.
onFilterChange
();
//* temporary, use paginated event to watch change in filters, to modify geojson on map
//* replace function calls in watcher and on input
let
url
=
`
${
this
.
API_BASE_URL
}
projects/
${
this
.
$route
.
params
.
slug
}
/feature-paginated/?output=geojson&limit=
${
this
.
pagination
.
pagesize
}
&offset=
${
this
.
pagination
.
start
}
`
;
let
url
=
`
${
this
.
API_BASE_URL
}
projects/
${
this
.
$route
.
params
.
slug
}
/feature-paginated/?output=geojson&limit=
${
this
.
pagination
.
pagesize
}
&offset=
${
this
.
pagination
.
start
}
`
;
if
(
params
)
{
if
(
params
)
{
...
@@ -492,10 +565,10 @@ export default {
...
@@ -492,10 +565,10 @@ export default {
this
.
featuresCount
=
response
.
data
.
count
;
this
.
featuresCount
=
response
.
data
.
count
;
this
.
previous
=
response
.
data
.
previous
;
this
.
previous
=
response
.
data
.
previous
;
this
.
next
=
response
.
data
.
next
;
this
.
next
=
response
.
data
.
next
;
this
.
geojsonFeatures
=
response
.
data
.
results
.
features
;
this
.
geojsonFeatures
Paginated
=
response
.
data
.
results
.
features
;
//if (response.data.results.features.length > 0) {
//if (response.data.results.features.length > 0) {
this
.
loadFeatures
();
//
this.loadFeatures();
this
.
onFilterChange
();
//
this.onFilterChange();
//}
//}
}
}
this
.
$store
.
commit
(
"
DISCARD_LOADER
"
);
this
.
$store
.
commit
(
"
DISCARD_LOADER
"
);
...
@@ -506,37 +579,7 @@ export default {
...
@@ -506,37 +579,7 @@ export default {
});
});
},
},
loadFeatures
()
{
//* Pagination for table *//
const
urlParams
=
new
URLSearchParams
(
window
.
location
.
search
);
const
featureType
=
urlParams
.
get
(
"
feature_type
"
);
const
featureStatus
=
urlParams
.
get
(
"
status
"
);
const
featureTitle
=
urlParams
.
get
(
"
title
"
);
this
.
featureGroup
=
mapUtil
.
addFeatures
(
this
.
geojsonFeatures
,
{
featureType
,
featureStatus
,
featureTitle
,
},
true
,
this
.
feature_types
);
// Fit the map to bound only if no initial zoom and center are defined
if
(
(
this
.
lat
===
""
||
this
.
lng
===
""
||
this
.
zoom
===
""
)
&&
this
.
geojsonFeatures
.
length
>
0
)
{
mapUtil
.
getMap
()
.
fitBounds
(
this
.
featureGroup
.
getBounds
(),
{
padding
:
[
25
,
25
]
});
}
this
.
form
.
type
.
choices
=
[
//* converting Set to an Array with spread "..."
...
new
Set
(
this
.
geojsonFeatures
.
map
((
el
)
=>
el
.
properties
.
feature_type
.
title
)
),
//* use Set to eliminate duplicate values
];
},
handlePageChange
(
page
)
{
handlePageChange
(
page
)
{
if
(
page
===
"
next
"
)
{
if
(
page
===
"
next
"
)
{
...
@@ -555,7 +598,7 @@ export default {
...
@@ -555,7 +598,7 @@ export default {
this
.
pagination
.
start
+=
toAddOrRemove
;
this
.
pagination
.
start
+=
toAddOrRemove
;
this
.
pagination
.
end
+=
toAddOrRemove
;
this
.
pagination
.
end
+=
toAddOrRemove
;
this
.
pagination
.
currentPage
=
pageNumber
;
this
.
pagination
.
currentPage
=
pageNumber
;
this
.
update
Features
();
this
.
fetchPaged
Features
();
},
},
toPreviousPage
()
{
toPreviousPage
()
{
...
@@ -565,7 +608,7 @@ export default {
...
@@ -565,7 +608,7 @@ export default {
this
.
pagination
.
end
-=
this
.
pagination
.
pagesize
;
this
.
pagination
.
end
-=
this
.
pagination
.
pagesize
;
this
.
pagination
.
currentPage
-=
1
;
this
.
pagination
.
currentPage
-=
1
;
}
}
this
.
update
Features
(
this
.
previous
);
this
.
fetchPaged
Features
(
this
.
previous
);
}
}
},
},
...
@@ -576,7 +619,7 @@ export default {
...
@@ -576,7 +619,7 @@ export default {
this
.
pagination
.
end
+=
this
.
pagination
.
pagesize
;
this
.
pagination
.
end
+=
this
.
pagination
.
pagesize
;
this
.
pagination
.
currentPage
+=
1
;
this
.
pagination
.
currentPage
+=
1
;
}
}
this
.
update
Features
(
this
.
next
);
this
.
fetchPaged
Features
(
this
.
next
);
}
}
},
},
},
},
...
...
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