Disallow names starting with underscore when saving externalProfile.

This commit is contained in:
FelisCatus 2014-10-15 10:11:33 +08:00
parent abd362f424
commit 0be33856e2
2 changed files with 5 additions and 2 deletions

View File

@ -50,7 +50,10 @@ module.controller 'PopupCtrl', ($scope, $window, $q, omegaTarget,
omegaTarget.addCondition(condition, profileName).then ->
refresh()
$scope.notConflict = (name) -> not $scope.availableProfiles?['+' + name]
$scope.validateProfileName =
conflict: '!$value || !availableProfiles["+" + $value]'
hidden: '!$value || $value[0] != "_"'
$scope.saveExternal = ->
$scope.nameExternal.open = false
name = $scope.externalProfile.name

View File

@ -37,7 +37,7 @@ html(lang='en' ng-app='omegaPopup' ng-controller='PopupCtrl' ng-csp)
= ' '
span(ng-show='!nameExternal.open') {{'popup_externalProfile' | tr}}
input.form-control(ng-show='!!nameExternal.open' ng-model='externalProfile.name' ng-blur='nameExternalForm.submit()'
placeholder='{{"popup_externalProfileName" | tr}}' ui-validate='{conflict: "notConflict($value)"}')
placeholder='{{"popup_externalProfileName" | tr}}' ui-validate='validateProfileName')
li.divider
li.profile(ng-repeat='profile in customProfiles' ng-class='{active: isActive(profile.name), "bg-info": isEffective(profile.name)}')
a(ng-click='applyProfile(profile)')