]> source.dussan.org Git - sonarqube.git/commitdiff
migrate js apps to es2015 modules
authorStas Vilchik <vilchiks@gmail.com>
Thu, 17 Sep 2015 14:15:28 +0000 (16:15 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Fri, 18 Sep 2015 08:47:27 +0000 (10:47 +0200)
264 files changed:
server/sonar-web/.eslintrc
server/sonar-web/Gruntfile.coffee
server/sonar-web/src/main/js/apps/account/app.js
server/sonar-web/src/main/js/apps/account/change-password-view.js
server/sonar-web/src/main/js/apps/api-documentation/action-view.js
server/sonar-web/src/main/js/apps/api-documentation/actions-view.js
server/sonar-web/src/main/js/apps/api-documentation/app.js
server/sonar-web/src/main/js/apps/api-documentation/controller.js
server/sonar-web/src/main/js/apps/api-documentation/filters-view.js
server/sonar-web/src/main/js/apps/api-documentation/header-view.js
server/sonar-web/src/main/js/apps/api-documentation/item-view.js
server/sonar-web/src/main/js/apps/api-documentation/layout.js
server/sonar-web/src/main/js/apps/api-documentation/list-view.js
server/sonar-web/src/main/js/apps/api-documentation/list.js
server/sonar-web/src/main/js/apps/api-documentation/router.js
server/sonar-web/src/main/js/apps/api-documentation/search-view.js
server/sonar-web/src/main/js/apps/coding-rules/app.js
server/sonar-web/src/main/js/apps/coding-rules/bulk-change-modal-view.js
server/sonar-web/src/main/js/apps/coding-rules/bulk-change-popup-view.js
server/sonar-web/src/main/js/apps/coding-rules/controller.js
server/sonar-web/src/main/js/apps/coding-rules/facets-view.js
server/sonar-web/src/main/js/apps/coding-rules/facets/active-severity-facet.js
server/sonar-web/src/main/js/apps/coding-rules/facets/available-since-facet.js
server/sonar-web/src/main/js/apps/coding-rules/facets/base-facet.js
server/sonar-web/src/main/js/apps/coding-rules/facets/characteristic-facet.js
server/sonar-web/src/main/js/apps/coding-rules/facets/custom-labels-facet.js
server/sonar-web/src/main/js/apps/coding-rules/facets/custom-values-facet.js
server/sonar-web/src/main/js/apps/coding-rules/facets/inheritance-facet.js
server/sonar-web/src/main/js/apps/coding-rules/facets/key-facet.js
server/sonar-web/src/main/js/apps/coding-rules/facets/language-facet.js
server/sonar-web/src/main/js/apps/coding-rules/facets/quality-profile-facet.js
server/sonar-web/src/main/js/apps/coding-rules/facets/query-facet.js
server/sonar-web/src/main/js/apps/coding-rules/facets/repository-facet.js
server/sonar-web/src/main/js/apps/coding-rules/facets/severity-facet.js
server/sonar-web/src/main/js/apps/coding-rules/facets/status-facet.js
server/sonar-web/src/main/js/apps/coding-rules/facets/tag-facet.js
server/sonar-web/src/main/js/apps/coding-rules/facets/template-facet.js
server/sonar-web/src/main/js/apps/coding-rules/filters-view.js
server/sonar-web/src/main/js/apps/coding-rules/layout.js
server/sonar-web/src/main/js/apps/coding-rules/models/rule.js
server/sonar-web/src/main/js/apps/coding-rules/models/rules.js
server/sonar-web/src/main/js/apps/coding-rules/models/state.js
server/sonar-web/src/main/js/apps/coding-rules/rule-details-view.js
server/sonar-web/src/main/js/apps/coding-rules/rule-filter-view.js
server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-creation-view.js
server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rule-view.js
server/sonar-web/src/main/js/apps/coding-rules/rule/custom-rules-view.js
server/sonar-web/src/main/js/apps/coding-rules/rule/manual-rule-creation-view.js
server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js
server/sonar-web/src/main/js/apps/coding-rules/rule/rule-description-view.js
server/sonar-web/src/main/js/apps/coding-rules/rule/rule-filter-mixin.js
server/sonar-web/src/main/js/apps/coding-rules/rule/rule-issues-view.js
server/sonar-web/src/main/js/apps/coding-rules/rule/rule-meta-view.js
server/sonar-web/src/main/js/apps/coding-rules/rule/rule-parameters-view.js
server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profile-view.js
server/sonar-web/src/main/js/apps/coding-rules/rule/rule-profiles-view.js
server/sonar-web/src/main/js/apps/coding-rules/workspace-header-view.js
server/sonar-web/src/main/js/apps/coding-rules/workspace-list-empty-view.js
server/sonar-web/src/main/js/apps/coding-rules/workspace-list-item-view.js
server/sonar-web/src/main/js/apps/coding-rules/workspace-list-view.js
server/sonar-web/src/main/js/apps/computation/app.js
server/sonar-web/src/main/js/apps/computation/header-view.js
server/sonar-web/src/main/js/apps/computation/layout.js
server/sonar-web/src/main/js/apps/computation/list-footer-view.js
server/sonar-web/src/main/js/apps/computation/list-item-view.js
server/sonar-web/src/main/js/apps/computation/list-view.js
server/sonar-web/src/main/js/apps/computation/report.js
server/sonar-web/src/main/js/apps/computation/reports.js
server/sonar-web/src/main/js/apps/computation/router.js
server/sonar-web/src/main/js/apps/computation/search-view.js
server/sonar-web/src/main/js/apps/custom-measures/app.js [new file with mode: 0644]
server/sonar-web/src/main/js/apps/custom-measures/app.jsx [deleted file]
server/sonar-web/src/main/js/apps/custom-measures/create-view.js
server/sonar-web/src/main/js/apps/custom-measures/custom-measure.js
server/sonar-web/src/main/js/apps/custom-measures/custom-measures.js
server/sonar-web/src/main/js/apps/custom-measures/delete-view.js
server/sonar-web/src/main/js/apps/custom-measures/form-view.js
server/sonar-web/src/main/js/apps/custom-measures/header-view.js
server/sonar-web/src/main/js/apps/custom-measures/layout.js
server/sonar-web/src/main/js/apps/custom-measures/list-footer-view.js
server/sonar-web/src/main/js/apps/custom-measures/list-item-view.js
server/sonar-web/src/main/js/apps/custom-measures/list-view.js
server/sonar-web/src/main/js/apps/custom-measures/update-view.js
server/sonar-web/src/main/js/apps/drilldown/app.js
server/sonar-web/src/main/js/apps/global-permissions/app.jsx
server/sonar-web/src/main/js/apps/global-permissions/groups-view.js
server/sonar-web/src/main/js/apps/global-permissions/main.jsx
server/sonar-web/src/main/js/apps/global-permissions/permission-users-groups-mixin.jsx
server/sonar-web/src/main/js/apps/global-permissions/permission-users.jsx
server/sonar-web/src/main/js/apps/global-permissions/permission.jsx
server/sonar-web/src/main/js/apps/global-permissions/users-view.js
server/sonar-web/src/main/js/apps/groups/app.js
server/sonar-web/src/main/js/apps/groups/create-view.js
server/sonar-web/src/main/js/apps/groups/delete-view.js
server/sonar-web/src/main/js/apps/groups/form-view.js
server/sonar-web/src/main/js/apps/groups/group.js
server/sonar-web/src/main/js/apps/groups/groups.js
server/sonar-web/src/main/js/apps/groups/header-view.js
server/sonar-web/src/main/js/apps/groups/layout.js
server/sonar-web/src/main/js/apps/groups/list-footer-view.js
server/sonar-web/src/main/js/apps/groups/list-item-view.js
server/sonar-web/src/main/js/apps/groups/list-view.js
server/sonar-web/src/main/js/apps/groups/search-view.js
server/sonar-web/src/main/js/apps/groups/update-view.js
server/sonar-web/src/main/js/apps/groups/users-view.js
server/sonar-web/src/main/js/apps/issues/app-context.js
server/sonar-web/src/main/js/apps/issues/app.js
server/sonar-web/src/main/js/apps/issues/component-viewer/issue-view.js
server/sonar-web/src/main/js/apps/issues/component-viewer/main.js
server/sonar-web/src/main/js/apps/issues/controller.js
server/sonar-web/src/main/js/apps/issues/facets-view.js
server/sonar-web/src/main/js/apps/issues/facets/action-plan-facet.js
server/sonar-web/src/main/js/apps/issues/facets/assignee-facet.js
server/sonar-web/src/main/js/apps/issues/facets/author-facet.js
server/sonar-web/src/main/js/apps/issues/facets/base-facet.js
server/sonar-web/src/main/js/apps/issues/facets/context-facet.js
server/sonar-web/src/main/js/apps/issues/facets/creation-date-facet.js
server/sonar-web/src/main/js/apps/issues/facets/custom-values-facet.js
server/sonar-web/src/main/js/apps/issues/facets/file-facet.js
server/sonar-web/src/main/js/apps/issues/facets/issue-key-facet.js
server/sonar-web/src/main/js/apps/issues/facets/language-facet.js
server/sonar-web/src/main/js/apps/issues/facets/mode-facet.js
server/sonar-web/src/main/js/apps/issues/facets/module-facet.js
server/sonar-web/src/main/js/apps/issues/facets/project-facet.js
server/sonar-web/src/main/js/apps/issues/facets/reporter-facet.js
server/sonar-web/src/main/js/apps/issues/facets/resolution-facet.js
server/sonar-web/src/main/js/apps/issues/facets/rule-facet.js
server/sonar-web/src/main/js/apps/issues/facets/severity-facet.js
server/sonar-web/src/main/js/apps/issues/facets/status-facet.js
server/sonar-web/src/main/js/apps/issues/facets/tag-facet.js
server/sonar-web/src/main/js/apps/issues/filters-view.js
server/sonar-web/src/main/js/apps/issues/helpers/format-facet-value.js
server/sonar-web/src/main/js/apps/issues/issue-filter-view.js
server/sonar-web/src/main/js/apps/issues/layout.js
server/sonar-web/src/main/js/apps/issues/models/filter.js
server/sonar-web/src/main/js/apps/issues/models/filters.js
server/sonar-web/src/main/js/apps/issues/models/issue.js
server/sonar-web/src/main/js/apps/issues/models/issues.js
server/sonar-web/src/main/js/apps/issues/models/state.js
server/sonar-web/src/main/js/apps/issues/router.js
server/sonar-web/src/main/js/apps/issues/workspace-header-view.js
server/sonar-web/src/main/js/apps/issues/workspace-home-view.js
server/sonar-web/src/main/js/apps/issues/workspace-list-empty-view.js
server/sonar-web/src/main/js/apps/issues/workspace-list-item-view.js
server/sonar-web/src/main/js/apps/issues/workspace-list-view.js
server/sonar-web/src/main/js/apps/maintenance/app.js
server/sonar-web/src/main/js/apps/maintenance/main-view.js
server/sonar-web/src/main/js/apps/markdown/app.js
server/sonar-web/src/main/js/apps/markdown/markdown-help-view.js
server/sonar-web/src/main/js/apps/measures/app.js
server/sonar-web/src/main/js/apps/measures/measures-filter-bar.js
server/sonar-web/src/main/js/apps/metrics/app.js
server/sonar-web/src/main/js/apps/metrics/create-view.js
server/sonar-web/src/main/js/apps/metrics/delete-view.js
server/sonar-web/src/main/js/apps/metrics/form-view.js
server/sonar-web/src/main/js/apps/metrics/header-view.js
server/sonar-web/src/main/js/apps/metrics/layout.js
server/sonar-web/src/main/js/apps/metrics/list-footer-view.js
server/sonar-web/src/main/js/apps/metrics/list-item-view.js
server/sonar-web/src/main/js/apps/metrics/list-view.js
server/sonar-web/src/main/js/apps/metrics/metric.js
server/sonar-web/src/main/js/apps/metrics/metrics.js
server/sonar-web/src/main/js/apps/metrics/update-view.js
server/sonar-web/src/main/js/apps/nav/component/component-nav-menu.jsx
server/sonar-web/src/main/js/apps/nav/component/component-nav.jsx
server/sonar-web/src/main/js/apps/nav/global/global-nav-search.jsx
server/sonar-web/src/main/js/apps/nav/global/global-nav.jsx
server/sonar-web/src/main/js/apps/nav/global/search-view.js
server/sonar-web/src/main/js/apps/nav/global/shortcuts-help-view.js
server/sonar-web/src/main/js/apps/nav/links-mixin.jsx
server/sonar-web/src/main/js/apps/nav/settings/settings-nav.jsx
server/sonar-web/src/main/js/apps/project-permissions/apply-template-view.jsx
server/sonar-web/src/main/js/apps/project-permissions/groups-view.js
server/sonar-web/src/main/js/apps/project-permissions/main-component.jsx
server/sonar-web/src/main/js/apps/project-permissions/search.jsx
server/sonar-web/src/main/js/apps/project-permissions/users-view.js
server/sonar-web/src/main/js/apps/provisioning/app.js
server/sonar-web/src/main/js/apps/provisioning/bulk-delete-view.js
server/sonar-web/src/main/js/apps/provisioning/create-view.js
server/sonar-web/src/main/js/apps/provisioning/delete-view.js
server/sonar-web/src/main/js/apps/provisioning/form-view.js
server/sonar-web/src/main/js/apps/provisioning/header-view.js
server/sonar-web/src/main/js/apps/provisioning/layout.js
server/sonar-web/src/main/js/apps/provisioning/list-footer-view.js
server/sonar-web/src/main/js/apps/provisioning/list-item-view.js
server/sonar-web/src/main/js/apps/provisioning/list-view.js
server/sonar-web/src/main/js/apps/provisioning/project.js
server/sonar-web/src/main/js/apps/provisioning/projects.js
server/sonar-web/src/main/js/apps/provisioning/search-view.js
server/sonar-web/src/main/js/apps/quality-gates/actions-view.js
server/sonar-web/src/main/js/apps/quality-gates/app.js
server/sonar-web/src/main/js/apps/quality-gates/condition.js
server/sonar-web/src/main/js/apps/quality-gates/conditions.js
server/sonar-web/src/main/js/apps/quality-gates/controller.js
server/sonar-web/src/main/js/apps/quality-gates/copy-view.js
server/sonar-web/src/main/js/apps/quality-gates/create-view.js
server/sonar-web/src/main/js/apps/quality-gates/delete-view.js
server/sonar-web/src/main/js/apps/quality-gates/details-view.js
server/sonar-web/src/main/js/apps/quality-gates/form-view.js
server/sonar-web/src/main/js/apps/quality-gates/gate-condition-view.js
server/sonar-web/src/main/js/apps/quality-gates/gate-conditions-delete-view.js
server/sonar-web/src/main/js/apps/quality-gates/gate-conditions-empty-view.js
server/sonar-web/src/main/js/apps/quality-gates/gate-conditions-view.js
server/sonar-web/src/main/js/apps/quality-gates/gate-projects-view.js
server/sonar-web/src/main/js/apps/quality-gates/gate-view.js
server/sonar-web/src/main/js/apps/quality-gates/gate.js
server/sonar-web/src/main/js/apps/quality-gates/gates-view.js
server/sonar-web/src/main/js/apps/quality-gates/gates.js
server/sonar-web/src/main/js/apps/quality-gates/header-view.js
server/sonar-web/src/main/js/apps/quality-gates/intro-view.js
server/sonar-web/src/main/js/apps/quality-gates/layout.js
server/sonar-web/src/main/js/apps/quality-gates/rename-view.js
server/sonar-web/src/main/js/apps/quality-gates/router.js
server/sonar-web/src/main/js/apps/quality-profiles/actions-view.js
server/sonar-web/src/main/js/apps/quality-profiles/app.js
server/sonar-web/src/main/js/apps/quality-profiles/change-profile-parent-view.js
server/sonar-web/src/main/js/apps/quality-profiles/controller.js
server/sonar-web/src/main/js/apps/quality-profiles/copy-profile-view.js
server/sonar-web/src/main/js/apps/quality-profiles/create-profile-view.js
server/sonar-web/src/main/js/apps/quality-profiles/delete-profile-view.js
server/sonar-web/src/main/js/apps/quality-profiles/helpers.js
server/sonar-web/src/main/js/apps/quality-profiles/intro-view.js
server/sonar-web/src/main/js/apps/quality-profiles/layout.js
server/sonar-web/src/main/js/apps/quality-profiles/profile-changelog-view.js
server/sonar-web/src/main/js/apps/quality-profiles/profile-comparison-view.js
server/sonar-web/src/main/js/apps/quality-profiles/profile-details-view.js
server/sonar-web/src/main/js/apps/quality-profiles/profile-header-view.js
server/sonar-web/src/main/js/apps/quality-profiles/profile-view.js
server/sonar-web/src/main/js/apps/quality-profiles/profile.js
server/sonar-web/src/main/js/apps/quality-profiles/profiles-empty-view.js
server/sonar-web/src/main/js/apps/quality-profiles/profiles-view.js
server/sonar-web/src/main/js/apps/quality-profiles/profiles.js
server/sonar-web/src/main/js/apps/quality-profiles/rename-profile-view.js
server/sonar-web/src/main/js/apps/quality-profiles/restore-built-in-profiles-view.js
server/sonar-web/src/main/js/apps/quality-profiles/restore-profile-view.js
server/sonar-web/src/main/js/apps/quality-profiles/router.js
server/sonar-web/src/main/js/apps/source-viewer/app.js
server/sonar-web/src/main/js/apps/update-center/app.js
server/sonar-web/src/main/js/apps/update-center/controller.js
server/sonar-web/src/main/js/apps/update-center/footer-view.js
server/sonar-web/src/main/js/apps/update-center/header-view.js
server/sonar-web/src/main/js/apps/update-center/layout.js
server/sonar-web/src/main/js/apps/update-center/list-item-view.js
server/sonar-web/src/main/js/apps/update-center/list-view.js
server/sonar-web/src/main/js/apps/update-center/plugin-changelog-view.js
server/sonar-web/src/main/js/apps/update-center/plugin.js
server/sonar-web/src/main/js/apps/update-center/plugins.js
server/sonar-web/src/main/js/apps/update-center/router.js
server/sonar-web/src/main/js/apps/update-center/search-view.js
server/sonar-web/src/main/js/apps/users/app.js
server/sonar-web/src/main/js/apps/users/change-password-view.js
server/sonar-web/src/main/js/apps/users/create-view.js
server/sonar-web/src/main/js/apps/users/deactivate-view.js
server/sonar-web/src/main/js/apps/users/form-view.js
server/sonar-web/src/main/js/apps/users/groups-view.js
server/sonar-web/src/main/js/apps/users/header-view.js
server/sonar-web/src/main/js/apps/users/layout.js
server/sonar-web/src/main/js/apps/users/list-footer-view.js
server/sonar-web/src/main/js/apps/users/list-item-view.js
server/sonar-web/src/main/js/apps/users/list-view.js
server/sonar-web/src/main/js/apps/users/search-view.js
server/sonar-web/src/main/js/apps/users/update-view.js
server/sonar-web/src/main/js/apps/users/user.js
server/sonar-web/src/main/js/apps/users/users.js

index 95ac0b44959a8642745838d26aa476f0dacb25d1..5f72d666f6c6eb386ebfd35428399b54d28ddada 100644 (file)
   "globals": {
     "define": true,
     "require": true,
-    "jQuery": true,
-    "$": true,
-    "_": true,
     "Templates": true,
     "Handlebars": true,
-    "Backbone": true,
-    "Marionette": true,
     "moment": true,
     "numeral": true,
     "key": true,
index 2a35ef057dbc2fe200bd0e070afa1e82195890aa..939625d8ab03ac9acc99ebb53390045966caa270 100644 (file)
@@ -43,7 +43,11 @@ module.exports = (grunt) ->
         files: [
           expand: true
           cwd: '<%= SOURCE_PATH %>/js'
-          src: ['**/*.jsx']
+          src: [
+            '**/*.jsx'
+            '**/api/**/*.js'
+            '**/apps/**/*.js'
+          ]
           dest: '<%= BUILD_PATH %>/js'
           ext: '.js'
         ]
@@ -310,11 +314,7 @@ module.exports = (grunt) ->
 
       js:
         files: '<%= SOURCE_PATH %>/js/**/*.js'
-        tasks: ['copy:js', 'concat:build', 'copy:assets-all-js']
-
-      jsx:
-        files: '<%= SOURCE_PATH %>/js/**/*.jsx'
-        tasks: ['babel:build', 'concat:build', 'copy:assets-all-js']
+        tasks: ['copy:js', 'babel:build', 'concat:build', 'copy:assets-all-js']
 
       handlebars:
         files: '<%= SOURCE_PATH %>/**/*.hbs'
index 7559a916e4810baa7f93406dd2924df71aac392a..0f441abacca80998d1f725375f8d41a3b9b42bf7 100644 (file)
@@ -1,35 +1,31 @@
-define([
-  './change-password-view'
-], function (ChangePasswordView) {
+import $ from 'jquery';
+import ChangePasswordView from './change-password-view';
 
-  var $ = jQuery;
-  var shouldShowAvatars = window.SS && window.SS.lf && window.SS.lf.enableGravatar;
-  var favorites = $('.js-account-favorites tr');
+var shouldShowAvatars = window.SS && window.SS.lf && window.SS.lf.enableGravatar;
+var favorites = $('.js-account-favorites tr');
 
-  function showExtraFavorites () {
-    favorites.removeClass('hidden');
-  }
-
-  return {
-    start: function () {
-      $('html').addClass('dashboard-page');
-
-      if (shouldShowAvatars) {
-        var avatarHtml = Handlebars.helpers.avatarHelper(window.SS.userEmail, 100).string;
-        $('.js-avatar').html(avatarHtml);
-      }
+function showExtraFavorites () {
+  favorites.removeClass('hidden');
+}
 
-      $('.js-show-all-favorites').on('click', function (e) {
-        e.preventDefault();
-        $(e.currentTarget).hide();
-        showExtraFavorites();
-      });
+export default {
+  start: function () {
+    $('html').addClass('dashboard-page');
 
-      $('#account-change-password-trigger').on('click', function (e) {
-        e.preventDefault();
-        new ChangePasswordView().render();
-      });
+    if (shouldShowAvatars) {
+      var avatarHtml = Handlebars.helpers.avatarHelper(window.SS.userEmail, 100).string;
+      $('.js-avatar').html(avatarHtml);
     }
-  };
 
-});
+    $('.js-show-all-favorites').on('click', function (e) {
+      e.preventDefault();
+      $(e.currentTarget).hide();
+      showExtraFavorites();
+    });
+
+    $('#account-change-password-trigger').on('click', function (e) {
+      e.preventDefault();
+      new ChangePasswordView().render();
+    });
+  }
+};
index 86522a8dc40ece874d2b8feb69b060c64863336b..e8f825f57b409cfb6fdbe00cbfe31575b8082903 100644 (file)
@@ -1,52 +1,47 @@
-define([
-  'components/common/modal-form',
-  './templates'
-], function (ModalForm) {
+import $ from 'jquery';
+import ModalForm from '../../components/common/modal-form';
+import './templates';
 
-  var $ = jQuery;
+export default ModalForm.extend({
+  template: Templates['account-change-password'],
 
-  return ModalForm.extend({
-    template: Templates['account-change-password'],
-
-    onFormSubmit: function (e) {
-      this._super(e);
-      if (this.checkPasswords()) {
-        this.sendRequest();
-      } else {
-        this.showErrors([{ msg: t('user.password_doesnt_match_confirmation') }]);
-      }
-    },
-
-    checkPasswords: function () {
-      var p1 = this.$('#password').val(),
-          p2 = this.$('#password_confirmation').val();
-      return p1 === p2;
-    },
-
-    sendRequest: function () {
-      var that = this;
-      var data = {
-        login: window.SS.user,
-        password: this.$('#password').val(),
-        previousPassword: this.$('#old_password').val()
-      };
-      var opts = {
-        type: 'POST',
-        url: baseUrl + '/api/users/change_password',
-        data: data,
-        statusCode: {
-          // do not show global error
-          400: null
-        }
-      };
-      this.disableForm();
-      $.ajax(opts).done(function () {
-        that.destroy();
-      }).fail(function (jqXHR) {
-        that.enableForm();
-        that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
-      });
+  onFormSubmit: function (e) {
+    this._super(e);
+    if (this.checkPasswords()) {
+      this.sendRequest();
+    } else {
+      this.showErrors([{ msg: t('user.password_doesnt_match_confirmation') }]);
     }
-  });
+  },
+
+  checkPasswords: function () {
+    var p1 = this.$('#password').val(),
+        p2 = this.$('#password_confirmation').val();
+    return p1 === p2;
+  },
 
+  sendRequest: function () {
+    var that = this;
+    var data = {
+      login: window.SS.user,
+      password: this.$('#password').val(),
+      previousPassword: this.$('#old_password').val()
+    };
+    var opts = {
+      type: 'POST',
+      url: baseUrl + '/api/users/change_password',
+      data: data,
+      statusCode: {
+        // do not show global error
+        400: null
+      }
+    };
+    this.disableForm();
+    $.ajax(opts).done(function () {
+      that.destroy();
+    }).fail(function (jqXHR) {
+      that.enableForm();
+      that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+    });
+  }
 });
index 8def59981b1040c86894e00b93bd2f38f9bc6305..5ccac8c097b757d94149372d645bc395ef726398 100644 (file)
@@ -1,55 +1,51 @@
-define([
-  './templates'
-], function () {
-
-  var $ = jQuery;
-
-  return Marionette.ItemView.extend({
-    className: 'panel panel-vertical',
-    template: Templates['api-documentation-action'],
-
-    modelEvents: {
-      'change': 'render'
-    },
-
-    events: {
-      'click .js-show-response-example': 'onShowResponseExampleClick',
-      'click .js-hide-response-example': 'onHideResponseExampleClick'
-    },
-
-    initialize: function () {
-      this.listenTo(this.options.state, 'change:query', this.toggleHidden);
-    },
-
-    onRender: function () {
-      this.$el.attr('data-web-service', this.model.get('path'));
-      this.$el.attr('data-action', this.model.get('key'));
-      this.toggleHidden();
-    },
-
-    onShowResponseExampleClick: function (e) {
-      e.preventDefault();
-      this.fetchResponse();
-    },
-
-    onHideResponseExampleClick: function (e) {
-      e.preventDefault();
-      this.model.unset('responseExample');
-    },
-
-    fetchResponse: function () {
-      var that = this,
-          url = baseUrl + '/api/webservices/response_example',
-          options = { controller: this.model.get('path'), action: this.model.get('key') };
-      return $.get(url, options).done(function (r) {
-        that.model.set({ responseExample: r.example });
-      });
-    },
-
-    toggleHidden: function () {
-      var test = this.model.get('path') + '/' + this.model.get('key');
-      this.$el.toggleClass('hidden', !this.options.state.match(test));
-    }
-  });
-
+import $ from 'jquery';
+import Marionette from 'backbone.marionette';
+import './templates';
+
+export default Marionette.ItemView.extend({
+  className: 'panel panel-vertical',
+  template: Templates['api-documentation-action'],
+
+  modelEvents: {
+    'change': 'render'
+  },
+
+  events: {
+    'click .js-show-response-example': 'onShowResponseExampleClick',
+    'click .js-hide-response-example': 'onHideResponseExampleClick'
+  },
+
+  initialize: function () {
+    this.listenTo(this.options.state, 'change:query', this.toggleHidden);
+  },
+
+  onRender: function () {
+    this.$el.attr('data-web-service', this.model.get('path'));
+    this.$el.attr('data-action', this.model.get('key'));
+    this.toggleHidden();
+  },
+
+  onShowResponseExampleClick: function (e) {
+    e.preventDefault();
+    this.fetchResponse();
+  },
+
+  onHideResponseExampleClick: function (e) {
+    e.preventDefault();
+    this.model.unset('responseExample');
+  },
+
+  fetchResponse: function () {
+    var that = this,
+        url = baseUrl + '/api/webservices/response_example',
+        options = { controller: this.model.get('path'), action: this.model.get('key') };
+    return $.get(url, options).done(function (r) {
+      that.model.set({ responseExample: r.example });
+    });
+  },
+
+  toggleHidden: function () {
+    var test = this.model.get('path') + '/' + this.model.get('key');
+    this.$el.toggleClass('hidden', !this.options.state.match(test));
+  }
 });
index 1553c648400ef0c434d05edb7b235a1e8b349508..d316434fe614b38869b0299d28459043ac4e39fd 100644 (file)
@@ -1,49 +1,45 @@
-define([
-  './action-view'
-], function (ActionView) {
+import $ from 'jquery';
+import Marionette from 'backbone.marionette';
+import ActionView from './action-view';
 
-  var $ = jQuery;
+export default Marionette.CollectionView.extend({
+  childView: ActionView,
 
-  return Marionette.CollectionView.extend({
-    childView: ActionView,
+  childViewOptions: function () {
+    return {
+      state: this.options.state
+    };
+  },
 
-    childViewOptions: function () {
-      return {
-        state: this.options.state
-      };
-    },
-
-    scrollToTop: function () {
-      var parent = this.$el.scrollParent();
-      if (parent.is(document)) {
-        parent = $(window);
-      }
-      parent.scrollTop(0);
-    },
-
-    scrollToAction: function (action) {
-      var model = this.collection.findWhere({ key: action });
-      if (model != null) {
-        var view = this.children.findByModel(model);
-        if (view != null) {
-          this.scrollToView(view);
-        }
-      }
-    },
+  scrollToTop: function () {
+    var parent = this.$el.scrollParent();
+    if (parent.is(document)) {
+      parent = $(window);
+    }
+    parent.scrollTop(0);
+  },
 
-    scrollToView: function (view) {
-      var el = view.$el,
-          parent = el.scrollParent();
-      var elOffset = el.offset(),
-          parentOffset = parent.offset();
-      if (parent.is(document)) {
-        parentOffset = { top: 0 };
-      }
-      if (elOffset != null && parentOffset != null) {
-        var scrollTop = elOffset.top - parentOffset.top - 70;
-        parent.scrollTop(scrollTop);
+  scrollToAction: function (action) {
+    var model = this.collection.findWhere({ key: action });
+    if (model != null) {
+      var view = this.children.findByModel(model);
+      if (view != null) {
+        this.scrollToView(view);
       }
     }
-  });
+  },
 
+  scrollToView: function (view) {
+    var el = view.$el,
+        parent = el.scrollParent();
+    var elOffset = el.offset(),
+        parentOffset = parent.offset();
+    if (parent.is(document)) {
+      parentOffset = { top: 0 };
+    }
+    if (elOffset != null && parentOffset != null) {
+      var scrollTop = elOffset.top - parentOffset.top - 70;
+      parent.scrollTop(scrollTop);
+    }
+  }
 });
index 640cb0ede39a31c3e336dfa4dc44b5850c20e334..5451cde9da769ab890c9f6d9593de5a8b6196a78 100644 (file)
@@ -1,71 +1,69 @@
-define([
-  './router',
-  './controller',
-  './layout',
-  './list',
-  './list-view',
-  './filters-view',
-  './search-view'
-], function (Router, Controller, Layout, List, ListView, FiltersView, SearchView) {
+import $ from 'jquery';
+import Backbone from 'backbone';
+import Marionette from 'backbone.marionette';
+import Router from './router';
+import Controller from './controller';
+import Layout from './layout';
+import List from './list';
+import ListView from './list-view';
+import FiltersView from './filters-view';
+import SearchView from './search-view';
 
-  var $ = jQuery,
-      App = new Marionette.Application(),
-      init = function (options) {
-        // State
-        this.state = new Backbone.Model({ internal: false });
-        this.state.match = function (test) {
-          var pattern = new RegExp(this.get('query'), 'i');
-          return test.search(pattern) !== -1;
-        };
+var App = new Marionette.Application(),
+    init = function (options) {
+      // State
+      this.state = new Backbone.Model({ internal: false });
+      this.state.match = function (test) {
+        var pattern = new RegExp(this.get('query'), 'i');
+        return test.search(pattern) !== -1;
+      };
 
-        // Layout
-        this.layout = new Layout({ el: options.el });
-        this.layout.render();
-        $('#footer').addClass('search-navigator-footer');
+      // Layout
+      this.layout = new Layout({ el: options.el });
+      this.layout.render();
+      $('#footer').addClass('search-navigator-footer');
 
-        // Web Services List
-        this.list = new List();
+      // Web Services List
+      this.list = new List();
 
-        // Controller
-        this.controller = new Controller({
-          app: this,
-          state: this.state
-        });
+      // Controller
+      this.controller = new Controller({
+        app: this,
+        state: this.state
+      });
 
-        // List View
-        this.listView = new ListView({
-          collection: this.list,
-          state: this.state
-        });
-        this.layout.resultsRegion.show(this.listView);
+      // List View
+      this.listView = new ListView({
+        collection: this.list,
+        state: this.state
+      });
+      this.layout.resultsRegion.show(this.listView);
 
-        // Filters View
-        this.filtersView = new FiltersView({
-          collection: this.list,
-          state: this.state
-        });
-        this.layout.actionsRegion.show(this.filtersView);
+      // Filters View
+      this.filtersView = new FiltersView({
+        collection: this.list,
+        state: this.state
+      });
+      this.layout.actionsRegion.show(this.filtersView);
 
-        // Search View
-        this.searchView = new SearchView({
-          state: this.state
-        });
-        this.layout.searchRegion.show(this.searchView);
+      // Search View
+      this.searchView = new SearchView({
+        state: this.state
+      });
+      this.layout.searchRegion.show(this.searchView);
 
-        // Router
-        this.router = new Router({ app: this });
-        Backbone.history.start({
-          pushState: true,
-          root: options.urlRoot
-        });
-      };
+      // Router
+      this.router = new Router({ app: this });
+      Backbone.history.start({
+        pushState: true,
+        root: options.urlRoot
+      });
+    };
 
-  App.on('start', function (options) {
-    window.requestMessages().done(function () {
-      init.call(App, options);
-    });
+App.on('start', function (options) {
+  window.requestMessages().done(function () {
+    init.call(App, options);
   });
-
-  return App;
-
 });
+
+export default App;
index 9e0738b9de8f98451275e045aec963018cee148c..1d668e2d46f89ee0565b2701a32663705d2605e8 100644 (file)
@@ -1,77 +1,74 @@
-define([
-  './actions-view',
-  './header-view'
-], function (ActionsView, HeaderView) {
+import _ from 'underscore';
+import Backbone from 'backbone';
+import Marionette from 'backbone.marionette';
+import ActionsView from './actions-view';
+import HeaderView from './header-view';
 
-  return Marionette.Controller.extend({
+export default Marionette.Controller.extend({
+  initialize: function (options) {
+    this.list = options.app.list;
+    this.listenTo(this.list, 'select', this.onItemSelect);
+  },
 
-    initialize: function (options) {
-      this.list = options.app.list;
-      this.listenTo(this.list, 'select', this.onItemSelect);
-    },
-
-    show: function (path) {
-      var that = this;
-      this.fetchList().done(function () {
-        if (path) {
-          var item = that.list.findWhere({ path: path });
-          if (item != null) {
-            that.showWebService(path);
-          } else {
-            that.showAction(path);
-          }
+  show: function (path) {
+    var that = this;
+    this.fetchList().done(function () {
+      if (path) {
+        var item = that.list.findWhere({ path: path });
+        if (item != null) {
+          that.showWebService(path);
+        } else {
+          that.showAction(path);
         }
-      });
-    },
-
-    showWebService: function (path) {
-      var item = this.list.findWhere({ path: path });
-      if (item != null) {
-        item.trigger('select', item);
       }
-    },
+    });
+  },
 
-    showAction: function (path) {
-      var webService = this.list.find(function (item) {
-        return path.indexOf(item.get('path')) === 0;
-      });
-      if (webService != null) {
-        var action = path.substr(webService.get('path').length + 1);
-        webService.trigger('select', webService, { trigger: false, action: action });
-      }
-    },
+  showWebService: function (path) {
+    var item = this.list.findWhere({ path: path });
+    if (item != null) {
+      item.trigger('select', item);
+    }
+  },
 
-    onItemSelect: function (item, options) {
-      var path = item.get('path'),
-          opts = _.defaults(options || {}, { trigger: true });
-      if (opts.trigger) {
-        this.options.app.router.navigate(path);
-      }
-      this.options.app.listView.highlight(path);
+  showAction: function (path) {
+    var webService = this.list.find(function (item) {
+      return path.indexOf(item.get('path')) === 0;
+    });
+    if (webService != null) {
+      var action = path.substr(webService.get('path').length + 1);
+      webService.trigger('select', webService, { trigger: false, action: action });
+    }
+  },
 
-      if (item.get('internal')) {
-        this.options.state.set({ internal: true });
-      }
+  onItemSelect: function (item, options) {
+    var path = item.get('path'),
+        opts = _.defaults(options || {}, { trigger: true });
+    if (opts.trigger) {
+      this.options.app.router.navigate(path);
+    }
+    this.options.app.listView.highlight(path);
 
-      var actions = new Backbone.Collection(item.get('actions')),
-          actionsView = new ActionsView({
-            collection: actions,
-            state: this.options.state
-          });
-      this.options.app.layout.detailsRegion.show(actionsView);
-      this.options.app.layout.headerRegion.show(new HeaderView({ model: item }));
+    if (item.get('internal')) {
+      this.options.state.set({ internal: true });
+    }
 
-      if (opts.action != null) {
-        actionsView.scrollToAction(opts.action);
-      } else {
-        actionsView.scrollToTop();
-      }
-    },
+    var actions = new Backbone.Collection(item.get('actions')),
+        actionsView = new ActionsView({
+          collection: actions,
+          state: this.options.state
+        });
+    this.options.app.layout.detailsRegion.show(actionsView);
+    this.options.app.layout.headerRegion.show(new HeaderView({ model: item }));
 
-    fetchList: function () {
-      return this.list.fetch({ data: { 'include_internals': true } });
+    if (opts.action != null) {
+      actionsView.scrollToAction(opts.action);
+    } else {
+      actionsView.scrollToTop();
     }
+  },
 
-  });
-
+  fetchList: function () {
+    return this.list.fetch({ data: { 'include_internals': true } });
+  }
 });
index 3511e704b94d165195612e59e33c867adf97f11c..aa54b532f2b47ab8455f48012c7d0290b4448576 100644 (file)
@@ -1,27 +1,27 @@
-define([
-  './templates'
-], function () {
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import './templates';
 
-  return Marionette.ItemView.extend({
-    template: Templates['api-documentation-filters'],
+export default Marionette.ItemView.extend({
+  template: Templates['api-documentation-filters'],
 
-    events: {
-      'change .js-toggle-internal': 'toggleInternal'
-    },
+  events: {
+    'change .js-toggle-internal': 'toggleInternal'
+  },
 
-    initialize: function () {
-      this.listenTo(this.options.state, 'change:internal', this.render);
-    },
+  initialize: function () {
+    this.listenTo(this.options.state, 'change:internal', this.render);
+  },
 
-    toggleInternal: function () {
-      this.options.state.set({ internal: !this.options.state.get('internal')});
-    },
-
-    serializeData: function () {
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        state: this.options.state.toJSON()
-      });
-    }
-  });
+  toggleInternal: function () {
+    this.options.state.set({ internal: !this.options.state.get('internal') });
+  },
 
+  serializeData: function () {
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      state: this.options.state.toJSON()
+    });
+  }
 });
+
+
index a880fa4f2dcd27368e0498ad4990e564edb2dcbb..818ccfdde4714c5600f0aface8c4b1f3b484e899 100644 (file)
@@ -1,13 +1,12 @@
-define([
-  './templates'
-], function () {
+import Marionette from 'backbone.marionette';
+import './templates';
 
-  return Marionette.ItemView.extend({
-    template: Templates['api-documentation-header'],
-
-    modelEvents: {
-      'change': 'render'
-    }
-  });
+export default Marionette.ItemView.extend({
+  template: Templates['api-documentation-header'],
 
+  modelEvents: {
+    'change': 'render'
+  }
 });
+
+
index 9649989d915acd1b68a641fb5d5897809a254b4c..b23ffff12ff56f8b83285e3dd9e9d67e864aa81d 100644 (file)
@@ -1,52 +1,52 @@
-define([
-  './templates'
-], function () {
-
-  return Marionette.ItemView.extend({
-    tagName: 'a',
-    className: 'list-group-item',
-    template: Templates['api-documentation-web-service'],
-
-    modelEvents: {
-      'change': 'render'
-    },
-
-    events: {
-      'click': 'onClick'
-    },
-
-    initialize: function () {
-      this.listenTo(this.options.state, 'change:query', this.toggleHidden);
-      this.listenTo(this.options.state, 'change:internal', this.toggleHidden);
-    },
-
-    shouldBeHidden: function () {
-      var that = this;
-      var match = this.options.state.match(this.model.get('path')) ||
-          _.some(this.model.get('actions'), function (action) {
-            var test = action.path + '/' + action.key;
-            return that.options.state.match(test);
-          });
-
-      var showInternal = this.options.state.get('internal'),
-          hideMe = this.model.get('internal') && !showInternal;
-      return !match || hideMe;
-    },
-
-    onRender: function () {
-      this.$el.attr('data-path', this.model.get('path'));
-      this.$el.toggleClass('active', this.options.highlighted);
-      this.toggleHidden();
-    },
-
-    onClick: function (e) {
-      e.preventDefault();
-      this.model.trigger('select', this.model);
-    },
-
-    toggleHidden: function () {
-      this.$el.toggleClass('hidden', this.shouldBeHidden());
-    }
-  });
-
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import './templates';
+
+export default Marionette.ItemView.extend({
+  tagName: 'a',
+  className: 'list-group-item',
+  template: Templates['api-documentation-web-service'],
+
+  modelEvents: {
+    'change': 'render'
+  },
+
+  events: {
+    'click': 'onClick'
+  },
+
+  initialize: function () {
+    this.listenTo(this.options.state, 'change:query', this.toggleHidden);
+    this.listenTo(this.options.state, 'change:internal', this.toggleHidden);
+  },
+
+  shouldBeHidden: function () {
+    var that = this;
+    var match = this.options.state.match(this.model.get('path')) ||
+        _.some(this.model.get('actions'), function (action) {
+          var test = action.path + '/' + action.key;
+          return that.options.state.match(test);
+        });
+
+    var showInternal = this.options.state.get('internal'),
+        hideMe = this.model.get('internal') && !showInternal;
+    return !match || hideMe;
+  },
+
+  onRender: function () {
+    this.$el.attr('data-path', this.model.get('path'));
+    this.$el.toggleClass('active', this.options.highlighted);
+    this.toggleHidden();
+  },
+
+  onClick: function (e) {
+    e.preventDefault();
+    this.model.trigger('select', this.model);
+  },
+
+  toggleHidden: function () {
+    this.$el.toggleClass('hidden', this.shouldBeHidden());
+  }
 });
+
+
index ac46b9c1bc6f5870bcf134aab4bb019889987eaf..229b48ec560d3b98f22b76b31413ada87e1ddda4 100644 (file)
@@ -1,25 +1,24 @@
-define([
-  './templates'
-], function () {
+import Marionette from 'backbone.marionette';
+import './templates';
 
-  return Marionette.LayoutView.extend({
-    template: Templates['api-documentation-layout'],
+export default Marionette.LayoutView.extend({
+  template: Templates['api-documentation-layout'],
 
-    regions: {
-      headerRegion: '.search-navigator-workspace-header',
-      actionsRegion: '.search-navigator-filters',
-      searchRegion: '.api-documentation-search',
-      resultsRegion: '.api-documentation-results',
-      detailsRegion: '.search-navigator-workspace-details'
-    },
-
-    onRender: function () {
-      var navigator = this.$('.search-navigator');
-      navigator.addClass('sticky search-navigator-extended-view');
-      var top = navigator.offset().top;
-      this.$('.search-navigator-workspace-header').css({ top: top });
-      this.$('.search-navigator-side').css({ top: top }).isolatedScroll();
-    }
-  });
+  regions: {
+    headerRegion: '.search-navigator-workspace-header',
+    actionsRegion: '.search-navigator-filters',
+    searchRegion: '.api-documentation-search',
+    resultsRegion: '.api-documentation-results',
+    detailsRegion: '.search-navigator-workspace-details'
+  },
 
+  onRender: function () {
+    var navigator = this.$('.search-navigator');
+    navigator.addClass('sticky search-navigator-extended-view');
+    var top = navigator.offset().top;
+    this.$('.search-navigator-workspace-header').css({ top: top });
+    this.$('.search-navigator-side').css({ top: top }).isolatedScroll();
+  }
 });
+
+
index c953c4fcab1a905ccd66bbf880cb48ceaf23502f..2360ebf707a28cf619f8714098a20de99c906ac3 100644 (file)
@@ -1,23 +1,22 @@
-define([
-  './item-view'
-], function (ItemView) {
+import Marionette from 'backbone.marionette';
+import ItemView from './item-view';
 
-  return Marionette.CollectionView.extend({
-    className: 'list-group',
-    childView: ItemView,
+export default Marionette.CollectionView.extend({
+  className: 'list-group',
+  childView: ItemView,
 
-    childViewOptions: function (model) {
-      return {
-        collectionView: this,
-        highlighted: model.get('path') === this.highlighted,
-        state: this.options.state
-      };
-    },
-
-    highlight: function (path) {
-      this.highlighted = path;
-      this.render();
-    }
-  });
+  childViewOptions: function (model) {
+    return {
+      collectionView: this,
+      highlighted: model.get('path') === this.highlighted,
+      state: this.options.state
+    };
+  },
 
+  highlight: function (path) {
+    this.highlighted = path;
+    this.render();
+  }
 });
+
+
index 1ac6c325d080395b3e1878378e88747be5e6df31..dcb5823f8090b78ffa5b249e2b2d6e6af57737e9 100644 (file)
@@ -1,23 +1,24 @@
-define(function () {
+import _ from 'underscore';
+import Backbone from 'backbone';
 
-  return Backbone.Collection.extend({
-    url: baseUrl + '/api/webservices/list',
-    comparator: 'path',
+export default Backbone.Collection.extend({
+  url: baseUrl + '/api/webservices/list',
+  comparator: 'path',
 
-    parse: function (r) {
-      return r.webServices.map(function (webService) {
-        var internal = _.every(webService.actions, function (action) {
-              return action.internal;
-            }),
-            actions = webService.actions.map(function (action) {
-              return _.extend(action, { path: webService.path });
-            });
-        return _.extend(webService, {
-          internal: internal,
-          actions: actions
-        });
+  parse: function (r) {
+    return r.webServices.map(function (webService) {
+      var internal = _.every(webService.actions, function (action) {
+            return action.internal;
+          }),
+          actions = webService.actions.map(function (action) {
+            return _.extend(action, { path: webService.path });
+          });
+      return _.extend(webService, {
+        internal: internal,
+        actions: actions
       });
-    }
-  });
-
+    });
+  }
 });
+
+
index b187022a6bba8bb92f120a963a23bd7e47142ff8..f84f4394d8c1844a212de853f29e6ef8c105f09a 100644 (file)
@@ -1,18 +1,17 @@
-define(function () {
+import Backbone from 'backbone';
 
-  return Backbone.Router.extend({
+export default Backbone.Router.extend({
+  routes: {
+    '*path': 'show'
+  },
 
-    routes: {
-      '*path': 'show'
-    },
+  initialize: function (options) {
+    this.app = options.app;
+  },
 
-    initialize: function (options) {
-      this.app = options.app;
-    },
+  show: function (path) {
+    this.app.controller.show(path);
+  }
+});
 
-    show: function (path) {
-      this.app.controller.show(path);
-    }
-  });
 
-});
index a24d9390bb2cc85c83d164006a2ba601fa585ca4..1635d8a2abf3b4e16c57be3643d6a827f6e633b4 100644 (file)
@@ -1,36 +1,36 @@
-define([
-  './templates'
-], function () {
-
-  return Marionette.ItemView.extend({
-    template: Templates['api-documentation-search'],
-
-    ui: {
-      input: '.search-box-input'
-    },
-
-    events: {
-      'keyup @ui.input': 'onChange',
-      'search @ui.input': 'onChange'
-    },
-
-    initialize: function () {
-      this.query = '';
-      this.debouncedFilter = _.debounce(this.filter, 250);
-    },
-
-    onChange: function () {
-      var query = this.ui.input.val();
-      if (query === this.query) {
-        return;
-      }
-      this.query = this.ui.input.val();
-      this.debouncedFilter(query);
-    },
-
-    filter: function (query) {
-      this.options.state.set({ query: query });
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import './templates';
+
+export default Marionette.ItemView.extend({
+  template: Templates['api-documentation-search'],
+
+  ui: {
+    input: '.search-box-input'
+  },
+
+  events: {
+    'keyup @ui.input': 'onChange',
+    'search @ui.input': 'onChange'
+  },
+
+  initialize: function () {
+    this.query = '';
+    this.debouncedFilter = _.debounce(this.filter, 250);
+  },
+
+  onChange: function () {
+    var query = this.ui.input.val();
+    if (query === this.query) {
+      return;
     }
-  });
+    this.query = this.ui.input.val();
+    this.debouncedFilter(query);
+  },
 
+  filter: function (query) {
+    this.options.state.set({ query: query });
+  }
 });
+
+
index 61f5e97ddd2cf8cef31c3a4d97d7302ee91f4ce1..e1e53516f05b4642a817b1fa6a0ff2c7f3189350 100644 (file)
-define([
-      './models/state',
-      './layout',
-      './models/rules',
-      'components/navigator/models/facets',
-
-      './controller',
-      'components/navigator/router',
-
-      './workspace-list-view',
-      './workspace-header-view',
-
-      './facets-view',
-      './filters-view'
-    ],
-    function (State,
-              Layout,
-              Rules,
-              Facets,
-              Controller,
-              Router,
-              WorkspaceListView,
-              WorkspaceHeaderView,
-              FacetsView,
-              FiltersView) {
-
-      var $ = jQuery,
-          App = new Marionette.Application(),
-          init = function (options) {
-            this.layout = new Layout({ el: options.el });
-            this.layout.render();
-            $('#footer').addClass('search-navigator-footer');
-
-            this.state = new State();
-            this.list = new Rules();
-            this.facets = new Facets();
-
-            this.controller = new Controller({ app: this });
-
-            this.workspaceListView = new WorkspaceListView({
-              app: this,
-              collection: this.list
-            });
-            this.layout.workspaceListRegion.show(this.workspaceListView);
-            this.workspaceListView.bindScrollEvents();
-
-            this.workspaceHeaderView = new WorkspaceHeaderView({
-              app: this,
-              collection: this.list
-            });
-            this.layout.workspaceHeaderRegion.show(this.workspaceHeaderView);
-
-            this.facetsView = new FacetsView({
-              app: this,
-              collection: this.facets
-            });
-            this.layout.facetsRegion.show(this.facetsView);
-
-            this.filtersView = new FiltersView({
-              app: this
-            });
-            this.layout.filtersRegion.show(this.filtersView);
-
-            key.setScope('list');
-            this.router = new Router({
-              app: this
-            });
-            Backbone.history.start();
-          };
-
-      App.manualRepository = function () {
-        return {
-          key: 'manual',
-          name: t('coding_rules.manual_rule'),
-          language: 'none'
-        };
-      };
-
-      App.getSubCharacteristicName = function (key) {
-        if (key != null) {
-          var ch = _.findWhere(App.characteristics, { key: key }),
-              parent = _.findWhere(App.characteristics, { key: ch.parent });
-          return [parent.name, ch.name].join(' > ');
-        } else {
-          return null;
-        }
-      };
+import $ from 'jquery';
+import _ from 'underscore';
+import Backbone from 'backbone';
+import Marionette from 'backbone.marionette';
+import State from './models/state';
+import Layout from './layout';
+import Rules from './models/rules';
+import Facets from 'components/navigator/models/facets';
+import Controller from './controller';
+import Router from 'components/navigator/router';
+import WorkspaceListView from './workspace-list-view';
+import WorkspaceHeaderView from './workspace-header-view';
+import FacetsView from './facets-view';
+import FiltersView from './filters-view';
+
+var App = new Marionette.Application(),
+    init = function (options) {
+      this.layout = new Layout({ el: options.el });
+      this.layout.render();
+      $('#footer').addClass('search-navigator-footer');
+
+      this.state = new State();
+      this.list = new Rules();
+      this.facets = new Facets();
+
+      this.controller = new Controller({ app: this });
+
+      this.workspaceListView = new WorkspaceListView({
+        app: this,
+        collection: this.list
+      });
+      this.layout.workspaceListRegion.show(this.workspaceListView);
+      this.workspaceListView.bindScrollEvents();
 
-      var appXHR = $.get(baseUrl + '/api/rules/app').done(function (r) {
-        App.canWrite = r.canWrite;
-        App.qualityProfiles = _.sortBy(r.qualityprofiles, ['name', 'lang']);
-        App.languages = _.extend(r.languages, {
-          none: 'None'
-        });
-        _.map(App.qualityProfiles, function (profile) {
-          profile.language = App.languages[profile.lang];
-        });
-        App.repositories = r.repositories;
-        App.repositories.push(App.manualRepository());
-        App.statuses = r.statuses;
-        App.characteristics = r.characteristics.map(function (item, index) {
-          return _.extend(item, { index: index });
-        });
+      this.workspaceHeaderView = new WorkspaceHeaderView({
+        app: this,
+        collection: this.list
       });
+      this.layout.workspaceHeaderRegion.show(this.workspaceHeaderView);
 
-      App.on('start', function (options) {
-        $.when(window.requestMessages(), appXHR).done(function () {
-          init.call(App, options);
-        });
+      this.facetsView = new FacetsView({
+        app: this,
+        collection: this.facets
       });
+      this.layout.facetsRegion.show(this.facetsView);
 
-      return App;
+      this.filtersView = new FiltersView({
+        app: this
+      });
+      this.layout.filtersRegion.show(this.filtersView);
 
-    });
+      key.setScope('list');
+      this.router = new Router({
+        app: this
+      });
+      Backbone.history.start();
+    };
+
+App.manualRepository = function () {
+  return {
+    key: 'manual',
+    name: t('coding_rules.manual_rule'),
+    language: 'none'
+  };
+};
+
+App.getSubCharacteristicName = function (key) {
+  if (key != null) {
+    var ch = _.findWhere(App.characteristics, { key: key }),
+        parent = _.findWhere(App.characteristics, { key: ch.parent });
+    return [parent.name, ch.name].join(' > ');
+  } else {
+    return null;
+  }
+};
+
+var appXHR = $.get(baseUrl + '/api/rules/app').done(function (r) {
+  App.canWrite = r.canWrite;
+  App.qualityProfiles = _.sortBy(r.qualityprofiles, ['name', 'lang']);
+  App.languages = _.extend(r.languages, {
+    none: 'None'
+  });
+  _.map(App.qualityProfiles, function (profile) {
+    profile.language = App.languages[profile.lang];
+  });
+  App.repositories = r.repositories;
+  App.repositories.push(App.manualRepository());
+  App.statuses = r.statuses;
+  App.characteristics = r.characteristics.map(function (item, index) {
+    return _.extend(item, { index: index });
+  });
+});
+
+App.on('start', function (options) {
+  $.when(window.requestMessages(), appXHR).done(function () {
+    init.call(App, options);
+  });
+});
+
+export default App;
index 4bd38a5425cfc4993ab82d1fa45e96a128294dc0..76e193d8f3372c737214755e8f725d20a1c21c0c 100644 (file)
@@ -1,97 +1,95 @@
-define([
-  'components/common/modal-form',
-  './templates'
-], function (ModalFormView) {
+import $ from 'jquery';
+import _ from 'underscore';
+import ModalFormView from 'components/common/modal-form';
+import './templates';
 
-  var $ = jQuery;
+export default ModalFormView.extend({
+  template: Templates['coding-rules-bulk-change-modal'],
 
-  return ModalFormView.extend({
-    template: Templates['coding-rules-bulk-change-modal'],
+  ui: function () {
+    return _.extend(ModalFormView.prototype.ui.apply(this, arguments), {
+      codingRulesSubmitBulkChange: '#coding-rules-submit-bulk-change'
+    });
+  },
 
-    ui: function () {
-      return _.extend(ModalFormView.prototype.ui.apply(this, arguments), {
-        codingRulesSubmitBulkChange: '#coding-rules-submit-bulk-change'
-      });
-    },
-
-    showSuccessMessage: function (profile, succeeded) {
-      var profileBase = _.findWhere(this.options.app.qualityProfiles, { key: profile }),
-          profileName = profileBase != null ? profileBase.name : profile,
-          message = tp('coding_rules.bulk_change.success', profileName, profileBase.language, succeeded);
-      this.ui.messagesContainer.append('<div class="alert alert-success">' + message + '</div>');
-    },
+  showSuccessMessage: function (profile, succeeded) {
+    var profileBase = _.findWhere(this.options.app.qualityProfiles, { key: profile }),
+        profileName = profileBase != null ? profileBase.name : profile,
+        message = tp('coding_rules.bulk_change.success', profileName, profileBase.language, succeeded);
+    this.ui.messagesContainer.append('<div class="alert alert-success">' + message + '</div>');
+  },
 
-    showWarnMessage: function (profile, succeeded, failed) {
-      var profileBase = _.findWhere(this.options.app.qualityProfiles, { key: profile }),
-          profileName = profileBase != null ? profileBase.name : profile,
-          message = tp('coding_rules.bulk_change.warning', profileName, profileBase.language, succeeded, failed);
-      this.ui.messagesContainer.append('<div class="alert alert-warning">' + message + '</div>');
-    },
+  showWarnMessage: function (profile, succeeded, failed) {
+    var profileBase = _.findWhere(this.options.app.qualityProfiles, { key: profile }),
+        profileName = profileBase != null ? profileBase.name : profile,
+        message = tp('coding_rules.bulk_change.warning', profileName, profileBase.language, succeeded, failed);
+    this.ui.messagesContainer.append('<div class="alert alert-warning">' + message + '</div>');
+  },
 
-    onRender: function () {
-      ModalFormView.prototype.onRender.apply(this, arguments);
-      this.$('#coding-rules-bulk-change-profile').select2({
-        width: '250px',
-        minimumResultsForSearch: 1,
-        openOnEnter: false
-      });
-    },
+  onRender: function () {
+    ModalFormView.prototype.onRender.apply(this, arguments);
+    this.$('#coding-rules-bulk-change-profile').select2({
+      width: '250px',
+      minimumResultsForSearch: 1,
+      openOnEnter: false
+    });
+  },
 
-    onFormSubmit: function () {
-      ModalFormView.prototype.onFormSubmit.apply(this, arguments);
-      var url = baseUrl + '/api/qualityprofiles/' + this.options.action + '_rules',
-          options = _.extend({}, this.options.app.state.get('query'), { wsAction: this.options.action }),
-          profiles = this.$('#coding-rules-bulk-change-profile').val() || [this.options.param];
-      this.ui.messagesContainer.empty();
-      this.sendRequests(url, options, profiles);
-    },
+  onFormSubmit: function () {
+    ModalFormView.prototype.onFormSubmit.apply(this, arguments);
+    var url = baseUrl + '/api/qualityprofiles/' + this.options.action + '_rules',
+        options = _.extend({}, this.options.app.state.get('query'), { wsAction: this.options.action }),
+        profiles = this.$('#coding-rules-bulk-change-profile').val() || [this.options.param];
+    this.ui.messagesContainer.empty();
+    this.sendRequests(url, options, profiles);
+  },
 
-    sendRequests: function (url, options, profiles) {
-      var that = this,
-          looper = $.Deferred().resolve();
-      profiles.forEach(function (profile) {
-        var opts = _.extend({}, options, { profile_key: profile });
-        looper = looper.then(function () {
-          return $.post(url, opts).done(function (r) {
-            if (r.failed) {
-              that.showWarnMessage(profile, r.succeeded, r.failed);
-            } else {
-              that.showSuccessMessage(profile, r.succeeded);
-            }
-          });
+  sendRequests: function (url, options, profiles) {
+    var that = this,
+        looper = $.Deferred().resolve();
+    profiles.forEach(function (profile) {
+      var opts = _.extend({}, options, { profile_key: profile });
+      looper = looper.then(function () {
+        return $.post(url, opts).done(function (r) {
+          if (r.failed) {
+            that.showWarnMessage(profile, r.succeeded, r.failed);
+          } else {
+            that.showSuccessMessage(profile, r.succeeded);
+          }
         });
       });
-      looper.done(function () {
-        that.options.app.controller.fetchList();
-        that.$(that.ui.codingRulesSubmitBulkChange.selector).hide();
-        that.$('.modal-field').hide();
-        that.$('.js-modal-close').focus();
-      });
-    },
+    });
+    looper.done(function () {
+      that.options.app.controller.fetchList();
+      that.$(that.ui.codingRulesSubmitBulkChange.selector).hide();
+      that.$('.modal-field').hide();
+      that.$('.js-modal-close').focus();
+    });
+  },
 
-    getAvailableQualityProfiles: function () {
-      var queryLanguages = this.options.app.state.get('query').languages,
-          languages = queryLanguages && queryLanguages.length > 0 ? queryLanguages.split(',') : [],
-          profiles = this.options.app.qualityProfiles;
-      if (languages.length > 0) {
-        profiles = _.filter(profiles, function (profile) {
-          return languages.indexOf(profile.lang) !== -1;
-        });
-      }
-      return profiles;
-    },
-
-    serializeData: function () {
-      var profile = _.findWhere(this.options.app.qualityProfiles, { key: this.options.param });
-      return _.extend(ModalFormView.prototype.serializeData.apply(this, arguments), {
-        action: this.options.action,
-        state: this.options.app.state.toJSON(),
-        qualityProfile: this.options.param,
-        qualityProfileName: profile != null ? profile.name : null,
-        qualityProfiles: this.options.app.qualityProfiles,
-        availableQualityProfiles: this.getAvailableQualityProfiles()
+  getAvailableQualityProfiles: function () {
+    var queryLanguages = this.options.app.state.get('query').languages,
+        languages = queryLanguages && queryLanguages.length > 0 ? queryLanguages.split(',') : [],
+        profiles = this.options.app.qualityProfiles;
+    if (languages.length > 0) {
+      profiles = _.filter(profiles, function (profile) {
+        return languages.indexOf(profile.lang) !== -1;
       });
     }
-  });
+    return profiles;
+  },
 
+  serializeData: function () {
+    var profile = _.findWhere(this.options.app.qualityProfiles, { key: this.options.param });
+    return _.extend(ModalFormView.prototype.serializeData.apply(this, arguments), {
+      action: this.options.action,
+      state: this.options.app.state.toJSON(),
+      qualityProfile: this.options.param,
+      qualityProfileName: profile != null ? profile.name : null,
+      qualityProfiles: this.options.app.qualityProfiles,
+      availableQualityProfiles: this.getAvailableQualityProfiles()
+    });
+  }
 });
+
+
index 9dab485f22e2998eb31b7e575cc518ceb6b1e8e5..6d6268f3ef69a5e9f41d53316bebf86541370361 100644 (file)
@@ -1,41 +1,39 @@
-define([
-  'components/common/popup',
-  './bulk-change-modal-view',
-  './templates'
-], function (PopupView, BulkChangeModalView) {
+import $ from 'jquery';
+import _ from 'underscore';
+import PopupView from 'components/common/popup';
+import BulkChangeModalView from './bulk-change-modal-view';
+import './templates';
 
-  var $ = jQuery;
+export default PopupView.extend({
+  template: Templates['coding-rules-bulk-change-popup'],
 
-  return PopupView.extend({
-    template: Templates['coding-rules-bulk-change-popup'],
+  events: {
+    'click .js-bulk-change': 'doAction'
+  },
 
-    events: {
-      'click .js-bulk-change': 'doAction'
-    },
+  doAction: function (e) {
+    var action = $(e.currentTarget).data('action'),
+        param = $(e.currentTarget).data('param');
+    new BulkChangeModalView({
+      app: this.options.app,
+      action: action,
+      param: param
+    }).render();
+  },
 
-    doAction: function (e) {
-      var action = $(e.currentTarget).data('action'),
-          param = $(e.currentTarget).data('param');
-      new BulkChangeModalView({
-        app: this.options.app,
-        action: action,
-        param: param
-      }).render();
-    },
+  serializeData: function () {
+    var query = this.options.app.state.get('query'),
+        profileKey = query.qprofile,
+        profile = _.findWhere(this.options.app.qualityProfiles, { key: profileKey }),
+        activation = '' + query.activation;
 
-    serializeData: function () {
-      var query = this.options.app.state.get('query'),
-          profileKey = query.qprofile,
-          profile = _.findWhere(this.options.app.qualityProfiles, { key: profileKey }),
-          activation = '' + query.activation;
+    return {
+      qualityProfile: profileKey,
+      qualityProfileName: profile != null ? profile.name : null,
+      allowActivateOnProfile: profileKey != null && activation === 'false',
+      allowDeactivateOnProfile: profileKey != null && activation === 'true'
+    };
+  }
+});
 
-      return {
-        qualityProfile: profileKey,
-        qualityProfileName: profile != null ? profile.name : null,
-        allowActivateOnProfile: profileKey != null && activation === 'false',
-        allowDeactivateOnProfile: profileKey != null && activation === 'true'
-      };
-    }
-  });
 
-});
index dabd4a0b1663b6adf136048b8b2c6219ff3ec037..dad6224391a67ee5d24fefe3fed42ce57e946702 100644 (file)
-define([
-  'components/navigator/controller',
-  './models/rule',
-  './rule-details-view'
-], function (Controller, Rule, RuleDetailsView) {
-
-  var $ = jQuery;
-
-  return Controller.extend({
-    pageSize: 200,
-    ruleFields: ['name', 'lang', 'langName', 'sysTags', 'tags', 'status', 'severity',
-                 'debtChar', 'debtCharName', 'debtSubChar', 'debtSubCharName'],
-
-
-    _searchParameters: function () {
-      var fields = this.ruleFields.slice(),
-          profile = this.app.state.get('query').qprofile;
-      if (profile != null) {
-        fields.push('actives');
-        fields.push('params');
-        fields.push('isTemplate');
-        fields.push('severity');
-      }
-      var params = {
-        p: this.app.state.get('page'),
-        ps: this.pageSize,
-        facets: this._facetsFromServer().join(),
-        f: fields.join()
-      };
-      if (this.app.state.get('query').q == null) {
-        _.extend(params, { s: 'name', asc: true });
-      }
-      return params;
-    },
+import $ from 'jquery';
+import _ from 'underscore';
+import Controller from 'components/navigator/controller';
+import Rule from './models/rule';
+import RuleDetailsView from './rule-details-view';
+
+export default Controller.extend({
+  pageSize: 200,
+  ruleFields: [
+    'name', 'lang', 'langName', 'sysTags', 'tags', 'status', 'severity',
+    'debtChar', 'debtCharName', 'debtSubChar', 'debtSubCharName'
+  ],
+
+
+  _searchParameters: function () {
+    var fields = this.ruleFields.slice(),
+        profile = this.app.state.get('query').qprofile;
+    if (profile != null) {
+      fields.push('actives');
+      fields.push('params');
+      fields.push('isTemplate');
+      fields.push('severity');
+    }
+    var params = {
+      p: this.app.state.get('page'),
+      ps: this.pageSize,
+      facets: this._facetsFromServer().join(),
+      f: fields.join()
+    };
+    if (this.app.state.get('query').q == null) {
+      _.extend(params, { s: 'name', asc: true });
+    }
+    return params;
+  },
 
-    fetchList: function (firstPage) {
-      firstPage = firstPage == null ? true : firstPage;
+  fetchList: function (firstPage) {
+    firstPage = firstPage == null ? true : firstPage;
+    if (firstPage) {
+      this.app.state.set({ selectedIndex: 0, page: 1 }, { silent: true });
+    }
+
+    this.hideDetails(firstPage);
+
+    var that = this,
+        url = baseUrl + '/api/rules/search',
+        options = _.extend(this._searchParameters(), this.app.state.get('query'));
+    return $.get(url, options).done(function (r) {
+      var rules = that.app.list.parseRules(r);
       if (firstPage) {
-        this.app.state.set({ selectedIndex: 0, page: 1 }, { silent: true });
+        that.app.list.reset(rules);
+      } else {
+        that.app.list.add(rules);
       }
-
-      this.hideDetails(firstPage);
-
-      var that = this,
-          url = baseUrl + '/api/rules/search',
-          options = _.extend(this._searchParameters(), this.app.state.get('query'));
-      return $.get(url, options).done(function (r) {
-        var rules = that.app.list.parseRules(r);
-        if (firstPage) {
-          that.app.list.reset(rules);
-        } else {
-          that.app.list.add(rules);
-        }
-        that.app.list.setIndex();
-        that.app.list.addExtraAttributes(that.app.languages, that.app.repositories);
-        that.app.facets.reset(that._allFacets());
-        that.app.facets.add(r.facets, { merge: true });
-        that.enableFacets(that._enabledFacets());
-        that.app.state.set({
-          page: r.p,
-          pageSize: r.ps,
-          total: r.total,
-          maxResultsReached: r.p * r.ps >= r.total
-        });
-        if (firstPage && that.isRulePermalink()) {
-          that.showDetails(that.app.list.first());
-        }
-      });
-    },
-
-    isRulePermalink: function () {
-      var query = this.app.state.get('query');
-      return query.rule_key != null && this.app.list.length === 1;
-    },
-
-    requestFacet: function (id) {
-      var url = baseUrl + '/api/rules/search',
-          facet = this.app.facets.get(id),
-          options = _.extend({ facets: id, ps: 1 }, this.app.state.get('query'));
-      return $.get(url, options).done(function (r) {
-        var facetData = _.findWhere(r.facets, { property: id });
-        if (facetData) {
-          facet.set(facetData);
-        }
+      that.app.list.setIndex();
+      that.app.list.addExtraAttributes(that.app.languages, that.app.repositories);
+      that.app.facets.reset(that._allFacets());
+      that.app.facets.add(r.facets, { merge: true });
+      that.enableFacets(that._enabledFacets());
+      that.app.state.set({
+        page: r.p,
+        pageSize: r.ps,
+        total: r.total,
+        maxResultsReached: r.p * r.ps >= r.total
       });
-    },
-
-    parseQuery: function () {
-      var q = Controller.prototype.parseQuery.apply(this, arguments);
-      delete q.asc;
-      delete q.s;
-      return q;
-    },
-
-    getRuleDetails: function (rule) {
-      var that = this,
-          url = baseUrl + '/api/rules/show',
-          options = {
-            key: rule.id,
-            actives: true
-          };
-      return $.get(url, options).done(function (data) {
-        rule.set(data.rule);
-        rule.addExtraAttributes(that.app.repositories);
-      });
-    },
-
-    showDetails: function (rule) {
-      var that = this,
-          ruleModel = typeof rule === 'string' ? new Rule({ key: rule }) : rule;
-      this.app.layout.workspaceDetailsRegion.reset();
-      this.getRuleDetails(ruleModel).done(function (data) {
-        key.setScope('details');
-        that.app.workspaceListView.unbindScrollEvents();
-        that.app.state.set({ rule: ruleModel });
-        that.app.workspaceDetailsView = new RuleDetailsView({
-          app: that.app,
-          model: ruleModel,
-          actives: data.actives
-        });
-        that.app.layout.showDetails();
-        that.app.layout.workspaceDetailsRegion.show(that.app.workspaceDetailsView);
-      });
-    },
-
-    showDetailsForSelected: function () {
-      var rule = this.app.list.at(this.app.state.get('selectedIndex'));
-      this.showDetails(rule);
-    },
-
-    hideDetails: function (firstPage) {
-      key.setScope('list');
-      this.app.state.unset('rule');
-      this.app.layout.workspaceDetailsRegion.reset();
-      this.app.layout.hideDetails();
-      this.app.workspaceListView.bindScrollEvents();
-      if (firstPage) {
-        this.app.workspaceListView.scrollTo();
+      if (firstPage && that.isRulePermalink()) {
+        that.showDetails(that.app.list.first());
+      }
+    });
+  },
+
+  isRulePermalink: function () {
+    var query = this.app.state.get('query');
+    return query.rule_key != null && this.app.list.length === 1;
+  },
+
+  requestFacet: function (id) {
+    var url = baseUrl + '/api/rules/search',
+        facet = this.app.facets.get(id),
+        options = _.extend({ facets: id, ps: 1 }, this.app.state.get('query'));
+    return $.get(url, options).done(function (r) {
+      var facetData = _.findWhere(r.facets, { property: id });
+      if (facetData) {
+        facet.set(facetData);
       }
-    },
-
-    activateCurrent: function () {
-      var rule = this.app.list.at(this.app.state.get('selectedIndex'));
-      var ruleView = this.app.workspaceListView.children.findByModel(rule);
-      ruleView.$('.coding-rules-detail-quality-profile-activate').click();
-    },
-
-    deactivateCurrent: function () {
-      var rule = this.app.list.at(this.app.state.get('selectedIndex'));
-      var ruleView = this.app.workspaceListView.children.findByModel(rule);
-      ruleView.$('.coding-rules-detail-quality-profile-deactivate').click();
+    });
+  },
+
+  parseQuery: function () {
+    var q = Controller.prototype.parseQuery.apply(this, arguments);
+    delete q.asc;
+    delete q.s;
+    return q;
+  },
+
+  getRuleDetails: function (rule) {
+    var that = this,
+        url = baseUrl + '/api/rules/show',
+        options = {
+          key: rule.id,
+          actives: true
+        };
+    return $.get(url, options).done(function (data) {
+      rule.set(data.rule);
+      rule.addExtraAttributes(that.app.repositories);
+    });
+  },
+
+  showDetails: function (rule) {
+    var that = this,
+        ruleModel = typeof rule === 'string' ? new Rule({ key: rule }) : rule;
+    this.app.layout.workspaceDetailsRegion.reset();
+    this.getRuleDetails(ruleModel).done(function (data) {
+      key.setScope('details');
+      that.app.workspaceListView.unbindScrollEvents();
+      that.app.state.set({ rule: ruleModel });
+      that.app.workspaceDetailsView = new RuleDetailsView({
+        app: that.app,
+        model: ruleModel,
+        actives: data.actives
+      });
+      that.app.layout.showDetails();
+      that.app.layout.workspaceDetailsRegion.show(that.app.workspaceDetailsView);
+    });
+  },
+
+  showDetailsForSelected: function () {
+    var rule = this.app.list.at(this.app.state.get('selectedIndex'));
+    this.showDetails(rule);
+  },
+
+  hideDetails: function (firstPage) {
+    key.setScope('list');
+    this.app.state.unset('rule');
+    this.app.layout.workspaceDetailsRegion.reset();
+    this.app.layout.hideDetails();
+    this.app.workspaceListView.bindScrollEvents();
+    if (firstPage) {
+      this.app.workspaceListView.scrollTo();
     }
+  },
+
+  activateCurrent: function () {
+    var rule = this.app.list.at(this.app.state.get('selectedIndex'));
+    var ruleView = this.app.workspaceListView.children.findByModel(rule);
+    ruleView.$('.coding-rules-detail-quality-profile-activate').click();
+  },
 
-  });
+  deactivateCurrent: function () {
+    var rule = this.app.list.at(this.app.state.get('selectedIndex'));
+    var ruleView = this.app.workspaceListView.children.findByModel(rule);
+    ruleView.$('.coding-rules-detail-quality-profile-deactivate').click();
+  }
 
 });
+
+
index 47f9e2edae5773e1c7d294132e3c8d483fa085bc..c3da8bbe54b052adac696f47aace45d74500af16 100644 (file)
@@ -1,59 +1,40 @@
-define([
-      'components/navigator/facets-view',
-      './facets/base-facet',
-      './facets/query-facet',
-      './facets/key-facet',
-      './facets/language-facet',
-      './facets/repository-facet',
-      './facets/tag-facet',
-      './facets/quality-profile-facet',
-      './facets/characteristic-facet',
-      './facets/severity-facet',
-      './facets/status-facet',
-      './facets/available-since-facet',
-      './facets/inheritance-facet',
-      './facets/active-severity-facet',
-      './facets/template-facet'
-    ],
-    function (FacetsView,
-              BaseFacet,
-              QueryFacet,
-              KeyFacet,
-              LanguageFacet,
-              RepositoryFacet,
-              TagFacet,
-              QualityProfileFacet,
-              CharacteristicFacet,
-              SeverityFacet,
-              StatusFacet,
-              AvailableSinceFacet,
-              InheritanceFacet,
-              ActiveSeverityFacet,
-              TemplateFacet) {
+import FacetsView from 'components/navigator/facets-view';
+import BaseFacet from './facets/base-facet';
+import QueryFacet from './facets/query-facet';
+import KeyFacet from './facets/key-facet';
+import LanguageFacet from './facets/language-facet';
+import RepositoryFacet from './facets/repository-facet';
+import TagFacet from './facets/tag-facet';
+import QualityProfileFacet from './facets/quality-profile-facet';
+import CharacteristicFacet from './facets/characteristic-facet';
+import SeverityFacet from './facets/severity-facet';
+import StatusFacet from './facets/status-facet';
+import AvailableSinceFacet from './facets/available-since-facet';
+import InheritanceFacet from './facets/inheritance-facet';
+import ActiveSeverityFacet from './facets/active-severity-facet';
+import TemplateFacet from './facets/template-facet';
 
-      var viewsMapping = {
-        q: QueryFacet,
-        rule_key: KeyFacet,
-        languages: LanguageFacet,
-        repositories: RepositoryFacet,
-        tags: TagFacet,
-        qprofile: QualityProfileFacet,
-        debt_characteristics: CharacteristicFacet,
-        severities: SeverityFacet,
-        statuses: StatusFacet,
-        available_since: AvailableSinceFacet,
-        inheritance: InheritanceFacet,
-        active_severities: ActiveSeverityFacet,
-        is_template: TemplateFacet
-      };
+var viewsMapping = {
+  q: QueryFacet,
+  rule_key: KeyFacet,
+  languages: LanguageFacet,
+  repositories: RepositoryFacet,
+  tags: TagFacet,
+  qprofile: QualityProfileFacet,
+  debt_characteristics: CharacteristicFacet,
+  severities: SeverityFacet,
+  statuses: StatusFacet,
+  available_since: AvailableSinceFacet,
+  inheritance: InheritanceFacet,
+  active_severities: ActiveSeverityFacet,
+  is_template: TemplateFacet
+};
 
-      return FacetsView.extend({
+export default FacetsView.extend({
 
-        getChildView: function (model) {
-          var view = viewsMapping[model.get('property')];
-          return view ? view : BaseFacet;
-        }
+  getChildView: function (model) {
+    var view = viewsMapping[model.get('property')];
+    return view ? view : BaseFacet;
+  }
 
-      });
-
-    });
+});
index f41233b9a7a952ccac432a7280315e3dbb089f97..0f0de13b0de9ecc3f19cfd5f6217f0ed8a54976c 100644 (file)
@@ -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);
+    });
+  }
 });
+
+
index 830fbe1bef0572a012301867426b983d8f848b98..3f2f6a2839f93e8f40b1cfc781765fa6f0441181 100644 (file)
@@ -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;
+  }
 
 });
+
+
index 18dc6f2c040df55a781e1db586847defc1328f8d..f02260069cb71c9c8ed33186f3284f04c5f2b5c3 100644 (file)
@@ -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']
 });
+
+
index c4a5e814bc2d2306abbe3f0164760e8e883b93c1..5463b4e13bcfaeb0c42709b1691259c57cb177b9 100644 (file)
@@ -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())
+    });
+  }
 });
+
+
index cda2d4bd4f6b13a581abb22fdb53418a20596201..7396208123f8185b2883de84a1c20357918bd264 100644 (file)
@@ -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()
+    });
+  }
 });
+
+
index d42604e6feebc68ebf996fd63ac9124d11d64f10..c2499876610a7c496fa822b11753dd4370611fdc 100644 (file)
@@ -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);
+  }
 });
+
+
index 08339bebe144ca20a695df324010f4037a2edbd3..e3dc2c2cafce919e6f2b2f8d2bd3c49e70b9cae2 100644 (file)
@@ -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()
+    });
+  }
 });
+
+
index 7c26655108ce0f8d265c17569ccacd3960c52837..4117345bd4b7438251e9a1da425969a664f9f07f 100644 (file)
@@ -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
+    });
+  }
 });
+
+
index 7033080676f0bcd73f0abb41944ee913a26ee47b..258640cbd8922da1916ebd2809f820e2530ff9ee 100644 (file)
@@ -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()
+    });
+  }
 
 });
+
+
index 21a7ed30d750082064d31baaa97fa201cc407da5..5686d6b2cea3ff868cfecd28739032896bc93258 100644 (file)
@@ -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()
-      });
-    }
-  });
 
-});
index f4770ff165f7f8c79e46354ef194f28ba8d3c5dc..fe380885438ad427861882bfec883f08a175882a 100644 (file)
@@ -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 });
+  }
 });
+
+
index 163bd5d23e86c0d4c9da01e39798edb354ec9bf6..8efc8b468690961abdcecb8faefe02a1bc96c435 100644 (file)
@@ -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()
+    });
+  }
 
 });
+
+
index 2b8a8af79741adf3468aa910d89e092edf436e7c..6ab2c4f8a4ddca76fb664d1873f7fdf24bea0ac3 100644 (file)
@@ -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);
+    });
+  }
 });
+
+
index 51a0c2c4451d0dbf337d0b0b3f9d556b3a3e6d2a..7d2e627f243a61011947d735507aa022a788d661 100644 (file)
@@ -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())
+    });
+  }
 });
+
+
index cf4ba7e135e90151b3cc7865c6b6d5fc2cbd2baa..b54b63ddb1a5468e1222f9fafd0b6ebe2bdc0e2a 100644 (file)
@@ -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 };
+          })
+        };
+      }
+    };
+  }
 
 });
+
+
index 8e35756ab4ac37f81976d2f8deb00fe8f06d18ad..bf819b33b5f3aa93628df33201d4dbe102ccfd77 100644 (file)
@@ -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);
+  }
 
 });
+
+
index 8cb424a488f9b417f61571244971439b22d2f257..37644b06ee91ab957efb2a1d59edfa961c36d23f 100644 (file)
@@ -1,24 +1,24 @@
-define([
-  './rule/manual-rule-creation-view',
-  './templates'
-], function (ManualRuleCreationView) {
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import ManualRuleCreationView from './rule/manual-rule-creation-view';
+import './templates';
 
-  return Marionette.ItemView.extend({
-    template: Templates['coding-rules-filters'],
+export default Marionette.ItemView.extend({
+  template: Templates['coding-rules-filters'],
 
-    events: {
-      'click .js-create-manual-rule': 'createManualRule'
-    },
+  events: {
+    'click .js-create-manual-rule': 'createManualRule'
+  },
 
-    createManualRule: function () {
-      new ManualRuleCreationView({
-        app: this.options.app
-      }).render();
-    },
-
-    serializeData: function () {
-      return _.extend(this._super(), { canWrite: this.options.app.canWrite });
-    }
-  });
+  createManualRule: function () {
+    new ManualRuleCreationView({
+      app: this.options.app
+    }).render();
+  },
 
+  serializeData: function () {
+    return _.extend(this._super(), { canWrite: this.options.app.canWrite });
+  }
 });
+
+
index b17061792d1a5841425a699347e3c4d42299ba4c..ac5e1b7e421aaad0e40fd85aec2667790772a9dd 100644 (file)
@@ -1,40 +1,38 @@
-define([
-  './templates'
-], function () {
-
-  var $ = jQuery;
-
-  return Marionette.LayoutView.extend({
-    template: Templates['coding-rules-layout'],
-
-    regions: {
-      filtersRegion: '.search-navigator-filters',
-      facetsRegion: '.search-navigator-facets',
-      workspaceHeaderRegion: '.search-navigator-workspace-header',
-      workspaceListRegion: '.search-navigator-workspace-list',
-      workspaceDetailsRegion: '.search-navigator-workspace-details'
-    },
-
-    onRender: function () {
-      var navigator = this.$('.search-navigator');
-      var top = navigator.offset().top;
-      this.$('.search-navigator-workspace-header').css({ top: top });
-      this.$('.search-navigator-side').css({ top: top }).isolatedScroll();
-    },
-
-    showDetails: function () {
-      this.scroll = $(window).scrollTop();
-      this.$('.search-navigator').addClass('search-navigator-extended-view');
-    },
-
-
-    hideDetails: function () {
-      this.$('.search-navigator').removeClass('search-navigator-extended-view');
-      if (this.scroll != null) {
-        $(window).scrollTop(this.scroll);
-      }
+import $ from 'jquery';
+import Marionette from 'backbone.marionette';
+import './templates';
+
+export default Marionette.LayoutView.extend({
+  template: Templates['coding-rules-layout'],
+
+  regions: {
+    filtersRegion: '.search-navigator-filters',
+    facetsRegion: '.search-navigator-facets',
+    workspaceHeaderRegion: '.search-navigator-workspace-header',
+    workspaceListRegion: '.search-navigator-workspace-list',
+    workspaceDetailsRegion: '.search-navigator-workspace-details'
+  },
+
+  onRender: function () {
+    var navigator = this.$('.search-navigator');
+    var top = navigator.offset().top;
+    this.$('.search-navigator-workspace-header').css({ top: top });
+    this.$('.search-navigator-side').css({ top: top }).isolatedScroll();
+  },
+
+  showDetails: function () {
+    this.scroll = $(window).scrollTop();
+    this.$('.search-navigator').addClass('search-navigator-extended-view');
+  },
+
+
+  hideDetails: function () {
+    this.$('.search-navigator').removeClass('search-navigator-extended-view');
+    if (this.scroll != null) {
+      $(window).scrollTop(this.scroll);
     }
-
-  });
+  }
 
 });
+
+
index 8b9fb46502244f264217396a2af14bea94bf8968..6cc502192d5f6205add5ee0144bc72ca1ac53b16 100644 (file)
@@ -1,29 +1,30 @@
-define(function () {
+import _ from 'underscore';
+import Backbone from 'backbone';
 
-  return Backbone.Model.extend({
-    idAttribute: 'key',
+export default Backbone.Model.extend({
+  idAttribute: 'key',
 
-    addExtraAttributes: function (repositories) {
-      var repo = _.findWhere(repositories, { key: this.get('repo') }) || this.get('repo'),
-          repoName = repo != null ? repo.name : repo,
-          isManual = this.get('repo') === 'manual',
-          isCustom = this.has('templateKey');
-      this.set({
-        repoName: repoName,
-        isManual: isManual,
-        isCustom: isCustom
-      }, { silent: true });
-    },
-
-    getInactiveProfiles: function (actives, profiles) {
-      return actives.map(function (profile) {
-        var profileBase = _.findWhere(profiles, { key: profile.qProfile });
-        if (profileBase != null) {
-          _.extend(profile, profileBase);
-        }
-        return profile;
-      });
-    }
-  });
+  addExtraAttributes: function (repositories) {
+    var repo = _.findWhere(repositories, { key: this.get('repo') }) || this.get('repo'),
+        repoName = repo != null ? repo.name : repo,
+        isManual = this.get('repo') === 'manual',
+        isCustom = this.has('templateKey');
+    this.set({
+      repoName: repoName,
+      isManual: isManual,
+      isCustom: isCustom
+    }, { silent: true });
+  },
 
+  getInactiveProfiles: function (actives, profiles) {
+    return actives.map(function (profile) {
+      var profileBase = _.findWhere(profiles, { key: profile.qProfile });
+      if (profileBase != null) {
+        _.extend(profile, profileBase);
+      }
+      return profile;
+    });
+  }
 });
+
+
index 3cc31fcd1498f3a840c7129be5cce7096f4d8bca..8e293c6ad6e6fe6dd507240f0fa06d289fc368c8 100644 (file)
@@ -1,43 +1,43 @@
-define([
-  './rule'
-], function (Rule) {
+import _ from 'underscore';
+import Backbone from 'backbone';
+import Rule from './rule';
 
-  return Backbone.Collection.extend({
-    model: Rule,
+export default Backbone.Collection.extend({
+  model: Rule,
 
-    parseRules: function (r) {
-      var rules = r.rules,
-          profiles = r.qProfiles || [];
+  parseRules: function (r) {
+    var rules = r.rules,
+        profiles = r.qProfiles || [];
 
-      if (r.actives != null) {
-        rules = rules.map(function (rule) {
-          var activations = (r.actives[rule.key] || []).map(function (activation) {
-            var profile = profiles[activation.qProfile];
-            if (profile != null) {
-              _.extend(activation, { profile: profile });
-              if (profile.parent != null) {
-                _.extend(activation, { parentProfile: profiles[profile.parent] });
-              }
+    if (r.actives != null) {
+      rules = rules.map(function (rule) {
+        var activations = (r.actives[rule.key] || []).map(function (activation) {
+          var profile = profiles[activation.qProfile];
+          if (profile != null) {
+            _.extend(activation, { profile: profile });
+            if (profile.parent != null) {
+              _.extend(activation, { parentProfile: profiles[profile.parent] });
             }
-            return activation;
-          });
-          return _.extend(rule, { activation: activations.length > 0 ? activations[0] : null });
+          }
+          return activation;
         });
-      }
-      return rules;
-    },
-
-    setIndex: function () {
-      this.forEach(function (rule, index) {
-        rule.set({ index: index });
-      });
-    },
-
-    addExtraAttributes: function (repositories) {
-      this.models.forEach(function (model) {
-        model.addExtraAttributes(repositories);
+        return _.extend(rule, { activation: activations.length > 0 ? activations[0] : null });
       });
     }
-  });
+    return rules;
+  },
 
+  setIndex: function () {
+    this.forEach(function (rule, index) {
+      rule.set({ index: index });
+    });
+  },
+
+  addExtraAttributes: function (repositories) {
+    this.models.forEach(function (model) {
+      model.addExtraAttributes(repositories);
+    });
+  }
 });
+
+
index 9d29484502fc5d1da06ccd446bca1cc54fc8148a..da1dcad586c859f26df404ff62a512710acad5e2 100644 (file)
@@ -1,22 +1,24 @@
-define([
-  'components/navigator/models/state'
-], function (State) {
+import State from 'components/navigator/models/state';
 
-  return State.extend({
-    defaults: {
-      page: 1,
-      maxResultsReached: false,
-      query: {},
-      facets: ['languages', 'tags'],
-      allFacets: ['q', 'rule_key', 'languages', 'tags', 'repositories', 'debt_characteristics', 'severities',
-                  'statuses', 'available_since', 'is_template', 'qprofile', 'inheritance', 'active_severities'],
-      facetsFromServer: ['languages', 'repositories', 'tags', 'severities', 'statuses', 'debt_characteristics',
-                         'active_severities'],
-      transform: {
-        'has_debt_characteristic': 'debt_characteristics'
-      }
+export default State.extend({
+  defaults: {
+    page: 1,
+    maxResultsReached: false,
+    query: {},
+    facets: ['languages', 'tags'],
+    allFacets: [
+      'q', 'rule_key', 'languages', 'tags', 'repositories', 'debt_characteristics', 'severities',
+      'statuses', 'available_since', 'is_template', 'qprofile', 'inheritance', 'active_severities'
+    ],
+    facetsFromServer: [
+      'languages', 'repositories', 'tags', 'severities', 'statuses', 'debt_characteristics',
+      'active_severities'
+    ],
+    transform: {
+      'has_debt_characteristic': 'debt_characteristics'
     }
-  });
-
+  }
 });
 
+
+
index f1a57c3a0ec00f18ad9366544302b202d78f673a..c33ea38e401d7fc727772a366d1cbe49deac67cb 100644 (file)
-define([
-      './models/rules',
-      './rule/rule-meta-view',
-      './rule/rule-description-view',
-      './rule/rule-parameters-view',
-      './rule/rule-profiles-view',
-      './rule/custom-rules-view',
-      './rule/manual-rule-creation-view',
-      './rule/custom-rule-creation-view',
-      './rule/rule-issues-view',
-      './templates'
-    ],
-    function (Rules,
-              MetaView,
-              DescView,
-              ParamView,
-              ProfilesView,
-              CustomRulesView,
-              ManualRuleCreationView,
-              CustomRuleCreationView,
-              IssuesView) {
-
-      var $ = jQuery;
-
-      return Marionette.LayoutView.extend({
-        className: 'coding-rule-details',
-        template: Templates['coding-rules-rule-details'],
-
-        regions: {
-          metaRegion: '.js-rule-meta',
-          descRegion: '.js-rule-description',
-          paramRegion: '.js-rule-parameters',
-          profilesRegion: '.js-rule-profiles',
-          customRulesRegion: '.js-rule-custom-rules',
-          issuesRegion: '.js-rule-issues'
-        },
-
-        events: {
-          'click .js-edit-manual': 'editManualRule',
-          'click .js-edit-custom': 'editCustomRule',
-          'click .js-delete': 'deleteRule'
-        },
-
-        initialize: function () {
-          this.bindShortcuts();
-          this.customRules = new Rules();
-          if (this.model.get('isTemplate')) {
-            this.fetchCustomRules();
-          }
-          this.listenTo(this.options.app.state, 'change:selectedIndex', this.select);
-        },
-
-        onRender: function () {
-          this.metaRegion.show(new MetaView({
-            app: this.options.app,
-            model: this.model
-          }));
-          this.descRegion.show(new DescView({
-            app: this.options.app,
-            model: this.model
-          }));
-          this.paramRegion.show(new ParamView({
-            app: this.options.app,
-            model: this.model
-          }));
-          this.profilesRegion.show(new ProfilesView({
-            app: this.options.app,
-            model: this.model,
-            collection: new Backbone.Collection(this.getQualityProfiles())
-          }));
-          this.customRulesRegion.show(new CustomRulesView({
-            app: this.options.app,
-            model: this.model,
-            collection: this.customRules
-          }));
-          this.issuesRegion.show(new IssuesView({
-            app: this.options.app,
-            model: this.model
-          }));
-          this.$el.scrollParent().scrollTop(0);
-        },
-
-        onDestroy: function () {
-          this.unbindShortcuts();
-        },
-
-        fetchCustomRules: function () {
-          var that = this,
-              url = baseUrl + '/api/rules/search',
-              options = {
-                template_key: this.model.get('key'),
-                f: 'name,severity,params'
-              };
-          return $.get(url, options).done(function (data) {
-            that.customRules.reset(data.rules);
-          });
-        },
-
-        getQualityProfiles: function () {
-          return this.model.getInactiveProfiles(this.options.actives, this.options.app.qualityProfiles);
-        },
-
-        bindShortcuts: function () {
-          var that = this;
-          key('up', 'details', function () {
-            that.options.app.controller.selectPrev();
-            return false;
-          });
-          key('down', 'details', function () {
-            that.options.app.controller.selectNext();
-            return false;
-          });
-          key('left, backspace', 'details', function () {
-            that.options.app.controller.hideDetails();
-            return false;
-          });
-        },
-
-        unbindShortcuts: function () {
-          key.deleteScope('details');
-        },
-
-        editManualRule: function () {
-          new ManualRuleCreationView({
-            app: this.options.app,
-            model: this.model
-          }).render();
-        },
-
-        editCustomRule: function () {
-          new CustomRuleCreationView({
-            app: this.options.app,
-            model: this.model
-          }).render();
-        },
-
-        deleteRule: function () {
-          var that = this,
-              ruleType = this.model.has('templateKey') ? 'custom' : 'manual';
-          window.confirmDialog({
-            title: t('delete'),
-            html: tp('coding_rules.delete.' + ruleType + '.confirm', this.model.get('name')),
-            yesHandler: function () {
-              var url = baseUrl + '/api/rules/delete',
-                  options = { key: that.model.id };
-              $.post(url, options).done(function () {
-                that.options.app.controller.fetchList();
-              });
-            }
-          });
-        },
-
-        select: function () {
-          var selected = this.options.app.state.get('selectedIndex'),
-              selectedRule = this.options.app.list.at(selected);
-          this.options.app.controller.showDetails(selectedRule);
-        },
-
-        serializeData: function () {
-          var isManual = this.model.get('isManual'),
-              isCustom = this.model.has('templateKey'),
-              isEditable = this.options.app.canWrite && (isManual || isCustom),
-              qualityProfilesVisible = !isManual;
-
-          if (qualityProfilesVisible) {
-            if (this.model.get('isTemplate')) {
-              qualityProfilesVisible = !_.isEmpty(this.options.actives);
-            }
-            else {
-              qualityProfilesVisible = (this.options.app.canWrite || !_.isEmpty(this.options.actives));
-            }
-          }
-
-          return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-            isEditable: isEditable,
-            canWrite: this.options.app.canWrite,
-            qualityProfilesVisible: qualityProfilesVisible,
-            allTags: _.union(this.model.get('sysTags'), this.model.get('tags'))
-          });
-        }
-      });
+import $ from 'jquery';
+import _ from 'underscore';
+import Backbone from 'backbone';
+import Marionette from 'backbone.marionette';
+import Rules from './models/rules';
+import MetaView from './rule/rule-meta-view';
+import DescView from './rule/rule-description-view';
+import ParamView from './rule/rule-parameters-view';
+import ProfilesView from './rule/rule-profiles-view';
+import CustomRulesView from './rule/custom-rules-view';
+import ManualRuleCreationView from './rule/manual-rule-creation-view';
+import CustomRuleCreationView from './rule/custom-rule-creation-view';
+import IssuesView from './rule/rule-issues-view';
+import './templates';
+
+export default Marionette.LayoutView.extend({
+  className: 'coding-rule-details',
+  template: Templates['coding-rules-rule-details'],
+
+  regions: {
+    metaRegion: '.js-rule-meta',
+    descRegion: '.js-rule-description',
+    paramRegion: '.js-rule-parameters',
+    profilesRegion: '.js-rule-profiles',
+    customRulesRegion: '.js-rule-custom-rules',
+    issuesRegion: '.js-rule-issues'
+  },
+
+  events: {
+    'click .js-edit-manual': 'editManualRule',
+    'click .js-edit-custom': 'editCustomRule',
+    'click .js-delete': 'deleteRule'
+  },
+
+  initialize: function () {
+    this.bindShortcuts();
+    this.customRules = new Rules();
+    if (this.model.get('isTemplate')) {
+      this.fetchCustomRules();
+    }
+    this.listenTo(this.options.app.state, 'change:selectedIndex', this.select);
+  },
+
+  onRender: function () {
+    this.metaRegion.show(new MetaView({
+      app: this.options.app,
+      model: this.model
+    }));
+    this.descRegion.show(new DescView({
+      app: this.options.app,
+      model: this.model
+    }));
+    this.paramRegion.show(new ParamView({
+      app: this.options.app,
+      model: this.model
+    }));
+    this.profilesRegion.show(new ProfilesView({
+      app: this.options.app,
+      model: this.model,
+      collection: new Backbone.Collection(this.getQualityProfiles())
+    }));
+    this.customRulesRegion.show(new CustomRulesView({
+      app: this.options.app,
+      model: this.model,
+      collection: this.customRules
+    }));
+    this.issuesRegion.show(new IssuesView({
+      app: this.options.app,
+      model: this.model
+    }));
+    this.$el.scrollParent().scrollTop(0);
+  },
+
+  onDestroy: function () {
+    this.unbindShortcuts();
+  },
+
+  fetchCustomRules: function () {
+    var that = this,
+        url = baseUrl + '/api/rules/search',
+        options = {
+          template_key: this.model.get('key'),
+          f: 'name,severity,params'
+        };
+    return $.get(url, options).done(function (data) {
+      that.customRules.reset(data.rules);
+    });
+  },
+
+  getQualityProfiles: function () {
+    return this.model.getInactiveProfiles(this.options.actives, this.options.app.qualityProfiles);
+  },
 
+  bindShortcuts: function () {
+    var that = this;
+    key('up', 'details', function () {
+      that.options.app.controller.selectPrev();
+      return false;
+    });
+    key('down', 'details', function () {
+      that.options.app.controller.selectNext();
+      return false;
+    });
+    key('left, backspace', 'details', function () {
+      that.options.app.controller.hideDetails();
+      return false;
+    });
+  },
+
+  unbindShortcuts: function () {
+    key.deleteScope('details');
+  },
+
+  editManualRule: function () {
+    new ManualRuleCreationView({
+      app: this.options.app,
+      model: this.model
+    }).render();
+  },
+
+  editCustomRule: function () {
+    new CustomRuleCreationView({
+      app: this.options.app,
+      model: this.model
+    }).render();
+  },
+
+  deleteRule: function () {
+    var that = this,
+        ruleType = this.model.has('templateKey') ? 'custom' : 'manual';
+    window.confirmDialog({
+      title: t('delete'),
+      html: tp('coding_rules.delete.' + ruleType + '.confirm', this.model.get('name')),
+      yesHandler: function () {
+        var url = baseUrl + '/api/rules/delete',
+            options = { key: that.model.id };
+        $.post(url, options).done(function () {
+          that.options.app.controller.fetchList();
+        });
+      }
+    });
+  },
+
+  select: function () {
+    var selected = this.options.app.state.get('selectedIndex'),
+        selectedRule = this.options.app.list.at(selected);
+    this.options.app.controller.showDetails(selectedRule);
+  },
+
+  serializeData: function () {
+    var isManual = this.model.get('isManual'),
+        isCustom = this.model.has('templateKey'),
+        isEditable = this.options.app.canWrite && (isManual || isCustom),
+        qualityProfilesVisible = !isManual;
+
+    if (qualityProfilesVisible) {
+      if (this.model.get('isTemplate')) {
+        qualityProfilesVisible = !_.isEmpty(this.options.actives);
+      }
+      else {
+        qualityProfilesVisible = (this.options.app.canWrite || !_.isEmpty(this.options.actives));
+      }
+    }
+
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      isEditable: isEditable,
+      canWrite: this.options.app.canWrite,
+      qualityProfilesVisible: qualityProfilesVisible,
+      allTags: _.union(this.model.get('sysTags'), this.model.get('tags'))
     });
+  }
+});
index 3d1428c62f114dfe78fa2bbf695faeae19b27a8a..bb9acd5ccefa1437e04d9510fb01b5fcc6568bc6 100644 (file)
@@ -1,24 +1,23 @@
-define([
-  'components/common/action-options-view',
-  './templates'
-], function (ActionOptionsView) {
-  var $ = jQuery;
+import $ from 'jquery';
+import _ from 'underscore';
+import ActionOptionsView from 'components/common/action-options-view';
+import './templates';
 
-  return ActionOptionsView.extend({
-    template: Templates['coding-rules-rule-filter-form'],
+export default ActionOptionsView.extend({
+  template: Templates['coding-rules-rule-filter-form'],
 
-    selectOption: function (e) {
-      var property = $(e.currentTarget).data('property'),
-          value = $(e.currentTarget).data('value');
-      this.trigger('select', property, value);
-      return ActionOptionsView.prototype.selectOption.apply(this, arguments);
-    },
+  selectOption: function (e) {
+    var property = $(e.currentTarget).data('property'),
+        value = $(e.currentTarget).data('value');
+    this.trigger('select', property, value);
+    return ActionOptionsView.prototype.selectOption.apply(this, arguments);
+  },
 
-    serializeData: function () {
-      return _.extend(ActionOptionsView.prototype.serializeData.apply(this, arguments), {
-        tags: _.union(this.model.get('sysTags'), this.model.get('tags'))
-      });
-    }
+  serializeData: function () {
+    return _.extend(ActionOptionsView.prototype.serializeData.apply(this, arguments), {
+      tags: _.union(this.model.get('sysTags'), this.model.get('tags'))
+    });
+  }
 
-  });
 });
+
index 76e5f10fea129938f3a0e2997a223bf7b3b8973e..dbaf9af0d6426efbfb3404b16db044eda5ef7959 100644 (file)
-define([
-  'components/common/modal-form',
-  '../templates'
-], function (ModalFormView) {
-
-  var $ = jQuery;
-
-  return ModalFormView.extend({
-    template: Templates['coding-rules-custom-rule-creation'],
-
-    ui: function () {
-      return _.extend(ModalFormView.prototype.ui.apply(this, arguments), {
-        customRuleCreationKey: '#coding-rules-custom-rule-creation-key',
-        customRuleCreationName: '#coding-rules-custom-rule-creation-name',
-        customRuleCreationHtmlDescription: '#coding-rules-custom-rule-creation-html-description',
-        customRuleCreationSeverity: '#coding-rules-custom-rule-creation-severity',
-        customRuleCreationStatus: '#coding-rules-custom-rule-creation-status',
-        customRuleCreationParameters: '[name]',
-        customRuleCreationCreate: '#coding-rules-custom-rule-creation-create',
-        customRuleCreationReactivate: '#coding-rules-custom-rule-creation-reactivate',
-        modalFoot: '.modal-foot'
-      });
-    },
-
-    events: function () {
-      return _.extend(ModalFormView.prototype.events.apply(this, arguments), {
-        'input @ui.customRuleCreationName': 'generateKey',
-        'keydown @ui.customRuleCreationName': 'generateKey',
-        'keyup @ui.customRuleCreationName': 'generateKey',
-
-        'input @ui.customRuleCreationKey': 'flagKey',
-        'keydown @ui.customRuleCreationKey': 'flagKey',
-        'keyup @ui.customRuleCreationKey': 'flagKey',
-
-        'click #coding-rules-custom-rule-creation-cancel': 'destroy',
-        'click @ui.customRuleCreationCreate': 'create',
-        'click @ui.customRuleCreationReactivate': 'reactivate'
+import $ from 'jquery';
+import _ from 'underscore';
+import ModalFormView from 'components/common/modal-form';
+import '../templates';
+
+export default ModalFormView.extend({
+  template: Templates['coding-rules-custom-rule-creation'],
+
+  ui: function () {
+    return _.extend(ModalFormView.prototype.ui.apply(this, arguments), {
+      customRuleCreationKey: '#coding-rules-custom-rule-creation-key',
+      customRuleCreationName: '#coding-rules-custom-rule-creation-name',
+      customRuleCreationHtmlDescription: '#coding-rules-custom-rule-creation-html-description',
+      customRuleCreationSeverity: '#coding-rules-custom-rule-creation-severity',
+      customRuleCreationStatus: '#coding-rules-custom-rule-creation-status',
+      customRuleCreationParameters: '[name]',
+      customRuleCreationCreate: '#coding-rules-custom-rule-creation-create',
+      customRuleCreationReactivate: '#coding-rules-custom-rule-creation-reactivate',
+      modalFoot: '.modal-foot'
+    });
+  },
+
+  events: function () {
+    return _.extend(ModalFormView.prototype.events.apply(this, arguments), {
+      'input @ui.customRuleCreationName': 'generateKey',
+      'keydown @ui.customRuleCreationName': 'generateKey',
+      'keyup @ui.customRuleCreationName': 'generateKey',
+
+      'input @ui.customRuleCreationKey': 'flagKey',
+      'keydown @ui.customRuleCreationKey': 'flagKey',
+      'keyup @ui.customRuleCreationKey': 'flagKey',
+
+      'click #coding-rules-custom-rule-creation-cancel': 'destroy',
+      'click @ui.customRuleCreationCreate': 'create',
+      'click @ui.customRuleCreationReactivate': 'reactivate'
+    });
+  },
+
+  generateKey: function () {
+    if (!this.keyModifiedByUser && this.ui.customRuleCreationKey) {
+      var generatedKey = this.ui.customRuleCreationName.val().latinize().replace(/[^A-Za-z0-9]/g, '_');
+      this.ui.customRuleCreationKey.val(generatedKey);
+    }
+  },
+
+  flagKey: function () {
+    this.keyModifiedByUser = true;
+  },
+
+  onRender: function () {
+    ModalFormView.prototype.onRender.apply(this, arguments);
+
+    this.keyModifiedByUser = false;
+
+    var format = function (state) {
+          if (!state.id) {
+            return state.text;
+          } else {
+            return '<i class="icon-severity-' + state.id.toLowerCase() + '"></i> ' + state.text;
+          }
+        },
+        severity = (this.model && this.model.get('severity')) || this.options.templateRule.get('severity'),
+        status = (this.model && this.model.get('status')) || this.options.templateRule.get('status');
+
+    this.ui.customRuleCreationSeverity.val(severity);
+    this.ui.customRuleCreationSeverity.select2({
+      width: '250px',
+      minimumResultsForSearch: 999,
+      formatResult: format,
+      formatSelection: format
+    });
+
+    this.ui.customRuleCreationStatus.val(status);
+    this.ui.customRuleCreationStatus.select2({
+      width: '250px',
+      minimumResultsForSearch: 999
+    });
+  },
+
+  create: function (e) {
+    e.preventDefault();
+    var action = (this.model && this.model.has('key')) ? 'update' : 'create',
+        options = {
+          name: this.ui.customRuleCreationName.val(),
+          markdown_description: this.ui.customRuleCreationHtmlDescription.val(),
+          severity: this.ui.customRuleCreationSeverity.val(),
+          status: this.ui.customRuleCreationStatus.val()
+        };
+    if (this.model && this.model.has('key')) {
+      options.key = this.model.get('key');
+    } else {
+      _.extend(options, {
+        template_key: this.options.templateRule.get('key'),
+        custom_key: this.ui.customRuleCreationKey.val(),
+        prevent_reactivation: true
       });
-    },
-
-    generateKey: function () {
-      if (!this.keyModifiedByUser && this.ui.customRuleCreationKey) {
-        var generatedKey = this.ui.customRuleCreationName.val().latinize().replace(/[^A-Za-z0-9]/g, '_');
-        this.ui.customRuleCreationKey.val(generatedKey);
+    }
+    var params = this.ui.customRuleCreationParameters.map(function () {
+      var node = $(this),
+          value = node.val();
+      if (!value && action === 'create') {
+        value = node.prop('placeholder') || '';
       }
-    },
-
-    flagKey: function () {
-      this.keyModifiedByUser = true;
-    },
-
-    onRender: function () {
-      ModalFormView.prototype.onRender.apply(this, arguments);
-
-      this.keyModifiedByUser = false;
-
-      var format = function (state) {
-            if (!state.id) {
-              return state.text;
-            } else {
-              return '<i class="icon-severity-' + state.id.toLowerCase() + '"></i> ' + state.text;
-            }
-          },
-          severity = (this.model && this.model.get('severity')) || this.options.templateRule.get('severity'),
-          status = (this.model && this.model.get('status')) || this.options.templateRule.get('status');
-
-      this.ui.customRuleCreationSeverity.val(severity);
-      this.ui.customRuleCreationSeverity.select2({
-        width: '250px',
-        minimumResultsForSearch: 999,
-        formatResult: format,
-        formatSelection: format
-      });
-
-      this.ui.customRuleCreationStatus.val(status);
-      this.ui.customRuleCreationStatus.select2({
-        width: '250px',
-        minimumResultsForSearch: 999
-      });
-    },
-
-    create: function (e) {
-      e.preventDefault();
-      var action = (this.model && this.model.has('key')) ? 'update' : 'create',
-          options = {
-            name: this.ui.customRuleCreationName.val(),
-            markdown_description: this.ui.customRuleCreationHtmlDescription.val(),
-            severity: this.ui.customRuleCreationSeverity.val(),
-            status: this.ui.customRuleCreationStatus.val()
-          };
-      if (this.model && this.model.has('key')) {
-        options.key = this.model.get('key');
-      } else {
-        _.extend(options, {
-          template_key: this.options.templateRule.get('key'),
+      return {
+        key: node.prop('name'),
+        value: value
+      };
+    }).get();
+    options.params = params.map(function (param) {
+      return param.key + '=' + window.csvEscape(param.value);
+    }).join(';');
+    this.sendRequest(action, options);
+  },
+
+  reactivate: function () {
+    var options = {
+          name: this.existingRule.name,
+          markdown_description: this.existingRule.mdDesc,
+          severity: this.existingRule.severity,
+          status: this.existingRule.status,
+          template_key: this.existingRule.templateKey,
           custom_key: this.ui.customRuleCreationKey.val(),
-          prevent_reactivation: true
-        });
+          prevent_reactivation: false
+        },
+        params = this.existingRule.params;
+    options.params = params.map(function (param) {
+      return param.key + '=' + param.defaultValue;
+    }).join(';');
+    this.sendRequest('create', options);
+  },
+
+  sendRequest: function (action, options) {
+    this.$('.alert').addClass('hidden');
+    var that = this,
+        url = baseUrl + '/api/rules/' + action;
+    return $.ajax({
+      url: url,
+      type: 'POST',
+      data: options,
+      statusCode: {
+        // do not show global error
+        400: null
       }
-      var params = this.ui.customRuleCreationParameters.map(function () {
-        var node = $(this),
-            value = node.val();
-        if (!value && action === 'create') {
-          value = node.prop('placeholder') || '';
-        }
-        return {
-          key: node.prop('name'),
-          value: value
-        };
-      }).get();
-      options.params = params.map(function (param) {
-        return param.key + '=' + window.csvEscape(param.value);
-      }).join(';');
-      this.sendRequest(action, options);
-    },
-
-    reactivate: function () {
-      var options = {
-            name: this.existingRule.name,
-            markdown_description: this.existingRule.mdDesc,
-            severity: this.existingRule.severity,
-            status: this.existingRule.status,
-            template_key: this.existingRule.templateKey,
-            custom_key: this.ui.customRuleCreationKey.val(),
-            prevent_reactivation: false
-          },
-          params = this.existingRule.params;
-      options.params = params.map(function (param) {
-        return param.key + '=' + param.defaultValue;
-      }).join(';');
-      this.sendRequest('create', options);
-    },
-
-    sendRequest: function (action, options) {
-      this.$('.alert').addClass('hidden');
-      var that = this,
-          url = baseUrl + '/api/rules/' + action;
-      return $.ajax({
-        url: url,
-        type: 'POST',
-        data: options,
-        statusCode: {
-          // do not show global error
-          400: null
-        }
-      }).done(function () {
-        if (that.options.templateRule) {
-          that.options.app.controller.showDetails(that.options.templateRule);
-        } else {
-          that.options.app.controller.showDetails(that.model);
-        }
-        that.destroy();
-      }).fail(function (jqXHR) {
-        if (jqXHR.status === 409) {
-          that.existingRule = jqXHR.responseJSON.rule;
-          that.showErrors([], [{ msg: t('coding_rules.reactivate.help') }]);
-          that.ui.customRuleCreationCreate.addClass('hidden');
-          that.ui.customRuleCreationReactivate.removeClass('hidden');
-        } else {
-          that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
-        }
-      });
-    },
-
-    serializeData: function () {
-      var params = {};
-      if (this.options.templateRule) {
-        params = this.options.templateRule.get('params');
-      } else if (this.model && this.model.has('params')) {
-        params = this.model.get('params').map(function (p) {
-          return _.extend(p, { value: p.defaultValue });
-        });
+    }).done(function () {
+      if (that.options.templateRule) {
+        that.options.app.controller.showDetails(that.options.templateRule);
+      } else {
+        that.options.app.controller.showDetails(that.model);
       }
-
-      var statuses = ['READY', 'BETA', 'DEPRECATED'].map(function (status) {
-        return {
-          id: status,
-          text: t('rules.status', status.toLowerCase())
-        };
-      });
-
-      return _.extend(ModalFormView.prototype.serializeData.apply(this, arguments), {
-        change: this.model && this.model.has('key'),
-        params: params,
-        severities: ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'],
-        statuses: statuses
+      that.destroy();
+    }).fail(function (jqXHR) {
+      if (jqXHR.status === 409) {
+        that.existingRule = jqXHR.responseJSON.rule;
+        that.showErrors([], [{ msg: t('coding_rules.reactivate.help') }]);
+        that.ui.customRuleCreationCreate.addClass('hidden');
+        that.ui.customRuleCreationReactivate.removeClass('hidden');
+      } else {
+        that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+      }
+    });
+  },
+
+  serializeData: function () {
+    var params = {};
+    if (this.options.templateRule) {
+      params = this.options.templateRule.get('params');
+    } else if (this.model && this.model.has('params')) {
+      params = this.model.get('params').map(function (p) {
+        return _.extend(p, { value: p.defaultValue });
       });
     }
-  });
 
+    var statuses = ['READY', 'BETA', 'DEPRECATED'].map(function (status) {
+      return {
+        id: status,
+        text: t('rules.status', status.toLowerCase())
+      };
+    });
+
+    return _.extend(ModalFormView.prototype.serializeData.apply(this, arguments), {
+      change: this.model && this.model.has('key'),
+      params: params,
+      severities: ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'],
+      statuses: statuses
+    });
+  }
 });
+
+
index f13f23bd9b419b45fa65883b8e94e20e3ecca334..a47aef607b8077c30155ad7ce89b9c8b72edf103 100644 (file)
@@ -1,44 +1,43 @@
-define([
-  '../templates'
-], function () {
+import $ from 'jquery';
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import '../templates';
 
-  var $ = jQuery;
+export default Marionette.ItemView.extend({
+  tagName: 'tr',
+  template: Templates['coding-rules-custom-rule'],
 
-  return Marionette.ItemView.extend({
-    tagName: 'tr',
-    template: Templates['coding-rules-custom-rule'],
+  modelEvents: {
+    'change': 'render'
+  },
 
-    modelEvents: {
-      'change': 'render'
-    },
+  events: {
+    'click .js-delete-custom-rule': 'deleteRule'
+  },
 
-    events: {
-      'click .js-delete-custom-rule': 'deleteRule'
-    },
+  deleteRule: function () {
+    var that = this;
+    window.confirmDialog({
+      title: t('delete'),
+      html: t('are_you_sure'),
+      yesHandler: function () {
+        var url = baseUrl + '/api/rules/delete',
+            options = { key: that.model.id };
+        $.post(url, options).done(function () {
+          that.model.collection.remove(that.model);
+          that.destroy();
+        });
+      }
+    });
+  },
 
-    deleteRule: function () {
-      var that = this;
-      window.confirmDialog({
-        title: t('delete'),
-        html: t('are_you_sure'),
-        yesHandler: function () {
-          var url = baseUrl + '/api/rules/delete',
-              options = { key: that.model.id };
-          $.post(url, options).done(function () {
-            that.model.collection.remove(that.model);
-            that.destroy();
-          });
-        }
-      });
-    },
+  serializeData: function () {
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      canWrite: this.options.app.canWrite,
+      templateRule: this.options.templateRule,
+      permalink: baseUrl + '/coding_rules/#rule_key=' + encodeURIComponent(this.model.id)
+    });
+  }
+});
 
-    serializeData: function () {
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        canWrite: this.options.app.canWrite,
-        templateRule: this.options.templateRule,
-        permalink: baseUrl + '/coding_rules/#rule_key=' + encodeURIComponent(this.model.id)
-      });
-    }
-  });
 
-});
index 937dde942676d3551db1c3a93a3035ff58bbfe95..7486abbb57314f622053a1d58ec6b217de5cf3a5 100644 (file)
@@ -1,45 +1,45 @@
-define([
-  './custom-rule-view',
-  './custom-rule-creation-view',
-  '../templates'
-], function (CustomRuleView, CustomRuleCreationView) {
-
-  return Marionette.CompositeView.extend({
-    template: Templates['coding-rules-custom-rules'],
-    childView: CustomRuleView,
-    childViewContainer: '#coding-rules-detail-custom-rules',
-
-    childViewOptions: function () {
-      return {
-        app: this.options.app,
-        templateRule: this.model
-      };
-    },
-
-    modelEvents: {
-      'change': 'render'
-    },
-
-    events: {
-      'click .js-create-custom-rule': 'createCustomRule'
-    },
-
-    onRender: function () {
-      this.$el.toggleClass('hidden', !this.model.get('isTemplate'));
-    },
-
-    createCustomRule: function () {
-      new CustomRuleCreationView({
-        app: this.options.app,
-        templateRule: this.model
-      }).render();
-    },
-
-    serializeData: function () {
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        canWrite: this.options.app.canWrite
-      });
-    }
-  });
-
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import CustomRuleView from './custom-rule-view';
+import CustomRuleCreationView from './custom-rule-creation-view';
+import '../templates';
+
+export default Marionette.CompositeView.extend({
+  template: Templates['coding-rules-custom-rules'],
+  childView: CustomRuleView,
+  childViewContainer: '#coding-rules-detail-custom-rules',
+
+  childViewOptions: function () {
+    return {
+      app: this.options.app,
+      templateRule: this.model
+    };
+  },
+
+  modelEvents: {
+    'change': 'render'
+  },
+
+  events: {
+    'click .js-create-custom-rule': 'createCustomRule'
+  },
+
+  onRender: function () {
+    this.$el.toggleClass('hidden', !this.model.get('isTemplate'));
+  },
+
+  createCustomRule: function () {
+    new CustomRuleCreationView({
+      app: this.options.app,
+      templateRule: this.model
+    }).render();
+  },
+
+  serializeData: function () {
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      canWrite: this.options.app.canWrite
+    });
+  }
 });
+
+
index 2118434b3042ab4a61cb35c18b1a4f10dd51bd2a..f0890a06e08b336893d4ccfd697b6b504e6eada8 100644 (file)
-define([
-  'components/common/modal-form',
-  '../templates'
-], function (ModalFormView) {
+import $ from 'jquery';
+import _ from 'underscore';
+import ModalFormView from 'components/common/modal-form';
+import '../templates';
 
-  var $ = jQuery;
+export default ModalFormView.extend({
+  template: Templates['coding-rules-manual-rule-creation'],
 
-  return ModalFormView.extend({
-    template: Templates['coding-rules-manual-rule-creation'],
+  ui: function () {
+    return _.extend(ModalFormView.prototype.ui.apply(this.arguments), {
+      manualRuleCreationKey: '#coding-rules-manual-rule-creation-key',
+      manualRuleCreationName: '#coding-rules-manual-rule-creation-name',
+      manualRuleCreationHtmlDescription: '#coding-rules-manual-rule-creation-html-description',
+      manualRuleCreationSeverity: '#coding-rules-manual-rule-creation-severity',
+      manualRuleCreationStatus: '#coding-rules-manual-rule-creation-status',
+      manualRuleCreationParameters: '[name]',
+      manualRuleCreationCreate: '#coding-rules-manual-rule-creation-create',
+      manualRuleCreationReactivate: '#coding-rules-manual-rule-creation-reactivate',
+      modalFoot: '.modal-foot'
+    });
+  },
 
-    ui: function () {
-      return _.extend(ModalFormView.prototype.ui.apply(this.arguments), {
-        manualRuleCreationKey: '#coding-rules-manual-rule-creation-key',
-        manualRuleCreationName: '#coding-rules-manual-rule-creation-name',
-        manualRuleCreationHtmlDescription: '#coding-rules-manual-rule-creation-html-description',
-        manualRuleCreationSeverity: '#coding-rules-manual-rule-creation-severity',
-        manualRuleCreationStatus: '#coding-rules-manual-rule-creation-status',
-        manualRuleCreationParameters: '[name]',
-        manualRuleCreationCreate: '#coding-rules-manual-rule-creation-create',
-        manualRuleCreationReactivate: '#coding-rules-manual-rule-creation-reactivate',
-        modalFoot: '.modal-foot'
-      });
-    },
+  events: function () {
+    return _.extend(ModalFormView.prototype.events.apply(this.arguments), {
+      'input @ui.manualRuleCreationName': 'generateKey',
+      'keydown @ui.manualRuleCreationName': 'generateKey',
+      'keyup @ui.manualRuleCreationName': 'generateKey',
 
-    events: function () {
-      return _.extend(ModalFormView.prototype.events.apply(this.arguments), {
-        'input @ui.manualRuleCreationName': 'generateKey',
-        'keydown @ui.manualRuleCreationName': 'generateKey',
-        'keyup @ui.manualRuleCreationName': 'generateKey',
+      'input @ui.manualRuleCreationKey': 'flagKey',
+      'keydown @ui.manualRuleCreationKey': 'flagKey',
+      'keyup @ui.manualRuleCreationKey': 'flagKey',
 
-        'input @ui.manualRuleCreationKey': 'flagKey',
-        'keydown @ui.manualRuleCreationKey': 'flagKey',
-        'keyup @ui.manualRuleCreationKey': 'flagKey',
+      'click #coding-rules-manual-rule-creation-cancel': 'hide',
+      'click @ui.manualRuleCreationCreate': 'create',
+      'click @ui.manualRuleCreationReactivate': 'reactivate'
+    });
+  },
 
-        'click #coding-rules-manual-rule-creation-cancel': 'hide',
-        'click @ui.manualRuleCreationCreate': 'create',
-        'click @ui.manualRuleCreationReactivate': 'reactivate'
-      });
-    },
+  onRender: function () {
+    ModalFormView.prototype.onRender.apply(this, arguments);
+    this.keyModifiedByUser = false;
+    this.ui.manualRuleCreationReactivate.addClass('hidden');
+  },
 
-    onRender: function () {
-      ModalFormView.prototype.onRender.apply(this, arguments);
-      this.keyModifiedByUser = false;
-      this.ui.manualRuleCreationReactivate.addClass('hidden');
-    },
+  generateKey: function () {
+    if (!this.keyModifiedByUser && this.ui.manualRuleCreationKey) {
+      var generatedKey = this.ui.manualRuleCreationName.val().latinize().replace(/[^A-Za-z0-9]/g, '_');
+      this.ui.manualRuleCreationKey.val(generatedKey);
+    }
+  },
 
-    generateKey: function () {
-      if (!this.keyModifiedByUser && this.ui.manualRuleCreationKey) {
-        var generatedKey = this.ui.manualRuleCreationName.val().latinize().replace(/[^A-Za-z0-9]/g, '_');
-        this.ui.manualRuleCreationKey.val(generatedKey);
-      }
-    },
+  flagKey: function () {
+    this.keyModifiedByUser = true;
+  },
 
-    flagKey: function () {
-      this.keyModifiedByUser = true;
-    },
+  create: function () {
+    var action = (this.model && this.model.has('key')) ? 'update' : 'create',
+        options = {
+          name: this.ui.manualRuleCreationName.val(),
+          markdown_description: this.ui.manualRuleCreationHtmlDescription.val()
+        };
+    if (action === 'update') {
+      options.key = this.model.get('key');
+    } else {
+      options.manual_key = this.ui.manualRuleCreationKey.val();
+      options.prevent_reactivation = true;
+    }
+    this.sendRequest(action, options);
+  },
 
-    create: function () {
-      var action = (this.model && this.model.has('key')) ? 'update' : 'create',
-          options = {
-            name: this.ui.manualRuleCreationName.val(),
-            markdown_description: this.ui.manualRuleCreationHtmlDescription.val()
-          };
-      if (action === 'update') {
-        options.key = this.model.get('key');
+  reactivate: function () {
+    var options = {
+      name: this.existingRule.name,
+      markdown_description: this.existingRule.mdDesc,
+      manual_key: this.ui.manualRuleCreationKey.val(),
+      prevent_reactivation: false
+    };
+    this.sendRequest('create', options);
+  },
+
+  sendRequest: function (action, options) {
+    var that = this,
+        url = baseUrl + '/api/rules/' + action;
+    return $.ajax({
+      url: url,
+      type: 'POST',
+      data: options,
+      statusCode: {
+        // do not show global error
+        400: null
+      }
+    }).done(function (r) {
+      if (typeof r === 'string') {
+        r = JSON.parse(r);
+      }
+      that.options.app.controller.showDetails(r.rule.key);
+      that.destroy();
+    }).fail(function (jqXHR) {
+      if (jqXHR.status === 409) {
+        that.existingRule = jqXHR.responseJSON.rule;
+        that.showErrors([], [{ msg: t('coding_rules.reactivate.help') }]);
+        that.ui.manualRuleCreationCreate.addClass('hidden');
+        that.ui.manualRuleCreationReactivate.removeClass('hidden');
       } else {
-        options.manual_key = this.ui.manualRuleCreationKey.val();
-        options.prevent_reactivation = true;
+        that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
       }
-      this.sendRequest(action, options);
-    },
+    });
+  },
 
-    reactivate: function () {
-      var options = {
-        name: this.existingRule.name,
-        markdown_description: this.existingRule.mdDesc,
-        manual_key: this.ui.manualRuleCreationKey.val(),
-        prevent_reactivation: false
-      };
-      this.sendRequest('create', options);
-    },
+  serializeData: function () {
+    return _.extend(ModalFormView.prototype.serializeData.apply(this, arguments), {
+      change: this.model && this.model.has('key')
+    });
+  }
+});
 
-    sendRequest: function (action, options) {
-      var that = this,
-          url = baseUrl + '/api/rules/' + action;
-      return $.ajax({
-        url: url,
-        type: 'POST',
-        data: options,
-        statusCode: {
-          // do not show global error
-          400: null
-        }
-      }).done(function (r) {
-        if (typeof r === 'string') {
-          r = JSON.parse(r);
-        }
-        that.options.app.controller.showDetails(r.rule.key);
-        that.destroy();
-      }).fail(function (jqXHR) {
-        if (jqXHR.status === 409) {
-          that.existingRule = jqXHR.responseJSON.rule;
-          that.showErrors([], [{ msg: t('coding_rules.reactivate.help') }]);
-          that.ui.manualRuleCreationCreate.addClass('hidden');
-          that.ui.manualRuleCreationReactivate.removeClass('hidden');
-        } else {
-          that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
-        }
-      });
-    },
 
-    serializeData: function () {
-      return _.extend(ModalFormView.prototype.serializeData.apply(this, arguments), {
-        change: this.model && this.model.has('key')
-      });
-    }
-  });
-
-});
index 8354a882453b6e925b9ca09eb5a9bb5c93e281bb..8ea8ce0496d18082fe599eddf61e6690a5eae2cf 100644 (file)
-define([
-  'components/common/modal-form',
-  '../templates'
-], function (ModalForm) {
-
-  var $ = jQuery;
-
-  return ModalForm.extend({
-    template: Templates['coding-rules-profile-activation'],
-
-    ui: function () {
-      return _.extend(this._super(), {
-        qualityProfileSelect: '#coding-rules-quality-profile-activation-select',
-        qualityProfileSeverity: '#coding-rules-quality-profile-activation-severity',
-        qualityProfileActivate: '#coding-rules-quality-profile-activation-activate',
-        qualityProfileParameters: '[name]'
-      });
-    },
-
-    events: function () {
-      return _.extend(this._super(), {
-        'click @ui.qualityProfileActivate': 'activate'
-      });
-    },
-
-    onRender: function () {
-      this._super();
-
-      this.ui.qualityProfileSelect.select2({
-        width: '250px',
-        minimumResultsForSearch: 5
-      });
-
-      var that = this,
-          format = function (state) {
-            if (!state.id) {
-              return state.text;
-            } else {
-              return '<i class="icon-severity-' + state.id.toLowerCase() + '"></i> ' + state.text;
-            }
-          },
-          severity = (this.model && this.model.get('severity')) || this.options.rule.get('severity');
-      this.ui.qualityProfileSeverity.val(severity);
-      this.ui.qualityProfileSeverity.select2({
-        width: '250px',
-        minimumResultsForSearch: 999,
-        formatResult: format,
-        formatSelection: format
-      });
-      setTimeout(function () {
-        that.$('a').first().focus();
-      }, 0);
-    },
-
-    activate: function (e) {
-      e.preventDefault();
-      var that = this,
-          profileKey = this.ui.qualityProfileSelect.val(),
-          params = this.ui.qualityProfileParameters.map(function () {
-            return {
-              key: $(this).prop('name'),
-              value: $(this).val() || $(this).prop('placeholder') || ''
-            };
-          }).get(),
-          paramsHash = (params.map(function (param) {
-            return param.key + '=' + window.csvEscape(param.value);
-          })).join(';');
-
-      if (this.model) {
-        profileKey = this.model.get('qProfile');
-        if (!profileKey) {
-          profileKey = this.model.get('key');
-        }
-      }
-
-      var severity = this.ui.qualityProfileSeverity.val(),
-          ruleKey = this.options.rule.get('key');
-
-      this.disableForm();
-
-      return jQuery.ajax({
-        type: 'POST',
-        url: baseUrl + '/api/qualityprofiles/activate_rule',
-        data: {
-          profile_key: profileKey,
-          rule_key: ruleKey,
-          severity: severity,
-          params: paramsHash
+import $ from 'jquery';
+import _ from 'underscore';
+import Backbone from 'backbone';
+import ModalForm from 'components/common/modal-form';
+import '../templates';
+
+export default ModalForm.extend({
+  template: Templates['coding-rules-profile-activation'],
+
+  ui: function () {
+    return _.extend(this._super(), {
+      qualityProfileSelect: '#coding-rules-quality-profile-activation-select',
+      qualityProfileSeverity: '#coding-rules-quality-profile-activation-severity',
+      qualityProfileActivate: '#coding-rules-quality-profile-activation-activate',
+      qualityProfileParameters: '[name]'
+    });
+  },
+
+  events: function () {
+    return _.extend(this._super(), {
+      'click @ui.qualityProfileActivate': 'activate'
+    });
+  },
+
+  onRender: function () {
+    this._super();
+
+    this.ui.qualityProfileSelect.select2({
+      width: '250px',
+      minimumResultsForSearch: 5
+    });
+
+    var that = this,
+        format = function (state) {
+          if (!state.id) {
+            return state.text;
+          } else {
+            return '<i class="icon-severity-' + state.id.toLowerCase() + '"></i> ' + state.text;
+          }
         },
-        statusCode: {
-          // do not show global error
-          400: null
-        }
-      }).done(function () {
-        that.destroy();
-        that.trigger('profileActivated', severity, params, profileKey);
-      }).fail(function (jqXHR) {
-        that.enableForm();
-        that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
-      });
-    },
-
-    getAvailableQualityProfiles: function (lang) {
-      var activeQualityProfiles = this.collection || new Backbone.Collection(),
-          inactiveProfiles = _.reject(this.options.app.qualityProfiles, function (profile) {
-            return activeQualityProfiles.findWhere({ key: profile.key });
-          });
-      return _.filter(inactiveProfiles, function (profile) {
-        return profile.lang === lang;
-      });
-    },
-
-    serializeData: function () {
-      var params = this.options.rule.get('params');
-      if (this.model != null) {
-        var modelParams = this.model.get('params');
-        if (_.isArray(modelParams)) {
-          params = params.map(function (p) {
-            var parentParam = _.findWhere(modelParams, { key: p.key });
-            if (parentParam != null) {
-              _.extend(p, { value: parentParam.value });
-            }
-            return p;
-          });
-        }
+        severity = (this.model && this.model.get('severity')) || this.options.rule.get('severity');
+    this.ui.qualityProfileSeverity.val(severity);
+    this.ui.qualityProfileSeverity.select2({
+      width: '250px',
+      minimumResultsForSearch: 999,
+      formatResult: format,
+      formatSelection: format
+    });
+    setTimeout(function () {
+      that.$('a').first().focus();
+    }, 0);
+  },
+
+  activate: function (e) {
+    e.preventDefault();
+    var that = this,
+        profileKey = this.ui.qualityProfileSelect.val(),
+        params = this.ui.qualityProfileParameters.map(function () {
+          return {
+            key: $(this).prop('name'),
+            value: $(this).val() || $(this).prop('placeholder') || ''
+          };
+        }).get(),
+        paramsHash = (params.map(function (param) {
+          return param.key + '=' + window.csvEscape(param.value);
+        })).join(';');
+
+    if (this.model) {
+      profileKey = this.model.get('qProfile');
+      if (!profileKey) {
+        profileKey = this.model.get('key');
       }
+    }
 
-      var availableProfiles = this.getAvailableQualityProfiles(this.options.rule.get('lang')),
-          contextProfile = this.options.app.state.get('query').qprofile;
-
-      return _.extend(this._super(), {
-        change: this.model && this.model.has('severity'),
-        params: params,
-        qualityProfiles: availableProfiles,
-        contextProfile: contextProfile,
-        severities: ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'],
-        saveEnabled: !_.isEmpty(availableProfiles) || (this.model && this.model.get('qProfile')),
-        isCustomRule: (this.model && this.model.has('templateKey')) || this.options.rule.has('templateKey')
-      });
+    var severity = this.ui.qualityProfileSeverity.val(),
+        ruleKey = this.options.rule.get('key');
+
+    this.disableForm();
+
+    return $.ajax({
+      type: 'POST',
+      url: baseUrl + '/api/qualityprofiles/activate_rule',
+      data: {
+        profile_key: profileKey,
+        rule_key: ruleKey,
+        severity: severity,
+        params: paramsHash
+      },
+      statusCode: {
+        // do not show global error
+        400: null
+      }
+    }).done(function () {
+      that.destroy();
+      that.trigger('profileActivated', severity, params, profileKey);
+    }).fail(function (jqXHR) {
+      that.enableForm();
+      that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+    });
+  },
+
+  getAvailableQualityProfiles: function (lang) {
+    var activeQualityProfiles = this.collection || new Backbone.Collection(),
+        inactiveProfiles = _.reject(this.options.app.qualityProfiles, function (profile) {
+          return activeQualityProfiles.findWhere({ key: profile.key });
+        });
+    return _.filter(inactiveProfiles, function (profile) {
+      return profile.lang === lang;
+    });
+  },
+
+  serializeData: function () {
+    var params = this.options.rule.get('params');
+    if (this.model != null) {
+      var modelParams = this.model.get('params');
+      if (_.isArray(modelParams)) {
+        params = params.map(function (p) {
+          var parentParam = _.findWhere(modelParams, { key: p.key });
+          if (parentParam != null) {
+            _.extend(p, { value: parentParam.value });
+          }
+          return p;
+        });
+      }
     }
-  });
 
+    var availableProfiles = this.getAvailableQualityProfiles(this.options.rule.get('lang')),
+        contextProfile = this.options.app.state.get('query').qprofile;
+
+    return _.extend(this._super(), {
+      change: this.model && this.model.has('severity'),
+      params: params,
+      qualityProfiles: availableProfiles,
+      contextProfile: contextProfile,
+      severities: ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'],
+      saveEnabled: !_.isEmpty(availableProfiles) || (this.model && this.model.get('qProfile')),
+      isCustomRule: (this.model && this.model.has('templateKey')) || this.options.rule.has('templateKey')
+    });
+  }
 });
+
+
index 3bb81840549ffc698e2b4d46e1d64470e0d1c0c9..e49e2bb2a75a877a52f179c96b274ee0c4be5dd5 100644 (file)
@@ -1,83 +1,84 @@
-define([
-  '../templates'
-], function () {
+import $ from 'jquery';
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import '../templates';
 
-  return Marionette.ItemView.extend({
-    template: Templates['coding-rules-rule-description'],
+export default Marionette.ItemView.extend({
+  template: Templates['coding-rules-rule-description'],
 
-    modelEvents: {
-      'change': 'render'
-    },
+  modelEvents: {
+    'change': 'render'
+  },
 
-    ui: {
-      descriptionExtra: '#coding-rules-detail-description-extra',
-      extendDescriptionLink: '#coding-rules-detail-extend-description',
-      extendDescriptionForm: '.coding-rules-detail-extend-description-form',
-      extendDescriptionSubmit: '#coding-rules-detail-extend-description-submit',
-      extendDescriptionRemove: '#coding-rules-detail-extend-description-remove',
-      extendDescriptionText: '#coding-rules-detail-extend-description-text',
-      cancelExtendDescription: '#coding-rules-detail-extend-description-cancel'
-    },
+  ui: {
+    descriptionExtra: '#coding-rules-detail-description-extra',
+    extendDescriptionLink: '#coding-rules-detail-extend-description',
+    extendDescriptionForm: '.coding-rules-detail-extend-description-form',
+    extendDescriptionSubmit: '#coding-rules-detail-extend-description-submit',
+    extendDescriptionRemove: '#coding-rules-detail-extend-description-remove',
+    extendDescriptionText: '#coding-rules-detail-extend-description-text',
+    cancelExtendDescription: '#coding-rules-detail-extend-description-cancel'
+  },
 
-    events: {
-      'click @ui.extendDescriptionLink': 'showExtendDescriptionForm',
-      'click @ui.cancelExtendDescription': 'hideExtendDescriptionForm',
-      'click @ui.extendDescriptionSubmit': 'submitExtendDescription',
-      'click @ui.extendDescriptionRemove': 'removeExtendedDescription'
-    },
+  events: {
+    'click @ui.extendDescriptionLink': 'showExtendDescriptionForm',
+    'click @ui.cancelExtendDescription': 'hideExtendDescriptionForm',
+    'click @ui.extendDescriptionSubmit': 'submitExtendDescription',
+    'click @ui.extendDescriptionRemove': 'removeExtendedDescription'
+  },
 
-    showExtendDescriptionForm: function () {
-      this.ui.descriptionExtra.addClass('hidden');
-      this.ui.extendDescriptionForm.removeClass('hidden');
-      this.ui.extendDescriptionText.focus();
-    },
+  showExtendDescriptionForm: function () {
+    this.ui.descriptionExtra.addClass('hidden');
+    this.ui.extendDescriptionForm.removeClass('hidden');
+    this.ui.extendDescriptionText.focus();
+  },
 
-    hideExtendDescriptionForm: function () {
-      this.ui.descriptionExtra.removeClass('hidden');
-      this.ui.extendDescriptionForm.addClass('hidden');
-    },
+  hideExtendDescriptionForm: function () {
+    this.ui.descriptionExtra.removeClass('hidden');
+    this.ui.extendDescriptionForm.addClass('hidden');
+  },
 
-    submitExtendDescription: function () {
-      var that = this;
-      this.ui.extendDescriptionForm.addClass('hidden');
-      return jQuery.ajax({
-        type: 'POST',
-        url: baseUrl + '/api/rules/update',
-        dataType: 'json',
-        data: {
-          key: this.model.get('key'),
-          markdown_note: this.ui.extendDescriptionText.val()
-        }
-      }).done(function (r) {
-        that.model.set({
-          htmlNote: r.rule.htmlNote,
-          mdNote: r.rule.mdNote
-        });
-        that.render();
-      }).fail(function () {
-        that.render();
+  submitExtendDescription: function () {
+    var that = this;
+    this.ui.extendDescriptionForm.addClass('hidden');
+    return $.ajax({
+      type: 'POST',
+      url: baseUrl + '/api/rules/update',
+      dataType: 'json',
+      data: {
+        key: this.model.get('key'),
+        markdown_note: this.ui.extendDescriptionText.val()
+      }
+    }).done(function (r) {
+      that.model.set({
+        htmlNote: r.rule.htmlNote,
+        mdNote: r.rule.mdNote
       });
-    },
+      that.render();
+    }).fail(function () {
+      that.render();
+    });
+  },
 
-    removeExtendedDescription: function () {
-      var that = this;
-      window.confirmDialog({
-        html: t('coding_rules.remove_extended_description.confirm'),
-        yesHandler: function () {
-          that.ui.extendDescriptionText.val('');
-          that.submitExtendDescription();
-        }
-      });
-    },
-
-    serializeData: function () {
-      var isEditable = this.options.app.canWrite && (this.model.get('isManual') || this.model.get('isCustom'));
+  removeExtendedDescription: function () {
+    var that = this;
+    window.confirmDialog({
+      html: t('coding_rules.remove_extended_description.confirm'),
+      yesHandler: function () {
+        that.ui.extendDescriptionText.val('');
+        that.submitExtendDescription();
+      }
+    });
+  },
 
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        isEditable: isEditable,
-        canWrite: this.options.app.canWrite
-      });
-    }
-  });
+  serializeData: function () {
+    var isEditable = this.options.app.canWrite && (this.model.get('isManual') || this.model.get('isCustom'));
 
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      isEditable: isEditable,
+      canWrite: this.options.app.canWrite
+    });
+  }
 });
+
+
index 75e072f979b7a69796101421caf3e6b74662d813..f71af9a5826c69d03855df394d7ede3c96b7393e 100644 (file)
@@ -1,28 +1,25 @@
-define([
-  '../rule-filter-view'
-], function (RuleFilterView) {
+import $ from 'jquery';
+import RuleFilterView from '../rule-filter-view';
 
-  var $ = jQuery;
+export default {
+  onRuleFilterClick: function (e) {
+    e.preventDefault();
+    e.stopPropagation();
+    $('body').click();
+    var that = this,
+        popup = new RuleFilterView({
+          triggerEl: $(e.currentTarget),
+          bottomRight: true,
+          model: this.model
+        });
+    popup.on('select', function (property, value) {
+      var obj = {};
+      obj[property] = '' + value;
+      that.options.app.state.updateFilter(obj);
+      popup.destroy();
+    });
+    popup.render();
+  }
+};
 
-  return {
-    onRuleFilterClick: function (e) {
-      e.preventDefault();
-      e.stopPropagation();
-      $('body').click();
-      var that = this,
-          popup = new RuleFilterView({
-            triggerEl: $(e.currentTarget),
-            bottomRight: true,
-            model: this.model
-          });
-      popup.on('select', function (property, value) {
-        var obj = {};
-        obj[property] = '' + value;
-        that.options.app.state.updateFilter(obj);
-        popup.destroy();
-      });
-      popup.render();
-    }
-  };
 
-});
index 429be6fb6eee1740fa6e42dc8a3f8201de8bbb3b..0bd9da9bdacf277b8e51c8853de5a3994b93ffa1 100644 (file)
@@ -1,51 +1,50 @@
-define([
-  '../templates'
-], function () {
+import $ from 'jquery';
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import '../templates';
 
-  var $ = jQuery;
+export default Marionette.ItemView.extend({
+  template: Templates['coding-rules-rule-issues'],
 
-  return Marionette.ItemView.extend({
-    template: Templates['coding-rules-rule-issues'],
+  initialize: function () {
+    var that = this;
+    this.total = null;
+    this.projects = [];
+    this.requestIssues().done(function () {
+      that.render();
+    });
+  },
 
-    initialize: function () {
-      var that = this;
-      this.total = null;
-      this.projects = [];
-      this.requestIssues().done(function () {
-        that.render();
-      });
-    },
-
-    requestIssues: function () {
-      var that = this,
-          url = baseUrl + '/api/issues/search',
-          options = {
-            rules: this.model.id,
-            resolved: false,
-            ps: 1,
-            facets: 'projectUuids'
-          };
-      return $.get(url, options).done(function (r) {
-        var projectsFacet = _.findWhere(r.facets, { property: 'projectUuids' }),
-            projects = projectsFacet != null ? projectsFacet.values : [];
-        projects = projects.map(function (project) {
-          var projectBase = _.findWhere(r.components, { uuid: project.val });
-          return _.extend(project, {
-            name: projectBase != null ? projectBase.longName : ''
-          });
+  requestIssues: function () {
+    var that = this,
+        url = baseUrl + '/api/issues/search',
+        options = {
+          rules: this.model.id,
+          resolved: false,
+          ps: 1,
+          facets: 'projectUuids'
+        };
+    return $.get(url, options).done(function (r) {
+      var projectsFacet = _.findWhere(r.facets, { property: 'projectUuids' }),
+          projects = projectsFacet != null ? projectsFacet.values : [];
+      projects = projects.map(function (project) {
+        var projectBase = _.findWhere(r.components, { uuid: project.val });
+        return _.extend(project, {
+          name: projectBase != null ? projectBase.longName : ''
         });
-        that.projects = projects;
-        that.total = r.total;
-      });
-    },
-
-    serializeData: function () {
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        total: this.total,
-        projects: this.projects,
-        baseSearchUrl: baseUrl + '/issues/search#resolved=false|rules=' + encodeURIComponent(this.model.id)
       });
-    }
-  });
+      that.projects = projects;
+      that.total = r.total;
+    });
+  },
 
+  serializeData: function () {
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      total: this.total,
+      projects: this.projects,
+      baseSearchUrl: baseUrl + '/issues/search#resolved=false|rules=' + encodeURIComponent(this.model.id)
+    });
+  }
 });
+
+
index ea48038362f60023f6862cf6446cdb0f8f920f6f..f2b947343ddf7082a6cfb6511a3260db35c977ca 100644 (file)
@@ -1,96 +1,97 @@
-define([
-  './rule-filter-mixin',
-  '../templates'
-], function (RuleFilterMixin) {
+import $ from 'jquery';
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import RuleFilterMixin from './rule-filter-mixin';
+import '../templates';
 
-  return Marionette.ItemView.extend(RuleFilterMixin).extend({
-    template: Templates['coding-rules-rule-meta'],
+export default Marionette.ItemView.extend(RuleFilterMixin).extend({
+  template: Templates['coding-rules-rule-meta'],
 
-    modelEvents: {
-      'change': 'render'
-    },
+  modelEvents: {
+    'change': 'render'
+  },
 
-    ui: {
-      tagsChange: '.coding-rules-detail-tags-change',
-      tagInput: '.coding-rules-detail-tag-input',
-      tagsEdit: '.coding-rules-detail-tag-edit',
-      tagsEditDone: '.coding-rules-detail-tag-edit-done',
-      tagsEditCancel: '.coding-rules-details-tag-edit-cancel',
-      tagsList: '.coding-rules-detail-tag-list'
-    },
+  ui: {
+    tagsChange: '.coding-rules-detail-tags-change',
+    tagInput: '.coding-rules-detail-tag-input',
+    tagsEdit: '.coding-rules-detail-tag-edit',
+    tagsEditDone: '.coding-rules-detail-tag-edit-done',
+    tagsEditCancel: '.coding-rules-details-tag-edit-cancel',
+    tagsList: '.coding-rules-detail-tag-list'
+  },
 
-    events: {
-      'click @ui.tagsChange': 'changeTags',
-      'click @ui.tagsEditDone': 'editDone',
-      'click @ui.tagsEditCancel': 'cancelEdit',
-      'click .js-rule-filter': 'onRuleFilterClick'
-    },
+  events: {
+    'click @ui.tagsChange': 'changeTags',
+    'click @ui.tagsEditDone': 'editDone',
+    'click @ui.tagsEditCancel': 'cancelEdit',
+    'click .js-rule-filter': 'onRuleFilterClick'
+  },
 
-    onRender: function () {
-      this.$('[data-toggle="tooltip"]').tooltip({
-        container: 'body'
-      });
-    },
-
-    onDestroy: function () {
-      this.$('[data-toggle="tooltip"]').tooltip('destroy');
-    },
+  onRender: function () {
+    this.$('[data-toggle="tooltip"]').tooltip({
+      container: 'body'
+    });
+  },
 
-    requestTags: function () {
-      var url = baseUrl + '/api/rules/tags';
-      return jQuery.get(url);
-    },
+  onDestroy: function () {
+    this.$('[data-toggle="tooltip"]').tooltip('destroy');
+  },
 
-    changeTags: function () {
-      var that = this;
-      this.requestTags().done(function (r) {
-        that.ui.tagInput.select2({
-          tags: _.difference(_.difference(r.tags, that.model.get('tags')), that.model.get('sysTags')),
-          width: '300px'
-        });
+  requestTags: function () {
+    var url = baseUrl + '/api/rules/tags';
+    return $.get(url);
+  },
 
-        that.ui.tagsEdit.removeClass('hidden');
-        that.ui.tagsList.addClass('hidden');
-        that.tagsBuffer = that.ui.tagInput.select2('val');
-        that.ui.tagInput.select2('open');
+  changeTags: function () {
+    var that = this;
+    this.requestTags().done(function (r) {
+      that.ui.tagInput.select2({
+        tags: _.difference(_.difference(r.tags, that.model.get('tags')), that.model.get('sysTags')),
+        width: '300px'
       });
-    },
 
-    cancelEdit: function () {
-      this.ui.tagsList.removeClass('hidden');
-      this.ui.tagsEdit.addClass('hidden');
-      if (this.ui.tagInput.select2) {
-        this.ui.tagInput.select2('val', this.tagsBuffer);
-        this.ui.tagInput.select2('close');
-      }
-    },
-
-    editDone: function () {
-      var that = this,
-          tags = this.ui.tagInput.val();
-      return jQuery.ajax({
-        type: 'POST',
-        url: baseUrl + '/api/rules/update',
-        data: {
-          key: this.model.get('key'),
-          tags: tags
-        }
-      }).done(function (r) {
-        that.model.set('tags', r.rule.tags);
-        that.cancelEdit();
-      }).always(function () {
-        that.cancelEdit();
-      });
-    },
+      that.ui.tagsEdit.removeClass('hidden');
+      that.ui.tagsList.addClass('hidden');
+      that.tagsBuffer = that.ui.tagInput.select2('val');
+      that.ui.tagInput.select2('open');
+    });
+  },
 
-    serializeData: function () {
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        canWrite: this.options.app.canWrite,
-        subCharacteristic: this.options.app.getSubCharacteristicName(this.model.get('debtSubChar')),
-        allTags: _.union(this.model.get('sysTags'), this.model.get('tags')),
-        permalink: baseUrl + '/coding_rules#rule_key=' + encodeURIComponent(this.model.id)
-      });
+  cancelEdit: function () {
+    this.ui.tagsList.removeClass('hidden');
+    this.ui.tagsEdit.addClass('hidden');
+    if (this.ui.tagInput.select2) {
+      this.ui.tagInput.select2('val', this.tagsBuffer);
+      this.ui.tagInput.select2('close');
     }
-  });
+  },
+
+  editDone: function () {
+    var that = this,
+        tags = this.ui.tagInput.val();
+    return $.ajax({
+      type: 'POST',
+      url: baseUrl + '/api/rules/update',
+      data: {
+        key: this.model.get('key'),
+        tags: tags
+      }
+    }).done(function (r) {
+      that.model.set('tags', r.rule.tags);
+      that.cancelEdit();
+    }).always(function () {
+      that.cancelEdit();
+    });
+  },
 
+  serializeData: function () {
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      canWrite: this.options.app.canWrite,
+      subCharacteristic: this.options.app.getSubCharacteristicName(this.model.get('debtSubChar')),
+      allTags: _.union(this.model.get('sysTags'), this.model.get('tags')),
+      permalink: baseUrl + '/coding_rules#rule_key=' + encodeURIComponent(this.model.id)
+    });
+  }
 });
+
+
index 3dd13c51534655d8f8424d3001c50bcf4d62a0d6..fc34437c23cdc86c9369116b2e83c8af4a559afc 100644 (file)
@@ -1,26 +1,26 @@
-define([
-    '../templates'
-], function () {
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import '../templates';
 
-  return Marionette.ItemView.extend({
-    template: Templates['coding-rules-rule-parameters'],
+export default Marionette.ItemView.extend({
+  template: Templates['coding-rules-rule-parameters'],
 
-    modelEvents: {
-      'change': 'render'
-    },
+  modelEvents: {
+    'change': 'render'
+  },
 
-    onRender: function () {
-      this.$el.toggleClass('hidden', _.isEmpty(this.model.get('params')));
-    },
+  onRender: function () {
+    this.$el.toggleClass('hidden', _.isEmpty(this.model.get('params')));
+  },
 
-    serializeData: function () {
-      var isEditable = this.options.app.canWrite && (this.model.get('isManual') || this.model.get('isCustom'));
-
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        isEditable: isEditable,
-        canWrite: this.options.app.canWrite
-      });
-    }
-  });
+  serializeData: function () {
+    var isEditable = this.options.app.canWrite && (this.model.get('isManual') || this.model.get('isCustom'));
 
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      isEditable: isEditable,
+      canWrite: this.options.app.canWrite
+    });
+  }
 });
+
+
index 7e0255190944ff83d3a625d16cc2d7dd0c340c09..40e09aed4a44c3ed99404ca03d7a8044e7391edf 100644 (file)
-define([
-  './profile-activation-view',
-  '../templates'
-], function (ProfileActivationView) {
+import $ from 'jquery';
+import _ from 'underscore';
+import Backbone from 'backbone';
+import Marionette from 'backbone.marionette';
+import ProfileActivationView from './profile-activation-view';
+import '../templates';
 
-  return Marionette.ItemView.extend({
-    tagName: 'tr',
-    template: Templates['coding-rules-rule-profile'],
+export default Marionette.ItemView.extend({
+  tagName: 'tr',
+  template: Templates['coding-rules-rule-profile'],
 
-    modelEvents: {
-      'change': 'render'
-    },
+  modelEvents: {
+    'change': 'render'
+  },
 
-    ui: {
-      change: '.coding-rules-detail-quality-profile-change',
-      revert: '.coding-rules-detail-quality-profile-revert',
-      deactivate: '.coding-rules-detail-quality-profile-deactivate'
-    },
+  ui: {
+    change: '.coding-rules-detail-quality-profile-change',
+    revert: '.coding-rules-detail-quality-profile-revert',
+    deactivate: '.coding-rules-detail-quality-profile-deactivate'
+  },
 
-    events: {
-      'click @ui.change': 'change',
-      'click @ui.revert': 'revert',
-      'click @ui.deactivate': 'deactivate'
-    },
+  events: {
+    'click @ui.change': 'change',
+    'click @ui.revert': 'revert',
+    'click @ui.deactivate': 'deactivate'
+  },
 
-    onRender: function () {
-      this.$('[data-toggle="tooltip"]').tooltip({
-        container: 'body'
-      });
-    },
+  onRender: function () {
+    this.$('[data-toggle="tooltip"]').tooltip({
+      container: 'body'
+    });
+  },
 
-    change: function () {
-      var that = this,
-          activationView = new ProfileActivationView({
-            model: this.model,
-            collection: this.model.collection,
-            rule: this.options.rule,
-            app: this.options.app
-          });
-      activationView.on('profileActivated', function () {
-        that.options.refreshActives();
-      });
-      activationView.render();
-    },
+  change: function () {
+    var that = this,
+        activationView = new ProfileActivationView({
+          model: this.model,
+          collection: this.model.collection,
+          rule: this.options.rule,
+          app: this.options.app
+        });
+    activationView.on('profileActivated', function () {
+      that.options.refreshActives();
+    });
+    activationView.render();
+  },
 
-    revert: function () {
-      var that = this,
-          ruleKey = this.options.rule.get('key');
-      window.confirmDialog({
-        title: t('coding_rules.revert_to_parent_definition'),
-        html: tp('coding_rules.revert_to_parent_definition.confirm', this.getParent().name),
-        yesHandler: function () {
-          return jQuery.ajax({
-            type: 'POST',
-            url: baseUrl + '/api/qualityprofiles/activate_rule',
-            data: {
-              profile_key: that.model.get('qProfile'),
-              rule_key: ruleKey,
-              reset: true
-            }
-          }).done(function () {
-            that.options.refreshActives();
-          });
-        }
-      });
-    },
-
-    deactivate: function () {
-      var that = this,
-          ruleKey = this.options.rule.get('key');
-      window.confirmDialog({
-        title: t('coding_rules.deactivate'),
-        html: tp('coding_rules.deactivate.confirm'),
-        yesHandler: function () {
-          return jQuery.ajax({
-            type: 'POST',
-            url: baseUrl + '/api/qualityprofiles/deactivate_rule',
-            data: {
-              profile_key: that.model.get('qProfile'),
-              rule_key: ruleKey
-            }
-          }).done(function () {
-            that.options.refreshActives();
-          });
-        }
-      });
-    },
-
-    enableUpdate: function () {
-      return this.ui.update.prop('disabled', false);
-    },
-
-    getParent: function () {
-      if (!(this.model.get('inherit') && this.model.get('inherit') !== 'NONE')) {
-        return null;
+  revert: function () {
+    var that = this,
+        ruleKey = this.options.rule.get('key');
+    window.confirmDialog({
+      title: t('coding_rules.revert_to_parent_definition'),
+      html: tp('coding_rules.revert_to_parent_definition.confirm', this.getParent().name),
+      yesHandler: function () {
+        return $.ajax({
+          type: 'POST',
+          url: baseUrl + '/api/qualityprofiles/activate_rule',
+          data: {
+            profile_key: that.model.get('qProfile'),
+            rule_key: ruleKey,
+            reset: true
+          }
+        }).done(function () {
+          that.options.refreshActives();
+        });
       }
-      var myProfile = _.findWhere(this.options.app.qualityProfiles, {
-            key: this.model.get('qProfile')
-          }),
-          parentKey = myProfile.parentKey,
-          parent = _.extend({}, _.findWhere(this.options.app.qualityProfiles, {
-            key: parentKey
-          })),
-          parentActiveInfo = this.model.collection.findWhere({ qProfile: parentKey }) || new Backbone.Model();
-      _.extend(parent, parentActiveInfo.toJSON());
-      return parent;
-    },
+    });
+  },
 
-    enhanceParameters: function () {
-      var parent = this.getParent(),
-          params = _.sortBy(this.model.get('params'), 'key');
-      if (!parent) {
-        return params;
+  deactivate: function () {
+    var that = this,
+        ruleKey = this.options.rule.get('key');
+    window.confirmDialog({
+      title: t('coding_rules.deactivate'),
+      html: tp('coding_rules.deactivate.confirm'),
+      yesHandler: function () {
+        return $.ajax({
+          type: 'POST',
+          url: baseUrl + '/api/qualityprofiles/deactivate_rule',
+          data: {
+            profile_key: that.model.get('qProfile'),
+            rule_key: ruleKey
+          }
+        }).done(function () {
+          that.options.refreshActives();
+        });
       }
-      return params.map(function (p) {
-        var parentParam = _.findWhere(parent.params, { key: p.key });
-        if (parentParam != null) {
-          return _.extend(p, {
-            original: _.findWhere(parent.params, { key: p.key }).value
-          });
-        } else {
-          return p;
-        }
-      });
-    },
+    });
+  },
 
-    serializeData: function () {
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        canWrite: this.options.app.canWrite,
-        parent: this.getParent(),
-        parameters: this.enhanceParameters(),
-        templateKey: this.options.rule.get('templateKey'),
-        isTemplate: this.options.rule.get('isTemplate')
-      });
+  enableUpdate: function () {
+    return this.ui.update.prop('disabled', false);
+  },
+
+  getParent: function () {
+    if (!(this.model.get('inherit') && this.model.get('inherit') !== 'NONE')) {
+      return null;
     }
-  });
+    var myProfile = _.findWhere(this.options.app.qualityProfiles, {
+          key: this.model.get('qProfile')
+        }),
+        parentKey = myProfile.parentKey,
+        parent = _.extend({}, _.findWhere(this.options.app.qualityProfiles, {
+          key: parentKey
+        })),
+        parentActiveInfo = this.model.collection.findWhere({ qProfile: parentKey }) || new Backbone.Model();
+    _.extend(parent, parentActiveInfo.toJSON());
+    return parent;
+  },
 
+  enhanceParameters: function () {
+    var parent = this.getParent(),
+        params = _.sortBy(this.model.get('params'), 'key');
+    if (!parent) {
+      return params;
+    }
+    return params.map(function (p) {
+      var parentParam = _.findWhere(parent.params, { key: p.key });
+      if (parentParam != null) {
+        return _.extend(p, {
+          original: _.findWhere(parent.params, { key: p.key }).value
+        });
+      } else {
+        return p;
+      }
+    });
+  },
+
+  serializeData: function () {
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      canWrite: this.options.app.canWrite,
+      parent: this.getParent(),
+      parameters: this.enhanceParameters(),
+      templateKey: this.options.rule.get('templateKey'),
+      isTemplate: this.options.rule.get('isTemplate')
+    });
+  }
 });
+
+
index c9abf5425410bb69109dc5cac7fd60c7d8c7bc83..f449d9444735e1236373fe811812645cc94ff8bf 100644 (file)
@@ -1,10 +1,10 @@
-define([
-  './rule-profile-view',
-  './profile-activation-view',
-  '../templates'
-], function (ProfileView, ProfileActivationView) {
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import ProfileView from './rule-profile-view';
+import ProfileActivationView from './profile-activation-view';
+import '../templates';
 
-  return Marionette.CompositeView.extend({
+  export default Marionette.CompositeView.extend({
     template: Templates['coding-rules-rule-profiles'],
     childView: ProfileView,
     childViewContainer: '#coding-rules-detail-quality-profiles',
@@ -77,4 +77,4 @@ define([
     }
   });
 
-});
+
index b4ef460bacfd415f978d070a1c3725bc8afd3f9b..74b1a14dc50346678c89ab5d4686d758e75ce707 100644 (file)
@@ -1,50 +1,48 @@
-define([
-  'components/navigator/workspace-header-view',
-  './bulk-change-popup-view',
-  './templates'
-], function (WorkspaceHeaderView, BulkChangePopup) {
-
-  var $ = jQuery;
-
-  return WorkspaceHeaderView.extend({
-    template: Templates['coding-rules-workspace-header'],
-
-    events: function () {
-      return _.extend(WorkspaceHeaderView.prototype.events.apply(this, arguments), {
-        'click .js-back': 'onBackClick',
-        'click .js-bulk-change': 'onBulkChangeClick',
-        'click .js-reload': 'reload',
-        'click .js-new-search': 'newSearch'
-      });
-    },
-
-    onBackClick: function () {
-      this.options.app.controller.hideDetails();
-    },
-
-    onBulkChangeClick: function (e) {
-      e.stopPropagation();
-      $('body').click();
-      new BulkChangePopup({
-        app: this.options.app,
-        triggerEl: $(e.currentTarget),
-        bottomRight: true
-      }).render();
-    },
-
-    reload: function () {
-      this.options.app.controller.fetchList(true);
-    },
-
-    newSearch: function () {
-      this.options.app.controller.newSearch();
-    },
-
-    serializeData: function () {
-      return _.extend(WorkspaceHeaderView.prototype.serializeData.apply(this, arguments), {
-        canWrite: this.options.app.canWrite
-      });
-    }
-  });
-
+import $ from 'jquery';
+import _ from 'underscore';
+import WorkspaceHeaderView from 'components/navigator/workspace-header-view';
+import BulkChangePopup from './bulk-change-popup-view';
+import './templates';
+
+export default WorkspaceHeaderView.extend({
+  template: Templates['coding-rules-workspace-header'],
+
+  events: function () {
+    return _.extend(WorkspaceHeaderView.prototype.events.apply(this, arguments), {
+      'click .js-back': 'onBackClick',
+      'click .js-bulk-change': 'onBulkChangeClick',
+      'click .js-reload': 'reload',
+      'click .js-new-search': 'newSearch'
+    });
+  },
+
+  onBackClick: function () {
+    this.options.app.controller.hideDetails();
+  },
+
+  onBulkChangeClick: function (e) {
+    e.stopPropagation();
+    $('body').click();
+    new BulkChangePopup({
+      app: this.options.app,
+      triggerEl: $(e.currentTarget),
+      bottomRight: true
+    }).render();
+  },
+
+  reload: function () {
+    this.options.app.controller.fetchList(true);
+  },
+
+  newSearch: function () {
+    this.options.app.controller.newSearch();
+  },
+
+  serializeData: function () {
+    return _.extend(WorkspaceHeaderView.prototype.serializeData.apply(this, arguments), {
+      canWrite: this.options.app.canWrite
+    });
+  }
 });
+
+
index da182d390956e707abdf4f517085169e00be5206..6563efc2e3adc4005723b1bb9b3b6728526baa4a 100644 (file)
@@ -1,11 +1,11 @@
-define(function () {
+import Marionette from 'backbone.marionette';
 
-  return Marionette.ItemView.extend({
-    className: 'search-navigator-no-results',
-
-    template: function () {
-      return t('coding_rules.no_results');
-    }
-  });
+export default Marionette.ItemView.extend({
+  className: 'search-navigator-no-results',
 
+  template: function () {
+    return t('coding_rules.no_results');
+  }
 });
+
+
index 01b4efb553e0a83f4eeaa5018caa6311af145a1b..4fda1255c8c442d85c4b1d56e190057f060cd3c6 100644 (file)
@@ -1,89 +1,90 @@
-define([
-  'components/navigator/workspace-list-item-view',
-  './rule/profile-activation-view',
-  './rule/rule-filter-mixin',
-  './templates'
-], function (WorkspaceListItemView, ProfileActivationView, RuleFilterMixin) {
+import $ from 'jquery';
+import _ from 'underscore';
+import Backbone from 'backbone';
+import WorkspaceListItemView from 'components/navigator/workspace-list-item-view';
+import ProfileActivationView from './rule/profile-activation-view';
+import RuleFilterMixin from './rule/rule-filter-mixin';
+import './templates';
 
-  return WorkspaceListItemView.extend(RuleFilterMixin).extend({
-    className: 'coding-rule',
-    template: Templates['coding-rules-workspace-list-item'],
+export default WorkspaceListItemView.extend(RuleFilterMixin).extend({
+  className: 'coding-rule',
+  template: Templates['coding-rules-workspace-list-item'],
 
-    modelEvents: {
-      'change': 'render'
-    },
+  modelEvents: {
+    'change': 'render'
+  },
 
-    events: {
-      'click': 'selectCurrent',
-      'dblclick': 'openRule',
-      'click .js-rule': 'openRule',
-      'click .js-rule-filter': 'onRuleFilterClick',
-      'click .coding-rules-detail-quality-profile-activate': 'activate',
-      'click .coding-rules-detail-quality-profile-change': 'change',
-      'click .coding-rules-detail-quality-profile-revert': 'revert',
-      'click .coding-rules-detail-quality-profile-deactivate': 'deactivate'
-    },
+  events: {
+    'click': 'selectCurrent',
+    'dblclick': 'openRule',
+    'click .js-rule': 'openRule',
+    'click .js-rule-filter': 'onRuleFilterClick',
+    'click .coding-rules-detail-quality-profile-activate': 'activate',
+    'click .coding-rules-detail-quality-profile-change': 'change',
+    'click .coding-rules-detail-quality-profile-revert': 'revert',
+    'click .coding-rules-detail-quality-profile-deactivate': 'deactivate'
+  },
 
-    selectCurrent: function () {
-      this.options.app.state.set({ selectedIndex: this.model.get('index') });
-    },
+  selectCurrent: function () {
+    this.options.app.state.set({ selectedIndex: this.model.get('index') });
+  },
 
-    openRule: function () {
-      this.options.app.controller.showDetails(this.model);
-    },
+  openRule: function () {
+    this.options.app.controller.showDetails(this.model);
+  },
 
-    activate: function () {
-      var that = this,
-          selectedProfile = this.options.app.state.get('query').qprofile,
-          othersQualityProfiles = _.reject(this.options.app.qualityProfiles, function (profile) {
-            return profile.key === selectedProfile;
-          }),
-          activationView = new ProfileActivationView({
-            rule: this.model,
-            collection: new Backbone.Collection(othersQualityProfiles),
-            app: this.options.app
-          });
-      activationView.on('profileActivated', function (severity, params, profile) {
-        var activation = {
-          severity: severity,
-          inherit: 'NONE',
-          params: params,
-          qProfile: profile
-        };
-        that.model.set({ activation: activation });
-      });
-      activationView.render();
-    },
+  activate: function () {
+    var that = this,
+        selectedProfile = this.options.app.state.get('query').qprofile,
+        othersQualityProfiles = _.reject(this.options.app.qualityProfiles, function (profile) {
+          return profile.key === selectedProfile;
+        }),
+        activationView = new ProfileActivationView({
+          rule: this.model,
+          collection: new Backbone.Collection(othersQualityProfiles),
+          app: this.options.app
+        });
+    activationView.on('profileActivated', function (severity, params, profile) {
+      var activation = {
+        severity: severity,
+        inherit: 'NONE',
+        params: params,
+        qProfile: profile
+      };
+      that.model.set({ activation: activation });
+    });
+    activationView.render();
+  },
 
-    deactivate: function () {
-      var that = this,
-          ruleKey = this.model.get('key'),
-          activation = this.model.get('activation');
-      window.confirmDialog({
-        title: t('coding_rules.deactivate'),
-        html: tp('coding_rules.deactivate.confirm'),
-        yesHandler: function () {
-          return jQuery.ajax({
-            type: 'POST',
-            url: baseUrl + '/api/qualityprofiles/deactivate_rule',
-            data: {
-              profile_key: activation.qProfile,
-              rule_key: ruleKey
-            }
-          }).done(function () {
-            that.model.unset('activation');
-          });
-        }
-      });
-    },
-
-    serializeData: function () {
-      return _.extend(WorkspaceListItemView.prototype.serializeData.apply(this, arguments), {
-        tags: _.union(this.model.get('sysTags'), this.model.get('tags')),
-        canWrite: this.options.app.canWrite,
-        selectedProfile: this.options.app.state.get('query').qprofile
-      });
-    }
-  });
+  deactivate: function () {
+    var that = this,
+        ruleKey = this.model.get('key'),
+        activation = this.model.get('activation');
+    window.confirmDialog({
+      title: t('coding_rules.deactivate'),
+      html: tp('coding_rules.deactivate.confirm'),
+      yesHandler: function () {
+        return $.ajax({
+          type: 'POST',
+          url: baseUrl + '/api/qualityprofiles/deactivate_rule',
+          data: {
+            profile_key: activation.qProfile,
+            rule_key: ruleKey
+          }
+        }).done(function () {
+          that.model.unset('activation');
+        });
+      }
+    });
+  },
 
+  serializeData: function () {
+    return _.extend(WorkspaceListItemView.prototype.serializeData.apply(this, arguments), {
+      tags: _.union(this.model.get('sysTags'), this.model.get('tags')),
+      canWrite: this.options.app.canWrite,
+      selectedProfile: this.options.app.state.get('query').qprofile
+    });
+  }
 });
+
+
index d8ed84d5c816aca00539a26d0f5a63fe7511b996..252d5a093cebc1cc0307d409b45da49affef35f3 100644 (file)
@@ -1,32 +1,30 @@
-define([
-  'components/navigator/workspace-list-view',
-  './workspace-list-item-view',
-  './workspace-list-empty-view',
-  './templates'
-], function (WorkspaceListView, WorkspaceListItemView, WorkspaceListEmptyView) {
+import WorkspaceListView from 'components/navigator/workspace-list-view';
+import WorkspaceListItemView from './workspace-list-item-view';
+import WorkspaceListEmptyView from './workspace-list-empty-view';
+import './templates';
 
-  return WorkspaceListView.extend({
-    template: Templates['coding-rules-workspace-list'],
-    childView: WorkspaceListItemView,
-    childViewContainer: '.js-list',
-    emptyView: WorkspaceListEmptyView,
-
-    bindShortcuts: function () {
-      WorkspaceListView.prototype.bindShortcuts.apply(this, arguments);
-      var that = this;
-      key('right', 'list', function () {
-        that.options.app.controller.showDetailsForSelected();
-        return false;
-      });
-      key('a', function () {
-        that.options.app.controller.activateCurrent();
-        return false;
-      });
-      key('d', function () {
-        that.options.app.controller.deactivateCurrent();
-        return false;
-      });
-    }
-  });
+export default WorkspaceListView.extend({
+  template: Templates['coding-rules-workspace-list'],
+  childView: WorkspaceListItemView,
+  childViewContainer: '.js-list',
+  emptyView: WorkspaceListEmptyView,
 
+  bindShortcuts: function () {
+    WorkspaceListView.prototype.bindShortcuts.apply(this, arguments);
+    var that = this;
+    key('right', 'list', function () {
+      that.options.app.controller.showDetailsForSelected();
+      return false;
+    });
+    key('a', function () {
+      that.options.app.controller.activateCurrent();
+      return false;
+    });
+    key('d', function () {
+      that.options.app.controller.deactivateCurrent();
+      return false;
+    });
+  }
 });
+
+
index 43e64d86b5d2a404d1ca6d17dc5a847f92d2e606..ed7d8ede521675a2ef442ec897a9a54e37fe82d4 100644 (file)
@@ -1,57 +1,57 @@
-define([
-  './router',
-  './layout',
-  './reports',
-  './header-view',
-  './search-view',
-  './list-view',
-  './list-footer-view'
-], function (Router, Layout, Reports, HeaderView, SearchView, ListView, ListFooterView) {
-
-  var App = new Marionette.Application(),
-      init = function (options) {
-        // Collection
-        this.reports = new Reports();
-
-        // Router
-        this.router = new Router({ reports: this.reports });
-
-        // Layout
-        this.layout = new Layout({ el: options.el });
-        this.layout.render();
-
-        // Header View
-        this.headerView = new HeaderView({ collection: this.reports });
-        this.layout.headerRegion.show(this.headerView);
-
-        // Search View
-        this.searchView = new SearchView({
-          collection: this.reports,
-          router: this.router
-        });
-        this.layout.searchRegion.show(this.searchView);
-
-        // List View
-        this.listView = new ListView({ collection: this.reports });
-        this.layout.listRegion.show(this.listView);
-
-        // List Footer View
-        this.listFooterView = new ListFooterView({ collection: this.reports });
-        this.layout.listFooterRegion.show(this.listFooterView);
-
-        // Go!
-        Backbone.history.start({
-          pushState: true,
-          root: options.urlRoot
-        });
-      };
-
-  App.on('start', function (options) {
-    window.requestMessages().done(function () {
-      init.call(App, options);
-    });
+import Backbone from 'backbone';
+import Marionette from 'backbone.marionette';
+import Router from './router';
+import Layout from './layout';
+import Reports from './reports';
+import HeaderView from './header-view';
+import SearchView from './search-view';
+import ListView from './list-view';
+import ListFooterView from './list-footer-view';
+
+var App = new Marionette.Application(),
+    init = function (options) {
+      // Collection
+      this.reports = new Reports();
+
+      // Router
+      this.router = new Router({ reports: this.reports });
+
+      // Layout
+      this.layout = new Layout({ el: options.el });
+      this.layout.render();
+
+      // Header View
+      this.headerView = new HeaderView({ collection: this.reports });
+      this.layout.headerRegion.show(this.headerView);
+
+      // Search View
+      this.searchView = new SearchView({
+        collection: this.reports,
+        router: this.router
+      });
+      this.layout.searchRegion.show(this.searchView);
+
+      // List View
+      this.listView = new ListView({ collection: this.reports });
+      this.layout.listRegion.show(this.listView);
+
+      // List Footer View
+      this.listFooterView = new ListFooterView({ collection: this.reports });
+      this.layout.listFooterRegion.show(this.listFooterView);
+
+      // Go!
+      Backbone.history.start({
+        pushState: true,
+        root: options.urlRoot
+      });
+    };
+
+App.on('start', function (options) {
+  window.requestMessages().done(function () {
+    init.call(App, options);
   });
+});
+
+export default App;
 
-  return App;
 
-});
index 8e010c0eded1ae86c451186a7dfc72f35002b5fc..570ea82cde2c588f014d0635b28eaeb13415499f 100644 (file)
@@ -1,9 +1,8 @@
-define([
-  './templates'
-], function () {
-
-  return Marionette.ItemView.extend({
-    template: Templates['computation-header']
-  });
+import Marionette from 'backbone.marionette';
+import './templates';
 
+export default Marionette.ItemView.extend({
+  template: Templates['computation-header']
 });
+
+
index 2e7edcd22bf9435c238e0e12d0bae05da59e7e99..7ac5b7007bd6456c5d020d2f95a4401e337807f8 100644 (file)
@@ -1,16 +1,15 @@
-define([
-  './templates'
-], function () {
+import Marionette from 'backbone.marionette';
+import './templates';
 
-  return Marionette.LayoutView.extend({
-    template: Templates['computation-layout'],
-
-    regions: {
-      headerRegion: '#computation-header',
-      searchRegion: '#computation-search',
-      listRegion: '#computation-list',
-      listFooterRegion: '#computation-list-footer'
-    }
-  });
+export default Marionette.LayoutView.extend({
+  template: Templates['computation-layout'],
 
+  regions: {
+    headerRegion: '#computation-header',
+    searchRegion: '#computation-search',
+    listRegion: '#computation-list',
+    listFooterRegion: '#computation-list-footer'
+  }
 });
+
+
index 5034f25a3e89c61296613a62d5cd1d99995fb6b4..89ee31209349e065bd395d498b55d8d1b28d6011 100644 (file)
@@ -1,34 +1,34 @@
-define([
-  './templates'
-], function () {
-
-  return Marionette.ItemView.extend({
-    template: Templates['computation-list-footer'],
-
-    collectionEvents: {
-      'all': 'render'
-    },
-
-    events: {
-      'click #computation-fetch-more': 'onMoreClick'
-    },
-
-    onMoreClick: function (e) {
-      e.preventDefault();
-      this.fetchMore();
-    },
-
-    fetchMore: function () {
-      this.collection.fetchMore();
-    },
-
-    serializeData: function () {
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        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['computation-list-footer'],
+
+  collectionEvents: {
+    'all': 'render'
+  },
+
+  events: {
+    'click #computation-fetch-more': 'onMoreClick'
+  },
+
+  onMoreClick: function (e) {
+    e.preventDefault();
+    this.fetchMore();
+  },
+
+  fetchMore: function () {
+    this.collection.fetchMore();
+  },
+
+  serializeData: function () {
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      total: this.collection.total,
+      count: this.collection.length,
+      more: this.collection.hasMore()
+    });
+  }
 });
+
+
index afcf2f15d3fcebc49c6bd9d931acdcc139cad31d..e891effd244842e26ccf1db7a9540530f6d80e5c 100644 (file)
@@ -1,27 +1,27 @@
-define([
-  './templates'
-], function () {
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import './templates';
 
-  return Marionette.ItemView.extend({
-    tagName: 'li',
-    className: 'panel',
-    template: Templates['computation-list-item'],
+export default Marionette.ItemView.extend({
+  tagName: 'li',
+  className: 'panel',
+  template: Templates['computation-list-item'],
 
-    onRender: function () {
-      this.$el.attr('data-id', this.model.id);
-      this.$el.toggleClass('panel-danger', this.model.isDanger());
-      this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
-    },
+  onRender: function () {
+    this.$el.attr('data-id', this.model.id);
+    this.$el.toggleClass('panel-danger', this.model.isDanger());
+    this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
+  },
 
-    onDestroy: function () {
-      this.$('[data-toggle="tooltip"]').tooltip('destroy');
-    },
-
-    serializeData: function () {
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        duration: this.model.getDuration()
-      });
-    }
-  });
+  onDestroy: function () {
+    this.$('[data-toggle="tooltip"]').tooltip('destroy');
+  },
 
+  serializeData: function () {
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      duration: this.model.getDuration()
+    });
+  }
 });
+
+
index 24878864d309901cfd4c6b951fa0ab09114d12d2..695bf2ac034422cd4a228e67bec5d08fe0357f6a 100644 (file)
@@ -1,11 +1,10 @@
-define([
-  './list-item-view',
-  './templates'
-], function (ListItemView) {
-
-  return Marionette.CollectionView.extend({
-    tagName: 'ul',
-    childView: ListItemView
-  });
+import Marionette from 'backbone.marionette';
+import ListItemView from './list-item-view';
+import './templates';
 
+export default Marionette.CollectionView.extend({
+  tagName: 'ul',
+  childView: ListItemView
 });
+
+
index 2eac3f23e8469e96d603c339c6c75220b4853dfd..9c1ca5258d071ec911a6f17a8b81bce869bfbb47 100644 (file)
@@ -1,27 +1,27 @@
-define(function () {
+import Backbone from 'backbone';
 
-  return Backbone.Model.extend({
-    idAttribute: 'key',
+export default Backbone.Model.extend({
+  idAttribute: 'key',
 
-    getDuration: function () {
-      var duration = null;
-      if (this.has('startedAt')) {
-        var startedAtMoment = moment(this.get('startedAt')),
-            finishedAtMoment = moment(this.get('finishedAt') || new Date()),
-            diff = finishedAtMoment.diff(startedAtMoment);
-        duration = {
-          seconds: Math.floor(diff / 1000) % 60,
-          minutes: Math.floor(diff / (1000 * 60)) % 60,
-          hours: Math.floor(diff / (1000 * 60 * 60)) % 24
-        };
-      }
-      return duration;
-    },
-
-    isDanger: function () {
-      var dangerStatuses = ['CANCELLED', 'FAILED'];
-      return dangerStatuses.indexOf(this.get('status')) !== -1;
+  getDuration: function () {
+    var duration = null;
+    if (this.has('startedAt')) {
+      var startedAtMoment = moment(this.get('startedAt')),
+          finishedAtMoment = moment(this.get('finishedAt') || new Date()),
+          diff = finishedAtMoment.diff(startedAtMoment);
+      duration = {
+        seconds: Math.floor(diff / 1000) % 60,
+        minutes: Math.floor(diff / (1000 * 60)) % 60,
+        hours: Math.floor(diff / (1000 * 60 * 60)) % 24
+      };
     }
-  });
+    return duration;
+  },
 
+  isDanger: function () {
+    var dangerStatuses = ['CANCELLED', 'FAILED'];
+    return dangerStatuses.indexOf(this.get('status')) !== -1;
+  }
 });
+
+
index 68b40269018a403f64a1040822bcab7c065fded4..b355aedf50ccaf79fe81a23184464aa4df433459 100644 (file)
@@ -1,34 +1,34 @@
-define([
-  './report'
-], function (Report) {
-
-  return Backbone.Collection.extend({
-    model: Report,
-    url: '',
-
-    parse: function (r) {
-      this.total = r.total || r.reports.length;
-      this.p = r.p || 1;
-      this.ps = r.ps;
-      return r.reports;
-    },
-
-    fetch: function (options) {
-      var opts = _.defaults(options || {}, { q: this.q }, { q: 'history', data: { ps: 250 } });
-      opts.url = baseUrl + '/api/computation/' + opts.q;
-      this.q = opts.q;
-      return Backbone.Collection.prototype.fetch.call(this, opts);
-    },
-
-    fetchMore: function () {
-      var p = this.p + 1;
-      return this.fetch({ add: true, remove: false, data: { p: p, ps: this.ps } });
-    },
-
-    hasMore: function () {
-      return this.total > this.p * this.ps;
-    }
-
-  });
+import _ from 'underscore';
+import Backbone from 'backbone';
+import Report from './report';
+
+export default Backbone.Collection.extend({
+  model: Report,
+  url: '',
+
+  parse: function (r) {
+    this.total = r.total || r.reports.length;
+    this.p = r.p || 1;
+    this.ps = r.ps;
+    return r.reports;
+  },
+
+  fetch: function (options) {
+    var opts = _.defaults(options || {}, { q: this.q }, { q: 'history', data: { ps: 250 } });
+    opts.url = baseUrl + '/api/computation/' + opts.q;
+    this.q = opts.q;
+    return Backbone.Collection.prototype.fetch.call(this, opts);
+  },
+
+  fetchMore: function () {
+    var p = this.p + 1;
+    return this.fetch({ add: true, remove: false, data: { p: p, ps: this.ps } });
+  },
+
+  hasMore: function () {
+    return this.total > this.p * this.ps;
+  }
 
 });
+
+
index 6d874801cd3410230005554b9588dcb5fa922ae0..8ac31c7be904b90df55bce89fb4bfa52bdc0ee38 100644 (file)
@@ -1,29 +1,29 @@
-define(function () {
+import Backbone from 'backbone';
 
-  return Backbone.Router.extend({
-    routes: {
-      '': 'index',
-      'index': 'index',
-      'current': 'current',
-      'past': 'past'
-    },
+export default Backbone.Router.extend({
+  routes: {
+    '': 'index',
+    'index': 'index',
+    'current': 'current',
+    'past': 'past'
+  },
 
-    initialize: function (options) {
-      this.options = options;
-    },
+  initialize: function (options) {
+    this.options = options;
+  },
 
-    index: function () {
-      this.navigate('current');
-      this.current();
-    },
+  index: function () {
+    this.navigate('current');
+    this.current();
+  },
 
-    current: function () {
-      this.options.reports.fetch({ q: 'queue' });
-    },
-
-    past: function () {
-      this.options.reports.fetch({ q: 'history' });
-    }
-  });
+  current: function () {
+    this.options.reports.fetch({ q: 'queue' });
+  },
 
+  past: function () {
+    this.options.reports.fetch({ q: 'history' });
+  }
 });
+
+
index 75ab65c4dad114fc548b570387f2d891ffa46585..1e896df0c16af225a4fbb13c975054ed9ca84271 100644 (file)
@@ -1,34 +1,34 @@
-define([
-  './templates'
-], function () {
-
-  return Marionette.ItemView.extend({
-    template: Templates['computation-search'],
-
-    collectionEvents: {
-      'all': 'render'
-    },
-
-    events: {
-      'click .js-queue': 'queue',
-      'click .js-history': 'history'
-    },
-
-    queue: function (e) {
-      e.preventDefault();
-      this.options.router.navigate('current', { trigger: true });
-    },
-
-    history: function (e) {
-      e.preventDefault();
-      this.options.router.navigate('past', { trigger: true });
-    },
-
-    serializeData: function () {
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        tab: this.collection.q
-      });
-    }
-  });
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import './templates';
 
+export default Marionette.ItemView.extend({
+  template: Templates['computation-search'],
+
+  collectionEvents: {
+    'all': 'render'
+  },
+
+  events: {
+    'click .js-queue': 'queue',
+    'click .js-history': 'history'
+  },
+
+  queue: function (e) {
+    e.preventDefault();
+    this.options.router.navigate('current', { trigger: true });
+  },
+
+  history: function (e) {
+    e.preventDefault();
+    this.options.router.navigate('past', { trigger: true });
+  },
+
+  serializeData: function () {
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      tab: this.collection.q
+    });
+  }
 });
+
+
diff --git a/server/sonar-web/src/main/js/apps/custom-measures/app.js b/server/sonar-web/src/main/js/apps/custom-measures/app.js
new file mode 100644 (file)
index 0000000..5d6c1c2
--- /dev/null
@@ -0,0 +1,51 @@
+import Marionette from 'backbone.marionette';
+import Layout from './layout';
+import CustomMeasures from './custom-measures';
+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.customMeasures = new CustomMeasures({
+        projectId: options.projectId
+      });
+
+      // Header View
+      this.headerView = new HeaderView({
+        collection: this.customMeasures,
+        projectId: options.projectId
+      });
+      this.layout.headerRegion.show(this.headerView);
+
+      // List View
+      this.listView = new ListView({
+        collection: this.customMeasures
+      });
+      this.layout.listRegion.show(this.listView);
+
+      // List Footer View
+      this.listFooterView = new ListFooterView({
+        collection: this.customMeasures
+      });
+      this.layout.listFooterRegion.show(this.listFooterView);
+
+      // Go!
+      this.customMeasures.fetch();
+    };
+
+App.on('start', function (options) {
+  window.requestMessages().done(function () {
+    init.call(App, options);
+  });
+});
+
+export default App;
+
diff --git a/server/sonar-web/src/main/js/apps/custom-measures/app.jsx b/server/sonar-web/src/main/js/apps/custom-measures/app.jsx
deleted file mode 100644 (file)
index 1a0d965..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-import Layout from './layout';
-import CustomMeasures from './custom-measures';
-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.customMeasures = new CustomMeasures({
-        projectId: options.projectId
-      });
-
-      // Header View
-      this.headerView = new HeaderView({
-        collection: this.customMeasures,
-        projectId: options.projectId
-      });
-      this.layout.headerRegion.show(this.headerView);
-
-      // List View
-      this.listView = new ListView({
-        collection: this.customMeasures
-      });
-      this.layout.listRegion.show(this.listView);
-
-      // List Footer View
-      this.listFooterView = new ListFooterView({
-        collection: this.customMeasures
-      });
-      this.layout.listFooterRegion.show(this.listFooterView);
-
-      // Go!
-      this.customMeasures.fetch();
-    };
-
-App.on('start', function (options) {
-  window.requestMessages().done(function () {
-    init.call(App, options);
-  });
-});
-
-export default App;
-
index d7461fe715882fbface989edbacd864ba4c3ed79..6e113b4911f535d61f120caf1ebcbcce3a48ed3c 100644 (file)
@@ -1,32 +1,30 @@
-define([
-  './custom-measure',
-  './form-view'
-], function (CustomMeasure, FormView) {
+import CustomMeasure from './custom-measure';
+import FormView from './form-view';
 
-  return FormView.extend({
-
-    sendRequest: function () {
-      var that = this,
-          customMeasure = new CustomMeasure({
-            metricId: this.$('#create-custom-measure-metric').val(),
-            value: this.$('#create-custom-measure-value').val(),
-            description: this.$('#create-custom-measure-description').val(),
-            projectId: this.options.projectId
-          });
-      this.disableForm();
-      return customMeasure.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,
+        customMeasure = new CustomMeasure({
+          metricId: this.$('#create-custom-measure-metric').val(),
+          value: this.$('#create-custom-measure-value').val(),
+          description: this.$('#create-custom-measure-description').val(),
+          projectId: this.options.projectId
+        });
+    this.disableForm();
+    return customMeasure.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);
+    });
+  }
 });
+
+
index fce8bf4fbdf2f9c1635a39ca34e34ae1257fb8b2..17565de6cfe39f6ca3f57abf80f2a31f39fbbcc8 100644 (file)
@@ -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/custom_measures';
-    },
+  urlRoot: function () {
+    return baseUrl + '/api/custom_measures';
+  },
 
-    sync: function (method, model, options) {
-      var opts = options || {};
-      if (method === 'create') {
-        _.defaults(opts, {
-          url: this.urlRoot() + '/create',
-          type: 'POST',
-          data: _.pick(model.toJSON(), 'metricId', 'value', 'description', 'projectId')
-        });
-      }
-      if (method === 'update') {
-        _.defaults(opts, {
-          url: this.urlRoot() + '/update',
-          type: 'POST',
-          data: _.pick(model.toJSON(), 'id', 'value', 'description')
-        });
-      }
-      if (method === 'delete') {
-        _.defaults(opts, {
-          url: this.urlRoot() + '/delete',
-          type: 'POST',
-          data: { id: 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(), 'metricId', 'value', 'description', 'projectId')
+      });
     }
-  });
-
+    if (method === 'update') {
+      _.defaults(opts, {
+        url: this.urlRoot() + '/update',
+        type: 'POST',
+        data: _.pick(model.toJSON(), 'id', 'value', 'description')
+      });
+    }
+    if (method === 'delete') {
+      _.defaults(opts, {
+        url: this.urlRoot() + '/delete',
+        type: 'POST',
+        data: { id: this.id }
+      });
+    }
+    return Backbone.ajax(opts);
+  }
 });
+
+
index 2febc1ea652a4cb7ae5f95f524b2be34d2a737fe..14d51c6cf332852abdb87c63fb470a314f18c4f3 100644 (file)
@@ -1,52 +1,52 @@
-define([
-  './custom-measure'
-], function (CustomMeasure) {
-
-  return Backbone.Collection.extend({
-    model: CustomMeasure,
-
-    initialize: function (options) {
-      this.projectId = options.projectId;
-    },
-
-    url: function () {
-      return baseUrl + '/api/custom_measures/search';
-    },
-
-    parse: function (r) {
-      this.total = r.total;
-      this.p = r.p;
-      this.ps = r.ps;
-      return r.customMeasures;
-    },
-
-    fetch: function (options) {
-      var opts = _.defaults(options || {}, { data: {} });
-      this.q = opts.data.q;
-      opts.data.projectId = this.projectId;
-      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;
-    },
-
-    getTakenMetrics: function () {
-      var metrics = this.map(function (model) {
-        return model.get('metric').id;
-      });
-      return _.uniq(metrics);
-    }
-
-  });
+import _ from 'underscore';
+import Backbone from 'backbone';
+import CustomMeasure from './custom-measure';
+
+export default Backbone.Collection.extend({
+  model: CustomMeasure,
+
+  initialize: function (options) {
+    this.projectId = options.projectId;
+  },
+
+  url: function () {
+    return baseUrl + '/api/custom_measures/search';
+  },
+
+  parse: function (r) {
+    this.total = r.total;
+    this.p = r.p;
+    this.ps = r.ps;
+    return r.customMeasures;
+  },
+
+  fetch: function (options) {
+    var opts = _.defaults(options || {}, { data: {} });
+    this.q = opts.data.q;
+    opts.data.projectId = this.projectId;
+    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;
+  },
+
+  getTakenMetrics: function () {
+    var metrics = this.map(function (model) {
+      return model.get('metric').id;
+    });
+    return _.uniq(metrics);
+  }
 
 });
+
+
index 1838b83e044cccfcb42535c6e41b8d8705866ebc..6798c1259a3adf502bac8ced04b9a2ad41e87119 100644 (file)
@@ -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['custom-measures-delete'],
+export default ModalForm.extend({
+  template: Templates['custom-measures-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);
+    });
+  }
 });
+
+
index 30ed30082b94d2eb51c47d21b4d952acb6a20a94..d86e0176b30815fb10d87682cfdbec1795280b26 100644 (file)
@@ -1,52 +1,51 @@
-define([
-  'components/common/modal-form',
-  'apps/metrics/metrics',
-  './templates'
-], function (ModalForm, Metrics) {
-
-  return ModalForm.extend({
-    template: Templates['custom-measures-form'],
-
-    initialize: function () {
-      this.metrics = new Metrics();
-      this.listenTo(this.metrics, 'reset', this.render);
-      this.metrics.fetch({ reset: true });
-    },
-
-    onRender: function () {
-      this._super();
-      this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
-      this.$('#create-custom-measure-metric').select2({
-        width: '250px',
-        minimumResultsForSearch: 20
-      });
-    },
-
-    onDestroy: function () {
-      this._super();
-      this.$('[data-toggle="tooltip"]').tooltip('destroy');
-    },
-
-    onFormSubmit: function (e) {
-      this._super(e);
-      this.sendRequest();
-    },
-
-    getAvailableMetrics: function () {
-      var takenMetrics = this.collection.getTakenMetrics();
-      return this.metrics.toJSON().filter(function (metric) {
-        return takenMetrics.indexOf(metric.id) === -1;
-      });
-    },
-
-    serializeData: function () {
-      var metrics = this.getAvailableMetrics(),
-          isNew = !this.model;
-      return _.extend(this._super(), {
-        metrics: metrics,
-        canCreateMetric: !isNew || (isNew && metrics.length > 0)
-      });
-    }
-  });
-
+import _ from 'underscore';
+import ModalForm from 'components/common/modal-form';
+import Metrics from 'apps/metrics/metrics';
+import './templates';
+
+export default ModalForm.extend({
+  template: Templates['custom-measures-form'],
+
+  initialize: function () {
+    this.metrics = new Metrics();
+    this.listenTo(this.metrics, 'reset', this.render);
+    this.metrics.fetch({ reset: true });
+  },
+
+  onRender: function () {
+    this._super();
+    this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
+    this.$('#create-custom-measure-metric').select2({
+      width: '250px',
+      minimumResultsForSearch: 20
+    });
+  },
+
+  onDestroy: function () {
+    this._super();
+    this.$('[data-toggle="tooltip"]').tooltip('destroy');
+  },
+
+  onFormSubmit: function (e) {
+    this._super(e);
+    this.sendRequest();
+  },
+
+  getAvailableMetrics: function () {
+    var takenMetrics = this.collection.getTakenMetrics();
+    return this.metrics.toJSON().filter(function (metric) {
+      return takenMetrics.indexOf(metric.id) === -1;
+    });
+  },
+
+  serializeData: function () {
+    var metrics = this.getAvailableMetrics(),
+        isNew = !this.model;
+    return _.extend(this._super(), {
+      metrics: metrics,
+      canCreateMetric: !isNew || (isNew && metrics.length > 0)
+    });
+  }
 });
+
+
index 8b22efcec5a04b2e868b10eb0041844ab3e56251..02ee2a795c31cbe7bbd61430e75b11046e4b5601 100644 (file)
@@ -1,26 +1,25 @@
-define([
-  './create-view',
-  './templates'
-], function (CreateView) {
+import Marionette from 'backbone.marionette';
+import CreateView from './create-view';
+import './templates';
 
-  return Marionette.ItemView.extend({
-    template: Templates['custom-measures-header'],
+export default Marionette.ItemView.extend({
+  template: Templates['custom-measures-header'],
 
-    events: {
-      'click #custom-measures-create': 'onCreateClick'
-    },
+  events: {
+    'click #custom-measures-create': 'onCreateClick'
+  },
 
-    onCreateClick: function (e) {
-      e.preventDefault();
-      this.createCustomMeasure();
-    },
-
-    createCustomMeasure: function () {
-      new CreateView({
-        collection: this.collection,
-        projectId: this.options.projectId
-      }).render();
-    }
-  });
+  onCreateClick: function (e) {
+    e.preventDefault();
+    this.createCustomMeasure();
+  },
 
+  createCustomMeasure: function () {
+    new CreateView({
+      collection: this.collection,
+      projectId: this.options.projectId
+    }).render();
+  }
 });
+
+
index b4aa4ece791816772a141fb0c3ebe8823373f781..92ac6de28b1a008c88ba6e055ca464b8bb1f40a6 100644 (file)
@@ -1,15 +1,14 @@
-define([
-  './templates'
-], function () {
+import Marionette from 'backbone.marionette';
+import './templates';
 
-  return Marionette.LayoutView.extend({
-    template: Templates['custom-measures-layout'],
-
-    regions: {
-      headerRegion: '#custom-measures-header',
-      listRegion: '#custom-measures-list',
-      listFooterRegion: '#custom-measures-list-footer'
-    }
-  });
+export default Marionette.LayoutView.extend({
+  template: Templates['custom-measures-layout'],
 
+  regions: {
+    headerRegion: '#custom-measures-header',
+    listRegion: '#custom-measures-list',
+    listFooterRegion: '#custom-measures-list-footer'
+  }
 });
+
+
index d66c27ad3357e889b3e55decd422642f4bf334c1..e917ddb294abd16651422c7ff75a0ca16760cb19 100644 (file)
@@ -1,34 +1,34 @@
-define([
-  './templates'
-], function () {
-
-  return Marionette.ItemView.extend({
-    template: Templates['custom-measures-list-footer'],
-
-    collectionEvents: {
-      'all': 'render'
-    },
-
-    events: {
-      'click #custom-measures-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['custom-measures-list-footer'],
+
+  collectionEvents: {
+    'all': 'render'
+  },
+
+  events: {
+    'click #custom-measures-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()
+    });
+  }
 });
+
+
index 32ba7e691d886d61f4feb64beaf61d4f53fcfb08..7b7cb5aa6e14894883684337e40e60d6e27ba629 100644 (file)
@@ -1,47 +1,46 @@
-define([
-  './update-view',
-  './delete-view',
-  './templates'
-], function (UpdateView, DeleteView) {
-
-  return Marionette.ItemView.extend({
-    tagName: 'tr',
-    template: Templates['custom-measures-list-item'],
-
-    events: {
-      'click .js-custom-measure-update': 'onUpdateClick',
-      'click .js-custom-measure-delete': 'onDeleteClick'
-    },
-
-    onRender: function () {
-      this.$el.attr('data-id', this.model.id);
-      this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
-    },
-
-    onDestroy: function () {
-      this.$('[data-toggle="tooltip"]').tooltip('destroy');
-    },
-
-    onUpdateClick: function (e) {
-      e.preventDefault();
-      this.updateCustomMeasure();
-    },
-
-    onDeleteClick: function (e) {
-      e.preventDefault();
-      this.deleteCustomMeasure();
-    },
-
-    updateCustomMeasure: function () {
-      new UpdateView({
-        model: this.model,
-        collection: this.model.collection
-      }).render();
-    },
-
-    deleteCustomMeasure: 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: 'tr',
+  template: Templates['custom-measures-list-item'],
+
+  events: {
+    'click .js-custom-measure-update': 'onUpdateClick',
+    'click .js-custom-measure-delete': 'onDeleteClick'
+  },
+
+  onRender: function () {
+    this.$el.attr('data-id', this.model.id);
+    this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
+  },
+
+  onDestroy: function () {
+    this.$('[data-toggle="tooltip"]').tooltip('destroy');
+  },
+
+  onUpdateClick: function (e) {
+    e.preventDefault();
+    this.updateCustomMeasure();
+  },
+
+  onDeleteClick: function (e) {
+    e.preventDefault();
+    this.deleteCustomMeasure();
+  },
+
+  updateCustomMeasure: function () {
+    new UpdateView({
+      model: this.model,
+      collection: this.model.collection
+    }).render();
+  },
+
+  deleteCustomMeasure: function () {
+    new DeleteView({ model: this.model }).render();
+  }
 });
+
+
index 986ad559e9862e071495ef709aae6564bbefa814..2d38eae4d1d4285b85c40bf623340203d21ef9f9 100644 (file)
@@ -1,12 +1,11 @@
-define([
-  './list-item-view',
-  './templates'
-], function (ListItemView) {
-
-  return Marionette.CompositeView.extend({
-    template: Templates['custom-measures-list'],
-    childView: ListItemView,
-    childViewContainer: 'tbody'
-  });
+import Marionette from 'backbone.marionette';
+import ListItemView from './list-item-view';
+import './templates';
 
+export default Marionette.CompositeView.extend({
+  template: Templates['custom-measures-list'],
+  childView: ListItemView,
+  childViewContainer: 'tbody'
 });
+
+
index 301c083e5e60a98d79db8da86c5421fdf4559441..4b3fae8384b3626f60b2ffd5fe3bc107e2baac6d 100644 (file)
@@ -1,29 +1,27 @@
-define([
-  './form-view'
-], function (FormView) {
+import FormView from './form-view';
 
-  return FormView.extend({
-
-    sendRequest: function () {
-      var that = this;
-      this.model.set({
-        value: this.$('#create-custom-measure-value').val(),
-        description: this.$('#create-custom-measure-description').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({
+      value: this.$('#create-custom-measure-value').val(),
+      description: this.$('#create-custom-measure-description').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);
+    });
+  }
 });
+
+
index 6c7bb383a6026624f9151ded382a743ab6b05f86..f860933924fcd3f455e33e49b13184020bd14a30 100644 (file)
@@ -1,32 +1,30 @@
-define([
-  'components/source-viewer/main'
-], function (SourceViewer) {
+import $ from 'jquery';
+import Marionette from 'backbone.marionette';
+import SourceViewer from '../../components/source-viewer/main';
 
-  var $ = jQuery,
-      App = new Marionette.Application(),
-      init = function (options) {
-        App.addRegions({ viewerRegion: options.el });
-        $('.js-drilldown-link').on('click', function (e) {
-          e.preventDefault();
-          $(e.currentTarget).closest('table').find('.selected').removeClass('selected');
-          $(e.currentTarget).closest('tr').addClass('selected');
-          var uuid = $(e.currentTarget).data('uuid'),
-              viewer = new SourceViewer();
-          App.viewerRegion.show(viewer);
-          viewer.open(uuid);
-          if (window.drilldown.period != null) {
-            viewer.on('loaded', function () {
-              viewer.filterLinesByDate(window.drilldown.period, window.drilldown.periodName);
-            });
-          }
-        });
-      };
+var App = new Marionette.Application(),
+    init = function (options) {
+      App.addRegions({ viewerRegion: options.el });
+      $('.js-drilldown-link').on('click', function (e) {
+        e.preventDefault();
+        $(e.currentTarget).closest('table').find('.selected').removeClass('selected');
+        $(e.currentTarget).closest('tr').addClass('selected');
+        var uuid = $(e.currentTarget).data('uuid'),
+            viewer = new SourceViewer();
+        App.viewerRegion.show(viewer);
+        viewer.open(uuid);
+        if (window.drilldown.period != null) {
+          viewer.on('loaded', function () {
+            viewer.filterLinesByDate(window.drilldown.period, window.drilldown.periodName);
+          });
+        }
+      });
+    };
 
-  App.on('start', function (options) {
-    window.requestMessages().done(function () {
-      init.call(App, options);
-    });
+App.on('start', function (options) {
+  window.requestMessages().done(function () {
+    init.call(App, options);
   });
-
-  return App;
 });
+
+export default App;
index 28dc73b7f428ac2d9b3e9572b23c8bad83fdae05..f35eeceda983d8908233c81ee8133e45452ec0b4 100644 (file)
@@ -1,8 +1,6 @@
 import React from 'react';
 import Main from './main';
 
-const $ = jQuery;
-
 export default {
   start(options) {
     window.requestMessages().done(() => {
index ef87bb94186331f1a1b16999fd76258cdf7f9d9d..f6369ea191ab4a2b40387c34897d6e9a888e54ab 100644 (file)
@@ -1,56 +1,54 @@
-define([
-  'components/common/modals',
-  'components/common/select-list',
-  './templates'
-], function (Modal) {
+import Modal from 'components/common/modals';
+import 'components/common/select-list';
+import './templates';
 
-  function getSearchUrl(permission, project) {
-    var url = baseUrl + '/api/permissions/groups?ps=100&permission=' + permission;
-    if (project) {
-      url = url + '&projectId=' + project;
-    }
-    return url;
+function getSearchUrl (permission, project) {
+  var url = baseUrl + '/api/permissions/groups?ps=100&permission=' + permission;
+  if (project) {
+    url = url + '&projectId=' + project;
   }
+  return url;
+}
 
-  function getExtra (permission, project) {
-    var extra = { permission: permission };
-    if (project) {
-      extra.projectId = project;
-    }
-    return extra;
+function getExtra (permission, project) {
+  var extra = { permission: permission };
+  if (project) {
+    extra.projectId = project;
   }
+  return extra;
+}
 
-  return Modal.extend({
-    template: Templates['global-permissions-groups'],
+export default Modal.extend({
+  template: Templates['global-permissions-groups'],
 
-    onRender: function () {
-      this._super();
-      new window.SelectList({
-        el: this.$('#global-permissions-groups'),
-        width: '100%',
-        readOnly: false,
-        focusSearch: false,
-        format: function (item) {
-          return item.name;
-        },
-        queryParam: 'q',
-        searchUrl: getSearchUrl(this.options.permission, this.options.project),
-        selectUrl: baseUrl + '/api/permissions/add_group',
-        deselectUrl: baseUrl + '/api/permissions/remove_group',
-        extra: getExtra(this.options.permission, this.options.project),
-        selectParameter: 'groupName',
-        selectParameterValue: 'name',
-        parse: function (r) {
-          this.more = false;
-          return r.groups;
-        }
-      });
-    },
-
-    onDestroy: function () {
-      this.options.refresh();
-      this._super();
-    }
-  });
+  onRender: function () {
+    this._super();
+    new window.SelectList({
+      el: this.$('#global-permissions-groups'),
+      width: '100%',
+      readOnly: false,
+      focusSearch: false,
+      format: function (item) {
+        return item.name;
+      },
+      queryParam: 'q',
+      searchUrl: getSearchUrl(this.options.permission, this.options.project),
+      selectUrl: baseUrl + '/api/permissions/add_group',
+      deselectUrl: baseUrl + '/api/permissions/remove_group',
+      extra: getExtra(this.options.permission, this.options.project),
+      selectParameter: 'groupName',
+      selectParameterValue: 'name',
+      parse: function (r) {
+        this.more = false;
+        return r.groups;
+      }
+    });
+  },
 
+  onDestroy: function () {
+    this.options.refresh();
+    this._super();
+  }
 });
+
+
index 8712c979465d8719090432a0be4aa11ee842ed44..11f6b032ebf44eb7b246c669738143885418b973 100644 (file)
@@ -1,8 +1,7 @@
+import $ from 'jquery';
 import React from 'react';
 import PermissionsList from './permissions-list';
 
-let $ = jQuery;
-
 export default React.createClass({
   getInitialState() {
     return { permissions: [] };
index ec7f415d83a65a2c892d821a33594771d7a3f9af..91da5b747bbb7c6410c5a94c183e31678f8e6f0e 100644 (file)
@@ -1,7 +1,5 @@
 import React from 'react';
 
-let $ = jQuery;
-
 export default {
   propTypes: {
     permission: React.PropTypes.object.isRequired,
index 56f52feed0d9bbc7bace09183f6d003f96e04398..aaed2ab00142595d580df5ff97335b55ac9f43ad 100644 (file)
@@ -1,6 +1,5 @@
 import React from 'react';
 import PermissionsUsersGroupsMixin from './permission-users-groups-mixin';
-import Avatar from 'components/shared/avatar';
 import UsersView from './users-view';
 
 export default React.createClass({
index ac259f521de8464aedebd3bad68499ac80637b9b..1a5f993a90e15a4dfb9c8f0746954dd79d9f7dfe 100644 (file)
@@ -1,9 +1,8 @@
+import $ from 'jquery';
 import React from 'react';
 import PermissionUsers from './permission-users';
 import PermissionGroups from './permission-groups';
 
-let $ = jQuery;
-
 // Maximum number of displayed groups
 const MAX_ITEMS = 3;
 
index 4e85024f480956ebb978421282fe05e47768b6da..61ad9371166aaa1424c2dc33f97f0ef0b9bb8bb6 100644 (file)
@@ -1,56 +1,54 @@
-define([
-  'components/common/modals',
-  'components/common/select-list',
-  './templates'
-], function (Modal) {
+import Modal from 'components/common/modals';
+import 'components/common/select-list';
+import './templates';
 
-  function getSearchUrl (permission, project) {
-    var url = baseUrl + '/api/permissions/users?ps=100&permission=' + permission;
-    if (project) {
-      url = url + '&projectId=' + project;
-    }
-    return url;
+function getSearchUrl (permission, project) {
+  var url = baseUrl + '/api/permissions/users?ps=100&permission=' + permission;
+  if (project) {
+    url = url + '&projectId=' + project;
   }
+  return url;
+}
 
-  function getExtra (permission, project) {
-    var extra = { permission: permission };
-    if (project) {
-      extra.projectId = project;
-    }
-    return extra;
+function getExtra (permission, project) {
+  var extra = { permission: permission };
+  if (project) {
+    extra.projectId = project;
   }
+  return extra;
+}
 
-  return Modal.extend({
-    template: Templates['global-permissions-users'],
+export default Modal.extend({
+  template: Templates['global-permissions-users'],
 
-    onRender: function () {
-      this._super();
-      new window.SelectList({
-        el: this.$('#global-permissions-users'),
-        width: '100%',
-        readOnly: false,
-        focusSearch: false,
-        format: function (item) {
-          return item.name + '<br><span class="note">' + item.login + '</span>';
-        },
-        queryParam: 'q',
-        searchUrl: getSearchUrl(this.options.permission, this.options.project),
-        selectUrl: baseUrl + '/api/permissions/add_user',
-        deselectUrl: baseUrl + '/api/permissions/remove_user',
-        extra: getExtra(this.options.permission, this.options.project),
-        selectParameter: 'login',
-        selectParameterValue: 'login',
-        parse: function (r) {
-          this.more = false;
-          return r.users;
-        }
-      });
-    },
-
-    onDestroy: function () {
-      this.options.refresh();
-      this._super();
-    }
-  });
+  onRender: function () {
+    this._super();
+    new window.SelectList({
+      el: this.$('#global-permissions-users'),
+      width: '100%',
+      readOnly: false,
+      focusSearch: false,
+      format: function (item) {
+        return item.name + '<br><span class="note">' + item.login + '</span>';
+      },
+      queryParam: 'q',
+      searchUrl: getSearchUrl(this.options.permission, this.options.project),
+      selectUrl: baseUrl + '/api/permissions/add_user',
+      deselectUrl: baseUrl + '/api/permissions/remove_user',
+      extra: getExtra(this.options.permission, this.options.project),
+      selectParameter: 'login',
+      selectParameterValue: 'login',
+      parse: function (r) {
+        this.more = false;
+        return r.users;
+      }
+    });
+  },
 
+  onDestroy: function () {
+    this.options.refresh();
+    this._super();
+  }
 });
+
+
index 55c6dfef53486a0ac93c420f144153cdb1416e60..8965f3ecea7ad8db25a69c890fecfee6c1b279a4 100644 (file)
@@ -1,47 +1,46 @@
-define([
-  './layout',
-  './groups',
-  './header-view',
-  './search-view',
-  './list-view',
-  './list-footer-view'
-], function (Layout, Groups, HeaderView, SearchView, ListView, ListFooterView) {
-
-  var App = new Marionette.Application(),
-      init = function (options) {
-        // Layout
-        this.layout = new Layout({ el: options.el });
-        this.layout.render();
-
-        // Collection
-        this.groups = new Groups();
-
-        // Header View
-        this.headerView = new HeaderView({ collection: this.groups });
-        this.layout.headerRegion.show(this.headerView);
-
-        // Search View
-        this.searchView = new SearchView({ collection: this.groups });
-        this.layout.searchRegion.show(this.searchView);
-
-        // List View
-        this.listView = new ListView({ collection: this.groups });
-        this.layout.listRegion.show(this.listView);
-
-        // List Footer View
-        this.listFooterView = new ListFooterView({ collection: this.groups });
-        this.layout.listFooterRegion.show(this.listFooterView);
-
-        // Go!
-        this.groups.fetch();
-      };
-
-  App.on('start', function (options) {
-    window.requestMessages().done(function () {
-      init.call(App, options);
-    });
+import Marionette from 'backbone.marionette';
+import Layout from './layout';
+import Groups from './groups';
+import HeaderView from './header-view';
+import SearchView from './search-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.groups = new Groups();
+
+      // Header View
+      this.headerView = new HeaderView({ collection: this.groups });
+      this.layout.headerRegion.show(this.headerView);
+
+      // Search View
+      this.searchView = new SearchView({ collection: this.groups });
+      this.layout.searchRegion.show(this.searchView);
+
+      // List View
+      this.listView = new ListView({ collection: this.groups });
+      this.layout.listRegion.show(this.listView);
+
+      // List Footer View
+      this.listFooterView = new ListFooterView({ collection: this.groups });
+      this.layout.listFooterRegion.show(this.listFooterView);
+
+      // Go!
+      this.groups.fetch();
+    };
+
+App.on('start', function (options) {
+  window.requestMessages().done(function () {
+    init.call(App, options);
   });
+});
+
+export default App;
 
-  return App;
 
-});
index cddde867a999b1def54a4357f54621b21392d08f..2f3edf11fa079861746b63e57d83b8f142df9165 100644 (file)
@@ -1,30 +1,28 @@
-define([
-  './group',
-  './form-view'
-], function (Group, FormView) {
+import Group from './group';
+import FormView from './form-view';
 
-  return FormView.extend({
-
-    sendRequest: function () {
-      var that = this,
-          group = new Group({
-            name: this.$('#create-group-name').val(),
-            description: this.$('#create-group-description').val()
-          });
-      this.disableForm();
-      return group.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,
+        group = new Group({
+          name: this.$('#create-group-name').val(),
+          description: this.$('#create-group-description').val()
+        });
+    this.disableForm();
+    return group.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);
+    });
+  }
 });
+
+
index 85b33a632b5b4525f06d2e58351006ab0b635305..272a0a85bbc16bbad272414e38c56246048a644c 100644 (file)
@@ -1,38 +1,36 @@
-define([
-  'components/common/modal-form',
-  './templates'
-], function (ModalForm) {
+import ModalForm from 'components/common/modal-form';
+import './templates';
 
-  return ModalForm.extend({
-    template: Templates['groups-delete'],
+export default ModalForm.extend({
+  template: Templates['groups-delete'],
 
-    onFormSubmit: function (e) {
-      this._super(e);
-      this.sendRequest();
-    },
+  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.total--;
-        that.destroy();
-      }).fail(function (jqXHR) {
-        that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
-      });
-    },
-
-    showErrors: function (errors, warnings) {
-      this.$('.js-modal-text').addClass('hidden');
-      this.disableForm();
-      this._super(errors, warnings);
-    }
-  });
+  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.total--;
+      that.destroy();
+    }).fail(function (jqXHR) {
+      that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+    });
+  },
 
+  showErrors: function (errors, warnings) {
+    this.$('.js-modal-text').addClass('hidden');
+    this.disableForm();
+    this._super(errors, warnings);
+  }
 });
+
+
index 7e3c26b98eedab2978c4eef3e85cdab65cd1d1c8..5b541f1ae121506e1cea76d06cebcdd36bd0f39e 100644 (file)
@@ -1,25 +1,23 @@
-define([
-  'components/common/modal-form',
-  './templates'
-], function (ModalForm) {
+import ModalForm from 'components/common/modal-form';
+import './templates';
 
-  return ModalForm.extend({
-    template: Templates['groups-form'],
+export default ModalForm.extend({
+  template: Templates['groups-form'],
 
-    onRender: function () {
-      this._super();
-      this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
-    },
+  onRender: function () {
+    this._super();
+    this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
+  },
 
-    onDestroy: function () {
-      this._super();
-      this.$('[data-toggle="tooltip"]').tooltip('destroy');
-    },
-
-    onFormSubmit: function (e) {
-      this._super(e);
-      this.sendRequest();
-    }
-  });
+  onDestroy: function () {
+    this._super();
+    this.$('[data-toggle="tooltip"]').tooltip('destroy');
+  },
 
+  onFormSubmit: function (e) {
+    this._super(e);
+    this.sendRequest();
+  }
 });
+
+
index aced6727b911051d008cbc82d19b73ac8de87eaf..8901890189530ea562a0c91209b5240b76ebd169 100644 (file)
@@ -1,36 +1,37 @@
-define(function () {
+import _ from 'underscore';
+import Backbone from 'backbone';
 
-  return Backbone.Model.extend({
-    urlRoot: function () {
-      return baseUrl + '/api/usergroups';
-    },
+export default 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') {
-        var attrs = _.extend(_.pick(model.changed, 'name', 'description'), { id: model.id });
-        _.defaults(opts, {
-          url: this.urlRoot() + '/update',
-          type: 'POST',
-          data: attrs
-        });
-      }
-      if (method === 'delete') {
-        _.defaults(opts, {
-          url: this.urlRoot() + '/delete',
-          type: 'POST',
-          data: { id: 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(), 'name', 'description')
+      });
     }
-  });
-
+    if (method === 'update') {
+      var attrs = _.extend(_.pick(model.changed, 'name', 'description'), { id: model.id });
+      _.defaults(opts, {
+        url: this.urlRoot() + '/update',
+        type: 'POST',
+        data: attrs
+      });
+    }
+    if (method === 'delete') {
+      _.defaults(opts, {
+        url: this.urlRoot() + '/delete',
+        type: 'POST',
+        data: { id: this.id }
+      });
+    }
+    return Backbone.ajax(opts);
+  }
 });
+
+
index dcfbb8c731bf30ec05f5492b68fa4e00bbed627e..d22d3373d9a597024eec7d53dcd7953286156734 100644 (file)
@@ -1,40 +1,39 @@
-define([
-  './group'
-], function (Group) {
+import Backbone from 'backbone';
+import Group from './group';
+
+export default Backbone.Collection.extend({
+  model: Group,
+
+  url: function () {
+    return baseUrl + '/api/usergroups/search';
+  },
+
+  parse: function (r) {
+    this.total = +r.total;
+    this.p = +r.p;
+    this.ps = +r.ps;
+    return r.groups;
+  },
+
+  fetch: function (options) {
+    var d = (options && options.data) || {};
+    this.q = d.q;
+    return this._super(options);
+  },
+
+  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;
+  }
 
-  return Backbone.Collection.extend({
-    model: Group,
-
-    url: function () {
-      return baseUrl + '/api/usergroups/search';
-    },
-
-    parse: function (r) {
-      this.total = +r.total;
-      this.p = +r.p;
-      this.ps = +r.ps;
-      return r.groups;
-    },
-
-    fetch: function (options) {
-      var d = (options && options.data) || {};
-      this.q = d.q;
-      return this._super(options);
-    },
-
-    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;
-    }
+});
 
-  });
 
-});
index da6f7f60919294c1730fedee1e524a059acb3ad0..bd7226176b28c01f98a9f156d03b6ecc9912ca03 100644 (file)
@@ -1,25 +1,24 @@
-define([
-  './create-view',
-  './templates'
-], function (CreateView) {
+import Marionette from 'backbone.marionette';
+import CreateView from './create-view';
+import './templates';
 
-  return Marionette.ItemView.extend({
-    template: Templates['groups-header'],
+export default Marionette.ItemView.extend({
+  template: Templates['groups-header'],
 
-    events: {
-      'click #groups-create': 'onCreateClick'
-    },
+  events: {
+    'click #groups-create': 'onCreateClick'
+  },
 
-    onCreateClick: function (e) {
-      e.preventDefault();
-      this.createGroup();
-    },
-
-    createGroup: function () {
-      new CreateView({
-        collection: this.collection
-      }).render();
-    }
-  });
+  onCreateClick: function (e) {
+    e.preventDefault();
+    this.createGroup();
+  },
 
+  createGroup: function () {
+    new CreateView({
+      collection: this.collection
+    }).render();
+  }
 });
+
+
index 18f6c7738d158668c7f80555d5c77dfa79ac47fa..ba1f58e81fc0f66a8a042c61be18a7e72e3d4053 100644 (file)
@@ -1,16 +1,15 @@
-define([
-  './templates'
-], function () {
+import Marionette from 'backbone.marionette';
+import './templates';
 
-  return Marionette.LayoutView.extend({
-    template: Templates['groups-layout'],
-
-    regions: {
-      headerRegion: '#groups-header',
-      searchRegion: '#groups-search',
-      listRegion: '#groups-list',
-      listFooterRegion: '#groups-list-footer'
-    }
-  });
+export default Marionette.LayoutView.extend({
+  template: Templates['groups-layout'],
 
+  regions: {
+    headerRegion: '#groups-header',
+    searchRegion: '#groups-search',
+    listRegion: '#groups-list',
+    listFooterRegion: '#groups-list-footer'
+  }
 });
+
+
index 3c0fbe198c52229193c6913925bdecce9025edef..53dc3e7acaaf51944a83723e7d55d4adfcf9154b 100644 (file)
@@ -1,34 +1,34 @@
-define([
-  './templates'
-], function () {
-
-  return Marionette.ItemView.extend({
-    template: Templates['groups-list-footer'],
-
-    collectionEvents: {
-      'all': 'render'
-    },
-
-    events: {
-      'click #groups-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['groups-list-footer'],
+
+  collectionEvents: {
+    'all': 'render'
+  },
+
+  events: {
+    'click #groups-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()
+    });
+  }
 });
+
+
index 45ce8b9688ac9fdabf354475926a1dc1a2b61082..43278c2ac6e1f2558eabc0eb4e4192213db49add 100644 (file)
@@ -1,62 +1,60 @@
-define([
-  './update-view',
-  './delete-view',
-  './users-view',
-  './templates'
-], function (UpdateView, DeleteView, UsersView) {
-
-  var $ = jQuery;
-
-  return Marionette.ItemView.extend({
-    tagName: 'li',
-    className: 'panel panel-vertical',
-    template: Templates['groups-list-item'],
-
-    events: {
-      'click .js-group-update': 'onUpdateClick',
-      'click .js-group-delete': 'onDeleteClick',
-      'click .js-group-users': 'onUsersClick'
-    },
-
-    onRender: function () {
-      this.$el.attr('data-id', this.model.id);
-      this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
-    },
-
-    onDestroy: function () {
-      this.$('[data-toggle="tooltip"]').tooltip('destroy');
-    },
-
-    onUpdateClick: function (e) {
-      e.preventDefault();
-      this.updateGroup();
-    },
-
-    onDeleteClick: function (e) {
-      e.preventDefault();
-      this.deleteGroup();
-    },
-
-    onUsersClick: function (e) {
-      e.preventDefault();
-      $('.tooltip').remove();
-      this.showUsers();
-    },
-
-    updateGroup: function () {
-      new UpdateView({
-        model: this.model,
-        collection: this.model.collection
-      }).render();
-    },
-
-    deleteGroup: function () {
-      new DeleteView({ model: this.model }).render();
-    },
-
-    showUsers: function () {
-      new UsersView({ model: this.model }).render();
-    }
-  });
-
+import $ from 'jquery';
+import Marionette from 'backbone.marionette';
+import UpdateView from './update-view';
+import DeleteView from './delete-view';
+import UsersView from './users-view';
+import './templates';
+
+export default Marionette.ItemView.extend({
+  tagName: 'li',
+  className: 'panel panel-vertical',
+  template: Templates['groups-list-item'],
+
+  events: {
+    'click .js-group-update': 'onUpdateClick',
+    'click .js-group-delete': 'onDeleteClick',
+    'click .js-group-users': 'onUsersClick'
+  },
+
+  onRender: function () {
+    this.$el.attr('data-id', this.model.id);
+    this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
+  },
+
+  onDestroy: function () {
+    this.$('[data-toggle="tooltip"]').tooltip('destroy');
+  },
+
+  onUpdateClick: function (e) {
+    e.preventDefault();
+    this.updateGroup();
+  },
+
+  onDeleteClick: function (e) {
+    e.preventDefault();
+    this.deleteGroup();
+  },
+
+  onUsersClick: function (e) {
+    e.preventDefault();
+    $('.tooltip').remove();
+    this.showUsers();
+  },
+
+  updateGroup: function () {
+    new UpdateView({
+      model: this.model,
+      collection: this.model.collection
+    }).render();
+  },
+
+  deleteGroup: function () {
+    new DeleteView({ model: this.model }).render();
+  },
+
+  showUsers: function () {
+    new UsersView({ model: this.model }).render();
+  }
 });
+
+
index 24878864d309901cfd4c6b951fa0ab09114d12d2..695bf2ac034422cd4a228e67bec5d08fe0357f6a 100644 (file)
@@ -1,11 +1,10 @@
-define([
-  './list-item-view',
-  './templates'
-], function (ListItemView) {
-
-  return Marionette.CollectionView.extend({
-    tagName: 'ul',
-    childView: ListItemView
-  });
+import Marionette from 'backbone.marionette';
+import ListItemView from './list-item-view';
+import './templates';
 
+export default Marionette.CollectionView.extend({
+  tagName: 'ul',
+  childView: ListItemView
 });
+
+
index 1540d7eb36e559e82590698d2060384e9e8cd51a..db3d4d8bb1806eb1dcb098c52ace01ca1bf34c81 100644 (file)
@@ -1,49 +1,49 @@
-define([
-  './templates'
-], function () {
-
-  return Marionette.ItemView.extend({
-    template: Templates['groups-search'],
-
-    events: {
-      'submit #groups-search-form': 'onFormSubmit',
-      'search #groups-search-query': 'debouncedOnKeyUp',
-      'keyup #groups-search-query': 'debouncedOnKeyUp'
-    },
-
-    initialize: function () {
-      this._bufferedValue = null;
-      this.debouncedOnKeyUp = _.debounce(this.onKeyUp, 400);
-    },
-
-    onRender: function () {
-      this.delegateEvents();
-    },
-
-    onFormSubmit: function (e) {
-      e.preventDefault();
-      this.debouncedOnKeyUp();
-    },
-
-    onKeyUp: function () {
-      var q = this.getQuery();
-      if (q === this._bufferedValue) {
-        return;
-      }
-      this._bufferedValue = this.getQuery();
-      if (this.searchRequest != null) {
-        this.searchRequest.abort();
-      }
-      this.searchRequest = this.search(q);
-    },
-
-    getQuery: function () {
-      return this.$('#groups-search-query').val();
-    },
-
-    search: function (q) {
-      return this.collection.fetch({ reset: true, data: { q: q } });
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import './templates';
+
+export default Marionette.ItemView.extend({
+  template: Templates['groups-search'],
+
+  events: {
+    'submit #groups-search-form': 'onFormSubmit',
+    'search #groups-search-query': 'debouncedOnKeyUp',
+    'keyup #groups-search-query': 'debouncedOnKeyUp'
+  },
+
+  initialize: function () {
+    this._bufferedValue = null;
+    this.debouncedOnKeyUp = _.debounce(this.onKeyUp, 400);
+  },
+
+  onRender: function () {
+    this.delegateEvents();
+  },
+
+  onFormSubmit: function (e) {
+    e.preventDefault();
+    this.debouncedOnKeyUp();
+  },
+
+  onKeyUp: function () {
+    var q = this.getQuery();
+    if (q === this._bufferedValue) {
+      return;
     }
-  });
+    this._bufferedValue = this.getQuery();
+    if (this.searchRequest != null) {
+      this.searchRequest.abort();
+    }
+    this.searchRequest = this.search(q);
+  },
+
+  getQuery: function () {
+    return this.$('#groups-search-query').val();
+  },
 
+  search: function (q) {
+    return this.collection.fetch({ reset: true, data: { q: q } });
+  }
 });
+
+
index 850ddb7510f978296926a8626b11c4d1cff24956..c93608b197b51c236b74567f81c6331c96595e24 100644 (file)
@@ -1,29 +1,27 @@
-define([
-  './form-view'
-], function (FormView) {
+import FormView from './form-view';
 
-  return FormView.extend({
-
-    sendRequest: function () {
-      var that = this;
-      this.model.set({
-        name: this.$('#create-group-name').val(),
-        description: this.$('#create-group-description').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({
+      name: this.$('#create-group-name').val(),
+      description: this.$('#create-group-description').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);
+    });
+  }
 });
+
+
index de5901fc5f118542f6068590ae52c53ebc902761..8c815ff2e4d840972204ade36c5e33cbe11565fd 100644 (file)
@@ -1,42 +1,40 @@
-define([
-  'components/common/modals',
-  'components/common/select-list',
-  './templates'
-], function (Modal) {
+import Modal from 'components/common/modals';
+import 'components/common/select-list';
+import './templates';
 
-  return Modal.extend({
-    template: Templates['groups-users'],
+export default Modal.extend({
+  template: Templates['groups-users'],
 
-    onRender: function () {
-      this._super();
-      new window.SelectList({
-        el: this.$('#groups-users'),
-        width: '100%',
-        readOnly: false,
-        focusSearch: false,
-        format: function (item) {
-          return item.name + '<br><span class="note">' + item.login + '</span>';
-        },
-        queryParam: 'q',
-        searchUrl: baseUrl + '/api/usergroups/users?ps=100&id=' + this.model.id,
-        selectUrl: baseUrl + '/api/usergroups/add_user',
-        deselectUrl: baseUrl + '/api/usergroups/remove_user',
-        extra: {
-          id: this.model.id
-        },
-        selectParameter: 'login',
-        selectParameterValue: 'login',
-        parse: function (r) {
-          this.more = false;
-          return r.users;
-        }
-      });
-    },
-
-    onDestroy: function () {
-      this.model.collection.refresh();
-      this._super();
-    }
-  });
+  onRender: function () {
+    this._super();
+    new window.SelectList({
+      el: this.$('#groups-users'),
+      width: '100%',
+      readOnly: false,
+      focusSearch: false,
+      format: function (item) {
+        return item.name + '<br><span class="note">' + item.login + '</span>';
+      },
+      queryParam: 'q',
+      searchUrl: baseUrl + '/api/usergroups/users?ps=100&id=' + this.model.id,
+      selectUrl: baseUrl + '/api/usergroups/add_user',
+      deselectUrl: baseUrl + '/api/usergroups/remove_user',
+      extra: {
+        id: this.model.id
+      },
+      selectParameter: 'login',
+      selectParameterValue: 'login',
+      parse: function (r) {
+        this.more = false;
+        return r.users;
+      }
+    });
+  },
 
+  onDestroy: function () {
+    this.model.collection.refresh();
+    this._super();
+  }
 });
+
+
index 3d7db3aa2ef3001e66e5c1fcb7ad1ef0e1e49024..8d28597d056aa0c2a780d4e3cd6aec078006b3ea 100644 (file)
@@ -1,97 +1,97 @@
-define([
-  './models/state',
-  './layout',
-  './models/issues',
-  'components/navigator/models/facets',
-  './models/filters',
-  './controller',
-  './router',
-  './workspace-list-view',
-  './workspace-header-view',
-  './facets-view',
-  './helpers/format-facet-value'
-], function (State, Layout, Issues, Facets, Filters, Controller, Router, WorkspaceListView, WorkspaceHeaderView,
-             FacetsView) {
+import $ from 'jquery';
+import _ from 'underscore';
+import Backbone from 'backbone';
+import Marionette from 'backbone.marionette';
+import State from './models/state';
+import Layout from './layout';
+import Issues from './models/issues';
+import Facets from 'components/navigator/models/facets';
+import Filters from './models/filters';
+import Controller from './controller';
+import Router from './router';
+import WorkspaceListView from './workspace-list-view';
+import WorkspaceHeaderView from './workspace-header-view';
+import FacetsView from './facets-view';
+import './helpers/format-facet-value';
 
-  var $ = jQuery,
-      App = new Marionette.Application(),
-      init = function (options) {
-        this.config = options.config;
-        this.state = new State({
-          isContext: true,
-          contextQuery: { componentUuids: options.config.resource },
-          contextComponentUuid: options.config.resource,
-          contextComponentName: options.config.resourceName,
-          contextComponentQualifier: options.config.resourceQualifier
-        });
-        this.updateContextFacets();
-        this.list = new Issues();
-        this.facets = new Facets();
-        this.filters = new Filters();
+var App = new Marionette.Application(),
+    init = function (options) {
+      this.config = options.config;
+      this.state = new State({
+        isContext: true,
+        contextQuery: { componentUuids: options.config.resource },
+        contextComponentUuid: options.config.resource,
+        contextComponentName: options.config.resourceName,
+        contextComponentQualifier: options.config.resourceQualifier
+      });
+      this.updateContextFacets();
+      this.list = new Issues();
+      this.facets = new Facets();
+      this.filters = new Filters();
 
-        this.layout = new Layout({ app: this, el: options.el });
-        this.layout.render();
-        $('#footer').addClass('search-navigator-footer');
+      this.layout = new Layout({ app: this, el: options.el });
+      this.layout.render();
+      $('#footer').addClass('search-navigator-footer');
 
-        this.controller = new Controller({ app: this });
+      this.controller = new Controller({ app: this });
 
-        this.issuesView = new WorkspaceListView({
-          app: this,
-          collection: this.list
-        });
-        this.layout.workspaceListRegion.show(this.issuesView);
-        this.issuesView.bindScrollEvents();
+      this.issuesView = new WorkspaceListView({
+        app: this,
+        collection: this.list
+      });
+      this.layout.workspaceListRegion.show(this.issuesView);
+      this.issuesView.bindScrollEvents();
 
-        this.workspaceHeaderView = new WorkspaceHeaderView({
-          app: this,
-          collection: this.list
-        });
-        this.layout.workspaceHeaderRegion.show(this.workspaceHeaderView);
+      this.workspaceHeaderView = new WorkspaceHeaderView({
+        app: this,
+        collection: this.list
+      });
+      this.layout.workspaceHeaderRegion.show(this.workspaceHeaderView);
 
-        this.facetsView = new FacetsView({
-          app: this,
-          collection: this.facets
-        });
-        this.layout.facetsRegion.show(this.facetsView);
+      this.facetsView = new FacetsView({
+        app: this,
+        collection: this.facets
+      });
+      this.layout.facetsRegion.show(this.facetsView);
 
-        this.controller.fetchFilters().done(function () {
-          key.setScope('list');
-          App.router = new Router({ app: App });
-          Backbone.history.start();
-        });
-      };
+      this.controller.fetchFilters().done(function () {
+        key.setScope('list');
+        App.router = new Router({ app: App });
+        Backbone.history.start();
+      });
+    };
 
-  App.getContextQuery = function () {
-    return { componentUuids: this.config.resource };
-  };
+App.getContextQuery = function () {
+  return { componentUuids: this.config.resource };
+};
 
-  App.getRestrictedFacets = function () {
-    return {
-      'TRK': ['projectUuids'],
-      'BRC': ['projectUuids'],
-      'DIR': ['projectUuids', 'moduleUuids', 'directories'],
-      'DEV': ['authors'],
-      'DEV_PRJ': ['projectUuids', 'authors']
-    };
+App.getRestrictedFacets = function () {
+  return {
+    'TRK': ['projectUuids'],
+    'BRC': ['projectUuids'],
+    'DIR': ['projectUuids', 'moduleUuids', 'directories'],
+    'DEV': ['authors'],
+    'DEV_PRJ': ['projectUuids', 'authors']
   };
+};
 
-  App.updateContextFacets = function () {
-    var facets = this.state.get('facets'),
-        allFacets = this.state.get('allFacets'),
-        facetsFromServer = this.state.get('facetsFromServer');
-    return this.state.set({
-      facets: facets,
-      allFacets: _.difference(allFacets, this.getRestrictedFacets()[this.config.resourceQualifier]),
-      facetsFromServer: _.difference(facetsFromServer, this.getRestrictedFacets()[this.config.resourceQualifier])
-    });
-  };
+App.updateContextFacets = function () {
+  var facets = this.state.get('facets'),
+      allFacets = this.state.get('allFacets'),
+      facetsFromServer = this.state.get('facetsFromServer');
+  return this.state.set({
+    facets: facets,
+    allFacets: _.difference(allFacets, this.getRestrictedFacets()[this.config.resourceQualifier]),
+    facetsFromServer: _.difference(facetsFromServer, this.getRestrictedFacets()[this.config.resourceQualifier])
+  });
+};
 
-  App.on('start', function (options) {
-    $.when(window.requestMessages()).done(function () {
-      init.call(App, options);
-    });
+App.on('start', function (options) {
+  $.when(window.requestMessages()).done(function () {
+    init.call(App, options);
   });
+});
+
+export default App;
 
-  return App;
 
-});
index 12e5671c5c31e88b8b5e9f9d9c9d1ab5507e6c80..fe9188b27f8e19e879a29d3d3d6e8d650a7ef94e 100644 (file)
@@ -1,71 +1,70 @@
-define([
-  './models/state',
-  './layout',
-  './models/issues',
-  'components/navigator/models/facets',
-  './models/filters',
-  './controller',
-  './router',
-  './workspace-list-view',
-  './workspace-header-view',
-  './facets-view',
-  './filters-view',
-  './helpers/format-facet-value'
-], function (State, Layout, Issues, Facets, Filters, Controller, Router, WorkspaceListView, WorkspaceHeaderView,
-             FacetsView, FiltersView) {
+import $ from 'jquery';
+import Backbone from 'backbone';
+import Marionette from 'backbone.marionette';
+import State from './models/state';
+import Layout from './layout';
+import Issues from './models/issues';
+import Facets from 'components/navigator/models/facets';
+import Filters from './models/filters';
+import Controller from './controller';
+import Router from './router';
+import WorkspaceListView from './workspace-list-view';
+import WorkspaceHeaderView from './workspace-header-view';
+import FacetsView from './facets-view';
+import FiltersView from './filters-view';
+import './helpers/format-facet-value';
 
-  var $ = jQuery,
-      App = new Marionette.Application(),
-      init = function (options) {
-        this.state = new State();
-        this.list = new Issues();
-        this.facets = new Facets();
-        this.filters = new Filters();
+var App = new Marionette.Application(),
+    init = function (options) {
+      this.state = new State();
+      this.list = new Issues();
+      this.facets = new Facets();
+      this.filters = new Filters();
 
-        this.layout = new Layout({ app: this, el: options.el });
-        this.layout.render();
-        $('#footer').addClass('search-navigator-footer');
+      this.layout = new Layout({ app: this, el: options.el });
+      this.layout.render();
+      $('#footer').addClass('search-navigator-footer');
 
-        this.controller = new Controller({ app: this });
+      this.controller = new Controller({ app: this });
 
-        this.issuesView = new WorkspaceListView({
-          app: this,
-          collection: this.list
-        });
-        this.layout.workspaceListRegion.show(this.issuesView);
-        this.issuesView.bindScrollEvents();
+      this.issuesView = new WorkspaceListView({
+        app: this,
+        collection: this.list
+      });
+      this.layout.workspaceListRegion.show(this.issuesView);
+      this.issuesView.bindScrollEvents();
 
-        this.workspaceHeaderView = new WorkspaceHeaderView({
-          app: this,
-          collection: this.list
-        });
-        this.layout.workspaceHeaderRegion.show(this.workspaceHeaderView);
+      this.workspaceHeaderView = new WorkspaceHeaderView({
+        app: this,
+        collection: this.list
+      });
+      this.layout.workspaceHeaderRegion.show(this.workspaceHeaderView);
 
-        this.facetsView = new FacetsView({
-          app: this,
-          collection: this.facets
-        });
-        this.layout.facetsRegion.show(this.facetsView);
+      this.facetsView = new FacetsView({
+        app: this,
+        collection: this.facets
+      });
+      this.layout.facetsRegion.show(this.facetsView);
 
-        this.filtersView = new FiltersView({
-          app: this,
-          collection: this.filters
-        });
-        this.layout.filtersRegion.show(this.filtersView);
+      this.filtersView = new FiltersView({
+        app: this,
+        collection: this.filters
+      });
+      this.layout.filtersRegion.show(this.filtersView);
 
-        this.controller.fetchFilters().done(function () {
-          key.setScope('list');
-          App.router = new Router({ app: App });
-          Backbone.history.start();
-        });
-      };
+      this.controller.fetchFilters().done(function () {
+        key.setScope('list');
+        App.router = new Router({ app: App });
+        Backbone.history.start();
+      });
+    };
 
-  App.on('start', function (options) {
-    $.when(window.requestMessages()).done(function () {
-      init.call(App, options);
-    });
+App.on('start', function (options) {
+  $.when(window.requestMessages()).done(function () {
+    init.call(App, options);
   });
+});
+
+export default App;
 
-  return App;
 
-});
index 97d3e2b40e96f141df24582d684d227fe13bee50..41e8087fd25b6248a3bcee1557d28adc870d244a 100644 (file)
@@ -1,18 +1,17 @@
-define([
-  '../workspace-list-item-view'
-], function (IssueView) {
+import _ from 'underscore';
+import IssueView from '../workspace-list-item-view';
 
-  return IssueView.extend({
-    onRender: function () {
-      IssueView.prototype.onRender.apply(this, arguments);
-      this.$el.removeClass('issue-navigate-right issue-with-checkbox');
-    },
-
-    serializeData: function () {
-      return _.extend(IssueView.prototype.serializeData.apply(this, arguments), {
-        showComponent: false
-      });
-    }
-  });
+export default IssueView.extend({
+  onRender: function () {
+    IssueView.prototype.onRender.apply(this, arguments);
+    this.$el.removeClass('issue-navigate-right issue-with-checkbox');
+  },
 
+  serializeData: function () {
+    return _.extend(IssueView.prototype.serializeData.apply(this, arguments), {
+      showComponent: false
+    });
+  }
 });
+
+
index 8792113e2136783b7064cc43ab6d496f7a6e2cb2..2397bf06cb071ae76a81a2fb0c223ddbf3a67266 100644 (file)
-define([
-  'components/source-viewer/main',
-  '../models/issues',
-  './issue-view',
-  '../templates'
-], function (SourceViewer, Issues, IssueView) {
-
-  var $ = jQuery;
-
-  return SourceViewer.extend({
-    events: function () {
-      return _.extend(SourceViewer.prototype.events.apply(this, arguments), {
-        'click .js-close-component-viewer': 'closeComponentViewer',
-        'click .code-issue': 'selectIssue'
-      });
-    },
-
-    initialize: function (options) {
-      SourceViewer.prototype.initialize.apply(this, arguments);
-      return this.listenTo(options.app.state, 'change:selectedIndex', this.select);
-    },
-
-    onLoaded: function () {
-      SourceViewer.prototype.onLoaded.apply(this, arguments);
-      this.bindShortcuts();
-      if (this.baseIssue != null) {
-        this.baseIssue.trigger('locations', this.baseIssue);
-        return this.scrollToLine(this.baseIssue.get('line'));
+import $ from 'jquery';
+import _ from 'underscore';
+import SourceViewer from 'components/source-viewer/main';
+import IssueView from './issue-view';
+import '../templates';
+
+export default SourceViewer.extend({
+  events: function () {
+    return _.extend(SourceViewer.prototype.events.apply(this, arguments), {
+      'click .js-close-component-viewer': 'closeComponentViewer',
+      'click .code-issue': 'selectIssue'
+    });
+  },
+
+  initialize: function (options) {
+    SourceViewer.prototype.initialize.apply(this, arguments);
+    return this.listenTo(options.app.state, 'change:selectedIndex', this.select);
+  },
+
+  onLoaded: function () {
+    SourceViewer.prototype.onLoaded.apply(this, arguments);
+    this.bindShortcuts();
+    if (this.baseIssue != null) {
+      this.baseIssue.trigger('locations', this.baseIssue);
+      return this.scrollToLine(this.baseIssue.get('line'));
+    }
+  },
+
+  bindShortcuts: function () {
+    var that = this;
+    var doAction = function (action) {
+      var selectedIssueView = that.getSelectedIssueEl();
+      if (!selectedIssueView) {
+        return;
       }
-    },
-
-    bindShortcuts: function () {
-      var that = this;
-      var doAction = function (action) {
-        var selectedIssueView = that.getSelectedIssueEl();
-        if (!selectedIssueView) {
-          return;
-        }
-        return selectedIssueView.find('.js-issue-' + action).click();
-      };
-      key('up', 'componentViewer', function () {
-        that.options.app.controller.selectPrev();
-        return false;
-      });
-      key('down', 'componentViewer', function () {
-        that.options.app.controller.selectNext();
-        return false;
-      });
-      key('left,backspace', 'componentViewer', function () {
-        that.options.app.controller.closeComponentViewer();
-        return false;
-      });
-      key('f', 'componentViewer', function () {
-        return doAction('transition');
-      });
-      key('a', 'componentViewer', function () {
-        return doAction('assign');
-      });
-      key('m', 'componentViewer', function () {
-        return doAction('assign-to-me');
-      });
-      key('p', 'componentViewer', function () {
-        return doAction('plan');
-      });
-      key('i', 'componentViewer', function () {
-        return doAction('set-severity');
-      });
-      return key('c', 'componentViewer', function () {
-        return doAction('comment');
-      });
-    },
-
-    unbindShortcuts: function () {
-      return key.deleteScope('componentViewer');
-    },
-
-    onDestroy: function () {
-      SourceViewer.prototype.onDestroy.apply(this, arguments);
-      this.unbindScrollEvents();
-      return this.unbindShortcuts();
-    },
-
-    select: function () {
+      return selectedIssueView.find('.js-issue-' + action).click();
+    };
+    key('up', 'componentViewer', function () {
+      that.options.app.controller.selectPrev();
+      return false;
+    });
+    key('down', 'componentViewer', function () {
+      that.options.app.controller.selectNext();
+      return false;
+    });
+    key('left,backspace', 'componentViewer', function () {
+      that.options.app.controller.closeComponentViewer();
+      return false;
+    });
+    key('f', 'componentViewer', function () {
+      return doAction('transition');
+    });
+    key('a', 'componentViewer', function () {
+      return doAction('assign');
+    });
+    key('m', 'componentViewer', function () {
+      return doAction('assign-to-me');
+    });
+    key('p', 'componentViewer', function () {
+      return doAction('plan');
+    });
+    key('i', 'componentViewer', function () {
+      return doAction('set-severity');
+    });
+    return key('c', 'componentViewer', function () {
+      return doAction('comment');
+    });
+  },
+
+  unbindShortcuts: function () {
+    return key.deleteScope('componentViewer');
+  },
+
+  onDestroy: function () {
+    SourceViewer.prototype.onDestroy.apply(this, arguments);
+    this.unbindScrollEvents();
+    return this.unbindShortcuts();
+  },
+
+  select: function () {
+    var selected = this.options.app.state.get('selectedIndex'),
+        selectedIssue = this.options.app.list.at(selected);
+    if (selectedIssue.get('component') === this.model.get('key')) {
+      selectedIssue.trigger('locations', selectedIssue);
+      return this.scrollToIssue(selectedIssue.get('key'));
+    } else {
+      this.unbindShortcuts();
+      return this.options.app.controller.showComponentViewer(selectedIssue);
+    }
+  },
+
+  getSelectedIssueEl: function () {
+    var selected = this.options.app.state.get('selectedIndex');
+    if (selected == null) {
+      return null;
+    }
+    var selectedIssue = this.options.app.list.at(selected);
+    if (selectedIssue == null) {
+      return null;
+    }
+    var selectedIssueView = this.$('#issue-' + (selectedIssue.get('key')));
+    if (selectedIssueView.length > 0) {
+      return selectedIssueView;
+    } else {
+      return null;
+    }
+  },
+
+  selectIssue: function (e) {
+    var key = $(e.currentTarget).data('issue-key'),
+        issue = this.issues.find(function (model) {
+          return model.get('key') === key;
+        }),
+        index = this.options.app.list.indexOf(issue);
+    return this.options.app.state.set({ selectedIndex: index });
+  },
+
+  scrollToIssue: function (key) {
+    var el = this.$('#issue-' + key);
+    if (el.length > 0) {
+      var line = el.closest('[data-line-number]').data('line-number');
+      return this.scrollToLine(line);
+    } else {
+      this.unbindShortcuts();
       var selected = this.options.app.state.get('selectedIndex'),
           selectedIssue = this.options.app.list.at(selected);
-      if (selectedIssue.get('component') === this.model.get('key')) {
-        selectedIssue.trigger('locations', selectedIssue);
-        return this.scrollToIssue(selectedIssue.get('key'));
-      } else {
-        this.unbindShortcuts();
-        return this.options.app.controller.showComponentViewer(selectedIssue);
-      }
-    },
-
-    getSelectedIssueEl: function () {
-      var selected = this.options.app.state.get('selectedIndex');
-      if (selected == null) {
-        return null;
-      }
-      var selectedIssue = this.options.app.list.at(selected);
-      if (selectedIssue == null) {
-        return null;
-      }
-      var selectedIssueView = this.$('#issue-' + (selectedIssue.get('key')));
-      if (selectedIssueView.length > 0) {
-        return selectedIssueView;
-      } else {
-        return null;
-      }
-    },
-
-    selectIssue: function (e) {
-      var key = $(e.currentTarget).data('issue-key'),
-          issue = this.issues.find(function (model) {
-            return model.get('key') === key;
-          }),
-          index = this.options.app.list.indexOf(issue);
-      return this.options.app.state.set({ selectedIndex: index });
-    },
-
-    scrollToIssue: function (key) {
-      var el = this.$('#issue-' + key);
-      if (el.length > 0) {
-        var line = el.closest('[data-line-number]').data('line-number');
-        return this.scrollToLine(line);
-      } else {
-        this.unbindShortcuts();
-        var selected = this.options.app.state.get('selectedIndex'),
-            selectedIssue = this.options.app.list.at(selected);
-        return this.options.app.controller.showComponentViewer(selectedIssue);
-      }
-    },
-
-    openFileByIssue: function (issue) {
-      this.baseIssue = issue;
-      var componentKey = issue.get('component'),
-          componentUuid = issue.get('componentUuid');
-      return this.open(componentUuid, componentKey);
-    },
-
-    linesLimit: function () {
-      var line = this.LINES_LIMIT / 2;
-      if ((this.baseIssue != null) && this.baseIssue.has('line')) {
-        line = Math.max(line, this.baseIssue.get('line'));
-      }
-      return {
-        from: line - this.LINES_LIMIT / 2 + 1,
-        to: line + this.LINES_LIMIT / 2
-      };
-    },
-
-    limitIssues: function (issues) {
-      var that = this;
-      var index = this.ISSUES_LIMIT / 2;
-      if ((this.baseIssue != null) && this.baseIssue.has('index')) {
-        index = Math.max(index, this.baseIssue.get('index'));
-      }
-      return issues.filter(function (issue) {
-        return Math.abs(issue.get('index') - index) <= that.ISSUES_LIMIT / 2;
-      });
-    },
-
-    requestIssues: function () {
-      var that = this;
-      var r;
-      if (this.options.app.list.last().get('component') === this.model.get('key')) {
-        r = this.options.app.controller.fetchNextPage();
-      } else {
-        r = $.Deferred().resolve().promise();
-      }
-      return r.done(function () {
-        that.issues.reset(that.options.app.list.filter(function (issue) {
-          return issue.get('component') === that.model.key();
-        }));
-        that.issues.reset(that.limitIssues(that.issues));
-        return that.addIssuesPerLineMeta(that.issues);
-      });
-    },
-
-    renderIssues: function () {
-      this.issues.forEach(this.renderIssue, this);
-      return this.$('.source-line-issues').addClass('hidden');
-    },
-
-    renderIssue: function (issue) {
-      var issueView = new IssueView({
-        el: '#issue-' + issue.get('key'),
-        model: issue,
-        app: this.options.app
-      });
-      this.issueViews.push(issueView);
-      return issueView.render();
-    },
-
-    scrollToLine: function (line) {
-      var row = this.$('[data-line-number=' + line + ']'),
-          goal = row.length > 0 ? row.offset().top - 200 : 0;
-      return $(window).scrollTop(goal);
-    },
-
-    closeComponentViewer: function () {
-      return this.options.app.controller.closeComponentViewer();
+      return this.options.app.controller.showComponentViewer(selectedIssue);
     }
-  });
-
+  },
+
+  openFileByIssue: function (issue) {
+    this.baseIssue = issue;
+    var componentKey = issue.get('component'),
+        componentUuid = issue.get('componentUuid');
+    return this.open(componentUuid, componentKey);
+  },
+
+  linesLimit: function () {
+    var line = this.LINES_LIMIT / 2;
+    if ((this.baseIssue != null) && this.baseIssue.has('line')) {
+      line = Math.max(line, this.baseIssue.get('line'));
+    }
+    return {
+      from: line - this.LINES_LIMIT / 2 + 1,
+      to: line + this.LINES_LIMIT / 2
+    };
+  },
+
+  limitIssues: function (issues) {
+    var that = this;
+    var index = this.ISSUES_LIMIT / 2;
+    if ((this.baseIssue != null) && this.baseIssue.has('index')) {
+      index = Math.max(index, this.baseIssue.get('index'));
+    }
+    return issues.filter(function (issue) {
+      return Math.abs(issue.get('index') - index) <= that.ISSUES_LIMIT / 2;
+    });
+  },
+
+  requestIssues: function () {
+    var that = this;
+    var r;
+    if (this.options.app.list.last().get('component') === this.model.get('key')) {
+      r = this.options.app.controller.fetchNextPage();
+    } else {
+      r = $.Deferred().resolve().promise();
+    }
+    return r.done(function () {
+      that.issues.reset(that.options.app.list.filter(function (issue) {
+        return issue.get('component') === that.model.key();
+      }));
+      that.issues.reset(that.limitIssues(that.issues));
+      return that.addIssuesPerLineMeta(that.issues);
+    });
+  },
+
+  renderIssues: function () {
+    this.issues.forEach(this.renderIssue, this);
+    return this.$('.source-line-issues').addClass('hidden');
+  },
+
+  renderIssue: function (issue) {
+    var issueView = new IssueView({
+      el: '#issue-' + issue.get('key'),
+      model: issue,
+      app: this.options.app
+    });
+    this.issueViews.push(issueView);
+    return issueView.render();
+  },
+
+  scrollToLine: function (line) {
+    var row = this.$('[data-line-number=' + line + ']'),
+        goal = row.length > 0 ? row.offset().top - 200 : 0;
+    return $(window).scrollTop(goal);
+  },
+
+  closeComponentViewer: function () {
+    return this.options.app.controller.closeComponentViewer();
+  }
 });
+
+
index bf54a35c2bc8b930007462b7c28100a79c34ae4d..b7843450adaeb2db7dec7f1eef40c21098bf9847 100644 (file)
-define([
-  'components/navigator/controller',
-  './component-viewer/main',
-  './workspace-home-view'
-], function (Controller, ComponentViewer, HomeView) {
+import $ from 'jquery';
+import _ from 'underscore';
+import Backbone from 'backbone';
+import Controller from 'components/navigator/controller';
+import ComponentViewer from './component-viewer/main';
+import HomeView from './workspace-home-view';
 
-  var $ = jQuery,
-      FIELDS = 'component,componentId,project,subProject,rule,status,resolution,author,reporter,assignee,debt,line,' +
-          'message,severity,actionPlan,creationDate,updateDate,closeDate,tags,comments,attr,actions,transitions,' +
-          'actionPlanName',
-      FACET_DATA_FIELDS = ['components', 'users', 'rules', 'actionPlans', 'languages'];
+var FIELDS = 'component,componentId,project,subProject,rule,status,resolution,author,reporter,assignee,debt,line,' +
+        'message,severity,actionPlan,creationDate,updateDate,closeDate,tags,comments,attr,actions,transitions,' +
+        'actionPlanName',
+    FACET_DATA_FIELDS = ['components', 'users', 'rules', 'actionPlans', 'languages'];
 
-  return Controller.extend({
-    _facetsFromServer: function () {
-      var facets = Controller.prototype._facetsFromServer.apply(this, arguments) || [];
-      facets.push('assigned_to_me');
-      return facets;
-    },
+export default Controller.extend({
+  _facetsFromServer: function () {
+    var facets = Controller.prototype._facetsFromServer.apply(this, arguments) || [];
+    facets.push('assigned_to_me');
+    return facets;
+  },
 
-    _issuesParameters: function () {
-      return {
-        p: this.options.app.state.get('page'),
-        ps: this.pageSize,
-        s: 'FILE_LINE',
-        asc: true,
-        f: FIELDS,
-        additionalFields: '_all',
-        facets: this._facetsFromServer().join()
-      };
-    },
+  _issuesParameters: function () {
+    return {
+      p: this.options.app.state.get('page'),
+      ps: this.pageSize,
+      s: 'FILE_LINE',
+      asc: true,
+      f: FIELDS,
+      additionalFields: '_all',
+      facets: this._facetsFromServer().join()
+    };
+  },
 
-    _myIssuesFromResponse: function (r) {
-      var myIssuesData = _.findWhere(r.facets, { property: 'assigned_to_me' });
-      if ((myIssuesData != null) && _.isArray(myIssuesData.values) && myIssuesData.values.length > 0) {
-        return this.options.app.state.set({ myIssues: myIssuesData.values[0].count }, { silent: true });
-      } else {
-        return this.options.app.state.unset('myIssues', { silent: true });
-      }
-    },
+  _myIssuesFromResponse: function (r) {
+    var myIssuesData = _.findWhere(r.facets, { property: 'assigned_to_me' });
+    if ((myIssuesData != null) && _.isArray(myIssuesData.values) && myIssuesData.values.length > 0) {
+      return this.options.app.state.set({ myIssues: myIssuesData.values[0].count }, { silent: true });
+    } else {
+      return this.options.app.state.unset('myIssues', { silent: true });
+    }
+  },
 
-    fetchList: function (firstPage) {
-      var that = this;
-      if (firstPage == null) {
-        firstPage = true;
-      }
+  fetchList: function (firstPage) {
+    var that = this;
+    if (firstPage == null) {
+      firstPage = true;
+    }
+    if (firstPage) {
+      this.options.app.state.set({ selectedIndex: 0, page: 1 }, { silent: true });
+      this.hideHomePage();
+      this.closeComponentViewer();
+    }
+    var data = this._issuesParameters();
+    _.extend(data, this.options.app.state.get('query'));
+    if (this.options.app.state.get('isContext')) {
+      _.extend(data, this.options.app.state.get('contextQuery'));
+    }
+    return $.get(baseUrl + '/api/issues/search', data).done(function (r) {
+      var issues = that.options.app.list.parseIssues(r);
       if (firstPage) {
-        this.options.app.state.set({ selectedIndex: 0, page: 1 }, { silent: true });
-        this.hideHomePage();
-        this.closeComponentViewer();
-      }
-      var data = this._issuesParameters();
-      _.extend(data, this.options.app.state.get('query'));
-      if (this.options.app.state.get('isContext')) {
-        _.extend(data, this.options.app.state.get('contextQuery'));
+        that.options.app.list.reset(issues);
+      } else {
+        that.options.app.list.add(issues);
       }
-      return $.get(baseUrl + '/api/issues/search', data).done(function (r) {
-        var issues = that.options.app.list.parseIssues(r);
-        if (firstPage) {
-          that.options.app.list.reset(issues);
-        } else {
-          that.options.app.list.add(issues);
-        }
-        that.options.app.list.setIndex();
-        FACET_DATA_FIELDS.forEach(function (field) {
-          that.options.app.facets[field] = r[field];
-        });
-        that.options.app.facets.reset(that._allFacets());
-        that.options.app.facets.add(_.reject(r.facets, function (f) {
-          return f.property === 'assigned_to_me';
-        }), { merge: true });
-        that._myIssuesFromResponse(r);
-        that.enableFacets(that._enabledFacets());
-        that.options.app.state.set({
-          page: r.p,
-          pageSize: r.ps,
-          total: r.total,
-          maxResultsReached: r.p * r.ps >= r.total
-        });
-        if (firstPage && that.isIssuePermalink()) {
-          return that.showComponentViewer(that.options.app.list.first());
-        }
+      that.options.app.list.setIndex();
+      FACET_DATA_FIELDS.forEach(function (field) {
+        that.options.app.facets[field] = r[field];
+      });
+      that.options.app.facets.reset(that._allFacets());
+      that.options.app.facets.add(_.reject(r.facets, function (f) {
+        return f.property === 'assigned_to_me';
+      }), { merge: true });
+      that._myIssuesFromResponse(r);
+      that.enableFacets(that._enabledFacets());
+      that.options.app.state.set({
+        page: r.p,
+        pageSize: r.ps,
+        total: r.total,
+        maxResultsReached: r.p * r.ps >= r.total
       });
-    },
+      if (firstPage && that.isIssuePermalink()) {
+        return that.showComponentViewer(that.options.app.list.first());
+      }
+    });
+  },
 
-    isIssuePermalink: function () {
-      var query = this.options.app.state.get('query');
-      return (query.issues != null) && this.options.app.list.length === 1;
-    },
+  isIssuePermalink: function () {
+    var query = this.options.app.state.get('query');
+    return (query.issues != null) && this.options.app.list.length === 1;
+  },
 
-    fetchFilters: function () {
-      var that = this;
-      return $.when(
-          that.options.app.filters.fetch({ reset: true }),
-          $.get(baseUrl + '/api/issue_filters/app', function (r) {
-            that.options.app.state.set({
-              canBulkChange: r.canBulkChange,
-              canManageFilters: r.canManageFilters
-            });
-          }));
-    },
+  fetchFilters: function () {
+    var that = this;
+    return $.when(
+        that.options.app.filters.fetch({ reset: true }),
+        $.get(baseUrl + '/api/issue_filters/app', function (r) {
+          that.options.app.state.set({
+            canBulkChange: r.canBulkChange,
+            canManageFilters: r.canManageFilters
+          });
+        }));
+  },
 
-    _mergeCollections: function (a, b) {
-      var collection = new Backbone.Collection(a);
-      collection.add(b, { merge: true });
-      return collection.toJSON();
-    },
+  _mergeCollections: function (a, b) {
+    var collection = new Backbone.Collection(a);
+    collection.add(b, { merge: true });
+    return collection.toJSON();
+  },
 
-    requestFacet: function (id) {
-      var that = this;
-      if (id === 'assignees') {
-        return this.requestAssigneeFacet();
-      }
-      var facet = this.options.app.facets.get(id),
-          data = _.extend({ facets: id, ps: 1, additionalFields: '_all' }, this.options.app.state.get('query'));
-      if (this.options.app.state.get('isContext')) {
-        _.extend(data, this.options.app.state.get('contextQuery'));
-      }
-      return $.get(baseUrl + '/api/issues/search', data, function (r) {
-        FACET_DATA_FIELDS.forEach(function (field) {
-          that.options.app.facets[field] = that._mergeCollections(that.options.app.facets[field], r[field]);
-        });
-        var facetData = _.findWhere(r.facets, { property: id });
-        if (facetData != null) {
-          return facet.set(facetData);
-        }
+  requestFacet: function (id) {
+    var that = this;
+    if (id === 'assignees') {
+      return this.requestAssigneeFacet();
+    }
+    var facet = this.options.app.facets.get(id),
+        data = _.extend({ facets: id, ps: 1, additionalFields: '_all' }, this.options.app.state.get('query'));
+    if (this.options.app.state.get('isContext')) {
+      _.extend(data, this.options.app.state.get('contextQuery'));
+    }
+    return $.get(baseUrl + '/api/issues/search', data, function (r) {
+      FACET_DATA_FIELDS.forEach(function (field) {
+        that.options.app.facets[field] = that._mergeCollections(that.options.app.facets[field], r[field]);
       });
-    },
-
-    requestAssigneeFacet: function () {
-      var that = this;
-      var facet = this.options.app.facets.get('assignees'),
-          data = _.extend({ facets: 'assignees,assigned_to_me', ps: 1, additionalFields: '_all' },
-              this.options.app.state.get('query'));
-      if (this.options.app.state.get('isContext')) {
-        _.extend(data, this.options.app.state.get('contextQuery'));
+      var facetData = _.findWhere(r.facets, { property: id });
+      if (facetData != null) {
+        return facet.set(facetData);
       }
-      return $.get(baseUrl + '/api/issues/search', data, function (r) {
-        FACET_DATA_FIELDS.forEach(function (field) {
-          that.options.app.facets[field] = that._mergeCollections(that.options.app.facets[field], r[field]);
-        });
-        var facetData = _.findWhere(r.facets, { property: 'assignees' });
-        that._myIssuesFromResponse(r);
-        if (facetData != null) {
-          return facet.set(facetData);
-        }
+    });
+  },
+
+  requestAssigneeFacet: function () {
+    var that = this;
+    var facet = this.options.app.facets.get('assignees'),
+        data = _.extend({ facets: 'assignees,assigned_to_me', ps: 1, additionalFields: '_all' },
+            this.options.app.state.get('query'));
+    if (this.options.app.state.get('isContext')) {
+      _.extend(data, this.options.app.state.get('contextQuery'));
+    }
+    return $.get(baseUrl + '/api/issues/search', data, function (r) {
+      FACET_DATA_FIELDS.forEach(function (field) {
+        that.options.app.facets[field] = that._mergeCollections(that.options.app.facets[field], r[field]);
       });
-    },
+      var facetData = _.findWhere(r.facets, { property: 'assignees' });
+      that._myIssuesFromResponse(r);
+      if (facetData != null) {
+        return facet.set(facetData);
+      }
+    });
+  },
 
-    newSearch: function () {
-      this.options.app.state.unset('filter');
-      return this.options.app.state.setQuery({ resolved: 'false' });
-    },
+  newSearch: function () {
+    this.options.app.state.unset('filter');
+    return this.options.app.state.setQuery({ resolved: 'false' });
+  },
 
-    applyFilter: function (filter, ignoreQuery) {
-      if (ignoreQuery == null) {
-        ignoreQuery = false;
-      }
-      if (!ignoreQuery) {
-        var filterQuery = this.parseQuery(filter.get('query'));
-        this.options.app.state.setQuery(filterQuery);
-      }
-      return this.options.app.state.set({ filter: filter, changed: false });
-    },
+  applyFilter: function (filter, ignoreQuery) {
+    if (ignoreQuery == null) {
+      ignoreQuery = false;
+    }
+    if (!ignoreQuery) {
+      var filterQuery = this.parseQuery(filter.get('query'));
+      this.options.app.state.setQuery(filterQuery);
+    }
+    return this.options.app.state.set({ filter: filter, changed: false });
+  },
 
-    parseQuery: function () {
-      var q = Controller.prototype.parseQuery.apply(this, arguments);
-      delete q.asc;
-      delete q.s;
-      return q;
-    },
+  parseQuery: function () {
+    var q = Controller.prototype.parseQuery.apply(this, arguments);
+    delete q.asc;
+    delete q.s;
+    return q;
+  },
 
-    getQuery: function (separator, addContext) {
-      if (separator == null) {
-        separator = '|';
-      }
-      if (addContext == null) {
-        addContext = false;
-      }
-      var filter = this.options.app.state.get('query');
-      if (addContext && this.options.app.state.get('isContext')) {
-        _.extend(filter, this.options.app.state.get('contextQuery'));
-      }
-      var route = [];
-      _.map(filter, function (value, property) {
-        return route.push('' + property + '=' + encodeURIComponent(value));
-      });
-      return route.join(separator);
-    },
+  getQuery: function (separator, addContext) {
+    if (separator == null) {
+      separator = '|';
+    }
+    if (addContext == null) {
+      addContext = false;
+    }
+    var filter = this.options.app.state.get('query');
+    if (addContext && this.options.app.state.get('isContext')) {
+      _.extend(filter, this.options.app.state.get('contextQuery'));
+    }
+    var route = [];
+    _.map(filter, function (value, property) {
+      return route.push('' + property + '=' + encodeURIComponent(value));
+    });
+    return route.join(separator);
+  },
 
-    getRoute: function () {
-      var filter = this.options.app.state.get('filter'),
-          query = Controller.prototype.getRoute.apply(this, arguments);
-      if (filter != null) {
-        if (this.options.app.state.get('changed') && query.length > 0) {
-          query = 'id=' + filter.id + '|' + query;
-        } else {
-          query = 'id=' + filter.id;
-        }
+  getRoute: function () {
+    var filter = this.options.app.state.get('filter'),
+        query = Controller.prototype.getRoute.apply(this, arguments);
+    if (filter != null) {
+      if (this.options.app.state.get('changed') && query.length > 0) {
+        query = 'id=' + filter.id + '|' + query;
+      } else {
+        query = 'id=' + filter.id;
       }
-      return query;
-    },
+    }
+    return query;
+  },
 
-    _prepareComponent: function (issue) {
-      return {
-        key: issue.get('component'),
-        name: issue.get('componentLongName'),
-        qualifier: issue.get('componentQualifier'),
-        subProject: issue.get('subProject'),
-        subProjectName: issue.get('subProjectLongName'),
-        project: issue.get('project'),
-        projectName: issue.get('projectLongName')
-      };
-    },
+  _prepareComponent: function (issue) {
+    return {
+      key: issue.get('component'),
+      name: issue.get('componentLongName'),
+      qualifier: issue.get('componentQualifier'),
+      subProject: issue.get('subProject'),
+      subProjectName: issue.get('subProjectLongName'),
+      project: issue.get('project'),
+      projectName: issue.get('projectLongName')
+    };
+  },
 
-    showComponentViewer: function (issue) {
-      this.options.app.layout.workspaceComponentViewerRegion.reset();
-      key.setScope('componentViewer');
-      this.options.app.issuesView.unbindScrollEvents();
-      this.options.app.state.set('component', this._prepareComponent(issue));
-      this.options.app.componentViewer = new ComponentViewer({ app: this.options.app });
-      this.options.app.layout.workspaceComponentViewerRegion.show(this.options.app.componentViewer);
-      this.options.app.layout.showComponentViewer();
-      return this.options.app.componentViewer.openFileByIssue(issue);
-    },
+  showComponentViewer: function (issue) {
+    this.options.app.layout.workspaceComponentViewerRegion.reset();
+    key.setScope('componentViewer');
+    this.options.app.issuesView.unbindScrollEvents();
+    this.options.app.state.set('component', this._prepareComponent(issue));
+    this.options.app.componentViewer = new ComponentViewer({ app: this.options.app });
+    this.options.app.layout.workspaceComponentViewerRegion.show(this.options.app.componentViewer);
+    this.options.app.layout.showComponentViewer();
+    return this.options.app.componentViewer.openFileByIssue(issue);
+  },
 
-    closeComponentViewer: function () {
-      key.setScope('list');
-      $('body').click();
-      this.options.app.state.unset('component');
-      this.options.app.layout.workspaceComponentViewerRegion.reset();
-      this.options.app.layout.hideComponentViewer();
-      this.options.app.issuesView.bindScrollEvents();
-      return this.options.app.issuesView.scrollTo();
-    },
+  closeComponentViewer: function () {
+    key.setScope('list');
+    $('body').click();
+    this.options.app.state.unset('component');
+    this.options.app.layout.workspaceComponentViewerRegion.reset();
+    this.options.app.layout.hideComponentViewer();
+    this.options.app.issuesView.bindScrollEvents();
+    return this.options.app.issuesView.scrollTo();
+  },
 
-    showHomePage: function () {
-      this.fetchList();
-      this.options.app.layout.workspaceComponentViewerRegion.reset();
-      key.setScope('home');
-      this.options.app.issuesView.unbindScrollEvents();
-      this.options.app.homeView = new HomeView({
-        app: this.options.app,
-        collection: this.options.app.filters
-      });
-      this.options.app.layout.workspaceHomeRegion.show(this.options.app.homeView);
-      return this.options.app.layout.showHomePage();
-    },
-
-    hideHomePage: function () {
-      this.options.app.layout.workspaceComponentViewerRegion.reset();
-      this.options.app.layout.workspaceHomeRegion.reset();
-      key.setScope('list');
-      this.options.app.layout.hideHomePage();
-      this.options.app.issuesView.bindScrollEvents();
-      return this.options.app.issuesView.scrollTo();
-    }
-  });
+  showHomePage: function () {
+    this.fetchList();
+    this.options.app.layout.workspaceComponentViewerRegion.reset();
+    key.setScope('home');
+    this.options.app.issuesView.unbindScrollEvents();
+    this.options.app.homeView = new HomeView({
+      app: this.options.app,
+      collection: this.options.app.filters
+    });
+    this.options.app.layout.workspaceHomeRegion.show(this.options.app.homeView);
+    return this.options.app.layout.showHomePage();
+  },
 
+  hideHomePage: function () {
+    this.options.app.layout.workspaceComponentViewerRegion.reset();
+    this.options.app.layout.workspaceHomeRegion.reset();
+    key.setScope('list');
+    this.options.app.layout.hideHomePage();
+    this.options.app.issuesView.bindScrollEvents();
+    return this.options.app.issuesView.scrollTo();
+  }
 });
+
+
index fa715f902f7fed7fdb9402f04d0c30a801d221cc..82fd76fe7145e30c7153fddd882198ecbef3c967 100644 (file)
@@ -1,52 +1,48 @@
-define([
-  'components/navigator/facets-view',
-  './facets/base-facet',
-  './facets/severity-facet',
-  './facets/status-facet',
-  './facets/project-facet',
-  './facets/module-facet',
-  './facets/assignee-facet',
-  './facets/rule-facet',
-  './facets/tag-facet',
-  './facets/resolution-facet',
-  './facets/creation-date-facet',
-  './facets/action-plan-facet',
-  './facets/file-facet',
-  './facets/reporter-facet',
-  './facets/language-facet',
-  './facets/author-facet',
-  './facets/issue-key-facet',
-  './facets/context-facet',
-  './facets/mode-facet'
-], function (FacetsView, BaseFacet, SeverityFacet, StatusFacet, ProjectFacet, ModuleFacet, AssigneeFacet, RuleFacet,
-             TagFacet, ResolutionFacet, CreationDateFacet, ActionPlanFacet, FileFacet, ReporterFacet, LanguageFacet,
-             AuthorFacet, IssueKeyFacet, ContextFacet, ModeFacet) {
+import FacetsView from 'components/navigator/facets-view';
+import BaseFacet from './facets/base-facet';
+import SeverityFacet from './facets/severity-facet';
+import StatusFacet from './facets/status-facet';
+import ProjectFacet from './facets/project-facet';
+import ModuleFacet from './facets/module-facet';
+import AssigneeFacet from './facets/assignee-facet';
+import RuleFacet from './facets/rule-facet';
+import TagFacet from './facets/tag-facet';
+import ResolutionFacet from './facets/resolution-facet';
+import CreationDateFacet from './facets/creation-date-facet';
+import ActionPlanFacet from './facets/action-plan-facet';
+import FileFacet from './facets/file-facet';
+import ReporterFacet from './facets/reporter-facet';
+import LanguageFacet from './facets/language-facet';
+import AuthorFacet from './facets/author-facet';
+import IssueKeyFacet from './facets/issue-key-facet';
+import ContextFacet from './facets/context-facet';
+import ModeFacet from './facets/mode-facet';
 
-  var viewsMapping = {
-    severities: SeverityFacet,
-    statuses: StatusFacet,
-    assignees: AssigneeFacet,
-    resolutions: ResolutionFacet,
-    createdAt: CreationDateFacet,
-    projectUuids: ProjectFacet,
-    moduleUuids: ModuleFacet,
-    rules: RuleFacet,
-    tags: TagFacet,
-    actionPlans: ActionPlanFacet,
-    fileUuids: FileFacet,
-    reporters: ReporterFacet,
-    languages: LanguageFacet,
-    authors: AuthorFacet,
-    issues: IssueKeyFacet,
-    context: ContextFacet,
-    facetMode: ModeFacet
-  };
-
-  return FacetsView.extend({
-    getChildView: function (model) {
-      var view = viewsMapping[model.get('property')];
-      return view ? view : BaseFacet;
-    }
-  });
+var viewsMapping = {
+  severities: SeverityFacet,
+  statuses: StatusFacet,
+  assignees: AssigneeFacet,
+  resolutions: ResolutionFacet,
+  createdAt: CreationDateFacet,
+  projectUuids: ProjectFacet,
+  moduleUuids: ModuleFacet,
+  rules: RuleFacet,
+  tags: TagFacet,
+  actionPlans: ActionPlanFacet,
+  fileUuids: FileFacet,
+  reporters: ReporterFacet,
+  languages: LanguageFacet,
+  authors: AuthorFacet,
+  issues: IssueKeyFacet,
+  context: ContextFacet,
+  facetMode: ModeFacet
+};
 
+export default FacetsView.extend({
+  getChildView: function (model) {
+    var view = viewsMapping[model.get('property')];
+    return view ? view : BaseFacet;
+  }
 });
+
+
index d85fa9e5dfdd03ba3ec6e82b4bef61719f1d206f..fa415f981ff18cb9a551b14cc84dd5374b039683 100644 (file)
@@ -1,68 +1,66 @@
-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['issues-action-plan-facet'],
 
-  return BaseFacet.extend({
-    template: Templates['issues-action-plan-facet'],
-
-    onRender: function () {
-      BaseFacet.prototype.onRender.apply(this, arguments);
-      var value = this.options.app.state.get('query').planned;
-      if ((value != null) && (!value || value === 'false')) {
-        return this.$('.js-facet').filter('[data-unplanned]').addClass('active');
-      }
-    },
-
-    toggleFacet: function (e) {
-      var unplanned = $(e.currentTarget).is('[data-unplanned]');
-      $(e.currentTarget).toggleClass('active');
-      if (unplanned) {
-        var checked = $(e.currentTarget).is('.active'),
-            value = checked ? 'false' : null;
-        return this.options.app.state.updateFilter({
-          planned: value,
-          actionPlans: null
-        });
-      } else {
-        return this.options.app.state.updateFilter({
-          planned: null,
-          actionPlans: this.getValue()
-        });
-      }
-    },
-
-    getValuesWithLabels: function () {
-      var values = this.model.getValues(),
-          actionPlans = this.options.app.facets.actionPlans;
-      values.forEach(function (v) {
-        var key = v.val,
-            label = null;
-        if (key) {
-          var actionPlan = _.findWhere(actionPlans, { key: key });
-          if (actionPlan != null) {
-            label = actionPlan.name;
-          }
-        }
-        v.label = label;
-      });
-      return values;
-    },
+  onRender: function () {
+    BaseFacet.prototype.onRender.apply(this, arguments);
+    var value = this.options.app.state.get('query').planned;
+    if ((value != null) && (!value || value === 'false')) {
+      return this.$('.js-facet').filter('[data-unplanned]').addClass('active');
+    }
+  },
 
-    disable: function () {
+  toggleFacet: function (e) {
+    var unplanned = $(e.currentTarget).is('[data-unplanned]');
+    $(e.currentTarget).toggleClass('active');
+    if (unplanned) {
+      var checked = $(e.currentTarget).is('.active'),
+          value = checked ? 'false' : null;
       return this.options.app.state.updateFilter({
-        planned: null,
+        planned: value,
         actionPlans: null
       });
-    },
-
-    serializeData: function () {
-      return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
-        values: this.getValuesWithLabels()
+    } else {
+      return this.options.app.state.updateFilter({
+        planned: null,
+        actionPlans: this.getValue()
       });
     }
-  });
+  },
 
+  getValuesWithLabels: function () {
+    var values = this.model.getValues(),
+        actionPlans = this.options.app.facets.actionPlans;
+    values.forEach(function (v) {
+      var key = v.val,
+          label = null;
+      if (key) {
+        var actionPlan = _.findWhere(actionPlans, { key: key });
+        if (actionPlan != null) {
+          label = actionPlan.name;
+        }
+      }
+      v.label = label;
+    });
+    return values;
+  },
+
+  disable: function () {
+    return this.options.app.state.updateFilter({
+      planned: null,
+      actionPlans: null
+    });
+  },
+
+  serializeData: function () {
+    return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
+      values: this.getValuesWithLabels()
+    });
+  }
 });
+
+
index 3645b7215d6dc5a7a1b81b827d7ecaf9a8f329be..edebc4adf524398ee752de3390c79880101018f2 100644 (file)
-define([
-  './custom-values-facet',
-  '../templates'
-], function (CustomValuesFacet) {
+import $ from 'jquery';
+import _ from 'underscore';
+import CustomValuesFacet from './custom-values-facet';
+import '../templates';
 
-  var $ = jQuery;
+export default CustomValuesFacet.extend({
+  template: Templates['issues-assignee-facet'],
 
-  return CustomValuesFacet.extend({
-    template: Templates['issues-assignee-facet'],
+  getUrl: function () {
+    return baseUrl + '/api/users/search';
+  },
 
-    getUrl: function () {
-      return baseUrl + '/api/users/search';
-    },
+  prepareAjaxSearch: function () {
+    return {
+      quietMillis: 300,
+      url: this.getUrl(),
+      data: function (term, page) {
+        return { q: term, p: page };
+      },
+      results: window.usersToSelect2
+    };
+  },
 
-    prepareAjaxSearch: function () {
-      return {
-        quietMillis: 300,
-        url: this.getUrl(),
-        data: function (term, page) {
-          return { q: term, p: page };
-        },
-        results: window.usersToSelect2
-      };
-    },
-
-    onRender: function () {
-      CustomValuesFacet.prototype.onRender.apply(this, arguments);
-      var value = this.options.app.state.get('query').assigned;
-      if ((value != null) && (!value || value === 'false')) {
-        return this.$('.js-facet').filter('[data-unassigned]').addClass('active');
-      }
-    },
-
-    toggleFacet: function (e) {
-      var unassigned = $(e.currentTarget).is('[data-unassigned]');
-      $(e.currentTarget).toggleClass('active');
-      if (unassigned) {
-        var checked = $(e.currentTarget).is('.active'),
-            value = checked ? 'false' : null;
-        return this.options.app.state.updateFilter({
-          assigned: value,
-          assignees: null
-        });
-      } else {
-        return this.options.app.state.updateFilter({
-          assigned: null,
-          assignees: this.getValue()
-        });
-      }
-    },
+  onRender: function () {
+    CustomValuesFacet.prototype.onRender.apply(this, arguments);
+    var value = this.options.app.state.get('query').assigned;
+    if ((value != null) && (!value || value === 'false')) {
+      return this.$('.js-facet').filter('[data-unassigned]').addClass('active');
+    }
+  },
 
-    getValuesWithLabels: function () {
-      var values = this.model.getValues(),
-          users = this.options.app.facets.users;
-      values.forEach(function (v) {
-        var login = v.val,
-            name = '';
-        if (login) {
-          var user = _.findWhere(users, { login: login });
-          if (user != null) {
-            name = user.name;
-          }
-        }
-        v.label = name;
+  toggleFacet: function (e) {
+    var unassigned = $(e.currentTarget).is('[data-unassigned]');
+    $(e.currentTarget).toggleClass('active');
+    if (unassigned) {
+      var checked = $(e.currentTarget).is('.active'),
+          value = checked ? 'false' : null;
+      return this.options.app.state.updateFilter({
+        assigned: value,
+        assignees: null
       });
-      return values;
-    },
-
-    disable: function () {
+    } else {
       return this.options.app.state.updateFilter({
         assigned: null,
-        assignees: null
+        assignees: this.getValue()
       });
-    },
+    }
+  },
 
-    addCustomValue: function () {
-      var property = this.model.get('property'),
-          customValue = this.$('.js-custom-value').select2('val'),
-          value = this.getValue();
-      if (value.length > 0) {
-        value += ',';
+  getValuesWithLabels: function () {
+    var values = this.model.getValues(),
+        users = this.options.app.facets.users;
+    values.forEach(function (v) {
+      var login = v.val,
+          name = '';
+      if (login) {
+        var user = _.findWhere(users, { login: login });
+        if (user != null) {
+          name = user.name;
+        }
       }
-      value += customValue;
-      var obj = {};
-      obj[property] = value;
-      obj.assigned = null;
-      return this.options.app.state.updateFilter(obj);
-    },
+      v.label = name;
+    });
+    return values;
+  },
 
-    sortValues: function (values) {
-      return _.sortBy(values, function (v) {
-        return v.val === '' ? -999999 : -v.count;
-      });
-    },
+  disable: function () {
+    return this.options.app.state.updateFilter({
+      assigned: null,
+      assignees: null
+    });
+  },
 
-    getNumberOfMyIssues: function () {
-      return this.options.app.state.get('myIssues');
-    },
-
-    serializeData: function () {
-      return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), {
-        myIssues: this.getNumberOfMyIssues(),
-        values: this.sortValues(this.getValuesWithLabels())
-      });
+  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;
+    obj.assigned = null;
+    return this.options.app.state.updateFilter(obj);
+  },
 
+  sortValues: function (values) {
+    return _.sortBy(values, function (v) {
+      return v.val === '' ? -999999 : -v.count;
+    });
+  },
+
+  getNumberOfMyIssues: function () {
+    return this.options.app.state.get('myIssues');
+  },
+
+  serializeData: function () {
+    return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), {
+      myIssues: this.getNumberOfMyIssues(),
+      values: this.sortValues(this.getValuesWithLabels())
+    });
+  }
 });
+
+
index ee987a3d06767f714f4958e184d2998fdaa77a6c..6567912ab1e3203bf34b8d131fee4eb21b5d925a 100644 (file)
@@ -1,44 +1,42 @@
-define([
-  './custom-values-facet'
-], function (CustomValuesFacet) {
+import CustomValuesFacet from './custom-values-facet';
 
-  return CustomValuesFacet.extend({
-    getUrl: function () {
-      return baseUrl + '/api/issues/authors';
-    },
+export default CustomValuesFacet.extend({
+  getUrl: function () {
+    return baseUrl + '/api/issues/authors';
+  },
 
-    prepareSearch: function () {
-      return this.$('.js-custom-value').select2({
-        placeholder: 'Search...',
-        minimumInputLength: 2,
-        allowClear: false,
-        formatNoMatches: function () {
-          return t('select2.noMatches');
+  prepareSearch: function () {
+    return this.$('.js-custom-value').select2({
+      placeholder: 'Search...',
+      minimumInputLength: 2,
+      allowClear: false,
+      formatNoMatches: function () {
+        return t('select2.noMatches');
+      },
+      formatSearching: function () {
+        return t('select2.searching');
+      },
+      formatInputTooShort: function () {
+        return tp('select2.tooShort', 2);
+      },
+      width: '100%',
+      ajax: {
+        quietMillis: 300,
+        url: this.getUrl(),
+        data: function (term) {
+          return { q: term, ps: 25 };
         },
-        formatSearching: function () {
-          return t('select2.searching');
-        },
-        formatInputTooShort: function () {
-          return tp('select2.tooShort', 2);
-        },
-        width: '100%',
-        ajax: {
-          quietMillis: 300,
-          url: this.getUrl(),
-          data: function (term) {
-            return { q: term, ps: 25 };
-          },
-          results: function (data) {
-            return {
-              more: false,
-              results: data.authors.map(function (author) {
-                return { id: author, text: author };
-              })
-            };
-          }
+        results: function (data) {
+          return {
+            more: false,
+            results: data.authors.map(function (author) {
+              return { id: author, text: author };
+            })
+          };
         }
-      });
-    }
-  });
-
+      }
+    });
+  }
 });
+
+
index 923e1d4e6d1b95162091a31660491188dd76a1ef..d781c602fbd22e7ce222ff7762e99ffea86912a7 100644 (file)
@@ -1,25 +1,24 @@
-define([
-  'components/navigator/facets/base-facet',
-  '../templates'
-], function (BaseFacet) {
+import _ from 'underscore';
+import BaseFacet from 'components/navigator/facets/base-facet';
+import '../templates';
 
-  return BaseFacet.extend({
-    template: Templates['issues-base-facet'],
+export default BaseFacet.extend({
+  template: Templates['issues-base-facet'],
 
-    onRender: function () {
-      BaseFacet.prototype.onRender.apply(this, arguments);
-      return this.$('[data-toggle="tooltip"]').tooltip({ container: 'body' });
-    },
+  onRender: function () {
+    BaseFacet.prototype.onRender.apply(this, arguments);
+    return this.$('[data-toggle="tooltip"]').tooltip({ container: 'body' });
+  },
 
-    onDestroy: function () {
-      return this.$('[data-toggle="tooltip"]').tooltip('destroy');
-    },
-
-    serializeData: function () {
-      return _.extend(this._super(), {
-        state: this.options.app.state.toJSON()
-      });
-    }
-  });
+  onDestroy: function () {
+    return this.$('[data-toggle="tooltip"]').tooltip('destroy');
+  },
 
+  serializeData: function () {
+    return _.extend(this._super(), {
+      state: this.options.app.state.toJSON()
+    });
+  }
 });
+
+
index 48c88c8f1c0dbacdd170c6e589c39cd3bd413996..4f49aebc6ea73fa4ada035126dc925752aa44576 100644 (file)
@@ -1,16 +1,15 @@
-define([
-  './base-facet',
-  '../templates'
-], function (BaseFacet) {
+import _ from 'underscore';
+import BaseFacet from './base-facet';
+import '../templates';
 
-  return BaseFacet.extend({
-    template: Templates['issues-context-facet'],
-
-    serializeData: function () {
-      return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
-        state: this.options.app.state.toJSON()
-      });
-    }
-  });
+export default BaseFacet.extend({
+  template: Templates['issues-context-facet'],
 
+  serializeData: function () {
+    return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
+      state: this.options.app.state.toJSON()
+    });
+  }
 });
+
+
index fbf81e94fbbc4d477a9f47dbec25b685e26de37a..34edcbf706d0567ce5db93d5cc17f06c8a3d3fe8 100644 (file)
-define([
-  './base-facet',
-  '../templates'
-], function (BaseFacet) {
-
-  var $ = jQuery;
-
-  return BaseFacet.extend({
-    template: Templates['issues-creation-date-facet'],
-
-    events: function () {
-      return _.extend(BaseFacet.prototype.events.apply(this, arguments), {
-        'change input': 'applyFacet',
-        'click .js-select-period-start': 'selectPeriodStart',
-        'click .js-select-period-end': 'selectPeriodEnd',
-        'click .sonar-d3 rect': 'selectBar',
-        'click .js-all': 'onAllClick',
-        'click .js-last-week': 'onLastWeekClick',
-        'click .js-last-month': 'onLastMonthClick',
-        'click .js-last-year': 'onLastYearClick'
-      });
-    },
-
-    onRender: function () {
-      var that = this;
-      this.$el.toggleClass('search-navigator-facet-box-collapsed', !this.model.get('enabled'));
-      this.$('input').datepicker({
-        dateFormat: 'yy-mm-dd',
-        changeMonth: true,
-        changeYear: true
-      });
-      var props = ['createdAfter', 'createdBefore', 'createdAt'],
-          query = this.options.app.state.get('query');
-      props.forEach(function (prop) {
-        var value = query[prop];
-        if (value != null) {
-          return that.$('input[name=' + prop + ']').val(value);
-        }
-      });
-      var values = this.model.getValues();
-      if (!(_.isArray(values) && values.length > 0)) {
-        var date = moment();
-        values = [];
-        _.times(10, function () {
-            values.push({ count: 0, val: date.toDate().toString() });
-            date = date.subtract(1, 'days');
-        });
-        values.reverse();
+import $ from 'jquery';
+import _ from 'underscore';
+import BaseFacet from './base-facet';
+import '../templates';
+
+export default BaseFacet.extend({
+  template: Templates['issues-creation-date-facet'],
+
+  events: function () {
+    return _.extend(BaseFacet.prototype.events.apply(this, arguments), {
+      'change input': 'applyFacet',
+      'click .js-select-period-start': 'selectPeriodStart',
+      'click .js-select-period-end': 'selectPeriodEnd',
+      'click .sonar-d3 rect': 'selectBar',
+      'click .js-all': 'onAllClick',
+      'click .js-last-week': 'onLastWeekClick',
+      'click .js-last-month': 'onLastMonthClick',
+      'click .js-last-year': 'onLastYearClick'
+    });
+  },
+
+  onRender: function () {
+    var that = this;
+    this.$el.toggleClass('search-navigator-facet-box-collapsed', !this.model.get('enabled'));
+    this.$('input').datepicker({
+      dateFormat: 'yy-mm-dd',
+      changeMonth: true,
+      changeYear: true
+    });
+    var props = ['createdAfter', 'createdBefore', 'createdAt'],
+        query = this.options.app.state.get('query');
+    props.forEach(function (prop) {
+      var value = query[prop];
+      if (value != null) {
+        return that.$('input[name=' + prop + ']').val(value);
       }
-      values = values.map(function (v) {
-        var format = that.options.app.state.getFacetMode() === 'count' ? 'SHORT_INT' : 'SHORT_WORK_DUR';
-        var text = window.formatMeasure(v.count, format);
-        return _.extend(v, { text: text });
-      });
-      return this.$('.js-barchart').barchart(values);
-    },
-
-    selectPeriodStart: function () {
-      return this.$('.js-period-start').datepicker('show');
-    },
-
-    selectPeriodEnd: function () {
-      return this.$('.js-period-end').datepicker('show');
-    },
-
-    applyFacet: function () {
-      var obj = { createdAt: null, createdInLast: null };
-      this.$('input').each(function () {
-        var property, value;
-        property = $(this).prop('name');
-        value = $(this).val();
-        obj[property] = value;
-      });
-      return this.options.app.state.updateFilter(obj);
-    },
-
-    disable: function () {
-      return this.options.app.state.updateFilter({
-        createdAfter: null,
-        createdBefore: null,
-        createdAt: null,
-        createdInLast: null
-      });
-    },
-
-    selectBar: function (e) {
-      var periodStart = $(e.currentTarget).data('period-start'),
-          periodEnd = $(e.currentTarget).data('period-end');
-      return this.options.app.state.updateFilter({
-        createdAfter: periodStart,
-        createdBefore: periodEnd,
-        createdAt: null,
-        createdInLast: null
-      });
-    },
-
-    selectPeriod: function (period) {
-      return this.options.app.state.updateFilter({
-        createdAfter: null,
-        createdBefore: null,
-        createdAt: null,
-        createdInLast: period
-      });
-    },
-
-    onAllClick: function () {
-      return this.disable();
-    },
-
-    onLastWeekClick: function (e) {
-      e.preventDefault();
-      return this.selectPeriod('1w');
-    },
-
-    onLastMonthClick: function (e) {
-      e.preventDefault();
-      return this.selectPeriod('1m');
-    },
-
-    onLastYearClick: function (e) {
-      e.preventDefault();
-      return this.selectPeriod('1y');
-    },
-
-    serializeData: function () {
-      return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
-        periodStart: this.options.app.state.get('query').createdAfter,
-        periodEnd: this.options.app.state.get('query').createdBefore,
-        createdAt: this.options.app.state.get('query').createdAt,
-        createdInLast: this.options.app.state.get('query').createdInLast
+    });
+    var values = this.model.getValues();
+    if (!(_.isArray(values) && values.length > 0)) {
+      var date = moment();
+      values = [];
+      _.times(10, function () {
+        values.push({ count: 0, val: date.toDate().toString() });
+        date = date.subtract(1, 'days');
       });
+      values.reverse();
     }
-  });
-
+    values = values.map(function (v) {
+      var format = that.options.app.state.getFacetMode() === 'count' ? 'SHORT_INT' : 'SHORT_WORK_DUR';
+      var text = window.formatMeasure(v.count, format);
+      return _.extend(v, { text: text });
+    });
+    return this.$('.js-barchart').barchart(values);
+  },
+
+  selectPeriodStart: function () {
+    return this.$('.js-period-start').datepicker('show');
+  },
+
+  selectPeriodEnd: function () {
+    return this.$('.js-period-end').datepicker('show');
+  },
+
+  applyFacet: function () {
+    var obj = { createdAt: null, createdInLast: null };
+    this.$('input').each(function () {
+      var property, value;
+      property = $(this).prop('name');
+      value = $(this).val();
+      obj[property] = value;
+    });
+    return this.options.app.state.updateFilter(obj);
+  },
+
+  disable: function () {
+    return this.options.app.state.updateFilter({
+      createdAfter: null,
+      createdBefore: null,
+      createdAt: null,
+      createdInLast: null
+    });
+  },
+
+  selectBar: function (e) {
+    var periodStart = $(e.currentTarget).data('period-start'),
+        periodEnd = $(e.currentTarget).data('period-end');
+    return this.options.app.state.updateFilter({
+      createdAfter: periodStart,
+      createdBefore: periodEnd,
+      createdAt: null,
+      createdInLast: null
+    });
+  },
+
+  selectPeriod: function (period) {
+    return this.options.app.state.updateFilter({
+      createdAfter: null,
+      createdBefore: null,
+      createdAt: null,
+      createdInLast: period
+    });
+  },
+
+  onAllClick: function () {
+    return this.disable();
+  },
+
+  onLastWeekClick: function (e) {
+    e.preventDefault();
+    return this.selectPeriod('1w');
+  },
+
+  onLastMonthClick: function (e) {
+    e.preventDefault();
+    return this.selectPeriod('1m');
+  },
+
+  onLastYearClick: function (e) {
+    e.preventDefault();
+    return this.selectPeriod('1y');
+  },
+
+  serializeData: function () {
+    return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
+      periodStart: this.options.app.state.get('query').createdAfter,
+      periodEnd: this.options.app.state.get('query').createdBefore,
+      createdAt: this.options.app.state.get('query').createdAt,
+      createdInLast: this.options.app.state.get('query').createdInLast
+    });
+  }
 });
+
+
index 11b3aebdd749b75b25027f250d3908004a3ba361..04faae8470b4589a03d8fe8c705e7b718bc1eab9 100644 (file)
@@ -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['issues-custom-values-facet'],
+export default BaseFacet.extend({
+  template: Templates['issues-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 () {
+  getUrl: function () {
 
-    },
+  },
 
-    onRender: function () {
-      BaseFacet.prototype.onRender.apply(this, arguments);
-      return this.prepareSearch();
-    },
+  onRender: function () {
+    BaseFacet.prototype.onRender.apply(this, arguments);
+    return this.prepareSearch();
+  },
 
-    prepareSearch: function () {
-      return this.$('.js-custom-value').select2({
-        placeholder: 'Search...',
-        minimumInputLength: 2,
-        allowClear: false,
-        formatNoMatches: function () {
-          return t('select2.noMatches');
-        },
-        formatSearching: function () {
-          return t('select2.searching');
-        },
-        formatInputTooShort: function () {
-          return tp('select2.tooShort', 2);
-        },
-        width: '100%',
-        ajax: this.prepareAjaxSearch()
-      });
-    },
+  prepareSearch: function () {
+    return this.$('.js-custom-value').select2({
+      placeholder: 'Search...',
+      minimumInputLength: 2,
+      allowClear: false,
+      formatNoMatches: function () {
+        return t('select2.noMatches');
+      },
+      formatSearching: function () {
+        return t('select2.searching');
+      },
+      formatInputTooShort: function () {
+        return tp('select2.tooShort', 2);
+      },
+      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;
-      return 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;
+    return this.options.app.state.updateFilter(obj);
+  }
 });
+
+
index d01340e6d3c34803a22849a8fd96c37c825b9b49..0c904feeec599767cb73ddc9124c63bf2c1ecf85 100644 (file)
@@ -1,43 +1,41 @@
-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['issues-file-facet'],
 
-  return BaseFacet.extend({
-    template: Templates['issues-file-facet'],
+  onRender: function () {
+    BaseFacet.prototype.onRender.apply(this, arguments);
+    var maxValueWidth = _.max(this.$('.facet-stat').map(function () {
+      return $(this).outerWidth();
+    }).get());
+    return this.$('.facet-name').css('padding-right', maxValueWidth);
+  },
 
-    onRender: function () {
-      BaseFacet.prototype.onRender.apply(this, arguments);
-      var maxValueWidth = _.max(this.$('.facet-stat').map(function () {
-        return $(this).outerWidth();
-      }).get());
-      return this.$('.facet-name').css('padding-right', maxValueWidth);
-    },
-
-    getValuesWithLabels: function () {
-      var values = this.model.getValues(),
-          source = this.options.app.facets.components;
-      values.forEach(function (v) {
-        var key = v.val,
-            label = null;
-        if (key) {
-          var item = _.findWhere(source, { uuid: key });
-          if (item != null) {
-            label = item.longName;
-          }
+  getValuesWithLabels: function () {
+    var values = this.model.getValues(),
+        source = this.options.app.facets.components;
+    values.forEach(function (v) {
+      var key = v.val,
+          label = null;
+      if (key) {
+        var item = _.findWhere(source, { uuid: key });
+        if (item != null) {
+          label = item.longName;
         }
-        v.label = label;
-      });
-      return values;
-    },
-
-    serializeData: function () {
-      return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
-        values: this.sortValues(this.getValuesWithLabels())
-      });
-    }
-  });
+      }
+      v.label = label;
+    });
+    return values;
+  },
 
+  serializeData: function () {
+    return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
+      values: this.sortValues(this.getValuesWithLabels())
+    });
+  }
 });
+
+
index 2d309b85a3ed21fc942cf8826e00e080d05bf14b..b7e8cfd136a10b05c5aa7a1761d5171bcdf8e93d 100644 (file)
@@ -1,24 +1,23 @@
-define([
-  './base-facet',
-  '../templates'
-], function (BaseFacet) {
+import _ from 'underscore';
+import BaseFacet from './base-facet';
+import '../templates';
 
-  return BaseFacet.extend({
-    template: Templates['issues-issue-key-facet'],
+export default BaseFacet.extend({
+  template: Templates['issues-issue-key-facet'],
 
-    onRender: function () {
-      return this.$el.toggleClass('hidden', !this.options.app.state.get('query').issues);
-    },
+  onRender: function () {
+    return this.$el.toggleClass('hidden', !this.options.app.state.get('query').issues);
+  },
 
-    disable: function () {
-      return this.options.app.state.updateFilter({ issues: null });
-    },
-
-    serializeData: function () {
-      return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
-        issues: this.options.app.state.get('query').issues
-      });
-    }
-  });
+  disable: function () {
+    return this.options.app.state.updateFilter({ issues: null });
+  },
 
+  serializeData: function () {
+    return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
+      issues: this.options.app.state.get('query').issues
+    });
+  }
 });
+
+
index 3418158fba432f1df4407fd25df4af5e0293a5f4..c3d6f2744204066086fc63de45396d0fda311600 100644 (file)
@@ -1,67 +1,66 @@
-define([
-  './custom-values-facet'
-], function (CustomValuesFacet) {
+import _ from 'underscore';
+import CustomValuesFacet from './custom-values-facet';
 
-  return CustomValuesFacet.extend({
-    getUrl: function () {
-      return baseUrl + '/api/languages/list';
-    },
+export default CustomValuesFacet.extend({
+  getUrl: function () {
+    return baseUrl + '/api/languages/list';
+  },
 
-    prepareSearch: function () {
-      return this.$('.js-custom-value').select2({
-        placeholder: 'Search...',
-        minimumInputLength: 2,
-        allowClear: false,
-        formatNoMatches: function () {
-          return t('select2.noMatches');
+  prepareSearch: function () {
+    return this.$('.js-custom-value').select2({
+      placeholder: 'Search...',
+      minimumInputLength: 2,
+      allowClear: false,
+      formatNoMatches: function () {
+        return t('select2.noMatches');
+      },
+      formatSearching: function () {
+        return t('select2.searching');
+      },
+      formatInputTooShort: function () {
+        return tp('select2.tooShort', 2);
+      },
+      width: '100%',
+      ajax: {
+        quietMillis: 300,
+        url: this.getUrl(),
+        data: function (term) {
+          return { q: term, ps: 0 };
         },
-        formatSearching: function () {
-          return t('select2.searching');
-        },
-        formatInputTooShort: function () {
-          return tp('select2.tooShort', 2);
-        },
-        width: '100%',
-        ajax: {
-          quietMillis: 300,
-          url: this.getUrl(),
-          data: function (term) {
-            return { q: term, ps: 0 };
-          },
-          results: function (data) {
-            return {
-              more: false,
-              results: data.languages.map(function (lang) {
-                return { id: lang.key, text: lang.name };
-              })
-            };
-          }
+        results: function (data) {
+          return {
+            more: false,
+            results: data.languages.map(function (lang) {
+              return { id: lang.key, text: lang.name };
+            })
+          };
         }
-      });
-    },
+      }
+    });
+  },
 
-    getValuesWithLabels: function () {
-      var values = this.model.getValues(),
-          source = this.options.app.facets.languages;
-      values.forEach(function (v) {
-        var key = v.val,
-            label = null;
-        if (key) {
-          var item = _.findWhere(source, { key: key });
-          if (item != null) {
-            label = item.name;
-          }
+  getValuesWithLabels: function () {
+    var values = this.model.getValues(),
+        source = this.options.app.facets.languages;
+    values.forEach(function (v) {
+      var key = v.val,
+          label = null;
+      if (key) {
+        var item = _.findWhere(source, { key: key });
+        if (item != null) {
+          label = item.name;
         }
-        v.label = label;
-      });
-      return values;
-    },
-
-    serializeData: function () {
-      return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), {
-        values: this.sortValues(this.getValuesWithLabels())
-      });
-    }
-  });
+      }
+      v.label = label;
+    });
+    return values;
+  },
 
+  serializeData: function () {
+    return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), {
+      values: this.sortValues(this.getValuesWithLabels())
+    });
+  }
 });
+
+
index 454b4e96803e572f4d18211b831019e93305d99f..d826c379940a78b732f55fc567846920a5c48db6 100644 (file)
@@ -1,23 +1,22 @@
-define([
-  './base-facet',
-  '../templates'
-], function (BaseFacet) {
+import _ from 'underscore';
+import BaseFacet from './base-facet';
+import '../templates';
 
-  return BaseFacet.extend({
-    template: Templates['issues-mode-facet'],
+export default BaseFacet.extend({
+  template: Templates['issues-mode-facet'],
 
-    events: {
-      'change [name="issues-page-mode"]': 'onModeChange'
-    },
+  events: {
+    'change [name="issues-page-mode"]': 'onModeChange'
+  },
 
-    onModeChange: function () {
-      var mode = this.$('[name="issues-page-mode"]:checked').val();
-      this.options.app.state.updateFilter({ facetMode: mode });
-    },
-
-    serializeData: function () {
-      return _.extend(this._super(), { mode: this.options.app.state.getFacetMode() });
-    }
-  });
+  onModeChange: function () {
+    var mode = this.$('[name="issues-page-mode"]:checked').val();
+    this.options.app.state.updateFilter({ facetMode: mode });
+  },
 
+  serializeData: function () {
+    return _.extend(this._super(), { mode: this.options.app.state.getFacetMode() });
+  }
 });
+
+
index 96c4a1de07f79623c74142439b9cc0900194064e..ef9507620811aa6fef988f33bd0971601b802c7a 100644 (file)
@@ -1,30 +1,29 @@
-define([
-  './base-facet'
-], function (BaseFacet) {
+import _ from 'underscore';
+import BaseFacet from './base-facet';
 
-  return BaseFacet.extend({
-    getValuesWithLabels: function () {
-      var values = this.model.getValues(),
-          components = this.options.app.facets.components;
-      values.forEach(function (v) {
-        var uuid = v.val,
-            label = uuid;
-        if (uuid) {
-          var component = _.findWhere(components, { uuid: uuid });
-          if (component != null) {
-            label = component.longName;
-          }
+export default BaseFacet.extend({
+  getValuesWithLabels: function () {
+    var values = this.model.getValues(),
+        components = this.options.app.facets.components;
+    values.forEach(function (v) {
+      var uuid = v.val,
+          label = uuid;
+      if (uuid) {
+        var component = _.findWhere(components, { uuid: uuid });
+        if (component != null) {
+          label = component.longName;
         }
-        v.label = label;
-      });
-      return values;
-    },
-
-    serializeData: function () {
-      return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
-        values: this.sortValues(this.getValuesWithLabels())
-      });
-    }
-  });
+      }
+      v.label = label;
+    });
+    return values;
+  },
 
+  serializeData: function () {
+    return _.extend(BaseFacet.prototype.serializeData.apply(this, arguments), {
+      values: this.sortValues(this.getValuesWithLabels())
+    });
+  }
 });
+
+
index 429d9e876c2c9068a951079d4f63003afae8e2cb..ba84cb017a24ed23c74820181abfc81efd90fa32 100644 (file)
@@ -1,83 +1,82 @@
-define([
-  './custom-values-facet'
-], function (CustomValuesFacet) {
+import _ from 'underscore';
+import CustomValuesFacet from './custom-values-facet';
 
-  return CustomValuesFacet.extend({
+export default CustomValuesFacet.extend({
 
-    getUrl: function () {
-      var q = this.options.app.state.get('contextComponentQualifier');
-      if (q === 'VW' || q === 'SVW') {
-        return baseUrl + '/api/components/search';
-      } else {
-        return baseUrl + '/api/resources/search?f=s2&q=TRK&display_uuid=true';
-      }
-    },
+  getUrl: function () {
+    var q = this.options.app.state.get('contextComponentQualifier');
+    if (q === 'VW' || q === 'SVW') {
+      return baseUrl + '/api/components/search';
+    } else {
+      return baseUrl + '/api/resources/search?f=s2&q=TRK&display_uuid=true';
+    }
+  },
 
-    prepareSearch: function () {
-      var q = this.options.app.state.get('contextComponentQualifier');
-      if (q === 'VW' || q === 'SVW') {
-        return this.prepareSearchForViews();
-      } else {
-        return CustomValuesFacet.prototype.prepareSearch.apply(this, arguments);
-      }
-    },
+  prepareSearch: function () {
+    var q = this.options.app.state.get('contextComponentQualifier');
+    if (q === 'VW' || q === 'SVW') {
+      return this.prepareSearchForViews();
+    } else {
+      return CustomValuesFacet.prototype.prepareSearch.apply(this, arguments);
+    }
+  },
 
-    prepareSearchForViews: function () {
-      var componentUuid = this.options.app.state.get('contextComponentUuid');
-      return this.$('.js-custom-value').select2({
-        placeholder: 'Search...',
-        minimumInputLength: 2,
-        allowClear: false,
-        formatNoMatches: function () {
-          return t('select2.noMatches');
-        },
-        formatSearching: function () {
-          return t('select2.searching');
-        },
-        formatInputTooShort: function () {
-          return tp('select2.tooShort', 2);
+  prepareSearchForViews: function () {
+    var componentUuid = this.options.app.state.get('contextComponentUuid');
+    return this.$('.js-custom-value').select2({
+      placeholder: 'Search...',
+      minimumInputLength: 2,
+      allowClear: false,
+      formatNoMatches: function () {
+        return t('select2.noMatches');
+      },
+      formatSearching: function () {
+        return t('select2.searching');
+      },
+      formatInputTooShort: function () {
+        return tp('select2.tooShort', 2);
+      },
+      width: '100%',
+      ajax: {
+        quietMillis: 300,
+        url: this.getUrl(),
+        data: function (term, page) {
+          return { q: term, componentUuid: componentUuid, p: page, ps: 25 };
         },
-        width: '100%',
-        ajax: {
-          quietMillis: 300,
-          url: this.getUrl(),
-          data: function (term, page) {
-            return { q: term, componentUuid: componentUuid, p: page, ps: 25 };
-          },
-          results: function (data) {
-            return {
-              more: data.p * data.ps < data.total,
-              results: data.components.map(function (c) {
-                return { id: c.uuid, text: c.name };
-              })
-            };
-          }
+        results: function (data) {
+          return {
+            more: data.p * data.ps < data.total,
+            results: data.components.map(function (c) {
+              return { id: c.uuid, text: c.name };
+            })
+          };
         }
-      });
-    },
+      }
+    });
+  },
 
-    getValuesWithLabels: function () {
-      var values = this.model.getValues(),
-          projects = this.options.app.facets.components;
-      values.forEach(function (v) {
-        var uuid = v.val,
-            label = '';
-        if (uuid) {
-          var project = _.findWhere(projects, { uuid: uuid });
-          if (project != null) {
-            label = project.longName;
-          }
+  getValuesWithLabels: function () {
+    var values = this.model.getValues(),
+        projects = this.options.app.facets.components;
+    values.forEach(function (v) {
+      var uuid = v.val,
+          label = '';
+      if (uuid) {
+        var project = _.findWhere(projects, { uuid: uuid });
+        if (project != null) {
+          label = project.longName;
         }
-        v.label = label;
-      });
-      return values;
-    },
-
-    serializeData: function () {
-      return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), {
-        values: this.sortValues(this.getValuesWithLabels())
-      });
-    }
-  });
+      }
+      v.label = label;
+    });
+    return values;
+  },
 
+  serializeData: function () {
+    return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), {
+      values: this.sortValues(this.getValuesWithLabels())
+    });
+  }
 });
+
+
index 6340aefe04fd3176a059f7eda26b624881f803ed..240297a469e224dbccf4498e3aed7f3aea99c8c3 100644 (file)
@@ -1,46 +1,45 @@
-define([
-  './custom-values-facet'
-], function (CustomValuesFacet) {
+import _ from 'underscore';
+import CustomValuesFacet from './custom-values-facet';
 
-  return CustomValuesFacet.extend({
-    getUrl: function () {
-      return baseUrl + '/api/users/search';
-    },
+export default CustomValuesFacet.extend({
+  getUrl: function () {
+    return baseUrl + '/api/users/search';
+  },
 
-    prepareAjaxSearch: function () {
-      return {
-        quietMillis: 300,
-        url: this.getUrl(),
-        data: function (term, page) {
-          return { q: term, p: page };
-        },
-        results: window.usersToSelect2
-      };
-    },
+  prepareAjaxSearch: function () {
+    return {
+      quietMillis: 300,
+      url: this.getUrl(),
+      data: function (term, page) {
+        return { q: term, p: page };
+      },
+      results: window.usersToSelect2
+    };
+  },
 
-    getValuesWithLabels: function () {
-      var values = this.model.getValues(),
-          source = this.options.app.facets.users;
-      values.forEach(function (v) {
-        var item, key, label;
-        key = v.val;
-        label = null;
-        if (key) {
-          item = _.findWhere(source, { login: key });
-          if (item != null) {
-            label = item.name;
-          }
+  getValuesWithLabels: function () {
+    var values = this.model.getValues(),
+        source = this.options.app.facets.users;
+    values.forEach(function (v) {
+      var item, key, label;
+      key = v.val;
+      label = null;
+      if (key) {
+        item = _.findWhere(source, { login: key });
+        if (item != null) {
+          label = item.name;
         }
-        v.label = label;
-      });
-      return values;
-    },
-
-    serializeData: function () {
-      return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), {
-        values: this.sortValues(this.getValuesWithLabels())
-      });
-    }
-  });
+      }
+      v.label = label;
+    });
+    return values;
+  },
 
+  serializeData: function () {
+    return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), {
+      values: this.sortValues(this.getValuesWithLabels())
+    });
+  }
 });
+
+
index 75dd3e7828940a59abd1cc458a49ec8a3ee17a59..a15cf51aed7706fec4e706e19d9751db10b859fd 100644 (file)
@@ -1,52 +1,50 @@
-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['issues-resolution-facet'],
 
-  return BaseFacet.extend({
-    template: Templates['issues-resolution-facet'],
-
-    onRender: function () {
-      BaseFacet.prototype.onRender.apply(this, arguments);
-      var value = this.options.app.state.get('query').resolved;
-      if ((value != null) && (!value || value === 'false')) {
-        return this.$('.js-facet').filter('[data-unresolved]').addClass('active');
-      }
-    },
-
-    toggleFacet: function (e) {
-      var unresolved = $(e.currentTarget).is('[data-unresolved]');
-      $(e.currentTarget).toggleClass('active');
-      if (unresolved) {
-        var checked = $(e.currentTarget).is('.active'),
-            value = checked ? 'false' : null;
-        return this.options.app.state.updateFilter({
-          resolved: value,
-          resolutions: null
-        });
-      } else {
-        return this.options.app.state.updateFilter({
-          resolved: null,
-          resolutions: this.getValue()
-        });
-      }
-    },
+  onRender: function () {
+    BaseFacet.prototype.onRender.apply(this, arguments);
+    var value = this.options.app.state.get('query').resolved;
+    if ((value != null) && (!value || value === 'false')) {
+      return this.$('.js-facet').filter('[data-unresolved]').addClass('active');
+    }
+  },
 
-    disable: function () {
+  toggleFacet: function (e) {
+    var unresolved = $(e.currentTarget).is('[data-unresolved]');
+    $(e.currentTarget).toggleClass('active');
+    if (unresolved) {
+      var checked = $(e.currentTarget).is('.active'),
+          value = checked ? 'false' : null;
       return this.options.app.state.updateFilter({
-        resolved: null,
+        resolved: value,
         resolutions: null
       });
-    },
-
-    sortValues: function (values) {
-      var order = ['', 'FIXED', 'FALSE-POSITIVE', 'WONTFIX', 'REMOVED'];
-      return _.sortBy(values, function (v) {
-        return order.indexOf(v.val);
+    } else {
+      return this.options.app.state.updateFilter({
+        resolved: null,
+        resolutions: this.getValue()
       });
     }
-  });
+  },
+
+  disable: function () {
+    return this.options.app.state.updateFilter({
+      resolved: null,
+      resolutions: null
+    });
+  },
 
+  sortValues: function (values) {
+    var order = ['', 'FIXED', 'FALSE-POSITIVE', 'WONTFIX', 'REMOVED'];
+    return _.sortBy(values, function (v) {
+      return order.indexOf(v.val);
+    });
+  }
 });
+
+
index 32e06658d3c1275c990dd4e018ff89f85f9c99d3..8d50f462c0e677556b7dae93d493a22b2696b3d9 100644 (file)
@@ -1,79 +1,78 @@
-define([
-  './custom-values-facet'
-], function (CustomValuesFacet) {
+import _ from 'underscore';
+import CustomValuesFacet from './custom-values-facet';
 
-  return CustomValuesFacet.extend({
-    prepareSearch: function () {
-      var url = baseUrl + '/api/rules/search?f=name,langName',
-          languages = this.options.app.state.get('query').languages;
-      if (languages != null) {
-        url += '&languages=' + languages;
-      }
-      return this.$('.js-custom-value').select2({
-        placeholder: 'Search...',
-        minimumInputLength: 2,
-        allowClear: false,
-        formatNoMatches: function () {
-          return t('select2.noMatches');
-        },
-        formatSearching: function () {
-          return t('select2.searching');
-        },
-        formatInputTooShort: function () {
-          return tp('select2.tooShort', 2);
+export default CustomValuesFacet.extend({
+  prepareSearch: function () {
+    var url = baseUrl + '/api/rules/search?f=name,langName',
+        languages = this.options.app.state.get('query').languages;
+    if (languages != null) {
+      url += '&languages=' + languages;
+    }
+    return this.$('.js-custom-value').select2({
+      placeholder: 'Search...',
+      minimumInputLength: 2,
+      allowClear: false,
+      formatNoMatches: function () {
+        return t('select2.noMatches');
+      },
+      formatSearching: function () {
+        return t('select2.searching');
+      },
+      formatInputTooShort: function () {
+        return tp('select2.tooShort', 2);
+      },
+      width: '100%',
+      ajax: {
+        quietMillis: 300,
+        url: url,
+        data: function (term, page) {
+          return { q: term, p: page };
         },
-        width: '100%',
-        ajax: {
-          quietMillis: 300,
-          url: url,
-          data: function (term, page) {
-            return { q: term, p: page };
-          },
-          results: function (data) {
-            var results;
-            results = data.rules.map(function (rule) {
-              var lang = rule.langName || window.t('manual');
-              return {
-                id: rule.key,
-                text: '(' + lang + ') ' + rule.name
-              };
-            });
+        results: function (data) {
+          var results;
+          results = data.rules.map(function (rule) {
+            var lang = rule.langName || window.t('manual');
             return {
-              more: data.p * data.ps < data.total,
-              results: results
+              id: rule.key,
+              text: '(' + lang + ') ' + rule.name
             };
-          }
+          });
+          return {
+            more: data.p * data.ps < data.total,
+            results: results
+          };
         }
-      });
-    },
+      }
+    });
+  },
 
-    getValuesWithLabels: function () {
-      var values = this.model.getValues(),
-          rules = this.options.app.facets.rules;
-      values.forEach(function (v) {
-        var key = v.val,
-            label = '',
-            extra = '';
-        if (key) {
-          var rule = _.findWhere(rules, { key: key });
-          if (rule != null) {
-            label = rule.name;
-          }
-          if (rule != null) {
-            extra = rule.langName;
-          }
+  getValuesWithLabels: function () {
+    var values = this.model.getValues(),
+        rules = this.options.app.facets.rules;
+    values.forEach(function (v) {
+      var key = v.val,
+          label = '',
+          extra = '';
+      if (key) {
+        var rule = _.findWhere(rules, { key: key });
+        if (rule != null) {
+          label = rule.name;
         }
-        v.label = label;
-        v.extra = extra;
-      });
-      return values;
-    },
-
-    serializeData: function () {
-      return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), {
-        values: this.sortValues(this.getValuesWithLabels())
-      });
-    }
-  });
+        if (rule != null) {
+          extra = rule.langName;
+        }
+      }
+      v.label = label;
+      v.extra = extra;
+    });
+    return values;
+  },
 
+  serializeData: function () {
+    return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), {
+      values: this.sortValues(this.getValuesWithLabels())
+    });
+  }
 });
+
+
index eccaf54668407ae2e4d5de3bb3f6a12f48d6e0cb..e1dc9abe3961ea430155ef9a4923d3d9dff20b39 100644 (file)
@@ -1,17 +1,16 @@
-define([
-  './base-facet',
-  '../templates'
-], function (BaseFacet) {
+import _ from 'underscore';
+import BaseFacet from './base-facet';
+import '../templates';
 
-  return BaseFacet.extend({
-    template: Templates['issues-severity-facet'],
-
-    sortValues: function (values) {
-      var order = ['BLOCKER', 'MINOR', 'CRITICAL', 'INFO', 'MAJOR'];
-      return _.sortBy(values, function (v) {
-        return order.indexOf(v.val);
-      });
-    }
-  });
+export default BaseFacet.extend({
+  template: Templates['issues-severity-facet'],
 
+  sortValues: function (values) {
+    var order = ['BLOCKER', 'MINOR', 'CRITICAL', 'INFO', 'MAJOR'];
+    return _.sortBy(values, function (v) {
+      return order.indexOf(v.val);
+    });
+  }
 });
+
+
index 08db6d508f85b0ece7e327864ead6461ab01b3e8..9293d393cf7ba6f784c3d9dae36ae39fe1252f79 100644 (file)
@@ -1,17 +1,16 @@
-define([
-  './base-facet',
-  '../templates'
-], function (BaseFacet) {
+import _ from 'underscore';
+import BaseFacet from './base-facet';
+import '../templates';
 
-  return BaseFacet.extend({
-    template: Templates['issues-status-facet'],
-
-    sortValues: function (values) {
-      var order = ['OPEN', 'RESOLVED', 'REOPENED', 'CLOSED', 'CONFIRMED'];
-      return _.sortBy(values, function (v) {
-        return order.indexOf(v.val);
-      });
-    }
-  });
+export default BaseFacet.extend({
+  template: Templates['issues-status-facet'],
 
+  sortValues: function (values) {
+    var order = ['OPEN', 'RESOLVED', 'REOPENED', 'CLOSED', 'CONFIRMED'];
+    return _.sortBy(values, function (v) {
+      return order.indexOf(v.val);
+    });
+  }
 });
+
+
index 96a0d85729e2f1b34a9027a708911f09f20ac228..291bcf6f393273b5d69506737c3072abe97afa73 100644 (file)
@@ -1,55 +1,54 @@
-define([
-  './custom-values-facet'
-], function (CustomValuesFacet) {
+import _ from 'underscore';
+import CustomValuesFacet from './custom-values-facet';
 
-  return CustomValuesFacet.extend({
-    prepareSearch: function () {
-      var url = baseUrl + '/api/issues/tags?ps=10',
-          tags = this.options.app.state.get('query').tags;
-      if (tags != null) {
-        url += '&tags=' + tags;
-      }
-      return this.$('.js-custom-value').select2({
-        placeholder: 'Search...',
-        minimumInputLength: 0,
-        allowClear: false,
-        formatNoMatches: function () {
-          return t('select2.noMatches');
-        },
-        formatSearching: function () {
-          return t('select2.searching');
+export default CustomValuesFacet.extend({
+  prepareSearch: function () {
+    var url = baseUrl + '/api/issues/tags?ps=10',
+        tags = this.options.app.state.get('query').tags;
+    if (tags != null) {
+      url += '&tags=' + tags;
+    }
+    return this.$('.js-custom-value').select2({
+      placeholder: 'Search...',
+      minimumInputLength: 0,
+      allowClear: false,
+      formatNoMatches: function () {
+        return t('select2.noMatches');
+      },
+      formatSearching: function () {
+        return t('select2.searching');
+      },
+      width: '100%',
+      ajax: {
+        quietMillis: 300,
+        url: url,
+        data: function (term) {
+          return { q: term, ps: 10 };
         },
-        width: '100%',
-        ajax: {
-          quietMillis: 300,
-          url: url,
-          data: function (term) {
-            return { q: term, ps: 10 };
-          },
-          results: function (data) {
-            var results = data.tags.map(function (tag) {
-              return { id: tag, text: tag };
-            });
-            return { more: false, results: results };
-          }
+        results: function (data) {
+          var results = data.tags.map(function (tag) {
+            return { id: tag, text: tag };
+          });
+          return { more: false, results: results };
         }
-      });
-    },
-
-    getValuesWithLabels: function () {
-      var values = this.model.getValues();
-      values.forEach(function (v) {
-        v.label = v.val;
-        v.extra = '';
-      });
-      return values;
-    },
+      }
+    });
+  },
 
-    serializeData: function () {
-      return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), {
-        values: this.sortValues(this.getValuesWithLabels())
-      });
-    }
-  });
+  getValuesWithLabels: function () {
+    var values = this.model.getValues();
+    values.forEach(function (v) {
+      v.label = v.val;
+      v.extra = '';
+    });
+    return values;
+  },
 
+  serializeData: function () {
+    return _.extend(CustomValuesFacet.prototype.serializeData.apply(this, arguments), {
+      values: this.sortValues(this.getValuesWithLabels())
+    });
+  }
 });
+
+
index c3ea67bd4340531f87fb01c95b8d0df01a563897..18a46bfd0961d450916221c2a759e57ae528403d 100644 (file)
@@ -1,92 +1,91 @@
-define([
-  './templates'
-], function () {
+import $ from 'jquery';
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import './templates';
 
-  var $ = jQuery;
+export default Marionette.ItemView.extend({
+  template: Templates['issues-filters'],
 
-  return Marionette.ItemView.extend({
-    template: Templates['issues-filters'],
+  events: {
+    'click .js-toggle-filters': 'toggleFilters',
+    'click .js-filter': 'applyFilter',
+    'click .js-filter-save-as': 'saveAs',
+    'click .js-filter-save': 'save',
+    'click .js-filter-copy': 'copy',
+    'click .js-filter-edit': 'edit'
+  },
 
-    events: {
-      'click .js-toggle-filters': 'toggleFilters',
-      'click .js-filter': 'applyFilter',
-      'click .js-filter-save-as': 'saveAs',
-      'click .js-filter-save': 'save',
-      'click .js-filter-copy': 'copy',
-      'click .js-filter-edit': 'edit'
-    },
-
-    initialize: function (options) {
-      var that = this;
-      this.listenTo(options.app.state, 'change:filter', this.render);
-      this.listenTo(options.app.state, 'change:changed', this.render);
-      this.listenTo(options.app.filters, 'reset', this.render);
-      window.onSaveAs = window.onCopy = window.onEdit = function (id) {
-        $('#modal').dialog('close');
-        return that.options.app.controller.fetchFilters().done(function () {
-          var filter = that.collection.get(id);
-          return filter.fetch().done(function () {
-            return that.options.app.controller.applyFilter(filter);
-          });
+  initialize: function (options) {
+    var that = this;
+    this.listenTo(options.app.state, 'change:filter', this.render);
+    this.listenTo(options.app.state, 'change:changed', this.render);
+    this.listenTo(options.app.filters, 'reset', this.render);
+    window.onSaveAs = window.onCopy = window.onEdit = function (id) {
+      $('#modal').dialog('close');
+      return that.options.app.controller.fetchFilters().done(function () {
+        var filter = that.collection.get(id);
+        return filter.fetch().done(function () {
+          return that.options.app.controller.applyFilter(filter);
         });
-      };
-    },
-
-    onRender: function () {
-      this.$el.toggleClass('search-navigator-filters-selected', this.options.app.state.has('filter'));
-    },
-
-    toggleFilters: function (e) {
-      var that = this;
-      e.stopPropagation();
-      this.$('.search-navigator-filters-list').toggle();
-      return $('body').on('click.issues-filters', function () {
-        $('body').off('click.issues-filters');
-        return that.$('.search-navigator-filters-list').hide();
       });
-    },
+    };
+  },
 
-    applyFilter: function (e) {
-      var that = this;
-      var id = $(e.currentTarget).data('id'),
-          filter = this.collection.get(id);
-      return that.options.app.controller.applyFilter(filter);
+  onRender: function () {
+    this.$el.toggleClass('search-navigator-filters-selected', this.options.app.state.has('filter'));
+  },
 
-    },
+  toggleFilters: function (e) {
+    var that = this;
+    e.stopPropagation();
+    this.$('.search-navigator-filters-list').toggle();
+    return $('body').on('click.issues-filters', function () {
+      $('body').off('click.issues-filters');
+      return that.$('.search-navigator-filters-list').hide();
+    });
+  },
 
-    saveAs: function () {
-      var query = this.options.app.controller.getQuery('&'),
-          url = baseUrl + '/issues/save_as_form?' + query;
-      window.openModalWindow(url, {});
-    },
+  applyFilter: function (e) {
+    var that = this;
+    var id = $(e.currentTarget).data('id'),
+        filter = this.collection.get(id);
+    return that.options.app.controller.applyFilter(filter);
 
-    save: function () {
-      var that = this;
-      var query = this.options.app.controller.getQuery('&'),
-          url = baseUrl + '/issues/save/' + (this.options.app.state.get('filter').id) + '?' + query;
-      return $.post(url).done(function () {
-        return that.options.app.state.set({ changed: false });
-      });
-    },
+  },
 
-    copy: function () {
-      var url = baseUrl + '/issues/copy_form/' + (this.options.app.state.get('filter').id);
-      window.openModalWindow(url, {});
-    },
+  saveAs: function () {
+    var query = this.options.app.controller.getQuery('&'),
+        url = baseUrl + '/issues/save_as_form?' + query;
+    window.openModalWindow(url, {});
+  },
 
-    edit: function () {
-      var url = baseUrl + '/issues/edit_form/' + (this.options.app.state.get('filter').id);
-      window.openModalWindow(url, {});
-    },
+  save: function () {
+    var that = this;
+    var query = this.options.app.controller.getQuery('&'),
+        url = baseUrl + '/issues/save/' + (this.options.app.state.get('filter').id) + '?' + query;
+    return $.post(url).done(function () {
+      return that.options.app.state.set({ changed: false });
+    });
+  },
 
-    serializeData: function () {
-      var filter = this.options.app.state.get('filter');
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        state: this.options.app.state.toJSON(),
-        filter: filter != null ? filter.toJSON() : null,
-        currentUser: window.SS.user
-      });
-    }
-  });
+  copy: function () {
+    var url = baseUrl + '/issues/copy_form/' + (this.options.app.state.get('filter').id);
+    window.openModalWindow(url, {});
+  },
+
+  edit: function () {
+    var url = baseUrl + '/issues/edit_form/' + (this.options.app.state.get('filter').id);
+    window.openModalWindow(url, {});
+  },
 
+  serializeData: function () {
+    var filter = this.options.app.state.get('filter');
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      state: this.options.app.state.toJSON(),
+      filter: filter != null ? filter.toJSON() : null,
+      currentUser: window.SS.user
+    });
+  }
 });
+
+
index b89d39ccef2ce256cfa2674b4ee85f646dcc16f0..5cef0500dedb3d79594e83d9431280f6756de342 100644 (file)
@@ -1,8 +1,6 @@
-define(function () {
+Handlebars.registerHelper('formatFacetValue', function (value, facetMode) {
+  var formatter = facetMode === 'debt' ? 'SHORT_WORK_DUR' : 'SHORT_INT';
+  return window.formatMeasure(value, formatter);
+});
 
-  Handlebars.registerHelper('formatFacetValue', function (value, facetMode) {
-    var formatter = facetMode === 'debt' ? 'SHORT_WORK_DUR' : 'SHORT_INT';
-    return window.formatMeasure(value, formatter);
-  });
 
-});
index 28a6a86e212efab5898d45171f74861b12d5da2c..980a0ecededf47c7938c03b74ca8f89e1fe5c2f2 100644 (file)
@@ -1,25 +1,23 @@
-define([
-  'components/common/action-options-view',
-  './templates'
-], function (ActionOptionsView) {
+import $ from 'jquery';
+import _ from 'underscore';
+import ActionOptionsView from 'components/common/action-options-view';
+import './templates';
 
-  var $ = jQuery;
+export default ActionOptionsView.extend({
+  template: Templates['issues-issue-filter-form'],
 
-  return ActionOptionsView.extend({
-    template: Templates['issues-issue-filter-form'],
+  selectOption: function (e) {
+    var property = $(e.currentTarget).data('property'),
+        value = $(e.currentTarget).data('value');
+    this.trigger('select', property, value);
+    this._super(e);
+  },
 
-    selectOption: function (e) {
-      var property = $(e.currentTarget).data('property'),
-          value = $(e.currentTarget).data('value');
-      this.trigger('select', property, value);
-      this._super(e);
-    },
+  serializeData: function () {
+    return _.extend(this._super(), {
+      s: this.model.get('severity')
+    });
+  }
+});
 
-    serializeData: function () {
-      return _.extend(this._super(), {
-        s: this.model.get('severity')
-      });
-    }
-  });
 
-});
index 5dbbcaf1139b3a2135e51444b1b4dbbc11e5dd50..7b6c7b8366e9e53b3168bdec25f98a7a8d0982f4 100644 (file)
@@ -1,55 +1,55 @@
-define([
-  './templates'
-], function () {
-
-  var $ = jQuery;
-  return Marionette.LayoutView.extend({
-    template: Templates['issues-layout'],
-
-    regions: {
-      filtersRegion: '.search-navigator-filters',
-      facetsRegion: '.search-navigator-facets',
-      workspaceHeaderRegion: '.search-navigator-workspace-header',
-      workspaceListRegion: '.search-navigator-workspace-list',
-      workspaceComponentViewerRegion: '.issues-workspace-component-viewer',
-      workspaceHomeRegion: '.issues-workspace-home'
-    },
-
-    onRender: function () {
-      if (this.options.app.state.get('isContext')) {
-        this.$(this.filtersRegion.el).addClass('hidden');
-      }
-      this.$('.search-navigator').addClass('sticky');
-      var top = this.$('.search-navigator').offset().top;
-      this.$('.search-navigator-workspace-header').css({ top: top });
-      this.$('.search-navigator-side').css({ top: top }).isolatedScroll();
-    },
-
-    showSpinner: function (region) {
-      return this[region].show(new Marionette.ItemView({
-        template: _.template('<i class="spinner"></i>')
-      }));
-    },
-
-    showComponentViewer: function () {
-      this.scroll = $(window).scrollTop();
-      this.$('.issues').addClass('issues-extended-view');
-    },
-
-    hideComponentViewer: function () {
-      this.$('.issues').removeClass('issues-extended-view');
-      if (this.scroll != null) {
-        $(window).scrollTop(this.scroll);
-      }
-    },
-
-    showHomePage: function () {
-      this.$('.issues').addClass('issues-home-view');
-    },
-
-    hideHomePage: function () {
-      this.$('.issues').removeClass('issues-home-view');
+import $ from 'jquery';
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import './templates';
+
+export default Marionette.LayoutView.extend({
+  template: Templates['issues-layout'],
+
+  regions: {
+    filtersRegion: '.search-navigator-filters',
+    facetsRegion: '.search-navigator-facets',
+    workspaceHeaderRegion: '.search-navigator-workspace-header',
+    workspaceListRegion: '.search-navigator-workspace-list',
+    workspaceComponentViewerRegion: '.issues-workspace-component-viewer',
+    workspaceHomeRegion: '.issues-workspace-home'
+  },
+
+  onRender: function () {
+    if (this.options.app.state.get('isContext')) {
+      this.$(this.filtersRegion.el).addClass('hidden');
     }
-  });
+    this.$('.search-navigator').addClass('sticky');
+    var top = this.$('.search-navigator').offset().top;
+    this.$('.search-navigator-workspace-header').css({ top: top });
+    this.$('.search-navigator-side').css({ top: top }).isolatedScroll();
+  },
+
+  showSpinner: function (region) {
+    return this[region].show(new Marionette.ItemView({
+      template: _.template('<i class="spinner"></i>')
+    }));
+  },
+
+  showComponentViewer: function () {
+    this.scroll = $(window).scrollTop();
+    this.$('.issues').addClass('issues-extended-view');
+  },
+
+  hideComponentViewer: function () {
+    this.$('.issues').removeClass('issues-extended-view');
+    if (this.scroll != null) {
+      $(window).scrollTop(this.scroll);
+    }
+  },
+
+  showHomePage: function () {
+    this.$('.issues').addClass('issues-home-view');
+  },
 
+  hideHomePage: function () {
+    this.$('.issues').removeClass('issues-home-view');
+  }
 });
+
+
index aa31f8ab267b93941924d0d1449fe60a202a7b27..14f9746938d51a3816d84b679430f16a9efb5704 100644 (file)
@@ -1,17 +1,17 @@
-define(function () {
+import Backbone from 'backbone';
 
-  return Backbone.Model.extend({
-    url: function () {
-      return baseUrl + '/api/issue_filters/show/' + this.id;
-    },
+export default Backbone.Model.extend({
+  url: function () {
+    return baseUrl + '/api/issue_filters/show/' + this.id;
+  },
 
-    parse: function (r) {
-      if (r.filter != null) {
-        return r.filter;
-      } else {
-        return r;
-      }
+  parse: function (r) {
+    if (r.filter != null) {
+      return r.filter;
+    } else {
+      return r;
     }
-  });
-
+  }
 });
+
+
index 34a46690bfe9757b1f3a7c8cb9c02a04763ad623..e24ef5c146e34ae4bb766043dbd5e2e8aa36506c 100644 (file)
@@ -1,17 +1,16 @@
-define([
-  './filter'
-], function (Filter) {
+import Backbone from 'backbone';
+import Filter from './filter';
 
-  return Backbone.Collection.extend({
-    model: Filter,
+export default Backbone.Collection.extend({
+  model: Filter,
 
-    url: function () {
-      return window.baseUrl + '/api/issue_filters/search';
-    },
-
-    parse: function (r) {
-      return r.issueFilters;
-    }
-  });
+  url: function () {
+    return window.baseUrl + '/api/issue_filters/search';
+  },
 
+  parse: function (r) {
+    return r.issueFilters;
+  }
 });
+
+
index 6266434fa237f0651758d70b82b8afda1c6ac1b8..f466243ad638fce840da294e9aed559b8bd61112 100644 (file)
@@ -1,15 +1,13 @@
-define([
-  'components/issue/models/issue'
-], function (Issue) {
-
-  return Issue.extend({
-    reset: function (attrs, options) {
-      var keepFields = ['index', 'selected', 'comments'];
-      keepFields.forEach(function (field) {
-        attrs[field] = this.get(field);
-      }.bind(this));
-      return this._super(attrs, options);
-    }
-  });
+import Issue from 'components/issue/models/issue';
 
+export default Issue.extend({
+  reset: function (attrs, options) {
+    var keepFields = ['index', 'selected', 'comments'];
+    keepFields.forEach(function (field) {
+      attrs[field] = this.get(field);
+    }.bind(this));
+    return this._super(attrs, options);
+  }
 });
+
+
index 2b57399a5b58a936142c99efc630ed14d594159f..0ec79f448dc31ab551d45a56b8598a9d9ea1200d 100644 (file)
@@ -1,84 +1,84 @@
-define([
-  './issue'
-], function (Issue) {
+import _ from 'underscore';
+import Backbone from 'backbone';
+import Issue from './issue';
 
-  return Backbone.Collection.extend({
-    model: Issue,
+export default Backbone.Collection.extend({
+  model: Issue,
 
-    url: function () {
-      return baseUrl + '/api/issues/search';
-    },
+  url: function () {
+    return baseUrl + '/api/issues/search';
+  },
 
-    _injectRelational: function (issue, source, baseField, lookupField) {
-      var baseValue = issue[baseField];
-      if (baseValue != null && _.size(source)) {
-        var lookupValue = _.find(source, function (candidate) {
-          return candidate[lookupField] === baseValue;
-        });
-        if (lookupValue != null) {
-          Object.keys(lookupValue).forEach(function (key) {
-            var newKey = baseField + key.charAt(0).toUpperCase() + key.slice(1);
-            issue[newKey] = lookupValue[key];
-          });
-        }
-      }
-      return issue;
-    },
-
-    _injectCommentsRelational: function (issue, users) {
-      if (issue.comments) {
-        var that = this;
-        var newComments = issue.comments.map(function (comment) {
-          var newComment = _.extend({}, comment, { author: comment.login });
-          delete newComment.login;
-          newComment = that._injectRelational(newComment, users, 'author', 'login');
-          return newComment;
+  _injectRelational: function (issue, source, baseField, lookupField) {
+    var baseValue = issue[baseField];
+    if (baseValue != null && _.size(source)) {
+      var lookupValue = _.find(source, function (candidate) {
+        return candidate[lookupField] === baseValue;
+      });
+      if (lookupValue != null) {
+        Object.keys(lookupValue).forEach(function (key) {
+          var newKey = baseField + key.charAt(0).toUpperCase() + key.slice(1);
+          issue[newKey] = lookupValue[key];
         });
-        issue = _.extend({}, issue, { comments: newComments });
       }
-      return issue;
-    },
-
-    _prepareClosed: function (issue) {
-      if (issue.status === 'CLOSED') {
-        issue.flows = [];
-        delete issue.textRange;
-      }
-      return issue;
-    },
+    }
+    return issue;
+  },
 
-    parseIssues: function (r) {
+  _injectCommentsRelational: function (issue, users) {
+    if (issue.comments) {
       var that = this;
-      return r.issues.map(function (issue, index) {
-        _.extend(issue, { index: index });
-        issue = that._injectRelational(issue, r.components, 'component', 'key');
-        issue = that._injectRelational(issue, r.components, 'project', 'key');
-        issue = that._injectRelational(issue, r.components, 'subProject', 'key');
-        issue = that._injectRelational(issue, r.rules, 'rule', 'key');
-        issue = that._injectRelational(issue, r.users, 'assignee', 'login');
-        issue = that._injectRelational(issue, r.users, 'reporter', 'login');
-        issue = that._injectRelational(issue, r.actionPlans, 'actionPlan', 'key');
-        issue = that._injectCommentsRelational(issue, r.users);
-        issue = that._prepareClosed(issue);
-        return issue;
+      var newComments = issue.comments.map(function (comment) {
+        var newComment = _.extend({}, comment, { author: comment.login });
+        delete newComment.login;
+        newComment = that._injectRelational(newComment, users, 'author', 'login');
+        return newComment;
       });
-    },
-
-    setIndex: function () {
-      return this.forEach(function (issue, index) {
-        return issue.set({ index: index });
-      });
-    },
+      issue = _.extend({}, issue, { comments: newComments });
+    }
+    return issue;
+  },
 
-    selectByKeys: function (keys) {
-      var that = this;
-      keys.forEach(function (key) {
-        var issue = that.get(key);
-        if (issue) {
-          issue.set({ selected: true });
-        }
-      });
+  _prepareClosed: function (issue) {
+    if (issue.status === 'CLOSED') {
+      issue.flows = [];
+      delete issue.textRange;
     }
-  });
+    return issue;
+  },
+
+  parseIssues: function (r) {
+    var that = this;
+    return r.issues.map(function (issue, index) {
+      _.extend(issue, { index: index });
+      issue = that._injectRelational(issue, r.components, 'component', 'key');
+      issue = that._injectRelational(issue, r.components, 'project', 'key');
+      issue = that._injectRelational(issue, r.components, 'subProject', 'key');
+      issue = that._injectRelational(issue, r.rules, 'rule', 'key');
+      issue = that._injectRelational(issue, r.users, 'assignee', 'login');
+      issue = that._injectRelational(issue, r.users, 'reporter', 'login');
+      issue = that._injectRelational(issue, r.actionPlans, 'actionPlan', 'key');
+      issue = that._injectCommentsRelational(issue, r.users);
+      issue = that._prepareClosed(issue);
+      return issue;
+    });
+  },
+
+  setIndex: function () {
+    return this.forEach(function (issue, index) {
+      return issue.set({ index: index });
+    });
+  },
 
+  selectByKeys: function (keys) {
+    var that = this;
+    keys.forEach(function (key) {
+      var issue = that.get(key);
+      if (issue) {
+        issue.set({ selected: true });
+      }
+    });
+  }
 });
+
+
index 246d27c24caa533c13fb250556145bcbf64a92ef..f49d2566dfcf762b4417dd6c0a8df573e956d622 100644 (file)
@@ -1,68 +1,67 @@
-define([
-  'components/navigator/models/state'
-], function (State) {
+import _ from 'underscore';
+import State from 'components/navigator/models/state';
 
-  return State.extend({
-    defaults: {
-      page: 1,
-      maxResultsReached: false,
-      query: {},
-      facets: ['facetMode', 'severities', 'resolutions'],
-      isContext: false,
-      allFacets: [
-        'facetMode',
-        'issues',
-        'severities',
-        'resolutions',
-        'statuses',
-        'createdAt',
-        'rules',
-        'tags',
-        'projectUuids',
-        'moduleUuids',
-        'directories',
-        'fileUuids',
-        'assignees',
-        'reporters',
-        'authors',
-        'languages',
-        'actionPlans'
-      ],
-      facetsFromServer: [
-        'severities',
-        'statuses',
-        'resolutions',
-        'actionPlans',
-        'projectUuids',
-        'directories',
-        'rules',
-        'moduleUuids',
-        'tags',
-        'assignees',
-        'reporters',
-        'authors',
-        'fileUuids',
-        'languages',
-        'createdAt'
-      ],
-      transform: {
-        'resolved': 'resolutions',
-        'assigned': 'assignees',
-        'planned': 'actionPlans',
-        'createdBefore': 'createdAt',
-        'createdAfter': 'createdAt',
-        'createdInLast': 'createdAt'
-      }
-    },
-
-    getFacetMode: function () {
-      var query = this.get('query');
-      return query.facetMode || 'count';
-    },
-
-    toJSON: function () {
-      return _.extend({ facetMode: this.getFacetMode() }, this.attributes);
+export default State.extend({
+  defaults: {
+    page: 1,
+    maxResultsReached: false,
+    query: {},
+    facets: ['facetMode', 'severities', 'resolutions'],
+    isContext: false,
+    allFacets: [
+      'facetMode',
+      'issues',
+      'severities',
+      'resolutions',
+      'statuses',
+      'createdAt',
+      'rules',
+      'tags',
+      'projectUuids',
+      'moduleUuids',
+      'directories',
+      'fileUuids',
+      'assignees',
+      'reporters',
+      'authors',
+      'languages',
+      'actionPlans'
+    ],
+    facetsFromServer: [
+      'severities',
+      'statuses',
+      'resolutions',
+      'actionPlans',
+      'projectUuids',
+      'directories',
+      'rules',
+      'moduleUuids',
+      'tags',
+      'assignees',
+      'reporters',
+      'authors',
+      'fileUuids',
+      'languages',
+      'createdAt'
+    ],
+    transform: {
+      'resolved': 'resolutions',
+      'assigned': 'assignees',
+      'planned': 'actionPlans',
+      'createdBefore': 'createdAt',
+      'createdAfter': 'createdAt',
+      'createdInLast': 'createdAt'
     }
-  });
+  },
+
+  getFacetMode: function () {
+    var query = this.get('query');
+    return query.facetMode || 'count';
+  },
 
+  toJSON: function () {
+    return _.extend({ facetMode: this.getFacetMode() }, this.attributes);
+  }
 });
+
+
index 519689e8f40c2eccac02dd67b78e93640a138872..6cb6622da6e70a5c1e2fc16818bd8a6d5e90b486 100644 (file)
@@ -1,45 +1,43 @@
-define([
-  'components/navigator/router'
-], function (Router) {
+import Router from 'components/navigator/router';
 
-  return Router.extend({
-    routes: {
-      '': 'home',
-      ':query': 'index'
-    },
+export default Router.extend({
+  routes: {
+    '': 'home',
+    ':query': 'index'
+  },
 
-    initialize: function (options) {
-      Router.prototype.initialize.apply(this, arguments);
-      this.listenTo(options.app.state, 'change:filter', this.updateRoute);
-    },
+  initialize: function (options) {
+    Router.prototype.initialize.apply(this, arguments);
+    this.listenTo(options.app.state, 'change:filter', this.updateRoute);
+  },
 
-    home: function () {
-      if (this.options.app.state.get('isContext')) {
-        return this.navigate('resolved=false', { trigger: true, replace: true });
-      } else {
-        return this.options.app.controller.showHomePage();
-      }
-    },
-
-    index: function (query) {
-      var that = this;
-      query = this.options.app.controller.parseQuery(query);
-      if (query.id != null) {
-        var filter = this.options.app.filters.get(query.id);
-        delete query.id;
-        return filter.fetch().done(function () {
-          if (Object.keys(query).length > 0) {
-            that.options.app.controller.applyFilter(filter, true);
-            that.options.app.state.setQuery(query);
-            that.options.app.state.set({ changed: true });
-          } else {
-            that.options.app.controller.applyFilter(filter);
-          }
-        });
-      } else {
-        return this.options.app.state.setQuery(query);
-      }
+  home: function () {
+    if (this.options.app.state.get('isContext')) {
+      return this.navigate('resolved=false', { trigger: true, replace: true });
+    } else {
+      return this.options.app.controller.showHomePage();
     }
-  });
+  },
 
+  index: function (query) {
+    var that = this;
+    query = this.options.app.controller.parseQuery(query);
+    if (query.id != null) {
+      var filter = this.options.app.filters.get(query.id);
+      delete query.id;
+      return filter.fetch().done(function () {
+        if (Object.keys(query).length > 0) {
+          that.options.app.controller.applyFilter(filter, true);
+          that.options.app.state.setQuery(query);
+          that.options.app.state.set({ changed: true });
+        } else {
+          that.options.app.controller.applyFilter(filter);
+        }
+      });
+    } else {
+      return this.options.app.state.setQuery(query);
+    }
+  }
 });
+
+
index 928b4b42c5fc5bbb43f95f48479a4805bfb77497..dba0e384c5a9ee91d2a26943f0303ed638a6d923 100644 (file)
-define([
-  'components/navigator/workspace-header-view',
-  './templates'
-], function (WorkspaceHeaderView) {
-
-  var $ = jQuery;
-
-  return WorkspaceHeaderView.extend({
-    template: Templates['issues-workspace-header'],
-
-    events: function () {
-      return _.extend(WorkspaceHeaderView.prototype.events.apply(this, arguments), {
-        'click .js-selection': 'onSelectionClick',
-        'click .js-back': 'returnToList',
-        'click .js-new-search': 'newSearch',
-        'click .js-bulk-change-selected': 'onBulkChangeSelectedClick'
-      });
-    },
-
-    initialize: function () {
-      WorkspaceHeaderView.prototype.initialize.apply(this, arguments);
-      this._onBulkIssues = window.onBulkIssues;
-      window.onBulkIssues = _.bind(this.afterBulkChange, this);
-    },
-
-    onDestroy: function () {
+import $ from 'jquery';
+import _ from 'underscore';
+import WorkspaceHeaderView from 'components/navigator/workspace-header-view';
+import './templates';
+
+export default WorkspaceHeaderView.extend({
+  template: Templates['issues-workspace-header'],
+
+  events: function () {
+    return _.extend(WorkspaceHeaderView.prototype.events.apply(this, arguments), {
+      'click .js-selection': 'onSelectionClick',
+      'click .js-back': 'returnToList',
+      'click .js-new-search': 'newSearch',
+      'click .js-bulk-change-selected': 'onBulkChangeSelectedClick'
+    });
+  },
+
+  initialize: function () {
+    WorkspaceHeaderView.prototype.initialize.apply(this, arguments);
+    this._onBulkIssues = window.onBulkIssues;
+    window.onBulkIssues = _.bind(this.afterBulkChange, this);
+  },
+
+  onDestroy: function () {
+    this._super();
+    window.onBulkIssues = this._onBulkIssues;
+  },
+
+  onSelectionClick: function (e) {
+    e.preventDefault();
+    this.toggleSelection();
+  },
+
+  onBulkChangeSelectedClick: function (e) {
+    e.preventDefault();
+    this.bulkChangeSelected();
+  },
+
+  afterBulkChange: function () {
+    var that = this;
+    $('#modal').dialog('close');
+    var selectedIndex = this.options.app.state.get('selectedIndex');
+    var selectedKeys = _.pluck(this.options.app.list.where({ selected: true }), 'id');
+    this.options.app.controller.fetchList().done(function () {
+      that.options.app.state.set({ selectedIndex: selectedIndex });
+      that.options.app.list.selectByKeys(selectedKeys);
+    });
+  },
+
+  render: function () {
+    if (!this._suppressUpdate) {
       this._super();
-      window.onBulkIssues = this._onBulkIssues;
-    },
-
-    onSelectionClick: function (e) {
-      e.preventDefault();
-      this.toggleSelection();
-    },
-
-    onBulkChangeSelectedClick: function (e) {
-      e.preventDefault();
-      this.bulkChangeSelected();
-    },
-
-    afterBulkChange: function () {
-      var that = this;
-      $('#modal').dialog('close');
-      var selectedIndex = this.options.app.state.get('selectedIndex');
-      var selectedKeys = _.pluck(this.options.app.list.where({ selected: true }), 'id');
-      this.options.app.controller.fetchList().done(function () {
-        that.options.app.state.set({ selectedIndex: selectedIndex });
-        that.options.app.list.selectByKeys(selectedKeys);
-      });
-    },
-
-    render: function () {
-      if (!this._suppressUpdate) {
-        this._super();
-      }
-    },
-
-    toggleSelection: function () {
-      this._suppressUpdate = true;
-      var selectedCount = this.options.app.list.where({ selected: true }).length,
-          someSelected = selectedCount > 0;
-      return someSelected ? this.selectNone() : this.selectAll();
-    },
-
-    selectNone: function () {
-      this.options.app.list.where({ selected: true }).forEach(function (issue) {
-        issue.set({ selected: false });
-      });
-      this._suppressUpdate = false;
-      this.render();
-    },
-
-    selectAll: function () {
-      this.options.app.list.forEach(function (issue) {
-        issue.set({ selected: true });
-      });
-      this._suppressUpdate = false;
-      this.render();
-    },
-
-    returnToList: function () {
-      this.options.app.controller.closeComponentViewer();
-    },
-
-    newSearch: function () {
-      this.options.app.controller.newSearch();
-    },
-
-    bulkChange: function () {
-      var query = this.options.app.controller.getQuery('&', true),
-          url = baseUrl + '/issues/bulk_change_form?' + query;
-      window.openModalWindow(url, {});
-    },
-
-    bulkChangeSelected: function () {
-      var selected = this.options.app.list.where({ selected: true }),
-          selectedKeys = _.first(_.pluck(selected, 'id'), 200),
-          query = 'issues=' + selectedKeys.join(),
-          url = baseUrl + '/issues/bulk_change_form?' + query;
-      window.openModalWindow(url, {});
-    },
-
-    serializeData: function () {
-      var issuesCount = this.options.app.list.length,
-          selectedCount = this.options.app.list.where({ selected: true }).length,
-          allSelected = issuesCount > 0 && issuesCount === selectedCount,
-          someSelected = !allSelected && selectedCount > 0;
-      return _.extend(this._super(), {
-        selectedCount: selectedCount,
-        allSelected: allSelected,
-        someSelected: someSelected
-      });
     }
-  });
-
+  },
+
+  toggleSelection: function () {
+    this._suppressUpdate = true;
+    var selectedCount = this.options.app.list.where({ selected: true }).length,
+        someSelected = selectedCount > 0;
+    return someSelected ? this.selectNone() : this.selectAll();
+  },
+
+  selectNone: function () {
+    this.options.app.list.where({ selected: true }).forEach(function (issue) {
+      issue.set({ selected: false });
+    });
+    this._suppressUpdate = false;
+    this.render();
+  },
+
+  selectAll: function () {
+    this.options.app.list.forEach(function (issue) {
+      issue.set({ selected: true });
+    });
+    this._suppressUpdate = false;
+    this.render();
+  },
+
+  returnToList: function () {
+    this.options.app.controller.closeComponentViewer();
+  },
+
+  newSearch: function () {
+    this.options.app.controller.newSearch();
+  },
+
+  bulkChange: function () {
+    var query = this.options.app.controller.getQuery('&', true),
+        url = baseUrl + '/issues/bulk_change_form?' + query;
+    window.openModalWindow(url, {});
+  },
+
+  bulkChangeSelected: function () {
+    var selected = this.options.app.list.where({ selected: true }),
+        selectedKeys = _.first(_.pluck(selected, 'id'), 200),
+        query = 'issues=' + selectedKeys.join(),
+        url = baseUrl + '/issues/bulk_change_form?' + query;
+    window.openModalWindow(url, {});
+  },
+
+  serializeData: function () {
+    var issuesCount = this.options.app.list.length,
+        selectedCount = this.options.app.list.where({ selected: true }).length,
+        allSelected = issuesCount > 0 && issuesCount === selectedCount,
+        someSelected = !allSelected && selectedCount > 0;
+    return _.extend(this._super(), {
+      selectedCount: selectedCount,
+      allSelected: allSelected,
+      someSelected: someSelected
+    });
+  }
 });
+
+
index aff1c52366fac29027241709d8b3e7b3c9eb7ea3..44efc574890aab5b9b04a7e338d7111d59c65561 100644 (file)
@@ -1,13 +1,12 @@
-define([
-  './templates'
-], function () {
+import Marionette from 'backbone.marionette';
+import './templates';
 
-  Handlebars.registerHelper('issueFilterHomeLink', function (id) {
-    return baseUrl + '/issues/search#id=' + id;
-  });
-
-  return Marionette.ItemView.extend({
-    template: Templates['issues-workspace-home']
-  });
+Handlebars.registerHelper('issueFilterHomeLink', function (id) {
+  return baseUrl + '/issues/search#id=' + id;
+});
 
+export default Marionette.ItemView.extend({
+  template: Templates['issues-workspace-home']
 });
+
+
index ada57f15a2d84aa1cacb433e9cf6fd746db12b4f..b40c68d0ab69d95fbcd876ba480c1d2d6091004d 100644 (file)
@@ -1,11 +1,11 @@
-define(function () {
+import Marionette from 'backbone.marionette';
 
-  return Marionette.ItemView.extend({
-    className: 'search-navigator-no-results',
-
-    template: function () {
-      return t('issue_filter.no_issues');
-    }
-  });
+export default Marionette.ItemView.extend({
+  className: 'search-navigator-no-results',
 
+  template: function () {
+    return t('issue_filter.no_issues');
+  }
 });
+
+
index 28a6eb7e433188b9e325c9b4d7e0da3d6309c2a5..585beb1afce3f6265127e6249b84390d11749720 100644 (file)
-define([
-  'components/issue/issue-view',
-  './issue-filter-view',
-  './templates'
-], function (IssueView, IssueFilterView) {
-
-  var $ = jQuery,
-      SHOULD_NULL = {
-        any: ['issues'],
-        resolutions: ['resolved'],
-        resolved: ['resolutions'],
-        assignees: ['assigned'],
-        assigned: ['assignees'],
-        actionPlans: ['planned'],
-        planned: ['actionPlans']
-      };
-
-  return IssueView.extend({
-    checkboxTemplate: Templates['issues-issue-checkbox'],
-    filterTemplate: Templates['issues-issue-filter'],
-
-    events: function () {
-      return _.extend(IssueView.prototype.events.apply(this, arguments), {
-        'click': 'selectCurrent',
-        'dblclick': 'openComponentViewer',
-        'click .js-issue-navigate': 'openComponentViewer',
-        'click .js-issue-filter': 'onIssueFilterClick',
-        'click .js-toggle': 'onIssueToggle'
-      });
-    },
-
-    initialize: function (options) {
-      IssueView.prototype.initialize.apply(this, arguments);
-      this.listenTo(options.app.state, 'change:selectedIndex', this.select);
-    },
-
-    onRender: function () {
-      IssueView.prototype.onRender.apply(this, arguments);
-      this.select();
-      this.addFilterSelect();
-      this.addCheckbox();
-      this.$el.addClass('issue-navigate-right');
-      if (this.options.app.state.get('canBulkChange')) {
-        this.$el.addClass('issue-with-checkbox');
-      }
-    },
-
-    onIssueFilterClick: function (e) {
-      var that = this;
-      e.preventDefault();
-      e.stopPropagation();
-      $('body').click();
-      this.popup = new IssueFilterView({
-        triggerEl: $(e.currentTarget),
-        bottomRight: true,
-        model: this.model
+import $ from 'jquery';
+import _ from 'underscore';
+import IssueView from 'components/issue/issue-view';
+import IssueFilterView from './issue-filter-view';
+import './templates';
+
+var SHOULD_NULL = {
+      any: ['issues'],
+      resolutions: ['resolved'],
+      resolved: ['resolutions'],
+      assignees: ['assigned'],
+      assigned: ['assignees'],
+      actionPlans: ['planned'],
+      planned: ['actionPlans']
+    };
+
+export default IssueView.extend({
+  checkboxTemplate: Templates['issues-issue-checkbox'],
+  filterTemplate: Templates['issues-issue-filter'],
+
+  events: function () {
+    return _.extend(IssueView.prototype.events.apply(this, arguments), {
+      'click': 'selectCurrent',
+      'dblclick': 'openComponentViewer',
+      'click .js-issue-navigate': 'openComponentViewer',
+      'click .js-issue-filter': 'onIssueFilterClick',
+      'click .js-toggle': 'onIssueToggle'
+    });
+  },
+
+  initialize: function (options) {
+    IssueView.prototype.initialize.apply(this, arguments);
+    this.listenTo(options.app.state, 'change:selectedIndex', this.select);
+  },
+
+  onRender: function () {
+    IssueView.prototype.onRender.apply(this, arguments);
+    this.select();
+    this.addFilterSelect();
+    this.addCheckbox();
+    this.$el.addClass('issue-navigate-right');
+    if (this.options.app.state.get('canBulkChange')) {
+      this.$el.addClass('issue-with-checkbox');
+    }
+  },
+
+  onIssueFilterClick: function (e) {
+    var that = this;
+    e.preventDefault();
+    e.stopPropagation();
+    $('body').click();
+    this.popup = new IssueFilterView({
+      triggerEl: $(e.currentTarget),
+      bottomRight: true,
+      model: this.model
+    });
+    this.popup.on('select', function (property, value) {
+      var obj;
+      obj = {};
+      obj[property] = '' + value;
+      SHOULD_NULL.any.forEach(function (p) {
+        obj[p] = null;
       });
-      this.popup.on('select', function (property, value) {
-        var obj;
-        obj = {};
-        obj[property] = '' + value;
-        SHOULD_NULL.any.forEach(function (p) {
+      if (SHOULD_NULL[property] != null) {
+        SHOULD_NULL[property].forEach(function (p) {
           obj[p] = null;
         });
-        if (SHOULD_NULL[property] != null) {
-          SHOULD_NULL[property].forEach(function (p) {
-            obj[p] = null;
-          });
-        }
-        that.options.app.state.updateFilter(obj);
-        that.popup.destroy();
-      });
-      this.popup.render();
-    },
-
-    onIssueToggle: function (e) {
-      e.preventDefault();
-      this.model.set({ selected: !this.model.get('selected') });
-      var selected = this.model.collection.where({ selected: true }).length;
-      this.options.app.state.set({ selected: selected });
-    },
-
-    addFilterSelect: function () {
-      this.$('.issue-table-meta-cell-first')
-          .find('.issue-meta-list')
-          .append(this.filterTemplate(this.model.toJSON()));
-    },
-
-    addCheckbox: function () {
-      this.$el.append(this.checkboxTemplate(this.model.toJSON()));
-    },
-
-    select: function () {
-      var selected = this.model.get('index') === this.options.app.state.get('selectedIndex');
-      this.$el.toggleClass('selected', selected);
-    },
-
-    selectCurrent: function () {
-      this.options.app.state.set({ selectedIndex: this.model.get('index') });
-    },
-
-    resetIssue: function (options) {
-      var that = this;
-      var key = this.model.get('key'),
-          componentUuid = this.model.get('componentUuid'),
-          index = this.model.get('index'),
-          selected = this.model.get('selected');
-      this.model.reset({
-        key: key,
-        componentUuid: componentUuid,
-        index: index,
-        selected: selected
-      }, { silent: true });
-      return this.model.fetch(options).done(function () {
-        return that.trigger('reset');
-      });
-    },
-
-    openComponentViewer: function () {
-      this.options.app.state.set({ selectedIndex: this.model.get('index') });
-      if (this.options.app.state.has('component')) {
-        return this.options.app.controller.closeComponentViewer();
-      } else {
-        return this.options.app.controller.showComponentViewer(this.model);
       }
-    },
+      that.options.app.state.updateFilter(obj);
+      that.popup.destroy();
+    });
+    this.popup.render();
+  },
 
-    serializeData: function () {
-      return _.extend(IssueView.prototype.serializeData.apply(this, arguments), {
-        showComponent: true
-      });
+  onIssueToggle: function (e) {
+    e.preventDefault();
+    this.model.set({ selected: !this.model.get('selected') });
+    var selected = this.model.collection.where({ selected: true }).length;
+    this.options.app.state.set({ selected: selected });
+  },
+
+  addFilterSelect: function () {
+    this.$('.issue-table-meta-cell-first')
+        .find('.issue-meta-list')
+        .append(this.filterTemplate(this.model.toJSON()));
+  },
+
+  addCheckbox: function () {
+    this.$el.append(this.checkboxTemplate(this.model.toJSON()));
+  },
+
+  select: function () {
+    var selected = this.model.get('index') === this.options.app.state.get('selectedIndex');
+    this.$el.toggleClass('selected', selected);
+  },
+
+  selectCurrent: function () {
+    this.options.app.state.set({ selectedIndex: this.model.get('index') });
+  },
+
+  resetIssue: function (options) {
+    var that = this;
+    var key = this.model.get('key'),
+        componentUuid = this.model.get('componentUuid'),
+        index = this.model.get('index'),
+        selected = this.model.get('selected');
+    this.model.reset({
+      key: key,
+      componentUuid: componentUuid,
+      index: index,
+      selected: selected
+    }, { silent: true });
+    return this.model.fetch(options).done(function () {
+      return that.trigger('reset');
+    });
+  },
+
+  openComponentViewer: function () {
+    this.options.app.state.set({ selectedIndex: this.model.get('index') });
+    if (this.options.app.state.has('component')) {
+      return this.options.app.controller.closeComponentViewer();
+    } else {
+      return this.options.app.controller.showComponentViewer(this.model);
     }
-  });
+  },
 
+  serializeData: function () {
+    return _.extend(IssueView.prototype.serializeData.apply(this, arguments), {
+      showComponent: true
+    });
+  }
 });
+
+
index 30a192d0b0196d59259ff4b1c9ef31d9033cf896..3a4d2be2599f522479d442c6a78d2303c60b2962 100644 (file)
-define([
-  'components/navigator/workspace-list-view',
-  './workspace-list-item-view',
-  './workspace-list-empty-view',
-  './templates'
-], function (WorkspaceListView, IssueView, EmptyView) {
+import $ from 'jquery';
+import WorkspaceListView from 'components/navigator/workspace-list-view';
+import IssueView from './workspace-list-item-view';
+import EmptyView from './workspace-list-empty-view';
+import './templates';
 
-  var $ = jQuery,
-      COMPONENT_HEIGHT = 29,
-      BOTTOM_OFFSET = 10;
+var COMPONENT_HEIGHT = 29,
+    BOTTOM_OFFSET = 10;
 
-  return WorkspaceListView.extend({
-    template: Templates['issues-workspace-list'],
-    componentTemplate: Templates['issues-workspace-list-component'],
-    childView: IssueView,
-    childViewContainer: '.js-list',
-    emptyView: EmptyView,
+export default WorkspaceListView.extend({
+  template: Templates['issues-workspace-list'],
+  componentTemplate: Templates['issues-workspace-list-component'],
+  childView: IssueView,
+  childViewContainer: '.js-list',
+  emptyView: EmptyView,
 
-    bindShortcuts: function () {
-      var that = this;
-      var doAction = function (action) {
-        var selectedIssue = that.collection.at(that.options.app.state.get('selectedIndex'));
-        if (selectedIssue == null) {
-          return;
-        }
-        var selectedIssueView = that.children.findByModel(selectedIssue);
-        selectedIssueView.$('.js-issue-' + action).click();
-      };
-      WorkspaceListView.prototype.bindShortcuts.apply(this, arguments);
-      key('right', 'list', function () {
-        var selectedIssue = that.collection.at(that.options.app.state.get('selectedIndex'));
-        that.options.app.controller.showComponentViewer(selectedIssue);
-        return false;
-      });
-      key('space', 'list', function () {
-        var selectedIssue = that.collection.at(that.options.app.state.get('selectedIndex'));
-        selectedIssue.set({ selected: !selectedIssue.get('selected') });
-        return false;
-      });
-      key('f', 'list', function () {
-        return doAction('transition');
-      });
-      key('a', 'list', function () {
-        return doAction('assign');
-      });
-      key('m', 'list', function () {
-        return doAction('assign-to-me');
-      });
-      key('p', 'list', function () {
-        return doAction('plan');
-      });
-      key('i', 'list', function () {
-        return doAction('set-severity');
-      });
-      key('c', 'list', function () {
-        return doAction('comment');
-      });
-      return key('t', 'list', function () {
-        return doAction('edit-tags');
-      });
-    },
-
-    scrollTo: function () {
-      var selectedIssue = this.collection.at(this.options.app.state.get('selectedIndex'));
+  bindShortcuts: function () {
+    var that = this;
+    var doAction = function (action) {
+      var selectedIssue = that.collection.at(that.options.app.state.get('selectedIndex'));
       if (selectedIssue == null) {
         return;
       }
-      var selectedIssueView = this.children.findByModel(selectedIssue),
-          parentTopOffset = this.$el.offset().top,
-          viewTop = selectedIssueView.$el.offset().top - parentTopOffset;
-      if (selectedIssueView.$el.prev().is('.issues-workspace-list-component')) {
-        viewTop -= COMPONENT_HEIGHT;
-      }
-      var viewBottom = selectedIssueView.$el.offset().top + selectedIssueView.$el.outerHeight() + BOTTOM_OFFSET,
-          windowTop = $(window).scrollTop(),
-          windowBottom = windowTop + $(window).height();
-      if (viewTop < windowTop) {
-        $(window).scrollTop(viewTop);
-      }
-      if (viewBottom > windowBottom) {
-        $(window).scrollTop($(window).scrollTop() - windowBottom + viewBottom);
-      }
-    },
+      var selectedIssueView = that.children.findByModel(selectedIssue);
+      selectedIssueView.$('.js-issue-' + action).click();
+    };
+    WorkspaceListView.prototype.bindShortcuts.apply(this, arguments);
+    key('right', 'list', function () {
+      var selectedIssue = that.collection.at(that.options.app.state.get('selectedIndex'));
+      that.options.app.controller.showComponentViewer(selectedIssue);
+      return false;
+    });
+    key('space', 'list', function () {
+      var selectedIssue = that.collection.at(that.options.app.state.get('selectedIndex'));
+      selectedIssue.set({ selected: !selectedIssue.get('selected') });
+      return false;
+    });
+    key('f', 'list', function () {
+      return doAction('transition');
+    });
+    key('a', 'list', function () {
+      return doAction('assign');
+    });
+    key('m', 'list', function () {
+      return doAction('assign-to-me');
+    });
+    key('p', 'list', function () {
+      return doAction('plan');
+    });
+    key('i', 'list', function () {
+      return doAction('set-severity');
+    });
+    key('c', 'list', function () {
+      return doAction('comment');
+    });
+    return key('t', 'list', function () {
+      return doAction('edit-tags');
+    });
+  },
 
-    attachHtml: function (compositeView, childView, index) {
-      var $container = this.getChildViewContainer(compositeView),
-          model = this.collection.at(index);
-      if (model != null) {
-        var prev = this.collection.at(index - 1),
-            putComponent = prev == null;
-        if (prev != null) {
-          var fullComponent = [model.get('project'), model.get('component')].join(' '),
-              fullPrevComponent = [prev.get('project'), prev.get('component')].join(' ');
-          if (fullComponent !== fullPrevComponent) {
-            putComponent = true;
-          }
-        }
-        if (putComponent) {
-          $container.append(this.componentTemplate(model.toJSON()));
+  scrollTo: function () {
+    var selectedIssue = this.collection.at(this.options.app.state.get('selectedIndex'));
+    if (selectedIssue == null) {
+      return;
+    }
+    var selectedIssueView = this.children.findByModel(selectedIssue),
+        parentTopOffset = this.$el.offset().top,
+        viewTop = selectedIssueView.$el.offset().top - parentTopOffset;
+    if (selectedIssueView.$el.prev().is('.issues-workspace-list-component')) {
+      viewTop -= COMPONENT_HEIGHT;
+    }
+    var viewBottom = selectedIssueView.$el.offset().top + selectedIssueView.$el.outerHeight() + BOTTOM_OFFSET,
+        windowTop = $(window).scrollTop(),
+        windowBottom = windowTop + $(window).height();
+    if (viewTop < windowTop) {
+      $(window).scrollTop(viewTop);
+    }
+    if (viewBottom > windowBottom) {
+      $(window).scrollTop($(window).scrollTop() - windowBottom + viewBottom);
+    }
+  },
+
+  attachHtml: function (compositeView, childView, index) {
+    var $container = this.getChildViewContainer(compositeView),
+        model = this.collection.at(index);
+    if (model != null) {
+      var prev = this.collection.at(index - 1),
+          putComponent = prev == null;
+      if (prev != null) {
+        var fullComponent = [model.get('project'), model.get('component')].join(' '),
+            fullPrevComponent = [prev.get('project'), prev.get('component')].join(' ');
+        if (fullComponent !== fullPrevComponent) {
+          putComponent = true;
         }
       }
-      $container.append(childView.el);
-    },
-
-    destroyChildren: function () {
-      WorkspaceListView.prototype.destroyChildren.apply(this, arguments);
-      this.$('.issues-workspace-list-component').remove();
+      if (putComponent) {
+        $container.append(this.componentTemplate(model.toJSON()));
+      }
     }
-  });
+    $container.append(childView.el);
+  },
 
+  destroyChildren: function () {
+    WorkspaceListView.prototype.destroyChildren.apply(this, arguments);
+    this.$('.issues-workspace-list-component').remove();
+  }
 });
+
+
index cc7b016bef09e1704d609edc5a8eaef4578633eb..b089a9cb57465c37ec7bb5c67a77c093f5a646a3 100644 (file)
@@ -1,17 +1,18 @@
-define([
-  './main-view'
-], function (MainView) {
+import _ from 'underscore';
+import Backbone from 'backbone';
+import Marionette from 'backbone.marionette';
+import MainView from './main-view';
 
-  var App = new Marionette.Application();
+var App = new Marionette.Application();
 
-  App.on('start', function (options) {
-    var viewOptions = _.extend(options, {
-      model: new Backbone.Model()
-    });
-    var mainView = new MainView(viewOptions);
-    mainView.render().refresh();
+App.on('start', function (options) {
+  var viewOptions = _.extend(options, {
+    model: new Backbone.Model()
   });
+  var mainView = new MainView(viewOptions);
+  mainView.render().refresh();
+});
+
+export default App;
 
-  return App;
 
-});
index 47b380973da72d655da4b2444f2d314c7ed9a7eb..3e9825adfa018bf68a427c50309e970c88c1e3f8 100644 (file)
@@ -1,62 +1,62 @@
-define([
-  './templates'
-], function () {
-
-  var $ = jQuery;
-
-  return Marionette.ItemView.extend({
-    template: Templates['maintenance-main'],
-
-    events: {
-      'click #start-migration': 'startMigration'
-    },
-
-    initialize: function () {
-      var that = this;
-      this.requestOptions = {
-        type: 'GET',
-        url: baseUrl + '/api/system/' + (this.options.setup ? 'db_migration_status' : 'status')
-      };
-      setInterval(function () {
-        that.refresh();
-      }, 5000);
-    },
-
-    refresh: function () {
-      var that = this;
-      return Backbone.ajax(this.requestOptions).done(function (r) {
-        that.model.set(r);
-        that.render();
-        if (that.model.get('state') === 'MIGRATION_SUCCEEDED') {
-          that.goHome();
-        }
-      });
-    },
-
-    startMigration: function () {
-      var that = this;
-      Backbone.ajax({
-        url: baseUrl + '/api/system/migrate_db',
-        type: 'POST'
-      }).done(function (r) {
-        that.model.set(r);
-        that.render();
-      });
-    },
-
-    onRender: function () {
-      $('.page-simple').toggleClass('panel-warning', this.model.get('state') === 'MIGRATION_REQUIRED');
-    },
-
-    goHome: function () {
-      setInterval(function () {
-        window.location = baseUrl + '/';
-      }, 2500);
-    },
-
-    serializeData: function () {
-      return _.extend(this._super(), { setup: this.options.setup });
-    }
-  });
-
+import $ from 'jquery';
+import _ from 'underscore';
+import Backbone from 'backbone';
+import Marionette from 'backbone.marionette';
+import './templates';
+
+export default Marionette.ItemView.extend({
+  template: Templates['maintenance-main'],
+
+  events: {
+    'click #start-migration': 'startMigration'
+  },
+
+  initialize: function () {
+    var that = this;
+    this.requestOptions = {
+      type: 'GET',
+      url: baseUrl + '/api/system/' + (this.options.setup ? 'db_migration_status' : 'status')
+    };
+    setInterval(function () {
+      that.refresh();
+    }, 5000);
+  },
+
+  refresh: function () {
+    var that = this;
+    return Backbone.ajax(this.requestOptions).done(function (r) {
+      that.model.set(r);
+      that.render();
+      if (that.model.get('state') === 'MIGRATION_SUCCEEDED') {
+        that.goHome();
+      }
+    });
+  },
+
+  startMigration: function () {
+    var that = this;
+    Backbone.ajax({
+      url: baseUrl + '/api/system/migrate_db',
+      type: 'POST'
+    }).done(function (r) {
+      that.model.set(r);
+      that.render();
+    });
+  },
+
+  onRender: function () {
+    $('.page-simple').toggleClass('panel-warning', this.model.get('state') === 'MIGRATION_REQUIRED');
+  },
+
+  goHome: function () {
+    setInterval(function () {
+      window.location = baseUrl + '/';
+    }, 2500);
+  },
+
+  serializeData: function () {
+    return _.extend(this._super(), { setup: this.options.setup });
+  }
 });
+
+
index 46cf48a8fc520e9b6affbbe1f95602ce9b7a377a..86ed29e5207e32533e84f8b51e7ec19fced21b6b 100644 (file)
@@ -1,11 +1,12 @@
-define(['./markdown-help-view'], function (MarkdownView) {
+import Marionette from 'backbone.marionette';
+import MarkdownView from './markdown-help-view';
 
-  var App = new Marionette.Application();
+var App = new Marionette.Application();
 
-  App.on('start', function (options) {
-    new MarkdownView({ el: options.el }).render();
-  });
+App.on('start', function (options) {
+  new MarkdownView({ el: options.el }).render();
+});
+
+export default App;
 
-  return App;
 
-});
index 321dd2c40b0dcb8f977cc7ca791a4fb2cef6b729..c7db13a5b0997fe4a64f507ce5ce0756a5011485 100644 (file)
@@ -1,7 +1,8 @@
-define(['./templates'], function () {
-
-  return Marionette.ItemView.extend({
-    template: Templates['markdown-help']
-  });
+import Marionette from 'backbone.marionette';
+import './templates';
 
+export default Marionette.ItemView.extend({
+  template: Templates['markdown-help']
 });
+
+
index f382eae97735dff9841967457fe3af12b1d45b38..a3b533d0958972cdc4ee126b92a644bdc41d02e7 100644 (file)
-define([
-      './measures-filter-bar',
-      'components/navigator/filters/base-filters',
-      'components/navigator/filters/checkbox-filters',
-      'components/navigator/filters/choice-filters',
-      'components/navigator/filters/ajax-select-filters',
-      'components/navigator/filters/favorite-filters',
-      'components/navigator/filters/range-filters',
-      'components/navigator/filters/string-filters',
-      'components/navigator/filters/metric-filters'
-    ],
-    function (FilterBar, BaseFilters, CheckboxFilterView, ChoiceFilters, AjaxSelectFilters, FavoriteFilters,
-              RangeFilters, StringFilterView, MetricFilterView) {
-
-      var NavigatorApp = new Marionette.Application(),
-          init = function () {
-            NavigatorApp.addRegions({ filtersRegion: '.navigator-filters' });
-
-            this.filters = new BaseFilters.Filters();
-
-            if (_.isObject(window.SS.favorites)) {
-              this.filters.add([
-                new BaseFilters.Filter({
-                  type: FavoriteFilters.FavoriteFilterView,
-                  enabled: true,
-                  optional: false,
-                  choices: window.SS.favorites,
-                  favoriteUrl: '/measures/filter',
-                  manageUrl: '/measures/manage'
-                })
-              ]);
-            }
-
-            this.filters.add([
-              new BaseFilters.Filter({
-                name: window.SS.phrases.components,
-                property: 'qualifiers[]',
-                type: ChoiceFilters.ChoiceFilterView,
-                enabled: true,
-                optional: false,
-                choices: window.SS.qualifiers,
-                defaultValue: window.SS.phrases.any
-              }),
-
-              new BaseFilters.Filter({
-                name: window.SS.phrases.componentsOf,
-                property: 'base',
-                type: AjaxSelectFilters.ComponentFilterView,
-                multiple: false,
-                enabled: false,
-                optional: true
-              }),
-
-              new BaseFilters.Filter({
-                name: window.SS.phrases.favoritesOnly,
-                property: 'onFavourites',
-                type: CheckboxFilterView,
-                enabled: false,
-                optional: true
-              }),
-
-              new BaseFilters.Filter({
-                name: window.SS.phrases.date,
-                propertyFrom: 'fromDate',
-                propertyTo: 'toDate',
-                type: RangeFilters.DateRangeFilterView,
-                enabled: false,
-                optional: true
-              }),
-
-              new BaseFilters.Filter({
-                name: window.SS.phrases.keyContains,
-                property: 'keySearch',
-                type: StringFilterView,
-                enabled: false,
-                optional: true
-              })
-            ]);
-
-            this.filters.add([
-              new BaseFilters.Filter({
-                name: window.SS.phrases.lastAnalysis,
-                propertyFrom: 'ageMinDays',
-                propertyTo: 'ageMaxDays',
-                type: RangeFilters.RangeFilterView,
-                placeholder: window.SS.phrases.days,
-                enabled: false,
-                optional: true
-              }),
-
-              new BaseFilters.Filter({
-                name: window.SS.phrases.metric,
-                property: 'c3',
-                type: MetricFilterView,
-                metrics: window.SS.metrics,
-                periods: window.SS.metricPeriods,
-                operations: { 'eq': '=', 'lt': '<', 'lte': '≤', 'gt': '>', 'gte': '≥' },
-                enabled: false,
-                optional: true
-              }),
-
-              new BaseFilters.Filter({
-                name: window.SS.phrases.metric,
-                property: 'c2',
-                type: MetricFilterView,
-                metrics: window.SS.metrics,
-                periods: window.SS.metricPeriods,
-                operations: { 'eq': '=', 'lt': '<', 'lte': '≤', 'gt': '>', 'gte': '≥' },
-                enabled: false,
-                optional: true
-              }),
-
-              new BaseFilters.Filter({
-                name: window.SS.phrases.metric,
-                property: 'c1',
-                type: MetricFilterView,
-                metrics: window.SS.metrics,
-                periods: window.SS.metricPeriods,
-                operations: { 'eq': '=', 'lt': '<', 'lte': '≤', 'gt': '>', 'gte': '≥' },
-                enabled: false,
-                optional: true
-              }),
-
-              new BaseFilters.Filter({
-                name: window.SS.phrases.nameContains,
-                property: 'nameSearch',
-                type: StringFilterView,
-                enabled: false,
-                optional: true
-              }),
-
-              new BaseFilters.Filter({
-                name: window.SS.phrases.alert,
-                property: 'alertLevels[]',
-                type: ChoiceFilters.ChoiceFilterView,
-                enabled: false,
-                optional: true,
-                choices: {
-                  'error': window.SS.phrases.error,
-                  'warn': window.SS.phrases.warning,
-                  'ok': window.SS.phrases.ok
-                }
-              })
-            ]);
-
-            this.filterBarView = new FilterBar({
-              collection: this.filters,
-              extra: {
-                sort: '',
-                asc: false
-              }
-            });
-
-            this.filtersRegion.show(this.filterBarView);
-
-            if (window.queryParams) {
-              NavigatorApp.filterBarView.restoreFromQuery(window.queryParams);
-            }
-            key.setScope('list');
-          };
-
-      NavigatorApp.on('start', function () {
-        init.call(NavigatorApp);
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import FilterBar from './measures-filter-bar';
+import BaseFilters from 'components/navigator/filters/base-filters';
+import CheckboxFilterView from 'components/navigator/filters/checkbox-filters';
+import ChoiceFilters from 'components/navigator/filters/choice-filters';
+import AjaxSelectFilters from 'components/navigator/filters/ajax-select-filters';
+import FavoriteFilters from 'components/navigator/filters/favorite-filters';
+import RangeFilters from 'components/navigator/filters/range-filters';
+import StringFilterView from 'components/navigator/filters/string-filters';
+import MetricFilterView from 'components/navigator/filters/metric-filters';
+
+var NavigatorApp = new Marionette.Application(),
+    init = function () {
+      NavigatorApp.addRegions({ filtersRegion: '.navigator-filters' });
+
+      this.filters = new BaseFilters.Filters();
+
+      if (_.isObject(window.SS.favorites)) {
+        this.filters.add([
+          new BaseFilters.Filter({
+            type: FavoriteFilters.FavoriteFilterView,
+            enabled: true,
+            optional: false,
+            choices: window.SS.favorites,
+            favoriteUrl: '/measures/filter',
+            manageUrl: '/measures/manage'
+          })
+        ]);
+      }
+
+      this.filters.add([
+        new BaseFilters.Filter({
+          name: window.SS.phrases.components,
+          property: 'qualifiers[]',
+          type: ChoiceFilters.ChoiceFilterView,
+          enabled: true,
+          optional: false,
+          choices: window.SS.qualifiers,
+          defaultValue: window.SS.phrases.any
+        }),
+
+        new BaseFilters.Filter({
+          name: window.SS.phrases.componentsOf,
+          property: 'base',
+          type: AjaxSelectFilters.ComponentFilterView,
+          multiple: false,
+          enabled: false,
+          optional: true
+        }),
+
+        new BaseFilters.Filter({
+          name: window.SS.phrases.favoritesOnly,
+          property: 'onFavourites',
+          type: CheckboxFilterView,
+          enabled: false,
+          optional: true
+        }),
+
+        new BaseFilters.Filter({
+          name: window.SS.phrases.date,
+          propertyFrom: 'fromDate',
+          propertyTo: 'toDate',
+          type: RangeFilters.DateRangeFilterView,
+          enabled: false,
+          optional: true
+        }),
+
+        new BaseFilters.Filter({
+          name: window.SS.phrases.keyContains,
+          property: 'keySearch',
+          type: StringFilterView,
+          enabled: false,
+          optional: true
+        })
+      ]);
+
+      this.filters.add([
+        new BaseFilters.Filter({
+          name: window.SS.phrases.lastAnalysis,
+          propertyFrom: 'ageMinDays',
+          propertyTo: 'ageMaxDays',
+          type: RangeFilters.RangeFilterView,
+          placeholder: window.SS.phrases.days,
+          enabled: false,
+          optional: true
+        }),
+
+        new BaseFilters.Filter({
+          name: window.SS.phrases.metric,
+          property: 'c3',
+          type: MetricFilterView,
+          metrics: window.SS.metrics,
+          periods: window.SS.metricPeriods,
+          operations: { 'eq': '=', 'lt': '<', 'lte': '≤', 'gt': '>', 'gte': '≥' },
+          enabled: false,
+          optional: true
+        }),
+
+        new BaseFilters.Filter({
+          name: window.SS.phrases.metric,
+          property: 'c2',
+          type: MetricFilterView,
+          metrics: window.SS.metrics,
+          periods: window.SS.metricPeriods,
+          operations: { 'eq': '=', 'lt': '<', 'lte': '≤', 'gt': '>', 'gte': '≥' },
+          enabled: false,
+          optional: true
+        }),
+
+        new BaseFilters.Filter({
+          name: window.SS.phrases.metric,
+          property: 'c1',
+          type: MetricFilterView,
+          metrics: window.SS.metrics,
+          periods: window.SS.metricPeriods,
+          operations: { 'eq': '=', 'lt': '<', 'lte': '≤', 'gt': '>', 'gte': '≥' },
+          enabled: false,
+          optional: true
+        }),
+
+        new BaseFilters.Filter({
+          name: window.SS.phrases.nameContains,
+          property: 'nameSearch',
+          type: StringFilterView,
+          enabled: false,
+          optional: true
+        }),
+
+        new BaseFilters.Filter({
+          name: window.SS.phrases.alert,
+          property: 'alertLevels[]',
+          type: ChoiceFilters.ChoiceFilterView,
+          enabled: false,
+          optional: true,
+          choices: {
+            'error': window.SS.phrases.error,
+            'warn': window.SS.phrases.warning,
+            'ok': window.SS.phrases.ok
+          }
+        })
+      ]);
+
+      this.filterBarView = new FilterBar({
+        collection: this.filters,
+        extra: {
+          sort: '',
+          asc: false
+        }
       });
 
-      return NavigatorApp;
+      this.filtersRegion.show(this.filterBarView);
 
-    });
+      if (window.queryParams) {
+        NavigatorApp.filterBarView.restoreFromQuery(window.queryParams);
+      }
+      key.setScope('list');
+    };
+
+NavigatorApp.on('start', function () {
+  init.call(NavigatorApp);
+});
+
+export default NavigatorApp;
index a14400664f31026f35df0df6b3bf11455a2eedf3..acd0c0dea3a788dd45d94bc5573781b8c94d62d4 100644 (file)
@@ -1,9 +1,10 @@
-define(['components/navigator/filters/filter-bar'], function (FilterBarView) {
-
-  return FilterBarView.extend({
-    template: function () {
-      return jQuery('#filter-bar-template').html();
-    }
-  });
+import $ from 'jquery';
+import FilterBarView from 'components/navigator/filters/filter-bar';
 
+export default FilterBarView.extend({
+  template: function () {
+    return $('#filter-bar-template').html();
+  }
 });
+
+
index 4e42d95a09da7b04a093c8a74d1a427c40c8c199..42eecceff9aaf88c61e3fe731886b915d89f684f 100644 (file)
@@ -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;
 
-});
index 9e2145fbee7237aefddaf8e745bc5f9b7722efd8..68681d93822cfd405893981249629e34710fc4c3 100644 (file)
@@ -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();
+    });
+  }
 });
+
+
index 8719b9fdb3a998d6affe68615b7804d61df645d2..cef043b54b8dadfaa2b117172fe77db85dd6a8cd 100644 (file)
@@ -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);
+    });
+  }
 });
+
+
index 03e66f715b668c30527eb29718b644b87012fc65..7396e4da8ff4f106bc6a29a9b273eb76f587822d 100644 (file)
@@ -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
+    });
+  }
 
 });
+
+
index 78a9b0da0d053789061574497698c891e12b8e30..37cdc7dc8b47fdd6791f074dfec2c20a1b17e354 100644 (file)
@@ -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();
+  }
 });
+
+
index 9575307d96f0c40fb9673a822d9fce854b758c20..6d1a560cf897d4f3d88e9b657ee32cb3629b1433 100644 (file)
@@ -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'
+  }
 });
+
+
index 932dfd6d35fa589b97881deed7bfad708266418f..a48c0a11e7a26a737f2d114dbbdd0e3ba4e340ad 100644 (file)
@@ -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()
+    });
+  }
 });
+
+
index c6989e3b7b38e4b82e672168c499014dd2fc7e28..3a56e9c9650c629874137900dbaa87c55e246c7b 100644 (file)
@@ -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();
+  }
 });
+
+
index b015c65d966b176b0d4bdb784f65c7dab5cd96ce..e5a0f9f1e96e353ceda9532980946b3eeb69b772 100644 (file)
@@ -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
+    };
+  }
 });
+
+
index cb160c882d00570fc6ada8a0eaddc6f6097fa944..82bb67c20fef3564e898a0e029eeea9c685acaba 100644 (file)
@@ -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);
+  }
 });
+
+
index 393ebe3c2b15c1c9f2e576c75511df171e7b097e..44fa17c8227c8aaf5a80503fb1e91a143082a09b 100644 (file)
@@ -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;
+  }
 
 });
+
+
index 3dfea4a584ea960613879001d0dd6a5deb7af168..8ccce5ce7d025935841a5284caf351709799d5a2 100644 (file)
@@ -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);
+    });
+  }
 });
+
+
index ae1564630863f5003887ffe77d89dfe9d8d2b5dc..fd55fa80097cf29c6fb5aefac9f21866d1096155 100644 (file)
@@ -1,3 +1,4 @@
+import _ from 'underscore';
 import React from 'react';
 import DashboardNameMixin from '../dashboard-name-mixin';
 import LinksMixin from '../links-mixin';
index 855482981d9e7750f9417ead8d7dc8c1922bfd63..29d93a87b64ba68a630d14d26147d36c527a9364 100644 (file)
@@ -1,11 +1,10 @@
+import $ from 'jquery';
 import React from 'react';
 import ComponentNavFavorite from './component-nav-favorite';
 import ComponentNavBreadcrumbs from './component-nav-breadcrumbs';
 import ComponentNavMeta from './component-nav-meta';
 import ComponentNavMenu from './component-nav-menu';
 
-let $ = jQuery;
-
 export default React.createClass({
   getInitialState() {
     return { component: {}, conf: {} };
index 157ba7b25f79f41eff48a4569fcaba2ae17193fe..48fadbfe6eb75da86871d61e464b1d65f3a2035a 100644 (file)
@@ -1,8 +1,7 @@
+import Backbone from 'backbone';
 import React from 'react';
 import SearchView from './search-view';
 
-let $ = jQuery;
-
 function contains (root, node) {
   while (node) {
     if (node === root) {
index 908033c73bf384ced6ee567aa0dfe1fe8007ceb9..ebbdc07db5c2def4c3c50035bfe376aa85c88880 100644 (file)
@@ -1,3 +1,4 @@
+import $ from 'jquery';
 import React from 'react';
 import GlobalNavBranding from './global-nav-branding';
 import GlobalNavMenu from './global-nav-menu';
@@ -5,8 +6,6 @@ import GlobalNavUser from './global-nav-user';
 import GlobalNavSearch from './global-nav-search';
 import ShortcutsHelpView from './shortcuts-help-view';
 
-let $ = jQuery;
-
 export default React.createClass({
   getInitialState() {
     return this.props;
index e38787aba66995688bf0bb0c276ce40e29177685..12e170da60be30810e296be482bdcefa4fb36194 100644 (file)
-define([
-  'components/common/selectable-collection-view',
-  '../templates'
-], function (SelectableCollectionView) {
-
-  var $ = jQuery,
-
-      SearchItemView = Marionette.ItemView.extend({
-        tagName: 'li',
-        template: Templates['nav-search-item'],
-
-        select: function () {
-          this.$el.addClass('active');
-        },
-
-        deselect: function () {
-          this.$el.removeClass('active');
-        },
-
-        submit: function () {
-          this.$('a')[0].click();
-        },
-
-        serializeData: function () {
-          return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-            index: this.options.index
-          });
-        }
-      }),
-
-      SearchEmptyView = Marionette.ItemView.extend({
-        tagName: 'li',
-        template: Templates['nav-search-empty']
-      }),
-
-      SearchResultsView = SelectableCollectionView.extend({
-        className: 'menu',
-        tagName: 'ul',
-        childView: SearchItemView,
-        emptyView: SearchEmptyView
-      });
-
-  return Marionette.LayoutView.extend({
-    className: 'navbar-search',
-    tagName: 'form',
-    template: Templates['nav-search'],
-
-    regions: {
-      resultsRegion: '.js-search-results'
-    },
-
-    events: {
-      'submit': 'onSubmit',
-      'keydown .js-search-input': 'onKeyDown',
-      'keyup .js-search-input': 'debouncedOnKeyUp'
-    },
-
-    initialize: function () {
-      var that = this;
-      this.results = new Backbone.Collection();
-      this.favorite = [];
-      if (window.SS.user) {
-        this.fetchFavorite().always(function () {
-          that.resetResultsToDefault();
+import $ from 'jquery';
+import _ from 'underscore';
+import Backbone from 'backbone';
+import Marionette from 'backbone.marionette';
+import SelectableCollectionView from 'components/common/selectable-collection-view';
+import '../templates';
+
+var SearchItemView = Marionette.ItemView.extend({
+      tagName: 'li',
+      template: Templates['nav-search-item'],
+
+      select: function () {
+        this.$el.addClass('active');
+      },
+
+      deselect: function () {
+        this.$el.removeClass('active');
+      },
+
+      submit: function () {
+        this.$('a')[0].click();
+      },
+
+      serializeData: function () {
+        return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+          index: this.options.index
         });
-      } else {
-        this.resetResultsToDefault();
-      }
-      this.resultsView = new SearchResultsView({ collection: this.results });
-      this.debouncedOnKeyUp = _.debounce(this.onKeyUp, 400);
-      this._bufferedValue = '';
-    },
-
-    onRender: function () {
-      var that = this;
-      this.resultsRegion.show(this.resultsView);
-      setTimeout(function () {
-        that.$('.js-search-input').focus();
-      }, 0);
-    },
-
-    onKeyDown: function (e) {
-      if (e.keyCode === 38) {
-        this.resultsView.selectPrev();
-        return false;
-      }
-      if (e.keyCode === 40) {
-        this.resultsView.selectNext();
-        return false;
-      }
-      if (e.keyCode === 13) {
-        this.resultsView.submitCurrent();
-        return false;
-      }
-      if (e.keyCode === 27) {
-        this.options.hide();
-        return false;
       }
-    },
-
-    onKeyUp: function () {
-      var value = this.$('.js-search-input').val();
-      if (value === this._bufferedValue) {
-        return;
-      }
-      this._bufferedValue = this.$('.js-search-input').val();
-      if (this.searchRequest != null && this.searchRequest.abort != null) {
-        this.searchRequest.abort();
-      }
-      this.searchRequest = this.search(value);
-    },
-
-    onSubmit: function () {
+    }),
+
+    SearchEmptyView = Marionette.ItemView.extend({
+      tagName: 'li',
+      template: Templates['nav-search-empty']
+    }),
+
+    SearchResultsView = SelectableCollectionView.extend({
+      className: 'menu',
+      tagName: 'ul',
+      childView: SearchItemView,
+      emptyView: SearchEmptyView
+    });
+
+export default Marionette.LayoutView.extend({
+  className: 'navbar-search',
+  tagName: 'form',
+  template: Templates['nav-search'],
+
+  regions: {
+    resultsRegion: '.js-search-results'
+  },
+
+  events: {
+    'submit': 'onSubmit',
+    'keydown .js-search-input': 'onKeyDown',
+    'keyup .js-search-input': 'debouncedOnKeyUp'
+  },
+
+  initialize: function () {
+    var that = this;
+    this.results = new Backbone.Collection();
+    this.favorite = [];
+    if (window.SS.user) {
+      this.fetchFavorite().always(function () {
+        that.resetResultsToDefault();
+      });
+    } else {
+      this.resetResultsToDefault();
+    }
+    this.resultsView = new SearchResultsView({ collection: this.results });
+    this.debouncedOnKeyUp = _.debounce(this.onKeyUp, 400);
+    this._bufferedValue = '';
+  },
+
+  onRender: function () {
+    var that = this;
+    this.resultsRegion.show(this.resultsView);
+    setTimeout(function () {
+      that.$('.js-search-input').focus();
+    }, 0);
+  },
+
+  onKeyDown: function (e) {
+    if (e.keyCode === 38) {
+      this.resultsView.selectPrev();
+      return false;
+    }
+    if (e.keyCode === 40) {
+      this.resultsView.selectNext();
+      return false;
+    }
+    if (e.keyCode === 13) {
+      this.resultsView.submitCurrent();
       return false;
-    },
+    }
+    if (e.keyCode === 27) {
+      this.options.hide();
+      return false;
+    }
+  },
 
-    fetchFavorite: function () {
-      var that = this;
-      return $.get(baseUrl + '/api/favourites').done(function (r) {
-        that.favorite = r.map(function (f) {
-          var isFile = ['FIL', 'UTS'].indexOf(f.qualifier) !== -1;
+  onKeyUp: function () {
+    var value = this.$('.js-search-input').val();
+    if (value === this._bufferedValue) {
+      return;
+    }
+    this._bufferedValue = this.$('.js-search-input').val();
+    if (this.searchRequest != null && this.searchRequest.abort != null) {
+      this.searchRequest.abort();
+    }
+    this.searchRequest = this.search(value);
+  },
+
+  onSubmit: function () {
+    return false;
+  },
+
+  fetchFavorite: function () {
+    var that = this;
+    return $.get(baseUrl + '/api/favourites').done(function (r) {
+      that.favorite = r.map(function (f) {
+        var isFile = ['FIL', 'UTS'].indexOf(f.qualifier) !== -1;
+        return {
+          url: baseUrl + '/dashboard/index?id=' + encodeURIComponent(f.key) + window.dashboardParameters(true),
+          name: isFile ? window.collapsedDirFromPath(f.lname) + window.fileFromPath(f.lname) : f.name,
+          icon: 'favorite'
+        };
+      });
+      that.favorite = _.sortBy(that.favorite, 'name');
+    });
+  },
+
+  resetResultsToDefault: function () {
+    var recentHistory = JSON.parse(localStorage.getItem('sonar_recent_history')),
+        history = (recentHistory || []).map(function (historyItem, index) {
+          var url = baseUrl + '/dashboard/index?id=' + encodeURIComponent(historyItem.key) +
+              window.dashboardParameters(true);
           return {
-            url: baseUrl + '/dashboard/index?id=' + encodeURIComponent(f.key) + window.dashboardParameters(true),
-            name: isFile ? window.collapsedDirFromPath(f.lname) + window.fileFromPath(f.lname) : f.name,
-            icon: 'favorite'
+            url: url,
+            name: historyItem.name,
+            q: historyItem.icon,
+            extra: index === 0 ? t('browsed_recently') : null
+          };
+        }),
+        favorite = _.first(this.favorite, 6).map(function (f, index) {
+          return _.extend(f, { extra: index === 0 ? t('favorite') : null });
+        }),
+        qualifiers = this.model.get('qualifiers').map(function (q, index) {
+          return {
+            url: baseUrl + '/all_projects?qualifier=' + encodeURIComponent(q),
+            name: t('qualifiers.all', q),
+            extra: index === 0 ? '' : null
           };
         });
-        that.favorite = _.sortBy(that.favorite, 'name');
-      });
-    },
-
-    resetResultsToDefault: function () {
-      var recentHistory = JSON.parse(localStorage.getItem('sonar_recent_history')),
-          history = (recentHistory || []).map(function (historyItem, index) {
-            var url = baseUrl + '/dashboard/index?id=' + encodeURIComponent(historyItem.key) +
-                window.dashboardParameters(true);
-            return {
-              url: url,
-              name: historyItem.name,
-              q: historyItem.icon,
-              extra: index === 0 ? t('browsed_recently') : null
-            };
-          }),
-          favorite = _.first(this.favorite, 6).map(function (f, index) {
-            return _.extend(f, { extra: index === 0 ? t('favorite') : null });
-          }),
-          qualifiers = this.model.get('qualifiers').map(function (q, index) {
-            return {
-              url: baseUrl + '/all_projects?qualifier=' + encodeURIComponent(q),
-              name: t('qualifiers.all', q),
-              extra: index === 0 ? '' : null
-            };
-          });
-      this.results.reset([].concat(history, favorite, qualifiers));
-    },
-
-    search: function (q) {
-      if (q.length < 2) {
-        this.resetResultsToDefault();
-        return;
-      }
-      var that = this,
-          url = baseUrl + '/api/components/suggestions',
-          options = { s: q };
-      return $.get(url, options).done(function (r) {
-        var collection = [];
-        r.results.forEach(function (domain) {
-          domain.items.forEach(function (item, index) {
-            collection.push(_.extend(item, {
-              q: domain.q,
-              extra: index === 0 ? domain.name : null,
-              url: baseUrl + '/dashboard/index?id=' + encodeURIComponent(item.key) + window.dashboardParameters(true)
-            }));
-          });
-        });
-        that.results.reset([].concat(
-            that.getNavigationFindings(q),
-            that.getGlobalDashboardFindings(q),
-            that.getFavoriteFindings(q),
-            collection
-        ));
-      });
-    },
-
-    getNavigationFindings: function (q) {
-      var DEFAULT_ITEMS = [
-            { name: t('issues.page'), url: baseUrl + '/issues/search' },
-            { name: t('layout.measures'), url: baseUrl + '/measures/search?qualifiers[]=TRK' },
-            { name: t('coding_rules.page'), url: baseUrl + '/coding_rules' },
-            { name: t('quality_profiles.page'), url: baseUrl + '/profiles' },
-            { name: t('quality_gates.page'), url: baseUrl + '/quality_gates' },
-            { name: t('comparison_global.page'), url: baseUrl + '/comparison' }
-          ],
-          customItems = [];
-      if (window.SS.isUserAdmin) {
-        customItems.push({ name: t('layout.settings'), url: baseUrl + '/settings' });
-      }
-      var findings = [].concat(DEFAULT_ITEMS, customItems).filter(function (f) {
-        return f.name.match(new RegExp(q, 'i'));
-      });
-      if (findings.length > 0) {
-        findings[0].extra = t('navigation');
-      }
-      return _.first(findings, 6);
-    },
-
-    getGlobalDashboardFindings: function (q) {
-      var dashboards = this.model.get('globalDashboards') || [],
-          items = dashboards.map(function (d) {
-            return { name: d.name, url: baseUrl + '/dashboard/index?did=' + encodeURIComponent(d.key) };
-          });
-      var findings = items.filter(function (f) {
-        return f.name.match(new RegExp(q, 'i'));
-      });
-      if (findings.length > 0) {
-        findings[0].extra = t('dashboard.global_dashboards');
-      }
-      return _.first(findings, 6);
-    },
+    this.results.reset([].concat(history, favorite, qualifiers));
+  },
 
-    getFavoriteFindings: function (q) {
-      var findings = this.favorite.filter(function (f) {
-        return f.name.match(new RegExp(q, 'i'));
+  search: function (q) {
+    if (q.length < 2) {
+      this.resetResultsToDefault();
+      return;
+    }
+    var that = this,
+        url = baseUrl + '/api/components/suggestions',
+        options = { s: q };
+    return $.get(url, options).done(function (r) {
+      var collection = [];
+      r.results.forEach(function (domain) {
+        domain.items.forEach(function (item, index) {
+          collection.push(_.extend(item, {
+            q: domain.q,
+            extra: index === 0 ? domain.name : null,
+            url: baseUrl + '/dashboard/index?id=' + encodeURIComponent(item.key) + window.dashboardParameters(true)
+          }));
+        });
       });
-      if (findings.length > 0) {
-        findings[0].extra = t('favorite');
-      }
-      return _.first(findings, 6);
+      that.results.reset([].concat(
+          that.getNavigationFindings(q),
+          that.getGlobalDashboardFindings(q),
+          that.getFavoriteFindings(q),
+          collection
+      ));
+    });
+  },
+
+  getNavigationFindings: function (q) {
+    var DEFAULT_ITEMS = [
+          { name: t('issues.page'), url: baseUrl + '/issues/search' },
+          { name: t('layout.measures'), url: baseUrl + '/measures/search?qualifiers[]=TRK' },
+          { name: t('coding_rules.page'), url: baseUrl + '/coding_rules' },
+          { name: t('quality_profiles.page'), url: baseUrl + '/profiles' },
+          { name: t('quality_gates.page'), url: baseUrl + '/quality_gates' },
+          { name: t('comparison_global.page'), url: baseUrl + '/comparison' }
+        ],
+        customItems = [];
+    if (window.SS.isUserAdmin) {
+      customItems.push({ name: t('layout.settings'), url: baseUrl + '/settings' });
+    }
+    var findings = [].concat(DEFAULT_ITEMS, customItems).filter(function (f) {
+      return f.name.match(new RegExp(q, 'i'));
+    });
+    if (findings.length > 0) {
+      findings[0].extra = t('navigation');
     }
-  });
+    return _.first(findings, 6);
+  },
 
+  getGlobalDashboardFindings: function (q) {
+    var dashboards = this.model.get('globalDashboards') || [],
+        items = dashboards.map(function (d) {
+          return { name: d.name, url: baseUrl + '/dashboard/index?did=' + encodeURIComponent(d.key) };
+        });
+    var findings = items.filter(function (f) {
+      return f.name.match(new RegExp(q, 'i'));
+    });
+    if (findings.length > 0) {
+      findings[0].extra = t('dashboard.global_dashboards');
+    }
+    return _.first(findings, 6);
+  },
+
+  getFavoriteFindings: function (q) {
+    var findings = this.favorite.filter(function (f) {
+      return f.name.match(new RegExp(q, 'i'));
+    });
+    if (findings.length > 0) {
+      findings[0].extra = t('favorite');
+    }
+    return _.first(findings, 6);
+  }
 });
+
+
index b016a734d8c3e88260aa89a104b94faa0ccc6b8a..02807d5951fb23bf1e6410a65de73600394ad553 100644 (file)
@@ -1,11 +1,9 @@
-define([
-  'components/common/modals',
-  '../templates'
-], function (ModalView) {
-
-  return ModalView.extend({
-    className: 'modal modal-large',
-    template: Templates['nav-shortcuts-help']
-  });
+import ModalView from 'components/common/modals';
+import '../templates';
 
+export default ModalView.extend({
+  className: 'modal modal-large',
+  template: Templates['nav-shortcuts-help']
 });
+
+
index 7e9d76121aa34f2a6b5891d431fd31feeeb9929b..eb01839a8df02bf1896fcba637f8c808041de924 100644 (file)
@@ -1,3 +1,4 @@
+import _ from 'underscore';
 import React from 'react';
 
 export default {
index 760034e73846f7d6769a9ef4ceb1d247cd1750c2..d856844e2713c4137f5891be288dc02e04341529 100644 (file)
@@ -1,8 +1,7 @@
+import $ from 'jquery';
 import React from 'react';
 import LinksMixin from '../links-mixin';
 
-let $ = jQuery;
-
 export default React.createClass({
   mixins: [LinksMixin],
 
index 9bcd05d8e131dcf7ca12758d2d5f66e55978a01c..dbf1c26520f1f00d45783cd593d7e4ec3eccc4d2 100644 (file)
@@ -1,4 +1,5 @@
 import $ from 'jquery';
+import _ from 'underscore';
 import ModalForm from '../../components/common/modal-form';
 import {applyTemplateToProject} from '../../api/permissions';
 import './templates';
index e5315e5dd142b198c38cb9b51fd7efd0b78c0a07..ed88709054aa0ae2c86601e57a8677f1f5c6bcef 100644 (file)
@@ -1,55 +1,54 @@
-define([
-  'components/common/modals',
-  'components/common/select-list',
-  './templates'
-], function (Modal) {
+import _ from 'underscore';
+import Modal from 'components/common/modals';
+import 'components/common/select-list';
+import './templates';
 
-  function getSearchUrl(permission, project) {
-    return baseUrl + '/api/permissions/groups?ps=100&permission=' + permission + '&projectId=' + project;
-  }
-
-  return Modal.extend({
-    template: Templates['project-permissions-groups'],
+function getSearchUrl (permission, project) {
+  return baseUrl + '/api/permissions/groups?ps=100&permission=' + permission + '&projectId=' + project;
+}
 
-    onRender: function () {
-      this._super();
-      new window.SelectList({
-        el: this.$('#project-permissions-groups'),
-        width: '100%',
-        readOnly: false,
-        focusSearch: false,
-        format: function (item) {
-          return item.name;
-        },
-        queryParam: 'q',
-        searchUrl: getSearchUrl(this.options.permission, this.options.project),
-        selectUrl: baseUrl + '/api/permissions/add_group',
-        deselectUrl: baseUrl + '/api/permissions/remove_group',
-        extra: {
-          permission: this.options.permission,
-          projectId: this.options.project
-        },
-        selectParameter: 'groupName',
-        selectParameterValue: 'name',
-        parse: function (r) {
-          this.more = false;
-          return r.groups;
-        }
-      });
-    },
+export default Modal.extend({
+  template: Templates['project-permissions-groups'],
 
-    onDestroy: function () {
-      if (this.options.refresh) {
-        this.options.refresh();
+  onRender: function () {
+    this._super();
+    new window.SelectList({
+      el: this.$('#project-permissions-groups'),
+      width: '100%',
+      readOnly: false,
+      focusSearch: false,
+      format: function (item) {
+        return item.name;
+      },
+      queryParam: 'q',
+      searchUrl: getSearchUrl(this.options.permission, this.options.project),
+      selectUrl: baseUrl + '/api/permissions/add_group',
+      deselectUrl: baseUrl + '/api/permissions/remove_group',
+      extra: {
+        permission: this.options.permission,
+        projectId: this.options.project
+      },
+      selectParameter: 'groupName',
+      selectParameterValue: 'name',
+      parse: function (r) {
+        this.more = false;
+        return r.groups;
       }
-      this._super();
-    },
+    });
+  },
 
-    serializeData: function () {
-      return _.extend(Modal.prototype.serializeData.apply(this, arguments), {
-        projectName: this.options.projectName
-      });
+  onDestroy: function () {
+    if (this.options.refresh) {
+      this.options.refresh();
     }
-  });
+    this._super();
+  },
 
+  serializeData: function () {
+    return _.extend(Modal.prototype.serializeData.apply(this, arguments), {
+      projectName: this.options.projectName
+    });
+  }
 });
+
+
index 2df3f3694a97b3826b0788700cfebbe18951043b..253952fbe261014cddf16de5068b6c9eb68c86b8 100644 (file)
@@ -1,9 +1,8 @@
+import $ from 'jquery';
 import _ from 'underscore';
 import React from 'react';
 import PermissionsList from '../global-permissions/permissions-list';
 
-let $ = jQuery;
-
 const PERMISSIONS_ORDER = ['user', 'codeviewer', 'issueadmin', 'admin'];
 
 export default React.createClass({
index 3506d78834b997a1346eedfbac678450aa6ea79f..6b90a16b7f5cfe8ea2fca01d70adecca6b5c1707 100644 (file)
@@ -1,3 +1,4 @@
+import _ from 'underscore';
 import React from 'react';
 
 export default React.createClass({
index 370db728ba1ed16b8a65627a18f2d5d7644449bd..31cbc91c653be7ec995fa06a5f5f0b80f5b87db0 100644 (file)
@@ -1,53 +1,52 @@
-define([
-  'components/common/modals',
-  'components/common/select-list',
-  './templates'
-], function (Modal) {
+import _ from 'underscore';
+import Modal from 'components/common/modals';
+import 'components/common/select-list';
+import './templates';
 
-  return Modal.extend({
-    template: Templates['project-permissions-users'],
+export default Modal.extend({
+  template: Templates['project-permissions-users'],
 
-    onRender: function () {
-      this._super();
-      var searchUrl = baseUrl + '/api/permissions/users?ps=100&permission=' + this.options.permission +
-          '&projectId=' + this.options.project;
-      new window.SelectList({
-        el: this.$('#project-permissions-users'),
-        width: '100%',
-        readOnly: false,
-        focusSearch: false,
-        format: function (item) {
-          return item.name + '<br><span class="note">' + item.login + '</span>';
-        },
-        queryParam: 'q',
-        searchUrl: searchUrl,
-        selectUrl: baseUrl + '/api/permissions/add_user',
-        deselectUrl: baseUrl + '/api/permissions/remove_user',
-        extra: {
-          permission: this.options.permission,
-          projectId: this.options.project
-        },
-        selectParameter: 'login',
-        selectParameterValue: 'login',
-        parse: function (r) {
-          this.more = false;
-          return r.users;
-        }
-      });
-    },
-
-    onDestroy: function () {
-      if (this.options.refresh) {
-        this.options.refresh();
+  onRender: function () {
+    this._super();
+    var searchUrl = baseUrl + '/api/permissions/users?ps=100&permission=' + this.options.permission +
+        '&projectId=' + this.options.project;
+    new window.SelectList({
+      el: this.$('#project-permissions-users'),
+      width: '100%',
+      readOnly: false,
+      focusSearch: false,
+      format: function (item) {
+        return item.name + '<br><span class="note">' + item.login + '</span>';
+      },
+      queryParam: 'q',
+      searchUrl: searchUrl,
+      selectUrl: baseUrl + '/api/permissions/add_user',
+      deselectUrl: baseUrl + '/api/permissions/remove_user',
+      extra: {
+        permission: this.options.permission,
+        projectId: this.options.project
+      },
+      selectParameter: 'login',
+      selectParameterValue: 'login',
+      parse: function (r) {
+        this.more = false;
+        return r.users;
       }
-      this._super();
-    },
+    });
+  },
 
-    serializeData: function () {
-      return _.extend(Modal.prototype.serializeData.apply(this, arguments), {
-        projectName: this.options.projectName
-      });
+  onDestroy: function () {
+    if (this.options.refresh) {
+      this.options.refresh();
     }
-  });
+    this._super();
+  },
 
+  serializeData: function () {
+    return _.extend(Modal.prototype.serializeData.apply(this, arguments), {
+      projectName: this.options.projectName
+    });
+  }
 });
+
+
index aa754e5ba77f97a1980d59d4bbc68e898c60552d..427179d6fece86dbbedef7fa5fc956f1ca7f9776 100644 (file)
@@ -1,47 +1,46 @@
-define([
-  './layout',
-  './projects',
-  './header-view',
-  './search-view',
-  './list-view',
-  './list-footer-view'
-], function (Layout, Projects, HeaderView, SearchView, ListView, ListFooterView) {
-
-  var App = new Marionette.Application(),
-      init = function (options) {
-        // Layout
-        this.layout = new Layout({ el: options.el });
-        this.layout.render();
-
-        // Collection
-        this.projects = new Projects();
-
-        // Header View
-        this.headerView = new HeaderView({ collection: this.projects });
-        this.layout.headerRegion.show(this.headerView);
-
-        // Search View
-        this.searchView = new SearchView({ collection: this.projects });
-        this.layout.searchRegion.show(this.searchView);
-
-        // List View
-        this.listView = new ListView({ collection: this.projects });
-        this.layout.listRegion.show(this.listView);
-
-        // List Footer View
-        this.listFooterView = new ListFooterView({ collection: this.projects });
-        this.layout.listFooterRegion.show(this.listFooterView);
-
-        // Go!
-        this.projects.fetch();
-      };
-
-  App.on('start', function (options) {
-    window.requestMessages().done(function () {
-      init.call(App, options);
-    });
+import Marionette from 'backbone.marionette';
+import Layout from './layout';
+import Projects from './projects';
+import HeaderView from './header-view';
+import SearchView from './search-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.projects = new Projects();
+
+      // Header View
+      this.headerView = new HeaderView({ collection: this.projects });
+      this.layout.headerRegion.show(this.headerView);
+
+      // Search View
+      this.searchView = new SearchView({ collection: this.projects });
+      this.layout.searchRegion.show(this.searchView);
+
+      // List View
+      this.listView = new ListView({ collection: this.projects });
+      this.layout.listRegion.show(this.listView);
+
+      // List Footer View
+      this.listFooterView = new ListFooterView({ collection: this.projects });
+      this.layout.listFooterRegion.show(this.listFooterView);
+
+      // Go!
+      this.projects.fetch();
+    };
+
+App.on('start', function (options) {
+  window.requestMessages().done(function () {
+    init.call(App, options);
   });
+});
+
+export default App;
 
-  return App;
 
-});
index 731e3e163d2d22bd14e792ab41aa6f1a5ee286a2..6e6abfd127ed21e62b19c464998bcdfcbd2f6743 100644 (file)
@@ -1,31 +1,30 @@
-define([
-  'components/common/modal-form',
-  './templates'
-], function (ModalForm) {
+import _ from 'underscore';
+import ModalForm from 'components/common/modal-form';
+import './templates';
 
-  return ModalForm.extend({
-    template: Templates['provisioning-bulk-delete'],
+export default ModalForm.extend({
+  template: Templates['provisioning-bulk-delete'],
 
-    onFormSubmit: function (e) {
-      this._super(e);
-      this.sendRequest();
-    },
-
-    sendRequest: function () {
-      var that = this,
-          selected = _.pluck(this.collection.where({ selected: true }), 'id');
-      return this.collection.bulkDelete(selected, {
-        statusCode: {
-          // do not show global error
-          400: null
-        }
-      }).done(function () {
-        that.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,
+        selected = _.pluck(this.collection.where({ selected: true }), 'id');
+    return this.collection.bulkDelete(selected, {
+      statusCode: {
+        // do not show global error
+        400: null
+      }
+    }).done(function () {
+      that.collection.refresh();
+      that.destroy();
+    }).fail(function (jqXHR) {
+      that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+    });
+  }
 });
+
+
index 2aba2786c3c7d69b23dee36bff6579f854dd2d14..6c02f5a22816f74505eb5c4c45856afbb96be2ef 100644 (file)
@@ -1,31 +1,29 @@
-define([
-  './project',
-  './form-view'
-], function (Project, FormView) {
+import Project from './project';
+import FormView from './form-view';
 
-  return FormView.extend({
-
-    sendRequest: function () {
-      var that = this,
-          project = new Project({
-            name: this.$('#create-project-name').val(),
-            branch: this.$('#create-project-branch').val(),
-            key: this.$('#create-project-key').val()
-          });
-      this.disableForm();
-      return project.save(null, {
-        statusCode: {
-          // do not show global error
-          400: null
-        }
-      }).done(function () {
-        that.collection.refresh();
-        that.destroy();
-      }).fail(function (jqXHR) {
-        that.enableForm();
-        that.showErrors([{ msg: jqXHR.responseJSON.err_msg }]);
-      });
-    }
-  });
+export default FormView.extend({
 
+  sendRequest: function () {
+    var that = this,
+        project = new Project({
+          name: this.$('#create-project-name').val(),
+          branch: this.$('#create-project-branch').val(),
+          key: this.$('#create-project-key').val()
+        });
+    this.disableForm();
+    return project.save(null, {
+      statusCode: {
+        // do not show global error
+        400: null
+      }
+    }).done(function () {
+      that.collection.refresh();
+      that.destroy();
+    }).fail(function (jqXHR) {
+      that.enableForm();
+      that.showErrors([{ msg: jqXHR.responseJSON.err_msg }]);
+    });
+  }
 });
+
+
index dd503c4b1a4505f83cbc731ef1c3b0697b85ca15..d4176097d27f99b87b582dd2cd453dafc18aa03d 100644 (file)
@@ -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['provisioning-delete'],
+export default ModalForm.extend({
+  template: Templates['provisioning-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);
+    });
+  }
 });
+
+
index bb0fc0bcef545de853ed4ef8bc962fe8d1f589e6..525be213f493f62f465c304e54bc58a9009e60c5 100644 (file)
@@ -1,26 +1,24 @@
-define([
-  'components/common/modal-form',
-  './templates'
-], function (ModalForm) {
+import ModalForm from 'components/common/modal-form';
+import './templates';
 
-  return ModalForm.extend({
-    template: Templates['provisioning-form'],
+export default ModalForm.extend({
+  template: Templates['provisioning-form'],
 
-    onRender: function () {
-      this._super();
-      this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
-    },
+  onRender: function () {
+    this._super();
+    this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
+  },
 
-    onDestroy: function () {
-      this._super();
-      this.$('[data-toggle="tooltip"]').tooltip('destroy');
-    },
+  onDestroy: function () {
+    this._super();
+    this.$('[data-toggle="tooltip"]').tooltip('destroy');
+  },
 
-    onFormSubmit: function (e) {
-      this._super(e);
-      this.sendRequest();
-    }
-
-  });
+  onFormSubmit: function (e) {
+    this._super(e);
+    this.sendRequest();
+  }
 
 });
+
+
index 37165494eac0b3d2d91ce785ddc69b30478143e8..8fd88483e9b3261141504cd80d136b3cbfc9dfb7 100644 (file)
@@ -1,49 +1,48 @@
-define([
-  './create-view',
-  './bulk-delete-view',
-  './templates'
-], function (CreateView, BulkDeleteView) {
-
-  return Marionette.ItemView.extend({
-    template: Templates['provisioning-header'],
-
-    collectionEvents: {
-      'change:selected': 'toggleDeleteButton',
-      'reset': 'toggleDeleteButton'
-    },
-
-    events: {
-      'click #provisioning-create': 'onCreateClick',
-      'click #provisioning-bulk-delete': 'onBulkDeleteClick'
-    },
-
-    onCreateClick: function (e) {
-      e.preventDefault();
-      this.createProject();
-    },
-
-    onBulkDeleteClick: function (e) {
-      e.preventDefault();
-      this.bulkDelete();
-    },
-
-    createProject: function () {
-      new CreateView({
-        collection: this.collection
-      }).render();
-    },
-
-    bulkDelete: function () {
-      new BulkDeleteView({
-        collection: this.collection
-      }).render();
-    },
-
-    toggleDeleteButton: function () {
-      var selectedCount = this.collection.where({ selected: true }).length,
-          someSelected = selectedCount > 0;
-      this.$('#provisioning-bulk-delete').prop('disabled', !someSelected);
-    }
-  });
-
+import Marionette from 'backbone.marionette';
+import CreateView from './create-view';
+import BulkDeleteView from './bulk-delete-view';
+import './templates';
+
+export default Marionette.ItemView.extend({
+  template: Templates['provisioning-header'],
+
+  collectionEvents: {
+    'change:selected': 'toggleDeleteButton',
+    'reset': 'toggleDeleteButton'
+  },
+
+  events: {
+    'click #provisioning-create': 'onCreateClick',
+    'click #provisioning-bulk-delete': 'onBulkDeleteClick'
+  },
+
+  onCreateClick: function (e) {
+    e.preventDefault();
+    this.createProject();
+  },
+
+  onBulkDeleteClick: function (e) {
+    e.preventDefault();
+    this.bulkDelete();
+  },
+
+  createProject: function () {
+    new CreateView({
+      collection: this.collection
+    }).render();
+  },
+
+  bulkDelete: function () {
+    new BulkDeleteView({
+      collection: this.collection
+    }).render();
+  },
+
+  toggleDeleteButton: function () {
+    var selectedCount = this.collection.where({ selected: true }).length,
+        someSelected = selectedCount > 0;
+    this.$('#provisioning-bulk-delete').prop('disabled', !someSelected);
+  }
 });
+
+
index 31b67e8b7741c1dd9a62a4bcd4b1b819b838bcbc..60bf7f209ca982dad891e337f23f08677fbb3f3f 100644 (file)
@@ -1,16 +1,15 @@
-define([
-  './templates'
-], function () {
+import Marionette from 'backbone.marionette';
+import './templates';
 
-  return Marionette.LayoutView.extend({
-    template: Templates['provisioning-layout'],
-
-    regions: {
-      headerRegion: '#provisioning-header',
-      searchRegion: '#provisioning-search',
-      listRegion: '#provisioning-list',
-      listFooterRegion: '#provisioning-list-footer'
-    }
-  });
+export default Marionette.LayoutView.extend({
+  template: Templates['provisioning-layout'],
 
+  regions: {
+    headerRegion: '#provisioning-header',
+    searchRegion: '#provisioning-search',
+    listRegion: '#provisioning-list',
+    listFooterRegion: '#provisioning-list-footer'
+  }
 });
+
+
index 902b9322372d3f821ec057eab769f227840347d6..87fdbd793c9ba99df1f74702019ccfc57c711c94 100644 (file)
@@ -1,34 +1,34 @@
-define([
-  './templates'
-], function () {
-
-  return Marionette.ItemView.extend({
-    template: Templates['provisioning-list-footer'],
-
-    collectionEvents: {
-      'all': 'render'
-    },
-
-    events: {
-      'click #provisioning-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['provisioning-list-footer'],
+
+  collectionEvents: {
+    'all': 'render'
+  },
+
+  events: {
+    'click #provisioning-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()
+    });
+  }
 });
+
+
index ead9b009ca39e4b0d6d11ae21d0ff6755f8c790e..41959c7439d6d1e99e4e867eca1b56fe676ea470 100644 (file)
@@ -1,52 +1,51 @@
-define([
-  './delete-view',
-  './templates'
-], function (DeleteView) {
-
-  return Marionette.ItemView.extend({
-    tagName: 'li',
-    className: 'panel panel-vertical',
-    template: Templates['provisioning-list-item'],
-
-    modelEvents: {
-      'change:selected': 'onSelectedChange'
-    },
-
-    events: {
-      'click .js-toggle': 'onToggleClick',
-      'click .js-project-delete': 'onDeleteClick'
-    },
-
-    onRender: function () {
-      this.$el.attr('data-id', this.model.id);
-      this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
-    },
-
-    onDestroy: function () {
-      this.$('[data-toggle="tooltip"]').tooltip('destroy');
-    },
-
-    onToggleClick: function (e) {
-      e.preventDefault();
-      this.toggle();
-    },
-
-    onDeleteClick: function (e) {
-      e.preventDefault();
-      this.deleteProject();
-    },
-
-    onSelectedChange: function () {
-      this.$('.js-toggle').toggleClass('icon-checkbox-checked', this.model.get('selected'));
-    },
-
-    toggle: function () {
-      this.model.toggle();
-    },
-
-    deleteProject: function () {
-      new DeleteView({ model: this.model }).render();
-    }
-  });
-
+import Marionette from 'backbone.marionette';
+import DeleteView from './delete-view';
+import './templates';
+
+export default Marionette.ItemView.extend({
+  tagName: 'li',
+  className: 'panel panel-vertical',
+  template: Templates['provisioning-list-item'],
+
+  modelEvents: {
+    'change:selected': 'onSelectedChange'
+  },
+
+  events: {
+    'click .js-toggle': 'onToggleClick',
+    'click .js-project-delete': 'onDeleteClick'
+  },
+
+  onRender: function () {
+    this.$el.attr('data-id', this.model.id);
+    this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
+  },
+
+  onDestroy: function () {
+    this.$('[data-toggle="tooltip"]').tooltip('destroy');
+  },
+
+  onToggleClick: function (e) {
+    e.preventDefault();
+    this.toggle();
+  },
+
+  onDeleteClick: function (e) {
+    e.preventDefault();
+    this.deleteProject();
+  },
+
+  onSelectedChange: function () {
+    this.$('.js-toggle').toggleClass('icon-checkbox-checked', this.model.get('selected'));
+  },
+
+  toggle: function () {
+    this.model.toggle();
+  },
+
+  deleteProject: function () {
+    new DeleteView({ model: this.model }).render();
+  }
 });
+
+
index 24878864d309901cfd4c6b951fa0ab09114d12d2..695bf2ac034422cd4a228e67bec5d08fe0357f6a 100644 (file)
@@ -1,11 +1,10 @@
-define([
-  './list-item-view',
-  './templates'
-], function (ListItemView) {
-
-  return Marionette.CollectionView.extend({
-    tagName: 'ul',
-    childView: ListItemView
-  });
+import Marionette from 'backbone.marionette';
+import ListItemView from './list-item-view';
+import './templates';
 
+export default Marionette.CollectionView.extend({
+  tagName: 'ul',
+  childView: ListItemView
 });
+
+
index fa34df605f27e73473ae50bd74fdb082a6284c2c..b709f02695be123d3965fee4f25110bf24678581 100644 (file)
@@ -1,38 +1,39 @@
-define(function () {
+import _ from 'underscore';
+import Backbone from 'backbone';
 
-  return Backbone.Model.extend({
-    idAttribute: 'uuid',
+export default Backbone.Model.extend({
+  idAttribute: 'uuid',
 
-    defaults: {
-      selected: false
-    },
+  defaults: {
+    selected: false
+  },
 
-    urlRoot: function () {
-      return baseUrl + '/api/projects';
-    },
+  urlRoot: function () {
+    return baseUrl + '/api/projects';
+  },
 
-    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', 'branch')
-        });
-      }
-      if (method === 'delete') {
-        _.defaults(opts, {
-          url: this.urlRoot() + '/bulk_delete',
-          type: 'POST',
-          data: { ids: this.id }
-        });
-      }
-      return Backbone.ajax(opts);
-    },
-
-    toggle: function () {
-      this.set({ selected: !this.get('selected') });
+  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', 'branch')
+      });
+    }
+    if (method === 'delete') {
+      _.defaults(opts, {
+        url: this.urlRoot() + '/bulk_delete',
+        type: 'POST',
+        data: { ids: this.id }
+      });
     }
-  });
+    return Backbone.ajax(opts);
+  },
 
+  toggle: function () {
+    this.set({ selected: !this.get('selected') });
+  }
 });
+
+
index 05a59f822affb48687cc07ed0c8882e553ee829f..8e31d6a2a043f111abe71efaf5324c58f63438dc 100644 (file)
@@ -1,49 +1,49 @@
-define([
-  './project'
-], function (Project) {
-
-  return Backbone.Collection.extend({
-    model: Project,
-
-    url: function () {
-      return baseUrl + '/api/projects/provisioned';
-    },
-
-    parse: function (r) {
-      this.total = r.total;
-      this.p = r.p;
-      this.ps = r.ps;
-      return r.projects;
-    },
-
-    fetch: function (options) {
-      var d = (options && options.data) || {};
-      this.q = d.q;
-      return this._super(options);
-    },
-
-    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;
-    },
-
-    bulkDelete: function (ids, options) {
-      var opts = _.extend({}, options, {
-        type: 'POST',
-        url: baseUrl + '/api/projects/bulk_delete',
-        data: { ids: ids.join() }
-      });
-      return Backbone.ajax(opts);
-    }
-
-  });
+import _ from 'underscore';
+import Backbone from 'backbone';
+import Project from './project';
+
+export default Backbone.Collection.extend({
+  model: Project,
+
+  url: function () {
+    return baseUrl + '/api/projects/provisioned';
+  },
+
+  parse: function (r) {
+    this.total = r.total;
+    this.p = r.p;
+    this.ps = r.ps;
+    return r.projects;
+  },
+
+  fetch: function (options) {
+    var d = (options && options.data) || {};
+    this.q = d.q;
+    return this._super(options);
+  },
+
+  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;
+  },
+
+  bulkDelete: function (ids, options) {
+    var opts = _.extend({}, options, {
+      type: 'POST',
+      url: baseUrl + '/api/projects/bulk_delete',
+      data: { ids: ids.join() }
+    });
+    return Backbone.ajax(opts);
+  }
 
 });
+
+
index 55c0fafc4fb3076c39c4bd82d90dd3d0c1b797f3..2b926a05dbf54dbb604183a87d7e61caac53a235 100644 (file)
-define([
-  './templates'
-], function () {
-
-  return Marionette.ItemView.extend({
-    template: Templates['provisioning-search'],
-
-    collectionEvents: {
-      'change:selected': 'onSelectedChange',
-      'reset': 'onSelectedChange'
-    },
-
-    events: {
-      'click .js-toggle-selection': 'onToggleSelectionClick',
-      'submit #provisioning-search-form': 'onFormSubmit',
-      'search #provisioning-search-query': 'debouncedOnKeyUp',
-      'keyup #provisioning-search-query': 'debouncedOnKeyUp'
-    },
-
-    initialize: function () {
-      this._bufferedValue = null;
-      this.debouncedOnKeyUp = _.debounce(this.onKeyUp, 400);
-    },
-
-    onRender: function () {
-      this.delegateEvents();
-    },
-
-    onFormSubmit: function (e) {
-      e.preventDefault();
-      this.debouncedOnKeyUp();
-    },
-
-    onKeyUp: function () {
-      var q = this.getQuery();
-      if (q === this._bufferedValue) {
-        return;
-      }
-      this._bufferedValue = this.getQuery();
-      if (this.searchRequest != null) {
-        this.searchRequest.abort();
-      }
-      this.searchRequest = this.search(q);
-    },
-
-    onSelectedChange: function () {
-      var projectsCount = this.collection.length,
-          selectedCount = this.collection.where({ selected: true }).length,
-          allSelected = projectsCount > 0 && projectsCount === selectedCount,
-          someSelected = !allSelected && selectedCount > 0;
-      this.$('.js-toggle-selection')
-          .toggleClass('icon-checkbox-checked', allSelected || someSelected)
-          .toggleClass('icon-checkbox-single', someSelected);
-    },
-
-    onToggleSelectionClick: function (e) {
-      e.preventDefault();
-      this.toggleSelection();
-    },
-
-    toggleSelection: function () {
-      var selectedCount = this.collection.where({ selected: true }).length,
-          someSelected = selectedCount > 0;
-      return someSelected ? this.selectNone() : this.selectAll();
-    },
-
-    selectNone: function () {
-      this.collection.where({ selected: true }).forEach(function (project) {
-        project.set({ selected: false });
-      });
-    },
-
-    selectAll: function () {
-      this.collection.forEach(function (project) {
-        project.set({ selected: true });
-      });
-    },
-
-    getQuery: function () {
-      return this.$('#provisioning-search-query').val();
-    },
-
-    search: function (q) {
-      this.selectNone();
-      return this.collection.fetch({ reset: true, data: { q: q } });
-    },
-
-    serializeData: function () {
-      var projectsCount = this.collection.length,
-          selectedCount = this.collection.where({ selected: true }).length,
-          allSelected = projectsCount > 0 && projectsCount === selectedCount,
-          someSelected = !allSelected && selectedCount > 0;
-      return _.extend(this._super(), {
-        selectedCount: selectedCount,
-        allSelected: allSelected,
-        someSelected: someSelected
-      });
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import './templates';
+
+export default Marionette.ItemView.extend({
+  template: Templates['provisioning-search'],
+
+  collectionEvents: {
+    'change:selected': 'onSelectedChange',
+    'reset': 'onSelectedChange'
+  },
+
+  events: {
+    'click .js-toggle-selection': 'onToggleSelectionClick',
+    'submit #provisioning-search-form': 'onFormSubmit',
+    'search #provisioning-search-query': 'debouncedOnKeyUp',
+    'keyup #provisioning-search-query': 'debouncedOnKeyUp'
+  },
+
+  initialize: function () {
+    this._bufferedValue = null;
+    this.debouncedOnKeyUp = _.debounce(this.onKeyUp, 400);
+  },
+
+  onRender: function () {
+    this.delegateEvents();
+  },
+
+  onFormSubmit: function (e) {
+    e.preventDefault();
+    this.debouncedOnKeyUp();
+  },
+
+  onKeyUp: function () {
+    var q = this.getQuery();
+    if (q === this._bufferedValue) {
+      return;
     }
-  });
-
+    this._bufferedValue = this.getQuery();
+    if (this.searchRequest != null) {
+      this.searchRequest.abort();
+    }
+    this.searchRequest = this.search(q);
+  },
+
+  onSelectedChange: function () {
+    var projectsCount = this.collection.length,
+        selectedCount = this.collection.where({ selected: true }).length,
+        allSelected = projectsCount > 0 && projectsCount === selectedCount,
+        someSelected = !allSelected && selectedCount > 0;
+    this.$('.js-toggle-selection')
+        .toggleClass('icon-checkbox-checked', allSelected || someSelected)
+        .toggleClass('icon-checkbox-single', someSelected);
+  },
+
+  onToggleSelectionClick: function (e) {
+    e.preventDefault();
+    this.toggleSelection();
+  },
+
+  toggleSelection: function () {
+    var selectedCount = this.collection.where({ selected: true }).length,
+        someSelected = selectedCount > 0;
+    return someSelected ? this.selectNone() : this.selectAll();
+  },
+
+  selectNone: function () {
+    this.collection.where({ selected: true }).forEach(function (project) {
+      project.set({ selected: false });
+    });
+  },
+
+  selectAll: function () {
+    this.collection.forEach(function (project) {
+      project.set({ selected: true });
+    });
+  },
+
+  getQuery: function () {
+    return this.$('#provisioning-search-query').val();
+  },
+
+  search: function (q) {
+    this.selectNone();
+    return this.collection.fetch({ reset: true, data: { q: q } });
+  },
+
+  serializeData: function () {
+    var projectsCount = this.collection.length,
+        selectedCount = this.collection.where({ selected: true }).length,
+        allSelected = projectsCount > 0 && projectsCount === selectedCount,
+        someSelected = !allSelected && selectedCount > 0;
+    return _.extend(this._super(), {
+      selectedCount: selectedCount,
+      allSelected: allSelected,
+      someSelected: someSelected
+    });
+  }
 });
+
+
index 156c7d88104005699e760de787f5d6f2063907e1..62d27477f50d4eaceaf46c347b87c0a10c143284 100644 (file)
@@ -1,27 +1,27 @@
-define([
-  './create-view',
-  './templates'
-], function (CreateView) {
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import CreateView from './create-view';
+import './templates';
 
-  return Marionette.ItemView.extend({
-    template: Templates['quality-gate-actions'],
+export default Marionette.ItemView.extend({
+  template: Templates['quality-gate-actions'],
 
-    events: {
-      'click #quality-gate-add': 'add'
-    },
+  events: {
+    'click #quality-gate-add': 'add'
+  },
 
-    add: function (e) {
-      e.preventDefault();
-      new CreateView({
-        collection: this.collection
-      }).render();
-    },
-
-    serializeData: function () {
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        canEdit: this.options.canEdit
-      });
-    }
-  });
+  add: function (e) {
+    e.preventDefault();
+    new CreateView({
+      collection: this.collection
+    }).render();
+  },
 
+  serializeData: function () {
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      canEdit: this.options.canEdit
+    });
+  }
 });
+
+
index 6f939c9aa24e6a344bf857c99e298fe5b7ea9abf..3dc3eece7f6053327da1f6b0819c4ca99a6e8581 100644 (file)
@@ -1,62 +1,62 @@
-define([
-  './gates',
-  './gates-view',
-  './actions-view',
-  './router',
-  './layout',
-  './controller'
-], function (Gates, GatesView, ActionsView, Router, Layout, Controller) {
-
-  var $ = jQuery,
-      App = new Marionette.Application();
-
-  var init = function (options) {
-    // Layout
-    this.layout = new Layout({ el: options.el });
-    this.layout.render();
-    $('#footer').addClass('search-navigator-footer');
-
-    // Gates List
-    this.gates = new Gates();
-
-    // Controller
-    this.controller = new Controller({ app: this });
-
-    // Header
-    this.actionsView = new ActionsView({
-      canEdit: this.canEdit,
-      collection: this.gates
-    });
-    this.layout.actionsRegion.show(this.actionsView);
+import $ from 'jquery';
+import Backbone from 'backbone';
+import Marionette from 'backbone.marionette';
+import Gates from './gates';
+import GatesView from './gates-view';
+import ActionsView from './actions-view';
+import Router from './router';
+import Layout from './layout';
+import Controller from './controller';
+
+var App = new Marionette.Application();
+
+var init = function (options) {
+  // Layout
+  this.layout = new Layout({ el: options.el });
+  this.layout.render();
+  $('#footer').addClass('search-navigator-footer');
+
+  // Gates List
+  this.gates = new Gates();
+
+  // Controller
+  this.controller = new Controller({ app: this });
+
+  // Header
+  this.actionsView = new ActionsView({
+    canEdit: this.canEdit,
+    collection: this.gates
+  });
+  this.layout.actionsRegion.show(this.actionsView);
 
-    // List
-    this.gatesView = new GatesView({
-      canEdit: this.canEdit,
-      collection: this.gates
-    });
-    this.layout.resultsRegion.show(this.gatesView);
+  // List
+  this.gatesView = new GatesView({
+    canEdit: this.canEdit,
+    collection: this.gates
+  });
+  this.layout.resultsRegion.show(this.gatesView);
 
-    // Router
-    this.router = new Router({ app: this });
-    Backbone.history.start({
-      pushState: true,
-      root: options.urlRoot
-    });
-  };
-
-  var appXHR = $.get(baseUrl + '/api/qualitygates/app')
-      .done(function (r) {
-        App.canEdit = r.edit;
-        App.periods = r.periods;
-        App.metrics = r.metrics;
-      });
-
-  App.on('start', function (options) {
-    $.when(window.requestMessages(), appXHR).done(function () {
-      init.call(App, options);
-    });
+  // Router
+  this.router = new Router({ app: this });
+  Backbone.history.start({
+    pushState: true,
+    root: options.urlRoot
   });
+};
 
-  return App;
+var appXHR = $.get(baseUrl + '/api/qualitygates/app')
+    .done(function (r) {
+      App.canEdit = r.edit;
+      App.periods = r.periods;
+      App.metrics = r.metrics;
+    });
 
+App.on('start', function (options) {
+  $.when(window.requestMessages(), appXHR).done(function () {
+    init.call(App, options);
+  });
 });
+
+export default App;
+
+
index 9ca451ee5a0a1d049c252eaf109dfd457d428ea6..0a7787d40ec6f61301151e1e0d72834d75f5697b 100644 (file)
@@ -1,47 +1,47 @@
-define(function () {
-
-  return Backbone.Model.extend({
-
-    defaults: {
-      period: 0
-    },
-
-    url: function () {
-      return baseUrl + '/api/qualitygates';
-    },
-
-    createUrl: function () {
-      return this.url() + '/create_condition';
-    },
-
-    updateUrl: function () {
-      return this.url() + '/update_condition';
-    },
-
-    deleteUrl: function () {
-      return this.url() + '/delete_condition';
-    },
-
-    sync: function (method, model, options) {
-      var opts = options || {};
-      opts.type = 'POST';
-      if (method === 'create') {
-        opts.url = this.createUrl();
-        opts.data = model.toJSON();
-      }
-      if (method === 'update') {
-        opts.url = this.updateUrl();
-        opts.data = model.toJSON();
-      }
-      if (method === 'delete') {
-        opts.url = this.deleteUrl();
-        opts.data = { id: model.id };
-      }
-      if (opts.data.period === '0') {
-        delete opts.data.period;
-      }
-      return Backbone.ajax(opts);
-    }
-  });
+import Backbone from 'backbone';
+
+export default Backbone.Model.extend({
+
+  defaults: {
+    period: 0
+  },
+
+  url: function () {
+    return baseUrl + '/api/qualitygates';
+  },
+
+  createUrl: function () {
+    return this.url() + '/create_condition';
+  },
+
+  updateUrl: function () {
+    return this.url() + '/update_condition';
+  },
+
+  deleteUrl: function () {
+    return this.url() + '/delete_condition';
+  },
 
+  sync: function (method, model, options) {
+    var opts = options || {};
+    opts.type = 'POST';
+    if (method === 'create') {
+      opts.url = this.createUrl();
+      opts.data = model.toJSON();
+    }
+    if (method === 'update') {
+      opts.url = this.updateUrl();
+      opts.data = model.toJSON();
+    }
+    if (method === 'delete') {
+      opts.url = this.deleteUrl();
+      opts.data = { id: model.id };
+    }
+    if (opts.data.period === '0') {
+      delete opts.data.period;
+    }
+    return Backbone.ajax(opts);
+  }
 });
+
+
index 49cbb23f06977131aca33b0f4bf1cd95d4fa97fb..0307ebf0cb7eff58ce21f0a01c442f09109915f9 100644 (file)
@@ -1,10 +1,9 @@
-define([
-  './condition'
-], function (Condition) {
-
-  return Backbone.Collection.extend({
-    model: Condition,
-    comparator: 'metric'
-  });
+import Backbone from 'backbone';
+import Condition from './condition';
 
+export default Backbone.Collection.extend({
+  model: Condition,
+  comparator: 'metric'
 });
+
+
index 890adc1ad8bdc0a22988a2debbdaf7fb1e5f4489..a1589af3b5a5cad6a4e042d569f018fdbcc30ae3 100644 (file)
@@ -1,65 +1,64 @@
-define([
-  './gate',
-  './details-view',
-  './header-view'
-], function (Gate, DetailsView, HeaderView) {
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import DetailsView from './details-view';
+import HeaderView from './header-view';
 
-  return Marionette.Controller.extend({
+export default Marionette.Controller.extend({
 
-    initialize: function (options) {
-      this.app = options.app;
-      this.canEdit = this.app.canEdit;
-      this.listenTo(this.app.gates, 'select', this.onSelect);
-      this.listenTo(this.app.gates, 'destroy', this.onDestroy);
-    },
+  initialize: function (options) {
+    this.app = options.app;
+    this.canEdit = this.app.canEdit;
+    this.listenTo(this.app.gates, 'select', this.onSelect);
+    this.listenTo(this.app.gates, 'destroy', this.onDestroy);
+  },
 
-    index: function () {
-      this.app.gates.fetch();
-    },
+  index: function () {
+    this.app.gates.fetch();
+  },
 
-    show: function (id) {
-      var that = this;
-      this.app.gates.fetch().done(function () {
-        var gate = that.app.gates.get(id);
-        if (gate != null) {
-          gate.trigger('select', gate, { trigger: false });
-        }
-      });
-    },
-
-    onSelect: function (gate, options) {
-      var that = this,
-          route = 'show/' + gate.id,
-          opts = _.defaults(options || {}, { trigger: true });
-      if (opts.trigger) {
-        this.app.router.navigate(route);
+  show: function (id) {
+    var that = this;
+    this.app.gates.fetch().done(function () {
+      var gate = that.app.gates.get(id);
+      if (gate != null) {
+        gate.trigger('select', gate, { trigger: false });
       }
-      this.app.gatesView.highlight(gate.id);
-      gate.fetch().done(function () {
-        var headerView = new HeaderView({
-          model: gate,
-          canEdit: that.canEdit
-        });
-        that.app.layout.headerRegion.show(headerView);
+    });
+  },
 
-        var detailsView = new DetailsView({
-          model: gate,
-          canEdit: that.canEdit,
-          metrics: that.app.metrics,
-          periods: that.app.periods
-        });
-        that.app.layout.detailsRegion.show(detailsView);
+  onSelect: function (gate, options) {
+    var that = this,
+        route = 'show/' + gate.id,
+        opts = _.defaults(options || {}, { trigger: true });
+    if (opts.trigger) {
+      this.app.router.navigate(route);
+    }
+    this.app.gatesView.highlight(gate.id);
+    gate.fetch().done(function () {
+      var headerView = new HeaderView({
+        model: gate,
+        canEdit: that.canEdit
       });
-    },
+      that.app.layout.headerRegion.show(headerView);
 
-    onDestroy: function () {
-      this.app.router.navigate('');
-      this.app.layout.headerRegion.reset();
-      this.app.layout.detailsRegion.reset();
-      this.app.layout.renderIntro();
-      this.app.gatesView.highlight(null);
-    }
+      var detailsView = new DetailsView({
+        model: gate,
+        canEdit: that.canEdit,
+        metrics: that.app.metrics,
+        periods: that.app.periods
+      });
+      that.app.layout.detailsRegion.show(detailsView);
+    });
+  },
 
-  });
+  onDestroy: function () {
+    this.app.router.navigate('');
+    this.app.layout.headerRegion.reset();
+    this.app.layout.detailsRegion.reset();
+    this.app.layout.renderIntro();
+    this.app.gatesView.highlight(null);
+  }
 
 });
+
+
index fdd6c974cf83ea69c2920e14f05fdd18a56a52f6..8c4d1f04bc390797d8b8a7a27f92a656efb7c33e 100644 (file)
@@ -1,24 +1,22 @@
-define([
-  './form-view'
-], function (FormView) {
+import FormView from './form-view';
 
-  return FormView.extend({
-    method: 'copy',
-
-    prepareRequest: function () {
-      var that = this;
-      var url = baseUrl + '/api/qualitygates/copy',
-          name = this.$('#quality-gate-form-name').val(),
-          options = {
-            url: url,
-            data: { id: this.model.id, name: name }
-          };
-      return this.sendRequest(options)
-          .done(function (r) {
-            var gate = that.addGate(r);
-            gate.trigger('select', gate);
-          });
-    }
-  });
+export default FormView.extend({
+  method: 'copy',
 
+  prepareRequest: function () {
+    var that = this;
+    var url = baseUrl + '/api/qualitygates/copy',
+        name = this.$('#quality-gate-form-name').val(),
+        options = {
+          url: url,
+          data: { id: this.model.id, name: name }
+        };
+    return this.sendRequest(options)
+        .done(function (r) {
+          var gate = that.addGate(r);
+          gate.trigger('select', gate);
+        });
+  }
 });
+
+
index f58863ba315c9f35124eeee2d0c7e60b36aa1f12..4adbd45552bca70584e6e0cf62352b3715836837 100644 (file)
@@ -1,24 +1,22 @@
-define([
-  './form-view'
-], function (FormView) {
+import FormView from './form-view';
 
-  return FormView.extend({
-    method: 'create',
-
-    prepareRequest: function () {
-      var that = this;
-      var url = baseUrl + '/api/qualitygates/create',
-          name = this.$('#quality-gate-form-name').val(),
-          options = {
-            url: url,
-            data: { name: name }
-          };
-      return this.sendRequest(options)
-          .done(function (r) {
-            var gate = that.addGate(r);
-            gate.trigger('select', gate);
-          });
-    }
-  });
+export default FormView.extend({
+  method: 'create',
 
+  prepareRequest: function () {
+    var that = this;
+    var url = baseUrl + '/api/qualitygates/create',
+        name = this.$('#quality-gate-form-name').val(),
+        options = {
+          url: url,
+          data: { name: name }
+        };
+    return this.sendRequest(options)
+        .done(function (r) {
+          var gate = that.addGate(r);
+          gate.trigger('select', gate);
+        });
+  }
 });
+
+
index d142b883c841d5b382d5fa5cf9843319330e2879..ca25708f342b8f01a51ddab18b9e3a699ac74692 100644 (file)
@@ -1,33 +1,31 @@
-define([
-  'components/common/modal-form',
-  './templates'
-], function (ModalForm) {
+import ModalForm from 'components/common/modal-form';
+import './templates';
 
-  return ModalForm.extend({
-    template: Templates['quality-gates-delete'],
+export default ModalForm.extend({
+  template: Templates['quality-gates-delete'],
 
-    onFormSubmit: function () {
-      ModalForm.prototype.onFormSubmit.apply(this, arguments);
-      this.disableForm();
-      this.sendRequest();
-    },
-
-    sendRequest: function () {
-      var that = this,
-          options = {
-            statusCode: {
-              // do not show global error
-              400: null
-            }
-          };
-      return this.model.destroy(options)
-          .done(function () {
-            that.destroy();
-          }).fail(function (jqXHR) {
-            that.enableForm();
-            that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
-          });
-    }
-  });
+  onFormSubmit: function () {
+    ModalForm.prototype.onFormSubmit.apply(this, arguments);
+    this.disableForm();
+    this.sendRequest();
+  },
 
+  sendRequest: function () {
+    var that = this,
+        options = {
+          statusCode: {
+            // do not show global error
+            400: null
+          }
+        };
+    return this.model.destroy(options)
+        .done(function () {
+          that.destroy();
+        }).fail(function (jqXHR) {
+          that.enableForm();
+          that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+        });
+  }
 });
+
+
index 9af1b38e65e50f546c214558c54bf73c60c2d6c9..0c97cb26c016e0c4663ac111616df39e462af5e3 100644 (file)
@@ -1,46 +1,45 @@
-define([
-  './conditions',
-  './gate-conditions-view',
-  './gate-projects-view',
-  './templates'
-], function (Conditions, DetailConditionsView, ProjectsView) {
-
-  return Marionette.LayoutView.extend({
-    template: Templates['quality-gate-detail'],
-
-    regions: {
-      conditionsRegion: '#quality-gate-conditions',
-      projectsRegion: '#quality-gate-projects'
-    },
-
-    modelEvents: {
-      'change': 'render'
-    },
-
-    onRender: function () {
-      this.showConditions();
-      this.showProjects();
-    },
-
-    showConditions: function () {
-      var conditions = new Conditions(this.model.get('conditions')),
-          view = new DetailConditionsView({
-            canEdit: this.options.canEdit,
-            collection: conditions,
-            model: this.model,
-            metrics: this.options.metrics,
-            periods: this.options.periods
-          });
-      this.conditionsRegion.show(view);
-    },
-
-    showProjects: function () {
-      var view = new ProjectsView({
-        canEdit: this.options.canEdit,
-        model: this.model
-      });
-      this.projectsRegion.show(view);
-    }
-  });
+import Marionette from 'backbone.marionette';
+import Conditions from './conditions';
+import DetailConditionsView from './gate-conditions-view';
+import ProjectsView from './gate-projects-view';
+import './templates';
 
+export default Marionette.LayoutView.extend({
+  template: Templates['quality-gate-detail'],
+
+  regions: {
+    conditionsRegion: '#quality-gate-conditions',
+    projectsRegion: '#quality-gate-projects'
+  },
+
+  modelEvents: {
+    'change': 'render'
+  },
+
+  onRender: function () {
+    this.showConditions();
+    this.showProjects();
+  },
+
+  showConditions: function () {
+    var conditions = new Conditions(this.model.get('conditions')),
+        view = new DetailConditionsView({
+          canEdit: this.options.canEdit,
+          collection: conditions,
+          model: this.model,
+          metrics: this.options.metrics,
+          periods: this.options.periods
+        });
+    this.conditionsRegion.show(view);
+  },
+
+  showProjects: function () {
+    var view = new ProjectsView({
+      canEdit: this.options.canEdit,
+      model: this.model
+    });
+    this.projectsRegion.show(view);
+  }
 });
+
+
index 9b61f400bf310d81445f7c07bce3f05dbc313a43..f3f4d55d8693240ed863e5b89110d404ccc111fa 100644 (file)
@@ -1,47 +1,47 @@
-define([
-  'components/common/modal-form',
-  './gate',
-  './templates'
-], function (ModalForm, Gate) {
+import _ from 'underscore';
+import Backbone from 'backbone';
+import ModalForm from 'components/common/modal-form';
+import Gate from './gate';
+import './templates';
 
-  return ModalForm.extend({
-    template: Templates['quality-gate-form'],
+export default ModalForm.extend({
+  template: Templates['quality-gate-form'],
 
-    onFormSubmit: function () {
-      ModalForm.prototype.onFormSubmit.apply(this, arguments);
-      this.disableForm();
-      this.prepareRequest();
-    },
+  onFormSubmit: function () {
+    ModalForm.prototype.onFormSubmit.apply(this, arguments);
+    this.disableForm();
+    this.prepareRequest();
+  },
 
-    sendRequest: function (options) {
-      var that = this,
-          opts = _.defaults(options || {}, {
-            type: 'POST',
-            statusCode: {
-              // do not show global error
-              400: null
-            }
-          });
-      return Backbone.ajax(opts)
-          .done(function () {
-            that.destroy();
-          }).fail(function (jqXHR) {
-            that.enableForm();
-            that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
-          });
-    },
+  sendRequest: function (options) {
+    var that = this,
+        opts = _.defaults(options || {}, {
+          type: 'POST',
+          statusCode: {
+            // do not show global error
+            400: null
+          }
+        });
+    return Backbone.ajax(opts)
+        .done(function () {
+          that.destroy();
+        }).fail(function (jqXHR) {
+          that.enableForm();
+          that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+        });
+  },
 
-    addGate: function (attrs) {
-      var gate = new Gate(attrs);
-      this.collection.add(gate, { merge: true });
-      return gate;
-    },
-
-    serializeData: function () {
-      return _.extend(ModalForm.prototype.serializeData.apply(this, arguments), {
-        method: this.method
-      });
-    }
-  });
+  addGate: function (attrs) {
+    var gate = new Gate(attrs);
+    this.collection.add(gate, { merge: true });
+    return gate;
+  },
 
+  serializeData: function () {
+    return _.extend(ModalForm.prototype.serializeData.apply(this, arguments), {
+      method: this.method
+    });
+  }
 });
+
+
index 0dfbea0ab1703f415b43f2b1be428e6cf6683bc9..7678405c62225c0834b7ac058ba1d4b11b82be61 100644 (file)
-define([
-  './gate-conditions-delete-view',
-  './templates'
-], function (DeleteConditionView) {
-
-  return Marionette.ItemView.extend({
-    tagName: 'tr',
-    template: Templates['quality-gate-detail-condition'],
-
-    modelEvents: {
-      'change': 'render'
-    },
-
-    ui: {
-      periodSelect: '[name=period]',
-      operatorSelect: '[name=operator]',
-      warningInput: '[name=warning]',
-      errorInput: '[name=error]',
-      actionsBox: '.quality-gate-condition-actions',
-      updateButton: '.update-condition',
-      deleteButton: '.delete-condition'
-    },
-
-    events: {
-      'click @ui.updateButton': 'saveCondition',
-      'click @ui.deleteButton': 'deleteCondition',
-      'click .add-condition': 'saveCondition',
-      'click .cancel-add-condition': 'cancelAddCondition',
-      'keyup :input': 'enableUpdate',
-      'change :input': 'enableUpdate'
-    },
-
-    onRender: function () {
-      this.ui.warningInput.val(this.model.get('warning'));
-      this.ui.errorInput.val(this.model.get('error'));
-
-      this.ui.periodSelect.select2({
-        allowClear: false,
-        minimumResultsForSearch: 999
-      });
-
-      this.ui.operatorSelect.select2({
-        allowClear: false,
-        minimumResultsForSearch: 999
-      });
-
-      if (this.model.isNew()) {
-        this.ui.periodSelect.select2('open');
-      }
-    },
-
-    saveCondition: function () {
-      var attrs = {
-        gateId: this.model.isNew() ? this.options.gate.id : void 0,
-        period: this.ui.periodSelect.val(),
-        op: this.ui.operatorSelect.val(),
-        warning: this.ui.warningInput.val(),
-        error: this.ui.errorInput.val()
-      };
-      this.model.save(attrs, { wait: true });
-    },
-
-    deleteCondition: function () {
-      new DeleteConditionView({
-        model: this.model,
-        metric: this.getMetric()
-      }).render();
-    },
-
-    cancelAddCondition: function () {
-      this.destroy();
-    },
-
-    enableUpdate: function () {
-      this.ui.updateButton.prop('disabled', false);
-    },
-
-    getMetric: function () {
-      var key = this.model.get('metric');
-      return _.findWhere(this.options.metrics, { key: key });
-    },
-
-    isDiffMetric: function () {
-      var key = this.model.get('metric');
-      return key.indexOf('new_') === 0;
-    },
-
-    serializeData: function () {
-      var period = _.findWhere(this.options.periods, { key: this.model.get('period') });
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        canEdit: this.options.canEdit,
-        periods: this.options.periods,
-        periodText: period ? period.text : t('value'),
-        metric: this.getMetric(),
-        isDiffMetric: this.isDiffMetric()
-      });
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import DeleteConditionView from './gate-conditions-delete-view';
+import './templates';
+
+export default Marionette.ItemView.extend({
+  tagName: 'tr',
+  template: Templates['quality-gate-detail-condition'],
+
+  modelEvents: {
+    'change': 'render'
+  },
+
+  ui: {
+    periodSelect: '[name=period]',
+    operatorSelect: '[name=operator]',
+    warningInput: '[name=warning]',
+    errorInput: '[name=error]',
+    actionsBox: '.quality-gate-condition-actions',
+    updateButton: '.update-condition',
+    deleteButton: '.delete-condition'
+  },
+
+  events: {
+    'click @ui.updateButton': 'saveCondition',
+    'click @ui.deleteButton': 'deleteCondition',
+    'click .add-condition': 'saveCondition',
+    'click .cancel-add-condition': 'cancelAddCondition',
+    'keyup :input': 'enableUpdate',
+    'change :input': 'enableUpdate'
+  },
+
+  onRender: function () {
+    this.ui.warningInput.val(this.model.get('warning'));
+    this.ui.errorInput.val(this.model.get('error'));
+
+    this.ui.periodSelect.select2({
+      allowClear: false,
+      minimumResultsForSearch: 999
+    });
+
+    this.ui.operatorSelect.select2({
+      allowClear: false,
+      minimumResultsForSearch: 999
+    });
+
+    if (this.model.isNew()) {
+      this.ui.periodSelect.select2('open');
     }
-  });
-
+  },
+
+  saveCondition: function () {
+    var attrs = {
+      gateId: this.model.isNew() ? this.options.gate.id : void 0,
+      period: this.ui.periodSelect.val(),
+      op: this.ui.operatorSelect.val(),
+      warning: this.ui.warningInput.val(),
+      error: this.ui.errorInput.val()
+    };
+    this.model.save(attrs, { wait: true });
+  },
+
+  deleteCondition: function () {
+    new DeleteConditionView({
+      model: this.model,
+      metric: this.getMetric()
+    }).render();
+  },
+
+  cancelAddCondition: function () {
+    this.destroy();
+  },
+
+  enableUpdate: function () {
+    this.ui.updateButton.prop('disabled', false);
+  },
+
+  getMetric: function () {
+    var key = this.model.get('metric');
+    return _.findWhere(this.options.metrics, { key: key });
+  },
+
+  isDiffMetric: function () {
+    var key = this.model.get('metric');
+    return key.indexOf('new_') === 0;
+  },
+
+  serializeData: function () {
+    var period = _.findWhere(this.options.periods, { key: this.model.get('period') });
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      canEdit: this.options.canEdit,
+      periods: this.options.periods,
+      periodText: period ? period.text : t('value'),
+      metric: this.getMetric(),
+      isDiffMetric: this.isDiffMetric()
+    });
+  }
 });
+
+
index c8ed23a28839271437afdf8afe0b8a80afe3a122..9922a0bc5b15ca777a5ca969c5022bc3c7803455 100644 (file)
@@ -1,39 +1,39 @@
-define([
-  'components/common/modal-form',
-  './templates'
-], function (ModalForm) {
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import ModalForm from 'components/common/modal-form';
+import './templates';
 
-  return ModalForm.extend({
-    template: Templates['quality-gates-condition-delete'],
+export default ModalForm.extend({
+  template: Templates['quality-gates-condition-delete'],
 
-    onFormSubmit: function () {
-      ModalForm.prototype.onFormSubmit.apply(this, arguments);
-      this.disableForm();
-      this.sendRequest();
-    },
+  onFormSubmit: function () {
+    ModalForm.prototype.onFormSubmit.apply(this, arguments);
+    this.disableForm();
+    this.sendRequest();
+  },
 
-    sendRequest: function () {
-      var that = this,
-          options = {
-            statusCode: {
-              // do not show global error
-              400: null
-            }
-          };
-      return this.model.destroy(options)
-          .done(function () {
-            that.destroy();
-          }).fail(function (jqXHR) {
-            that.enableForm();
-            that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
-          });
-    },
-
-    serializeData: function () {
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        metric: this.options.metric
-      });
-    }
-  });
+  sendRequest: function () {
+    var that = this,
+        options = {
+          statusCode: {
+            // do not show global error
+            400: null
+          }
+        };
+    return this.model.destroy(options)
+        .done(function () {
+          that.destroy();
+        }).fail(function (jqXHR) {
+          that.enableForm();
+          that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+        });
+  },
 
+  serializeData: function () {
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      metric: this.options.metric
+    });
+  }
 });
+
+
index 03390ac7a8918182d7192575cf472052991e09c1..5be03d5a0c639b0e872f9a826b2e9870b4865f26 100644 (file)
@@ -1,16 +1,16 @@
-define([
-  './templates'
-], function () {
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import './templates';
 
-  return Marionette.ItemView.extend({
-    tagName: 'tr',
-    template: Templates['quality-gate-detail-conditions-empty'],
-
-    serializeData: function () {
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        canEdit: this.options.canEdit
-      });
-    }
-  });
+export default Marionette.ItemView.extend({
+  tagName: 'tr',
+  template: Templates['quality-gate-detail-conditions-empty'],
 
+  serializeData: function () {
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      canEdit: this.options.canEdit
+    });
+  }
 });
+
+
index b0c0857cc95fa7da60770b4ca350c9bc1a7721fe..d02f8f936037d34f5d109c582fcd68608e00dd50 100644 (file)
@@ -1,75 +1,75 @@
-define([
-  './condition',
-  './gate-condition-view',
-  './gate-conditions-empty-view',
-  './templates'
-], function (Condition, ConditionView, ConditionsEmptyView) {
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import Condition from './condition';
+import ConditionView from './gate-condition-view';
+import ConditionsEmptyView from './gate-conditions-empty-view';
+import './templates';
 
-  return Marionette.CompositeView.extend({
-    template: Templates['quality-gate-detail-conditions'],
-    childView: ConditionView,
-    emptyView: ConditionsEmptyView,
-    childViewContainer: '.js-conditions',
+export default Marionette.CompositeView.extend({
+  template: Templates['quality-gate-detail-conditions'],
+  childView: ConditionView,
+  emptyView: ConditionsEmptyView,
+  childViewContainer: '.js-conditions',
 
-    ui: {
-      metricSelect: '#quality-gate-new-condition-metric'
-    },
+  ui: {
+    metricSelect: '#quality-gate-new-condition-metric'
+  },
 
-    events: {
-      'click .js-show-more': 'showMoreIntroduction',
-      'change @ui.metricSelect': 'addCondition'
-    },
+  events: {
+    'click .js-show-more': 'showMoreIntroduction',
+    'change @ui.metricSelect': 'addCondition'
+  },
 
-    childViewOptions: function () {
-      return {
-        canEdit: this.options.canEdit,
-        gate: this.model,
-        collectionView: this,
-        metrics: this.options.metrics,
-        periods: this.options.periods
-      };
-    },
+  childViewOptions: function () {
+    return {
+      canEdit: this.options.canEdit,
+      gate: this.model,
+      collectionView: this,
+      metrics: this.options.metrics,
+      periods: this.options.periods
+    };
+  },
 
-    onRender: function () {
-      this.ui.metricSelect.select2({
-        allowClear: false,
-        width: '250px',
-        placeholder: t('alerts.select_metric')
-      });
-    },
+  onRender: function () {
+    this.ui.metricSelect.select2({
+      allowClear: false,
+      width: '250px',
+      placeholder: t('alerts.select_metric')
+    });
+  },
 
-    showMoreIntroduction: function () {
-      this.$('.js-show-more').addClass('hidden');
-      this.$('.js-more').removeClass('hidden');
-    },
+  showMoreIntroduction: function () {
+    this.$('.js-show-more').addClass('hidden');
+    this.$('.js-more').removeClass('hidden');
+  },
 
-    addCondition: function () {
-      var metric = this.ui.metricSelect.val();
-      this.ui.metricSelect.select2('val', '');
-      var condition = new Condition({ metric: metric });
-      this.collection.add(condition);
-    },
+  addCondition: function () {
+    var metric = this.ui.metricSelect.val();
+    this.ui.metricSelect.select2('val', '');
+    var condition = new Condition({ metric: metric });
+    this.collection.add(condition);
+  },
 
-    groupedMetrics: function () {
-      var metrics = this.options.metrics.filter(function (metric) {
-        return !metric.hidden;
-      });
-      metrics = _.groupBy(metrics, 'domain');
-      metrics = _.map(metrics, function (list, domain) {
-        return {
-          domain: domain,
-          metrics: _.sortBy(list, 'short_name')
-        };
-      });
-      return _.sortBy(metrics, 'domain');
-    },
-
-    serializeData: function () {
-      return _.extend(Marionette.CompositeView.prototype.serializeData.apply(this, arguments), {
-        canEdit: this.options.canEdit,
-        metricGroups: this.groupedMetrics()
-      });
-    }
-  });
+  groupedMetrics: function () {
+    var metrics = this.options.metrics.filter(function (metric) {
+      return !metric.hidden;
+    });
+    metrics = _.groupBy(metrics, 'domain');
+    metrics = _.map(metrics, function (list, domain) {
+      return {
+        domain: domain,
+        metrics: _.sortBy(list, 'short_name')
+      };
+    });
+    return _.sortBy(metrics, 'domain');
+  },
 
+  serializeData: function () {
+    return _.extend(Marionette.CompositeView.prototype.serializeData.apply(this, arguments), {
+      canEdit: this.options.canEdit,
+      metricGroups: this.groupedMetrics()
+    });
+  }
 });
+
+
index c188c473be51983957df5a281aaf947752b7b20e..732074be79d819ed8eeeab79d504bb4c13ecd52b 100644 (file)
@@ -1,48 +1,48 @@
-define([
-  'components/common/select-list',
-  './templates'
-], function () {
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import 'components/common/select-list';
+import './templates';
 
-  return Marionette.ItemView.extend({
-    template: Templates['quality-gate-detail-projects'],
+export default Marionette.ItemView.extend({
+  template: Templates['quality-gate-detail-projects'],
 
-    onRender: function () {
-      if (!this.model.isDefault()) {
-        new window.SelectList({
-          el: this.$('#select-list-projects'),
-          width: '100%',
-          readOnly: !this.options.canEdit,
-          focusSearch: false,
-          format: function (item) {
-            return item.name;
-          },
-          searchUrl: baseUrl + '/api/qualitygates/search?gateId=' + this.model.id,
-          selectUrl: baseUrl + '/api/qualitygates/select',
-          deselectUrl: baseUrl + '/api/qualitygates/deselect',
-          extra: {
-            gateId: this.model.id
-          },
-          selectParameter: 'projectId',
-          selectParameterValue: 'id',
-          labels: {
-            selected: t('quality_gates.projects.with'),
-            deselected: t('quality_gates.projects.without'),
-            all: t('quality_gates.projects.all'),
-            noResults: t('quality_gates.projects.noResults')
-          },
-          tooltips: {
-            select: t('quality_gates.projects.select_hint'),
-            deselect: t('quality_gates.projects.deselect_hint')
-          }
-        });
-      }
-    },
-
-    serializeData: function () {
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        canEdit: this.options.canEdit
+  onRender: function () {
+    if (!this.model.isDefault()) {
+      new window.SelectList({
+        el: this.$('#select-list-projects'),
+        width: '100%',
+        readOnly: !this.options.canEdit,
+        focusSearch: false,
+        format: function (item) {
+          return item.name;
+        },
+        searchUrl: baseUrl + '/api/qualitygates/search?gateId=' + this.model.id,
+        selectUrl: baseUrl + '/api/qualitygates/select',
+        deselectUrl: baseUrl + '/api/qualitygates/deselect',
+        extra: {
+          gateId: this.model.id
+        },
+        selectParameter: 'projectId',
+        selectParameterValue: 'id',
+        labels: {
+          selected: t('quality_gates.projects.with'),
+          deselected: t('quality_gates.projects.without'),
+          all: t('quality_gates.projects.all'),
+          noResults: t('quality_gates.projects.noResults')
+        },
+        tooltips: {
+          select: t('quality_gates.projects.select_hint'),
+          deselect: t('quality_gates.projects.deselect_hint')
+        }
       });
     }
-  });
+  },
 
+  serializeData: function () {
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      canEdit: this.options.canEdit
+    });
+  }
 });
+
+
index 30036a3c3133cc73707a1630cb0750af7460bb9e..13b3e582b96f8edae835232c4b24a3b5a0d2b5f3 100644 (file)
@@ -1,29 +1,28 @@
-define([
-  './templates'
-], function () {
+import Marionette from 'backbone.marionette';
+import './templates';
 
-  return Marionette.ItemView.extend({
-    tagName: 'a',
-    className: 'list-group-item',
-    template: Templates['quality-gates-gate'],
+export default Marionette.ItemView.extend({
+  tagName: 'a',
+  className: 'list-group-item',
+  template: Templates['quality-gates-gate'],
 
-    modelEvents: {
-      'change': 'render'
-    },
+  modelEvents: {
+    'change': 'render'
+  },
 
-    events: {
-      'click': 'onClick'
-    },
+  events: {
+    'click': 'onClick'
+  },
 
-    onRender: function () {
-      this.$el.toggleClass('active', this.options.highlighted);
-      this.$el.attr('data-id', this.model.id);
-    },
-
-    onClick: function (e) {
-      e.preventDefault();
-      this.model.trigger('select', this.model);
-    }
-  });
+  onRender: function () {
+    this.$el.toggleClass('active', this.options.highlighted);
+    this.$el.attr('data-id', this.model.id);
+  },
 
+  onClick: function (e) {
+    e.preventDefault();
+    this.model.trigger('select', this.model);
+  }
 });
+
+
index 54b4e6ce13c085872f1218525720a1b8934a7a23..f118bc9295d01f919ddf0e393dfc22c32300a04a 100644 (file)
@@ -1,54 +1,54 @@
-define(function () {
-
-  return Backbone.Model.extend({
-
-    isDefault: function () {
-      return this.get('isDefault');
-    },
-
-    url: function () {
-      return baseUrl + '/api/qualitygates';
-    },
-
-    showUrl: function () {
-      return this.url() + '/show';
-    },
-
-    deleteUrl: function () {
-      return this.url() + '/destroy';
-    },
-
-    toggleDefaultUrl: function () {
-      var method = this.isDefault() ? 'unset_default' : 'set_as_default';
-      return this.url() + '/' + method;
-    },
-
-    sync: function (method, model, options) {
-      var opts = options || {};
-      opts.data = opts.data || {};
-      opts.data.id = model.id;
-      if (method === 'read') {
-        opts.url = this.showUrl();
-      }
-      if (method === 'delete') {
-        opts.url = this.deleteUrl();
-        opts.type = 'POST';
-      }
-      return Backbone.ajax(opts);
-    },
-
-    toggleDefault: function () {
-      var that = this;
-      var opts = {
-        type: 'POST',
-        url: this.toggleDefaultUrl(),
-        data: { id: this.id }
-      };
-      return Backbone.ajax(opts).done(function () {
-        that.collection.toggleDefault(that);
-      });
-    }
+import Backbone from 'backbone';
+
+export default Backbone.Model.extend({
+
+  isDefault: function () {
+    return this.get('isDefault');
+  },
+
+  url: function () {
+    return baseUrl + '/api/qualitygates';
+  },
+
+  showUrl: function () {
+    return this.url() + '/show';
+  },
+
+  deleteUrl: function () {
+    return this.url() + '/destroy';
+  },
 
-  });
+  toggleDefaultUrl: function () {
+    var method = this.isDefault() ? 'unset_default' : 'set_as_default';
+    return this.url() + '/' + method;
+  },
+
+  sync: function (method, model, options) {
+    var opts = options || {};
+    opts.data = opts.data || {};
+    opts.data.id = model.id;
+    if (method === 'read') {
+      opts.url = this.showUrl();
+    }
+    if (method === 'delete') {
+      opts.url = this.deleteUrl();
+      opts.type = 'POST';
+    }
+    return Backbone.ajax(opts);
+  },
+
+  toggleDefault: function () {
+    var that = this;
+    var opts = {
+      type: 'POST',
+      url: this.toggleDefaultUrl(),
+      data: { id: this.id }
+    };
+    return Backbone.ajax(opts).done(function () {
+      that.collection.toggleDefault(that);
+    });
+  }
 
 });
+
+
index cd36c381a39fe462262d3d3a44bc957dd59f8344..956cc21826a615bcf50c5e28b25ca17eb88810b5 100644 (file)
@@ -1,25 +1,24 @@
-define([
-  './gate-view',
-  './templates'
-], function (ItemView) {
+import Marionette from 'backbone.marionette';
+import ItemView from './gate-view';
+import './templates';
 
-  return Marionette.CompositeView.extend({
-    className: 'list-group',
-    template: Templates['quality-gates-gates'],
-    childView: ItemView,
-    childViewContainer: '.js-list',
+export default Marionette.CompositeView.extend({
+  className: 'list-group',
+  template: Templates['quality-gates-gates'],
+  childView: ItemView,
+  childViewContainer: '.js-list',
 
-    childViewOptions: function (model) {
-      return {
-        collectionView: this,
-        highlighted: model.id === this.highlighted
-      };
-    },
-
-    highlight: function (id) {
-      this.highlighted = id;
-      this.render();
-    }
-  });
+  childViewOptions: function (model) {
+    return {
+      collectionView: this,
+      highlighted: model.id === this.highlighted
+    };
+  },
 
+  highlight: function (id) {
+    this.highlighted = id;
+    this.render();
+  }
 });
+
+
index d33b35bcfe5791c73bacb0672d7fd4110f0cbdec..f7664745e19e4989ed66136907653f40136ee0e3 100644 (file)
@@ -1,30 +1,30 @@
-define([
-  './gate'
-], function (Gate) {
+import _ from 'underscore';
+import Backbone from 'backbone';
+import Gate from './gate';
 
-  return Backbone.Collection.extend({
-    model: Gate,
+export default Backbone.Collection.extend({
+  model: Gate,
 
-    url: function () {
-      return baseUrl + '/api/qualitygates/list';
-    },
+  url: function () {
+    return baseUrl + '/api/qualitygates/list';
+  },
 
-    parse: function (r) {
-      return r.qualitygates.map(function (gate) {
-        return _.extend(gate, { isDefault: gate.id === r.default });
-      });
-    },
+  parse: function (r) {
+    return r.qualitygates.map(function (gate) {
+      return _.extend(gate, { isDefault: gate.id === r.default });
+    });
+  },
 
-    comparator: function (item) {
-      return item.get('name').toLowerCase();
-    },
-
-    toggleDefault: function (gate) {
-      var isDefault = gate.isDefault();
-      this.forEach(function (model) {
-        model.set({ isDefault: gate.id === model.id ? !isDefault : false });
-      });
-    }
-  });
+  comparator: function (item) {
+    return item.get('name').toLowerCase();
+  },
 
+  toggleDefault: function (gate) {
+    var isDefault = gate.isDefault();
+    this.forEach(function (model) {
+      model.set({ isDefault: gate.id === model.id ? !isDefault : false });
+    });
+  }
 });
+
+
index b86b2c9ba62cc531eab2779710e11fd6cd97fa58..7a002258513ccfeeeb657c577016587d9825d4f7 100644 (file)
@@ -1,52 +1,52 @@
-define([
-  './rename-view',
-  './copy-view',
-  './delete-view',
-  './templates'
-], function (RenameView, CopyView, DeleteView) {
-
-  return Marionette.ItemView.extend({
-    template: Templates['quality-gate-detail-header'],
-
-    modelEvents: {
-      'change': 'render'
-    },
-
-    events: {
-      'click #quality-gate-rename': 'renameQualityGate',
-      'click #quality-gate-copy': 'copyQualityGate',
-      'click #quality-gate-delete': 'deleteQualityGate',
-      'click #quality-gate-toggle-default': 'toggleDefault'
-    },
-
-    renameQualityGate: function () {
-      new RenameView({
-        model: this.model
-      }).render();
-    },
-
-    copyQualityGate: function () {
-      new CopyView({
-        model: this.model,
-        collection: this.model.collection
-      }).render();
-    },
-
-    deleteQualityGate: function () {
-      new DeleteView({
-        model: this.model
-      }).render();
-    },
-
-    toggleDefault: function () {
-      this.model.toggleDefault();
-    },
-
-    serializeData: function () {
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        canEdit: this.options.canEdit
-      });
-    }
-  });
-
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import RenameView from './rename-view';
+import CopyView from './copy-view';
+import DeleteView from './delete-view';
+import './templates';
+
+export default Marionette.ItemView.extend({
+  template: Templates['quality-gate-detail-header'],
+
+  modelEvents: {
+    'change': 'render'
+  },
+
+  events: {
+    'click #quality-gate-rename': 'renameQualityGate',
+    'click #quality-gate-copy': 'copyQualityGate',
+    'click #quality-gate-delete': 'deleteQualityGate',
+    'click #quality-gate-toggle-default': 'toggleDefault'
+  },
+
+  renameQualityGate: function () {
+    new RenameView({
+      model: this.model
+    }).render();
+  },
+
+  copyQualityGate: function () {
+    new CopyView({
+      model: this.model,
+      collection: this.model.collection
+    }).render();
+  },
+
+  deleteQualityGate: function () {
+    new DeleteView({
+      model: this.model
+    }).render();
+  },
+
+  toggleDefault: function () {
+    this.model.toggleDefault();
+  },
+
+  serializeData: function () {
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      canEdit: this.options.canEdit
+    });
+  }
 });
+
+
index c9588a3d48fcec5106ce877049e1b14594083852..6128211275c13704ca6b0d5db1478fb5db2ff34f 100644 (file)
@@ -1,9 +1,8 @@
-define([
-  './templates'
-], function () {
-
-  return Marionette.ItemView.extend({
-    template: Templates['quality-gates-intro']
-  });
+import Marionette from 'backbone.marionette';
+import './templates';
 
+export default Marionette.ItemView.extend({
+  template: Templates['quality-gates-intro']
 });
+
+
index db02143caa69de7b20c8c32d4b3c935fca71027d..5d0a65ae47b3f90bee72546af062c556fdf60ab1 100644 (file)
@@ -1,28 +1,27 @@
-define([
-  './intro-view',
-  './templates'
-], function (IntroView) {
+import Marionette from 'backbone.marionette';
+import IntroView from './intro-view';
+import './templates';
 
-  return Marionette.LayoutView.extend({
-    template: Templates['quality-gates-layout'],
+export default Marionette.LayoutView.extend({
+  template: Templates['quality-gates-layout'],
 
-    regions: {
-      headerRegion: '.search-navigator-workspace-header',
-      actionsRegion: '.search-navigator-filters',
-      resultsRegion: '.quality-gates-results',
-      detailsRegion: '.search-navigator-workspace-details'
-    },
+  regions: {
+    headerRegion: '.search-navigator-workspace-header',
+    actionsRegion: '.search-navigator-filters',
+    resultsRegion: '.quality-gates-results',
+    detailsRegion: '.search-navigator-workspace-details'
+  },
 
-    onRender: function () {
-      var top = this.$('.search-navigator').offset().top;
-      this.$('.search-navigator-workspace-header').css({ top: top });
-      this.$('.search-navigator-side').css({ top: top }).isolatedScroll();
-      this.renderIntro();
-    },
-
-    renderIntro: function () {
-      this.detailsRegion.show(new IntroView());
-    }
-  });
+  onRender: function () {
+    var top = this.$('.search-navigator').offset().top;
+    this.$('.search-navigator-workspace-header').css({ top: top });
+    this.$('.search-navigator-side').css({ top: top }).isolatedScroll();
+    this.renderIntro();
+  },
 
+  renderIntro: function () {
+    this.detailsRegion.show(new IntroView());
+  }
 });
+
+
index d9b5946653a07fe3757f137d3c6a02fbd4d3cdaa..1cc4ddeed5a6d078d76210d1e989024f2eacef70 100644 (file)
@@ -1,23 +1,21 @@
-define([
-  './form-view'
-], function (FormView) {
+import FormView from './form-view';
 
-  return FormView.extend({
-    method: 'rename',
-
-    prepareRequest: function () {
-      var that = this;
-      var url = baseUrl + '/api/qualitygates/rename',
-          name = this.$('#quality-gate-form-name').val(),
-          options = {
-            url: url,
-            data: { id: this.model.id, name: name }
-          };
-      return this.sendRequest(options)
-          .done(function (r) {
-            that.model.set(r);
-          });
-    }
-  });
+export default FormView.extend({
+  method: 'rename',
 
+  prepareRequest: function () {
+    var that = this;
+    var url = baseUrl + '/api/qualitygates/rename',
+        name = this.$('#quality-gate-form-name').val(),
+        options = {
+          url: url,
+          data: { id: this.model.id, name: name }
+        };
+    return this.sendRequest(options)
+        .done(function (r) {
+          that.model.set(r);
+        });
+  }
 });
+
+
index 582c47361d5333c0472e3b6fd875dfbf9b5aaad7..52d28d4787cb7d53cd77026ea710040312901f7d 100644 (file)
@@ -1,22 +1,22 @@
-define(function () {
+import Backbone from 'backbone';
 
-  return Backbone.Router.extend({
-    routes: {
-      '': 'index',
-      'show/:id': 'show'
-    },
+export default Backbone.Router.extend({
+  routes: {
+    '': 'index',
+    'show/:id': 'show'
+  },
 
-    initialize: function (options) {
-      this.app = options.app;
-    },
+  initialize: function (options) {
+    this.app = options.app;
+  },
 
-    index: function () {
-      this.app.controller.index();
-    },
-
-    show: function (id) {
-      this.app.controller.show(id);
-    }
-  });
+  index: function () {
+    this.app.controller.index();
+  },
 
+  show: function (id) {
+    this.app.controller.show(id);
+  }
 });
+
+
index efed98e7d351dc63b99e1aa2b32738fd4b609f4a..a2fe43cbe18eded11b370be182c715ea9a8f7b1b 100644 (file)
@@ -1,97 +1,96 @@
-define([
-  './create-profile-view',
-  './restore-profile-view',
-  './restore-built-in-profiles-view',
-  './templates'
-], function (CreateProfileView, RestoreProfileView, RestoreBuiltInProfilesView) {
-
-  var $ = jQuery;
-
-  return Marionette.ItemView.extend({
-    template: Templates['quality-profiles-actions'],
-
-    events: {
-      'click #quality-profiles-create': 'onCreateClick',
-      'click #quality-profiles-restore': 'onRestoreClick',
-      'click #quality-profiles-restore-built-in': 'onRestoreBuiltInClick',
-
-      'click .js-filter-by-language': 'onLanguageClick'
-    },
-
-    onCreateClick: function (e) {
-      e.preventDefault();
-      this.create();
-    },
-
-    onRestoreClick: function (e) {
-      e.preventDefault();
-      this.restore();
-    },
-
-    onRestoreBuiltInClick: function (e) {
-      e.preventDefault();
-      this.restoreBuiltIn();
-    },
-
-    onLanguageClick: function (e) {
-      e.preventDefault();
-      var language = $(e.currentTarget).data('language');
-      this.filterByLanguage(language);
-    },
-
-    create: function () {
-      var that = this;
-      this.requestImporters().done(function () {
-        new CreateProfileView({
-          collection: that.collection,
-          languages: that.languages,
-          importers: that.importers
-        }).render();
-      });
-    },
-
-    restore: function () {
-      new RestoreProfileView({
-        collection: this.collection
+import $ from 'jquery';
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import CreateProfileView from './create-profile-view';
+import RestoreProfileView from './restore-profile-view';
+import RestoreBuiltInProfilesView from './restore-built-in-profiles-view';
+import './templates';
+
+export default Marionette.ItemView.extend({
+  template: Templates['quality-profiles-actions'],
+
+  events: {
+    'click #quality-profiles-create': 'onCreateClick',
+    'click #quality-profiles-restore': 'onRestoreClick',
+    'click #quality-profiles-restore-built-in': 'onRestoreBuiltInClick',
+
+    'click .js-filter-by-language': 'onLanguageClick'
+  },
+
+  onCreateClick: function (e) {
+    e.preventDefault();
+    this.create();
+  },
+
+  onRestoreClick: function (e) {
+    e.preventDefault();
+    this.restore();
+  },
+
+  onRestoreBuiltInClick: function (e) {
+    e.preventDefault();
+    this.restoreBuiltIn();
+  },
+
+  onLanguageClick: function (e) {
+    e.preventDefault();
+    var language = $(e.currentTarget).data('language');
+    this.filterByLanguage(language);
+  },
+
+  create: function () {
+    var that = this;
+    this.requestImporters().done(function () {
+      new CreateProfileView({
+        collection: that.collection,
+        languages: that.languages,
+        importers: that.importers
       }).render();
-    },
+    });
+  },
+
+  restore: function () {
+    new RestoreProfileView({
+      collection: this.collection
+    }).render();
+  },
+
+  restoreBuiltIn: function () {
+    new RestoreBuiltInProfilesView({
+      collection: this.collection,
+      languages: this.languages
+    }).render();
+  },
+
+  requestLanguages: function () {
+    var that = this,
+        url = baseUrl + '/api/languages/list';
+    return $.get(url).done(function (r) {
+      that.languages = r.languages;
+    });
+  },
+
+  requestImporters: function () {
+    var that = this,
+        url = baseUrl + '/api/qualityprofiles/importers';
+    return $.get(url).done(function (r) {
+      that.importers = r.importers;
+    });
+  },
+
+  filterByLanguage: function (language) {
+    this.selectedLanguage = _.findWhere(this.languages, { key: language });
+    this.render();
+    this.collection.trigger('filter', language);
+  },
+
+  serializeData: function () {
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      canWrite: this.options.canWrite,
+      languages: this.languages,
+      selectedLanguage: this.selectedLanguage
+    });
+  }
+});
 
-    restoreBuiltIn: function () {
-      new RestoreBuiltInProfilesView({
-        collection: this.collection,
-        languages: this.languages
-      }).render();
-    },
-
-    requestLanguages: function () {
-      var that = this,
-          url = baseUrl + '/api/languages/list';
-      return $.get(url).done(function (r) {
-        that.languages = r.languages;
-      });
-    },
-
-    requestImporters: function () {
-      var that = this,
-          url = baseUrl + '/api/qualityprofiles/importers';
-      return $.get(url).done(function (r) {
-        that.importers = r.importers;
-      });
-    },
-
-    filterByLanguage: function (language) {
-      this.selectedLanguage = _.findWhere(this.languages, { key: language });
-      this.render();
-      this.collection.trigger('filter', language);
-    },
-
-    serializeData: function () {
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        canWrite: this.options.canWrite,
-        languages: this.languages,
-        selectedLanguage: this.selectedLanguage
-      });
-    }
-  });
 
-});
index cd94804cb039e223f4061af085959d96d693168d..1a81ee6598b9ea8ef8d47d98bb8fc7d2885a8b93 100644 (file)
@@ -1,62 +1,62 @@
-define([
-  './router',
-  './controller',
-  './layout',
-  './profiles',
-  './actions-view',
-  './profiles-view'
-], function (Router, Controller, Layout, Profiles, ActionsView, ProfilesView) {
-
-  var $ = jQuery,
-      App = new Marionette.Application(),
-      requestUser = $.get(baseUrl + '/api/users/current').done(function (r) {
-        App.canWrite = r.permissions.global.indexOf('profileadmin') !== -1;
-      }),
-      requestExporters = $.get(baseUrl + '/api/qualityprofiles/exporters').done(function (r) {
-        App.exporters = r.exporters;
-      }),
-      init = function (options) {
-        // Layout
-        this.layout = new Layout({ el: options.el });
-        this.layout.render();
-        $('#footer').addClass('search-navigator-footer');
-
-        // Profiles List
-        this.profiles = new Profiles();
-
-        // Controller
-        this.controller = new Controller({ app: this });
-
-        // Actions View
-        this.actionsView = new ActionsView({
-          collection: this.profiles,
-          canWrite: this.canWrite
-        });
-        this.actionsView.requestLanguages().done(function () {
-          App.layout.actionsRegion.show(App.actionsView);
-        });
-
-        // Profiles View
-        this.profilesView = new ProfilesView({
-          collection: this.profiles,
-          canWrite: this.canWrite
-        });
-        this.layout.resultsRegion.show(this.profilesView);
-
-        // Router
-        this.router = new Router({ app: this });
-        Backbone.history.start({
-          pushState: true,
-          root: options.urlRoot
-        });
-      };
-
-  App.on('start', function (options) {
-    $.when(window.requestMessages(), requestUser, requestExporters).done(function () {
-      init.call(App, options);
-    });
+import $ from 'jquery';
+import Backbone from 'backbone';
+import Marionette from 'backbone.marionette';
+import Router from './router';
+import Controller from './controller';
+import Layout from './layout';
+import Profiles from './profiles';
+import ActionsView from './actions-view';
+import ProfilesView from './profiles-view';
+
+var App = new Marionette.Application(),
+    requestUser = $.get(baseUrl + '/api/users/current').done(function (r) {
+      App.canWrite = r.permissions.global.indexOf('profileadmin') !== -1;
+    }),
+    requestExporters = $.get(baseUrl + '/api/qualityprofiles/exporters').done(function (r) {
+      App.exporters = r.exporters;
+    }),
+    init = function (options) {
+      // Layout
+      this.layout = new Layout({ el: options.el });
+      this.layout.render();
+      $('#footer').addClass('search-navigator-footer');
+
+      // Profiles List
+      this.profiles = new Profiles();
+
+      // Controller
+      this.controller = new Controller({ app: this });
+
+      // Actions View
+      this.actionsView = new ActionsView({
+        collection: this.profiles,
+        canWrite: this.canWrite
+      });
+      this.actionsView.requestLanguages().done(function () {
+        App.layout.actionsRegion.show(App.actionsView);
+      });
+
+      // Profiles View
+      this.profilesView = new ProfilesView({
+        collection: this.profiles,
+        canWrite: this.canWrite
+      });
+      this.layout.resultsRegion.show(this.profilesView);
+
+      // Router
+      this.router = new Router({ app: this });
+      Backbone.history.start({
+        pushState: true,
+        root: options.urlRoot
+      });
+    };
+
+App.on('start', function (options) {
+  $.when(window.requestMessages(), requestUser, requestExporters).done(function () {
+    init.call(App, options);
   });
+});
+
+export default App;
 
-  return App;
 
-});
index a8acc0d532520467b7866fe9d693eb0763607585..a3d5ec6b7ad774334dd37c5b1e5bd7ea91eb0c87 100644 (file)
@@ -1,63 +1,62 @@
-define([
-  'components/common/modal-form',
-  './templates'
-], function (ModalFormView) {
+import $ from 'jquery';
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import ModalFormView from 'components/common/modal-form';
+import './templates';
 
-  var $ = jQuery;
+export default ModalFormView.extend({
+  template: Templates['quality-profiles-change-profile-parent'],
 
-  return ModalFormView.extend({
-    template: Templates['quality-profiles-change-profile-parent'],
+  onRender: function () {
+    ModalFormView.prototype.onRender.apply(this, arguments);
+    this.$('select').select2({
+      width: '250px',
+      minimumResultsForSearch: 50
+    });
+  },
 
-    onRender: function () {
-      ModalFormView.prototype.onRender.apply(this, arguments);
-      this.$('select').select2({
-        width: '250px',
-        minimumResultsForSearch: 50
-      });
-    },
+  onFormSubmit: function () {
+    ModalFormView.prototype.onFormSubmit.apply(this, arguments);
+    this.disableForm();
+    this.sendRequest();
+  },
 
-    onFormSubmit: function () {
-      ModalFormView.prototype.onFormSubmit.apply(this, arguments);
-      this.disableForm();
-      this.sendRequest();
-    },
+  sendRequest: function () {
+    var that = this,
+        url = baseUrl + '/api/qualityprofiles/change_parent',
+        parent = this.$('#change-profile-parent').val(),
+        options = {
+          profileKey: this.model.get('key'),
+          parentKey: parent
+        };
+    return $.ajax({
+      type: 'POST',
+      url: url,
+      data: options,
+      statusCode: {
+        // do not show global error
+        400: null
+      }
+    }).done(function () {
+      that.model.collection.fetch();
+      that.model.trigger('select', that.model);
+      that.destroy();
+    }).fail(function (jqXHR) {
+      that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+      that.enableForm();
+    });
+  },
 
-    sendRequest: function () {
-      var that = this,
-          url = baseUrl + '/api/qualityprofiles/change_parent',
-          parent = this.$('#change-profile-parent').val(),
-          options = {
-            profileKey: this.model.get('key'),
-            parentKey: parent
-          };
-      return $.ajax({
-        type: 'POST',
-        url: url,
-        data: options,
-        statusCode: {
-          // do not show global error
-          400: null
-        }
-      }).done(function () {
-        that.model.collection.fetch();
-        that.model.trigger('select', that.model);
-        that.destroy();
-      }).fail(function (jqXHR) {
-        that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
-        that.enableForm();
-      });
-    },
+  serializeData: function () {
+    var that = this,
+        profilesData = this.model.collection.toJSON(),
+        profiles = _.filter(profilesData, function (profile) {
+          return profile.language === that.model.get('language') && profile.key !== that.model.id;
+        });
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      profiles: profiles
+    });
+  }
+});
 
-    serializeData: function () {
-      var that = this,
-          profilesData = this.model.collection.toJSON(),
-          profiles = _.filter(profilesData, function (profile) {
-            return profile.language === that.model.get('language') && profile.key !== that.model.id;
-          });
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        profiles: profiles
-      });
-    }
-  });
 
-});
index 09fed1ff580afe0ddf38113cd5da1122d35ab3fd..489db7f8b5361bcae87d4c88172a08e98f16aa43 100644 (file)
-define([
-  './profile-header-view',
-  './profile-details-view'
-], function (ProfileHeaderView, ProfileDetailsView) {
-
-  var $ = jQuery;
-
-  return Marionette.Controller.extend({
-
-    initialize: function () {
-      this.listenTo(this.options.app.profiles, 'select', this.onProfileSelect);
-      this.listenTo(this.options.app.profiles, 'setAsDefault', this.onProfileSetAsDefault);
-      this.listenTo(this.options.app.profiles, 'destroy', this.onProfileDestroy);
-    },
-
-    index: function () {
-      this.fetchProfiles();
-    },
-
-    show: function (key) {
-      var that = this;
-      this.fetchProfiles().done(function () {
-        var profile = that.options.app.profiles.findWhere({ key: key });
-        if (profile != null) {
-          profile.trigger('select', profile, { trigger: false });
-        }
-      });
-    },
-
-    changelog: function (key, since, to) {
-      var that = this;
-      this.anchor = 'changelog';
-      this.fetchProfiles().done(function () {
-        var profile = that.options.app.profiles.findWhere({ key: key });
-        if (profile != null) {
-          profile.trigger('select', profile, { trigger: false });
-          profile.fetchChangelog({ since: since, to: to });
-        }
-      });
-    },
-
-    compare: function (key, withKey) {
-      var that = this;
-      this.anchor = 'comparison';
-      this.fetchProfiles().done(function () {
-        var profile = that.options.app.profiles.findWhere({ key: key });
-        if (profile != null) {
-          profile.trigger('select', profile, { trigger: false });
-          profile.compareWith(withKey);
-        }
-      });
-    },
-
-    onProfileSelect: function (profile, options) {
-      var that = this,
-          key = profile.get('key'),
-          route = 'show?key=' + encodeURIComponent(key),
-          opts = _.defaults(options || {}, { trigger: true });
-      if (opts.trigger) {
-        this.options.app.router.navigate(route);
+import $ from 'jquery';
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import ProfileHeaderView from './profile-header-view';
+import ProfileDetailsView from './profile-details-view';
+
+export default Marionette.Controller.extend({
+
+  initialize: function () {
+    this.listenTo(this.options.app.profiles, 'select', this.onProfileSelect);
+    this.listenTo(this.options.app.profiles, 'setAsDefault', this.onProfileSetAsDefault);
+    this.listenTo(this.options.app.profiles, 'destroy', this.onProfileDestroy);
+  },
+
+  index: function () {
+    this.fetchProfiles();
+  },
+
+  show: function (key) {
+    var that = this;
+    this.fetchProfiles().done(function () {
+      var profile = that.options.app.profiles.findWhere({ key: key });
+      if (profile != null) {
+        profile.trigger('select', profile, { trigger: false });
       }
-      this.options.app.profilesView.highlight(key);
-      this.fetchProfile(profile).done(function () {
-        var profileHeaderView = new ProfileHeaderView({
-          model: profile,
-          canWrite: that.options.app.canWrite
-        });
-        that.options.app.layout.headerRegion.show(profileHeaderView);
-
-        var profileDetailsView = new ProfileDetailsView({
-          model: profile,
-          canWrite: that.options.app.canWrite,
-          exporters: that.options.app.exporters,
-          anchor: that.anchor
-        });
-        that.options.app.layout.detailsRegion.show(profileDetailsView);
-
-        that.anchor = null;
-      });
-    },
-
-    onProfileSetAsDefault: function (profile) {
-      var that = this,
-          url = baseUrl + '/api/qualityprofiles/set_default',
-          key = profile.get('key'),
-          options = { profileKey: key };
-      return $.post(url, options).done(function () {
-        profile.set({ isDefault: true });
-        that.fetchProfiles();
-      });
-    },
-
-    onProfileDestroy: function () {
-      this.options.app.router.navigate('');
-      this.options.app.layout.headerRegion.reset();
-      this.options.app.layout.detailsRegion.reset();
-      this.options.app.layout.renderIntro();
-      this.options.app.profilesView.highlight(null);
-    },
-
-    fetchProfiles: function () {
-      return this.options.app.profiles.fetch({ reset: true });
-    },
-
-    fetchProfile: function (profile) {
-      return profile.fetch();
+    });
+  },
+
+  changelog: function (key, since, to) {
+    var that = this;
+    this.anchor = 'changelog';
+    this.fetchProfiles().done(function () {
+      var profile = that.options.app.profiles.findWhere({ key: key });
+      if (profile != null) {
+        profile.trigger('select', profile, { trigger: false });
+        profile.fetchChangelog({ since: since, to: to });
+      }
+    });
+  },
+
+  compare: function (key, withKey) {
+    var that = this;
+    this.anchor = 'comparison';
+    this.fetchProfiles().done(function () {
+      var profile = that.options.app.profiles.findWhere({ key: key });
+      if (profile != null) {
+        profile.trigger('select', profile, { trigger: false });
+        profile.compareWith(withKey);
+      }
+    });
+  },
+
+  onProfileSelect: function (profile, options) {
+    var that = this,
+        key = profile.get('key'),
+        route = 'show?key=' + encodeURIComponent(key),
+        opts = _.defaults(options || {}, { trigger: true });
+    if (opts.trigger) {
+      this.options.app.router.navigate(route);
     }
+    this.options.app.profilesView.highlight(key);
+    this.fetchProfile(profile).done(function () {
+      var profileHeaderView = new ProfileHeaderView({
+        model: profile,
+        canWrite: that.options.app.canWrite
+      });
+      that.options.app.layout.headerRegion.show(profileHeaderView);
 
-  });
+      var profileDetailsView = new ProfileDetailsView({
+        model: profile,
+        canWrite: that.options.app.canWrite,
+        exporters: that.options.app.exporters,
+        anchor: that.anchor
+      });
+      that.options.app.layout.detailsRegion.show(profileDetailsView);
+
+      that.anchor = null;
+    });
+  },
+
+  onProfileSetAsDefault: function (profile) {
+    var that = this,
+        url = baseUrl + '/api/qualityprofiles/set_default',
+        key = profile.get('key'),
+        options = { profileKey: key };
+    return $.post(url, options).done(function () {
+      profile.set({ isDefault: true });
+      that.fetchProfiles();
+    });
+  },
+
+  onProfileDestroy: function () {
+    this.options.app.router.navigate('');
+    this.options.app.layout.headerRegion.reset();
+    this.options.app.layout.detailsRegion.reset();
+    this.options.app.layout.renderIntro();
+    this.options.app.profilesView.highlight(null);
+  },
+
+  fetchProfiles: function () {
+    return this.options.app.profiles.fetch({ reset: true });
+  },
+
+  fetchProfile: function (profile) {
+    return profile.fetch();
+  }
 
 });
+
+
index 246d2856bf3926714d569ed35feb0caeabb5cc4a..9c7d29d0dbc8e0de7cee86c5e75ca081cadc607b 100644 (file)
@@ -1,50 +1,47 @@
-define([
-  'components/common/modal-form',
-  './profile',
-  './templates'
-], function (ModalFormView, Profile) {
+import $ from 'jquery';
+import ModalFormView from 'components/common/modal-form';
+import Profile from './profile';
+import './templates';
 
-  var $ = jQuery;
+export default ModalFormView.extend({
+  template: Templates['quality-profiles-copy-profile'],
 
-  return ModalFormView.extend({
-    template: Templates['quality-profiles-copy-profile'],
+  onFormSubmit: function () {
+    ModalFormView.prototype.onFormSubmit.apply(this, arguments);
+    this.disableForm();
+    this.sendRequest();
+  },
 
-    onFormSubmit: function () {
-      ModalFormView.prototype.onFormSubmit.apply(this, arguments);
-      this.disableForm();
-      this.sendRequest();
-    },
+  sendRequest: function () {
+    var that = this,
+        url = baseUrl + '/api/qualityprofiles/copy',
+        name = this.$('#copy-profile-name').val(),
+        options = {
+          fromKey: this.model.get('key'),
+          toName: name
+        };
+    return $.ajax({
+      type: 'POST',
+      url: url,
+      data: options,
+      statusCode: {
+        // do not show global error
+        400: null
+      }
+    }).done(function (r) {
+      that.addProfile(r);
+      that.destroy();
+    }).fail(function (jqXHR) {
+      that.enableForm();
+      that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+    });
+  },
 
-    sendRequest: function () {
-      var that = this,
-          url = baseUrl + '/api/qualityprofiles/copy',
-          name = this.$('#copy-profile-name').val(),
-          options = {
-            fromKey: this.model.get('key'),
-            toName: name
-          };
-      return $.ajax({
-        type: 'POST',
-        url: url,
-        data: options,
-        statusCode: {
-          // do not show global error
-          400: null
-        }
-      }).done(function (r) {
-        that.addProfile(r);
-        that.destroy();
-      }).fail(function (jqXHR) {
-        that.enableForm();
-        that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
-      });
-    },
+  addProfile: function (profileData) {
+    var profile = new Profile(profileData);
+    this.model.collection.add([profile]);
+    profile.trigger('select', profile);
+  }
+});
 
-    addProfile: function (profileData) {
-      var profile = new Profile(profileData);
-      this.model.collection.add([profile]);
-      profile.trigger('select', profile);
-    }
-  });
 
-});
index e120c36d705d931e014d1e4eb64bf2f15c029cc4..a6258bff571501d82325d66425653455caf9420c 100644 (file)
@@ -1,87 +1,85 @@
-define([
-  'components/common/modal-form',
-  'components/common/file-upload',
-  './profile',
-  './templates'
-], function (ModalFormView, uploader, Profile) {
+import $ from 'jquery';
+import _ from 'underscore';
+import ModalFormView from 'components/common/modal-form';
+import uploader from 'components/common/file-upload';
+import Profile from './profile';
+import './templates';
 
-  var $ = jQuery;
+export default ModalFormView.extend({
+  template: Templates['quality-profiles-create-profile'],
 
-  return ModalFormView.extend({
-    template: Templates['quality-profiles-create-profile'],
+  events: function () {
+    return _.extend(ModalFormView.prototype.events.apply(this, arguments), {
+      'change #create-profile-language': 'onLanguageChange'
+    });
+  },
 
-    events: function () {
-      return _.extend(ModalFormView.prototype.events.apply(this, arguments), {
-        'change #create-profile-language': 'onLanguageChange'
-      });
-    },
-
-    onFormSubmit: function (e) {
-      ModalFormView.prototype.onFormSubmit.apply(this, arguments);
-      this.sendRequest(e);
-    },
+  onFormSubmit: function (e) {
+    ModalFormView.prototype.onFormSubmit.apply(this, arguments);
+    this.sendRequest(e);
+  },
 
-    onRender: function () {
-      ModalFormView.prototype.onRender.apply(this, arguments);
-      this.$('select').select2({
-        width: '250px',
-        minimumResultsForSearch: 50
-      });
-      this.onLanguageChange();
-    },
+  onRender: function () {
+    ModalFormView.prototype.onRender.apply(this, arguments);
+    this.$('select').select2({
+      width: '250px',
+      minimumResultsForSearch: 50
+    });
+    this.onLanguageChange();
+  },
 
-    onLanguageChange: function () {
-      var that = this;
-      var language = this.$('#create-profile-language').val();
-      var importers = this.getImportersForLanguages(language);
-      this.$('.js-importer').each(function () {
-        that.emptyInput($(this));
-        $(this).addClass('hidden');
-      });
-      importers.forEach(function (importer) {
-        that.$('.js-importer[data-key="' + importer.key + '"]').removeClass('hidden');
-      });
-    },
+  onLanguageChange: function () {
+    var that = this;
+    var language = this.$('#create-profile-language').val();
+    var importers = this.getImportersForLanguages(language);
+    this.$('.js-importer').each(function () {
+      that.emptyInput($(this));
+      $(this).addClass('hidden');
+    });
+    importers.forEach(function (importer) {
+      that.$('.js-importer[data-key="' + importer.key + '"]').removeClass('hidden');
+    });
+  },
 
-    emptyInput: function (e) {
-      e.wrap('<form>').closest('form').get(0).reset();
-      e.unwrap();
-    },
+  emptyInput: function (e) {
+    e.wrap('<form>').closest('form').get(0).reset();
+    e.unwrap();
+  },
 
-    sendRequest: function (e) {
-      var that = this;
-      uploader({ form: $(e.currentTarget) }).done(function (r) {
-        if (_.isArray(r.errors) || _.isArray(r.warnings)) {
-          that.showErrors(r.errors, r.warnings);
-        } else {
-          that.addProfile(r.profile);
-          that.destroy();
-        }
-      });
-    },
-
-    addProfile: function (profileData) {
-      var profile = new Profile(profileData);
-      this.collection.add([profile]);
-      profile.trigger('select', profile);
-    },
-
-    getImportersForLanguages: function (language) {
-      if (language != null) {
-        return this.options.importers.filter(function (importer) {
-          return importer.languages.indexOf(language) !== -1;
-        });
+  sendRequest: function (e) {
+    var that = this;
+    uploader({ form: $(e.currentTarget) }).done(function (r) {
+      if (_.isArray(r.errors) || _.isArray(r.warnings)) {
+        that.showErrors(r.errors, r.warnings);
       } else {
-        return [];
+        that.addProfile(r.profile);
+        that.destroy();
       }
-    },
+    });
+  },
+
+  addProfile: function (profileData) {
+    var profile = new Profile(profileData);
+    this.collection.add([profile]);
+    profile.trigger('select', profile);
+  },
 
-    serializeData: function () {
-      return _.extend(ModalFormView.prototype.serializeData.apply(this, arguments), {
-        languages: this.options.languages,
-        importers: this.options.importers
+  getImportersForLanguages: function (language) {
+    if (language != null) {
+      return this.options.importers.filter(function (importer) {
+        return importer.languages.indexOf(language) !== -1;
       });
+    } else {
+      return [];
     }
-  });
+  },
 
+  serializeData: function () {
+    return _.extend(ModalFormView.prototype.serializeData.apply(this, arguments), {
+      languages: this.options.languages,
+      importers: this.options.importers
+    });
+  }
 });
+
+
index 7511506f4fd4e77f36488e61c0560560a4df66e1..ed2ee8ac7da72d855fb2826cfd80c08a2794fc50 100644 (file)
@@ -1,43 +1,40 @@
-define([
-  'components/common/modal-form',
-  './templates'
-], function (ModalFormView) {
+import $ from 'jquery';
+import ModalFormView from 'components/common/modal-form';
+import './templates';
 
-  var $ = jQuery;
+export default ModalFormView.extend({
+  template: Templates['quality-profiles-delete-profile'],
 
-  return ModalFormView.extend({
-    template: Templates['quality-profiles-delete-profile'],
+  modelEvents: {
+    'destroy': 'destroy'
+  },
 
-    modelEvents: {
-      'destroy': 'destroy'
-    },
+  onFormSubmit: function () {
+    ModalFormView.prototype.onFormSubmit.apply(this, arguments);
+    this.disableForm();
+    this.sendRequest();
+  },
 
-    onFormSubmit: function () {
-      ModalFormView.prototype.onFormSubmit.apply(this, arguments);
-      this.disableForm();
-      this.sendRequest();
-    },
+  sendRequest: function () {
+    var that = this,
+        url = baseUrl + '/api/qualityprofiles/delete',
+        options = { profileKey: this.model.get('key') };
+    return $.ajax({
+      type: 'POST',
+      url: url,
+      data: options,
+      statusCode: {
+        // do not show global error
+        400: null
+      }
+    }).done(function () {
+      that.model.collection.fetch();
+      that.model.trigger('destroy', that.model, that.model.collection);
+    }).fail(function (jqXHR) {
+      that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+      that.enableForm();
+    });
+  }
+});
 
-    sendRequest: function () {
-      var that = this,
-          url = baseUrl + '/api/qualityprofiles/delete',
-          options = { profileKey: this.model.get('key') };
-      return $.ajax({
-        type: 'POST',
-        url: url,
-        data: options,
-        statusCode: {
-          // do not show global error
-          400: null
-        }
-      }).done(function () {
-        that.model.collection.fetch();
-        that.model.trigger('destroy', that.model, that.model.collection);
-      }).fail(function (jqXHR) {
-        that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
-        that.enableForm();
-      });
-    }
-  });
 
-});
index f511e5b6383cffb7a8a75dbe42a77269a278869d..efb8e83253dd9caed99f2595a975e6f653f59070 100644 (file)
@@ -1,31 +1,27 @@
-(function () {
+Handlebars.registerHelper('profileUrl', function (key) {
+  return baseUrl + '/profiles/show?key=' + encodeURIComponent(key);
+});
 
-  Handlebars.registerHelper('profileUrl', function (key) {
-    return baseUrl + '/profiles/show?key=' + encodeURIComponent(key);
-  });
+Handlebars.registerHelper('exporterUrl', function (profile, exporterKey) {
+  var url = baseUrl + '/api/qualityprofiles/export';
+  url += '?language=' + encodeURIComponent(profile.language);
+  url += '&name=' + encodeURIComponent(profile.name);
+  if (exporterKey != null) {
+    url += '&exporterKey=' + encodeURIComponent(exporterKey);
+  }
+  return url;
+});
 
-  Handlebars.registerHelper('exporterUrl', function (profile, exporterKey) {
-    var url = baseUrl + '/api/qualityprofiles/export';
-    url += '?language=' + encodeURIComponent(profile.language);
-    url += '&name=' + encodeURIComponent(profile.name);
-    if (exporterKey != null) {
-      url += '&exporterKey=' + encodeURIComponent(exporterKey);
-    }
-    return url;
-  });
+Handlebars.registerHelper('severityChangelog', function (severity) {
+  var label = '<i class="icon-severity-' + severity.toLowerCase() + '"></i>&nbsp;' + t('severity', severity),
+      message = tp('quality_profiles.severity_set_to_x', label);
+  return new Handlebars.SafeString(message);
+});
 
-  Handlebars.registerHelper('severityChangelog', function (severity) {
-    var label = '<i class="icon-severity-' + severity.toLowerCase() + '"></i>&nbsp;' + t('severity', severity),
-        message = tp('quality_profiles.severity_set_to_x', label);
-    return new Handlebars.SafeString(message);
-  });
-
-  Handlebars.registerHelper('parameterChangelog', function (value, parameter) {
-    if (parameter) {
-      return new Handlebars.SafeString(tp('quality_profiles.parameter_set_to_x', value, parameter));
-    } else {
-      return new Handlebars.SafeString(tp('quality_profiles.changelog.parameter_reset_to_default_value_x', parameter));
-    }
-  });
-
-})();
+Handlebars.registerHelper('parameterChangelog', function (value, parameter) {
+  if (parameter) {
+    return new Handlebars.SafeString(tp('quality_profiles.parameter_set_to_x', value, parameter));
+  } else {
+    return new Handlebars.SafeString(tp('quality_profiles.changelog.parameter_reset_to_default_value_x', parameter));
+  }
+});
index bb409c80cfe73487c1311a6c8734605f13472ee8..c250e4c756992371df428507bb87b8b01328e2dd 100644 (file)
@@ -1,9 +1,8 @@
-define([
-  './templates'
-], function () {
-
-  return Marionette.ItemView.extend({
-    template: Templates['quality-profiles-intro']
-  });
+import Marionette from 'backbone.marionette';
+import './templates';
 
+export default Marionette.ItemView.extend({
+  template: Templates['quality-profiles-intro']
 });
+
+
index eebc8a27045e8de5de8c86e7b070ee0a9392a502..6f7a0af90570f6f816173e852d42265a8674d84b 100644 (file)
@@ -1,30 +1,29 @@
-define([
-  './intro-view',
-  './templates'
-], function (IntroView) {
+import Marionette from 'backbone.marionette';
+import IntroView from './intro-view';
+import './templates';
 
-  return Marionette.LayoutView.extend({
-    template: Templates['quality-profiles-layout'],
+export default Marionette.LayoutView.extend({
+  template: Templates['quality-profiles-layout'],
 
-    regions: {
-      headerRegion: '.search-navigator-workspace-header',
-      actionsRegion: '.search-navigator-filters',
-      resultsRegion: '.quality-profiles-results',
-      detailsRegion: '.search-navigator-workspace-details'
-    },
+  regions: {
+    headerRegion: '.search-navigator-workspace-header',
+    actionsRegion: '.search-navigator-filters',
+    resultsRegion: '.quality-profiles-results',
+    detailsRegion: '.search-navigator-workspace-details'
+  },
 
-    onRender: function () {
-      var navigator = this.$('.search-navigator');
-      navigator.addClass('sticky search-navigator-extended-view');
-      var top = navigator.offset().top;
-      this.$('.search-navigator-workspace-header').css({ top: top });
-      this.$('.search-navigator-side').css({ top: top }).isolatedScroll();
-      this.renderIntro();
-    },
-
-    renderIntro: function () {
-      this.detailsRegion.show(new IntroView());
-    }
-  });
+  onRender: function () {
+    var navigator = this.$('.search-navigator');
+    navigator.addClass('sticky search-navigator-extended-view');
+    var top = navigator.offset().top;
+    this.$('.search-navigator-workspace-header').css({ top: top });
+    this.$('.search-navigator-side').css({ top: top }).isolatedScroll();
+    this.renderIntro();
+  },
 
+  renderIntro: function () {
+    this.detailsRegion.show(new IntroView());
+  }
 });
+
+
index ee2f4985dadd63d94f39acadf97e8d6de46df257..4d9e18ad660f5269754f29d546d2303d0b4ac008 100644 (file)
@@ -1,38 +1,37 @@
-define([
-    './templates'
-], function () {
-
-  return Marionette.ItemView.extend({
-    template: Templates['quality-profile-changelog'],
-
-    events: {
-      'submit #quality-profile-changelog-form': 'onFormSubmit',
-      'click .js-show-more-changelog': 'onShowMoreChangelogClick',
-      'click .js-hide-changelog': 'onHideChangelogClick'
-    },
-
-    onFormSubmit: function (e) {
-      e.preventDefault();
-      this.model.fetchChangelog(this.getSearchParameters());
-    },
-
-    onShowMoreChangelogClick: function (e) {
-      e.preventDefault();
-      this.model.fetchMoreChangelog();
-    },
-
-    onHideChangelogClick: function (e) {
-      e.preventDefault();
-      this.model.resetChangelog();
-    },
-
-    getSearchParameters: function () {
-      var form = this.$('#quality-profile-changelog-form');
-      return {
-        since: form.find('[name="since"]').val(),
-        to: form.find('[name="to"]').val()
-      };
-    }
-  });
+import Marionette from 'backbone.marionette';
+import './templates';
 
+export default Marionette.ItemView.extend({
+  template: Templates['quality-profile-changelog'],
+
+  events: {
+    'submit #quality-profile-changelog-form': 'onFormSubmit',
+    'click .js-show-more-changelog': 'onShowMoreChangelogClick',
+    'click .js-hide-changelog': 'onHideChangelogClick'
+  },
+
+  onFormSubmit: function (e) {
+    e.preventDefault();
+    this.model.fetchChangelog(this.getSearchParameters());
+  },
+
+  onShowMoreChangelogClick: function (e) {
+    e.preventDefault();
+    this.model.fetchMoreChangelog();
+  },
+
+  onHideChangelogClick: function (e) {
+    e.preventDefault();
+    this.model.resetChangelog();
+  },
+
+  getSearchParameters: function () {
+    var form = this.$('#quality-profile-changelog-form');
+    return {
+      since: form.find('[name="since"]').val(),
+      to: form.find('[name="to"]').val()
+    };
+  }
 });
+
+
index 522c75d16e02c2655f9b6c219bdbd72d7d383be5..aab7018aac641b8977138cd845cc15b95b66f2a2 100644 (file)
@@ -1,41 +1,41 @@
-define([
-    './templates'
-], function () {
-
-  return Marionette.ItemView.extend({
-    template: Templates['quality-profile-comparison'],
-
-    events: {
-      'submit #quality-profile-comparison-form': 'onFormSubmit'
-    },
-
-    onRender: function () {
-      this.$('select').select2({
-        width: '250px',
-        minimumResultsForSearch: 50
-      });
-    },
-
-    onFormSubmit: function (e) {
-      e.preventDefault();
-      var withKey = this.$('#quality-profile-comparison-with-key').val();
-      this.model.compareWith(withKey);
-    },
-
-    getProfilesForComparison: function () {
-      var profiles = this.model.collection.toJSON(),
-          key = this.model.id,
-          language = this.model.get('language');
-      return profiles.filter(function (profile) {
-        return profile.language === language && key !== profile.key;
-      });
-    },
-
-    serializeData: function () {
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        profiles: this.getProfilesForComparison()
-      });
-    }
-  });
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import './templates';
 
+export default Marionette.ItemView.extend({
+  template: Templates['quality-profile-comparison'],
+
+  events: {
+    'submit #quality-profile-comparison-form': 'onFormSubmit'
+  },
+
+  onRender: function () {
+    this.$('select').select2({
+      width: '250px',
+      minimumResultsForSearch: 50
+    });
+  },
+
+  onFormSubmit: function (e) {
+    e.preventDefault();
+    var withKey = this.$('#quality-profile-comparison-with-key').val();
+    this.model.compareWith(withKey);
+  },
+
+  getProfilesForComparison: function () {
+    var profiles = this.model.collection.toJSON(),
+        key = this.model.id,
+        language = this.model.get('language');
+    return profiles.filter(function (profile) {
+      return profile.language === language && key !== profile.key;
+    });
+  },
+
+  serializeData: function () {
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      profiles: this.getProfilesForComparison()
+    });
+  }
 });
+
+
index 8f20d637e9c2b4f262da11037ee9c57cd89bec64..03ea016e55590015ed0d5f326f546e95cf161c49 100644 (file)
-define([
-  './change-profile-parent-view',
-  './profile-changelog-view',
-  './profile-comparison-view',
-  'components/common/select-list',
-  './helpers',
-  './templates'
-], function (ChangeProfileParentView, ProfileChangelogView, ProfileComparisonView) {
-
-  var $ = jQuery;
-
-  return Marionette.LayoutView.extend({
-    template: Templates['quality-profiles-profile-details'],
-
-    regions: {
-      changelogRegion: '#quality-profile-changelog',
-      comparisonRegion: '#quality-profile-comparison'
-    },
-
-    modelEvents: {
-      'change': 'render',
-      'flashChangelog': 'flashChangelog'
-    },
-
-    events: {
-      'click .js-profile': 'onProfileClick',
-      'click #quality-profile-change-parent': 'onChangeParentClick'
-    },
-
-    onRender: function () {
-      if (!this.model.get('isDefault')) {
-        this.initProjectsSelect();
-      }
-      this.changelogRegion.show(new ProfileChangelogView({ model: this.model }));
-      this.comparisonRegion.show(new ProfileComparisonView({ model: this.model }));
-      if (this.options.anchor === 'changelog') {
-        this.scrollToChangelog();
-        this.flashChangelog();
-      }
-      if (this.options.anchor === 'comparison') {
-        this.scrollToComparison();
-      }
-      this.$('#quality-profile-changelog-form input')
-          .datepicker({
-            dateFormat: 'yy-mm-dd',
-            changeMonth: true,
-            changeYear: true
-          });
-    },
-
-    initProjectsSelect: function () {
-      var key = this.model.get('key');
-      this.projectsSelectList = new window.SelectList({
-        el: this.$('#quality-profile-projects-list'),
-        width: '100%',
-        height: 200,
-        readOnly: !this.options.canWrite,
-        focusSearch: false,
-        format: function (item) {
-          return item.name;
-        },
-        searchUrl: baseUrl + '/api/qualityprofiles/projects?key=' + encodeURIComponent(key),
-        selectUrl: baseUrl + '/api/qualityprofiles/add_project',
-        deselectUrl: baseUrl + '/api/qualityprofiles/remove_project',
-        extra: {
-          profileKey: key
-        },
-        selectParameter: 'projectUuid',
-        selectParameterValue: 'uuid',
-        labels: {
-          selected: t('quality_gates.projects.with'),
-          deselected: t('quality_gates.projects.without'),
-          all: t('quality_gates.projects.all'),
-          noResults: t('quality_gates.projects.noResults')
-        },
-        tooltips: {
-          select: t('quality_gates.projects.select_hint'),
-          deselect: t('quality_gates.projects.deselect_hint')
-        }
-      });
-      this.listenTo(this.projectsSelectList.collection, 'change:selected', this.onProjectsChange);
-    },
-
-    onProfileClick: function (e) {
-      var key = $(e.currentTarget).data('key'),
-          profile = this.model.collection.get(key);
-      if (profile != null) {
-        e.preventDefault();
-        this.model.collection.trigger('select', profile);
+import $ from 'jquery';
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import ChangeProfileParentView from './change-profile-parent-view';
+import ProfileChangelogView from './profile-changelog-view';
+import ProfileComparisonView from './profile-comparison-view';
+import 'components/common/select-list';
+import './helpers';
+import './templates';
+
+export default Marionette.LayoutView.extend({
+  template: Templates['quality-profiles-profile-details'],
+
+  regions: {
+    changelogRegion: '#quality-profile-changelog',
+    comparisonRegion: '#quality-profile-comparison'
+  },
+
+  modelEvents: {
+    'change': 'render',
+    'flashChangelog': 'flashChangelog'
+  },
+
+  events: {
+    'click .js-profile': 'onProfileClick',
+    'click #quality-profile-change-parent': 'onChangeParentClick'
+  },
+
+  onRender: function () {
+    if (!this.model.get('isDefault')) {
+      this.initProjectsSelect();
+    }
+    this.changelogRegion.show(new ProfileChangelogView({ model: this.model }));
+    this.comparisonRegion.show(new ProfileComparisonView({ model: this.model }));
+    if (this.options.anchor === 'changelog') {
+      this.scrollToChangelog();
+      this.flashChangelog();
+    }
+    if (this.options.anchor === 'comparison') {
+      this.scrollToComparison();
+    }
+    this.$('#quality-profile-changelog-form input')
+        .datepicker({
+          dateFormat: 'yy-mm-dd',
+          changeMonth: true,
+          changeYear: true
+        });
+  },
+
+  initProjectsSelect: function () {
+    var key = this.model.get('key');
+    this.projectsSelectList = new window.SelectList({
+      el: this.$('#quality-profile-projects-list'),
+      width: '100%',
+      height: 200,
+      readOnly: !this.options.canWrite,
+      focusSearch: false,
+      format: function (item) {
+        return item.name;
+      },
+      searchUrl: baseUrl + '/api/qualityprofiles/projects?key=' + encodeURIComponent(key),
+      selectUrl: baseUrl + '/api/qualityprofiles/add_project',
+      deselectUrl: baseUrl + '/api/qualityprofiles/remove_project',
+      extra: {
+        profileKey: key
+      },
+      selectParameter: 'projectUuid',
+      selectParameterValue: 'uuid',
+      labels: {
+        selected: t('quality_gates.projects.with'),
+        deselected: t('quality_gates.projects.without'),
+        all: t('quality_gates.projects.all'),
+        noResults: t('quality_gates.projects.noResults')
+      },
+      tooltips: {
+        select: t('quality_gates.projects.select_hint'),
+        deselect: t('quality_gates.projects.deselect_hint')
       }
-    },
-
-    onChangeParentClick: function (e) {
+    });
+    this.listenTo(this.projectsSelectList.collection, 'change:selected', this.onProjectsChange);
+  },
+
+  onProfileClick: function (e) {
+    var key = $(e.currentTarget).data('key'),
+        profile = this.model.collection.get(key);
+    if (profile != null) {
       e.preventDefault();
-      this.changeParent();
-    },
-
-    onProjectsChange: function () {
-      this.model.collection.updateForLanguage(this.model.get('language'));
-    },
-
-    changeParent: function () {
-      new ChangeProfileParentView({
-        model: this.model
-      }).render();
-    },
-
-    scrollTo: function (selector) {
-      var el = this.$(selector),
-          parent = el.scrollParent();
-      var elOffset = el.offset(),
-          parentOffset = parent.offset();
-      if (parent.is(document)) {
-        parentOffset = { top: 0 };
-      }
-      if (elOffset != null && parentOffset != null) {
-        var scrollTop = elOffset.top - parentOffset.top - 53;
-        parent.scrollTop(scrollTop);
-      }
-    },
-
-    scrollToChangelog: function () {
-      this.scrollTo('#quality-profile-changelog');
-    },
-
-    scrollToComparison: function () {
-      this.scrollTo('#quality-profile-comparison');
-    },
-
-    getExporters: function () {
-      var language = this.model.get('language');
-      return this.options.exporters.filter(function (exporter) {
-        return exporter.languages.indexOf(language) !== -1;
-      });
-    },
-
-    flashChangelog: function () {
-      var changelogEl = this.$(this.changelogRegion.el);
-      changelogEl.addClass('flash in');
-      setTimeout(function () {
-        changelogEl.removeClass('in');
-      }, 2000);
-    },
-
-    serializeData: function () {
-      var key = this.model.get('key'),
-          rulesSearchUrl = '/coding_rules#qprofile=' + encodeURIComponent(key) + '|activation=true';
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        rulesSearchUrl: rulesSearchUrl,
-        canWrite: this.options.canWrite,
-        exporters: this.getExporters()
-      });
+      this.model.collection.trigger('select', profile);
     }
-  });
-
+  },
+
+  onChangeParentClick: function (e) {
+    e.preventDefault();
+    this.changeParent();
+  },
+
+  onProjectsChange: function () {
+    this.model.collection.updateForLanguage(this.model.get('language'));
+  },
+
+  changeParent: function () {
+    new ChangeProfileParentView({
+      model: this.model
+    }).render();
+  },
+
+  scrollTo: function (selector) {
+    var el = this.$(selector),
+        parent = el.scrollParent();
+    var elOffset = el.offset(),
+        parentOffset = parent.offset();
+    if (parent.is(document)) {
+      parentOffset = { top: 0 };
+    }
+    if (elOffset != null && parentOffset != null) {
+      var scrollTop = elOffset.top - parentOffset.top - 53;
+      parent.scrollTop(scrollTop);
+    }
+  },
+
+  scrollToChangelog: function () {
+    this.scrollTo('#quality-profile-changelog');
+  },
+
+  scrollToComparison: function () {
+    this.scrollTo('#quality-profile-comparison');
+  },
+
+  getExporters: function () {
+    var language = this.model.get('language');
+    return this.options.exporters.filter(function (exporter) {
+      return exporter.languages.indexOf(language) !== -1;
+    });
+  },
+
+  flashChangelog: function () {
+    var changelogEl = this.$(this.changelogRegion.el);
+    changelogEl.addClass('flash in');
+    setTimeout(function () {
+      changelogEl.removeClass('in');
+    }, 2000);
+  },
+
+  serializeData: function () {
+    var key = this.model.get('key'),
+        rulesSearchUrl = '/coding_rules#qprofile=' + encodeURIComponent(key) + '|activation=true';
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      rulesSearchUrl: rulesSearchUrl,
+      canWrite: this.options.canWrite,
+      exporters: this.getExporters()
+    });
+  }
 });
+
+
index 99a9a1e022c970513b7926a49daa5ab7cc26d385..4c75884fff8410cac6156578381a8b9e31ecf8ad 100644 (file)
@@ -1,74 +1,73 @@
-define([
-  './copy-profile-view',
-  './rename-profile-view',
-  './delete-profile-view',
-  './templates'
-], function (ProfileCopyView, ProfileRenameView, ProfileDeleteView) {
+import $ from 'jquery';
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import ProfileCopyView from './copy-profile-view';
+import ProfileRenameView from './rename-profile-view';
+import ProfileDeleteView from './delete-profile-view';
+import './templates';
 
-  var $ = jQuery;
+export default Marionette.ItemView.extend({
+  template: Templates['quality-profiles-profile-header'],
 
-  return Marionette.ItemView.extend({
-    template: Templates['quality-profiles-profile-header'],
+  modelEvents: {
+    'change': 'render'
+  },
 
-    modelEvents: {
-      'change': 'render'
-    },
+  events: {
+    'click #quality-profile-backup': 'onBackupClick',
+    'click #quality-profile-copy': 'onCopyClick',
+    'click #quality-profile-rename': 'onRenameClick',
+    'click #quality-profile-set-as-default': 'onDefaultClick',
+    'click #quality-profile-delete': 'onDeleteClick'
+  },
 
-    events: {
-      'click #quality-profile-backup': 'onBackupClick',
-      'click #quality-profile-copy': 'onCopyClick',
-      'click #quality-profile-rename': 'onRenameClick',
-      'click #quality-profile-set-as-default': 'onDefaultClick',
-      'click #quality-profile-delete': 'onDeleteClick'
-    },
+  onBackupClick: function (e) {
+    $(e.currentTarget).blur();
+  },
 
-    onBackupClick: function (e) {
-      $(e.currentTarget).blur();
-    },
+  onCopyClick: function (e) {
+    e.preventDefault();
+    this.copy();
+  },
 
-    onCopyClick: function (e) {
-      e.preventDefault();
-      this.copy();
-    },
+  onRenameClick: function (e) {
+    e.preventDefault();
+    this.rename();
+  },
 
-    onRenameClick: function (e) {
-      e.preventDefault();
-      this.rename();
-    },
+  onDefaultClick: function (e) {
+    e.preventDefault();
+    this.setAsDefault();
+  },
 
-    onDefaultClick: function (e) {
-      e.preventDefault();
-      this.setAsDefault();
-    },
+  onDeleteClick: function (e) {
+    e.preventDefault();
+    this.delete();
+  },
 
-    onDeleteClick: function (e) {
-      e.preventDefault();
-      this.delete();
-    },
+  copy: function () {
+    new ProfileCopyView({ model: this.model }).render();
+  },
 
-    copy: function () {
-      new ProfileCopyView({ model: this.model }).render();
-    },
+  rename: function () {
+    new ProfileRenameView({ model: this.model }).render();
+  },
 
-    rename: function () {
-      new ProfileRenameView({ model: this.model }).render();
-    },
+  setAsDefault: function () {
+    this.model.trigger('setAsDefault', this.model);
+  },
 
-    setAsDefault: function () {
-      this.model.trigger('setAsDefault', this.model);
-    },
+  delete: function () {
+    new ProfileDeleteView({ model: this.model }).render();
+  },
 
-    delete: function () {
-      new ProfileDeleteView({ model: this.model }).render();
-    },
+  serializeData: function () {
+    var key = this.model.get('key');
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      encodedKey: encodeURIComponent(key),
+      canWrite: this.options.canWrite
+    });
+  }
+});
 
-    serializeData: function () {
-      var key = this.model.get('key');
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        encodedKey: encodeURIComponent(key),
-        canWrite: this.options.canWrite
-      });
-    }
-  });
 
-});
index 19ddacf5e7111ff1ca587e4920cab69be42cc8cc..541482a55690df549ae8e76b847ff7cc7764d508 100644 (file)
@@ -1,41 +1,41 @@
-define([
-  './templates'
-], function () {
-
-  return Marionette.ItemView.extend({
-    tagName: 'a',
-    className: 'list-group-item',
-    template: Templates['quality-profiles-profile'],
-
-    modelEvents: {
-      'change': 'render'
-    },
-
-    events: {
-      'click': 'onClick'
-    },
-
-    onRender: function () {
-      this.$el.toggleClass('active', this.options.highlighted);
-      this.$el.attr('data-key', this.model.id);
-      this.$el.attr('data-language', this.model.get('language'));
-      this.$('[data-toggle="tooltip"]').tooltip({ container: 'body' });
-    },
-
-    onDestroy: function () {
-      this.$('[data-toggle="tooltip"]').tooltip('destroy');
-    },
-
-    onClick: function (e) {
-      e.preventDefault();
-      this.model.trigger('select', this.model);
-    },
-
-    serializeData: function () {
-      return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
-        projectCountFormatted: window.formatMeasure(this.model.get('projectCount'), 'INT')
-      });
-    }
-  });
-
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import './templates';
+
+export default Marionette.ItemView.extend({
+  tagName: 'a',
+  className: 'list-group-item',
+  template: Templates['quality-profiles-profile'],
+
+  modelEvents: {
+    'change': 'render'
+  },
+
+  events: {
+    'click': 'onClick'
+  },
+
+  onRender: function () {
+    this.$el.toggleClass('active', this.options.highlighted);
+    this.$el.attr('data-key', this.model.id);
+    this.$el.attr('data-language', this.model.get('language'));
+    this.$('[data-toggle="tooltip"]').tooltip({ container: 'body' });
+  },
+
+  onDestroy: function () {
+    this.$('[data-toggle="tooltip"]').tooltip('destroy');
+  },
+
+  onClick: function (e) {
+    e.preventDefault();
+    this.model.trigger('select', this.model);
+  },
+
+  serializeData: function () {
+    return _.extend(Marionette.ItemView.prototype.serializeData.apply(this, arguments), {
+      projectCountFormatted: window.formatMeasure(this.model.get('projectCount'), 'INT')
+    });
+  }
 });
+
+
index 3ae71d5c5b6a73266cd0dccd69fd2d47091da564..955cb2546a748d5ad51d9db831fb6d2f90f9d85f 100644 (file)
-define(function () {
+import $ from 'jquery';
+import _ from 'underscore';
+import Backbone from 'backbone';
 
-  var $ = jQuery;
+export default Backbone.Model.extend({
+  idAttribute: 'key',
 
-  return Backbone.Model.extend({
-    idAttribute: 'key',
+  defaults: {
+    activeRuleCount: 0,
+    projectCount: 0
+  },
 
-    defaults: {
-      activeRuleCount: 0,
-      projectCount: 0
-    },
-
-    fetch: function () {
-      var that = this;
-      this.fetchChanged = {};
-      return $.when(
-          this.fetchProfileRules(),
-          this.fetchInheritance()
-      ).done(function () {
-            that.set(that.fetchChanged);
-          });
-    },
+  fetch: function () {
+    var that = this;
+    this.fetchChanged = {};
+    return $.when(
+        this.fetchProfileRules(),
+        this.fetchInheritance()
+    ).done(function () {
+          that.set(that.fetchChanged);
+        });
+  },
 
-    fetchProfileRules: function () {
-      var that = this,
-          url = baseUrl + '/api/rules/search',
-          key = this.id,
-          options = {
-            ps: 1,
-            facets: 'active_severities',
-            qprofile: key,
-            activation: 'true'
-          };
-      return $.get(url, options).done(function (r) {
-        var severityFacet = _.findWhere(r.facets, { property: 'active_severities' });
-        if (severityFacet != null) {
-          var severities = severityFacet.values,
-              severityComparator = function (s) {
-                return window.severityColumnsComparator(s.val);
-              },
-              sortedSeverities = _.sortBy(severities, severityComparator);
-          _.extend(that.fetchChanged, { rulesSeverities: sortedSeverities });
-        }
-      });
-    },
+  fetchProfileRules: function () {
+    var that = this,
+        url = baseUrl + '/api/rules/search',
+        key = this.id,
+        options = {
+          ps: 1,
+          facets: 'active_severities',
+          qprofile: key,
+          activation: 'true'
+        };
+    return $.get(url, options).done(function (r) {
+      var severityFacet = _.findWhere(r.facets, { property: 'active_severities' });
+      if (severityFacet != null) {
+        var severities = severityFacet.values,
+            severityComparator = function (s) {
+              return window.severityColumnsComparator(s.val);
+            },
+            sortedSeverities = _.sortBy(severities, severityComparator);
+        _.extend(that.fetchChanged, { rulesSeverities: sortedSeverities });
+      }
+    });
+  },
 
-    fetchInheritance: function () {
-      var that = this,
-          url = baseUrl + '/api/qualityprofiles/inheritance',
-          options = { profileKey: this.id };
-      return $.get(url, options).done(function (r) {
-        _.extend(that.fetchChanged, r.profile, {
-          ancestors: r.ancestors,
-          children: r.children
-        });
+  fetchInheritance: function () {
+    var that = this,
+        url = baseUrl + '/api/qualityprofiles/inheritance',
+        options = { profileKey: this.id };
+    return $.get(url, options).done(function (r) {
+      _.extend(that.fetchChanged, r.profile, {
+        ancestors: r.ancestors,
+        children: r.children
       });
-    },
+    });
+  },
 
-    fetchChangelog: function (options) {
-      var that = this,
-          url = baseUrl + '/api/qualityprofiles/changelog',
-          opts = _.extend({}, options, { profileKey: this.id });
-      return $.get(url, opts).done(function (r) {
-        that.set({
-          events: r.events,
-          eventsPage: r.p,
-          totalEvents: r.total,
-          eventsParameters: _.clone(options)
-        });
+  fetchChangelog: function (options) {
+    var that = this,
+        url = baseUrl + '/api/qualityprofiles/changelog',
+        opts = _.extend({}, options, { profileKey: this.id });
+    return $.get(url, opts).done(function (r) {
+      that.set({
+        events: r.events,
+        eventsPage: r.p,
+        totalEvents: r.total,
+        eventsParameters: _.clone(options)
       });
-    },
+    });
+  },
 
-    fetchMoreChangelog: function () {
-      var that = this,
-          url = baseUrl + '/api/qualityprofiles/changelog',
-          page = this.get('eventsPage') || 0,
-          parameters = this.get('eventsParameters') || {},
-          opts = _.extend({}, parameters, { profileKey: this.id, p: page + 1 });
-      return $.get(url, opts).done(function (r) {
-        var events = that.get('events') || [];
-        that.set({
-          events: [].concat(events, r.events),
-          eventsPage: r.p,
-          totalEvents: r.total
-        });
+  fetchMoreChangelog: function () {
+    var that = this,
+        url = baseUrl + '/api/qualityprofiles/changelog',
+        page = this.get('eventsPage') || 0,
+        parameters = this.get('eventsParameters') || {},
+        opts = _.extend({}, parameters, { profileKey: this.id, p: page + 1 });
+    return $.get(url, opts).done(function (r) {
+      var events = that.get('events') || [];
+      that.set({
+        events: [].concat(events, r.events),
+        eventsPage: r.p,
+        totalEvents: r.total
       });
-    },
+    });
+  },
 
 
-    resetChangelog: function () {
-      this.unset('events', { silent: true });
-      this.unset('eventsPage', { silent: true });
-      this.unset('totalEvents');
-    },
+  resetChangelog: function () {
+    this.unset('events', { silent: true });
+    this.unset('eventsPage', { silent: true });
+    this.unset('totalEvents');
+  },
 
-    compareWith: function (withKey) {
-      var that = this,
-          url = baseUrl + '/api/qualityprofiles/compare',
-          options = { leftKey: this.id, rightKey: withKey };
-      return $.get(url, options).done(function (r) {
-        var comparison = _.extend(r, {
-          inLeftSize: _.size(r.inLeft),
-          inRightSize: _.size(r.inRight),
-          modifiedSize: _.size(r.modified)
-        });
-        that.set({
-          comparison: comparison,
-          comparedWith: withKey
-        });
+  compareWith: function (withKey) {
+    var that = this,
+        url = baseUrl + '/api/qualityprofiles/compare',
+        options = { leftKey: this.id, rightKey: withKey };
+    return $.get(url, options).done(function (r) {
+      var comparison = _.extend(r, {
+        inLeftSize: _.size(r.inLeft),
+        inRightSize: _.size(r.inRight),
+        modifiedSize: _.size(r.modified)
       });
-    }
-  });
-
+      that.set({
+        comparison: comparison,
+        comparedWith: withKey
+      });
+    });
+  }
 });
+
+
index f4844bfc85f77eec2133f26729f77740d0daf261..49a0a80374905054096dde821c3747b5dc8c02af 100644 (file)
@@ -1,10 +1,9 @@
-define([
-  './templates'
-], function () {
-
-  return Marionette.ItemView.extend({
-    className: 'list-group-item',
-    template: Templates['quality-profiles-empty']
-  });
+import Marionette from 'backbone.marionette';
+import './templates';
 
+export default Marionette.ItemView.extend({
+  className: 'list-group-item',
+  template: Templates['quality-profiles-empty']
 });
+
+
index 33d95a47b5f0d2eb7648c09b3779ed240ffb0a12..82d8c26f29713d5f720f5ed000f90e49cfe95680 100644 (file)
@@ -1,66 +1,65 @@
-define([
-  './profile-view',
-  './profiles-empty-view',
-  './templates'
-], function (ProfileView, ProfilesEmptyView) {
+import Marionette from 'backbone.marionette';
+import ProfileView from './profile-view';
+import ProfilesEmptyView from './profiles-empty-view';
+import './templates';
 
-  return Marionette.CompositeView.extend({
-    className: 'list-group',
-    template: Templates['quality-profiles-profiles'],
-    languageTemplate: Templates['quality-profiles-profiles-language'],
-    childView: ProfileView,
-    childViewContainer: '.js-list',
-    emptyView: ProfilesEmptyView,
+export default Marionette.CompositeView.extend({
+  className: 'list-group',
+  template: Templates['quality-profiles-profiles'],
+  languageTemplate: Templates['quality-profiles-profiles-language'],
+  childView: ProfileView,
+  childViewContainer: '.js-list',
+  emptyView: ProfilesEmptyView,
 
-    collectionEvents: {
-      'filter': 'filterByLanguage'
-    },
+  collectionEvents: {
+    'filter': 'filterByLanguage'
+  },
 
-    childViewOptions: function (model) {
-      return {
-        collectionView: this,
-        highlighted: model.get('key') === this.highlighted
-      };
-    },
+  childViewOptions: function (model) {
+    return {
+      collectionView: this,
+      highlighted: model.get('key') === this.highlighted
+    };
+  },
 
-    highlight: function (key) {
-      this.highlighted = key;
-      this.render();
-    },
+  highlight: function (key) {
+    this.highlighted = key;
+    this.render();
+  },
 
-    attachHtml: function (compositeView, childView, index) {
-      var $container = this.getChildViewContainer(compositeView),
-          model = this.collection.at(index);
-      if (model != null) {
-        var prev = this.collection.at(index - 1),
-            putLanguage = prev == null;
-        if (prev != null) {
-          var lang = model.get('language'),
-              prevLang = prev.get('language');
-          if (lang !== prevLang) {
-            putLanguage = true;
-          }
-        }
-        if (putLanguage) {
-          $container.append(this.languageTemplate(model.toJSON()));
+  attachHtml: function (compositeView, childView, index) {
+    var $container = this.getChildViewContainer(compositeView),
+        model = this.collection.at(index);
+    if (model != null) {
+      var prev = this.collection.at(index - 1),
+          putLanguage = prev == null;
+      if (prev != null) {
+        var lang = model.get('language'),
+            prevLang = prev.get('language');
+        if (lang !== prevLang) {
+          putLanguage = true;
         }
       }
-      compositeView._insertAfter(childView);
-    },
-
-    destroyChildren: function () {
-      Marionette.CompositeView.prototype.destroyChildren.apply(this, arguments);
-      this.$('.js-list-language').remove();
-    },
-
-    filterByLanguage: function (language) {
-      if (language) {
-        this.$('[data-language]').addClass('hidden');
-        this.$('[data-language="' + language + '"]').removeClass('hidden');
-      } else {
-        this.$('[data-language]').removeClass('hidden');
+      if (putLanguage) {
+        $container.append(this.languageTemplate(model.toJSON()));
       }
     }
-  });
+    compositeView._insertAfter(childView);
+  },
+
+  destroyChildren: function () {
+    Marionette.CompositeView.prototype.destroyChildren.apply(this, arguments);
+    this.$('.js-list-language').remove();
+  },
 
+  filterByLanguage: function (language) {
+    if (language) {
+      this.$('[data-language]').addClass('hidden');
+      this.$('[data-language="' + language + '"]').removeClass('hidden');
+    } else {
+      this.$('[data-language]').removeClass('hidden');
+    }
+  }
 });
+
+
index fde1a6e63970a3e95ec1956a342a8055b446eae7..194004e905ea7834a78d9716ba73ab5e6ca17832 100644 (file)
@@ -1,26 +1,25 @@
-define([
-  './profile'
-], function (Profile) {
+import Backbone from 'backbone';
+import Profile from './profile';
 
-  return Backbone.Collection.extend({
-    model: Profile,
-    url: baseUrl + '/api/qualityprofiles/search',
-    comparator: 'key',
+export default Backbone.Collection.extend({
+  model: Profile,
+  url: baseUrl + '/api/qualityprofiles/search',
+  comparator: 'key',
 
-    parse: function (r) {
-      return r.profiles;
-    },
-
-    updateForLanguage: function (language) {
-      this.fetch({
-        data: {
-          language: language
-        },
-        merge: true,
-        reset: false,
-        remove: false
-      });
-    }
-  });
+  parse: function (r) {
+    return r.profiles;
+  },
 
+  updateForLanguage: function (language) {
+    this.fetch({
+      data: {
+        language: language
+      },
+      merge: true,
+      reset: false,
+      remove: false
+    });
+  }
 });
+
+
index e54377708caaeb6b78d184aed0bf4df605b9b1c3..9e4aef764039cf7921cbe610e085b8f0ba8da2c1 100644 (file)
@@ -1,41 +1,38 @@
-define([
-  'components/common/modal-form',
-  './templates'
-], function (ModalFormView) {
+import $ from 'jquery';
+import ModalFormView from 'components/common/modal-form';
+import './templates';
 
-  var $ = jQuery;
+export default ModalFormView.extend({
+  template: Templates['quality-profiles-rename-profile'],
 
-  return ModalFormView.extend({
-    template: Templates['quality-profiles-rename-profile'],
+  onFormSubmit: function () {
+    ModalFormView.prototype.onFormSubmit.apply(this, arguments);
+    this.sendRequest();
+  },
 
-    onFormSubmit: function () {
-      ModalFormView.prototype.onFormSubmit.apply(this, arguments);
-      this.sendRequest();
-    },
+  sendRequest: function () {
+    var that = this,
+        url = baseUrl + '/api/qualityprofiles/rename',
+        name = this.$('#rename-profile-name').val(),
+        options = {
+          key: this.model.get('key'),
+          name: name
+        };
+    return $.ajax({
+      type: 'POST',
+      url: url,
+      data: options,
+      statusCode: {
+        // do not show global error
+        400: null
+      }
+    }).done(function () {
+      that.model.set({ name: name });
+      that.destroy();
+    }).fail(function (jqXHR) {
+      that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+    });
+  }
+});
 
-    sendRequest: function () {
-      var that = this,
-          url = baseUrl + '/api/qualityprofiles/rename',
-          name = this.$('#rename-profile-name').val(),
-          options = {
-            key: this.model.get('key'),
-            name: name
-          };
-      return $.ajax({
-        type: 'POST',
-        url: url,
-        data: options,
-        statusCode: {
-          // do not show global error
-          400: null
-        }
-      }).done(function () {
-        that.model.set({ name: name });
-        that.destroy();
-      }).fail(function (jqXHR) {
-        that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
-      });
-    }
-  });
 
-});
index 2c84315281a35f4445d7c3d661644749a97ac9c7..76ca3851738707ff4618fbba4b53108997c83040 100644 (file)
@@ -1,56 +1,54 @@
-define([
-  'components/common/modal-form',
-  './templates'
-], function (ModalFormView) {
+import $ from 'jquery';
+import _ from 'underscore';
+import ModalFormView from 'components/common/modal-form';
+import './templates';
 
-  var $ = jQuery;
+export default ModalFormView.extend({
+  template: Templates['quality-profiles-restore-built-in-profiles'],
 
-  return ModalFormView.extend({
-    template: Templates['quality-profiles-restore-built-in-profiles'],
+  onFormSubmit: function () {
+    ModalFormView.prototype.onFormSubmit.apply(this, arguments);
+    this.disableForm();
+    this.sendRequest();
+  },
 
-    onFormSubmit: function () {
-      ModalFormView.prototype.onFormSubmit.apply(this, arguments);
-      this.disableForm();
-      this.sendRequest();
-    },
+  onRender: function () {
+    ModalFormView.prototype.onRender.apply(this, arguments);
+    this.$('select').select2({
+      width: '250px',
+      minimumResultsForSearch: 50
+    });
+  },
 
-    onRender: function () {
-      ModalFormView.prototype.onRender.apply(this, arguments);
-      this.$('select').select2({
-        width: '250px',
-        minimumResultsForSearch: 50
-      });
-    },
+  sendRequest: function () {
+    var that = this,
+        url = baseUrl + '/api/qualityprofiles/restore_built_in',
+        options = {
+          language: this.$('#restore-built-in-profiles-language').val()
+        };
+    return $.ajax({
+      type: 'POST',
+      url: url,
+      data: options,
+      statusCode: {
+        // do not show global error
+        400: null
+      }
+    }).done(function () {
+      that.collection.fetch({ reset: true });
+      that.collection.trigger('destroy');
+      that.destroy();
+    }).fail(function (jqXHR) {
+      that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+      that.enableForm();
+    });
+  },
 
-    sendRequest: function () {
-      var that = this,
-          url = baseUrl + '/api/qualityprofiles/restore_built_in',
-          options = {
-            language: this.$('#restore-built-in-profiles-language').val()
-          };
-      return $.ajax({
-        type: 'POST',
-        url: url,
-        data: options,
-        statusCode: {
-          // do not show global error
-          400: null
-        }
-      }).done(function () {
-        that.collection.fetch({ reset: true });
-        that.collection.trigger('destroy');
-        that.destroy();
-      }).fail(function (jqXHR) {
-        that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
-        that.enableForm();
-      });
-    },
+  serializeData: function () {
+    return _.extend(ModalFormView.prototype.serializeData.apply(this, arguments), {
+      languages: this.options.languages
+    });
+  }
+});
 
-    serializeData: function () {
-      return _.extend(ModalFormView.prototype.serializeData.apply(this, arguments), {
-        languages: this.options.languages
-      });
-    }
-  });
 
-});
index ebc7812e12d56b241f5d03c62d50fc71cbb8a245..57540d9b4a4c9ea46dbefb011a44b513bd96e05b 100644 (file)
@@ -1,36 +1,34 @@
-define([
-  'components/common/modal-form',
-  'components/common/file-upload',
-  './profile',
-  './templates'
-], function (ModalFormView, uploader, Profile) {
+import $ from 'jquery';
+import _ from 'underscore';
+import ModalFormView from 'components/common/modal-form';
+import uploader from 'components/common/file-upload';
+import Profile from './profile';
+import './templates';
 
-  var $ = jQuery;
+export default ModalFormView.extend({
+  template: Templates['quality-profiles-restore-profile'],
 
-  return ModalFormView.extend({
-    template: Templates['quality-profiles-restore-profile'],
-
-    onFormSubmit: function (e) {
-      var that = this;
-      ModalFormView.prototype.onFormSubmit.apply(this, arguments);
-      uploader({ form: $(e.currentTarget) }).done(function (r) {
-        if (_.isArray(r.errors) || _.isArray(r.warnings)) {
-          that.showErrors(r.errors, r.warnings);
-        } else {
-          that.addProfile(r.profile);
-          that.destroy();
-        }
-      });
-    },
-
-    addProfile: function (profileData) {
-      var profile = new Profile(profileData);
-      this.collection.add([profile], { merge: true });
-      var addedProfile = this.collection.get(profile.id);
-      if (addedProfile != null) {
-        addedProfile.trigger('select', addedProfile);
+  onFormSubmit: function (e) {
+    var that = this;
+    ModalFormView.prototype.onFormSubmit.apply(this, arguments);
+    uploader({ form: $(e.currentTarget) }).done(function (r) {
+      if (_.isArray(r.errors) || _.isArray(r.warnings)) {
+        that.showErrors(r.errors, r.warnings);
+      } else {
+        that.addProfile(r.profile);
+        that.destroy();
       }
-    }
-  });
+    });
+  },
 
+  addProfile: function (profileData) {
+    var profile = new Profile(profileData);
+    this.collection.add([profile], { merge: true });
+    var addedProfile = this.collection.get(profile.id);
+    if (addedProfile != null) {
+      addedProfile.trigger('select', addedProfile);
+    }
+  }
 });
+
+
index 1854fe66b221b86733df4609fbffaf3540377c74..c672f5b3418eb7653d6da1f9a1c5a055f28166c3 100644 (file)
@@ -1,37 +1,37 @@
-define(function () {
-
-  return Backbone.Router.extend({
-    routes: {
-      '': 'index',
-      'index': 'index',
-      'show?key=:key': 'show',
-      'changelog*': 'changelog',
-      'compare*': 'compare'
-    },
-
-    initialize: function (options) {
-      this.app = options.app;
-    },
-
-    index: function () {
-      this.app.controller.index();
-    },
-
-    show: function (key) {
-      this.app.controller.show(key);
-    },
-
-    changelog: function () {
-      var params = window.getQueryParams();
-      this.app.controller.changelog(params.key, params.since, params.to);
-    },
-
-    compare: function () {
-      var params = window.getQueryParams();
-      if (params.key && params.withKey) {
-        this.app.controller.compare(params.key, params.withKey);
-      }
-    }
-  });
+import Backbone from 'backbone';
+
+export default Backbone.Router.extend({
+  routes: {
+    '': 'index',
+    'index': 'index',
+    'show?key=:key': 'show',
+    'changelog*': 'changelog',
+    'compare*': 'compare'
+  },
+
+  initialize: function (options) {
+    this.app = options.app;
+  },
+
+  index: function () {
+    this.app.controller.index();
+  },
+
+  show: function (key) {
+    this.app.controller.show(key);
+  },
 
+  changelog: function () {
+    var params = window.getQueryParams();
+    this.app.controller.changelog(params.key, params.since, params.to);
+  },
+
+  compare: function () {
+    var params = window.getQueryParams();
+    if (params.key && params.withKey) {
+      this.app.controller.compare(params.key, params.withKey);
+    }
+  }
 });
+
+
index 1c6947db3ee2305c7ca41cdd2461d7a4ec331282..3c013e406de607fe3743691676b1c7391b4d3dfd 100644 (file)
@@ -1,29 +1,28 @@
-define([
-  'components/source-viewer/main'
-], function (SourceViewer) {
+import Marionette from 'backbone.marionette';
+import SourceViewer from 'components/source-viewer/main';
 
-  var App = new Marionette.Application(),
-      init = function (options) {
-        this.addRegions({ mainRegion: options.el });
+var App = new Marionette.Application(),
+    init = function (options) {
+      this.addRegions({ mainRegion: options.el });
 
-        var viewer = new SourceViewer();
-        this.mainRegion.show(viewer);
-        viewer.open(options.file.uuid);
-        if (typeof options.file.line === 'number') {
-          viewer.on('loaded', function () {
-            viewer
-                .highlightLine(options.file.line)
-                .scrollToLine(options.file.line);
-          });
-        }
-      };
+      var viewer = new SourceViewer();
+      this.mainRegion.show(viewer);
+      viewer.open(options.file.uuid);
+      if (typeof options.file.line === 'number') {
+        viewer.on('loaded', function () {
+          viewer
+              .highlightLine(options.file.line)
+              .scrollToLine(options.file.line);
+        });
+      }
+    };
 
-  App.on('start', function (options) {
-    window.requestMessages().done(function () {
-      init.call(App, options);
-    });
+App.on('start', function (options) {
+  window.requestMessages().done(function () {
+    init.call(App, options);
   });
+});
+
+export default App;
 
-  return App;
 
-});
index a866a0c2879faa0d54a6bf6d1e6b48924d25db57..b667f6736b8b961904ad751c01e693216a3ed6c3 100644 (file)
@@ -1,64 +1,64 @@
-define([
-  './layout',
-  './header-view',
-  './search-view',
-  './list-view',
-  './footer-view',
-  './controller',
-  './router',
-  './plugins'
-], function (Layout, HeaderView, SearchView, ListView, FooterView, Controller, Router, Plugins) {
+import Backbone from 'backbone';
+import Marionette from 'backbone.marionette';
+import Layout from './layout';
+import HeaderView from './header-view';
+import SearchView from './search-view';
+import ListView from './list-view';
+import FooterView from './footer-view';
+import Controller from './controller';
+import Router from './router';
+import Plugins from './plugins';
 
-  var App = new Marionette.Application(),
-      init = function (options) {
-        // State
-        this.state = new Backbone.Model({
-          updateCenterActive: window.SS.updateCenterActive
-        });
+var App = new Marionette.Application(),
+    init = function (options) {
+      // State
+      this.state = new Backbone.Model({
+        updateCenterActive: window.SS.updateCenterActive
+      });
 
-        // Layout
-        this.layout = new Layout({ el: options.el });
-        this.layout.render();
+      // Layout
+      this.layout = new Layout({ el: options.el });
+      this.layout.render();
 
-        // Plugins
-        this.plugins = new Plugins();
+      // Plugins
+      this.plugins = new Plugins();
 
-        // Controller
-        this.controller = new Controller({ collection: this.plugins, state: this.state });
+      // Controller
+      this.controller = new Controller({ collection: this.plugins, state: this.state });
 
-        // Router
-        this.router = new Router({ controller: this.controller});
+      // Router
+      this.router = new Router({ controller: this.controller });
 
-        // Header
-        this.headerView = new HeaderView({ collection: this.plugins });
-        this.layout.headerRegion.show(this.headerView);
+      // Header
+      this.headerView = new HeaderView({ collection: this.plugins });
+      this.layout.headerRegion.show(this.headerView);
 
-        // Search
-        this.searchView = new SearchView({ collection: this.plugins, router: this.router, state: this.state });
-        this.layout.searchRegion.show(this.searchView);
-        this.searchView.focusSearch();
+      // Search
+      this.searchView = new SearchView({ collection: this.plugins, router: this.router, state: this.state });
+      this.layout.searchRegion.show(this.searchView);
+      this.searchView.focusSearch();
 
-        // List
-        this.listView = new ListView({ collection: this.plugins });
-        this.layout.listRegion.show(this.listView);
+      // List
+      this.listView = new ListView({ collection: this.plugins });
+      this.layout.listRegion.show(this.listView);
 
-        // Footer
-        this.footerView = new FooterView({ collection: this.plugins });
-        this.layout.footerRegion.show(this.footerView);
+      // Footer
+      this.footerView = new FooterView({ collection: this.plugins });
+      this.layout.footerRegion.show(this.footerView);
 
-        // Go
-        Backbone.history.start({
-          pushState: true,
-          root: options.urlRoot
-        });
-      };
+      // Go
+      Backbone.history.start({
+        pushState: true,
+        root: options.urlRoot
+      });
+    };
 
-  App.on('start', function (options) {
-    window.requestMessages().done(function () {
-      init.call(App, options);
-    });
+App.on('start', function (options) {
+  window.requestMessages().done(function () {
+    init.call(App, options);
   });
+});
+
+export default App;
 
-  return App;
 
-});
index a8f069c9dc0f2518c8028a7c4d28661f51507934..4f80e0615a7ebc231f3231288e3f982ccd9183f4 100644 (file)
@@ -1,30 +1,30 @@
-define(function () {
+import Marionette from 'backbone.marionette';
 
-  return Marionette.Controller.extend({
-    initialize: function (options) {
-      this.collection = options.collection;
-      this.state = options.state;
-    },
+export default Marionette.Controller.extend({
+  initialize: function (options) {
+    this.collection = options.collection;
+    this.state = options.state;
+  },
 
-    showInstalled: function () {
-      this.state.set({ section: 'installed' });
-      this.collection.fetchInstalled();
-    },
+  showInstalled: function () {
+    this.state.set({ section: 'installed' });
+    this.collection.fetchInstalled();
+  },
 
-    showUpdates: function () {
-      this.state.set({ section: 'updates' });
-      this.collection.fetchUpdates();
-    },
+  showUpdates: function () {
+    this.state.set({ section: 'updates' });
+    this.collection.fetchUpdates();
+  },
 
-    showAvailable: function () {
-      this.state.set({ section: 'available' });
-      this.collection.fetchAvailable();
-    },
-
-    showSystemUpgrades: function () {
-      this.state.set({ section: 'system' });
-      this.collection.fetchSystemUpgrades();
-    }
-  });
+  showAvailable: function () {
+    this.state.set({ section: 'available' });
+    this.collection.fetchAvailable();
+  },
 
+  showSystemUpgrades: function () {
+    this.state.set({ section: 'system' });
+    this.collection.fetchSystemUpgrades();
+  }
 });
+
+
index 2f83d509dc7f0058ecd15881e8735068a91bb16d..085dacf43c2138fbf1257b12a6296ccc5baa2231 100644 (file)
@@ -1,19 +1,19 @@
-define([
-  './templates'
-], function () {
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import './templates';
 
-  return Marionette.ItemView.extend({
-    template: Templates['update-center-footer'],
+export default Marionette.ItemView.extend({
+  template: Templates['update-center-footer'],
 
-    collectionEvents: {
-      'all': 'render'
-    },
-
-    serializeData: function () {
-      return _.extend(this._super(), {
-        total: this.collection.where({ _hidden: false }).length
-      });
-    }
-  });
+  collectionEvents: {
+    'all': 'render'
+  },
 
+  serializeData: function () {
+    return _.extend(this._super(), {
+      total: this.collection.where({ _hidden: false }).length
+    });
+  }
 });
+
+
index 99e1095ad7f65492b8aeb6c3d5d2a2f19cea1348..1a78ad8533be47649f02f9265f898617c102299a 100644 (file)
@@ -1,28 +1,28 @@
-define([
-  './templates'
-], function () {
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import './templates';
 
-  return Marionette.ItemView.extend({
-    template: Templates['update-center-header'],
+export default Marionette.ItemView.extend({
+  template: Templates['update-center-header'],
 
-    collectionEvents: {
-      all: 'render'
-    },
+  collectionEvents: {
+    all: 'render'
+  },
 
-    events: {
-      'click .js-cancel-all': 'cancelAll'
-    },
+  events: {
+    'click .js-cancel-all': 'cancelAll'
+  },
 
-    cancelAll: function () {
-      this.collection.cancelAll();
-    },
-
-    serializeData: function () {
-      return _.extend(this._super(), {
-        installing: this.collection._installedCount,
-        uninstalling: this.collection._uninstalledCount
-      });
-    }
-  });
+  cancelAll: function () {
+    this.collection.cancelAll();
+  },
 
+  serializeData: function () {
+    return _.extend(this._super(), {
+      installing: this.collection._installedCount,
+      uninstalling: this.collection._uninstalledCount
+    });
+  }
 });
+
+
index 58e480d16deee5f4bf1808e0021d7f3541152d6b..2a8c5d7b4e8b0cb6a4478889a82119fed04e79d5 100644 (file)
@@ -1,16 +1,15 @@
-define([
-  './templates'
-], function () {
+import Marionette from 'backbone.marionette';
+import './templates';
 
-  return Marionette.LayoutView.extend({
-    template: Templates['update-center-layout'],
-
-    regions: {
-      headerRegion: '#update-center-header',
-      searchRegion: '#update-center-search',
-      listRegion: '#update-center-plugins',
-      footerRegion: '#update-center-footer'
-    }
-  });
+export default Marionette.LayoutView.extend({
+  template: Templates['update-center-layout'],
 
+  regions: {
+    headerRegion: '#update-center-header',
+    searchRegion: '#update-center-search',
+    listRegion: '#update-center-plugins',
+    footerRegion: '#update-center-footer'
+  }
 });
+
+
index 67750c343ecf5a82b1d93f607f3358dd03fff054..163d3c61fa03f72ab4afc36baec3aff73d9acf01 100644 (file)
@@ -1,98 +1,97 @@
-define([
-  './plugin-changelog-view',
-  './templates'
-], function (PluginChangelogView) {
-
-  var $ = jQuery;
-
-  return Marionette.ItemView.extend({
-    tagName: 'li',
-    className: 'panel panel-vertical',
-    template: Templates['update-center-plugin'],
-    systemTemplate: Templates['update-center-system-update'],
-
-    modelEvents: {
-      'change:_hidden': 'toggleDisplay',
-      'change': 'onModelChange',
-      'request': 'onRequest'
-    },
-
-    events: {
-      'click .js-changelog': 'onChangelogClick',
-      'click .js-install': 'install',
-      'click .js-update': 'update',
-      'click .js-uninstall': 'uninstall',
-      'change .js-terms': 'onTermsChange',
-      'click .js-plugin-category': 'onCategoryClick'
-    },
-
-    getTemplate: function () {
-      return this.model.get('_system') ? this.systemTemplate : this.template;
-    },
-
-    onRender: function () {
-      this.$el.attr('data-id', this.model.id);
-      if (this.model.get('_system')) {
-        this.$el.attr('data-system', '');
-      }
-      this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
-    },
-
-    onDestroy: function () {
-      this.$('[data-toggle="tooltip"]').tooltip('destroy');
-    },
-
-    onModelChange: function () {
-      if (!this.model.hasChanged('_hidden')) {
-        this.render();
-      }
-    },
-
-    onChangelogClick: function (e) {
-      e.preventDefault();
-      e.stopPropagation();
-      $('body').click();
-      var index = $(e.currentTarget).data('idx'),
-          // if show changelog of update, show details of this update
-          // otherwise show changelog of the available release
-          update = this.model.has('release') ? this.model.toJSON() : this.model.get('updates')[index],
-          popup = new PluginChangelogView({
-            triggerEl: $(e.currentTarget),
-            model: new Backbone.Model(update)
-          });
-      popup.render();
-    },
-
-    onRequest: function () {
-      this.$('.js-actions').addClass('hidden');
-      this.$('.js-spinner').removeClass('hidden');
-    },
-
-    toggleDisplay: function () {
-      this.$el.toggleClass('hidden', this.model.get('_hidden'));
-    },
-
-    install: function () {
-      this.model.install();
-    },
-
-    update: function () {
-      this.model.update();
-    },
-
-    uninstall: function () {
-      this.model.uninstall();
-    },
-
-    onTermsChange: function () {
-      var isAccepted = this.$('.js-terms').is(':checked');
-      this.$('.js-install').prop('disabled', !isAccepted);
-    },
-
-    onCategoryClick: function (e) {
-      e.preventDefault();
-      this.model.trigger('filter', this.model);
+import $ from 'jquery';
+import Backbone from 'backbone';
+import Marionette from 'backbone.marionette';
+import PluginChangelogView from './plugin-changelog-view';
+import './templates';
+
+export default Marionette.ItemView.extend({
+  tagName: 'li',
+  className: 'panel panel-vertical',
+  template: Templates['update-center-plugin'],
+  systemTemplate: Templates['update-center-system-update'],
+
+  modelEvents: {
+    'change:_hidden': 'toggleDisplay',
+    'change': 'onModelChange',
+    'request': 'onRequest'
+  },
+
+  events: {
+    'click .js-changelog': 'onChangelogClick',
+    'click .js-install': 'install',
+    'click .js-update': 'update',
+    'click .js-uninstall': 'uninstall',
+    'change .js-terms': 'onTermsChange',
+    'click .js-plugin-category': 'onCategoryClick'
+  },
+
+  getTemplate: function () {
+    return this.model.get('_system') ? this.systemTemplate : this.template;
+  },
+
+  onRender: function () {
+    this.$el.attr('data-id', this.model.id);
+    if (this.model.get('_system')) {
+      this.$el.attr('data-system', '');
     }
-  });
+    this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
+  },
 
+  onDestroy: function () {
+    this.$('[data-toggle="tooltip"]').tooltip('destroy');
+  },
+
+  onModelChange: function () {
+    if (!this.model.hasChanged('_hidden')) {
+      this.render();
+    }
+  },
+
+  onChangelogClick: function (e) {
+    e.preventDefault();
+    e.stopPropagation();
+    $('body').click();
+    var index = $(e.currentTarget).data('idx'),
+    // if show changelog of update, show details of this update
+    // otherwise show changelog of the available release
+        update = this.model.has('release') ? this.model.toJSON() : this.model.get('updates')[index],
+        popup = new PluginChangelogView({
+          triggerEl: $(e.currentTarget),
+          model: new Backbone.Model(update)
+        });
+    popup.render();
+  },
+
+  onRequest: function () {
+    this.$('.js-actions').addClass('hidden');
+    this.$('.js-spinner').removeClass('hidden');
+  },
+
+  toggleDisplay: function () {
+    this.$el.toggleClass('hidden', this.model.get('_hidden'));
+  },
+
+  install: function () {
+    this.model.install();
+  },
+
+  update: function () {
+    this.model.update();
+  },
+
+  uninstall: function () {
+    this.model.uninstall();
+  },
+
+  onTermsChange: function () {
+    var isAccepted = this.$('.js-terms').is(':checked');
+    this.$('.js-install').prop('disabled', !isAccepted);
+  },
+
+  onCategoryClick: function (e) {
+    e.preventDefault();
+    this.model.trigger('filter', this.model);
+  }
 });
+
+
index e188597e511566d9060e95fe6b4da184eea3d70b..699e9c76a855a1cb90b6bbd27ca0c2e9d8442d9d 100644 (file)
@@ -1,10 +1,9 @@
-define([
-  './list-item-view'
-], function (ListItemView) {
-
-  return Marionette.CollectionView.extend({
-    tagName: 'ul',
-    childView: ListItemView
-  });
+import Marionette from 'backbone.marionette';
+import ListItemView from './list-item-view';
 
+export default Marionette.CollectionView.extend({
+  tagName: 'ul',
+  childView: ListItemView
 });
+
+
index 9ece2454bb79f78584116e6170ed963cceaab0eb..56ce094b9229f7c38865a3e78f68961ba469e514 100644 (file)
@@ -1,29 +1,28 @@
-define([
-  'components/common/popup',
-  './templates'
-], function (Popup) {
+import _ from 'underscore';
+import Popup from 'components/common/popup';
+import './templates';
 
-  return Popup.extend({
-    template: Templates['update-center-plugin-changelog'],
+export default Popup.extend({
+  template: Templates['update-center-plugin-changelog'],
 
-    onRender: function () {
-      this._super();
-      this.$('.bubble-popup-container').isolatedScroll();
-      this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
-    },
+  onRender: function () {
+    this._super();
+    this.$('.bubble-popup-container').isolatedScroll();
+    this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
+  },
 
-    onClose: function () {
-      this._super();
-      this.$('[data-toggle="tooltip"]').tooltip('destroy');
-    },
-
-    serializeData: function () {
-      return _.extend(this._super(), {
-        // if there is no status, this is a new plugin
-        // => force COMPATIBLE status
-        status: this.model.get('status') || 'COMPATIBLE'
-      });
-    }
-  });
+  onClose: function () {
+    this._super();
+    this.$('[data-toggle="tooltip"]').tooltip('destroy');
+  },
 
+  serializeData: function () {
+    return _.extend(this._super(), {
+      // if there is no status, this is a new plugin
+      // => force COMPATIBLE status
+      status: this.model.get('status') || 'COMPATIBLE'
+    });
+  }
 });
+
+
index 697979e4ed073c41f0a71873506f07cf55ed485e..5730d0e45250166b2244ba91697f4a13372c1867 100644 (file)
@@ -1,70 +1,71 @@
-define(function () {
+import _ from 'underscore';
+import Backbone from 'backbone';
 
-  return Backbone.Model.extend({
-    idAttribute: 'key',
+export default Backbone.Model.extend({
+  idAttribute: 'key',
 
-    defaults: {
-      _hidden: false,
-      _system: false
-    },
+  defaults: {
+    _hidden: false,
+    _system: false
+  },
 
-    _matchAttribute: function (attr, query) {
-      var value = this.get(attr) || '';
-      return value.search(new RegExp(query, 'i')) !== -1;
-    },
+  _matchAttribute: function (attr, query) {
+    var value = this.get(attr) || '';
+    return value.search(new RegExp(query, 'i')) !== -1;
+  },
 
-    match: function (query) {
-      return this._matchAttribute('name', query) ||
-          this._matchAttribute('category', query) ||
-          this._matchAttribute('description', query);
-    },
+  match: function (query) {
+    return this._matchAttribute('name', query) ||
+        this._matchAttribute('category', query) ||
+        this._matchAttribute('description', query);
+  },
 
-    _action: function (options) {
-      var that = this;
-      var opts = _.extend({}, options, {
-        type: 'POST',
-        data: { key: this.id },
-        beforeSend: function () {
-          // disable global ajax notifications
-        },
-        success: function () {
-          options.success(that);
-        },
-        error: function (jqXHR) {
-          that.set({ _status: 'failed', _errors: jqXHR.responseJSON.errors });
-        }
-      });
-      var xhr = Backbone.ajax(opts);
-      this.trigger('request', this, xhr);
-      return xhr;
-    },
+  _action: function (options) {
+    var that = this;
+    var opts = _.extend({}, options, {
+      type: 'POST',
+      data: { key: this.id },
+      beforeSend: function () {
+        // disable global ajax notifications
+      },
+      success: function () {
+        options.success(that);
+      },
+      error: function (jqXHR) {
+        that.set({ _status: 'failed', _errors: jqXHR.responseJSON.errors });
+      }
+    });
+    var xhr = Backbone.ajax(opts);
+    this.trigger('request', this, xhr);
+    return xhr;
+  },
 
-    install: function () {
-      return this._action({
-        url: baseUrl + '/api/plugins/install',
-        success: function (model) {
-          model.set({ _status: 'installing' });
-        }
-      });
-    },
+  install: function () {
+    return this._action({
+      url: baseUrl + '/api/plugins/install',
+      success: function (model) {
+        model.set({ _status: 'installing' });
+      }
+    });
+  },
 
-    update: function () {
-      return this._action({
-        url: baseUrl + '/api/plugins/update',
-        success: function (model) {
-          model.set({ _status: 'installing' });
-        }
-      });
-    },
-
-    uninstall: function () {
-      return this._action({
-        url: baseUrl + '/api/plugins/uninstall',
-        success: function (model) {
-          model.set({ _status: 'uninstalling' });
-        }
-      });
-    }
-  });
+  update: function () {
+    return this._action({
+      url: baseUrl + '/api/plugins/update',
+      success: function (model) {
+        model.set({ _status: 'installing' });
+      }
+    });
+  },
 
+  uninstall: function () {
+    return this._action({
+      url: baseUrl + '/api/plugins/uninstall',
+      success: function (model) {
+        model.set({ _status: 'uninstalling' });
+      }
+    });
+  }
 });
+
+
index 021e124511cf78a73cb992ecdaf98d538ae866d1..5ae26d5f1d72174768002f25300f650d6b1b8356 100644 (file)
-define([
-  './plugin'
-], function (Plugin) {
-
-  var $ = jQuery;
-
-  var Plugins = Backbone.Collection.extend({
-    model: Plugin,
-
-    comparator: function (model) {
-      return model.get('name') || '';
-    },
-
-    initialize: function () {
-      this._installedCount = 0;
-      this._uninstalledCount = 0;
-      this.listenTo(this, 'change:_status', this.onStatusChange);
-    },
-
-    parse: function (r) {
-      var that = this;
-      return r.plugins.map(function (plugin) {
-        var updates = [
-          that._getLastWithStatus(plugin.updates, 'COMPATIBLE'),
-          that._getLastWithStatus(plugin.updates, 'REQUIRES_SYSTEM_UPGRADE'),
-          that._getLastWithStatus(plugin.updates, 'DEPS_REQUIRE_SYSTEM_UPGRADE')
-        ].filter(_.identity);
-        updates = updates.map(function (update) {
-          return that._extendChangelog(plugin.updates, update);
-        });
-        return _.extend(plugin, { updates: updates });
-      });
-    },
-
-    _getLastWithStatus: function (updates, status) {
-      var index = _.findLastIndex(updates, function (update) {
-        return update.status === status;
+import $ from 'jquery';
+import _ from 'underscore';
+import Backbone from 'backbone';
+import Plugin from './plugin';
+
+var Plugins = Backbone.Collection.extend({
+  model: Plugin,
+
+  comparator: function (model) {
+    return model.get('name') || '';
+  },
+
+  initialize: function () {
+    this._installedCount = 0;
+    this._uninstalledCount = 0;
+    this.listenTo(this, 'change:_status', this.onStatusChange);
+  },
+
+  parse: function (r) {
+    var that = this;
+    return r.plugins.map(function (plugin) {
+      var updates = [
+        that._getLastWithStatus(plugin.updates, 'COMPATIBLE'),
+        that._getLastWithStatus(plugin.updates, 'REQUIRES_SYSTEM_UPGRADE'),
+        that._getLastWithStatus(plugin.updates, 'DEPS_REQUIRE_SYSTEM_UPGRADE')
+      ].filter(_.identity);
+      updates = updates.map(function (update) {
+        return that._extendChangelog(plugin.updates, update);
       });
-      return index !== -1 ? updates[index] : null;
-    },
-
-    _extendChangelog: function (updates, update) {
-      var index = updates.indexOf(update);
-      var previousUpdates = index > 0 ? updates.slice(0, index) : [];
-      return _.extend(update, { previousUpdates: previousUpdates });
-    },
-
-    _fetchInstalled: function () {
-      if (this._installed) {
-        return $.Deferred().resolve().promise();
+      return _.extend(plugin, { updates: updates });
+    });
+  },
+
+  _getLastWithStatus: function (updates, status) {
+    var index = _.findLastIndex(updates, function (update) {
+      return update.status === status;
+    });
+    return index !== -1 ? updates[index] : null;
+  },
+
+  _extendChangelog: function (updates, update) {
+    var index = updates.indexOf(update);
+    var previousUpdates = index > 0 ? updates.slice(0, index) : [];
+    return _.extend(update, { previousUpdates: previousUpdates });
+  },
+
+  _fetchInstalled: function () {
+    if (this._installed) {
+      return $.Deferred().resolve().promise();
+    }
+    var that = this;
+    var opts = {
+      type: 'GET',
+      url: baseUrl + '/api/plugins/installed',
+      success: function (r) {
+        that._installed = that.parse(r);
       }
-      var that = this;
-      var opts = {
-        type: 'GET',
-        url: baseUrl + '/api/plugins/installed',
-        success: function (r) {
-          that._installed = that.parse(r);
-        }
-      };
-      return Backbone.ajax(opts);
-    },
-
-    _fetchUpdates: function () {
-      if (this._updates) {
-        return $.Deferred().resolve().promise();
+    };
+    return Backbone.ajax(opts);
+  },
+
+  _fetchUpdates: function () {
+    if (this._updates) {
+      return $.Deferred().resolve().promise();
+    }
+    var that = this;
+    var opts = {
+      type: 'GET',
+      url: baseUrl + '/api/plugins/updates',
+      success: function (r) {
+        that._updates = that.parse(r);
       }
-      var that = this;
-      var opts = {
-        type: 'GET',
-        url: baseUrl + '/api/plugins/updates',
-        success: function (r) {
-          that._updates = that.parse(r);
-        }
-      };
-      return Backbone.ajax(opts);
-    },
-
-    _fetchAvailable: function () {
-      if (this._available) {
-        return $.Deferred().resolve().promise();
+    };
+    return Backbone.ajax(opts);
+  },
+
+  _fetchAvailable: function () {
+    if (this._available) {
+      return $.Deferred().resolve().promise();
+    }
+    var that = this;
+    var opts = {
+      type: 'GET',
+      url: baseUrl + '/api/plugins/available',
+      success: function (r) {
+        that._available = that.parse(r);
       }
-      var that = this;
-      var opts = {
-        type: 'GET',
-        url: baseUrl + '/api/plugins/available',
-        success: function (r) {
-          that._available = that.parse(r);
-        }
-      };
-      return Backbone.ajax(opts);
-    },
-
-    _fetchPending: function () {
-      var that = this;
-      var opts = {
-        type: 'GET',
-        url: baseUrl + '/api/plugins/pending',
-        success: function (r) {
-          var installing = r.installing.map(function (plugin) {
-                return { key: plugin.key, _status: 'installing' };
-              }),
-              uninstalling = r.removing.map(function (plugin) {
-                return { key: plugin.key, _status: 'uninstalling' };
-              });
-          that._installedCount = installing.length;
-          that._uninstalledCount = uninstalling.length;
-          that._pending = new Plugins([].concat(installing, uninstalling)).models;
-        }
-      };
-      return Backbone.ajax(opts);
-    },
-
-    _fetchSystemUpgrades: function () {
-      if (this._systemUpdates) {
-        return $.Deferred().resolve().promise();
+    };
+    return Backbone.ajax(opts);
+  },
+
+  _fetchPending: function () {
+    var that = this;
+    var opts = {
+      type: 'GET',
+      url: baseUrl + '/api/plugins/pending',
+      success: function (r) {
+        var installing = r.installing.map(function (plugin) {
+              return { key: plugin.key, _status: 'installing' };
+            }),
+            uninstalling = r.removing.map(function (plugin) {
+              return { key: plugin.key, _status: 'uninstalling' };
+            });
+        that._installedCount = installing.length;
+        that._uninstalledCount = uninstalling.length;
+        that._pending = new Plugins([].concat(installing, uninstalling)).models;
       }
-      var that = this;
-      var opts = {
-        type: 'GET',
-        url: baseUrl + '/api/system/upgrades',
-        success: function (r) {
-          that._systemUpdates = r.upgrades.map(function (update) {
-            return _.extend(update, { _system: true });
-          });
-        }
-      };
-      return Backbone.ajax(opts);
-    },
-
-    fetchInstalled: function () {
-      var that = this;
-      return $.when(this._fetchInstalled(), this._fetchUpdates(), this._fetchPending()).done(function () {
-        var plugins = new Plugins();
-        plugins.set(that._installed);
-        plugins.set(that._updates, { remove: false });
-        plugins.set(that._pending, { add: false, remove: false });
-        that.reset(plugins.models);
-      });
-    },
-
-    fetchUpdates: function () {
-      var that = this;
-      return $.when(this._fetchInstalled(), this._fetchUpdates(), this._fetchPending())
-          .done(function () {
-            var plugins = new Plugins();
-            plugins.set(that._installed);
-            plugins.set(that._updates, { remove: true });
-            plugins.set(that._pending, { add: false, remove: false });
-            that.reset(plugins.models);
-          });
-    },
-
-    fetchAvailable: function () {
-      var that = this;
-      return $.when(this._fetchAvailable(), this._fetchPending()).done(function () {
-        var plugins = new Plugins();
-        plugins.set(that._available);
-        plugins.set(that._pending, { add: false, remove: false });
-        that.reset(plugins.models);
-      });
-    },
-
-    fetchSystemUpgrades: function () {
-      var that = this;
-      return $.when(this._fetchSystemUpgrades()).done(function () {
-        that.reset(that._systemUpdates);
-      });
-    },
+    };
+    return Backbone.ajax(opts);
+  },
 
-    search: function (query) {
-      this.filter(function (model) {
-        model.set({ _hidden: !model.match(query) });
-      });
-    },
-
-    cancelAll: function () {
-      var that = this;
-      var opts = {
-        type: 'POST',
-        url: baseUrl + '/api/plugins/cancel_all',
-        success: function () {
-          that._installedCount = 0;
-          that._uninstalledCount = 0;
-          that.forEach(function (model) {
-            model.unset('_status');
-          });
-          that.trigger('change');
-        }
-      };
-      return Backbone.ajax(opts);
-    },
-
-    onStatusChange: function (model, status) {
-      if (status === 'installing') {
-        this._installedCount++;
+  _fetchSystemUpgrades: function () {
+    if (this._systemUpdates) {
+      return $.Deferred().resolve().promise();
+    }
+    var that = this;
+    var opts = {
+      type: 'GET',
+      url: baseUrl + '/api/system/upgrades',
+      success: function (r) {
+        that._systemUpdates = r.upgrades.map(function (update) {
+          return _.extend(update, { _system: true });
+        });
       }
-      if (status === 'uninstalling') {
-        this._uninstalledCount++;
+    };
+    return Backbone.ajax(opts);
+  },
+
+  fetchInstalled: function () {
+    var that = this;
+    return $.when(this._fetchInstalled(), this._fetchUpdates(), this._fetchPending()).done(function () {
+      var plugins = new Plugins();
+      plugins.set(that._installed);
+      plugins.set(that._updates, { remove: false });
+      plugins.set(that._pending, { add: false, remove: false });
+      that.reset(plugins.models);
+    });
+  },
+
+  fetchUpdates: function () {
+    var that = this;
+    return $.when(this._fetchInstalled(), this._fetchUpdates(), this._fetchPending())
+        .done(function () {
+          var plugins = new Plugins();
+          plugins.set(that._installed);
+          plugins.set(that._updates, { remove: true });
+          plugins.set(that._pending, { add: false, remove: false });
+          that.reset(plugins.models);
+        });
+  },
+
+  fetchAvailable: function () {
+    var that = this;
+    return $.when(this._fetchAvailable(), this._fetchPending()).done(function () {
+      var plugins = new Plugins();
+      plugins.set(that._available);
+      plugins.set(that._pending, { add: false, remove: false });
+      that.reset(plugins.models);
+    });
+  },
+
+  fetchSystemUpgrades: function () {
+    var that = this;
+    return $.when(this._fetchSystemUpgrades()).done(function () {
+      that.reset(that._systemUpdates);
+    });
+  },
+
+  search: function (query) {
+    this.filter(function (model) {
+      model.set({ _hidden: !model.match(query) });
+    });
+  },
+
+  cancelAll: function () {
+    var that = this;
+    var opts = {
+      type: 'POST',
+      url: baseUrl + '/api/plugins/cancel_all',
+      success: function () {
+        that._installedCount = 0;
+        that._uninstalledCount = 0;
+        that.forEach(function (model) {
+          model.unset('_status');
+        });
+        that.trigger('change');
       }
-      this.trigger('change');
+    };
+    return Backbone.ajax(opts);
+  },
+
+  onStatusChange: function (model, status) {
+    if (status === 'installing') {
+      this._installedCount++;
+    }
+    if (status === 'uninstalling') {
+      this._uninstalledCount++;
     }
-  });
+    this.trigger('change');
+  }
+});
+
+export default Plugins;
 
-  return Plugins;
 
-});
index 0a9af1440cc80d9d0e02015dd79b396394b753b9..25b2b7a3b95cb3249108806e9d694b018a00edcd 100644 (file)
@@ -1,37 +1,37 @@
-define(function () {
-
-  return Backbone.Router.extend({
-    routes: {
-      '': 'index',
-      'installed': 'showInstalled',
-      'updates': 'showUpdates',
-      'available': 'showAvailable',
-      'system': 'showSystemUpgrades'
-    },
-
-    initialize: function (options) {
-      this.controller = options.controller;
-    },
-
-    index: function () {
-      this.navigate('installed', { trigger: true, replace: true });
-    },
-
-    showInstalled: function () {
-      this.controller.showInstalled();
-    },
-
-    showUpdates: function () {
-      this.controller.showUpdates();
-    },
-
-    showAvailable: function () {
-      this.controller.showAvailable();
-    },
-
-    showSystemUpgrades: function () {
-      this.controller.showSystemUpgrades();
-    }
-  });
-
+import Backbone from 'backbone';
+
+export default Backbone.Router.extend({
+  routes: {
+    '': 'index',
+    'installed': 'showInstalled',
+    'updates': 'showUpdates',
+    'available': 'showAvailable',
+    'system': 'showSystemUpgrades'
+  },
+
+  initialize: function (options) {
+    this.controller = options.controller;
+  },
+
+  index: function () {
+    this.navigate('installed', { trigger: true, replace: true });
+  },
+
+  showInstalled: function () {
+    this.controller.showInstalled();
+  },
+
+  showUpdates: function () {
+    this.controller.showUpdates();
+  },
+
+  showAvailable: function () {
+    this.controller.showAvailable();
+  },
+
+  showSystemUpgrades: function () {
+    this.controller.showSystemUpgrades();
+  }
 });
+
+
index b46cf5ce293853c0d641a403782b097ef0f6c401..739f11a2c968a69de47efd60ae1e478b35957917 100644 (file)
@@ -1,84 +1,84 @@
-define([
-  './templates'
-], function () {
-
-  return Marionette.ItemView.extend({
-    template: Templates['update-center-search'],
-
-    events: {
-      'change [name="update-center-filter"]': 'onFilterChange',
-
-      'submit #update-center-search-form': 'onFormSubmit',
-      'search #update-center-search-query': 'debouncedOnKeyUp',
-      'keyup #update-center-search-query': 'debouncedOnKeyUp',
-      'change #update-center-search-query': 'debouncedOnKeyUp'
-    },
-
-    collectionEvents: {
-      'filter': 'onFilter'
-    },
-
-    initialize: function () {
-      this._bufferedValue = null;
-      this.debouncedOnKeyUp = _.debounce(this.onKeyUp, 50);
-      this.listenTo(this.options.state, 'change', this.render);
-    },
-
-    onRender: function () {
-      this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
-    },
-
-    onDestroy: function () {
-      this.$('[data-toggle="tooltip"]').tooltip('destroy');
-    },
-
-    onFilterChange: function () {
-      var value = this.$('[name="update-center-filter"]:checked').val();
-      this.filter(value);
-    },
-
-    filter: function (value) {
-      this.options.router.navigate(value, { trigger: true });
-    },
-
-    onFormSubmit: function (e) {
-      e.preventDefault();
-      this.debouncedOnKeyUp();
-    },
-
-    onKeyUp: function () {
-      var q = this.getQuery();
-      if (q === this._bufferedValue) {
-        return;
-      }
-      this._bufferedValue = this.getQuery();
-      this.search(q);
-    },
-
-    getQuery: function () {
-      return this.$('#update-center-search-query').val();
-    },
-
-    search: function (q) {
-      this.collection.search(q);
-    },
-
-    focusSearch: function () {
-      var that = this;
-      setTimeout(function () {
-        that.$('#update-center-search-query').focus();
-      }, 0);
-    },
-
-    onFilter: function (model) {
-      var q = model.get('category');
-      this.$('#update-center-search-query').val(q);
-      this.search(q);
-    },
-
-    serializeData: function () {
-      return _.extend(this._super(), { state: this.options.state.toJSON() });
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import './templates';
+
+export default Marionette.ItemView.extend({
+  template: Templates['update-center-search'],
+
+  events: {
+    'change [name="update-center-filter"]': 'onFilterChange',
+
+    'submit #update-center-search-form': 'onFormSubmit',
+    'search #update-center-search-query': 'debouncedOnKeyUp',
+    'keyup #update-center-search-query': 'debouncedOnKeyUp',
+    'change #update-center-search-query': 'debouncedOnKeyUp'
+  },
+
+  collectionEvents: {
+    'filter': 'onFilter'
+  },
+
+  initialize: function () {
+    this._bufferedValue = null;
+    this.debouncedOnKeyUp = _.debounce(this.onKeyUp, 50);
+    this.listenTo(this.options.state, 'change', this.render);
+  },
+
+  onRender: function () {
+    this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
+  },
+
+  onDestroy: function () {
+    this.$('[data-toggle="tooltip"]').tooltip('destroy');
+  },
+
+  onFilterChange: function () {
+    var value = this.$('[name="update-center-filter"]:checked').val();
+    this.filter(value);
+  },
+
+  filter: function (value) {
+    this.options.router.navigate(value, { trigger: true });
+  },
+
+  onFormSubmit: function (e) {
+    e.preventDefault();
+    this.debouncedOnKeyUp();
+  },
+
+  onKeyUp: function () {
+    var q = this.getQuery();
+    if (q === this._bufferedValue) {
+      return;
     }
-  });
-
+    this._bufferedValue = this.getQuery();
+    this.search(q);
+  },
+
+  getQuery: function () {
+    return this.$('#update-center-search-query').val();
+  },
+
+  search: function (q) {
+    this.collection.search(q);
+  },
+
+  focusSearch: function () {
+    var that = this;
+    setTimeout(function () {
+      that.$('#update-center-search-query').focus();
+    }, 0);
+  },
+
+  onFilter: function (model) {
+    var q = model.get('category');
+    this.$('#update-center-search-query').val(q);
+    this.search(q);
+  },
+
+  serializeData: function () {
+    return _.extend(this._super(), { state: this.options.state.toJSON() });
+  }
 });
+
+
index 9fa9df3759aa5a0ecb82f3907511d654f9827e3c..cf64028a2e731c37b19b69b5c7a4337efb597f73 100644 (file)
@@ -1,47 +1,46 @@
-define([
-  './layout',
-  './users',
-  './header-view',
-  './search-view',
-  './list-view',
-  './list-footer-view'
-], function (Layout, Users, HeaderView, SearchView, ListView, ListFooterView) {
-
-  var App = new Marionette.Application(),
-      init = function (options) {
-        // Layout
-        this.layout = new Layout({ el: options.el });
-        this.layout.render();
-
-        // Collection
-        this.users = new Users();
-
-        // Header View
-        this.headerView = new HeaderView({ collection: this.users });
-        this.layout.headerRegion.show(this.headerView);
-
-        // Search View
-        this.searchView = new SearchView({ collection: this.users });
-        this.layout.searchRegion.show(this.searchView);
-
-        // List View
-        this.listView = new ListView({ collection: this.users });
-        this.layout.listRegion.show(this.listView);
-
-        // List Footer View
-        this.listFooterView = new ListFooterView({ collection: this.users });
-        this.layout.listFooterRegion.show(this.listFooterView);
-
-        // Go!
-        this.users.fetch();
-      };
-
-  App.on('start', function (options) {
-    window.requestMessages().done(function () {
-      init.call(App, options);
-    });
+import Marionette from 'backbone.marionette';
+import Layout from './layout';
+import Users from './users';
+import HeaderView from './header-view';
+import SearchView from './search-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.users = new Users();
+
+      // Header View
+      this.headerView = new HeaderView({ collection: this.users });
+      this.layout.headerRegion.show(this.headerView);
+
+      // Search View
+      this.searchView = new SearchView({ collection: this.users });
+      this.layout.searchRegion.show(this.searchView);
+
+      // List View
+      this.listView = new ListView({ collection: this.users });
+      this.layout.listRegion.show(this.listView);
+
+      // List Footer View
+      this.listFooterView = new ListFooterView({ collection: this.users });
+      this.layout.listFooterRegion.show(this.listFooterView);
+
+      // Go!
+      this.users.fetch();
+    };
+
+App.on('start', function (options) {
+  window.requestMessages().done(function () {
+    init.call(App, options);
   });
+});
+
+export default App;
 
-  return App;
 
-});
index 659d3012a79b33d47bda480dba389902502fff5e..f8b9f95eb605b06d0d6ad3fa2338f6b78f579d79 100644 (file)
@@ -1,37 +1,35 @@
-define([
-  'components/common/modal-form',
-  './templates'
-], function (ModalForm) {
+import ModalForm from 'components/common/modal-form';
+import './templates';
 
-  return ModalForm.extend({
-    template: Templates['users-change-password'],
+export default ModalForm.extend({
+  template: Templates['users-change-password'],
 
-    onFormSubmit: function (e) {
-      this._super(e);
-      this.sendRequest();
-    },
+  onFormSubmit: function (e) {
+    this._super(e);
+    this.sendRequest();
+  },
 
-    sendRequest: function () {
-      var that = this,
-          password = this.$('#change-user-password-password').val(),
-          confirmation = this.$('#change-user-password-password-confirmation').val();
-      if (password !== confirmation) {
-        that.showErrors([{ msg: 'New password and its confirmation do not match' }]);
-        return;
-      }
-      this.disableForm();
-      return this.model.changePassword(password, {
-        statusCode: {
-          // do not show global error
-          400: null
-        }
-      }).done(function () {
-        that.destroy();
-      }).fail(function (jqXHR) {
-        that.enableForm();
-        that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
-      });
+  sendRequest: function () {
+    var that = this,
+        password = this.$('#change-user-password-password').val(),
+        confirmation = this.$('#change-user-password-password-confirmation').val();
+    if (password !== confirmation) {
+      that.showErrors([{ msg: 'New password and its confirmation do not match' }]);
+      return;
     }
-  });
-
+    this.disableForm();
+    return this.model.changePassword(password, {
+      statusCode: {
+        // do not show global error
+        400: null
+      }
+    }).done(function () {
+      that.destroy();
+    }).fail(function (jqXHR) {
+      that.enableForm();
+      that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+    });
+  }
 });
+
+
index 743035362adf29c1d740d257ef163728be27ae3a..84e2bbdade14ee5705eb4a3fd7ea895f1effb2a8 100644 (file)
@@ -1,34 +1,32 @@
-define([
-  './user',
-  './form-view'
-], function (User, FormView) {
+import User from './user';
+import FormView from './form-view';
 
-  return FormView.extend({
-
-    sendRequest: function () {
-      var that = this,
-          user = new User({
-            login: this.$('#create-user-login').val(),
-            name: this.$('#create-user-name').val(),
-            email: this.$('#create-user-email').val(),
-            password: this.$('#create-user-password').val(),
-            scmAccounts: this.getScmAccounts()
-          });
-      this.disableForm();
-      return user.save(null, {
-        statusCode: {
-          // do not show global error
-          400: null,
-          500: 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,
+        user = new User({
+          login: this.$('#create-user-login').val(),
+          name: this.$('#create-user-name').val(),
+          email: this.$('#create-user-email').val(),
+          password: this.$('#create-user-password').val(),
+          scmAccounts: this.getScmAccounts()
+        });
+    this.disableForm();
+    return user.save(null, {
+      statusCode: {
+        // do not show global error
+        400: null,
+        500: null
+      }
+    }).done(function () {
+      that.collection.refresh();
+      that.destroy();
+    }).fail(function (jqXHR) {
+      that.enableForm();
+      that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+    });
+  }
 });
+
+
index 000a350ea57855bf0fa0e6f885eeb2370f139d15..bf7cbe804892a79c4c60f2b5198dab502dc25b6e 100644 (file)
@@ -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['users-deactivate'],
+export default ModalForm.extend({
+  template: Templates['users-deactivate'],
 
-    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.total--;
-        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.total--;
+      that.destroy();
+    }).fail(function (jqXHR) {
+      that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+    });
+  }
 });
+
+
index 50b18c1d237b6f83bbb0db457a48b866eb342e6b..71bd7716038a6169e5c08c9effbf82bb33b58c6b 100644 (file)
@@ -1,52 +1,50 @@
-define([
-  'components/common/modal-form',
-  './templates'
-], function (ModalForm) {
-
-  var $ = jQuery;
-
-  return ModalForm.extend({
-    template: Templates['users-form'],
-
-    events: function () {
-      return _.extend(this._super(), {
-        'click #create-user-add-scm-account': 'onAddScmAccountClick'
-      });
-    },
-
-    onRender: function () {
-      this._super();
-      this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
-    },
-
-    onDestroy: function () {
-      this._super();
-      this.$('[data-toggle="tooltip"]').tooltip('destroy');
-    },
-
-    onFormSubmit: function (e) {
-      this._super(e);
-      this.sendRequest();
-    },
-
-    onAddScmAccountClick: function (e) {
-      e.preventDefault();
-      this.addScmAccount();
-    },
-
-    getScmAccounts: function () {
-      var scmAccounts = this.$('[name="scmAccounts"]').map(function () {
-        return $(this).val();
-      }).toArray();
-      return scmAccounts.filter(function (value) {
-        return !!value;
-      });
-    },
-
-    addScmAccount: function () {
-      var fields = this.$('[name="scmAccounts"]');
-      fields.first().clone().val('').insertAfter(fields.last());
-    }
-  });
-
+import $ from 'jquery';
+import _ from 'underscore';
+import ModalForm from 'components/common/modal-form';
+import './templates';
+
+export default ModalForm.extend({
+  template: Templates['users-form'],
+
+  events: function () {
+    return _.extend(this._super(), {
+      'click #create-user-add-scm-account': 'onAddScmAccountClick'
+    });
+  },
+
+  onRender: function () {
+    this._super();
+    this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
+  },
+
+  onDestroy: function () {
+    this._super();
+    this.$('[data-toggle="tooltip"]').tooltip('destroy');
+  },
+
+  onFormSubmit: function (e) {
+    this._super(e);
+    this.sendRequest();
+  },
+
+  onAddScmAccountClick: function (e) {
+    e.preventDefault();
+    this.addScmAccount();
+  },
+
+  getScmAccounts: function () {
+    var scmAccounts = this.$('[name="scmAccounts"]').map(function () {
+      return $(this).val();
+    }).toArray();
+    return scmAccounts.filter(function (value) {
+      return !!value;
+    });
+  },
+
+  addScmAccount: function () {
+    var fields = this.$('[name="scmAccounts"]');
+    fields.first().clone().val('').insertAfter(fields.last());
+  }
 });
+
+
index 09a127fc6fdc77898476757309fb91af18ced6b4..f402b931cb87f2de997ef2be3eb4eb0285577ed9 100644 (file)
@@ -1,43 +1,41 @@
-define([
-  'components/common/modals',
-  'components/common/select-list',
-  './templates'
-], function (Modal) {
+import Modal from 'components/common/modals';
+import 'components/common/select-list';
+import './templates';
 
-  return Modal.extend({
-    template: Templates['users-groups'],
-    itemTemplate: Templates['users-group'],
+export default Modal.extend({
+  template: Templates['users-groups'],
+  itemTemplate: Templates['users-group'],
 
-    onRender: function () {
-      this._super();
-      new window.SelectList({
-        el: this.$('#users-groups'),
-        width: '100%',
-        readOnly: false,
-        focusSearch: false,
-        format: function (item) {
-          return item.name + '<br><span class="note">' + item.description + '</span>';
-        },
-        queryParam: 'q',
-        searchUrl: baseUrl + '/api/users/groups?ps=100&login=' + this.model.id,
-        selectUrl: baseUrl + '/api/usergroups/add_user',
-        deselectUrl: baseUrl + '/api/usergroups/remove_user',
-        extra: {
-          login: this.model.id
-        },
-        selectParameter: 'id',
-        selectParameterValue: 'id',
-        parse: function (r) {
-          this.more = false;
-          return r.groups;
-        }
-      });
-    },
-
-    onDestroy: function () {
-      this.model.collection.refresh();
-      Modal.prototype.onDestroy.apply(this, arguments);
-    }
-  });
+  onRender: function () {
+    this._super();
+    new window.SelectList({
+      el: this.$('#users-groups'),
+      width: '100%',
+      readOnly: false,
+      focusSearch: false,
+      format: function (item) {
+        return item.name + '<br><span class="note">' + item.description + '</span>';
+      },
+      queryParam: 'q',
+      searchUrl: baseUrl + '/api/users/groups?ps=100&login=' + this.model.id,
+      selectUrl: baseUrl + '/api/usergroups/add_user',
+      deselectUrl: baseUrl + '/api/usergroups/remove_user',
+      extra: {
+        login: this.model.id
+      },
+      selectParameter: 'id',
+      selectParameterValue: 'id',
+      parse: function (r) {
+        this.more = false;
+        return r.groups;
+      }
+    });
+  },
 
+  onDestroy: function () {
+    this.model.collection.refresh();
+    Modal.prototype.onDestroy.apply(this, arguments);
+  }
 });
+
+
index c8b76193b4cc09973d1da9f67c0b51cd7114c2ac..ae9bae8e422aca7740cb4ee3b147c13d042e05cc 100644 (file)
@@ -1,25 +1,24 @@
-define([
-  './create-view',
-  './templates'
-], function (CreateView) {
+import Marionette from 'backbone.marionette';
+import CreateView from './create-view';
+import './templates';
 
-  return Marionette.ItemView.extend({
-    template: Templates['users-header'],
+export default Marionette.ItemView.extend({
+  template: Templates['users-header'],
 
-    events: {
-      'click #users-create': 'onCreateClick'
-    },
+  events: {
+    'click #users-create': 'onCreateClick'
+  },
 
-    onCreateClick: function (e) {
-      e.preventDefault();
-      this.createUser();
-    },
-
-    createUser: function () {
-      new CreateView({
-        collection: this.collection
-      }).render();
-    }
-  });
+  onCreateClick: function (e) {
+    e.preventDefault();
+    this.createUser();
+  },
 
+  createUser: function () {
+    new CreateView({
+      collection: this.collection
+    }).render();
+  }
 });
+
+
index 9acb054bdad618fa01517ae4397e9868a2e15138..90866f6f6e18d49edc7c8e1ed10c13993a230555 100644 (file)
@@ -1,16 +1,15 @@
-define([
-  './templates'
-], function () {
+import Marionette from 'backbone.marionette';
+import './templates';
 
-  return Marionette.LayoutView.extend({
-    template: Templates['users-layout'],
-
-    regions: {
-      headerRegion: '#users-header',
-      searchRegion: '#users-search',
-      listRegion: '#users-list',
-      listFooterRegion: '#users-list-footer'
-    }
-  });
+export default Marionette.LayoutView.extend({
+  template: Templates['users-layout'],
 
+  regions: {
+    headerRegion: '#users-header',
+    searchRegion: '#users-search',
+    listRegion: '#users-list',
+    listFooterRegion: '#users-list-footer'
+  }
 });
+
+
index cf802586354e272f366d731013808a3229064dbc..7c4d2482efae95a9fa63902ab3f677a0ea1a41a7 100644 (file)
@@ -1,34 +1,34 @@
-define([
-  './templates'
-], function () {
-
-  return Marionette.ItemView.extend({
-    template: Templates['users-list-footer'],
-
-    collectionEvents: {
-      'all': 'render'
-    },
-
-    events: {
-      'click #users-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['users-list-footer'],
+
+  collectionEvents: {
+    'all': 'render'
+  },
+
+  events: {
+    'click #users-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()
+    });
+  }
 });
+
+
index b11e39e27662b55a2c1990556c242cc2c7afd6e0..50e864992fa19d1b30836504be3a5dd8ab436e3d 100644 (file)
-define([
-  './update-view',
-  './change-password-view',
-  './deactivate-view',
-  './groups-view',
-  './templates'
-], function (UpdateView, ChangePasswordView, DeactivateView, GroupsView) {
-
-  return Marionette.ItemView.extend({
-    tagName: 'li',
-    className: 'panel panel-vertical',
-    template: Templates['users-list-item'],
-
-    events: {
-      'click .js-user-more-scm': 'onMoreScmClick',
-      'click .js-user-more-groups': 'onMoreGroupsClick',
-      'click .js-user-update': 'onUpdateClick',
-      'click .js-user-change-password': 'onChangePasswordClick',
-      'click .js-user-deactivate': 'onDeactivateClick',
-      'click .js-user-groups': 'onGroupsClick'
-    },
-
-    initialize: function () {
-      this.scmLimit = 3;
-      this.groupsLimit = 3;
-    },
-
-    onRender: function () {
-      this.$el.attr('data-login', this.model.id);
-      this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
-    },
-
-    onDestroy: function () {
-      this.$('[data-toggle="tooltip"]').tooltip('destroy');
-    },
-
-    onMoreScmClick: function (e) {
-      e.preventDefault();
-      this.showMoreScm();
-    },
-
-    onMoreGroupsClick: function (e) {
-      e.preventDefault();
-      this.showMoreGroups();
-    },
-
-    onUpdateClick: function (e) {
-      e.preventDefault();
-      this.updateUser();
-    },
-
-    onChangePasswordClick: function (e) {
-      e.preventDefault();
-      this.changePassword();
-    },
-
-    onDeactivateClick: function (e) {
-      e.preventDefault();
-      this.deactivateUser();
-    },
-
-    onGroupsClick: function (e) {
-      e.preventDefault();
-      this.showGroups();
-    },
-
-    showMoreScm: function () {
-      this.scmLimit = 10000;
-      this.render();
-    },
-
-    showMoreGroups: function () {
-      this.groupsLimit = 10000;
-      this.render();
-    },
-
-    updateUser: function () {
-      new UpdateView({
-        model: this.model,
-        collection: this.model.collection
-      }).render();
-    },
-
-    changePassword: function () {
-      new ChangePasswordView({
-        model: this.model,
-        collection: this.model.collection
-      }).render();
-    },
-
-    deactivateUser: function () {
-      new DeactivateView({ model: this.model }).render();
-    },
-
-    showGroups: function () {
-      new GroupsView({ model: this.model }).render();
-    },
-
-    serializeData: function () {
-      var scmAccounts = this.model.get('scmAccounts'),
-          scmAccountsLimit = scmAccounts.length > this.scmLimit ? this.scmLimit - 1 : this.scmLimit,
-          groups = this.model.get('groups'),
-          groupsLimit = groups.length > this.groupsLimit ? this.groupsLimit - 1 : this.groupsLimit;
-      return _.extend(this._super(), {
-        firstScmAccounts: _.first(scmAccounts, scmAccountsLimit),
-        moreScmAccountsCount: scmAccounts.length - scmAccountsLimit,
-        firstGroups: _.first(groups, groupsLimit),
-        moreGroupsCount: groups.length - groupsLimit
-      });
-    }
-  });
-
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import UpdateView from './update-view';
+import ChangePasswordView from './change-password-view';
+import DeactivateView from './deactivate-view';
+import GroupsView from './groups-view';
+import './templates';
+
+export default Marionette.ItemView.extend({
+  tagName: 'li',
+  className: 'panel panel-vertical',
+  template: Templates['users-list-item'],
+
+  events: {
+    'click .js-user-more-scm': 'onMoreScmClick',
+    'click .js-user-more-groups': 'onMoreGroupsClick',
+    'click .js-user-update': 'onUpdateClick',
+    'click .js-user-change-password': 'onChangePasswordClick',
+    'click .js-user-deactivate': 'onDeactivateClick',
+    'click .js-user-groups': 'onGroupsClick'
+  },
+
+  initialize: function () {
+    this.scmLimit = 3;
+    this.groupsLimit = 3;
+  },
+
+  onRender: function () {
+    this.$el.attr('data-login', this.model.id);
+    this.$('[data-toggle="tooltip"]').tooltip({ container: 'body', placement: 'bottom' });
+  },
+
+  onDestroy: function () {
+    this.$('[data-toggle="tooltip"]').tooltip('destroy');
+  },
+
+  onMoreScmClick: function (e) {
+    e.preventDefault();
+    this.showMoreScm();
+  },
+
+  onMoreGroupsClick: function (e) {
+    e.preventDefault();
+    this.showMoreGroups();
+  },
+
+  onUpdateClick: function (e) {
+    e.preventDefault();
+    this.updateUser();
+  },
+
+  onChangePasswordClick: function (e) {
+    e.preventDefault();
+    this.changePassword();
+  },
+
+  onDeactivateClick: function (e) {
+    e.preventDefault();
+    this.deactivateUser();
+  },
+
+  onGroupsClick: function (e) {
+    e.preventDefault();
+    this.showGroups();
+  },
+
+  showMoreScm: function () {
+    this.scmLimit = 10000;
+    this.render();
+  },
+
+  showMoreGroups: function () {
+    this.groupsLimit = 10000;
+    this.render();
+  },
+
+  updateUser: function () {
+    new UpdateView({
+      model: this.model,
+      collection: this.model.collection
+    }).render();
+  },
+
+  changePassword: function () {
+    new ChangePasswordView({
+      model: this.model,
+      collection: this.model.collection
+    }).render();
+  },
+
+  deactivateUser: function () {
+    new DeactivateView({ model: this.model }).render();
+  },
+
+  showGroups: function () {
+    new GroupsView({ model: this.model }).render();
+  },
+
+  serializeData: function () {
+    var scmAccounts = this.model.get('scmAccounts'),
+        scmAccountsLimit = scmAccounts.length > this.scmLimit ? this.scmLimit - 1 : this.scmLimit,
+        groups = this.model.get('groups'),
+        groupsLimit = groups.length > this.groupsLimit ? this.groupsLimit - 1 : this.groupsLimit;
+    return _.extend(this._super(), {
+      firstScmAccounts: _.first(scmAccounts, scmAccountsLimit),
+      moreScmAccountsCount: scmAccounts.length - scmAccountsLimit,
+      firstGroups: _.first(groups, groupsLimit),
+      moreGroupsCount: groups.length - groupsLimit
+    });
+  }
 });
+
+
index 24878864d309901cfd4c6b951fa0ab09114d12d2..695bf2ac034422cd4a228e67bec5d08fe0357f6a 100644 (file)
@@ -1,11 +1,10 @@
-define([
-  './list-item-view',
-  './templates'
-], function (ListItemView) {
-
-  return Marionette.CollectionView.extend({
-    tagName: 'ul',
-    childView: ListItemView
-  });
+import Marionette from 'backbone.marionette';
+import ListItemView from './list-item-view';
+import './templates';
 
+export default Marionette.CollectionView.extend({
+  tagName: 'ul',
+  childView: ListItemView
 });
+
+
index 5129bf5a2536d7ddb19d4270a19483493f9644a6..114f0971e71aacc3876791653885a719c358c0a1 100644 (file)
@@ -1,49 +1,49 @@
-define([
-  './templates'
-], function () {
-
-  return Marionette.ItemView.extend({
-    template: Templates['users-search'],
-
-    events: {
-      'submit #users-search-form': 'onFormSubmit',
-      'search #users-search-query': 'debouncedOnKeyUp',
-      'keyup #users-search-query': 'debouncedOnKeyUp'
-    },
-
-    initialize: function () {
-      this._bufferedValue = null;
-      this.debouncedOnKeyUp = _.debounce(this.onKeyUp, 400);
-    },
-
-    onRender: function () {
-      this.delegateEvents();
-    },
-
-    onFormSubmit: function (e) {
-      e.preventDefault();
-      this.debouncedOnKeyUp();
-    },
-
-    onKeyUp: function () {
-      var q = this.getQuery();
-      if (q === this._bufferedValue) {
-        return;
-      }
-      this._bufferedValue = this.getQuery();
-      if (this.searchRequest != null) {
-        this.searchRequest.abort();
-      }
-      this.searchRequest = this.search(q);
-    },
-
-    getQuery: function () {
-      return this.$('#users-search-query').val();
-    },
-
-    search: function (q) {
-      return this.collection.fetch({ reset: true, data: { q: q } });
+import _ from 'underscore';
+import Marionette from 'backbone.marionette';
+import './templates';
+
+export default Marionette.ItemView.extend({
+  template: Templates['users-search'],
+
+  events: {
+    'submit #users-search-form': 'onFormSubmit',
+    'search #users-search-query': 'debouncedOnKeyUp',
+    'keyup #users-search-query': 'debouncedOnKeyUp'
+  },
+
+  initialize: function () {
+    this._bufferedValue = null;
+    this.debouncedOnKeyUp = _.debounce(this.onKeyUp, 400);
+  },
+
+  onRender: function () {
+    this.delegateEvents();
+  },
+
+  onFormSubmit: function (e) {
+    e.preventDefault();
+    this.debouncedOnKeyUp();
+  },
+
+  onKeyUp: function () {
+    var q = this.getQuery();
+    if (q === this._bufferedValue) {
+      return;
     }
-  });
+    this._bufferedValue = this.getQuery();
+    if (this.searchRequest != null) {
+      this.searchRequest.abort();
+    }
+    this.searchRequest = this.search(q);
+  },
+
+  getQuery: function () {
+    return this.$('#users-search-query').val();
+  },
 
+  search: function (q) {
+    return this.collection.fetch({ reset: true, data: { q: q } });
+  }
 });
+
+
index b276b79ba42c9243adf409da0ff5dbacc38b45b4..42a83c9fdd61c686615522ab11238a26a0728731 100644 (file)
@@ -1,30 +1,28 @@
-define([
-  './form-view'
-], function (FormView) {
+import FormView from './form-view';
 
-  return FormView.extend({
-
-    sendRequest: function () {
-      var that = this;
-      this.model.set({
-        name: this.$('#create-user-name').val(),
-        email: this.$('#create-user-email').val(),
-        scmAccounts: this.getScmAccounts()
-      });
-      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({
+      name: this.$('#create-user-name').val(),
+      email: this.$('#create-user-email').val(),
+      scmAccounts: this.getScmAccounts()
+    });
+    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);
+    });
+  }
 });
+
+
index 746ffe8bdd728534c084099ef4446f024c012e87..3c041571ddb572fe6bb6ff73e3ecd20d8ee6c8c5 100644 (file)
@@ -1,71 +1,72 @@
-define(function () {
+import _ from 'underscore';
+import Backbone from 'backbone';
 
-  return Backbone.Model.extend({
-    idAttribute: 'login',
+export default Backbone.Model.extend({
+  idAttribute: 'login',
 
-    urlRoot: function () {
-      return baseUrl + '/api/users';
-    },
+  urlRoot: function () {
+    return baseUrl + '/api/users';
+  },
 
-    defaults: function () {
-      return {
-        groups: [],
-        scmAccounts: []
-      };
-    },
+  defaults: function () {
+    return {
+      groups: [],
+      scmAccounts: []
+    };
+  },
 
-    toQuery: function () {
-      var q = this.toJSON();
-      _.each(q, function (value, key) {
-        if (_.isArray(value)) {
-          q[key] = value.join(',');
-        }
-      });
-      return q;
-    },
-
-    isNew: function() {
-      // server never sends a password
-      return this.has('password');
-    },
-
-    sync: function (method, model, options) {
-      var opts = options || {};
-      if (method === 'create') {
-        _.defaults(opts, {
-          url: this.urlRoot() + '/create',
-          type: 'POST',
-          data: _.pick(model.toQuery(), 'login', 'name', 'email', 'password', 'scmAccounts')
-        });
-      }
-      if (method === 'update') {
-        _.defaults(opts, {
-          url: this.urlRoot() + '/update',
-          type: 'POST',
-          data: _.pick(model.toQuery(), 'login', 'name', 'email', 'scmAccounts')
-        });
+  toQuery: function () {
+    var q = this.toJSON();
+    _.each(q, function (value, key) {
+      if (_.isArray(value)) {
+        q[key] = value.join(',');
       }
-      if (method === 'delete') {
-        _.defaults(opts, {
-          url: this.urlRoot() + '/deactivate',
-          type: 'POST',
-          data: { login: this.id }
-        });
-      }
-      return Backbone.ajax(opts);
-    },
+    });
+    return q;
+  },
+
+  isNew: function () {
+    // server never sends a password
+    return this.has('password');
+  },
 
-    changePassword: function (password, options) {
-      var opts = _.defaults(options || {}, {
-        url: this.urlRoot() + '/change_password',
+  sync: function (method, model, options) {
+    var opts = options || {};
+    if (method === 'create') {
+      _.defaults(opts, {
+        url: this.urlRoot() + '/create',
         type: 'POST',
-        data: {
-          login: this.id,
-          password: password
-        }
+        data: _.pick(model.toQuery(), 'login', 'name', 'email', 'password', 'scmAccounts')
       });
-      return Backbone.ajax(opts);
     }
-  });
+    if (method === 'update') {
+      _.defaults(opts, {
+        url: this.urlRoot() + '/update',
+        type: 'POST',
+        data: _.pick(model.toQuery(), 'login', 'name', 'email', 'scmAccounts')
+      });
+    }
+    if (method === 'delete') {
+      _.defaults(opts, {
+        url: this.urlRoot() + '/deactivate',
+        type: 'POST',
+        data: { login: this.id }
+      });
+    }
+    return Backbone.ajax(opts);
+  },
 
+  changePassword: function (password, options) {
+    var opts = _.defaults(options || {}, {
+      url: this.urlRoot() + '/change_password',
+      type: 'POST',
+      data: {
+        login: this.id,
+        password: password
+      }
+    });
+    return Backbone.ajax(opts);
+  }
 });
+
+
index 9c45979a9fefce4a35e863dee2f4dc195ba733d3..a123212ace9080c6172f183a79667d6e8143578b 100644 (file)
@@ -1,40 +1,39 @@
-define([
-  './user'
-], function (User) {
+import Backbone from 'backbone';
+import User from './user';
+
+export default Backbone.Collection.extend({
+  model: User,
+
+  url: function () {
+    return baseUrl + '/api/users/search';
+  },
+
+  parse: function (r) {
+    this.total = +r.total;
+    this.p = +r.p;
+    this.ps = +r.ps;
+    return r.users;
+  },
+
+  fetch: function (options) {
+    var d = (options && options.data) || {};
+    this.q = d.q;
+    return this._super(options);
+  },
+
+  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;
+  }
 
-  return Backbone.Collection.extend({
-    model: User,
-
-    url: function () {
-      return baseUrl + '/api/users/search';
-    },
-
-    parse: function (r) {
-      this.total = +r.total;
-      this.p = +r.p;
-      this.ps = +r.ps;
-      return r.users;
-    },
-
-    fetch: function (options) {
-      var d = (options && options.data) || {};
-      this.q = d.q;
-      return this._super(options);
-    },
-
-    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;
-    }
+});
 
-  });
 
-});