sap.ui.define([
	"sap/ui/core/mvc/Controller",
	"sap/m/BusyDialog"
], function (Controller, BusyDialog) {
	"use strict";

	return Controller.extend("tim.exakta.AuxilioCreche.controller.Main", {
		onInit: function () {
			this.getOwnerComponent().getModel().attachRequestSent(function (oEvent) {
				if (!this._oBusyDialog || this._oBusyDialog.isDestroyed()) {
					this._oBusyDialog = new BusyDialog();
					this._oBusyDialog.open();
				}
			}, this);

			this.getOwnerComponent().getModel().attachRequestCompleted(function (oEvent) {
				if (this._oBusyDialog) {
					this._oBusyDialog.destroy();
				}
			}, this);
		}
	});
});