mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-01-22 15:08:12 -05:00
Add watcher on the calling scope in watchAndUpdateRevision. Fix #79.
This commit is contained in:
parent
a3df567b4d
commit
1a68f4c60d
@ -238,7 +238,6 @@ angular.module('omega').controller 'MasterCtrl', ($scope, $rootScope, $window,
|
||||
|
||||
onOptionChange = (options, oldOptions) ->
|
||||
return if options == oldOptions or not oldOptions?
|
||||
plainOptions = angular.fromJson(angular.toJson(options))
|
||||
$rootScope.optionsDirty = true
|
||||
$rootScope.$watch 'options', onOptionChange, true
|
||||
|
||||
|
@ -70,6 +70,19 @@ angular.module('omega').controller 'ProfileCtrl', ($scope, $stateParams,
|
||||
break
|
||||
$state.go('ui')
|
||||
|
||||
# The watcher should be applied on the calling scope.
|
||||
# coffeelint: disable=missing_fat_arrows
|
||||
$scope.watchAndUpdateRevision = (expression) ->
|
||||
revisionChanged = false
|
||||
onChange = (profile, oldProfile) ->
|
||||
return profile if profile == oldProfile or not profile or not oldProfile
|
||||
if revisionChanged and profile.revision != oldProfile.revision
|
||||
revisionChanged = false
|
||||
else
|
||||
OmegaPac.Profiles.updateRevision(profile)
|
||||
revisionChanged = true
|
||||
this.$watch expression, onChange, true
|
||||
|
||||
unwatch = $scope.$watch (-> $scope.options?['+' + name]), (profile) ->
|
||||
if not profile
|
||||
if $scope.options
|
||||
@ -92,15 +105,4 @@ angular.module('omega').controller 'ProfileCtrl', ($scope, $stateParams,
|
||||
$scope.profileTemplate = 'partials/' + templ
|
||||
$scope.scriptable = true
|
||||
|
||||
$scope.watchAndUpdateRevision = (expression) ->
|
||||
revisionChanged = false
|
||||
onChange = (profile, oldProfile) ->
|
||||
return profile if profile == oldProfile or not profile or not oldProfile
|
||||
if revisionChanged and profile.revision != oldProfile.revision
|
||||
revisionChanged = false
|
||||
else
|
||||
OmegaPac.Profiles.updateRevision(profile)
|
||||
revisionChanged = true
|
||||
$scope.$watch expression, onChange, true
|
||||
|
||||
$scope.watchAndUpdateRevision 'profile'
|
||||
|
Loading…
Reference in New Issue
Block a user