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
b9bfe511
Commit
b9bfe511
authored
3 years ago
by
Timothee P
Browse files
Options
Downloads
Patches
Plain Diff
change endpoint and move fetch to component
parent
c70ab523
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/main.js
+0
-1
0 additions, 1 deletion
src/main.js
src/store/index.js
+2
-14
2 additions, 14 deletions
src/store/index.js
src/views/project/Project_members.vue
+46
-35
46 additions, 35 deletions
src/views/project/Project_members.vue
with
48 additions
and
50 deletions
src/main.js
+
0
−
1
View file @
b9bfe511
...
@@ -11,7 +11,6 @@ Vue.config.productionTip = false
...
@@ -11,7 +11,6 @@ Vue.config.productionTip = false
axios
.
all
([
store
.
dispatch
(
"
USER_INFO
"
),
axios
.
all
([
store
.
dispatch
(
"
USER_INFO
"
),
store
.
dispatch
(
"
GET_ALL_PROJECTS
"
),
store
.
dispatch
(
"
GET_ALL_PROJECTS
"
),
store
.
dispatch
(
"
GET_STATIC_PAGES
"
),
store
.
dispatch
(
"
GET_STATIC_PAGES
"
),
store
.
dispatch
(
"
GET_USERS
"
),
store
.
dispatch
(
"
GET_USER_LEVEL_PROJECTS
"
)
// * mock en attendant endpoint ou autre
store
.
dispatch
(
"
GET_USER_LEVEL_PROJECTS
"
)
// * mock en attendant endpoint ou autre
]).
then
(
axios
.
spread
(
function
()
{
]).
then
(
axios
.
spread
(
function
()
{
new
Vue
({
new
Vue
({
...
...
This diff is collapsed.
Click to expand it.
src/store/index.js
+
2
−
14
View file @
b9bfe511
...
@@ -33,9 +33,7 @@ export default new Vuex.Store({
...
@@ -33,9 +33,7 @@ export default new Vuex.Store({
state
:
{
state
:
{
logged
:
false
,
logged
:
false
,
user
:
false
,
user
:
false
,
users
:
[],
project_slug
:
null
,
project_slug
:
null
,
projectMembers
:
null
,
projects
:
[],
projects
:
[],
staticPages
:
null
,
staticPages
:
null
,
SSO_SETTED
:
false
,
SSO_SETTED
:
false
,
...
@@ -49,9 +47,6 @@ export default new Vuex.Store({
...
@@ -49,9 +47,6 @@ export default new Vuex.Store({
SET_PROJECT_SLUG
(
state
,
slug
)
{
SET_PROJECT_SLUG
(
state
,
slug
)
{
state
.
project_slug
=
slug
;
state
.
project_slug
=
slug
;
},
},
SET_PROJECT_MEMBERS
(
state
,
projectMembers
)
{
state
.
projectMembers
=
projectMembers
;
},
SET_USER
(
state
,
payload
)
{
SET_USER
(
state
,
payload
)
{
state
.
user
=
payload
;
state
.
user
=
payload
;
},
},
...
@@ -105,14 +100,7 @@ export default new Vuex.Store({
...
@@ -105,14 +100,7 @@ export default new Vuex.Store({
throw
error
;
throw
error
;
});
});
},
},
async
GET_USERS
({
commit
})
{
await
axios
.
get
(
`
${
DJANGO_API_BASE
}
users/`
)
.
then
((
response
)
=>
(
commit
(
"
SET_USERS
"
,
response
.
data
)))
.
catch
((
error
)
=>
{
throw
error
;
});
},
LOGIN
({
commit
,
dispatch
},
payload
)
{
LOGIN
({
commit
,
dispatch
},
payload
)
{
if
(
payload
.
username
&&
payload
.
password
)
{
if
(
payload
.
username
&&
payload
.
password
)
{
axios
axios
...
@@ -134,7 +122,7 @@ export default new Vuex.Store({
...
@@ -134,7 +122,7 @@ export default new Vuex.Store({
}
}
},
},
USER_INFO
({
commit
})
{
USER_INFO
({
commit
})
{
// ? not used currently ?
axios
axios
.
get
(
`
${
DJANGO_API_BASE
}
user_info/`
)
.
get
(
`
${
DJANGO_API_BASE
}
user_info/`
)
.
then
((
response
)
=>
{
.
then
((
response
)
=>
{
...
...
This diff is collapsed.
Click to expand it.
src/views/project/Project_members.vue
+
46
−
35
View file @
b9bfe511
...
@@ -17,15 +17,15 @@
...
@@ -17,15 +17,15 @@
<th>
Niveau d'autorisation
</th>
<th>
Niveau d'autorisation
</th>
</tr>
</tr>
</thead>
</thead>
<!--
<div
id=
"formsets-members"
>
-->
<tbody>
<tbody>
<div
v-frag
v-for=
"member in
m
ember
Form
s"
:key=
"member.username"
>
<div
v-frag
v-for=
"member in
projectM
embers"
:key=
"member.username"
>
<tr>
<tr>
<td>
<td>
{{
member
.
full_name
}}
<br
/><i>
{{
member
.
username
}}
</i>
{{
member
.
last_name
}}
{{
member
.
first_name
}}
<br
/><i>
{{
member
.
username
}}
</i>
</td>
</td>
<td>
<td>
<!-- :selection.sync="memberForms[index].userLevel" -->
<div
class=
"required field"
>
<div
class=
"required field"
>
<Dropdown
<Dropdown
:options=
"levelOptions"
:options=
"levelOptions"
...
@@ -33,33 +33,9 @@
...
@@ -33,33 +33,9 @@
:selection.sync=
"member.userLevel"
:selection.sync=
"member.userLevel"
:search=
"true"
:search=
"true"
/>
/>
<!--
<div
class=
"ui selection search dropdown"
>
<input
type=
"hidden"
name=
"level"
id=
"level"
v-model=
"member.level"
/>
<div
class=
"default text"
></div>
<i
class=
"dropdown icon"
></i>
<div
class=
"menu"
>
{% for x,y in form.level.field.choices %}
<div
v-for=
"(x, y) in form.level.field.choices"
:key=
"y"
class=
"item"
:data-value=
"x"
:selected=
"form.level.value === x"
>
{{
y
}}
</div>
</div>
</div>
{{
form
.
level
.
errors
}}
-->
</div>
</div>
</td>
</td>
</tr>
</tr>
<!--
</div>
-->
</div>
</div>
</tbody>
</tbody>
</table>
</table>
...
@@ -78,8 +54,9 @@
...
@@ -78,8 +54,9 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
axios
from
"
axios
"
;
import
frag
from
"
vue-frag
"
;
import
frag
from
"
vue-frag
"
;
import
{
map
State
}
from
"
vuex
"
;
import
{
map
Getters
}
from
"
vuex
"
;
import
Dropdown
from
"
@/components/Dropdown.vue
"
;
import
Dropdown
from
"
@/components/Dropdown.vue
"
;
export
default
{
export
default
{
...
@@ -93,12 +70,12 @@ export default {
...
@@ -93,12 +70,12 @@ export default {
},
},
computed
:
{
computed
:
{
...
map
State
([
"
users
"
]),
...
map
Getters
([
"
project
"
]),
},
},
data
()
{
data
()
{
return
{
return
{
m
ember
Form
s
:
[],
projectM
embers
:
[],
levelOptions
:
[
levelOptions
:
[
"
Utilisateur connecté
"
,
"
Utilisateur connecté
"
,
"
Contributeur
"
,
"
Contributeur
"
,
...
@@ -109,14 +86,48 @@ export default {
...
@@ -109,14 +86,48 @@ export default {
},
},
methods
:
{
methods
:
{
validateMembers
()
{
validateMembers
()
{
console
.
log
(
"
POST
"
,
this
.
memberForms
);
const
data
=
{
slug
:
this
.
project
.
slug
,
data
:
this
.
projectMembers
,
};
console
.
log
(
"
validateMembers
"
,
data
);
/* axios
.post(`${DJANGO_API_BASE}projet/${payload.slug}/utilisateurs/`, payload.data)
.then((response) => {
const user = response.data.user;
})
.catch(() => {
router.push({ name: "login" });
}); */
},
async
fetchMembers
()
{
return
axios
.
get
(
`
${
process
.
env
.
VUE_APP_DJANGO_API_BASE
}
projet/
${
this
.
$route
.
params
.
slug
}
/utilisateurs`
)
.
then
((
response
)
=>
response
.
data
.
members
)
.
catch
((
error
)
=>
{
throw
error
;
});
},
async
populateMembers
()
{
await
this
.
fetchMembers
().
then
((
members
)
=>
{
this
.
projectMembers
=
members
.
map
((
el
)
=>
{
return
{
userLevel
:
el
.
userLevel
?
el
.
userLevel
:
this
.
levelOptions
[
0
],
...
el
,
};
});
});
},
},
},
},
created
()
{
created
()
{
this
.
memberForms
=
this
.
users
.
map
((
el
)
=>
{
if
(
!
this
.
project
)
{
return
{
userLevel
:
null
,
...
el
};
this
.
$store
.
commit
(
"
SET_PROJECT_SLUG
"
,
this
.
$route
.
params
.
slug
);
});
}
this
.
populateMembers
();
},
},
};
};
</
script
>
</
script
>
\ No newline at end of file
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