Wire up TC widget to controller methods.

This commit is contained in:
Paulo Reis 2017-06-28 15:00:32 +01:00
parent dc2085c6e1
commit 1fa7338baf
3 changed files with 12 additions and 13 deletions

View file

@ -56,7 +56,7 @@
span.rp-tc-state-item-name.rp-tc-state-item-name-everyone Everyone
review-panel-toggle(
ng-model="reviewPanel.trackChangesOnForEveryone"
on-toggle="toggleTrackChangesForEveryone"
on-toggle="toggleTrackChangesForEveryone(isOn);"
disabled="!project.features.trackChanges"
on-disabled-click="openTrackChangesUpgradeModal"
)
@ -69,8 +69,7 @@
//- method, and it's not clear how.
review-panel-toggle(
ng-model="reviewPanel.trackChangesState[user.id]"
disabled="!project.features.trackChanges"
on-disabled-click="openTrackChangesUpgradeModal"
on-toggle="toggleTrackChangesForUser(isOn, user.id);"
)
li.rp-tc-state-item(ng-repeat="member in project.members")
span.rp-tc-state-item-name(
@ -79,8 +78,7 @@
//- {{member._id}}
review-panel-toggle(
ng-model="reviewPanel.trackChangesState[member._id]"
disabled="!project.features.trackChanges"
on-disabled-click="openTrackChangesUpgradeModal"
on-toggle="toggleTrackChangesForUser(isOn, member._id);"
)
//- span.review-panel-toolbar-label(ng-if="permissions.write")

View file

@ -610,14 +610,15 @@ define [
$scope.toggleTrackChangesForEveryone = (onForEveryone) ->
console.log "[toggleTrackChangesForEveryone]", onForEveryone
setTrackChangesState(onForEveryone)
window.toggleTrackChangesForUser = # DEBUG LINE
$scope.toggleTrackChangesForUser = (user_id) ->
$scope.toggleTrackChangesForUser = (onForUser, userId) ->
console.log "[toggleTrackChangesForUser]", onForUser, userId
state = $scope.reviewPanel.trackChangesState
if state[user_id]?
delete state[user_id]
else
state[user_id] = true
state[userId] = onForUser
if state[user_id] == false
delete state[userId]
setTrackChangesState(state)
ide.socket.on "toggle-track-changes", (state) ->

View file

@ -4,7 +4,7 @@ define [
App.directive "reviewPanelToggle", () ->
restrict: "E"
scope:
onToggle: '='
onToggle: '&'
ngModel: '='
disabled: '=?'
onDisabledClick: '=?'
@ -12,7 +12,7 @@ define [
if !scope.disabled?
scope.disabled = false
scope.onChange = (args...) ->
scope.onToggle(scope.localModel)
scope.onToggle({ isOn: scope.localModel })
scope.handleClick = () ->
if scope.disabled
scope.onDisabledClick()