From 33dd0e7f1d537f01d16f966136770b8bc30f9388 Mon Sep 17 00:00:00 2001 From: Erik Brommers <1458944+eb1@users.noreply.github.com> Date: Mon, 16 Sep 2024 17:06:49 -0700 Subject: [PATCH] Work on #598 Add URLs for each of the settings, so that the Back functionality is consistent. --- www/js/Application.js | 9 ++++ www/js/router.js | 1 + www/js/views/ProjectViews.js | 91 ++++++++---------------------------- www/tpl/EditProject.html | 22 ++++----- www/tpl/TargetUnitList.html | 2 +- 5 files changed, 42 insertions(+), 83 deletions(-) diff --git a/www/js/Application.js b/www/js/Application.js index 2b068106..e9d4f8e4 100755 --- a/www/js/Application.js +++ b/www/js/Application.js @@ -405,6 +405,15 @@ define(function (require) { window.Application.main.show(new ProjectViews.EditProjectView({model: proj[0]})); } }, + editProjectPage: function (id, page) { + // edit the selected project + var proj = this.ProjectList.where({projectid: id}); + var projView = new ProjectViews.EditProjectView({model: proj[0]}); + if (proj !== null) { + window.Application.main.show(projView); + projView.ShowView(parseInt(page, 10)); + } + }, // Copy project view copyProject: function () { var proj = new projModel.Project(); diff --git a/www/js/router.js b/www/js/router.js index 0bec980d..3e5fe9c3 100755 --- a/www/js/router.js +++ b/www/js/router.js @@ -17,6 +17,7 @@ define(function (require) { "copy": "copyProject", // #copy "project": "newProject", // #project "project/:id": "editProject", // #project/projectID + "project/:id/:page": "editProjectPage", // #project/projectID/page number (detail view for edit project) "search/:id": "lookupChapter", // #search/projectID "kb/:id": "editKB", // #kb/projectID (KB editor) "tu": "newTU", // #tu (create a new TU) diff --git a/www/js/views/ProjectViews.js b/www/js/views/ProjectViews.js index 96f9fc26..37b6c762 100644 --- a/www/js/views/ProjectViews.js +++ b/www/js/views/ProjectViews.js @@ -1123,17 +1123,7 @@ define(function (require) { 'change': 'render' }, events: { - "click #EditorUIPrefs": "OnEditorUIPrefs", - "click #CurrentProject": "OnCurrentProject", "click #KBEditor": "OnKBEditor", - "click #SourceLanguage": "OnEditSourceLanguage", - "click #TargetLanguage": "OnEditTargetLanguage", - "click #sourceFont": "OnEditSourceFont", - "click #targetFont": "OnEditTargetFont", - "click #navFont": "OnEditNavFont", - "click #Punctuation": "OnEditPunctuation", - "click #Cases": "OnEditCases", - "click #Filtering": "OnEditFiltering", "focus #LanguageName": "onFocusLanguageName", "keydown #LanguageName": "onKeydownLanguageName", "focus #LanguageVariant": "onFocusLanguageVariant", @@ -1151,17 +1141,10 @@ define(function (require) { "click #Cancel": "OnCancel", "click #OK": "OnOK" }, - OnEditorUIPrefs: function () { - step = 9; - this.ShowView(step); - }, - OnCurrentProject: function () { - step = 10; - this.ShowView(step); - }, OnKBEditor: function () { // KB editor is on a separate screen; tell the application to display it - window.Application.editKB(window.Application.currentProject.get("projectid")); + // URL is: kb/:projectid + window.Application.router.navigate("kb/" + window.Application.currentProject.get("projectid"), {trigger: true}); }, onFocusLanguageName: function (event) { window.Application.scrollIntoViewCenter(event.currentTarget); @@ -1252,63 +1235,27 @@ define(function (require) { OnClickCustomFilters: function (event) { currentView.onClickCustomFilters(event); }, - OnEditSourceLanguage: function () { - step = 1; - this.ShowView(step); - }, - OnEditTargetLanguage: function () { - step = 2; - this.ShowView(step); - }, - OnEditSourceFont: function () { - step = 3; - this.ShowView(step); - }, - OnEditTargetFont: function () { - step = 4; - this.ShowView(step); - }, - OnEditNavFont: function () { - step = 5; - this.ShowView(step); - }, - OnEditPunctuation: function () { - step = 6; - this.ShowView(step); - }, - OnEditCases: function () { - step = 7; - this.ShowView(step); - }, - OnEditFiltering: function () { - step = 8; - this.ShowView(step); - }, OnCancel: function () { - // just display the project settings list (don't save) - $("#WizStepTitle").hide(); - $("#StepInstructions").addClass("hide"); - $("#tbBottom").addClass("hide"); - $('#ProjectItems').removeClass("hide"); - $("#StepTitle").html(i18n.t('view.lblProjectSettings')); - $(".container").attr("style", "height: calc(100% - 70px);"); - $("#editor").removeClass("scroller-bottom-tb"); - $("#editor").addClass("scroller-notb"); - this.removeRegion("container"); + // just go back (don't save) + if (window.history.length > 1) { + // there actually is a history -- go back + window.history.back(); + } else { + // no history (import link from outside app) -- just go home + window.location.replace(""); + } }, OnOK: function () { // save the info from the current step this.UpdateProject(step); - // show / hide the appropriate UI elements - $("#WizStepTitle").hide(); - $("#StepInstructions").addClass("hide"); - $("#tbBottom").addClass("hide"); - $('#ProjectItems').removeClass("hide"); - $("#StepTitle").html(i18n.t('view.lblProjectSettings')); - $(".container").attr("style", "height: calc(100% - 70px);"); - $("#editor").removeClass("scroller-bottom-tb"); - $("#editor").addClass("scroller-notb"); - this.removeRegion("container"); + // go back + if (window.history.length > 1) { + // there actually is a history -- go back + window.history.back(); + } else { + // no history (import link from outside app) -- just go home + window.location.replace(""); + } }, UpdateProject: function (step) { @@ -1465,6 +1412,8 @@ define(function (require) { this.addRegions({ container: "#StepContainer" }); + // set the current step # + step = number; // hide the project list items $("#WizStepTitle").show(); $("#StepInstructions").removeClass("hide"); diff --git a/www/tpl/EditProject.html b/www/tpl/EditProject.html index 013e52eb..758adfbd 100644 --- a/www/tpl/EditProject.html +++ b/www/tpl/EditProject.html @@ -3,7 +3,7 @@ }}