0

Listeler arasında öğeleri sürükleyip bırakmak için açısal olarak kullanılamıyorum. Yapmak istediğim şey (belirli sürükle/bırak koşulları altında) bir onaylama diyaloğuna sahiptir ve kullanıcı diyaloğu iptal ederse listeleri orijinal haline geri döndürür. Güncelleştirme olayının içinde ui.item.sortable.cancel() yöntemini kullanabilirim, ancak bir söz veren bir model kullanırsam, iptal edilen listelerin nasıl geri alınacağını anlayamıyorum. Herhangi bir tavsiye takdirAçısal iletişim kuralı içinde geri arama iletişim kutusu nasıl beklenir Geri arama geri çağırma

$scope.sortableOptions = 
     handle: ' > span > span > .task-drag-icon', 
     connectWith: ".task-subset" 
     placeholder: "sortable-placeholder", 
     forcePlaceholderSize: true, 
     update: (e, ui) -> 
      if ui.item.sortable.sourceModel == ui.item.sortable.droptargetModel #sort was within the same list 
      #some other logic here..... 
      else 
      droptarget_element = ui.item.sortable.droptarget 

      if droptarget_element.attr('ng-model') == "task.subTasks" 
       #need the user to confirm here if they really want to do this drag/drop 
       modalOptions = 
       closeButtonText: 'Cancel' 
       actionButtonText: 'Make SubTask' 
       headerText: 'Make SubTask?' 
       bodyText: 'This action will remove any existing task groups as it will become a child task. Is this OK?' 
       modalService.showModal({}, modalOptions).then (result) -> 
        console.log "accpted" 
       ,() -> 
        console.log "cancelled" 
        #need to call ui.item.sortable.cancel() here, but I cant because the update callback has finished already!!!! 

       console.log "finished - gets to here immediately as modalService is asyncronous" 

      return 

: İşte benim denetleyicisi ne var (modalService bir önyükleme $ uibModal olan).

cevap

0

Bazı büyük kesmeler olmadan çalışamadım, bunun yerine güncelleştirme geri bildirimi içinde cancel() yöntemini kullanmamayı bitirdim, ancak verileri uygun dizilerde geri döndürerek etikete nasıl döndüklerine geri döndüm Geri Çağırma, bazı değişkenleri atayarak şöyle olabilir:

$scope.sortableOptions = 
     handle: ' > span > span > .task-drag-icon', 
     connectWith: ".task-subset" 
     placeholder: "sortable-placeholder", 
     forcePlaceholderSize: true, 
     stop: (e, ui) -> 
      orig_index = ui.item.sortable.index 
      new_idex = ui.item.sortable.dropindex 
      sourceModel = ui.item.sortable.sourceModel 
      droptargetModel = ui.item.sortable.droptargetModel 
      model = ui.item.sortable.model 

      if sourceModel == droptargetModel #sort was within the same list 
      #some other logic here..... 
      else 
      droptarget_element = ui.item.sortable.droptarget 

      if droptarget_element.attr('ng-model') == "task.subTasks" 
       #need the user to confirm here if they really want to do this drag/drop 
       modalOptions = 
       closeButtonText: 'Cancel' 
       actionButtonText: 'Make SubTask' 
       headerText: 'Make SubTask?' 
       bodyText: 'This action will remove any existing task groups as it will become a child task. Is this OK?' 
       modalService.showModal({}, modalOptions).then (result) -> 
        console.log "accpted" 
       ,() -> 
        #put model back in orginal poisition 
        sourceModel.splice orig_index, 0, model 
        #remove from target array 
        droptargetModel.splice new_idex, 1 

      return