chore: add projects CRUDL functionality

This commit is contained in:
Randall Morey committed 2020-07-23 11:31:46 -04:00
1 parent b7996f6271
commit b4e8b1be8b
2 files changed
+13 -2

No files matched your search

+3 -1
View File
@@ -55,6 +55,7 @@ export default class ScopesScopeProjectsRoute extends Route {
async save(project) {
try {
await project.save();
this.refresh();
// TODO: replace with translated strings
this.notify.success('Save succeeded.');
this.transitionTo('scopes.scope.projects.project', project);
@@ -72,7 +73,8 @@ export default class ScopesScopeProjectsRoute extends Route {
async delete(project) {
try {
await project.destroyRecord();
this.transitionTo('orgs.org.projects');
this.refresh();
this.transitionTo('scopes.scope.projects');
// TODO: replace with translated strings
this.notify.success('Deleted project succesfully.');
} catch (error) {
+10 -1
View File
@@ -24,7 +24,16 @@ export default function() {
return scope.scope ? scope.scope.id === scope_id : false
});
});
this.post('/scopes');
this.post('/scopes', function ({ scopes }, request) {
// Parent scope comes through the payload via `scope_id`, but this needs
// to be expanded to a scope object `scope: {id:..., type:...}` before
// saving, which is the gist of this function.
const attrs = this.normalizedRequestAttrs();
const parentScopeAttrs = this.serialize(scopes.find(attrs.scopeId));
delete attrs.scopeId;
attrs.scope = parentScopeAttrs;
return scopes.create(attrs);
});
// To simulate a possible real-world case, org scopes are not returned,
// but project scopes are.
// TODO this should be expanded to support other scenarios.