'use strict';

/**
 * Licensed Materials - Property of IBM
 * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp.  2014, 2018
 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
 */
define(['../../../lib/@waca/core-client/js/core-client/ui/dialogs/BaseDialog'], function (BaseDialog) {

	var Dialog = null;
	Dialog = BaseDialog.extend({

		_buttons: ['ok', 'cancel'],
		_okCallback: null,
		_cancelCallback: null,

		init: function init(options) {
			this.title = options.title;
			this.view = new options.viewClass(options.viewOptions);
			this._okCallback = options.okCallback;
			this._cancelCallback = options.cancelCallback;
			Dialog.inherited('init', this, arguments);
		},

		destroy: function destroy() {
			if (this.view) {
				this.view.remove();
			}

			Dialog.inherited('destroy', this, arguments);
		},
		renderContent: function renderContent(n) {
			this.view.render();
			n.append(this.view.$el);
			return n;
		},

		renderTitle: function renderTitle(n) {
			n.text(this.title);
			return n;
		},

		ok: function ok() {
			Dialog.inherited('ok', this, arguments);
			if (this._okCallback) {
				return this._okCallback();
			}
		},

		cancel: function cancel() {
			Dialog.inherited('cancel', this, arguments);
			if (this._cancelCallback) {
				return this._cancelCallback();
			}
		},

		open: function open() {
			Dialog.inherited('open', this, arguments);
			if (this.view.onOpen) {
				this.view.onOpen();
			}
		}

	});

	return Dialog;
});
//# sourceMappingURL=GenericViewDialog.js.map