@colijnit/configurator 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/builder.d.ts +10 -0
- package/app/components/answers/answers.component.d.ts +6 -0
- package/app/components/answers/answers.module.d.ts +2 -0
- package/app/components/selections/selections.component.d.ts +16 -0
- package/app/components/selections/selections.module.d.ts +2 -0
- package/bundles/colijnit-configurator.umd.js +224 -55
- package/bundles/colijnit-configurator.umd.js.map +1 -1
- package/bundles/colijnit-configurator.umd.min.js +2 -2
- package/bundles/colijnit-configurator.umd.min.js.map +1 -1
- package/colijnit-configurator.metadata.json +1 -1
- package/esm2015/app/builder.js +62 -38
- package/esm2015/app/components/answers/answers.component.js +29 -0
- package/esm2015/app/components/answers/answers.module.js +21 -0
- package/esm2015/app/components/selections/selections.component.js +83 -0
- package/esm2015/app/components/selections/selections.module.js +21 -0
- package/esm2015/public_api.js +5 -1
- package/esm2015/utils/threed.utils.js +3 -2
- package/esm5/app/builder.js +87 -51
- package/esm5/app/components/answers/answers.component.js +24 -0
- package/esm5/app/components/answers/answers.module.js +24 -0
- package/esm5/app/components/selections/selections.component.js +73 -0
- package/esm5/app/components/selections/selections.module.js +24 -0
- package/esm5/public_api.js +5 -1
- package/esm5/utils/threed.utils.js +3 -2
- package/fesm2015/colijnit-configurator.js +205 -40
- package/fesm2015/colijnit-configurator.js.map +1 -1
- package/fesm5/colijnit-configurator.js +221 -53
- package/fesm5/colijnit-configurator.js.map +1 -1
- package/package.json +2 -2
- package/public_api.d.ts +4 -0
- package/utils/threed.utils.d.ts +0 -1
package/app/builder.d.ts
CHANGED
|
@@ -2,8 +2,12 @@ import * as THREE from "three";
|
|
|
2
2
|
import { Options } from "@colijnit/configuratorapi/build/src/model/options";
|
|
3
3
|
import { Selection } from "@colijnit/configuratorapi/build/src/model/selection";
|
|
4
4
|
import { BehaviorSubject } from "rxjs";
|
|
5
|
+
import { Answer } from "@colijnit/configuratorapi/build/src/model/answer";
|
|
6
|
+
import { Question } from "@colijnit/configuratorapi/build/src/model/question";
|
|
5
7
|
export declare class Builder {
|
|
6
8
|
selectionsReceived: BehaviorSubject<Selection[]>;
|
|
9
|
+
answersReceived: BehaviorSubject<Answer[]>;
|
|
10
|
+
questionReceived: BehaviorSubject<Question>;
|
|
7
11
|
private _configuratorApi;
|
|
8
12
|
private _scene;
|
|
9
13
|
private _selections;
|
|
@@ -16,10 +20,16 @@ export declare class Builder {
|
|
|
16
20
|
private _source;
|
|
17
21
|
private _threedUtils;
|
|
18
22
|
private _variationHelper;
|
|
23
|
+
private _articleCache;
|
|
24
|
+
private _subs;
|
|
19
25
|
constructor(scene: THREE.Scene, options: Options);
|
|
20
26
|
buildModel(instanceId: string, sku: string, goodId?: number): Promise<THREE.Object3D>;
|
|
21
27
|
initNodeInstance(goodId: number): Promise<any>;
|
|
22
28
|
destroy(): void;
|
|
29
|
+
selectSelection(selection: Selection): void;
|
|
30
|
+
getQuestionAndAnswers(): Promise<void>;
|
|
31
|
+
selectAnswer(answer: Answer): void;
|
|
32
|
+
private _prepareConfiguration;
|
|
23
33
|
private _build;
|
|
24
34
|
private _prepareTheSelections;
|
|
25
35
|
private _createAdjustable;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EventEmitter } from "@angular/core";
|
|
2
|
+
import { Selection } from "@colijnit/configuratorapi/build/src/model/selection";
|
|
3
|
+
declare class SelectionViewModel {
|
|
4
|
+
selection: Selection;
|
|
5
|
+
children: Selection[];
|
|
6
|
+
expanded: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare class SelectionsComponent {
|
|
9
|
+
set selections(value: Selection[]);
|
|
10
|
+
selectionViewModels: SelectionViewModel[];
|
|
11
|
+
selectionClick: EventEmitter<Selection>;
|
|
12
|
+
expandClicked(selectionViewModel: SelectionViewModel, mouseEvent: MouseEvent): void;
|
|
13
|
+
selectSelection(selection: Selection, mouseEvent: MouseEvent): void;
|
|
14
|
+
private _prepareSelections;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('three'), require('@colijnit/configuratorapi/build/src/configurator'), require('@colijnit/configuratorapi/build/src/model/deco-node'), require('@colijnit/configuratorapi/build/src/service/business-object-factory'), require('@colijnit/configuratorapi/build/src/model/selection'), require('@colijnit/configuratorapi/build/src/enum/deco-node-type.enum'), require('axios'), require('@colijnit/configuratorapi/build/src/enum/deco-node-kind.enum'), require('jszip'), require('@colijnit/configuratorapi/build/src/model/article'), require('rxjs')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@colijnit/configurator', ['exports', 'three', '@colijnit/configuratorapi/build/src/configurator', '@colijnit/configuratorapi/build/src/model/deco-node', '@colijnit/configuratorapi/build/src/service/business-object-factory', '@colijnit/configuratorapi/build/src/model/selection', '@colijnit/configuratorapi/build/src/enum/deco-node-type.enum', 'axios', '@colijnit/configuratorapi/build/src/enum/deco-node-kind.enum', 'jszip', '@colijnit/configuratorapi/build/src/model/article', 'rxjs'], factory) :
|
|
4
|
-
(global = global || self, factory((global.colijnit = global.colijnit || {}, global.colijnit.configurator = {}), global.three, global.configurator, global.decoNode, global.businessObjectFactory, global.selection, global.decoNodeType_enum, global.axios, global.decoNodeKind_enum, global.JSZip, global.article, global.rxjs));
|
|
5
|
-
}(this, (function (exports, three, configurator, decoNode, businessObjectFactory, selection, decoNodeType_enum, axios, decoNodeKind_enum, JSZip, article, rxjs) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('three'), require('@colijnit/configuratorapi/build/src/configurator'), require('@colijnit/configuratorapi/build/src/model/deco-node'), require('@colijnit/configuratorapi/build/src/service/business-object-factory'), require('@colijnit/configuratorapi/build/src/model/selection'), require('@colijnit/configuratorapi/build/src/enum/deco-node-type.enum'), require('axios'), require('@colijnit/configuratorapi/build/src/enum/deco-node-kind.enum'), require('jszip'), require('@colijnit/configuratorapi/build/src/model/article'), require('rxjs'), require('@angular/core'), require('@angular/common'), require('@angular/animations')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@colijnit/configurator', ['exports', 'three', '@colijnit/configuratorapi/build/src/configurator', '@colijnit/configuratorapi/build/src/model/deco-node', '@colijnit/configuratorapi/build/src/service/business-object-factory', '@colijnit/configuratorapi/build/src/model/selection', '@colijnit/configuratorapi/build/src/enum/deco-node-type.enum', 'axios', '@colijnit/configuratorapi/build/src/enum/deco-node-kind.enum', 'jszip', '@colijnit/configuratorapi/build/src/model/article', 'rxjs', '@angular/core', '@angular/common', '@angular/animations'], factory) :
|
|
4
|
+
(global = global || self, factory((global.colijnit = global.colijnit || {}, global.colijnit.configurator = {}), global.three, global.configurator, global.decoNode, global.businessObjectFactory, global.selection, global.decoNodeType_enum, global.axios, global.decoNodeKind_enum, global.JSZip, global.article, global.rxjs, global.ng.core, global.ng.common, global.ng.animations));
|
|
5
|
+
}(this, (function (exports, three, configurator, decoNode, businessObjectFactory, selection, decoNodeType_enum, axios, decoNodeKind_enum, JSZip, article, rxjs, core, common, animations) { 'use strict';
|
|
6
6
|
|
|
7
7
|
axios = axios && Object.prototype.hasOwnProperty.call(axios, 'default') ? axios['default'] : axios;
|
|
8
8
|
|
|
@@ -447,7 +447,8 @@
|
|
|
447
447
|
fileName = fileName.replace('.unity3d', '');
|
|
448
448
|
lookupFileName = fileName + (fileName.indexOf('.glb') < 0 ? '.glb' : '');
|
|
449
449
|
if (this._objectCache.has(lookupFileName)) {
|
|
450
|
-
|
|
450
|
+
resolve(this._objectCache.get(lookupFileName));
|
|
451
|
+
return [2 /*return*/];
|
|
451
452
|
}
|
|
452
453
|
return [4 /*yield*/, FileUtils.FileExists(lookupFileName, 'https://cdn1.colijn-it.nl/content43/')];
|
|
453
454
|
case 1:
|
|
@@ -1537,13 +1538,18 @@
|
|
|
1537
1538
|
|
|
1538
1539
|
var Builder = /** @class */ (function () {
|
|
1539
1540
|
function Builder(scene, options) {
|
|
1541
|
+
var _this = this;
|
|
1540
1542
|
this.selectionsReceived = new rxjs.BehaviorSubject([]);
|
|
1543
|
+
this.answersReceived = new rxjs.BehaviorSubject([]);
|
|
1544
|
+
this.questionReceived = new rxjs.BehaviorSubject(undefined);
|
|
1541
1545
|
this._selections = [];
|
|
1542
1546
|
this._decos = [];
|
|
1543
1547
|
this._placedAdjustables = [];
|
|
1544
1548
|
this._placedAddables = [];
|
|
1545
1549
|
this._adjustables = [];
|
|
1546
1550
|
this._addables = [];
|
|
1551
|
+
this._articleCache = new Map();
|
|
1552
|
+
this._subs = [];
|
|
1547
1553
|
if (!scene) {
|
|
1548
1554
|
throw 'No scene object provided!';
|
|
1549
1555
|
}
|
|
@@ -1555,64 +1561,41 @@
|
|
|
1555
1561
|
this._boFactory = new businessObjectFactory.BusinessObjectFactory();
|
|
1556
1562
|
this._threedUtils = new ThreedUtils();
|
|
1557
1563
|
this._variationHelper = new VariationHelper();
|
|
1564
|
+
this._subs.push(this._configuratorApi.selectionsReceived.subscribe(function (selections) { return _this.selectionsReceived.next(selections); }), this._configuratorApi.answersReceived.subscribe(function (answers) { return _this.answersReceived.next(answers); }), this._configuratorApi.questionReceived.subscribe(function (question) { return _this.questionReceived.next(question); }));
|
|
1558
1565
|
}
|
|
1559
1566
|
Builder.prototype.buildModel = function (instanceId, sku, goodId) {
|
|
1560
1567
|
return __awaiter(this, void 0, void 0, function () {
|
|
1561
|
-
var
|
|
1562
|
-
return __generator(this, function (
|
|
1563
|
-
switch (
|
|
1568
|
+
var promises, e_1;
|
|
1569
|
+
return __generator(this, function (_a) {
|
|
1570
|
+
switch (_a.label) {
|
|
1564
1571
|
case 0:
|
|
1565
1572
|
if (!this._scene && !instanceId) {
|
|
1566
1573
|
return [2 /*return*/];
|
|
1567
1574
|
}
|
|
1568
|
-
|
|
1575
|
+
_a.label = 1;
|
|
1569
1576
|
case 1:
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
return [4 /*yield*/, this._getGoodIdFromSku(sku)
|
|
1573
|
-
.catch(function (error) {
|
|
1574
|
-
throw "Article with sku " + sku + " not found!";
|
|
1575
|
-
})];
|
|
1577
|
+
_a.trys.push([1, 7, , 8]);
|
|
1578
|
+
return [4 /*yield*/, this._prepareConfiguration(sku, goodId)];
|
|
1576
1579
|
case 2:
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
case 3: return [4 /*yield*/, this._getArticle(goodId)];
|
|
1580
|
-
case 4:
|
|
1581
|
-
article = _b.sent();
|
|
1582
|
-
if (!(article && article.assetUrl)) return [3 /*break*/, 10];
|
|
1583
|
-
_a = this;
|
|
1584
|
-
return [4 /*yield*/, this._threedUtils.download3DSource(article.assetUrl)
|
|
1585
|
-
.catch(function (error) {
|
|
1586
|
-
throw error;
|
|
1587
|
-
})];
|
|
1588
|
-
case 5:
|
|
1589
|
-
_a._source = _b.sent();
|
|
1590
|
-
if (!this._source) return [3 /*break*/, 8];
|
|
1591
|
-
if (article.contentDeliveryUrl) {
|
|
1592
|
-
this._variationHelper.assetPath =
|
|
1593
|
-
article.contentDeliveryUrl +
|
|
1594
|
-
(article.contentDeliveryUrl.endsWith('/') ? '' : '/') +
|
|
1595
|
-
(article.distSchema ? article.distSchema : 'UP_DBA');
|
|
1596
|
-
}
|
|
1580
|
+
_a.sent();
|
|
1581
|
+
if (!this._source) return [3 /*break*/, 5];
|
|
1597
1582
|
return [4 /*yield*/, this._configuratorApi.setInstanceToConfigure(instanceId)];
|
|
1598
|
-
case
|
|
1599
|
-
|
|
1583
|
+
case 3:
|
|
1584
|
+
_a.sent();
|
|
1600
1585
|
promises = [];
|
|
1601
|
-
promises.push(this._getSelections());
|
|
1586
|
+
promises.push(this._getSelections(instanceId));
|
|
1602
1587
|
promises.push(this._getDecos());
|
|
1603
1588
|
return [4 /*yield*/, Promise.all(promises)];
|
|
1604
|
-
case
|
|
1605
|
-
|
|
1589
|
+
case 4:
|
|
1590
|
+
_a.sent();
|
|
1606
1591
|
this._linkSelectionsAndDecos();
|
|
1607
1592
|
return [2 /*return*/, this._build(instanceId)];
|
|
1608
|
-
case
|
|
1609
|
-
case
|
|
1610
|
-
case
|
|
1611
|
-
|
|
1612
|
-
case 12:
|
|
1613
|
-
e_1 = _b.sent();
|
|
1593
|
+
case 5: throw 'GLB source not found!';
|
|
1594
|
+
case 6: return [3 /*break*/, 8];
|
|
1595
|
+
case 7:
|
|
1596
|
+
e_1 = _a.sent();
|
|
1614
1597
|
throw e_1;
|
|
1615
|
-
case
|
|
1598
|
+
case 8: return [2 /*return*/];
|
|
1616
1599
|
}
|
|
1617
1600
|
});
|
|
1618
1601
|
});
|
|
@@ -1624,6 +1607,47 @@
|
|
|
1624
1607
|
this._threedUtils.clearCache();
|
|
1625
1608
|
this._variationHelper.clearCache();
|
|
1626
1609
|
};
|
|
1610
|
+
Builder.prototype.selectSelection = function (selection) {
|
|
1611
|
+
this._configuratorApi.selectSelection(selection, false);
|
|
1612
|
+
};
|
|
1613
|
+
Builder.prototype.getQuestionAndAnswers = function () {
|
|
1614
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1615
|
+
return __generator(this, function (_a) {
|
|
1616
|
+
return [2 /*return*/, this._configuratorApi.getQuestionAndAnswers(false)];
|
|
1617
|
+
});
|
|
1618
|
+
});
|
|
1619
|
+
};
|
|
1620
|
+
Builder.prototype.selectAnswer = function (answer) {
|
|
1621
|
+
this._configuratorApi.selectAnswer(answer, false);
|
|
1622
|
+
};
|
|
1623
|
+
Builder.prototype._prepareConfiguration = function (sku, goodId) {
|
|
1624
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1625
|
+
var article, _a;
|
|
1626
|
+
return __generator(this, function (_b) {
|
|
1627
|
+
switch (_b.label) {
|
|
1628
|
+
case 0: return [4 /*yield*/, this._getArticle(sku, goodId)];
|
|
1629
|
+
case 1:
|
|
1630
|
+
article = _b.sent();
|
|
1631
|
+
if (!(article && article.assetUrl)) return [3 /*break*/, 3];
|
|
1632
|
+
_a = this;
|
|
1633
|
+
return [4 /*yield*/, this._threedUtils.download3DSource(article.assetUrl)
|
|
1634
|
+
.catch(function (error) {
|
|
1635
|
+
throw error;
|
|
1636
|
+
})];
|
|
1637
|
+
case 2:
|
|
1638
|
+
_a._source = _b.sent();
|
|
1639
|
+
if (article.contentDeliveryUrl) {
|
|
1640
|
+
this._variationHelper.assetPath =
|
|
1641
|
+
article.contentDeliveryUrl +
|
|
1642
|
+
(article.contentDeliveryUrl.endsWith('/') ? '' : '/') +
|
|
1643
|
+
(article.distSchema ? article.distSchema : 'UP_DBA');
|
|
1644
|
+
}
|
|
1645
|
+
_b.label = 3;
|
|
1646
|
+
case 3: return [2 /*return*/];
|
|
1647
|
+
}
|
|
1648
|
+
});
|
|
1649
|
+
});
|
|
1650
|
+
};
|
|
1627
1651
|
Builder.prototype._build = function (instanceId) {
|
|
1628
1652
|
return __awaiter(this, void 0, void 0, function () {
|
|
1629
1653
|
var adjustables, obj, connected, i, len, adjustable, ii, lenii;
|
|
@@ -1844,29 +1868,42 @@
|
|
|
1844
1868
|
});
|
|
1845
1869
|
});
|
|
1846
1870
|
};
|
|
1847
|
-
Builder.prototype._getArticle = function (
|
|
1871
|
+
Builder.prototype._getArticle = function (sku, goodId) {
|
|
1848
1872
|
return __awaiter(this, void 0, void 0, function () {
|
|
1849
|
-
var articleResponse, obj;
|
|
1873
|
+
var article$1, articleResponse, obj;
|
|
1850
1874
|
return __generator(this, function (_a) {
|
|
1851
1875
|
switch (_a.label) {
|
|
1852
|
-
case 0:
|
|
1876
|
+
case 0:
|
|
1877
|
+
if (this._articleCache.has(sku)) {
|
|
1878
|
+
return [2 /*return*/, this._articleCache.get(sku)];
|
|
1879
|
+
}
|
|
1880
|
+
if (!!goodId) return [3 /*break*/, 2];
|
|
1881
|
+
return [4 /*yield*/, this._getGoodIdFromSku(sku)
|
|
1882
|
+
.catch(function (error) {
|
|
1883
|
+
throw "Article with sku " + sku + " not found!";
|
|
1884
|
+
})];
|
|
1853
1885
|
case 1:
|
|
1886
|
+
goodId = _a.sent();
|
|
1887
|
+
_a.label = 2;
|
|
1888
|
+
case 2: return [4 /*yield*/, this._configuratorApi.getArticleQuickSel(goodId, false)];
|
|
1889
|
+
case 3:
|
|
1854
1890
|
articleResponse = _a.sent();
|
|
1855
1891
|
if (articleResponse.validationResult.success && articleResponse.resultObject) {
|
|
1856
1892
|
if (articleResponse.resultObject.hasOwnProperty('oArticle')) {
|
|
1857
1893
|
obj = Array.isArray(articleResponse.resultObject['oArticle']) ? articleResponse.resultObject['oArticle'][0] : articleResponse.resultObject['oArticle'];
|
|
1858
|
-
|
|
1894
|
+
article$1 = this._boFactory.makeWithRawBackendData(article.Article, obj);
|
|
1859
1895
|
}
|
|
1860
1896
|
else {
|
|
1861
|
-
|
|
1897
|
+
article$1 = this._boFactory.makeWithRawBackendData(article.Article, articleResponse.resultObject);
|
|
1862
1898
|
}
|
|
1863
1899
|
}
|
|
1864
|
-
|
|
1900
|
+
this._articleCache.set(sku, article$1);
|
|
1901
|
+
return [2 /*return*/, article$1];
|
|
1865
1902
|
}
|
|
1866
1903
|
});
|
|
1867
1904
|
});
|
|
1868
1905
|
};
|
|
1869
|
-
Builder.prototype._getSelections = function () {
|
|
1906
|
+
Builder.prototype._getSelections = function (instanceId) {
|
|
1870
1907
|
return __awaiter(this, void 0, void 0, function () {
|
|
1871
1908
|
var selectionResponse;
|
|
1872
1909
|
return __generator(this, function (_a) {
|
|
@@ -1878,7 +1915,7 @@
|
|
|
1878
1915
|
selectionResponse = _a.sent();
|
|
1879
1916
|
if (selectionResponse.resultObjects && selectionResponse.resultObjects.length > 0) {
|
|
1880
1917
|
this._selections = this._boFactory.makeBOArrayFromRawBackendDataArray(selection.Selection, selectionResponse.resultObjects);
|
|
1881
|
-
this.
|
|
1918
|
+
this._selections.forEach(function (s) { return s.instanceId = instanceId; });
|
|
1882
1919
|
}
|
|
1883
1920
|
else {
|
|
1884
1921
|
throw 'No selections found!';
|
|
@@ -1981,7 +2018,139 @@
|
|
|
1981
2018
|
return Builder;
|
|
1982
2019
|
}());
|
|
1983
2020
|
|
|
2021
|
+
var AnswersComponent = /** @class */ (function () {
|
|
2022
|
+
function AnswersComponent() {
|
|
2023
|
+
this.answers = [];
|
|
2024
|
+
this.answerClick = new core.EventEmitter();
|
|
2025
|
+
}
|
|
2026
|
+
__decorate([
|
|
2027
|
+
core.Input()
|
|
2028
|
+
], AnswersComponent.prototype, "answers", void 0);
|
|
2029
|
+
__decorate([
|
|
2030
|
+
core.Output()
|
|
2031
|
+
], AnswersComponent.prototype, "answerClick", void 0);
|
|
2032
|
+
AnswersComponent = __decorate([
|
|
2033
|
+
core.Component({
|
|
2034
|
+
selector: "answers",
|
|
2035
|
+
template: "\n <ng-container *ngFor=\"let answer of answers\">\n <div class=\"answers\" (click)=\"answerClick.emit(answer)\">\n <div class=\"answer\" [textContent]=\"answer.commercialAnswer\"></div>\n </div>\n </ng-container>\n ",
|
|
2036
|
+
styles: [":host{position:absolute;top:0;right:0;width:400px;height:100%;background:#fff}:host .answers{cursor:pointer}"]
|
|
2037
|
+
})
|
|
2038
|
+
], AnswersComponent);
|
|
2039
|
+
return AnswersComponent;
|
|
2040
|
+
}());
|
|
2041
|
+
|
|
2042
|
+
var AnswersModule = /** @class */ (function () {
|
|
2043
|
+
function AnswersModule() {
|
|
2044
|
+
}
|
|
2045
|
+
AnswersModule = __decorate([
|
|
2046
|
+
core.NgModule({
|
|
2047
|
+
imports: [
|
|
2048
|
+
common.CommonModule
|
|
2049
|
+
],
|
|
2050
|
+
declarations: [
|
|
2051
|
+
AnswersComponent
|
|
2052
|
+
],
|
|
2053
|
+
exports: [
|
|
2054
|
+
AnswersComponent
|
|
2055
|
+
]
|
|
2056
|
+
})
|
|
2057
|
+
], AnswersModule);
|
|
2058
|
+
return AnswersModule;
|
|
2059
|
+
}());
|
|
2060
|
+
|
|
2061
|
+
var SelectionViewModel = /** @class */ (function () {
|
|
2062
|
+
function SelectionViewModel() {
|
|
2063
|
+
this.children = [];
|
|
2064
|
+
this.expanded = false;
|
|
2065
|
+
}
|
|
2066
|
+
return SelectionViewModel;
|
|
2067
|
+
}());
|
|
2068
|
+
var SelectionsComponent = /** @class */ (function () {
|
|
2069
|
+
function SelectionsComponent() {
|
|
2070
|
+
this.selectionViewModels = [];
|
|
2071
|
+
this.selectionClick = new core.EventEmitter();
|
|
2072
|
+
}
|
|
2073
|
+
Object.defineProperty(SelectionsComponent.prototype, "selections", {
|
|
2074
|
+
set: function (value) {
|
|
2075
|
+
this._prepareSelections(value);
|
|
2076
|
+
},
|
|
2077
|
+
enumerable: true,
|
|
2078
|
+
configurable: true
|
|
2079
|
+
});
|
|
2080
|
+
SelectionsComponent.prototype.expandClicked = function (selectionViewModel, mouseEvent) {
|
|
2081
|
+
mouseEvent.preventDefault();
|
|
2082
|
+
mouseEvent.stopImmediatePropagation();
|
|
2083
|
+
selectionViewModel.expanded = !selectionViewModel.expanded;
|
|
2084
|
+
};
|
|
2085
|
+
SelectionsComponent.prototype.selectSelection = function (selection, mouseEvent) {
|
|
2086
|
+
mouseEvent.preventDefault();
|
|
2087
|
+
mouseEvent.stopImmediatePropagation();
|
|
2088
|
+
this.selectionClick.next(selection);
|
|
2089
|
+
};
|
|
2090
|
+
SelectionsComponent.prototype._prepareSelections = function (value) {
|
|
2091
|
+
var _this = this;
|
|
2092
|
+
this.selectionViewModels.length = 0;
|
|
2093
|
+
var selectionViewModel;
|
|
2094
|
+
value.forEach(function (s) {
|
|
2095
|
+
if (s.presentationLevel === 1) {
|
|
2096
|
+
selectionViewModel = new SelectionViewModel();
|
|
2097
|
+
selectionViewModel.selection = s;
|
|
2098
|
+
_this.selectionViewModels.push(selectionViewModel);
|
|
2099
|
+
}
|
|
2100
|
+
else if (s.presentationLevel > 1) {
|
|
2101
|
+
if (selectionViewModel) {
|
|
2102
|
+
selectionViewModel.children.push(s);
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
});
|
|
2106
|
+
};
|
|
2107
|
+
__decorate([
|
|
2108
|
+
core.Input()
|
|
2109
|
+
], SelectionsComponent.prototype, "selections", null);
|
|
2110
|
+
__decorate([
|
|
2111
|
+
core.Output()
|
|
2112
|
+
], SelectionsComponent.prototype, "selectionClick", void 0);
|
|
2113
|
+
SelectionsComponent = __decorate([
|
|
2114
|
+
core.Component({
|
|
2115
|
+
selector: "selections",
|
|
2116
|
+
template: "\n <ng-container *ngFor=\"let selectionViewModel of selectionViewModels\">\n <div class=\"selection\" (click)=\"selectSelection(selectionViewModel.selection, $event)\">\n <div class=\"question\" [textContent]=\"selectionViewModel.selection.commercialQuestion\"></div>\n <div class=\"answer\" [textContent]=\"selectionViewModel.selection.answer\"></div>\n <div class=\"collapse-handle\" [class.expanded]=\"selectionViewModel.expanded\" \n *ngIf=\"selectionViewModel.children.length > 0\" (click)=\"expandClicked(selectionViewModel, $event)\"></div>\n <div *ngIf=\"selectionViewModel.children.length > 0 && selectionViewModel.expanded\" @showHideChildren>\n <div class=\"child-selection\" *ngFor=\"let selection of selectionViewModel.children\"\n (click)=\"selectSelection(selection, $event)\"\n >\n <div class=\"question\" [textContent]=\"selection.commercialQuestion\"></div>\n <div class=\"answer\" [textContent]=\"selection.answer\"></div>\n </div>\n </div>\n </div>\n </ng-container>\n ",
|
|
2117
|
+
animations: [
|
|
2118
|
+
animations.trigger('showHideChildren', [
|
|
2119
|
+
animations.state('void', animations.style({ 'height': '0' })),
|
|
2120
|
+
animations.state('*', animations.style({ 'height': '*' })),
|
|
2121
|
+
animations.transition('void <=> *', animations.animate(200))
|
|
2122
|
+
])
|
|
2123
|
+
],
|
|
2124
|
+
styles: [":host{position:absolute;top:0;right:0;width:300px}:host .selection{position:relative;overflow:hidden;cursor:pointer;font-size:12px;border:1px solid gray}:host .question{font-weight:700}:host .answer{font-size:10px}:host .collapse-handle{position:absolute;top:10px;right:12px;border:solid #000;border-width:0 3px 3px 0;display:inline-block;padding:3px;transform:rotate(45deg);-webkit-transform:rotate(45deg)}:host .collapse-handle.expanded{transform:rotate(-135deg);-webkit-transform:rotate(-135deg)}:host .child-selection{margin-left:10px}"]
|
|
2125
|
+
})
|
|
2126
|
+
], SelectionsComponent);
|
|
2127
|
+
return SelectionsComponent;
|
|
2128
|
+
}());
|
|
2129
|
+
|
|
2130
|
+
var SelectionsModule = /** @class */ (function () {
|
|
2131
|
+
function SelectionsModule() {
|
|
2132
|
+
}
|
|
2133
|
+
SelectionsModule = __decorate([
|
|
2134
|
+
core.NgModule({
|
|
2135
|
+
imports: [
|
|
2136
|
+
common.CommonModule
|
|
2137
|
+
],
|
|
2138
|
+
declarations: [
|
|
2139
|
+
SelectionsComponent
|
|
2140
|
+
],
|
|
2141
|
+
exports: [
|
|
2142
|
+
SelectionsComponent
|
|
2143
|
+
]
|
|
2144
|
+
})
|
|
2145
|
+
], SelectionsModule);
|
|
2146
|
+
return SelectionsModule;
|
|
2147
|
+
}());
|
|
2148
|
+
|
|
2149
|
+
exports.AnswersComponent = AnswersComponent;
|
|
2150
|
+
exports.AnswersModule = AnswersModule;
|
|
1984
2151
|
exports.Builder = Builder;
|
|
2152
|
+
exports.SelectionsComponent = SelectionsComponent;
|
|
2153
|
+
exports.SelectionsModule = SelectionsModule;
|
|
1985
2154
|
|
|
1986
2155
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1987
2156
|
|