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(".", ",");
|
};
|