Skip to content
Snippets Groups Projects
Commit 6ef5001c authored by Sébastien DA ROCHA's avatar Sébastien DA ROCHA :bicyclist:
Browse files

Merge branch 'redmined-issues/11951' into 'develop'

parents 96490557 a2e83fc1
No related branches found
No related tags found
No related merge requests found
...@@ -71,8 +71,7 @@ ...@@ -71,8 +71,7 @@
type="checkbox" type="checkbox"
:id="feature.id" :id="feature.id"
:value="feature.id" :value="feature.id"
v-model="checkedFeatures" v-model="checked"
:checked="checkedFeatures[feature.id]"
/> />
<label></label> <label></label>
</div> </div>
...@@ -280,6 +279,15 @@ export default { ...@@ -280,6 +279,15 @@ export default {
return arr; return arr;
}, },
checked: {
get() {
return this.checkedFeatures;
},
set(newChecked) {
this.$store.commit("feature/UPDATE_CHECKED_FEATURES", newChecked);
},
},
displayedPageEnd() { displayedPageEnd() {
return this.filteredFeatures.length <= this.pagination.end return this.filteredFeatures.length <= this.pagination.end
? this.filteredFeatures.length ? this.filteredFeatures.length
......
...@@ -14,10 +14,11 @@ const feature = { ...@@ -14,10 +14,11 @@ const feature = {
attachmentFormset: [], attachmentFormset: [],
attachmentsToDelete: [], attachmentsToDelete: [],
attachmentsToPut: [], attachmentsToPut: [],
linkedFormset: [], checkedFeatures: [],
extra_form: [],
features: [], features: [],
form: null, form: null,
extra_form: [], linkedFormset: [],
linked_features: [], linked_features: [],
}, },
mutations: { mutations: {
...@@ -79,6 +80,9 @@ const feature = { ...@@ -79,6 +80,9 @@ const feature = {
REMOVE_ATTACHMENTS_ID_TO_DELETE(state, attachementId) { REMOVE_ATTACHMENTS_ID_TO_DELETE(state, attachementId) {
state.attachmentsToDelete = state.attachmentsToDelete.filter(el => el !== attachementId); state.attachmentsToDelete = state.attachmentsToDelete.filter(el => el !== attachementId);
}, },
UPDATE_CHECKED_FEATURES(state, checkedFeatures) {
state.checkedFeatures = checkedFeatures;
}
}, },
getters: { getters: {
}, },
...@@ -137,9 +141,9 @@ const feature = { ...@@ -137,9 +141,9 @@ const feature = {
if (routeName === "editer-signalement") { if (routeName === "editer-signalement") {
axios axios
.put(`${rootState.configuration.VUE_APP_DJANGO_API_BASE}features/${state.form.feature_id}/?` + .put(`${rootState.configuration.VUE_APP_DJANGO_API_BASE}features/${state.form.feature_id}/?` +
`feature_type__slug=${rootState.feature_type.current_feature_type_slug}` + `feature_type__slug=${rootState.feature_type.current_feature_type_slug}` +
`&project__slug=${rootState.project_slug}` `&project__slug=${rootState.project_slug}`
, geojson) , geojson)
.then((response) => { .then((response) => {
if (response.status === 200 && response.data) { if (response.status === 200 && response.data) {
if (state.attachmentFormset.length > 0 || state.linkedFormset.length > 0) { if (state.attachmentFormset.length > 0 || state.linkedFormset.length > 0) {
...@@ -189,7 +193,7 @@ const feature = { ...@@ -189,7 +193,7 @@ const feature = {
console.error(error); console.error(error);
return error return error
}); });
} }
} }
...@@ -203,7 +207,7 @@ const feature = { ...@@ -203,7 +207,7 @@ const feature = {
if (attachment.title) if (attachment.title)
data['info'] = attachment.info data['info'] = attachment.info
formdataToUpdate.append("data", JSON.stringify(data)); formdataToUpdate.append("data", JSON.stringify(data));
let payload ={ let payload = {
'attachmentsId': attachment.id, 'attachmentsId': attachment.id,
'featureId': featureId, 'featureId': featureId,
'formdataToUpdate': formdataToUpdate 'formdataToUpdate': formdataToUpdate
...@@ -213,7 +217,7 @@ const feature = { ...@@ -213,7 +217,7 @@ const feature = {
} }
function deleteAttachement(attachmentsId, featureId) { function deleteAttachement(attachmentsId, featureId) {
let payload ={ let payload = {
'attachmentsId': attachmentsId, 'attachmentsId': attachmentsId,
'featureId': featureId 'featureId': featureId
} }
...@@ -224,7 +228,7 @@ const feature = { ...@@ -224,7 +228,7 @@ const feature = {
...state.attachmentFormset.map((attachment) => postAttachement(attachment)), ...state.attachmentFormset.map((attachment) => postAttachement(attachment)),
...state.attachmentsToPut.map((attachments) => putAttachement(attachments, featureId)), ...state.attachmentsToPut.map((attachments) => putAttachement(attachments, featureId)),
...state.attachmentsToDelete.map((attachmentsId) => deleteAttachement(attachmentsId, featureId)) ...state.attachmentsToDelete.map((attachmentsId) => deleteAttachement(attachmentsId, featureId))
] ]
); );
state.attachmentsToDelete = [] state.attachmentsToDelete = []
state.attachmentsToPut = [] state.attachmentsToPut = []
...@@ -280,8 +284,8 @@ const feature = { ...@@ -280,8 +284,8 @@ const feature = {
DELETE_FEATURE({ state, rootState }, feature_id) { DELETE_FEATURE({ state, rootState }, feature_id) {
console.log("Deleting feature:", feature_id, state) console.log("Deleting feature:", feature_id, state)
const url = `${rootState.configuration.VUE_APP_DJANGO_API_BASE}features/${feature_id}/?` + const url = `${rootState.configuration.VUE_APP_DJANGO_API_BASE}features/${feature_id}/?` +
`feature_type__slug=${rootState.feature_type.current_feature_type_slug}` + `feature_type__slug=${rootState.feature_type.current_feature_type_slug}` +
`&project__slug=${rootState.project_slug}`; `&project__slug=${rootState.project_slug}`;
return axios return axios
.delete(url) .delete(url)
.then((response) => response) .then((response) => response)
......
...@@ -37,8 +37,9 @@ ...@@ -37,8 +37,9 @@
> >
<i class="inverted grey pencil alternate icon"></i> <i class="inverted grey pencil alternate icon"></i>
</router-link> </router-link>
<!-- (permissions && permissions.can_delete_feature) || -->
<a <a
v-if="permissions && permissions.can_delete_feature" v-if="isFeatureCreator"
@click="isCanceling = true" @click="isCanceling = true"
id="feature-delete" id="feature-delete"
class="ui button button-hover-red" class="ui button button-hover-red"
...@@ -101,7 +102,7 @@ ...@@ -101,7 +102,7 @@
v-if="feature.status" v-if="feature.status"
:class="getIconLabelStatus(feature.status, 'icon')" :class="getIconLabelStatus(feature.status, 'icon')"
></i> ></i>
{{ getIconLabelStatus(feature.status, 'label') }} {{ getIconLabelStatus(feature.status, "label") }}
</td> </td>
</tr> </tr>
<tr> <tr>
...@@ -417,7 +418,6 @@ export default { ...@@ -417,7 +418,6 @@ export default {
const result = this.$store.state.feature.features.find( const result = this.$store.state.feature.features.find(
(el) => el.feature_id === this.$route.params.slug_signal (el) => el.feature_id === this.$route.params.slug_signal
); );
console.log("result", result);
return result; return result;
}, },
...@@ -438,23 +438,19 @@ export default { ...@@ -438,23 +438,19 @@ export default {
}, },
methods: { methods: {
getIconLabelStatus(status, type){ getIconLabelStatus(status, type) {
if (status === 'archived') if (status === "archived")
if (type == 'icon') if (type == "icon") return "grey archive icon";
return "grey archive icon"; else return "Archivé";
else return 'Archivé'; else if (status === "pending")
else if (status === 'pending') if (type == "icon") return "teal hourglass outline icon";
if (type == 'icon') else return "En attente de publication";
return "teal hourglass outline icon"; else if (status === "published")
else return 'En attente de publication'; if (type == "icon") return "olive check icon";
else if (status === 'published') else return "Publié";
if (type == 'icon') else if (status === "draft")
return "olive check icon"; if (type == "icon") return "orange pencil alternate icon";
else return 'Publié'; else return "Brouillon";
else if (status === 'draft')
if (type == 'icon')
return "orange pencil alternate icon";
else return 'Brouillon';
}, },
pushNgo(link) { pushNgo(link) {
this.$router.push({ this.$router.push({
...@@ -533,7 +529,10 @@ export default { ...@@ -533,7 +529,10 @@ export default {
.dispatch("feature/DELETE_FEATURE", this.feature.feature_id) .dispatch("feature/DELETE_FEATURE", this.feature.feature_id)
.then((response) => { .then((response) => {
if (response.status === 204) { if (response.status === 204) {
this.$store.dispatch("feature/GET_PROJECT_FEATURES", this.$route.params.slug); this.$store.dispatch(
"feature/GET_PROJECT_FEATURES",
this.$route.params.slug
);
this.goBackToProject(); this.goBackToProject();
} }
}); });
...@@ -599,7 +598,9 @@ export default { ...@@ -599,7 +598,9 @@ export default {
if (feature) { if (feature) {
const currentFeature = [feature]; const currentFeature = [feature];
const featureGroup = mapUtil.addFeatures(currentFeature); const featureGroup = mapUtil.addFeatures(currentFeature);
mapUtil.getMap().fitBounds(featureGroup.getBounds(), { padding: [25, 25] }); mapUtil
.getMap()
.fitBounds(featureGroup.getBounds(), { padding: [25, 25] });
} }
}) })
.catch((error) => { .catch((error) => {
......
...@@ -199,7 +199,6 @@ export default { ...@@ -199,7 +199,6 @@ export default {
data() { data() {
return { return {
modalAllDeleteOpen: false, modalAllDeleteOpen: false,
checkedFeatures: [],
form: { form: {
type: { type: {
selected: null, selected: null,
...@@ -249,7 +248,7 @@ export default { ...@@ -249,7 +248,7 @@ export default {
computed: { computed: {
...mapGetters(["project", "permissions"]), ...mapGetters(["project", "permissions"]),
...mapState(["user"]), ...mapState(["user"]),
...mapState("feature", ["features"]), ...mapState("feature", ["features", "checkedFeatures"]),
...mapState("feature_type", ["feature_types"]), ...mapState("feature_type", ["feature_types"]),
baseMaps() { baseMaps() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment