UI: Dynamic window titles including URL
This commit is contained in:
@@ -312,4 +312,10 @@ export class CollectionsScene {
|
||||
}
|
||||
|
||||
is_transient() { return false; }
|
||||
|
||||
title_object() {
|
||||
if (this._principal_collection.displayname && this._principal_collection.displayname.length > 0)
|
||||
return this._principal_collection.displayname;
|
||||
else return this._user;
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@
|
||||
import { create_collection, edit_collection } from "../api/api.js";
|
||||
import { COLOR_RE } from "../constants.js";
|
||||
import { Collection, CollectionType } from "../models/collection.js";
|
||||
import { extract_title } from "../utils/collection_utils.js";
|
||||
import { collectionsCache } from "../utils/collections_cache.js";
|
||||
import { ErrorHandler } from "../utils/error.js";
|
||||
import { FormValidator, validate_color, validate_href } from "../utils/form_validator.js";
|
||||
@@ -224,4 +225,9 @@ export class CreateEditCollectionScene {
|
||||
this._create_edit_req = null;
|
||||
}
|
||||
}
|
||||
|
||||
title_object() {
|
||||
return extract_title(this._collection);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
import { Share, add_share_by_map, add_share_by_token, get_property_key, update_share_by_map, update_share_by_token } from "../api/sharing.js";
|
||||
import { CollectionType, Permission } from "../models/collection.js";
|
||||
import { extract_title } from "../utils/collection_utils.js";
|
||||
import { collectionsCache } from "../utils/collections_cache.js";
|
||||
import { ErrorHandler } from "../utils/error.js";
|
||||
import { FormValidator, validate_href, validate_non_empty, validate_not_empty_or_equals } from "../utils/form_validator.js";
|
||||
@@ -416,4 +417,9 @@ export class CreateEditShareScene {
|
||||
}
|
||||
|
||||
is_transient() { return false; }
|
||||
|
||||
title_object() {
|
||||
return extract_title(this._collection);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -153,4 +153,6 @@ export class DeleteConfirmationScene {
|
||||
this._delete_req = null;
|
||||
}
|
||||
}
|
||||
|
||||
title_object() { return ""; }
|
||||
}
|
||||
@@ -24,8 +24,8 @@ import { collectionsCache } from "../utils/collections_cache.js";
|
||||
import { ErrorHandler } from "../utils/error.js";
|
||||
import { get_element, get_element_by_id } from "../utils/misc.js";
|
||||
import { displayPermissionsOrConversion } from "../utils/permissions.js";
|
||||
import { Scene, pop_scene } from "./scene_manager.js";
|
||||
import { UrlTextHandler } from "../utils/url_text.js";
|
||||
import { Scene, pop_scene } from "./scene_manager.js";
|
||||
|
||||
/**
|
||||
* @implements {Scene}
|
||||
@@ -166,4 +166,6 @@ export class IncomingSharingScene {
|
||||
});
|
||||
this._nodes = [];
|
||||
}
|
||||
|
||||
title_object() { return ""; }
|
||||
}
|
||||
|
||||
@@ -37,4 +37,5 @@ export class LoadingScene {
|
||||
}
|
||||
release() { }
|
||||
is_transient() { return true; }
|
||||
title_object() { return "Loading..."}
|
||||
}
|
||||
@@ -196,4 +196,7 @@ export class LoginScene {
|
||||
}
|
||||
this._remove_logout();
|
||||
}
|
||||
|
||||
title_object() { return "Login" }
|
||||
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
reload_sharing_list,
|
||||
} from "../api/sharing.js";
|
||||
import { Collection, Permission } from "../models/collection.js";
|
||||
import { extract_title } from "../utils/collection_utils.js";
|
||||
|
||||
import { ErrorHandler } from "../utils/error.js";
|
||||
import { get_element, get_element_by_id } from "../utils/misc.js";
|
||||
@@ -126,6 +127,11 @@ export class ShareCollectionScene {
|
||||
}
|
||||
|
||||
is_transient() { return false; }
|
||||
|
||||
title_object() {
|
||||
return extract_title(this._collection);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -241,4 +241,6 @@ export class UploadCollectionScene {
|
||||
this._upload_req = null;
|
||||
}
|
||||
}
|
||||
|
||||
title_object() { return ""; }
|
||||
}
|
||||
@@ -19,6 +19,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { SERVER } from "../constants.js";
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
@@ -41,6 +43,9 @@ export class Scene {
|
||||
* @returns boolean
|
||||
*/
|
||||
is_transient() { return false; }
|
||||
|
||||
/** @returns str */
|
||||
title_object() { return ""; }
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +59,18 @@ let history_array = [];
|
||||
let current_history_index = -1;
|
||||
let is_navigating_history = false;
|
||||
|
||||
function update_window_title() {
|
||||
let title_parts = ["Radicale Web Interface", SERVER];
|
||||
|
||||
if (scene_stack.length > 0) {
|
||||
let title = scene_stack[scene_stack.length - 1].title_object();
|
||||
if (title) {
|
||||
title_parts.push(title);
|
||||
}
|
||||
}
|
||||
document.title = title_parts.join(" - ");
|
||||
}
|
||||
|
||||
function record_history() {
|
||||
if (is_navigating_history) return;
|
||||
|
||||
@@ -120,6 +137,7 @@ if (typeof window !== "undefined" && window.history) {
|
||||
}
|
||||
|
||||
current_history_index = new_index;
|
||||
update_window_title();
|
||||
} finally {
|
||||
is_navigating_history = false;
|
||||
}
|
||||
@@ -141,6 +159,7 @@ export function push_scene(scene) {
|
||||
scene_stack.push(scene);
|
||||
scene.show();
|
||||
record_history();
|
||||
update_window_title();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,6 +173,7 @@ function pop_and_release() {
|
||||
if (scene) {
|
||||
scene.release();
|
||||
}
|
||||
update_window_title();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,6 +188,7 @@ export function replace_scene(scene) {
|
||||
scene_stack.push(scene);
|
||||
scene.show();
|
||||
record_history();
|
||||
update_window_title();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,6 +204,7 @@ export function pop_scene() {
|
||||
scene_stack[scene_stack.length - 1].show();
|
||||
}
|
||||
record_history();
|
||||
update_window_title();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,6 +224,7 @@ export function pop_to_parent() {
|
||||
scene_stack[scene_stack.length - 1].show();
|
||||
}
|
||||
record_history();
|
||||
update_window_title();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,6 +245,7 @@ export function pop_to_root() {
|
||||
scene_stack[0].show(); // Ensure the root scene is visible
|
||||
}
|
||||
record_history();
|
||||
update_window_title();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user