1 | import { Component, EventEmitter, Input, Output } from '@angular/core';
|
2 | import { Addon } from '@vendasta/core/marketplace-apps';
|
3 | import { Product } from '../shared';
|
4 | var VaPackageDetailsComponent = (function () {
|
5 | function VaPackageDetailsComponent() {
|
6 | this.products = [];
|
7 | this.pkgAddons = [];
|
8 | this.showActionButton = true;
|
9 | this.showPricing = true;
|
10 | this.getItNow = new EventEmitter();
|
11 | this.selectedItem = null;
|
12 | this.combinedItemsList = [];
|
13 | }
|
14 | VaPackageDetailsComponent.prototype.ngOnInit = function () {
|
15 | this.getCombinedListItems();
|
16 | this.selectedItem = this.combinedItemsList[0] ? this.combinedItemsList[0] : null;
|
17 | };
|
18 | VaPackageDetailsComponent.prototype.getCombinedListItems = function () {
|
19 | this.combinedItemsList = this.combinedItemsList
|
20 | .concat(this.products ? this.products : [])
|
21 | .concat(this.pkgAddons ? this.pkgAddons : []);
|
22 | };
|
23 | VaPackageDetailsComponent.prototype.getSelectedItem = function (i) {
|
24 | this.selectedItem = this.combinedItemsList[i];
|
25 | };
|
26 | VaPackageDetailsComponent.prototype.emitGetItNow = function () {
|
27 | this.getItNow.emit();
|
28 | };
|
29 | Object.defineProperty(VaPackageDetailsComponent.prototype, "lmiCategories", {
|
30 | get: function () {
|
31 | var lmiCategories = [];
|
32 | if (this.products) {
|
33 | this.products.forEach(function (product) {
|
34 | lmiCategories = lmiCategories.concat(product.getLmiCategoryNames());
|
35 | });
|
36 | }
|
37 | return new Set(lmiCategories);
|
38 | },
|
39 | enumerable: true,
|
40 | configurable: true
|
41 | });
|
42 | Object.defineProperty(VaPackageDetailsComponent.prototype, "addons", {
|
43 | get: function () {
|
44 | if (this.selectedItem instanceof Product) {
|
45 | return this.selectedItem.addons.map(function (addon) { return Addon.fromApi(addon); });
|
46 | }
|
47 | },
|
48 | enumerable: true,
|
49 | configurable: true
|
50 | });
|
51 | VaPackageDetailsComponent.prototype.getDisplayTagline = function (pkg, pkgProducts) {
|
52 | if (pkg.products.length === 1 && !pkg.tagline && pkgProducts) {
|
53 | return pkgProducts[0] && pkgProducts[0].tagline ? pkgProducts[0].tagline : '';
|
54 | }
|
55 | return pkg.tagline || '';
|
56 | };
|
57 | VaPackageDetailsComponent.decorators = [
|
58 | { type: Component, args: [{
|
59 | selector: 'va-package-details',
|
60 | template: "<div class=\"page\"> <va-header-container [iconUrl]=\"pkg.icon\" [title]=\"pkg.name\" [tagline]=\"getDisplayTagline(pkg, products)\" [chipLabels]=\"lmiCategories\" [pricing]=\"pkg.pricing\" [pricingLabel]=\"'Pricing'\" [showAction]=\"showActionButton\" [showPricing]=\"showPricing\" [actionLabel]=\"'Get It Now'\" [actionEnabled]=true (actionSelected)=\"emitGetItNow()\" ></va-header-container> <ng-container *ngIf=\"pkg?.content\"> <va-selling-info [description]=\"pkg.content\"></va-selling-info> </ng-container> <va-products-nav [items]=\"combinedItemsList\" [hideItemsNav]=\"pkg?.hide_product_icons_and_names\" (itemSelected)=\"getSelectedItem($event)\"></va-products-nav> <div *ngIf=\"!!selectedItem && !pkg?.hide_product_details\" class=\"package-content\"> <div class=\"left-column\"> <ng-container *ngIf=\"selectedItem.description || selectedItem.keySellingPoints\"> <va-selling-info [description]=\"selectedItem.description\" [keySellingPoints]=\"selectedItem.keySellingPoints\"></va-selling-info> </ng-container> <section *ngIf=\"selectedItem.addons?.length > 0\"> <h2 class=\"va-component-title\">Add-Ons</h2> <va-addon-list [addons]=\"addons\" [product]=\"selectedItem\"></va-addon-list> </section> <section *ngIf=\"selectedItem.faqs?.length > 0\"> <h2 class=\"va-component-title\">FAQs</h2> <va-faqs [faqs]=\"selectedItem.faqs\"></va-faqs> </section> </div> <div class=\"right-column\"> <section *ngIf=\"selectedItem.screenshotUrls?.length > 0 || selectedItem.screenshots?.length > 0\"> <h2 class=\"va-component-title\">Gallery</h2> <va-image-gallery [imageUrls]=\"selectedItem.screenshotUrls?.length > 0 ? selectedItem.screenshotUrls : selectedItem.screenshots\"></va-image-gallery> </section> <section *ngIf=\"selectedItem.files?.length > 0\"> <h2 class=\"va-component-title\">Files</h2> <va-files [files]=\"selectedItem.files\"></va-files> </section> </div> </div> </div> ",
|
61 | styles: [":host { display: block; font-size: 14px; line-height: 1.4; } :host * { box-sizing: border-box; } .va-component-title { font-size: 24px; font-weight: 300; margin-top: 0; } @media screen and (min-width: 600px) { .va-component-title { font-size: 32px; } } img { max-width: 100%; } va-icon { display: inline-block; } .page { position: relative; margin: 0 auto 20px; background: #ffffff; box-shadow: 0 3px 10px rgba(33, 33, 33, 0.3); overflow: hidden; font-size: 16px; } .page .item-amount { color: #9e9e9e; font-size: 14px; text-align: right; margin: 0 24px 8px; } section { padding: 24px; } .left-column { width: 66%; } @media screen and (max-width: 600px) { .left-column { width: 100%; } } .right-column { width: 34%; } @media screen and (max-width: 600px) { .right-column { width: 100%; } } .package-content { display: flex; } @media screen and (max-width: 600px) { .package-content { flex-direction: column; } } "]
|
62 | },] },
|
63 | ];
|
64 |
|
65 | VaPackageDetailsComponent.ctorParameters = function () { return []; };
|
66 | VaPackageDetailsComponent.propDecorators = {
|
67 | 'pkg': [{ type: Input },],
|
68 | 'products': [{ type: Input },],
|
69 | 'pkgAddons': [{ type: Input },],
|
70 | 'showActionButton': [{ type: Input },],
|
71 | 'showPricing': [{ type: Input },],
|
72 | 'getItNow': [{ type: Output },],
|
73 | };
|
74 | return VaPackageDetailsComponent;
|
75 | }());
|
76 | export { VaPackageDetailsComponent };
|