diff --git a/omega-web/src/coffee/omega_decoration.coffee b/omega-web/src/coffee/omega_decoration.coffee index e316b85..26646c9 100644 --- a/omega-web/src/coffee/omega_decoration.coffee +++ b/omega-web/src/coffee/omega_decoration.coffee @@ -1,10 +1,24 @@ +orderForType = + 'FixedProfile': -2000 + 'PacProfile': -1000 + 'SwitchProfile': 2000 + 'RuleListProfile': 3000 + angular.module('omegaDecoration', []).value('profileIcons', { - 'DirectProfile': 'glyphicon-transfer', - 'SystemProfile': 'glyphicon-off', - 'AutoDetectProfile': 'glyphicon-file', - 'FixedProfile': 'glyphicon-globe', - 'PacProfile': 'glyphicon-file', - 'RulelistProfile': 'glyphicon-list', - 'SwitchProfile': 'glyphicon-retweet', - 'RuleListProfile': 'glyphicon-list', -}) + 'DirectProfile': 'glyphicon-transfer' + 'SystemProfile': 'glyphicon-off' + 'AutoDetectProfile': 'glyphicon-file' + 'FixedProfile': 'glyphicon-globe' + 'PacProfile': 'glyphicon-file' + 'RuleListProfile': 'glyphicon-list' + 'SwitchProfile': 'glyphicon-retweet' +}).constant('profileOrder', (a, b) -> + diff = (orderForType[a.profileType] | 0) - (orderForType[b.profileType] | 0) + return diff if diff != 0 + if a.name == b.name + 0 + else if a.name < b.name + -1 + else + 1 +) diff --git a/omega-web/src/coffee/popup.coffee b/omega-web/src/coffee/popup.coffee index 1d7509f..76351e8 100644 --- a/omega-web/src/coffee/popup.coffee +++ b/omega-web/src/coffee/popup.coffee @@ -6,7 +6,7 @@ module.filter 'dispName', (omegaTarget) -> (name) -> omegaTarget.getMessage('profile_' + name) || name module.controller 'PopupCtrl', ($scope, $window, $q, omegaTarget, - profileIcons) -> + profileIcons, profileOrder) -> refreshOnProfileChange = false refresh = -> @@ -73,6 +73,7 @@ module.controller 'PopupCtrl', ($scope, $window, $q, omegaTarget, $scope.builtinProfiles.push(profile) else $scope.customProfiles.push(profile) + $scope.customProfiles.sort(profileOrder) $scope.currentProfile = availableProfiles['+' + currentProfileName] $scope.currentProfileName = currentProfileName $scope.isSystemProfile = isSystemProfile diff --git a/omega-web/src/omega/controllers/pac_profile.coffee b/omega-web/src/omega/controllers/pac_profile.coffee index f1cd60d..ece0b89 100644 --- a/omega-web/src/omega/controllers/pac_profile.coffee +++ b/omega-web/src/omega/controllers/pac_profile.coffee @@ -10,7 +10,6 @@ angular.module('omega').controller 'PacProfileCtrl', ($scope) -> $scope.isFileUrl = OmegaPac.Profiles.isFileUrl $scope.pacUrlCtrl = {ctrl: null} - $scope.$watch 'pacUrlCtrl.ctrl', console.log.bind(console) set = OmegaPac.Profiles.referencedBySet($scope.profile, $scope.options) $scope.referenced = Object.keys(set).length > 0 diff --git a/omega-web/src/omega/directives.coffee b/omega-web/src/omega/directives.coffee index 30cdf7a..9754d9d 100644 --- a/omega-web/src/omega/directives.coffee +++ b/omega-web/src/omega/directives.coffee @@ -6,7 +6,7 @@ angular.module('omega').directive 'inputGroupClear', ($timeout) -> 'type': '@type' 'ngPattern': '=?ngPattern' 'placeholder': '@placeholder' - 'controller': '=controller' + 'controller': '=?controller' link: (scope, element, attrs) -> scope.catchAll = new RegExp('') $timeout -> diff --git a/omega-web/src/omega/filters.coffee b/omega-web/src/omega/filters.coffee index 3934a8c..1caa113 100644 --- a/omega-web/src/omega/filters.coffee +++ b/omega-web/src/omega/filters.coffee @@ -1,4 +1,4 @@ -angular.module('omega').filter 'profiles', (builtinProfiles) -> +angular.module('omega').filter 'profiles', (builtinProfiles, profileOrder) -> charCodePlus = '+'.charCodeAt(0) builtinProfileList = (profile for _, profile of builtinProfiles) (options, filter) -> @@ -12,6 +12,8 @@ angular.module('omega').filter 'profiles', (builtinProfiles) -> result = OmegaPac.Profiles.validResultProfilesFor(filter, options) if filter == 'all' result = result.concat builtinProfileList + if filter == 'sorted' + result.sort profileOrder result angular.module('omega').filter 'tr', (omegaTarget) -> omegaTarget.getMessage diff --git a/omega-web/src/options.jade b/omega-web/src/options.jade index 34c7f5a..1d5ebc4 100644 --- a/omega-web/src/options.jade +++ b/omega-web/src/options.jade @@ -28,7 +28,7 @@ html(lang='en' ng-controller='MasterCtrl' ng-csp) | {{'options_tab_importExport' | tr}} li.divider li.nav-header {{'options_navHeader_profiles' | tr}} - li(ng-repeat='profile in options | profiles' ui-sref-active='active') + li(ng-repeat='profile in options | profiles:"sorted"' ui-sref-active='active') a(ui-sref='profile({name: profile.name})') span.glyphicon(class='{{profileIcons[profile.profileType]}}' ng-style='{color: profile.color}') diff --git a/omega-web/src/partials/profile_rule_list.jade b/omega-web/src/partials/profile_rule_list.jade index f552117..f0f4bb7 100644 --- a/omega-web/src/partials/profile_rule_list.jade +++ b/omega-web/src/partials/profile_rule_list.jade @@ -17,7 +17,7 @@ div(ng-controller='RuleListProfileCtrl') | {{'rulelistFormat_' + format | tr}} section.settings-group h3 {{'options_group_ruleListUrl' | tr}} - .width-limit(input-group-clear type='url' model='profile.sourceUrl') + .width-limit(input-group-clear type='url' model='profile.sourceUrl' ng-if='profile') p.help-block {{'options_ruleListUrlHelp' | tr}} section.settings-group h3 {{'options_group_ruleListText' | tr}}