UNPKG

owl-bt

Version:

owl-bt is editor for Behavior trees. It has been inspired by Unreal engine behavior trees in a way, that it supports special node items like decorators and services. This makes trees smaller and much more readable.

35 lines (31 loc) 982 B
(function () { 'use strict'; class SaveTreeAction { constructor(ActionExecutor, TreeStore, AlertList) { this._ActionExecutor = ActionExecutor; this._TreeStore = TreeStore; this._AlertList = AlertList; } exec() { let _this = this; this._ActionExecutor.exec({ exec: () => { if (_this._TreeStore.allItemPropertiesAreValid() || confirm('Tree contains items with invalid properties (check red items). Do you really want to save it?')) { return _this._TreeStore.save() .then(() => _this._AlertList.addInfo('Done', { autoHide: true })) .catch(err => { if (err.data) { return Promise.reject(err.data) } else { return Promise.reject(err) } }); } } }); } } angular.module('editorApp') .service('SaveTreeAction', SaveTreeAction); })();