import { Component, ChangeDetectionStrategy, Input, Output, EventEmitter } from '@angular/core';
var AddToBundleDialogComponent = (function () {
    function AddToBundleDialogComponent() {
        this.hidden = false;
        this.errorMessage = null;
        this.close = new EventEmitter(false);
        this.cancel = new EventEmitter(false);
        this.addToBundle = new EventEmitter(false);
        //   @ViewChild(Dropdown)
        //   dropdown: Dropdown;
        this.selectedBundle = null;
    }
    AddToBundleDialogComponent.prototype.ngOnChanges = function (change) {
        if (change.bundleStores) {
            this.selectedBundle = change.bundleStores.currentValue[0];
        }
    };
    AddToBundleDialogComponent.prototype.setSelectedBundle = function (bundleId) {
        var _this = this;
        this.selectedBundle = {
            id: bundleId,
            name: bundleId
        };
        this.bundleStores.forEach(function (bundle) {
            if (bundle.id === bundleId) {
                _this.selectedBundle = bundle;
            }
        });
    };
    AddToBundleDialogComponent.prototype.focusDropDown = function () {
        // TODO: NG bring back this when rules gets in.
        // this.dropdown.focus();
    };
    return AddToBundleDialogComponent;
}());
export { AddToBundleDialogComponent };
AddToBundleDialogComponent.decorators = [
    { type: Component, args: [{
                changeDetection: ChangeDetectionStrategy.OnPush,
                selector: 'cw-add-to-bundle-dialog-component',
                template: "<cw-modal-dialog\n    [headerText]=\"'Add to Bundle'\"\n    [okButtonText]=\"'Add'\"\n    [hidden]=\"hidden\"\n    [okEnabled]=\"selectedBundle != null\"\n    [errorMessage]=\"errorMessage\"\n    width=\"25em\"\n    height=\"auto\"\n    (ok)=\"addToBundle.emit(selectedBundle)\"\n    (cancel)=\"cancel.emit()\"\n    (open)=\"focusDropDown()\">\n  <cw-input-dropdown\n      flex\n      [value]=\"bundleStores[0]?.id\"\n      allowAdditions=\"true\"\n      (click)=\"$event.stopPropagation()\"\n      (onDropDownChange)=\"setSelectedBundle($event)\"\n      (enter)=\"addToBundle.emit(selectedBundle)\">\n    <cw-input-option\n        *ngFor=\"let opt of bundleStores\"\n        [value]=\"opt.id\"\n        [label]=\"opt.name\"\n    ></cw-input-option>\n  </cw-input-dropdown>\n</cw-modal-dialog>"
            },] },
];
/** @nocollapse */
AddToBundleDialogComponent.ctorParameters = function () { return []; };
AddToBundleDialogComponent.propDecorators = {
    'hidden': [{ type: Input },],
    'bundleStores': [{ type: Input },],
    'errorMessage': [{ type: Input },],
    'close': [{ type: Output },],
    'cancel': [{ type: Output },],
    'addToBundle': [{ type: Output },],
};
//# sourceMappingURL=add-to-bundle-dialog-component.js.map