<commit_before>FolderDeleteButtonView = OrchestraView.extend(
  events:
    'click i.ajax-folder-delete': 'clickDeleteFolder'

  initialize: (options) ->
    @options = @reduceOption(options, [
      'medias'
    ])
    @loadTemplates [
      "OpenOrchestraMediaAdminBundle:BackOffice:Underscore/widgetFolderDeleteButton"
    ]
    return

  render: ->
    @setElement @renderTemplate('OpenOrchestraMediaAdminBundle:BackOffice:Underscore/widgetFolderDeleteButton')
    addCustomJarvisWidget(@$el)
    return

  clickDeleteFolder: (event) ->
    event.preventDefault()
    smartConfirm(
      'fa-trash-o',
      $('.folder-delete').data('title'),
      $('.folder-delete').data('text'),
      callBackParams:
        folderDeleteButtonView: @
      yesCallback: (params) ->
        params.folderDeleteButtonView.deleteFolder()
    )

  deleteFolder: ->
    if @options.medias.get('parent_id') == undefined
      redirectUrl = appRouter.generateUrl('showHome')
    else
      redirectUrl = appRouter.generateUrl('listFolder', appRouter.addParametersToRoute(
        'folderId':  @options.medias.get('parent_id')
      ))
    $.ajax
      url:  @options.medias.get('links')._self_delete
      method: 'DELETE'
      success: ->
        Backbone.history.loadUrl(redirectUrl)
        displayMenu(redirectUrl)
)<commit_msg>Redirect to dashboard on root folder delete<commit_after>FolderDeleteButtonView = OrchestraView.extend(
  events:
    'click i.ajax-folder-delete': 'clickDeleteFolder'

  initialize: (options) ->
    @options = @reduceOption(options, [
      'medias'
    ])
    @loadTemplates [
      "OpenOrchestraMediaAdminBundle:BackOffice:Underscore/widgetFolderDeleteButton"
    ]
    return

  render: ->
    @setElement @renderTemplate('OpenOrchestraMediaAdminBundle:BackOffice:Underscore/widgetFolderDeleteButton')
    addCustomJarvisWidget(@$el)
    return

  clickDeleteFolder: (event) ->
    event.preventDefault()
    smartConfirm(
      'fa-trash-o',
      $('.folder-delete').data('title'),
      $('.folder-delete').data('text'),
      callBackParams:
        folderDeleteButtonView: @
      yesCallback: (params) ->
        params.folderDeleteButtonView.deleteFolder()
    )

  deleteFolder: ->
    if @options.medias.get('parent_id') == undefined
      redirectUrl = appRouter.generateUrl('showDashboard')
    else
      redirectUrl = appRouter.generateUrl('listFolder', appRouter.addParametersToRoute(
        'folderId':  @options.medias.get('parent_id')
      ))
    $.ajax
      url:  @options.medias.get('links')._self_delete
      method: 'DELETE'
      success: ->
        appRouter.navigate redirectUrl,
            trigger: true
        displayMenu redirectUrl
)
{'fraction_non_alphanumeric': 0.12453531598513011, 'fraction_numerical': 0.0, 'mean_word_length': 3.3403225806451613, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '3318344', 'n_tokens_mistral': 793, 'n_tokens_neox': 785, 'n_words': 112}