1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-24 06:59:52 +01:00

vueui: model add full-id property that include string id of parents+self

This commit is contained in:
Ivan Velev 2021-09-20 12:13:06 -07:00
parent 9c52d69921
commit dcd9e6cbe2

View File

@ -104,6 +104,7 @@ export class PywbSnapshot {
export function PywbPeriod(init) { export function PywbPeriod(init) {
this.type = init.type; this.type = init.type;
this.id = init.id; this.id = init.id;
this.fullId = ''; // full-id property that include string id of parents and self with a delimitor
this.childrenIds = {}; // allow for query by ID this.childrenIds = {}; // allow for query by ID
this.children = []; // allow for sequentiality / order this.children = []; // allow for sequentiality / order
@ -215,6 +216,7 @@ PywbPeriod.prototype.addChild = function(period) {
period.parent = this; period.parent = this;
this.childrenIds[period.id] = this.children.length; this.childrenIds[period.id] = this.children.length;
this.children.push(period); this.children.push(period);
period.initFullId();
return true; return true;
}; };
@ -352,10 +354,10 @@ PywbPeriod.prototype.setSnapshot = function(snap) {
* Return the "full" id, which includes all parents ID and self ID, delimited by a hyphen "-" * Return the "full" id, which includes all parents ID and self ID, delimited by a hyphen "-"
* @returns {string} * @returns {string}
*/ */
PywbPeriod.prototype.getFullId = function() { PywbPeriod.prototype.initFullId = function() {
const ids = this.getParents(true).map(p => p.id); const ids = this.getParents(true).map(p => p.id);
ids.push(this.id); ids.push(this.id);
return ids.join("-"); this.fullId = ids.join("-");
}; };
/** /**