Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:unfoldingWord-dev/ts-desktop int…
Browse files Browse the repository at this point in the history
…o develop
  • Loading branch information
da1nerd committed Feb 22, 2017
2 parents 23ca272 + 4249f78 commit 02131cc
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 267 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "translationstudio",
"productName": "translationStudio",
"version": "11.1.0",
"build": "112",
"build": "113",
"description": "A utility for translating the Bible and biblical content into any language.",
"keywords": [],
"homepage": "https://github.com/unfoldingWord-dev/ts-desktop",
Expand Down
3 changes: 2 additions & 1 deletion src/elements/ts-translate/ts-chunk-mode/ts-chunk-mode.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@

mythis.timer = setTimeout(function() {
mythis.setheights();
}, 300);
}, 100);
},

setheights: function () {
Expand Down Expand Up @@ -166,6 +166,7 @@
setTimeout(function() {
contain.classList.remove("movein");
mythis.setheights();
mythis.fire('iron-signal', {name: 'closeloading'});
}, 500);
}, 500);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@

mythis.timer = setTimeout(function() {
mythis.setheights();
}, 300);
}, 100);
},

setheights: function () {
Expand Down Expand Up @@ -167,6 +167,7 @@
setTimeout(function() {
contain.classList.remove("movein");
mythis.setheights();
mythis.fire('iron-signal', {name: 'closeloading'});
}, 500);
}, 500);
},
Expand Down
1 change: 1 addition & 0 deletions src/elements/ts-translate/ts-nosource-mode.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
contain.classList.add("movein");
setTimeout(function() {
contain.classList.remove("movein");
mythis.fire('iron-signal', {name: 'closeloading'});
}, 500);
}, 500);
},
Expand Down
3 changes: 2 additions & 1 deletion src/elements/ts-translate/ts-read-mode/ts-read-mode.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@

mythis.timer = setTimeout(function() {
mythis.setheights();
}, 300);
}, 100);
},

setheights: function () {
Expand Down Expand Up @@ -162,6 +162,7 @@
setTimeout(function() {
contain.classList.remove("movein");
mythis.setheights();
mythis.fire('iron-signal', {name: 'closeloading'});
}, 500);
}, 500);
},
Expand Down
6 changes: 5 additions & 1 deletion src/elements/ts-translate/ts-resource/ts-resource-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
color: var(--primary-text-color);
}

.click {
cursor: pointer;
}

</style>

<template>
Expand All @@ -37,7 +41,7 @@
</template>
</template>
<template is="dom-if" if="{{!resource.array}}">
<div id="textholder"></div>
<div id="textholder"><span class="click" on-tap="renderresource">Click to display text</span></div>
</template>

</template>
Expand Down
3 changes: 2 additions & 1 deletion src/elements/ts-translate/ts-review-mode/ts-review-mode.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
mythis.timer = setTimeout(function() {
mythis.setheights();
mythis.fire('iron-signal', {name: 'passivesearch'});
}, 300);
}, 100);
},

setheights: function () {
Expand Down Expand Up @@ -221,6 +221,7 @@
setTimeout(function() {
contain.classList.remove("movein");
mythis.setheights();
mythis.fire('iron-signal', {name: 'closeloading'});
}, 500);
}, 500);
},
Expand Down
62 changes: 29 additions & 33 deletions src/elements/ts-translate/ts-translate.html
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,8 @@ <h2>Note</h2>
mythis.set('options.loading', true);
mythis.fire('iron-signal', {name: 'openloading'});

mythis.savestate();

App.dataManager.getSourcesByProject(projectmeta.project.id)
.then(function (sources) {
if (projectmeta.resource.id !== "udb") {
Expand Down Expand Up @@ -783,7 +785,9 @@ <h2>Note</h2>
mythis.set('currentproject.rawdata.main', translation);
mythis.createchunks();
mythis.createchapters();
mythis.fire('iron-signal', {name: 'closeloading'});
if (!full) {
mythis.fire('iron-signal', {name: 'closeloading'});
}
mythis.forceResize();
mythis.setlocation();
mythis.fire('iron-signal', {name: 'passivesearch'});
Expand Down Expand Up @@ -1213,18 +1217,12 @@ <h2>Note</h2>
setmodestate: function () {
var mythis = this;
var projectmeta = this.currentproject.projectmeta;
var sources = projectmeta.source_translations;
var key = projectmeta.unique_id;
var index = App.configurator.getValue(key + "-index");
var chapter = App.configurator.getValue(key + "-chapter");
var selected = App.configurator.getValue(key + "-selected");
var bemode = App.configurator.getUserSetting('bemode');
var typeclass = projectmeta.project_type_class;

if (selected === 2 && !bemode) {
selected = 3;
}

if (chapter > 0) {
mythis.set('modestatus.chapter', chapter);
}
Expand All @@ -1236,20 +1234,6 @@ <h2>Note</h2>
} else {
mythis.set('modestatus.lastmode', 3);
}

if ((sources !== undefined && sources.length !== 0) || typeclass === "extant") {
setTimeout(function() {
if (selected > 0) {
mythis.set('selected', selected);
} else {
if (typeclass === "standard" && bemode) {
mythis.set('selected', 1);
} else {
mythis.set('selected', 3);
}
}
}, 500);
}
},

checksources: function () {
Expand All @@ -1259,18 +1243,32 @@ <h2>Note</h2>
var lastmode = this.modestatus.lastmode;
var selected = this.selected;
var typeclass = projectmeta.project_type_class;
var key = projectmeta.unique_id;
var previous = App.configurator.getValue(key + "-selected");
var bemode = App.configurator.getUserSetting('bemode');
var gotomode = 3;

if (selected === 4) {
if (sources !== undefined && sources.length !== 0) {
mythis.set('selected', lastmode);
}
} else {
if ((sources === undefined || sources.length === 0) && typeclass !== "extant") {
setTimeout(function() {
mythis.set('selected', 4);
}, 500);
}
if (previous === 2 && !bemode) {
previous = 3;
}

if ((sources === undefined || sources.length === 0) && typeclass !== "extant") {
gotomode = 4;
} else if (selected === 4) {
gotomode = lastmode;
} else if (previous > 0) {
gotomode = previous;
} else if (typeclass === "standard" && bemode) {
gotomode = 1;
}

setTimeout(function() {
if (selected === gotomode) {
mythis.fire('iron-signal', {name: 'closeloading'});
} else {
mythis.set('selected', gotomode);
}
}, 500);
},

getlocation: function () {
Expand Down Expand Up @@ -1341,8 +1339,6 @@ <h2>Note</h2>
mythis.starttimers();
}, 500);
}

mythis.fire('iron-signal', {name: 'closeloading'});
}, 500);
},

Expand Down
49 changes: 32 additions & 17 deletions src/js/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,21 +273,25 @@ function DataManager(db, resourceDir, apiURL, sourceDir) {
var toc = this.parseYaml(container, "toc.yml");
var sorted = [];

toc.forEach (function (chapter) {
chapter.chunks.forEach (function (chunk) {
var results = frames.filter(function (item) {
return item.chapter === chapter.chapter && item.chunk === chunk;
});
if (toc) {
toc.forEach (function (chapter) {
chapter.chunks.forEach (function (chunk) {
var results = frames.filter(function (item) {
return item.chapter === chapter.chapter && item.chunk === chunk;
});

if (results.length) {
sorted.push(results[0]);
} else {
console.log("Cannot find data for:", container, chapter, chunk);
}
if (results.length) {
sorted.push(results[0]);
} else {
console.log("Cannot find data for:", container, chapter, chunk);
}
});
});
});

return sorted;
return sorted;
} else {
return frames;
}
},

getProjectName: function (id) {
Expand Down Expand Up @@ -373,8 +377,13 @@ function DataManager(db, resourceDir, apiURL, sourceDir) {

getSourceWords: function (source) {
var container = source.language_id + "_" + source.project_id + "_" + source.resource_id;
var words = this.parseYaml(container, "config.yml");

return this.parseYaml(container, "config.yml").content;
if (words && words.content) {
return words.content;
} else {
return [];
}
},

parseHelps: function (content) {
Expand All @@ -391,8 +400,14 @@ function DataManager(db, resourceDir, apiURL, sourceDir) {

parseYaml: function (container, filename) {
var filepath = path.join(resourceDir, container, "content", filename);
var file = fs.readFileSync(filepath, "utf8");
return yaml.load(file);

try {
var file = fs.readFileSync(filepath, "utf8");
return yaml.load(file);
} catch (e) {
console.log("Cannot read file:", filepath);
return null;
}
},

getRelatedWords: function (source, slug) {
Expand All @@ -404,7 +419,7 @@ function DataManager(db, resourceDir, apiURL, sourceDir) {
var container = "en_" + dict + "_tw";
var list = this.parseYaml(container, "config.yml");

if (list[slug] && list[slug]["see_also"]) {
if (list && list[slug] && list[slug]["see_also"]) {
var slugs = list[slug]["see_also"];

return slugs.map(function (item) {
Expand Down Expand Up @@ -448,7 +463,7 @@ function DataManager(db, resourceDir, apiURL, sourceDir) {
var container = "en_" + dict + "_tw";
var list = this.parseYaml(container, "config.yml");

if (list[slug] && list[slug]["examples"]) {
if (list && list[slug] && list[slug]["examples"]) {
var references = list[slug]["examples"];

return references.map(function (item) {
Expand Down
12 changes: 0 additions & 12 deletions unit_tests/configurator/configurator.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,6 @@
});
});

//the below test doesn't work right

/*describe('@PurgeValues', function () {
it('should purge all user-set values', function () {
var configurator = getConfigurator();
configurator.setValue('willpurge', 'user set');
configurator.setValue('new setting', 'test this');
configurator.purgeValues();
assert.equal(configurator.getValue('willpurge'), 'this is the default');
assert.equal(configurator.getValue('new setting'), '');
});
});*/
});

})();
32 changes: 0 additions & 32 deletions unit_tests/database/database.js

This file was deleted.

Loading

0 comments on commit 02131cc

Please sign in to comment.