dh_ackergaul
vor 3 Tagen bb80cdf5a6157ca1f3a276e12e9faae9a4739cb7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
function convertDecimalNCRtoUTF8(ncr) {
    if (ncr && ncr.length > 0) {
        return ncr.replace(/&#([0-9]+);/g, function (b) {
            return String.fromCodePoint(parseInt(b.slice(2, -1)))
        })
    }
    return ncr;
}
 
function Article(art, type, mod, selectedProgGroup, separatelist) {
    var self = this;
    self.imgPath = art.imgName ? convertDecimalNCRtoUTF8(art.imgName) : art.imgName;
    self.id = art.id;
    self.mod = mod;
    self.selectedProgGroup = selectedProgGroup;
    self.modName = mod.id;
    self.artNo = art.ArtNr;
    if(art.ArtNr === "205"){
        debugger;
    }
    self.artNoGroup = art.TypG;
    self.hingeSide = art.Anschl;
    self.manufacturer = art.Manu;
    self.program = art.Prog;
    self.manufacturerName = art.ManuName;
    self.programName = art.ProgName;
    self.GA = art.GA;
    self.dxma = +art.dxma;
    self.dyma = +art.dyma;
    self.dzma = +art.dzma;
    self.dxmi = +art.dxmi;
    self.dymi = +art.dymi;
    self.dzmi = +art.dzmi;
    self.classId = art.ClassID;
    if (art.MMdx !== "" && art.Dispdx !== "") {
        self.xMax = (+art.MMdx / 10).toFixed(1).replace(".", ",");
        self.xMaxDisplay = (+art.Dispdx / 10).toFixed(1).replace(".", ",");
        self.xMaxRaw = +art.MMdx;
    } else {
        self.xMax = (+art.dxma / 10).toFixed(1).replace(".", ",");
        self.xMaxNum = (+art.dxma / 10);
        self.xMinNum = (+art.dxmi / 10);
        self.xMaxDisplay = this.xMax;
        self.xMaxRaw = +art.dxma;
        self.xMinRaw = +art.dxmi;
    }
    if (art.MMdy !== "" && art.Dispdy !== "") {
        self.yMax = (+art.MMdy / 10).toFixed(1).replace(".", ",");
        self.yMaxDisplay = (+art.Dispdy / 10).toFixed(1).replace(".", ",");
        self.yMaxRaw = +art.MMdy;
    } else {
        self.yMax = (+art.dyma / 10).toFixed(1).replace(".", ",");
        self.yMaxNum = (+art.dyma / 10);
        self.yMinNum = (+art.dymi / 10);
        self.yMaxDisplay = this.yMax;
        self.yMaxRaw = +art.dyma;
        self.yMinRaw = +art.dymi;
    }
    if (art.MMdz !== "" && art.Dispdz !== "") {
        self.zMax = (+art.MMdz / 10).toFixed(1).replace(".", ",");
        self.zMaxDisplay = (+art.Dispdz / 10).toFixed(1).replace(".", ",");
        self.zMaxRaw = +art.MMdz;
    } else {
        self.zMax = (+art.dzma / 10).toFixed(1).replace(".", ",");
        self.zMaxNum = (+art.dzma / 10);
        self.zMinNum = (+art.dzmi / 10);
        self.zMaxDisplay = this.zMax;
        self.zMaxRaw = +art.dzma;
        self.zMinRaw = +art.dzmi;
    }
 
    self.imgName = art.ArtNr;
    self.type = type;
    self.subHingeArticle = undefined;
 
 
    self.artCategories = [];
 
    self.artPropVars = [];
    if (art.artPropVars) {
        art.artPropVars.forEach(function (artPropVar) {
            self.artPropVars.push(new ArticlePropertyVariable(artPropVar.key, +artPropVar.value, artPropVar.text, artPropVar.behavior, artPropVar.values));
        });
    }
 
    self.artPropTrans = [];
    self.artProgProperties = [];
    self.artFittings = [];
    self.artShoppingCartArticles = [];
    self.artPoEquipment = [];
    self.artInfoTexts = [];
    self.forceAutoGenImages = mod.cfg["forceAutoGenImages"];
    self.showArtNo = art.ShowArtNo;
    self.hideArticle = false;
    self.contructionType = art.KataConstGroup || ""; //Falls in DB noch nicht eingetragen dann setze auf Leer-String
    self.design = art.Des;
    self.baseArtNo = this.artNo.replace(this.design, "");
    self.rawData = art;
    self.isDefaultConfiguratorArt = false;
    self.isCategorySpacer = false;
    self.showFittingControls = false;
    self.showPropTransControls = false;
    self.insertType = art.InsertType;
    self.ptId = "";
    self.vPlacerId = art.VPlacerID;
    self.hasLighting = art.HasLighting;
 
    self.hasHingeChange = art.hasHingeChange; // nun aus C++, //Wenn der Artikel einen rechten oder linken Anschlag hat dann wird dieses im Katalog durch ein Symbol am Artikel gargestellt
    self.hasHinge = false;
    //self.modName = "";
    // self.selectedProgGroup = "";
    self.cftType = art.CftType || ""; //CFT-Type
    self.cftCL = +art.CftCL || 0.0; //CFT-Type6 Schenkellänge links
    self.cftCR = +art.CftCR || 0.0; //CFT-Type6 Schenkellänge rechts
    self.CftTypeUnique = art.CftTypeUnique;
    self.artText = art.artText;
    self.artTextLong = art.artTextLong;
    self.isNewArticle = art.isNewArticle;
    self.distinctFittingList = [];
 
    self.selectedProgGroup = selectedProgGroup;
    self.separatelist = separatelist;
    self.orderIndex = 0;
 
    self.hideXbyArtpropDataVars = art.hideXbyArtpropDataVars;
    self.hideYbyArtpropDataVars = art.hideYbyArtpropDataVars;
    self.hideZbyArtpropDataVars = art.hideZbyArtpropDataVars;
 
    if (type === ArticleType.NORMAL) {
        //Zubehör zuordnene
 
            
 
        if (!useDynZub) {
            self.artPoEquipment = Article.registeredPoEquipment(art.artPoEquipment);
            self.artShoppingCartArticles = Article.registeredShoppingCartArticles(art.artShoppingCartArticles);
 
            self.artFittings = Article.registeredFittings(art.artFittings);
            if (self.artFittings.length > 0) {
                var fittingInfoByArtNr = buildIndexMap(fittingInfo, "artNr"); // O(1)-Lookup statt fittingInfo.find() je Fitting
                self.artFittings.forEach(function (apt) {
                    var found = fittingInfoByArtNr["$" + apt.artNoFitting];
                    if (found) {
                        apt.hideInsert = found.hideInsert;
                        apt.jsAN = found.jsAN;
                        apt.hideFront = found.hideFront;
                        apt.hideDelete = found.hideDelete;
                        apt.hideMove = found.hideMove;
                        apt.hideRefresh = found.hideRefresh;
                        if (self.distinctFittingList.indexOf(apt.jsAN) < 0) {
                            self.distinctFittingList.push(apt.jsAN);
                        } else {
                            apt.hideFittingbyAN = true;
                        }
                    }
                });
            }            
            
            self.artPropTrans = Article.registeredPropTrans(art.artPropTrans);
            if (self.artPropTrans.length > 0) {
                var propTransInfoById = buildIndexMap(propTransInfo, "id"); // O(1)-Lookup statt propTransInfo.find() je PropTrans
                self.artPropTrans.forEach(function (apt) {
                    var found = propTransInfoById["$" + apt.id];
                    if (found) {
                        apt.img = found.img;
                        apt.text = found.text;
                        apt.hideDelete = found.hideDelete;
                        apt.hideFront = found.hideFront;
                        apt.artNo = found.artNo;
 
                        apt.controls = found.controls.map(function (control) {
                            return new ArticlePropertyTransControl(control);
                        });
                    }
                });
                //Hier abprüfen auf DEV-Artikel, da erst hier ArtNR von PropTrans bekannt und das PLUS nicht erscheint
                if (!devMode) {
                    self.artPropTrans = self.artPropTrans.filter(function (pt) {
                        return !pt.artNo.startsWith("devMode_");
                    })
                }
            }
        }else{
            self.artFittings = Article.registeredFittings(art.artFittings);
            self.artPropTrans = Article.registeredPropTrans(art.artPropTrans);
            self.artPoEquipment = Article.registeredPoEquipment(art.artPoEquipment);
            self.artShoppingCartArticles = Article.registeredShoppingCartArticles(art.artShoppingCartArticles);
        }
 
        //ArtInfoTexte zuordnen
        var artInfoTextCatById = buildIndexMap(definedArtInfoTextCategories, "id"); // O(1)-Lookup statt .find() je Kategorie
        art.ArtInfoCategories.forEach(function (tmpCat) {
            var foundCategory = artInfoTextCatById["$" + tmpCat];
            if (foundCategory) {
                if (foundCategory.priority === 3000) {
                    //Wenn Prio 3000 dann auch im Filter anzegien
                    self.artCategories.push(foundCategory)
                }
                self.artInfoTexts.push(foundCategory)
            };
        });
 
        //Artikelkategorien zuordnen
        var artHasSperateCat = false;
        var definedCatById = buildIndexMap(definedCategories, "id"); // O(1)-Lookup statt .find() in der (grossen) Kategorienliste je Kategorie
        art.ArtCategories.forEach(function (tmpCat) {
            //Wenn die Artikelkategorie in der Separierliste drin ist
            if (tmpCat === separatelist.cat) {
                if (separatelist.typ === "exclude") {
                    //Wenn die Kategorie
                    self.hideArticle = true;
                } else {
                    artHasSperateCat = true;
                }
            }
            var foundCategory = definedCatById["$" + tmpCat];
 
            if (foundCategory) self.artCategories.push(foundCategory);
        });
        if (separatelist.typ === "include") {
            if (artHasSperateCat === false) {
                self.hideArticle = true;
            }
        }
    }
}
 
Article.prototype.isFitting = function () {
    return this.insertType === "A";
}
 
Article.prototype.isPropTrans = function () {
    return this.insertType === "P" && this.vPlacerId === "";
}
 
Article.prototype.getArtText = function (showAdditionalText) {
    return this.artText;
    // return dh_artikeltext_get(this.artNo, currentProg, currentManu, showAdditionalText);
}
 
Article.prototype.getArtTextLong = function () {
    return this.artTextLong;
    // return dh_artikeltext_get(this.artNo, currentProg, currentManu, showAdditionalText);
}
 
Article.prototype.getCatText = function () {
    var text = "";
    this.artCategories.forEach(function (cat) {
        text += cat.name;
    });
    return text;
}
 
Article.prototype.imgURL = function () {
    return this.imgPath;
};
 
 
Article.checkPropTransByCfg = function (ptId, ArtPropsToHide, ArtPropsToShow) {
    if (ArtPropsToShow.length > 0) {
        if (ArtPropsToShow.indexOf(ptId) > -1) {
            return true;
        } else {
            return false;
        }
    } else if (ArtPropsToHide.length > 0) {
        if (ArtPropsToHide.indexOf(ptId) === -1) {
            return true;
        } else {
            return false;
        }
    }
    return true;
};
 
Article.checkFittingsByCfg = function (fittingArtNr, ArtPropsToHide, ArtPropsToShow) {
    if (ArtPropsToShow.length > 0) {
        if (ArtPropsToShow.indexOf(fittingArtNr) > -1) {
            return true
        } else {
            return false;
        }
    } else if (ArtPropsToHide.length > 0) {
        if (ArtPropsToHide.indexOf(fittingArtNr) === -1) {
            return true;
        } else {
            return false;
        }
    }
    return true;
};
 
Article.registeredPropTrans = function (propTransString) {
    var ret = [];
    for (var index = 0; index < propTransString.length; index++) {
        ret.push(new ArticlePropertyTrans(propTransString[index]));
    }
    return ret;
};
 
Article.registeredShoppingCartArticles = function (shoppingCartString) {
    var ret = [];
    for (var index = 0; index < shoppingCartString.length; index++) {
        ret.push(new ArticleShoppingCart(shoppingCartString[index]));
    }
    return ret;
};
 
Article.registeredFittings = function (FittingString) {
    var ret = [];
    for (var index = 0; index < FittingString.length; index++) {        
        ret.push(new ArticleFitting(FittingString[index]));
    }
    return ret;
};
 
Article.registeredPoEquipment = function (PoEquipmentString) {
    var ret = [];
    for (var index = 0; index < PoEquipmentString.length; index++) {
        ret.push(new ArticlePoEquipment(PoEquipmentString[index]));
    }
    return ret;
};
 
 
Article.formatDimension = function (value) {
    return value.toFixed(1).replace(".", ",");
};