0
角度uiを使用してリスト間で項目をドラッグアンドドロップすることができます。私ができるようにしたいのは、特定のドラッグ・ドロップ条件の下で確認ダイアログが表示され、ユーザーがダイアログをキャンセルした場合にリストを元の状態に戻すことです。更新イベント内でui.item.sortable.cancel()
メソッドを使用できますが、約束を返すモーダルを使用すると、キャンセル時にリストを元に戻す方法がわかりません。私のコントローラには、以下のものがあります(modalServiceはブートストラップ$ uibModalです):角度uiソート可能なコールバック内の確認ダイアログを待つ方法
$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
アドバイスをいただければ幸いです。