mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-01-22 15:08:12 -05:00
Sort profiles by type and then name in options and popup. See #32
This commit is contained in:
parent
c3b751a3fb
commit
98a8273fc0
@ -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
|
||||
)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 ->
|
||||
|
@ -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
|
||||
|
@ -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}')
|
||||
|
@ -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}}
|
||||
|
Loading…
Reference in New Issue
Block a user