<commit_before>module = angular.module('impac.components.widgets-common.top-buttons', [])
module.controller('CommonTopButtonsCtrl', ($scope, $rootScope, $log, ImpacWidgetsSvc, ImpacAssets) ->

  w = $scope.parentWidget

  $scope.showCloseActive = false
  $scope.showConfirmDelete = false
  $scope.isDeletePopoverLoading = false

  w.isEditMode = false

  $scope.deleteWidget = ->
    $scope.isDeletePopoverLoading = true
    ImpacWidgetsSvc.delete(w).then(
      (success) ->
        return true
      (errors) ->
        w.errors = Utilities.processRailsError(errors)
    ).finally(
      ->
        $scope.isDeletePopoverLoading = false
    )

  $scope.refreshWidget = ->
    w.isLoading = true
    ImpacWidgetsSvc.show(w).finally(-> w.isLoading=false)

  $scope.toggleEditMode = ->
    if !w.isLoading
      if w.isEditMode
        # = press 'Cancel' button
        w.isEditMode = false
        ImpacWidgetsSvc.initWidgetSettings(w)
      else
        # Otherwise, we pass in edit mode
        w.isEditMode = true
)

module.directive('commonTopButtons', ($templateCache) ->
  return {
    restrict: 'A',
    scope: {
      parentWidget: '='
    },
    template: $templateCache.get('widgets-common/top-buttons.tmpl.html'),
    controller: 'CommonTopButtonsCtrl'
  }
)<commit_msg>reestablish connec! cache clear on widget refresh<commit_after>module = angular.module('impac.components.widgets-common.top-buttons', [])
module.controller('CommonTopButtonsCtrl', ($scope, $rootScope, $log, ImpacWidgetsSvc, ImpacAssets) ->

  w = $scope.parentWidget

  $scope.showCloseActive = false
  $scope.showConfirmDelete = false
  $scope.isDeletePopoverLoading = false

  w.isEditMode = false

  $scope.deleteWidget = ->
    $scope.isDeletePopoverLoading = true
    ImpacWidgetsSvc.delete(w).then(
      (success) ->
        return true
      (errors) ->
        w.errors = Utilities.processRailsError(errors)
    ).finally(
      ->
        $scope.isDeletePopoverLoading = false
    )

  $scope.refreshWidget = ->
    w.isLoading = true
    ImpacWidgetsSvc.show(w, true).finally(-> w.isLoading=false)

  $scope.toggleEditMode = ->
    if !w.isLoading
      if w.isEditMode
        # = press 'Cancel' button
        w.isEditMode = false
        ImpacWidgetsSvc.initWidgetSettings(w)
      else
        # Otherwise, we pass in edit mode
        w.isEditMode = true
)

module.directive('commonTopButtons', ($templateCache) ->
  return {
    restrict: 'A',
    scope: {
      parentWidget: '='
    },
    template: $templateCache.get('widgets-common/top-buttons.tmpl.html'),
    controller: 'CommonTopButtonsCtrl'
  }
)
{'fraction_non_alphanumeric': 0.1251920122887865, 'fraction_numerical': 0.0, 'mean_word_length': 2.9831804281345566, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5630067', 'n_tokens_mistral': 845, 'n_tokens_neox': 834, 'n_words': 141}