aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/metrics
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-09-17 16:15:28 +0200
committerStas Vilchik <vilchiks@gmail.com>2015-09-18 10:47:27 +0200
commit890ab0b59cdb3902f4869eabf8ca534814f1b3dd (patch)
tree0ed74726957e590f6506e378366ea15bf21bfcbd /server/sonar-web/src/main/js/apps/metrics
parentce60ac8d2e137f33bb111668e54e78c195c73d79 (diff)
downloadsonarqube-890ab0b59cdb3902f4869eabf8ca534814f1b3dd.tar.gz
sonarqube-890ab0b59cdb3902f4869eabf8ca534814f1b3dd.zip
migrate js apps to es2015 modules
Diffstat (limited to 'server/sonar-web/src/main/js/apps/metrics')
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/app.js119
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/create-view.js64
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/delete-view.js54
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/form-view.js108
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/header-view.js45
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/layout.js23
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/list-footer-view.js64
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/list-item-view.js101
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/list-view.js29
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/metric.js65
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/metrics.js78
-rw-r--r--server/sonar-web/src/main/js/apps/metrics/update-view.js56
12 files changed, 397 insertions, 409 deletions
diff --git a/server/sonar-web/src/main/js/apps/metrics/app.js b/server/sonar-web/src/main/js/apps/metrics/app.js
index 4e42d95a09d..42eecceff9a 100644
--- a/server/sonar-web/src/main/js/apps/metrics/app.js
+++ b/server/sonar-web/src/main/js/apps/metrics/app.js
@@ -1,64 +1,63 @@
-define([
- './layout',
- './metrics',
- './header-view',
- './list-view',
- './list-footer-view'
-], function (Layout, Metrics, HeaderView, ListView, ListFooterView) {
-
- var $ = jQuery,
- App = new Marionette.Application(),
- init = function (options) {
- // Layout
- this.layout = new Layout({ el: options.el });
- this.layout.render();
-
- // Collection
- this.metrics = new Metrics();
-
- // Header View
- this.headerView = new HeaderView({
- collection: this.metrics,
- domains: this.domains,
- types: this.types,
- app: App
- });
- this.layout.headerRegion.show(this.headerView);
-
- // List View
- this.listView = new ListView({
- collection: this.metrics,
- domains: this.domains,
- types: this.types
- });
- this.layout.listRegion.show(this.listView);
-
- // List Footer View
- this.listFooterView = new ListFooterView({ collection: this.metrics });
- this.layout.listFooterRegion.show(this.listFooterView);
-
- // Go!
- this.metrics.fetch();
- };
-
-
- App.requestDomains = function () {
- return $.get(baseUrl + '/api/metrics/domains').done(function (r) {
- App.domains = r.domains;
- });
- };
- App.requestTypes = function () {
- return $.get(baseUrl + '/api/metrics/types').done(function (r) {
- App.types = r.types;
- });
- };
+import $ from 'jquery';
+import Marionette from 'backbone.marionette';
+import Layout from './layout';
+import Metrics from './metrics';
+import HeaderView from './header-view';
+import ListView from './list-view';
+import ListFooterView from './list-footer-view';
+
+var App = new Marionette.Application(),
+ init = function (options) {
+ // Layout
+ this.layout = new Layout({ el: options.el });
+ this.layout.render();
+
+ // Collection
+ this.metrics = new Metrics();
+
+ // Header View
+ this.headerView = new HeaderView({
+ collection: this.metrics,
+ domains: this.domains,
+ types: this.types,
+ app: App
+ });
+ this.layout.headerRegion.show(this.headerView);
+
+ // List View
+ this.listView = new ListView({
+ collection: this.metrics,
+ domains: this.domains,
+ types: this.types
+ });
+ this.layout.listRegion.show(this.listView);
+
+ // List Footer View
+ this.listFooterView = new ListFooterView({ collection: this.metrics });
+ this.layout.listFooterRegion.show(this.listFooterView);
+
+ // Go!
+ this.metrics.fetch();
+ };
+
+
+App.requestDomains = function () {
+ return $.get(baseUrl + '/api/metrics/domains').done(function (r) {
+ App.domains = r.domains;
+ });
+};
+App.requestTypes = function () {
+ return $.get(baseUrl + '/api/metrics/types').done(function (r) {
+ App.types = r.types;
+ });
+};
- App.on('start', function (options) {
- $.when(window.requestMessages(), App.requestDomains(), App.requestTypes()).done(function () {
- init.call(App, options);
- });
+App.on('start', function (options) {
+ $.when(window.requestMessages(), App.requestDomains(), App.requestTypes()).done(function () {
+ init.call(App, options);
});
+});
+
+export default App;
- return App;
-});
diff --git a/server/sonar-web/src/main/js/apps/metrics/create-view.js b/server/sonar-web/src/main/js/apps/metrics/create-view.js
index 9e2145fbee7..68681d93822 100644
--- a/server/sonar-web/src/main/js/apps/metrics/create-view.js
+++ b/server/sonar-web/src/main/js/apps/metrics/create-view.js
@@ -1,36 +1,34 @@
-define([
- './metric',
- './form-view'
-], function (Metric, FormView) {
+import Metric from './metric';
+import FormView from './form-view';
- return FormView.extend({
-
- sendRequest: function () {
- var that = this,
- metric = new Metric({
- key: this.$('#create-metric-key').val(),
- name: this.$('#create-metric-name').val(),
- description: this.$('#create-metric-description').val(),
- domain: this.$('#create-metric-domain').val(),
- type: this.$('#create-metric-type').val()
- });
- this.disableForm();
- return metric.save(null, {
- statusCode: {
- // do not show global error
- 400: null
- }
- }).done(function () {
- that.collection.refresh();
- if (that.options.domains.indexOf(metric.get('domain')) === -1) {
- that.options.domains.push(metric.get('domain'));
- }
- that.destroy();
- }).fail(function (jqXHR) {
- that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
- that.enableForm();
- });
- }
- });
+export default FormView.extend({
+ sendRequest: function () {
+ var that = this,
+ metric = new Metric({
+ key: this.$('#create-metric-key').val(),
+ name: this.$('#create-metric-name').val(),
+ description: this.$('#create-metric-description').val(),
+ domain: this.$('#create-metric-domain').val(),
+ type: this.$('#create-metric-type').val()
+ });
+ this.disableForm();
+ return metric.save(null, {
+ statusCode: {
+ // do not show global error
+ 400: null
+ }
+ }).done(function () {
+ that.collection.refresh();
+ if (that.options.domains.indexOf(metric.get('domain')) === -1) {
+ that.options.domains.push(metric.get('domain'));
+ }
+ that.destroy();
+ }).fail(function (jqXHR) {
+ that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+ that.enableForm();
+ });
+ }
});
+
+
diff --git a/server/sonar-web/src/main/js/apps/metrics/delete-view.js b/server/sonar-web/src/main/js/apps/metrics/delete-view.js
index 8719b9fdb3a..cef043b54b8 100644
--- a/server/sonar-web/src/main/js/apps/metrics/delete-view.js
+++ b/server/sonar-web/src/main/js/apps/metrics/delete-view.js
@@ -1,32 +1,30 @@
-define([
- 'components/common/modal-form',
- './templates'
-], function (ModalForm) {
+import ModalForm from 'components/common/modal-form';
+import './templates';
- return ModalForm.extend({
- template: Templates['metrics-delete'],
+export default ModalForm.extend({
+ template: Templates['metrics-delete'],
- onFormSubmit: function (e) {
- this._super(e);
- this.sendRequest();
- },
-
- sendRequest: function () {
- var that = this,
- collection = this.model.collection;
- return this.model.destroy({
- wait: true,
- statusCode: {
- // do not show global error
- 400: null
- }
- }).done(function () {
- collection.refresh();
- that.destroy();
- }).fail(function (jqXHR) {
- that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
- });
- }
- });
+ onFormSubmit: function (e) {
+ this._super(e);
+ this.sendRequest();
+ },
+ sendRequest: function () {
+ var that = this,
+ collection = this.model.collection;
+ return this.model.destroy({
+ wait: true,
+ statusCode: {
+ // do not show global error
+ 400: null
+ }
+ }).done(function () {
+ collection.refresh();
+ that.destroy();
+ }).fail(function (jqXHR) {
+ that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+ });
+ }
});
+
+
diff --git a/server/sonar-web/src/main/js/apps/metrics/form-view.js b/server/sonar-web/src/main/js/apps/metrics/form-view.js
index 03e66f715b6..7396e4da8ff 100644
--- a/server/sonar-web/src/main/js/apps/metrics/form-view.js
+++ b/server/sonar-web/src/main/js/apps/metrics/form-view.js
@@ -1,57 +1,55 @@
-define([
- 'components/common/modal-form',
- './templates'
-], function (ModalForm) {
-
- var $ = jQuery;
-
- return ModalForm.extend({
- template: Templates['metrics-form'],
-
- onRender: function () {
- var that = this;
- this._super();
- this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
- this.$('#create-metric-domain').select2({
- width: '250px',
- createSearchChoice: function (term) {
- return { id: term, text: '+' + term };
- },
- createSearchChoicePosition: 'top',
- initSelection: function (element, callback) {
- var value = $(element).val();
- callback({ id: value, text: value });
- },
- query: function (options) {
- var items = that.options.domains.filter(function (d) {
- return d.toLowerCase().indexOf(options.term.toLowerCase()) !== -1;
- }),
- results = items.map(function (item) {
- return { id: item, text: item };
- });
- options.callback({ results: results, more: false });
- }
- }).select2('val', this.model && this.model.get('domain'));
- this.$('#create-metric-type').select2({ width: '250px' });
- },
-
- onDestroy: function () {
- this._super();
- this.$('[data-toggle="tooltip"]').tooltip('destroy');
- },
-
- onFormSubmit: function (e) {
- this._super(e);
- this.sendRequest();
- },
-
- serializeData: function () {
- return _.extend(this._super(), {
- domains: this.options.domains,
- types: this.options.types
- });
- }
-
- });
+import $ from 'jquery';
+import _ from 'underscore';
+import ModalForm from 'components/common/modal-form';
+import './templates';
+
+export default ModalForm.extend({
+ template: Templates['metrics-form'],
+
+ onRender: function () {
+ var that = this;
+ this._super();
+ this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
+ this.$('#create-metric-domain').select2({
+ width: '250px',
+ createSearchChoice: function (term) {
+ return { id: term, text: '+' + term };
+ },
+ createSearchChoicePosition: 'top',
+ initSelection: function (element, callback) {
+ var value = $(element).val();
+ callback({ id: value, text: value });
+ },
+ query: function (options) {
+ var items = that.options.domains.filter(function (d) {
+ return d.toLowerCase().indexOf(options.term.toLowerCase()) !== -1;
+ }),
+ results = items.map(function (item) {
+ return { id: item, text: item };
+ });
+ options.callback({ results: results, more: false });
+ }
+ }).select2('val', this.model && this.model.get('domain'));
+ this.$('#create-metric-type').select2({ width: '250px' });
+ },
+
+ onDestroy: function () {
+ this._super();
+ this.$('[data-toggle="tooltip"]').tooltip('destroy');
+ },
+
+ onFormSubmit: function (e) {
+ this._super(e);
+ this.sendRequest();
+ },
+
+ serializeData: function () {
+ return _.extend(this._super(), {
+ domains: this.options.domains,
+ types: this.options.types
+ });
+ }
});
+
+
diff --git a/server/sonar-web/src/main/js/apps/metrics/header-view.js b/server/sonar-web/src/main/js/apps/metrics/header-view.js
index 78a9b0da0d0..37cdc7dc8b4 100644
--- a/server/sonar-web/src/main/js/apps/metrics/header-view.js
+++ b/server/sonar-web/src/main/js/apps/metrics/header-view.js
@@ -1,28 +1,27 @@
-define([
- './create-view',
- './templates'
-], function (CreateView) {
+import Marionette from 'backbone.marionette';
+import CreateView from './create-view';
+import './templates';
- return Marionette.ItemView.extend({
- template: Templates['metrics-header'],
+export default Marionette.ItemView.extend({
+ template: Templates['metrics-header'],
- events: {
- 'click #metrics-create': 'onCreateClick'
- },
+ events: {
+ 'click #metrics-create': 'onCreateClick'
+ },
- onCreateClick: function (e) {
- e.preventDefault();
- this.createMetric();
- },
-
- createMetric: function () {
- new CreateView({
- collection: this.collection,
- domains: this.options.domains,
- types: this.options.types,
- app: this.options.app
- }).render();
- }
- });
+ onCreateClick: function (e) {
+ e.preventDefault();
+ this.createMetric();
+ },
+ createMetric: function () {
+ new CreateView({
+ collection: this.collection,
+ domains: this.options.domains,
+ types: this.options.types,
+ app: this.options.app
+ }).render();
+ }
});
+
+
diff --git a/server/sonar-web/src/main/js/apps/metrics/layout.js b/server/sonar-web/src/main/js/apps/metrics/layout.js
index 9575307d96f..6d1a560cf89 100644
--- a/server/sonar-web/src/main/js/apps/metrics/layout.js
+++ b/server/sonar-web/src/main/js/apps/metrics/layout.js
@@ -1,15 +1,14 @@
-define([
- './templates'
-], function () {
+import Marionette from 'backbone.marionette';
+import './templates';
- return Marionette.LayoutView.extend({
- template: Templates['metrics-layout'],
-
- regions: {
- headerRegion: '#metrics-header',
- listRegion: '#metrics-list',
- listFooterRegion: '#metrics-list-footer'
- }
- });
+export default Marionette.LayoutView.extend({
+ template: Templates['metrics-layout'],
+ regions: {
+ headerRegion: '#metrics-header',
+ listRegion: '#metrics-list',
+ listFooterRegion: '#metrics-list-footer'
+ }
});
+
+
diff --git a/server/sonar-web/src/main/js/apps/metrics/list-footer-view.js b/server/sonar-web/src/main/js/apps/metrics/list-footer-view.js
index 932dfd6d35f..a48c0a11e7a 100644
--- a/server/sonar-web/src/main/js/apps/metrics/list-footer-view.js
+++ b/server/sonar-web/src/main/js/apps/metrics/list-footer-view.js
@@ -1,34 +1,34 @@
-define([
- './templates'
-], function () {
-
- return Marionette.ItemView.extend({
- template: Templates['metrics-list-footer'],
-
- collectionEvents: {
- 'all': 'render'
- },
-
- events: {
- 'click #metrics-fetch-more': 'onMoreClick'
- },
-
- onMoreClick: function (e) {
- e.preventDefault();
- this.fetchMore();
- },
-
- fetchMore: function () {
- this.collection.fetchMore();
- },
-
- serializeData: function () {
- return _.extend(this._super(), {
- total: this.collection.total,
- count: this.collection.length,
- more: this.collection.hasMore()
- });
- }
- });
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import './templates';
+export default Marionette.ItemView.extend({
+ template: Templates['metrics-list-footer'],
+
+ collectionEvents: {
+ 'all': 'render'
+ },
+
+ events: {
+ 'click #metrics-fetch-more': 'onMoreClick'
+ },
+
+ onMoreClick: function (e) {
+ e.preventDefault();
+ this.fetchMore();
+ },
+
+ fetchMore: function () {
+ this.collection.fetchMore();
+ },
+
+ serializeData: function () {
+ return _.extend(this._super(), {
+ total: this.collection.total,
+ count: this.collection.length,
+ more: this.collection.hasMore()
+ });
+ }
});
+
+
diff --git a/server/sonar-web/src/main/js/apps/metrics/list-item-view.js b/server/sonar-web/src/main/js/apps/metrics/list-item-view.js
index c6989e3b7b3..3a56e9c9650 100644
--- a/server/sonar-web/src/main/js/apps/metrics/list-item-view.js
+++ b/server/sonar-web/src/main/js/apps/metrics/list-item-view.js
@@ -1,52 +1,51 @@
-define([
- './update-view',
- './delete-view',
- './templates'
-], function (UpdateView, DeleteView) {
-
- return Marionette.ItemView.extend({
- tagName: 'li',
- className: 'panel panel-vertical',
- template: Templates['metrics-list-item'],
-
- events: {
- 'click .js-metric-update': 'onUpdateClick',
- 'click .js-metric-delete': 'onDeleteClick'
- },
-
- onRender: function () {
- this.$el
- .attr('data-id', this.model.id)
- .attr('data-key', this.model.get('key'));
- this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
- },
-
- onDestroy: function () {
- this.$('[data-toggle="tooltip"]').tooltip('destroy');
- },
-
- onUpdateClick: function (e) {
- e.preventDefault();
- this.updateMetric();
- },
-
- onDeleteClick: function (e) {
- e.preventDefault();
- this.deleteMetric();
- },
-
- updateMetric: function () {
- new UpdateView({
- model: this.model,
- collection: this.model.collection,
- types: this.options.types,
- domains: this.options.domains
- }).render();
- },
-
- deleteMetric: function () {
- new DeleteView({ model: this.model }).render();
- }
- });
-
+import Marionette from 'backbone.marionette';
+import UpdateView from './update-view';
+import DeleteView from './delete-view';
+import './templates';
+
+export default Marionette.ItemView.extend({
+ tagName: 'li',
+ className: 'panel panel-vertical',
+ template: Templates['metrics-list-item'],
+
+ events: {
+ 'click .js-metric-update': 'onUpdateClick',
+ 'click .js-metric-delete': 'onDeleteClick'
+ },
+
+ onRender: function () {
+ this.$el
+ .attr('data-id', this.model.id)
+ .attr('data-key', this.model.get('key'));
+ this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
+ },
+
+ onDestroy: function () {
+ this.$('[data-toggle="tooltip"]').tooltip('destroy');
+ },
+
+ onUpdateClick: function (e) {
+ e.preventDefault();
+ this.updateMetric();
+ },
+
+ onDeleteClick: function (e) {
+ e.preventDefault();
+ this.deleteMetric();
+ },
+
+ updateMetric: function () {
+ new UpdateView({
+ model: this.model,
+ collection: this.model.collection,
+ types: this.options.types,
+ domains: this.options.domains
+ }).render();
+ },
+
+ deleteMetric: function () {
+ new DeleteView({ model: this.model }).render();
+ }
});
+
+
diff --git a/server/sonar-web/src/main/js/apps/metrics/list-view.js b/server/sonar-web/src/main/js/apps/metrics/list-view.js
index b015c65d966..e5a0f9f1e96 100644
--- a/server/sonar-web/src/main/js/apps/metrics/list-view.js
+++ b/server/sonar-web/src/main/js/apps/metrics/list-view.js
@@ -1,18 +1,17 @@
-define([
- './list-item-view',
- './templates'
-], function (ListItemView) {
+import Marionette from 'backbone.marionette';
+import ListItemView from './list-item-view';
+import './templates';
- return Marionette.CollectionView.extend({
- tagName: 'ul',
- childView: ListItemView,
-
- childViewOptions: function () {
- return {
- types: this.options.types,
- domains: this.options.domains
- };
- }
- });
+export default Marionette.CollectionView.extend({
+ tagName: 'ul',
+ childView: ListItemView,
+ childViewOptions: function () {
+ return {
+ types: this.options.types,
+ domains: this.options.domains
+ };
+ }
});
+
+
diff --git a/server/sonar-web/src/main/js/apps/metrics/metric.js b/server/sonar-web/src/main/js/apps/metrics/metric.js
index cb160c882d0..82bb67c20fe 100644
--- a/server/sonar-web/src/main/js/apps/metrics/metric.js
+++ b/server/sonar-web/src/main/js/apps/metrics/metric.js
@@ -1,37 +1,38 @@
-define(function () {
+import _ from 'underscore';
+import Backbone from 'backbone';
- return Backbone.Model.extend({
- idAttribute: 'id',
+export default Backbone.Model.extend({
+ idAttribute: 'id',
- urlRoot: function () {
- return baseUrl + '/api/metrics';
- },
+ urlRoot: function () {
+ return baseUrl + '/api/metrics';
+ },
- sync: function (method, model, options) {
- var opts = options || {};
- if (method === 'create') {
- _.defaults(opts, {
- url: this.urlRoot() + '/create',
- type: 'POST',
- data: _.pick(model.toJSON(), 'key', 'name', 'description', 'domain', 'type')
- });
- }
- if (method === 'update') {
- _.defaults(opts, {
- url: this.urlRoot() + '/update',
- type: 'POST',
- data: _.pick(model.toJSON(), 'id', 'key', 'name', 'description', 'domain', 'type')
- });
- }
- if (method === 'delete') {
- _.defaults(opts, {
- url: this.urlRoot() + '/delete',
- type: 'POST',
- data: { ids: this.id }
- });
- }
- return Backbone.ajax(opts);
+ sync: function (method, model, options) {
+ var opts = options || {};
+ if (method === 'create') {
+ _.defaults(opts, {
+ url: this.urlRoot() + '/create',
+ type: 'POST',
+ data: _.pick(model.toJSON(), 'key', 'name', 'description', 'domain', 'type')
+ });
}
- });
-
+ if (method === 'update') {
+ _.defaults(opts, {
+ url: this.urlRoot() + '/update',
+ type: 'POST',
+ data: _.pick(model.toJSON(), 'id', 'key', 'name', 'description', 'domain', 'type')
+ });
+ }
+ if (method === 'delete') {
+ _.defaults(opts, {
+ url: this.urlRoot() + '/delete',
+ type: 'POST',
+ data: { ids: this.id }
+ });
+ }
+ return Backbone.ajax(opts);
+ }
});
+
+
diff --git a/server/sonar-web/src/main/js/apps/metrics/metrics.js b/server/sonar-web/src/main/js/apps/metrics/metrics.js
index 393ebe3c2b1..44fa17c8227 100644
--- a/server/sonar-web/src/main/js/apps/metrics/metrics.js
+++ b/server/sonar-web/src/main/js/apps/metrics/metrics.js
@@ -1,41 +1,41 @@
-define([
- './metric'
-], function (Metric) {
-
- return Backbone.Collection.extend({
- model: Metric,
-
- url: function () {
- return baseUrl + '/api/metrics/search';
- },
-
- parse: function (r) {
- this.total = r.total;
- this.p = r.p;
- this.ps = r.ps;
- return r.metrics;
- },
-
- fetch: function (options) {
- var opts = _.defaults(options || {}, { data: {} });
- this.q = opts.data.q;
- opts.data.isCustom = true;
- return this._super(opts);
- },
-
- fetchMore: function () {
- var p = this.p + 1;
- return this.fetch({ add: true, remove: false, data: { p: p, ps: this.ps, q: this.q } });
- },
-
- refresh: function () {
- return this.fetch({ reset: true, data: { q: this.q } });
- },
-
- hasMore: function () {
- return this.total > this.p * this.ps;
- }
-
- });
+import _ from 'underscore';
+import Backbone from 'backbone';
+import Metric from './metric';
+
+export default Backbone.Collection.extend({
+ model: Metric,
+
+ url: function () {
+ return baseUrl + '/api/metrics/search';
+ },
+
+ parse: function (r) {
+ this.total = r.total;
+ this.p = r.p;
+ this.ps = r.ps;
+ return r.metrics;
+ },
+
+ fetch: function (options) {
+ var opts = _.defaults(options || {}, { data: {} });
+ this.q = opts.data.q;
+ opts.data.isCustom = true;
+ return this._super(opts);
+ },
+
+ fetchMore: function () {
+ var p = this.p + 1;
+ return this.fetch({ add: true, remove: false, data: { p: p, ps: this.ps, q: this.q } });
+ },
+
+ refresh: function () {
+ return this.fetch({ reset: true, data: { q: this.q } });
+ },
+
+ hasMore: function () {
+ return this.total > this.p * this.ps;
+ }
});
+
+
diff --git a/server/sonar-web/src/main/js/apps/metrics/update-view.js b/server/sonar-web/src/main/js/apps/metrics/update-view.js
index 3dfea4a584e..8ccce5ce7d0 100644
--- a/server/sonar-web/src/main/js/apps/metrics/update-view.js
+++ b/server/sonar-web/src/main/js/apps/metrics/update-view.js
@@ -1,32 +1,30 @@
-define([
- './form-view'
-], function (FormView) {
+import FormView from './form-view';
- return FormView.extend({
-
- sendRequest: function () {
- var that = this;
- this.model.set({
- key: this.$('#create-metric-key').val(),
- name: this.$('#create-metric-name').val(),
- description: this.$('#create-metric-description').val(),
- domain: this.$('#create-metric-domain').val(),
- type: this.$('#create-metric-type').val()
- });
- this.disableForm();
- return this.model.save(null, {
- statusCode: {
- // do not show global error
- 400: null
- }
- }).done(function () {
- that.collection.refresh();
- that.destroy();
- }).fail(function (jqXHR) {
- that.enableForm();
- that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
- });
- }
- });
+export default FormView.extend({
+ sendRequest: function () {
+ var that = this;
+ this.model.set({
+ key: this.$('#create-metric-key').val(),
+ name: this.$('#create-metric-name').val(),
+ description: this.$('#create-metric-description').val(),
+ domain: this.$('#create-metric-domain').val(),
+ type: this.$('#create-metric-type').val()
+ });
+ this.disableForm();
+ return this.model.save(null, {
+ statusCode: {
+ // do not show global error
+ 400: null
+ }
+ }).done(function () {
+ that.collection.refresh();
+ that.destroy();
+ }).fail(function (jqXHR) {
+ that.enableForm();
+ that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+ });
+ }
});
+
+