diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-09-17 16:15:28 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-09-18 10:47:27 +0200 |
commit | 890ab0b59cdb3902f4869eabf8ca534814f1b3dd (patch) | |
tree | 0ed74726957e590f6506e378366ea15bf21bfcbd /server/sonar-web/src/main/js/apps/coding-rules/facets | |
parent | ce60ac8d2e137f33bb111668e54e78c195c73d79 (diff) | |
download | sonarqube-890ab0b59cdb3902f4869eabf8ca534814f1b3dd.tar.gz sonarqube-890ab0b59cdb3902f4869eabf8ca534814f1b3dd.zip |
migrate js apps to es2015 modules
Diffstat (limited to 'server/sonar-web/src/main/js/apps/coding-rules/facets')
16 files changed, 578 insertions, 601 deletions
diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/active-severity-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/active-severity-facet.js index f41233b9a7a..0f0de13b0de 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/active-severity-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/active-severity-facet.js @@ -1,46 +1,45 @@ -define([ - './base-facet', - '../templates' -], function (BaseFacet) { - - return BaseFacet.extend({ - template: Templates['coding-rules-severity-facet'], - severities: ['BLOCKER', 'MINOR', 'CRITICAL', 'INFO', 'MAJOR'], - - initialize: function (options) { - this.listenTo(options.app.state, 'change:query', this.onQueryChange); - }, - - onQueryChange: function () { - var query = this.options.app.state.get('query'), - isProfileSelected = query.qprofile != null, - isActiveShown = '' + query.activation === 'true'; - if (!isProfileSelected || !isActiveShown) { - this.forbid(); - } - }, - - onRender: function () { - BaseFacet.prototype.onRender.apply(this, arguments); - this.onQueryChange(); - }, - - forbid: function () { - BaseFacet.prototype.forbid.apply(this, arguments); - this.$el.prop('title', t('coding_rules.filters.active_severity.inactive')); - }, - - allow: function () { - BaseFacet.prototype.allow.apply(this, arguments); - this.$el.prop('title', null); - }, - - sortValues: function (values) { - var order = this.severities; - return _.sortBy(values, function (v) { - return order.indexOf(v.val); - }); +import _ from 'underscore'; +import BaseFacet from './base-facet'; +import '../templates'; + +export default BaseFacet.extend({ + template: Templates['coding-rules-severity-facet'], + severities: ['BLOCKER', 'MINOR', 'CRITICAL', 'INFO', 'MAJOR'], + + initialize: function (options) { + this.listenTo(options.app.state, 'change:query', this.onQueryChange); + }, + + onQueryChange: function () { + var query = this.options.app.state.get('query'), + isProfileSelected = query.qprofile != null, + isActiveShown = '' + query.activation === 'true'; + if (!isProfileSelected || !isActiveShown) { + this.forbid(); } - }); - + }, + + onRender: function () { + BaseFacet.prototype.onRender.apply(this, arguments); + this.onQueryChange(); + }, + + forbid: function () { + BaseFacet.prototype.forbid.apply(this, arguments); + this.$el.prop('title', t('coding_rules.filters.active_severity.inactive')); + }, + + allow: function () { + BaseFacet.prototype.allow.apply(this, arguments); + this.$el.prop('title', null); + }, + + sortValues: function (values) { + var order = this.severities; + return _.sortBy(values, function (v) { + return order.indexOf(v.val); + }); + } }); + + diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/available-since-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/available-since-facet.js index 830fbe1bef0..3f2f6a2839f 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/available-since-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/available-since-facet.js @@ -1,42 +1,41 @@ -define([ - './base-facet', - '../templates' -], function (BaseFacet) { - - return BaseFacet.extend({ - template: Templates['coding-rules-available-since-facet'], - - events: function () { - return _.extend(BaseFacet.prototype.events.apply(this, arguments), { - 'change input': 'applyFacet' - }); - }, - - onRender: function () { - this.$el.toggleClass('search-navigator-facet-box-collapsed', !this.model.get('enabled')); - this.$el.attr('data-property', this.model.get('property')); - this.$('input').datepicker({ - dateFormat: 'yy-mm-dd', - changeMonth: true, - changeYear: true - }); - var value = this.options.app.state.get('query').available_since; - if (value) { - this.$('input').val(value); - } - }, - - applyFacet: function() { - var obj = {}, - property = this.model.get('property'); - obj[property] = this.$('input').val(); - this.options.app.state.updateFilter(obj); - }, - - getLabelsSource: function () { - return this.options.app.languages; +import _ from 'underscore'; +import BaseFacet from './base-facet'; +import '../templates'; + +export default BaseFacet.extend({ + template: Templates['coding-rules-available-since-facet'], + + events: function () { + return _.extend(BaseFacet.prototype.events.apply(this, arguments), { + 'change input': 'applyFacet' + }); + }, + + onRender: function () { + this.$el.toggleClass('search-navigator-facet-box-collapsed', !this.model.get('enabled')); + this.$el.attr('data-property', this.model.get('property')); + this.$('input').datepicker({ + dateFormat: 'yy-mm-dd', + changeMonth: true, + changeYear: true + }); + var value = this.options.app.state.get('query').available_since; + if (value) { + this.$('input').val(value); } + }, - }); + applyFacet: function () { + var obj = {}, + property = this.model.get('property'); + obj[property] = this.$('input').val(); + this.options.app.state.updateFilter(obj); + }, + + getLabelsSource: function () { + return this.options.app.languages; + } }); + + diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/base-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/base-facet.js index 18dc6f2c040..f02260069cb 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/base-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/base-facet.js @@ -1,11 +1,9 @@ -define([ - 'components/navigator/facets/base-facet', - '../templates' -], function (BaseFacet) { - - return BaseFacet.extend({ - className: 'search-navigator-facet-box', - template: Templates['coding-rules-base-facet'] - }); +import BaseFacet from 'components/navigator/facets/base-facet'; +import '../templates'; +export default BaseFacet.extend({ + className: 'search-navigator-facet-box', + template: Templates['coding-rules-base-facet'] }); + + diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/characteristic-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/characteristic-facet.js index c4a5e814bc2..5463b4e13bc 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/characteristic-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/characteristic-facet.js @@ -1,66 +1,64 @@ -define([ - './base-facet', - '../templates' -], function (BaseFacet) { +import $ from 'jquery'; +import _ from 'underscore'; +import BaseFacet from './base-facet'; +import '../templates'; - var $ = jQuery; +export default BaseFacet.extend({ + template: Templates['coding-rules-characteristic-facet'], - return BaseFacet.extend({ - template: Templates['coding-rules-characteristic-facet'], - - onRender: function () { - BaseFacet.prototype.onRender.apply(this, arguments); - var value = this.options.app.state.get('query').has_debt_characteristic; - if (value != null && ('' + value === 'false')) { - this.$('.js-facet').filter('[data-empty-characteristic]').addClass('active'); - } - }, - - toggleFacet: function (e) { - var noneCharacteristic = $(e.currentTarget).is('[data-empty-characteristic]'), - property = this.model.get('property'), - obj = {}; - $(e.currentTarget).toggleClass('active'); - if (noneCharacteristic) { - var checked = $(e.currentTarget).is('.active'); - obj.has_debt_characteristic = checked ? 'false' : null; - obj[property] = null; - } else { - obj.has_debt_characteristic = null; - obj[property] = this.getValue(); - } - this.options.app.state.updateFilter(obj); - }, + onRender: function () { + BaseFacet.prototype.onRender.apply(this, arguments); + var value = this.options.app.state.get('query').has_debt_characteristic; + if (value != null && ('' + value === 'false')) { + this.$('.js-facet').filter('[data-empty-characteristic]').addClass('active'); + } + }, - disable: function () { - var property = this.model.get('property'), - obj = {}; - obj.has_debt_characteristic = null; + toggleFacet: function (e) { + var noneCharacteristic = $(e.currentTarget).is('[data-empty-characteristic]'), + property = this.model.get('property'), + obj = {}; + $(e.currentTarget).toggleClass('active'); + if (noneCharacteristic) { + var checked = $(e.currentTarget).is('.active'); + obj.has_debt_characteristic = checked ? 'false' : null; obj[property] = null; - this.options.app.state.updateFilter(obj); - }, + } else { + obj.has_debt_characteristic = null; + obj[property] = this.getValue(); + } + this.options.app.state.updateFilter(obj); + }, - getValues: function () { - var values = this.model.getValues(), - characteristics = this.options.app.characteristics; - return values.map(function (value) { - var ch = _.findWhere(characteristics, { key: value.val }); - if (ch != null) { - _.extend(value, ch, { label: ch.name }); - } - return value; - }); - }, + disable: function () { + var property = this.model.get('property'), + obj = {}; + obj.has_debt_characteristic = null; + obj[property] = null; + this.options.app.state.updateFilter(obj); + }, - sortValues: function (values) { - return _.sortBy(values, 'index'); - }, + getValues: function () { + var values = this.model.getValues(), + characteristics = this.options.app.characteristics; + return values.map(function (value) { + var ch = _.findWhere(characteristics, { key: value.val }); + if (ch != null) { + _.extend(value, ch, { label: ch.name }); + } + return value; + }); + }, - serializeData: function () { - return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), { - values: this.sortValues(this.getValues()) - }); - } - }); + sortValues: function (values) { + return _.sortBy(values, 'index'); + }, + serializeData: function () { + return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), { + values: this.sortValues(this.getValues()) + }); + } }); + + diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/custom-labels-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/custom-labels-facet.js index cda2d4bd4f6..7396208123f 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/custom-labels-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/custom-labels-facet.js @@ -1,28 +1,27 @@ -define([ - './base-facet' -], function (BaseFacet) { +import _ from 'underscore'; +import BaseFacet from './base-facet'; - return BaseFacet.extend({ +export default BaseFacet.extend({ - getLabelsSource: function () { - return []; - }, + getLabelsSource: function () { + return []; + }, - getValues: function () { - var that = this, - labels = that.getLabelsSource(); - return this.model.getValues().map(function (item) { - return _.extend(item, { - label: labels[item.val] - }); + getValues: function () { + var that = this, + labels = that.getLabelsSource(); + return this.model.getValues().map(function (item) { + return _.extend(item, { + label: labels[item.val] }); - }, - - serializeData: function () { - return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), { - values: this.getValues() - }); - } - }); + }); + }, + serializeData: function () { + return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), { + values: this.getValues() + }); + } }); + + diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/custom-values-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/custom-values-facet.js index d42604e6fee..c2499876610 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/custom-values-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/custom-values-facet.js @@ -1,70 +1,69 @@ -define([ - './base-facet', - '../templates' -], function (BaseFacet) { +import _ from 'underscore'; +import BaseFacet from './base-facet'; +import '../templates'; - return BaseFacet.extend({ - template: Templates['coding-rules-custom-values-facet'], +export default BaseFacet.extend({ + template: Templates['coding-rules-custom-values-facet'], - events: function () { - return _.extend(BaseFacet.prototype.events.apply(this, arguments), { - 'change .js-custom-value': 'addCustomValue' - }); - }, + events: function () { + return _.extend(BaseFacet.prototype.events.apply(this, arguments), { + 'change .js-custom-value': 'addCustomValue' + }); + }, - getUrl: function () { - return baseUrl; - }, + getUrl: function () { + return baseUrl; + }, - onRender: function () { - BaseFacet.prototype.onRender.apply(this, arguments); - this.prepareSearch(); - }, + onRender: function () { + BaseFacet.prototype.onRender.apply(this, arguments); + this.prepareSearch(); + }, - prepareSearch: function () { - this.$('.js-custom-value').select2({ - placeholder: t('search_verb'), - minimumInputLength: 1, - allowClear: false, - formatNoMatches: function () { - return t('select2.noMatches'); - }, - formatSearching: function () { - return t('select2.searching'); - }, - formatInputTooShort: function () { - return tp('select2.tooShort', 1); - }, - width: '100%', - ajax: this.prepareAjaxSearch() - }); - }, + prepareSearch: function () { + this.$('.js-custom-value').select2({ + placeholder: t('search_verb'), + minimumInputLength: 1, + allowClear: false, + formatNoMatches: function () { + return t('select2.noMatches'); + }, + formatSearching: function () { + return t('select2.searching'); + }, + formatInputTooShort: function () { + return tp('select2.tooShort', 1); + }, + width: '100%', + ajax: this.prepareAjaxSearch() + }); + }, - prepareAjaxSearch: function () { - return { - quietMillis: 300, - url: this.getUrl(), - data: function (term, page) { - return { s: term, p: page }; - }, - results: function (data) { - return { more: data.more, results: data.results }; - } - }; - }, - - addCustomValue: function () { - var property = this.model.get('property'), - customValue = this.$('.js-custom-value').select2('val'), - value = this.getValue(); - if (value.length > 0) { - value += ','; + prepareAjaxSearch: function () { + return { + quietMillis: 300, + url: this.getUrl(), + data: function (term, page) { + return { s: term, p: page }; + }, + results: function (data) { + return { more: data.more, results: data.results }; } - value += customValue; - var obj = {}; - obj[property] = value; - this.options.app.state.updateFilter(obj); - } - }); + }; + }, + addCustomValue: function () { + var property = this.model.get('property'), + customValue = this.$('.js-custom-value').select2('val'), + value = this.getValue(); + if (value.length > 0) { + value += ','; + } + value += customValue; + var obj = {}; + obj[property] = value; + this.options.app.state.updateFilter(obj); + } }); + + diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/inheritance-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/inheritance-facet.js index 08339bebe14..e3dc2c2cafc 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/inheritance-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/inheritance-facet.js @@ -1,71 +1,69 @@ -define([ - './base-facet', - '../templates' -], function (BaseFacet) { +import $ from 'jquery'; +import _ from 'underscore'; +import BaseFacet from './base-facet'; +import '../templates'; - var $ = jQuery; +export default BaseFacet.extend({ + template: Templates['coding-rules-inheritance-facet'], - return BaseFacet.extend({ - template: Templates['coding-rules-inheritance-facet'], + initialize: function (options) { + this.listenTo(options.app.state, 'change:query', this.onQueryChange); + }, - initialize: function (options) { - this.listenTo(options.app.state, 'change:query', this.onQueryChange); - }, - - onQueryChange: function () { - var query = this.options.app.state.get('query'), - isProfileSelected = query.qprofile != null; - if (isProfileSelected) { - var profile = _.findWhere(this.options.app.qualityProfiles, { key: query.qprofile }); - if (profile != null && profile.parentKey == null) { - this.forbid(); - } - } else { + onQueryChange: function () { + var query = this.options.app.state.get('query'), + isProfileSelected = query.qprofile != null; + if (isProfileSelected) { + var profile = _.findWhere(this.options.app.qualityProfiles, { key: query.qprofile }); + if (profile != null && profile.parentKey == null) { this.forbid(); } - }, - - onRender: function () { - BaseFacet.prototype.onRender.apply(this, arguments); - this.onQueryChange(); - }, + } else { + this.forbid(); + } + }, - forbid: function () { - BaseFacet.prototype.forbid.apply(this, arguments); - this.$el.prop('title', t('coding_rules.filters.inheritance.inactive')); - }, + onRender: function () { + BaseFacet.prototype.onRender.apply(this, arguments); + this.onQueryChange(); + }, - allow: function () { - BaseFacet.prototype.allow.apply(this, arguments); - this.$el.prop('title', null); - }, + forbid: function () { + BaseFacet.prototype.forbid.apply(this, arguments); + this.$el.prop('title', t('coding_rules.filters.inheritance.inactive')); + }, - getValues: function () { - var values = ['NONE', 'INHERITED', 'OVERRIDES']; - return values.map(function (key) { - return { - label: t('coding_rules.filters.inheritance', key.toLowerCase()), - val: key - }; - }); - }, + allow: function () { + BaseFacet.prototype.allow.apply(this, arguments); + this.$el.prop('title', null); + }, - toggleFacet: function (e) { - var obj = {}, - property = this.model.get('property'); - if ($(e.currentTarget).is('.active')) { - obj[property] = null; - } else { - obj[property] = $(e.currentTarget).data('value'); - } - this.options.app.state.updateFilter(obj); - }, + getValues: function () { + var values = ['NONE', 'INHERITED', 'OVERRIDES']; + return values.map(function (key) { + return { + label: t('coding_rules.filters.inheritance', key.toLowerCase()), + val: key + }; + }); + }, - serializeData: function () { - return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), { - values: this.getValues() - }); + toggleFacet: function (e) { + var obj = {}, + property = this.model.get('property'); + if ($(e.currentTarget).is('.active')) { + obj[property] = null; + } else { + obj[property] = $(e.currentTarget).data('value'); } - }); + this.options.app.state.updateFilter(obj); + }, + serializeData: function () { + return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), { + values: this.getValues() + }); + } }); + + diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/key-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/key-facet.js index 7c26655108c..4117345bd4b 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/key-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/key-facet.js @@ -1,24 +1,23 @@ -define([ - './base-facet', - '../templates' -], function (BaseFacet) { +import BaseFacet from './base-facet'; +import _ from 'underscore'; +import '../templates'; - return BaseFacet.extend({ - template: Templates['coding-rules-key-facet'], +export default BaseFacet.extend({ + template: Templates['coding-rules-key-facet'], - onRender: function () { - this.$el.toggleClass('hidden', !this.options.app.state.get('query').rule_key); - }, + onRender: function () { + this.$el.toggleClass('hidden', !this.options.app.state.get('query').rule_key); + }, - disable: function () { - this.options.app.state.updateFilter({ rule_key: null }); - }, - - serializeData: function () { - return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), { - key: this.options.app.state.get('query').rule_key - }); - } - }); + disable: function () { + this.options.app.state.updateFilter({ rule_key: null }); + }, + serializeData: function () { + return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), { + key: this.options.app.state.get('query').rule_key + }); + } }); + + diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/language-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/language-facet.js index 7033080676f..258640cbd89 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/language-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/language-facet.js @@ -1,51 +1,50 @@ -define([ - './custom-values-facet' -], function (CustomValuesFacet) { - - return CustomValuesFacet.extend({ - - getUrl: function () { - return baseUrl + '/api/languages/list'; - }, - - prepareAjaxSearch: function () { - return { - quietMillis: 300, - url: this.getUrl(), - data: function (term) { - return { q: term, ps: 10000 }; - }, - results: function (data) { - return { - more: false, - results: data.languages.map(function (lang) { - return { id: lang.key, text: lang.name }; - }) - }; - } - }; - }, - - getLabelsSource: function () { - return this.options.app.languages; - }, - - getValues: function () { - var that = this, - labels = that.getLabelsSource(); - return this.model.getValues().map(function (item) { - return _.extend(item, { - label: labels[item.val] - }); +import _ from 'underscore'; +import CustomValuesFacet from './custom-values-facet'; + +export default CustomValuesFacet.extend({ + + getUrl: function () { + return baseUrl + '/api/languages/list'; + }, + + prepareAjaxSearch: function () { + return { + quietMillis: 300, + url: this.getUrl(), + data: function (term) { + return { q: term, ps: 10000 }; + }, + results: function (data) { + return { + more: false, + results: data.languages.map(function (lang) { + return { id: lang.key, text: lang.name }; + }) + }; + } + }; + }, + + getLabelsSource: function () { + return this.options.app.languages; + }, + + getValues: function () { + var that = this, + labels = that.getLabelsSource(); + return this.model.getValues().map(function (item) { + return _.extend(item, { + label: labels[item.val] }); - }, + }); + }, - serializeData: function () { - return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), { - values: this.getValues() - }); - } - - }); + serializeData: function () { + return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), { + values: this.getValues() + }); + } }); + + diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js index 21a7ed30d75..5686d6b2cea 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js @@ -1,80 +1,78 @@ -define([ - './base-facet', - '../templates' -], function (BaseFacet) { +import $ from 'jquery'; +import _ from 'underscore'; +import BaseFacet from './base-facet'; +import '../templates'; - var $ = jQuery; +export default BaseFacet.extend({ + template: Templates['coding-rules-quality-profile-facet'], - return BaseFacet.extend({ - template: Templates['coding-rules-quality-profile-facet'], + events: function () { + return _.extend(BaseFacet.prototype.events.apply(this, arguments), { + 'click .js-active': 'setActivation', + 'click .js-inactive': 'unsetActivation' + }); + }, - events: function () { - return _.extend(BaseFacet.prototype.events.apply(this, arguments), { - 'click .js-active': 'setActivation', - 'click .js-inactive': 'unsetActivation' - }); - }, + getValues: function () { + var that = this, + languagesQuery = this.options.app.state.get('query').languages, + languages = languagesQuery != null ? languagesQuery.split(',') : [], + lang = languages.length === 1 ? languages[0] : null, + values = this.options.app.qualityProfiles + .filter(function (profile) { + return lang != null ? profile.lang === lang : true; + }) + .map(function (profile) { + return { + label: profile.name, + extra: that.options.app.languages[profile.lang], + val: profile.key + }; + }); + return _.sortBy(values, 'label'); + }, - getValues: function () { - var that = this, - languagesQuery = this.options.app.state.get('query').languages, - languages = languagesQuery != null ? languagesQuery.split(',') : [], - lang = languages.length === 1 ? languages[0] : null, - values = this.options.app.qualityProfiles - .filter(function (profile) { - return lang != null ? profile.lang === lang : true; - }) - .map(function (profile) { - return { - label: profile.name, - extra: that.options.app.languages[profile.lang], - val: profile.key - }; - }); - return _.sortBy(values, 'label'); - }, + toggleFacet: function (e) { + var obj = {}, + property = this.model.get('property'); + if ($(e.currentTarget).is('.active')) { + obj.activation = null; + obj[property] = null; + } else { + obj.activation = true; + obj[property] = $(e.currentTarget).data('value'); + } + this.options.app.state.updateFilter(obj); + }, - toggleFacet: function (e) { - var obj = {}, - property = this.model.get('property'); - if ($(e.currentTarget).is('.active')) { - obj.activation = null; - obj[property] = null; - } else { - obj.activation = true; - obj[property] = $(e.currentTarget).data('value'); - } - this.options.app.state.updateFilter(obj); - }, + setActivation: function (e) { + e.stopPropagation(); + this.options.app.state.updateFilter({ activation: 'true' }); + }, - setActivation: function (e) { - e.stopPropagation(); - this.options.app.state.updateFilter({ activation: 'true' }); - }, + unsetActivation: function (e) { + e.stopPropagation(); + this.options.app.state.updateFilter({ activation: 'false', active_severities: null }); + }, - unsetActivation: function (e) { - e.stopPropagation(); - this.options.app.state.updateFilter({ activation: 'false', active_severities: null }); - }, + getToggled: function () { + var activation = this.options.app.state.get('query').activation; + return activation === 'true' || activation === true; + }, - getToggled: function () { - var activation = this.options.app.state.get('query').activation; - return activation === 'true' || activation === true; - }, + disable: function () { + var obj = { activation: null }, + property = this.model.get('property'); + obj[property] = null; + this.options.app.state.updateFilter(obj); + }, - disable: function () { - var obj = { activation: null }, - property = this.model.get('property'); - obj[property] = null; - this.options.app.state.updateFilter(obj); - }, + serializeData: function () { + return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), { + values: this.getValues(), + toggled: this.getToggled() + }); + } +}); - serializeData: function () { - return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), { - values: this.getValues(), - toggled: this.getToggled() - }); - } - }); -}); diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/query-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/query-facet.js index f4770ff165f..fe380885438 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/query-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/query-facet.js @@ -1,37 +1,36 @@ -define([ - './base-facet', - '../templates' -], function (BaseFacet) { +import _ from 'underscore'; +import BaseFacet from './base-facet'; +import '../templates'; - return BaseFacet.extend({ - template: Templates['coding-rules-query-facet'], +export default BaseFacet.extend({ + template: Templates['coding-rules-query-facet'], - events: function () { - return _.extend(BaseFacet.prototype.events.apply(this, arguments), { - 'submit form': 'onFormSubmit' - }); - }, + events: function () { + return _.extend(BaseFacet.prototype.events.apply(this, arguments), { + 'submit form': 'onFormSubmit' + }); + }, - onRender: function () { - this.$el.attr('data-property', this.model.get('property')); - var query = this.options.app.state.get('query'), - value = query.q; - if (value != null) { - this.$('input').val(value); - } - }, - - onFormSubmit: function (e) { - e.preventDefault(); - this.applyFacet(); - }, - - applyFacet: function() { - var obj = {}, - property = this.model.get('property'); - obj[property] = this.$('input').val(); - this.options.app.state.updateFilter(obj, { force: true }); + onRender: function () { + this.$el.attr('data-property', this.model.get('property')); + var query = this.options.app.state.get('query'), + value = query.q; + if (value != null) { + this.$('input').val(value); } - }); + }, + + onFormSubmit: function (e) { + e.preventDefault(); + this.applyFacet(); + }, + applyFacet: function () { + var obj = {}, + property = this.model.get('property'); + obj[property] = this.$('input').val(); + this.options.app.state.updateFilter(obj, { force: true }); + } }); + + diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/repository-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/repository-facet.js index 163bd5d23e8..8efc8b46869 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/repository-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/repository-facet.js @@ -1,55 +1,54 @@ -define([ - './custom-values-facet' -], function (CustomValuesFacet) { - - return CustomValuesFacet.extend({ - - getUrl: function () { - return baseUrl + '/api/rules/repositories'; - }, - - prepareAjaxSearch: function () { - return { - quietMillis: 300, - url: this.getUrl(), - data: function (term) { - return { q: term, ps: 10000 }; - }, - results: function (data) { - return { - more: false, - results: data.repositories.map(function (repo) { - return { id: repo.key, text: repo.name + ' (' + repo.language + ')' }; - }) - }; - } - }; - }, - - getLabelsSource: function () { - var repos = this.options.app.repositories; - return _.object(_.pluck(repos, 'key'), _.pluck(repos, 'name')); - }, - - getValues: function () { - var that = this, - labels = that.getLabelsSource(); - return this.model.getValues().map(function (value) { - var repo = _.findWhere(that.options.app.repositories, { key: value.val }); - if (repo != null) { - var langName = that.options.app.languages[repo.language]; - _.extend(value, { extra: langName }); - } - return _.extend(value, { label: labels[value.val] }); - }); - }, - - serializeData: function () { - return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), { - values: this.getValues() - }); - } - - }); +import _ from 'underscore'; +import CustomValuesFacet from './custom-values-facet'; + +export default CustomValuesFacet.extend({ + + getUrl: function () { + return baseUrl + '/api/rules/repositories'; + }, + + prepareAjaxSearch: function () { + return { + quietMillis: 300, + url: this.getUrl(), + data: function (term) { + return { q: term, ps: 10000 }; + }, + results: function (data) { + return { + more: false, + results: data.repositories.map(function (repo) { + return { id: repo.key, text: repo.name + ' (' + repo.language + ')' }; + }) + }; + } + }; + }, + + getLabelsSource: function () { + var repos = this.options.app.repositories; + return _.object(_.pluck(repos, 'key'), _.pluck(repos, 'name')); + }, + + getValues: function () { + var that = this, + labels = that.getLabelsSource(); + return this.model.getValues().map(function (value) { + var repo = _.findWhere(that.options.app.repositories, { key: value.val }); + if (repo != null) { + var langName = that.options.app.languages[repo.language]; + _.extend(value, { extra: langName }); + } + return _.extend(value, { label: labels[value.val] }); + }); + }, + + serializeData: function () { + return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), { + values: this.getValues() + }); + } }); + + diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/severity-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/severity-facet.js index 2b8a8af7974..6ab2c4f8a4d 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/severity-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/severity-facet.js @@ -1,18 +1,17 @@ -define([ - './base-facet', - '../templates' -], function (BaseFacet) { +import _ from 'underscore'; +import BaseFacet from './base-facet'; +import '../templates'; - return BaseFacet.extend({ - template: Templates['coding-rules-severity-facet'], - severities: ['BLOCKER', 'MINOR', 'CRITICAL', 'INFO', 'MAJOR'], - - sortValues: function (values) { - var order = this.severities; - return _.sortBy(values, function (v) { - return order.indexOf(v.val); - }); - } - }); +export default BaseFacet.extend({ + template: Templates['coding-rules-severity-facet'], + severities: ['BLOCKER', 'MINOR', 'CRITICAL', 'INFO', 'MAJOR'], + sortValues: function (values) { + var order = this.severities; + return _.sortBy(values, function (v) { + return order.indexOf(v.val); + }); + } }); + + diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/status-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/status-facet.js index 51a0c2c4451..7d2e627f243 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/status-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/status-facet.js @@ -1,30 +1,29 @@ -define([ - './base-facet' -], function (BaseFacet) { +import _ from 'underscore'; +import BaseFacet from './base-facet'; - return BaseFacet.extend({ - statuses: ['READY', 'DEPRECATED', 'BETA'], +export default BaseFacet.extend({ + statuses: ['READY', 'DEPRECATED', 'BETA'], - getValues: function () { - var values = this.model.getValues(); - var x = values.map(function (value) { - return _.extend(value, { label: t('rules.status', value.val.toLowerCase()) }); - }); - return x; - }, + getValues: function () { + var values = this.model.getValues(); + var x = values.map(function (value) { + return _.extend(value, { label: t('rules.status', value.val.toLowerCase()) }); + }); + return x; + }, - sortValues: function (values) { - var order = this.statuses; - return _.sortBy(values, function (v) { - return order.indexOf(v.val); - }); - }, - - serializeData: function () { - return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), { - values: this.sortValues(this.getValues()) - }); - } - }); + sortValues: function (values) { + var order = this.statuses; + return _.sortBy(values, function (v) { + return order.indexOf(v.val); + }); + }, + serializeData: function () { + return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), { + values: this.sortValues(this.getValues()) + }); + } }); + + diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/tag-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/tag-facet.js index cf4ba7e135e..b54b63ddb1a 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/tag-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/tag-facet.js @@ -1,31 +1,29 @@ -define([ - './custom-values-facet' -], function (CustomValuesFacet) { +import CustomValuesFacet from './custom-values-facet'; - return CustomValuesFacet.extend({ +export default CustomValuesFacet.extend({ - getUrl: function () { - return baseUrl + '/api/rules/tags'; - }, + getUrl: function () { + return baseUrl + '/api/rules/tags'; + }, - prepareAjaxSearch: function () { - return { - quietMillis: 300, - url: this.getUrl(), - data: function (term) { - return { q: term, ps: 10000 }; - }, - results: function (data) { - return { - more: false, - results: data.tags.map(function (tag) { - return { id: tag, text: tag }; - }) - }; - } - }; - } - - }); + prepareAjaxSearch: function () { + return { + quietMillis: 300, + url: this.getUrl(), + data: function (term) { + return { q: term, ps: 10000 }; + }, + results: function (data) { + return { + more: false, + results: data.tags.map(function (tag) { + return { id: tag, text: tag }; + }) + }; + } + }; + } }); + + diff --git a/server/sonar-web/src/main/js/apps/coding-rules/facets/template-facet.js b/server/sonar-web/src/main/js/apps/coding-rules/facets/template-facet.js index 8e35756ab4a..bf819b33b5f 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/facets/template-facet.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/facets/template-facet.js @@ -1,33 +1,30 @@ -define([ - './base-facet', - '../templates' -], function (BaseFacet) { +import $ from 'jquery'; +import BaseFacet from './base-facet'; +import '../templates'; - var $ = jQuery; +export default BaseFacet.extend({ + template: Templates['coding-rules-template-facet'], - return BaseFacet.extend({ - template: Templates['coding-rules-template-facet'], - - onRender: function () { - BaseFacet.prototype.onRender.apply(this, arguments); - var value = this.options.app.state.get('query').is_template; - if (value != null) { - this.$('.js-facet').filter('[data-value="' + value + '"]').addClass('active'); - } - }, - - toggleFacet: function (e) { - $(e.currentTarget).toggleClass('active'); - var property = this.model.get('property'), - obj = {}; - if ($(e.currentTarget).hasClass('active')) { - obj[property] = '' + $(e.currentTarget).data('value'); - } else { - obj[property] = null; - } - this.options.app.state.updateFilter(obj); + onRender: function () { + BaseFacet.prototype.onRender.apply(this, arguments); + var value = this.options.app.state.get('query').is_template; + if (value != null) { + this.$('.js-facet').filter('[data-value="' + value + '"]').addClass('active'); } + }, - }); + toggleFacet: function (e) { + $(e.currentTarget).toggleClass('active'); + var property = this.model.get('property'), + obj = {}; + if ($(e.currentTarget).hasClass('active')) { + obj[property] = '' + $(e.currentTarget).data('value'); + } else { + obj[property] = null; + } + this.options.app.state.updateFilter(obj); + } }); + + |