aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/groups/group.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/apps/groups/group.js')
-rw-r--r--server/sonar-web/src/main/js/apps/groups/group.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/apps/groups/group.js b/server/sonar-web/src/main/js/apps/groups/group.js
new file mode 100644
index 00000000000..406f9ba3a3a
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/groups/group.js
@@ -0,0 +1,35 @@
+define(function () {
+
+ return Backbone.Model.extend({
+ urlRoot: function () {
+ return baseUrl + '/api/usergroups';
+ },
+
+ sync: function (method, model, options) {
+ var opts = options || {};
+ if (method === 'create') {
+ _.defaults(opts, {
+ url: this.urlRoot() + '/create',
+ type: 'POST',
+ data: _.pick(model.toJSON(), 'name', 'description')
+ });
+ }
+ if (method === 'update') {
+ _.defaults(opts, {
+ url: this.urlRoot() + '/update',
+ type: 'POST',
+ data: _.pick(model.toJSON(), 'id', 'name', 'description')
+ });
+ }
+ if (method === 'delete') {
+ _.defaults(opts, {
+ url: this.urlRoot() + '/delete',
+ type: 'POST',
+ data: { id: this.id }
+ });
+ }
+ return Backbone.ajax(opts);
+ }
+ });
+
+});