                 us = $model.$modelValue.clone()
                 us.team_requirement = not us.team_requirement
                 $model.$setViewValue(us)
+                $loading.start($el.find('label'))
                 promise = $tgrepo.save($model.$modelValue)
                 promise.then ->
+                    $loading.finish($el.find('label'))
                     $rootscope.$broadcast("history:reload")
                 promise.then null, ->
+                    $loading.finish($el.find('label'))
                     $confirm.notify("error")
                     us.revert()
                     $model.$setViewValue(us)

                us = $model.$modelValue.clone()
                us.client_requirement = not us.client_requirement
                $model.$setViewValue(us)
                promise = $tgrepo.save($model.$modelValue)
                promise.then ->
                    $rootscope.$broadcast("history:reload")
                promise.then null, ->
                    $confirm.notify("error")
                    us.revert()
                    $model.$setViewValue(us)

    return {
        link: link
        restrict: "EA"
        require: "ngModel"
    }
module.directive("tgUsClientRequirementButton", ["$rootScope", "$tgRepo", "$tgConfirm", UsClientRequirementButtonDirective])

## User story team requirements button directive
#############################################################################

UsTeamRequirementButtonDirective = ($rootscope, $tgrepo, $confirm, $loading) ->
    template = _.template("""
      <label for="team-requirement" class="button button-gray team-requirement">Team requirement</label>
      <input type="checkbox" id="team-requirement" name="team-requirement"/>
