(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[36],{

/***/ "../ozone/lib/listing/component/ListingEditApp.js":
/*!********************************************************!*\
  !*** ../ozone/lib/listing/component/ListingEditApp.js ***!
  \********************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = __webpack_require__(/*! react */ "../../node_modules/react/index.js");
var mobx_react_1 = __webpack_require__(/*! mobx-react */ "../../node_modules/mobx-react/index.module.js");
var ListingForm_1 = __webpack_require__(/*! ./ListingForm */ "../ozone/lib/listing/component/ListingForm.js");
var ListingFinder_1 = __webpack_require__(/*! ../model/ListingFinder */ "../ozone/lib/listing/model/ListingFinder.js");
var mobx_1 = __webpack_require__(/*! mobx */ "../../node_modules/mobx/lib/mobx.module.js");
var HostAppView_1 = __webpack_require__(/*! @twii/core-ui-fabric/lib/component/HostAppView */ "../core-ui-fabric/lib/component/HostAppView.js");
var ListingMenuHelper_1 = __webpack_require__(/*! ./ListingMenuHelper */ "../ozone/lib/listing/component/ListingMenuHelper.js");
var ListingEditApp = /** @class */ (function (_super) {
    __extends(ListingEditApp, _super);
    function ListingEditApp() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this._onBackToListing = function () {
            _this.host.load({ path: "/ozone/listings/" + _this.listingId });
        };
        _this._onSave = function (listing) {
            listing.save().then(_this._onBackToListing).catch(function () {
                // we don't do anything here - the error should be reported on the model
            });
        };
        _this._onSaveImmediate = function () {
            _this._onSave(_this.listingSupplier.value);
        };
        _this._onSubmitForApproval = function (listing) {
            listing.submitForApproval().then(_this._onBackToListing).catch(function () {
                // we don't do anything here - the error should be reported on the model
            });
        };
        _this._onCancel = function () {
            _this.host.load({ path: "/ozone/listings/" + _this.listingId });
        };
        return _this;
    }
    Object.defineProperty(ListingEditApp.prototype, "host", {
        get: function () {
            return this.props.match.host;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ListingEditApp.prototype, "userProfile", {
        get: function () {
            return this.props.match.userProfile;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ListingEditApp.prototype, "listingId", {
        get: function () {
            return this.props.match.params.listingId;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ListingEditApp.prototype, "listingSupplier", {
        get: function () {
            var _this = this;
            return this.host.getState("listingSupplier", function () {
                return ListingFinder_1.findById(_this.listingId);
            }, function (s) { return s.listingId !== _this.listingId; });
        },
        enumerable: true,
        configurable: true
    });
    ListingEditApp.prototype.componentWillMount = function () {
        var _this = this;
        this._titleSetDisposer = mobx_1.autorun(function () {
            _this.host.setTitle(_this.listingSupplier.sync.syncing ? "Loading..." : _this.listingSupplier.value ? _this.listingSupplier.value.title : undefined);
        });
    };
    ListingEditApp.prototype.componentWillUnount = function () {
        if (this._titleSetDisposer) {
            this._titleSetDisposer();
            delete this._titleSetDisposer;
        }
    };
    ListingEditApp.prototype.render = function () {
        var placeItems = ListingMenuHelper_1.createPlaceItems({ host: this.host, userProfile: this.userProfile });
        var listingDetailsItem = ListingMenuHelper_1.createListingPlaceItem({
            key: "listingDetails",
            host: this.host,
            path: "/ozone/listings/" + encodeURIComponent(this.listingId),
            listingSupplier: this.listingSupplier,
            onRenderTitle: function (s) { return s.value.title + " - Details"; }
        });
        var listingEditItem = ListingMenuHelper_1.createListingPlaceItem({
            key: "listingEdit",
            host: this.host,
            path: this.host.path,
            listingSupplier: this.listingSupplier,
            onRenderTitle: function (s) { return s.value.title + " - Edit"; }
        });
        placeItems.unshift({
            key: "sep",
            name: "-"
        });
        placeItems.unshift(listingDetailsItem);
        placeItems.unshift(listingEditItem);
        var items = [
            ListingMenuHelper_1.createPlaceMenu({ host: this.host, userProfile: this.userProfile, placeItems: placeItems }),
            {
                key: "cancel",
                name: "Cancel",
                iconProps: {
                    iconName: "Cancel"
                },
                onClick: this._onCancel
            },
            {
                key: "save",
                name: "Save",
                iconProps: {
                    iconName: "Save"
                },
                disabled: this.listingSupplier.sync.syncing,
                onClick: this._onSaveImmediate
            }
        ];
        return (React.createElement(HostAppView_1.HostAppView, { host: this.host, commandBarProps: { items: items } },
            React.createElement(ListingForm_1.ListingFormContainer, { listingSupplier: this.listingSupplier, onSave: this._onSave, onSubmitForApproval: this._onSubmitForApproval, onCancel: this._onCancel })));
    };
    ListingEditApp = __decorate([
        mobx_react_1.observer
    ], ListingEditApp);
    return ListingEditApp;
}(React.Component));
exports.ListingEditApp = ListingEditApp;
exports.default = ListingEditApp;


/***/ }),

/***/ "../ozone/lib/listing/model/ListingFinder.js":
/*!***************************************************!*\
  !*** ../ozone/lib/listing/model/ListingFinder.js ***!
  \***************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var ListingModelSupplier_1 = __webpack_require__(/*! ./ListingModelSupplier */ "../ozone/lib/listing/model/ListingModelSupplier.js");
var deleteAfter = 2 * 60 * 1000;
var entryMap = {};
var setEntry = function (key, entry) {
    entryMap[key] = entry;
};
var deleteEntry = function (key) {
    delete entryMap[key];
};
var findById = function (listingId) {
    var entry = entryMap[listingId];
    if (!entry) {
        entry = { supplier: new ListingModelSupplier_1.ListingModelSupplier(listingId) };
        setEntry(String(listingId), entry);
        // add our deletion timeout
        entry.timeout = setTimeout(function () {
            deleteEntry(String(listingId));
        }, deleteAfter);
    }
    entry.supplier.load();
    return entry.supplier;
};
exports.findById = findById;


/***/ })

}]);
//# sourceMappingURL=36.js.map