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
GéoContrib
Géocontrib Frontend
Commits
5184cfbd
Commit
5184cfbd
authored
3 years ago
by
Timothee P
Browse files
Options
Downloads
Patches
Plain Diff
stay on the same page or last after deleting many features & prevent undefined map
parent
fe00e054
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!424
version 3.1.0
,
!310
REDMINE_ISSUE-13296
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/views/feature/Feature_list.vue
+26
-16
26 additions, 16 deletions
src/views/feature/Feature_list.vue
with
26 additions
and
16 deletions
src/views/feature/Feature_list.vue
+
26
−
16
View file @
5184cfbd
...
...
@@ -339,13 +339,7 @@ export default {
},
pageNumbers
()
{
const
totalPages
=
Math
.
ceil
(
this
.
featuresCount
/
this
.
pagination
.
pagesize
);
return
[...
Array
(
totalPages
).
keys
()].
map
((
pageNumb
)
=>
{
++
pageNumb
;
return
pageNumb
;
});
return
this
.
createPagesArray
(
this
.
featuresCount
,
this
.
pagination
.
pagesize
);
},
},
...
...
@@ -476,17 +470,22 @@ export default {
},
deleteAllFeatureSelection
()
{
const
initialFeaturesCount
=
this
.
featuresCount
;
const
initialCurrentPage
=
this
.
pagination
.
currentPage
;
const
promises
=
this
.
checkedFeatures
.
map
(
(
feature_id
)
=>
this
.
DELETE_FEATURE
({
feature_id
,
noFeatureType
:
true
})
);
Promise
.
all
(
promises
).
then
((
response
)
=>
{
console
.
log
(
'
response
'
,
response
);
const
deletedFeaturesCount
=
response
.
reduce
((
acc
,
curr
)
=>
curr
.
status
===
204
?
acc
+=
1
:
acc
,
0
);
const
newFeaturesCount
=
initialFeaturesCount
-
deletedFeaturesCount
;
const
newPagesArray
=
this
.
createPagesArray
(
newFeaturesCount
,
this
.
pagination
.
pagesize
);
const
newLastPageNum
=
newPagesArray
[
newPagesArray
.
length
-
1
];
this
.
$store
.
commit
(
'
feature/UPDATE_CHECKED_FEATURES
'
,
[]);
// ? limit only to l
ast
p
age
if all its feature are deleted ?
this
.
pagination
=
{
...
initialPagination
};
//* reset initial pagination to avoid empty
last page
console
.
log
(
'
this.pagination
'
,
this
.
pagination
);
console
.
log
(
'
initialPagination
'
,
initialPagination
);
this
.
fetchPagedFeatures
();
if
(
initialCurrentPage
>
newL
ast
P
age
Num
)
{
//* if page doesn't exist anymore
this
.
toPage
(
newLastPageNum
);
//* go to new
last page
}
else
{
this
.
fetchPagedFeatures
(
);
}
})
.
catch
((
err
)
=>
console
.
error
(
err
));
this
.
toggleDeleteModal
();
...
...
@@ -547,8 +546,9 @@ export default {
featureAPI
.
getFeaturesBbox
(
this
.
projectSlug
,
queryParams
)
.
then
((
bbox
)
=>
{
if
(
bbox
)
{
mapUtil
.
getMap
().
fitBounds
(
bbox
,
{
padding
:
[
25
,
25
]
});
const
map
=
mapUtil
.
getMap
();
if
(
bbox
&&
map
)
{
map
.
fitBounds
(
bbox
,
{
padding
:
[
25
,
25
]
});
}
});
},
...
...
@@ -587,7 +587,7 @@ export default {
fetchPagedFeatures
(
newUrl
)
{
let
url
=
`
${
this
.
API_BASE_URL
}
projects/
${
this
.
projectSlug
}
/feature-paginated/?output=geojson&limit=
${
this
.
pagination
.
pagesize
}
&offset=
${
this
.
pagination
.
start
}
`
;
//* if receiving next & previous url
//* if receiving next & previous url
(// todo : might be not used anymore, to check)
if
(
newUrl
&&
typeof
newUrl
===
'
string
'
)
{
//newUrl = newUrl.replace("8000", "8010"); //* for dev uncomment to use proxy link
url
=
newUrl
;
...
...
@@ -622,6 +622,16 @@ export default {
//* Pagination for table *//
createPagesArray
(
featuresCount
,
pagesize
)
{
const
totalPages
=
Math
.
ceil
(
featuresCount
/
pagesize
);
return
[...
Array
(
totalPages
).
keys
()].
map
((
pageNumb
)
=>
{
++
pageNumb
;
return
pageNumb
;
});
},
handlePageChange
(
page
)
{
if
(
page
===
'
next
'
)
{
this
.
toNextPage
();
...
...
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