Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Using a file chooser instead of scanning the local drives for file import. Usability improved 100-fold, BUT this required a lot of refactoring. Will probably be dealing with lurking bugs for a bit before this milestone can be released (and will need to be released in lock-step with the project file issue adapt-it#539).
  • Loading branch information
eb1 committed Dec 20, 2023
1 parent 3ff5b1c commit 5d05564
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 275 deletions.
301 changes: 112 additions & 189 deletions www/js/views/DocumentViews.js

Large diffs are not rendered by default.

68 changes: 2 additions & 66 deletions www/js/views/ProjectViews.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,81 +358,17 @@ define(function (require) {
// - For browsers, uses the html <input type=file> element to allow the user
// to select an .aic file from the local PC.
onShow: function () {
$("#selFile").attr("accept", ".aic");
$("#selFile").removeAttr("multiple");
$("#title").html(i18n.t('view.lblCopyProject'));
$(".topcoat-progress-bar").hide();
$("#lblDirections").html(i18n.t('view.dscCopyProjInstructions'));
// cheater way to tell if running on mobile device
if (device && (device.platform !== "browser")) {
// running on device -- use cordova file plugin to select file
$("#browserGroup").hide();
$("#mobileSelect").html(Handlebars.compile(tplLoadingPleaseWait));
var DirsRemaining = window.Application.localURLs.length;
var index = 0;
var i;
var statusStr = "";
var addFileEntry = function (entry) {
var dirReader = entry.createReader();
dirReader.readEntries(
function (entries) {
var fileStr = "";
var i;
for (i = 0; i < entries.length; i++) {
if (entries[i].isDirectory === true) {
// Recursive -- call back into this subdirectory
DirsRemaining++;
addFileEntry(entries[i]);
} else {
if (entries[i].name.toLowerCase().indexOf(".aic") > 0) {
fileList[index] = entries[i].toURL();
fileStr += "<li class='topcoat-list__item' id=" + index + ">" + entries[i].fullPath + "<span class='chevron'></span></li>";
index++;
}
}
}
statusStr += fileStr;
DirsRemaining--;
if (DirsRemaining <= 0) {
if (statusStr.length > 0) {
$("#mobileSelect").html("<div class='wizard-instructions'>" + i18n.t('view.dscCopyProjInstructions') + "</div><div class='topcoat-list__container chapter-list'><ul class='topcoat-list__container chapter-list'>" + statusStr + "</ul></div>");
$("#OK").attr("disabled", true);
} else {
// nothing to select -- inform the user
$("#status").html(i18n.t("view.dscNoDocumentsFound"));
if ($("#loading").length) {
$("#loading").hide();
$("#waiting").hide();
$("#OK").show();
}
$("#OK").removeAttr("disabled");
}
}
},
function (error) {
console.log("readEntries error: " + error.code);
statusStr += "<p>readEntries error: " + error.code + "</p>";
}
);
};
var addError = function (error) {
// log the error and continue processing
console.log("getDirectory error: " + error.code);
DirsRemaining--;
};
for (i = 0; i < window.Application.localURLs.length; i++) {
if (window.Application.localURLs[i] === null || window.Application.localURLs[i].length === 0) {
DirsRemaining--;
continue; // skip blank / non-existent paths for this platform
}
window.resolveLocalFileSystemURL(window.Application.localURLs[i], addFileEntry, addError);
}
// running on device -- use cordova chooser plugin to select file
$("#browserSelect").hide();
} else {
// running in browser -- use html <input> to select file
$("#mobileSelect").hide();
$("#btnClipboard").hide(); // for now, no clipboard .aic import for the browser
}
$("#OK").attr("disabled", true);
}
}),

Expand Down
4 changes: 2 additions & 2 deletions www/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
"dscErrCannotFindChapter": "cannot find chapter number.",
"dscErrImportFirstChapterFirst": "this is a collaboration document; please import the first chapter before importing this chapter.",
"dscNoDocumentsFound": "No available files found on device. Please copy files onto the device and try again.",
"lblSelect": "Select Files",
"lblSelect": "Select File",
"ttlReset": "Reset Adapt It Mobile",
"dscReset": "WARNING: this will clear all documents and projects, as well as the Knowledge Base. Are you sure you want to reset Adapt It Mobile?",
"dscAdaptComplete": "Adaptation of __chapter__ complete.",
Expand Down Expand Up @@ -279,7 +279,7 @@
"lblPortion": "(portion)",
"dscBookName": "Here is a suggested book name for this document. You can keep this name, or change it to something more meaningful.",
"lblBookName": "Book Name:",
"lblCopyClipboardText": "Clipboard text...",
"lblCopyClipboardText": "Import Clipboard text",
"lblText": "Text",
"lblShowPreviewBtn": "Show Preview Button",
"lblShowPreview": "Show Preview",
Expand Down
2 changes: 1 addition & 1 deletion www/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
"dscErrCannotFindChapter": "ne peut pas trouver le numéro de chapitre.",
"dscErrImportFirstChapterFirst": "il s'agit d'un document de collaboration; importe le premier chapitre avant d'importer ce chapitre.",
"dscNoDocumentsFound": "Aucun fichier disponible trouvé sur l'appareil. Se il vous plaît copier des fichiers sur le périphérique et réessayez.",
"lblSelect": "Sélectionnez documents",
"lblSelect": "Sélectionnez document",
"ttlReset": "Réinitialiser Adapt It Mobile",
"dscReset": "AVERTISSEMENT: ce qui effacera tous les documents et de projets, ainsi que la Base de Connaissances. Etes-vous sûr que vous voulez réinitialiser Adapt It Mobile?",
"dscAdaptComplete": "Traduction de __chapter__ est maintenant terminée.",
Expand Down
2 changes: 1 addition & 1 deletion www/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
"dscErrCannotFindChapter": "Não é possível encontrar informações do capítulo.",
"dscErrImportFirstChapterFirst": "este é um documento de colaboração; importe o primeiro capítulo antes de importar este capítulo.",
"dscNoDocumentsFound": "Nenhum arquivo disponível encontrado no dispositivo. Copie os arquivos para o dispositivo e tente novamente.",
"lblSelect": "Selecionar arquivos",
"lblSelect": "Selecionar arquivo",
"ttlReset": "Restabelecer Adapt It Mobile",
"dscReset": "AVISO: isso limpará todos os documentos e projetos, bem como a Base de Conhecimento. Você tem certeza?",
"dscAdaptComplete": "Adaptação de __chapter__ completo.",
Expand Down
24 changes: 15 additions & 9 deletions www/tpl/CopyOrImport.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{! CopyOrImport.html
Template for rendering the Copy Project and Import Documents pages.
Template for rendering the Copy Project and Import Documents pages. Includes selection buttons
for both browser (using input type=file) and mobile (regular button w/cordova chooser plugin logic in js files)
Used by ProjectViews.js and DocumentViews.js.
}}

Expand All @@ -19,13 +20,18 @@ <h1 class="topcoat-navigation-bar__title bg-lightblue" id="title"></h1>
</div>
</div>
<div class="scroller-notb">
<div id="mobileSelect"></div>
<div class="control-group" id="browserGroup">
<div class="control-row" id="lblDirections"></div>
<div class="control-row full" id="status"></div>
<div id="WizardSteps">
<div id="browserSelect" style="display:inline-block"><label for="selFile" class="topcoat-button">{{t 'view.lblSelect'}}</label><input type="file" value="" id="selFile" multiple><button class="topcoat-button" id="btnClipboard">{{t 'view.lblCopyClipboardText'}}</button></div>
<button class="topcoat-button" id="OK">{{t 'view.lblOK'}}</button>
<ul id="selectControls" class='topcoat-list__container chapter-list'>
<li class="topcoat-list__item"><a class="big-link" id="btnClipboard" title="{{t 'view.lblCopyClipboardText'}}"><span class="btn-clipboard"></span>{{ t 'view.lblCopyClipboardText'}}<span class="chevron"></span></a></li>
<li class="topcoat-list__item" id="mobileSelect" ><a class="big-link" id="btnBrowse" title="{{ t 'view.lblSelect'}}"><span class="btn-file"></span>{{ t 'view.lblSelect'}}<span class="chevron"></span></a></li>
<li class="topcoat-list__item" id="browserSelect"><a class="big-link" title="{{ t 'view.lblSelect'}}"><span class="btn-file"></span><label for="selFile" class="topcoat-button">{{t 'view.lblSelect'}}</label><input type="file" value="" id="selFile" multiple><span class="chevron"></span></a></li>
</ul>
<div class="control-group" id="verifyNameControls">
<div class="control-row" id="lblDirections"></div>
<div class="control-row" id="lblVerify">{{ t 'view.dscBookName'}}</div>
<div class="control-row"><label for="BookName">{{ t 'view.lblBookName'}}</label><input type="text" id="BookName" class="topcoat-text-input full"></div>
<div id="OKCancelButtons" style="margin-top: 1em;">
<button class="topcoat-button" id="OK"><span id="lblOK">{{t 'view.lblOK'}}</span></button>
</div>
</div>
</div>
<div id="LoadingStatus"></div>
</div>
7 changes: 0 additions & 7 deletions www/tpl/ImportVerify.html

This file was deleted.

0 comments on commit 5d05564

Please sign in to comment.