mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-02-02 02:58:13 -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', {
|
angular.module('omegaDecoration', []).value('profileIcons', {
|
||||||
'DirectProfile': 'glyphicon-transfer',
|
'DirectProfile': 'glyphicon-transfer'
|
||||||
'SystemProfile': 'glyphicon-off',
|
'SystemProfile': 'glyphicon-off'
|
||||||
'AutoDetectProfile': 'glyphicon-file',
|
'AutoDetectProfile': 'glyphicon-file'
|
||||||
'FixedProfile': 'glyphicon-globe',
|
'FixedProfile': 'glyphicon-globe'
|
||||||
'PacProfile': 'glyphicon-file',
|
'PacProfile': 'glyphicon-file'
|
||||||
'RulelistProfile': 'glyphicon-list',
|
'RuleListProfile': 'glyphicon-list'
|
||||||
'SwitchProfile': 'glyphicon-retweet',
|
'SwitchProfile': 'glyphicon-retweet'
|
||||||
'RuleListProfile': 'glyphicon-list',
|
}).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
|
(name) -> omegaTarget.getMessage('profile_' + name) || name
|
||||||
|
|
||||||
module.controller 'PopupCtrl', ($scope, $window, $q, omegaTarget,
|
module.controller 'PopupCtrl', ($scope, $window, $q, omegaTarget,
|
||||||
profileIcons) ->
|
profileIcons, profileOrder) ->
|
||||||
|
|
||||||
refreshOnProfileChange = false
|
refreshOnProfileChange = false
|
||||||
refresh = ->
|
refresh = ->
|
||||||
@ -73,6 +73,7 @@ module.controller 'PopupCtrl', ($scope, $window, $q, omegaTarget,
|
|||||||
$scope.builtinProfiles.push(profile)
|
$scope.builtinProfiles.push(profile)
|
||||||
else
|
else
|
||||||
$scope.customProfiles.push(profile)
|
$scope.customProfiles.push(profile)
|
||||||
|
$scope.customProfiles.sort(profileOrder)
|
||||||
$scope.currentProfile = availableProfiles['+' + currentProfileName]
|
$scope.currentProfile = availableProfiles['+' + currentProfileName]
|
||||||
$scope.currentProfileName = currentProfileName
|
$scope.currentProfileName = currentProfileName
|
||||||
$scope.isSystemProfile = isSystemProfile
|
$scope.isSystemProfile = isSystemProfile
|
||||||
|
@ -10,7 +10,6 @@ angular.module('omega').controller 'PacProfileCtrl', ($scope) ->
|
|||||||
|
|
||||||
$scope.isFileUrl = OmegaPac.Profiles.isFileUrl
|
$scope.isFileUrl = OmegaPac.Profiles.isFileUrl
|
||||||
$scope.pacUrlCtrl = {ctrl: null}
|
$scope.pacUrlCtrl = {ctrl: null}
|
||||||
$scope.$watch 'pacUrlCtrl.ctrl', console.log.bind(console)
|
|
||||||
|
|
||||||
set = OmegaPac.Profiles.referencedBySet($scope.profile, $scope.options)
|
set = OmegaPac.Profiles.referencedBySet($scope.profile, $scope.options)
|
||||||
$scope.referenced = Object.keys(set).length > 0
|
$scope.referenced = Object.keys(set).length > 0
|
||||||
|
@ -6,7 +6,7 @@ angular.module('omega').directive 'inputGroupClear', ($timeout) ->
|
|||||||
'type': '@type'
|
'type': '@type'
|
||||||
'ngPattern': '=?ngPattern'
|
'ngPattern': '=?ngPattern'
|
||||||
'placeholder': '@placeholder'
|
'placeholder': '@placeholder'
|
||||||
'controller': '=controller'
|
'controller': '=?controller'
|
||||||
link: (scope, element, attrs) ->
|
link: (scope, element, attrs) ->
|
||||||
scope.catchAll = new RegExp('')
|
scope.catchAll = new RegExp('')
|
||||||
$timeout ->
|
$timeout ->
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
angular.module('omega').filter 'profiles', (builtinProfiles) ->
|
angular.module('omega').filter 'profiles', (builtinProfiles, profileOrder) ->
|
||||||
charCodePlus = '+'.charCodeAt(0)
|
charCodePlus = '+'.charCodeAt(0)
|
||||||
builtinProfileList = (profile for _, profile of builtinProfiles)
|
builtinProfileList = (profile for _, profile of builtinProfiles)
|
||||||
(options, filter) ->
|
(options, filter) ->
|
||||||
@ -12,6 +12,8 @@ angular.module('omega').filter 'profiles', (builtinProfiles) ->
|
|||||||
result = OmegaPac.Profiles.validResultProfilesFor(filter, options)
|
result = OmegaPac.Profiles.validResultProfilesFor(filter, options)
|
||||||
if filter == 'all'
|
if filter == 'all'
|
||||||
result = result.concat builtinProfileList
|
result = result.concat builtinProfileList
|
||||||
|
if filter == 'sorted'
|
||||||
|
result.sort profileOrder
|
||||||
result
|
result
|
||||||
|
|
||||||
angular.module('omega').filter 'tr', (omegaTarget) -> omegaTarget.getMessage
|
angular.module('omega').filter 'tr', (omegaTarget) -> omegaTarget.getMessage
|
||||||
|
@ -28,7 +28,7 @@ html(lang='en' ng-controller='MasterCtrl' ng-csp)
|
|||||||
| {{'options_tab_importExport' | tr}}
|
| {{'options_tab_importExport' | tr}}
|
||||||
li.divider
|
li.divider
|
||||||
li.nav-header {{'options_navHeader_profiles' | tr}}
|
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})')
|
a(ui-sref='profile({name: profile.name})')
|
||||||
span.glyphicon(class='{{profileIcons[profile.profileType]}}'
|
span.glyphicon(class='{{profileIcons[profile.profileType]}}'
|
||||||
ng-style='{color: profile.color}')
|
ng-style='{color: profile.color}')
|
||||||
|
@ -17,7 +17,7 @@ div(ng-controller='RuleListProfileCtrl')
|
|||||||
| {{'rulelistFormat_' + format | tr}}
|
| {{'rulelistFormat_' + format | tr}}
|
||||||
section.settings-group
|
section.settings-group
|
||||||
h3 {{'options_group_ruleListUrl' | tr}}
|
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}}
|
p.help-block {{'options_ruleListUrlHelp' | tr}}
|
||||||
section.settings-group
|
section.settings-group
|
||||||
h3 {{'options_group_ruleListText' | tr}}
|
h3 {{'options_group_ruleListText' | tr}}
|
||||||
|
Loading…
Reference in New Issue
Block a user