Skip to content

Commit

Permalink
Merge pull request #9 from RV1989/bug-fix-hoist
Browse files Browse the repository at this point in the history
Bug fix hoist
  • Loading branch information
RV1989 authored Oct 12, 2018
2 parents 4814d8c + 949c1a2 commit 7cd374e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "clean-io-app",
"version": "0.1.6",
"version": "0.1.7",
"author": "RV1989",
"description": "clean up io list for tia portal",
"license": null,
Expand Down
42 changes: 31 additions & 11 deletions src/renderer/store/utils/ioExcel.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ const changeText = function (obj) {
(textToChange.match(/\//gi) && !textToChange.match(/\/1\s|\/1$/gi))
) {
let dummyNumberRegex = /(?:\/)(\d*)/gi;
let dummyNumber = dummyNumberRegex.exec(textToChange)[1];
let regexRes = dummyNumberRegex.exec(textToChange)
let dummyNumber = ''
if (regexRes){dummyNumber = regexRes[1]}
obj.text = "dummy" + objNr.join("-") + "-" + dummyNumber + "Thermal";

obj.changed = true;
Expand All @@ -178,7 +180,9 @@ const changeText = function (obj) {
(textToChange.match(/\//gi) && !textToChange.match(/\/1\s|\/1$/gi))
) {
let dummyNumberRegex = /(?:\/)(\d*)/gi;
let dummyNumber = dummyNumberRegex.exec(textToChange)[1];
let regexRes = dummyNumberRegex.exec(textToChange)
let dummyNumber =''
if (regexRes){dummyNumber = regexRes[1]}
obj.text = "dummy" + objNr.join("-") +"-" + dummyNumber + "MainSwitch";

obj.changed = true;
Expand Down Expand Up @@ -292,7 +296,9 @@ const changeText = function (obj) {
textToChange.match(/Therm/gi)
) {
let idRegex = /(\d{5})(?:\/)(\d*)/gi;
let id = idRegex.exec(textToChange)[2];
let id = ''
let regexRes = idRegex.exec(textToChange)
if (regexRes){id = regexRes[2]}

obj.text = "hoist" + objNr.join("-") + "-" + id + "Thermal";

Expand All @@ -307,7 +313,9 @@ const changeText = function (obj) {

) {
let idRegex = /(\d{5})(?:\/)(\d*)/gi;
let id = idRegex.exec(textToChange)[2];
let id = ''
let regexRes = idRegex.exec(textToChange)
if (regexRes){id = regexRes[2]}
obj.text = "hoist" + objNr.join("-") + "-" + id + "MainSwitch";

obj.changed = true;
Expand All @@ -320,9 +328,10 @@ const changeText = function (obj) {
textToChange.match(/haut/gi)
) {
let idRegex = /(?:\/)(\d*)/gi;
let id = idRegex.exec(textToChange)[1];
let regexRes = idRegex.exec(textToChange)
let id = ''
if (regexRes){id = regexRes[1]}
obj.text = "hoist" + objNr.join("-") + "-" + id + "DetectionUp";

obj.changed = true;
}

Expand All @@ -333,7 +342,9 @@ const changeText = function (obj) {
textToChange.match(/bas/gi)
) {
let idRegex = /(?:\/)(\d*)/gi;
let id = idRegex.exec(textToChange)[1];
let regexRes = idRegex.exec(textToChange)
let id = ''
if (regexRes){id = regexRes[1]}
obj.text = "hoist" + objNr.join("-") + "-" + id + "DetectionDown";

obj.changed = true;
Expand All @@ -347,7 +358,9 @@ const changeText = function (obj) {
!textToChange.match(/desc/gi)
) {
let idRegex = /(?:\/)(\d*)/gi;
let id = idRegex.exec(textToChange)[1];
let regexRes = idRegex.exec(textToChange)
let id = ''
if (regexRes){id = regexRes[1]}
obj.text = "hoist" + objNr.join("-") + "-" + id + "MovementUp";

obj.changed = true;
Expand All @@ -361,7 +374,9 @@ const changeText = function (obj) {
textToChange.match(/desc/gi)
) {
let idRegex = /(?:\/)(\d*)/gi;
let id = idRegex.exec(textToChange)[1];
let id = ''
let regexRes = idRegex.exec(textToChange)
if (regexRes){id = regexRes[1]}
obj.text = "hoist" + objNr.join("_") + "-" + id + "MovementDown";

obj.changed = true;
Expand Down Expand Up @@ -478,8 +493,13 @@ const readExcel = function (dir) {
obj.capteur = cellCapteur.v.trim();
obj.comment += " " + obj.capteur;
}
obj = changeText(obj);
ioList.push(obj);
try {
obj = changeText(obj);
ioList.push(obj);
} catch (error) {
console.log(error)
}

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/ioExcel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ describe('changeText', () => {
expect(changeText(obj).text).to.equal('hoist02020-2MovementUp')
})

it('should return Hoist movement up', () => {
it('should return Hoist movement down', () => {
let obj = {}
obj.text = 'DESCENDRE ROULEAU CONVOYEUR 02020/2'
expect(changeText(obj).text).to.equal('hoist02020-2MovementDown')
Expand Down

0 comments on commit 7cd374e

Please sign in to comment.