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
0cb60528
Commit
0cb60528
authored
3 years ago
by
Timothee P
Browse files
Options
Downloads
Patches
Plain Diff
fill feature_edit linkedForm with existing linked_features (adapt data for dropdown with object
parent
54050631
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/components/feature/FeatureLinkedForm.vue
+78
-31
78 additions, 31 deletions
src/components/feature/FeatureLinkedForm.vue
src/store/modules/feature.js
+10
-7
10 additions, 7 deletions
src/store/modules/feature.js
src/views/feature/Feature_edit.vue
+24
-4
24 additions, 4 deletions
src/views/feature/Feature_edit.vue
with
112 additions
and
42 deletions
src/components/feature/FeatureLinkedForm.vue
+
78
−
31
View file @
0cb60528
...
...
@@ -54,12 +54,55 @@ export default {
Dropdown
,
},
data
()
{
return
{
form
:
{
errors
:
null
,
relation_type
:
{
errors
:
null
,
id_for_label
:
"
relation_type
"
,
field
:
{
choices
:
[
"
Doublon
"
,
"
Remplace
"
,
"
Est remplacé par
"
,
"
Dépend de
"
],
},
html_name
:
"
relation_type
"
,
label
:
"
Type de liaison
"
,
value
:
"
Doublon
"
,
},
feature_to
:
{
errors
:
null
,
id_for_label
:
"
feature_to
"
,
field
:
{
max_length
:
30
,
},
html_name
:
"
feature_to
"
,
label
:
"
Signalement lié
"
,
value
:
{
name
:
""
,
value
:
""
,
},
},
},
};
},
computed
:
{
featureOptions
:
function
()
{
return
this
.
features
.
map
(
(
el
)
=>
`
${
el
.
title
}
(
${
el
.
display_creator
}
-
${
el
.
created_on
}
)`
);
return
this
.
features
.
filter
(
(
el
)
=>
el
.
feature_type
.
slug
===
this
.
$route
.
params
.
slug_type_signal
&&
//* filter only for the same feature
el
.
feature_id
!==
this
.
$route
.
params
.
slug_signal
//* filter out current feature
)
.
map
((
el
)
=>
{
return
{
name
:
`
${
el
.
title
}
(
${
el
.
display_creator
}
-
${
this
.
formatDate
(
el
.
created_on
)}
)`
,
value
:
el
.
feature_id
,
};
});
},
selected_relation_type
:
{
// getter
get
()
{
...
...
@@ -71,10 +114,11 @@ export default {
this
.
updateStore
();
},
},
selected_feature_to
:
{
// getter
get
()
{
return
this
.
form
.
feature_to
.
value
;
return
this
.
form
.
feature_to
.
value
.
name
;
},
// setter
set
(
newValue
)
{
...
...
@@ -84,44 +128,33 @@ export default {
},
},
data
()
{
return
{
form
:
{
errors
:
null
,
relation_type
:
{
errors
:
null
,
id_for_label
:
"
relation_type
"
,
field
:
{
choices
:
[
"
Doublon
"
,
"
Remplace
"
,
"
Est remplacé par
"
,
"
Dépend de
"
],
},
html_name
:
"
relation_type
"
,
label
:
"
Type de liaison
"
,
value
:
"
Doublon
"
,
},
feature_to
:
{
errors
:
null
,
id_for_label
:
"
feature_to
"
,
field
:
{
max_length
:
30
,
},
html_name
:
"
feature_to
"
,
label
:
"
Signalement lié
"
,
value
:
""
,
},
},
};
watch
:
{
featureOptions
(
newValue
)
{
if
(
newValue
)
{
this
.
getExistingFeature_to
(
newValue
);
}
},
},
methods
:
{
formatDate
(
value
)
{
let
date
=
new
Date
(
value
);
date
=
date
.
toLocaleString
().
replace
(
"
,
"
,
""
);
return
date
.
substr
(
0
,
date
.
length
-
3
);
//* quick & dirty way to remove seconds from date
},
remove_linked_formset
()
{
this
.
$store
.
commit
(
"
feature/REMOVE_LINKED_FORM
"
,
this
.
linkedForm
.
dataKey
);
},
updateStore
()
{
this
.
$store
.
commit
(
"
feature/UPDATE_LINKED_FORM
"
,
{
dataKey
:
this
.
linkedForm
.
dataKey
,
relation_type
:
this
.
form
.
relation_type
.
value
,
feature_to
:
this
.
form
.
feature_to
.
value
,
feature_to
:
this
.
form
.
feature_to
.
value
.
value
,
});
},
checkForm
()
{
if
(
this
.
form
.
feature_to
.
value
===
""
)
{
this
.
form
.
errors
=
[
...
...
@@ -135,6 +168,20 @@ export default {
this
.
form
.
errors
=
[];
return
true
;
},
getExistingFeature_to
(
featureOptions
)
{
const
feature_to
=
featureOptions
.
find
(
(
el
)
=>
el
.
value
===
this
.
linkedForm
.
feature_to
.
feature_id
);
console
.
log
(
featureOptions
,
this
.
linkedForm
.
feature_to
.
feature_id
,
feature_to
);
if
(
feature_to
)
{
this
.
form
.
feature_to
.
value
=
feature_to
;
}
},
},
};
</
script
>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/store/modules/feature.js
+
10
−
7
View file @
0cb60528
...
...
@@ -47,8 +47,8 @@ const feature = {
CLEAR_ATTACHMENT_FORM
(
state
)
{
state
.
attachmentFormset
=
[];
},
ADD_LINKED_FORM
(
state
,
dataKey
)
{
state
.
linkedFormset
=
[...
state
.
linkedFormset
,
{
dataKey
}
];
ADD_LINKED_FORM
(
state
,
linkedFormset
)
{
state
.
linkedFormset
=
[...
state
.
linkedFormset
,
linkedFormset
];
},
UPDATE_LINKED_FORM
(
state
,
payload
)
{
const
index
=
state
.
linkedFormset
.
findIndex
((
el
)
=>
el
.
dataKey
===
payload
.
dataKey
);
...
...
@@ -60,6 +60,9 @@ const feature = {
SET_LINKED_FEATURES
(
state
,
payload
)
{
state
.
linked_features
=
payload
;
},
CLEAR_LINKED_FORM
(
state
)
{
state
.
linkedFormset
=
[];
},
},
getters
:
{
},
...
...
@@ -159,11 +162,11 @@ const feature = {
}
},
/* GET_FEATURE_LINK({ commit }, featureId) {
featureAPI
.getlinked_features(featureId)
.then((data) => commit("SET_FEATURE_LINKS", data));
} */
/* GET_FEATURE_LINK({ commit }, featureId) {
featureAPI
.getlinked_features(featureId)
.then((data) => commit("SET_FEATURE_LINKS", data));
} */
//DELETE_FEATURE({ state }, feature_slug) {
//console.log("Deleting feature:", feature_slug, state)
...
...
This diff is collapsed.
Click to expand it.
src/views/feature/Feature_edit.vue
+
24
−
4
View file @
0cb60528
...
...
@@ -323,6 +323,7 @@ export default {
"
linkedFormset
"
,
"
features
"
,
"
extra_form
"
,
"
linked_features
"
,
]),
...
mapGetters
(
"
feature_type
"
,
[
"
feature_type
"
]),
...
...
@@ -460,7 +461,6 @@ export default {
});
// * create an object with the counter in store
this
.
attachmentDataKey
+=
1
;
// * increment counter for key in v-for
},
addExistingAttachementFormset
(
attachementFormset
)
{
for
(
const
attachment
of
attachementFormset
)
{
console
.
log
(
"
attachment
"
,
attachment
);
...
...
@@ -476,9 +476,22 @@ export default {
},
add_linked_formset
()
{
this
.
$store
.
commit
(
"
feature/ADD_LINKED_FORM
"
,
this
.
linkedDataKey
);
// * create an object with the counter in store
this
.
$store
.
commit
(
"
feature/ADD_LINKED_FORM
"
,
{
dataKey
:
this
.
linkedDataKey
,
});
// * create an object with the counter in store
this
.
linkedDataKey
+=
1
;
// * increment counter for key in v-for
},
addExistingLinkedFormset
(
linkedFormset
)
{
for
(
const
linked
of
linkedFormset
)
{
console
.
log
(
"
linked
"
,
linked
);
this
.
$store
.
commit
(
"
feature/ADD_LINKED_FORM
"
,
{
dataKey
:
this
.
linkedDataKey
,
relation_type
:
linked
.
relation_type
,
feature_to
:
linked
.
feature_to
,
});
this
.
linkedDataKey
+=
1
;
}
},
updateStore
()
{
this
.
$store
.
commit
(
"
feature/UPDATE_FORM
"
,
{
...
...
@@ -837,11 +850,16 @@ export default {
},
getFeatureAttachments
()
{
// todo : mutualize in store with feature_detail.vue
featureAPI
.
getFeatureAttachments
(
this
.
$route
.
params
.
slug_signal
)
.
then
((
data
)
=>
this
.
addExistingAttachementFormset
(
data
));
},
getLinkedFeatures
()
{
featureAPI
.
getFeatureLinks
(
this
.
$route
.
params
.
slug_signal
)
.
then
((
data
)
=>
this
.
addExistingLinkedFormset
(
data
));
},
},
created
()
{
...
...
@@ -855,9 +873,11 @@ export default {
if
(
this
.
$route
.
params
.
slug_signal
)
{
this
.
getFeatureAttachments
();
this
.
getLinkedFeatures
();
}
else
{
//* be sure that previous
attachemnt
Formset ha
s
been cleared for creation
//* be sure that previous Formset ha
ve
been cleared for creation
this
.
$store
.
commit
(
"
feature/CLEAR_ATTACHMENT_FORM
"
);
this
.
$store
.
commit
(
"
feature/CLEAR_LINKED_FORM
"
);
}
},
...
...
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