Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
a161384b
Commit
a161384b
authored
May 31, 2017
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Declare store and service inside Vue app
parent
5bd52eae
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
24 deletions
+29
-24
app/assets/javascripts/groups/index.js
app/assets/javascripts/groups/index.js
+29
-24
No files found.
app/assets/javascripts/groups/index.js
View file @
a161384b
/* eslint-disable no-unused-vars */
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
GroupFilterableList
from
'
./groups_filterable_list
'
;
import
GroupFilterableList
from
'
./groups_filterable_list
'
;
import
GroupsComponent
from
'
./components/groups.vue
'
;
import
GroupsComponent
from
'
./components/groups.vue
'
;
...
@@ -9,25 +7,22 @@ import GroupsStore from './stores/groups_store';
...
@@ -9,25 +7,22 @@ import GroupsStore from './stores/groups_store';
import
GroupsService
from
'
./services/groups_service
'
;
import
GroupsService
from
'
./services/groups_service
'
;
import
eventHub
from
'
./event_hub
'
;
import
eventHub
from
'
./event_hub
'
;
$
(()
=>
{
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
const
appEl
=
document
.
querySelector
(
'
#dashboard-group-app
'
);
const
el
=
document
.
querySelector
(
'
#dashboard-group-app
'
);
const
form
=
document
.
querySelector
(
'
form#group-filter-form
'
);
const
filter
=
document
.
querySelector
(
'
.js-groups-list-filter
'
);
const
holder
=
document
.
querySelector
(
'
.js-groups-list-holder
'
);
const
store
=
new
GroupsStore
();
const
service
=
new
GroupsService
(
appEl
.
dataset
.
endpoint
);
Vue
.
component
(
'
groups-component
'
,
GroupsComponent
);
Vue
.
component
(
'
groups-component
'
,
GroupsComponent
);
Vue
.
component
(
'
group-folder
'
,
GroupFolder
);
Vue
.
component
(
'
group-folder
'
,
GroupFolder
);
Vue
.
component
(
'
group-item
'
,
GroupItem
);
Vue
.
component
(
'
group-item
'
,
GroupItem
);
const
GroupsApp
=
new
Vue
({
return
new
Vue
({
el
:
appEl
,
el
,
data
()
{
data
()
{
this
.
store
=
new
GroupsStore
();
this
.
service
=
new
GroupsService
(
el
.
dataset
.
endpoint
);
return
{
return
{
store
,
store
:
this
.
store
,
state
:
store
.
state
,
state
:
this
.
store
.
state
,
};
};
},
},
methods
:
{
methods
:
{
...
@@ -47,9 +42,9 @@ $(() => {
...
@@ -47,9 +42,9 @@ $(() => {
page
=
pageParam
;
page
=
pageParam
;
}
}
getGroups
=
service
.
getGroups
(
parentId
,
page
);
getGroups
=
this
.
service
.
getGroups
(
parentId
,
page
);
getGroups
.
then
((
response
)
=>
{
getGroups
.
then
((
response
)
=>
{
store
.
setGroups
(
response
.
json
(),
parentGroup
);
this
.
store
.
setGroups
(
response
.
json
(),
parentGroup
);
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{
// TODO: Handle error
// TODO: Handle error
...
@@ -59,14 +54,14 @@ $(() => {
...
@@ -59,14 +54,14 @@ $(() => {
},
},
toggleSubGroups
(
parentGroup
=
null
)
{
toggleSubGroups
(
parentGroup
=
null
)
{
if
(
!
parentGroup
.
isOpen
)
{
if
(
!
parentGroup
.
isOpen
)
{
store
.
resetGroups
(
parentGroup
);
this
.
store
.
resetGroups
(
parentGroup
);
this
.
fetchGroups
(
parentGroup
);
this
.
fetchGroups
(
parentGroup
);
}
}
GroupsStore
.
toggleSubGroups
(
parentGroup
);
GroupsStore
.
toggleSubGroups
(
parentGroup
);
},
},
leaveGroup
(
endpoint
)
{
leaveGroup
(
endpoint
)
{
service
.
leaveGroup
(
endpoint
)
this
.
service
.
leaveGroup
(
endpoint
)
.
then
(()
=>
{
.
then
(()
=>
{
// TODO: Refresh?
// TODO: Refresh?
})
})
...
@@ -75,22 +70,32 @@ $(() => {
...
@@ -75,22 +70,32 @@ $(() => {
});
});
},
},
},
},
created
()
{
beforeMount
()
{
let
groupFilterList
=
null
;
let
groupFilterList
=
null
;
const
form
=
document
.
querySelector
(
'
form#group-filter-form
'
);
const
filter
=
document
.
querySelector
(
'
.js-groups-list-filter
'
);
const
holder
=
document
.
querySelector
(
'
.js-groups-list-holder
'
);
groupFilterList
=
new
GroupFilterableList
({
form
,
filter
,
holder
,
store
});
const
options
=
{
form
,
filter
,
holder
,
store
:
this
.
store
,
};
groupFilterList
=
new
GroupFilterableList
(
options
);
groupFilterList
.
initSearch
();
groupFilterList
.
initSearch
();
eventHub
.
$on
(
'
toggleSubGroups
'
,
this
.
toggleSubGroups
);
eventHub
.
$on
(
'
leaveGroup
'
,
this
.
leaveGroup
);
},
mounted
()
{
this
.
fetchGroups
()
this
.
fetchGroups
()
.
then
((
response
)
=>
{
.
then
((
response
)
=>
{
store
.
storePagination
(
response
.
headers
);
this
.
store
.
storePagination
(
response
.
headers
);
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{
// TODO: Handle error
// TODO: Handle error
});
});
eventHub
.
$on
(
'
toggleSubGroups
'
,
this
.
toggleSubGroups
);
eventHub
.
$on
(
'
leaveGroup
'
,
this
.
leaveGroup
);
},
},
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment