Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit 00423df

Browse files
committed
Create ProjectObject.js
1 parent 1c42663 commit 00423df

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

modules/Project/ProjectObject.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module = angular.module('App.Project')
2+
module.factory('ProjectObject', (BaseObject, $http) => {
3+
class Project extends BaseObject {
4+
static list(userId) {
5+
return $http.get('/api/projects', { params: { user_id: userId } })
6+
.then( (response) => response.data.map( project => new Project(project) ) );
7+
}
8+
9+
static get(id) {
10+
return $http.get(`/api/projects/${id}`)
11+
.then( (response) => new Project(response.data));
12+
}
13+
14+
15+
create() {
16+
return $http.post('/api/projects', this )
17+
.then( (response) => {
18+
this.id = response.data.id;
19+
return response.data;
20+
});
21+
}
22+
23+
update() {
24+
return $http.put(`/api/projects/${this.id}`, this);
25+
}
26+
}
27+
28+
return Project;
29+
});

0 commit comments

Comments
 (0)