Changeset - e27a45d2b90a
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 20 months ago 2023-05-18 02:08:19
drewp@bigasterisk.com
suppress some ts warnings on already-broken code
1 file changed with 22 insertions and 18 deletions:
0 comments (0 inline, 0 general)
light9/web/ResourceDisplay.ts
Show inline comments
 
@@ -5,24 +5,25 @@ import { NamedNode } from "n3";
 
// import { GraphChangedEvent } from "../../web/RdfdbSyncedGraph";
 
// import { runHandler } from "./GraphAwarePage";
 
import { Patch, patchContainsPreds, patchSizeSummary } from "./patch";
 
import { getTopGraph } from "./RdfdbSyncedGraph";
 
import { SyncedGraph } from "./SyncedGraph";
 
debug.enable("*");
 
const log = debug("device-el");
 
const RDFS_LABEL = new NamedNode("http://www.w3.org/2000/01/rdf-schema#label");
 

	
 
@customElement("resource-display")
 
export class ResourceDisplay extends LitElement {
 
  graph!: SyncedGraph;
 
  private renameTo?: string
 
  static styles = [
 
    css`
 
      :host {
 
        display: inline-block;
 
      }
 

	
 
      a.resource {
 
        color: inherit;
 
        text-decoration: none;
 
      }
 

	
 
      .resource {
 
@@ -134,37 +135,40 @@ export class ResourceDisplay extends Lit
 
  }
 

	
 
  setLabel(patch?: Patch) {
 
    if (patch && !patchContainsPreds(patch, [RDFS_LABEL])) {
 
      return;
 
    }
 
    const uri = this.realUri();
 
    this.label = this.graph.labelOrTail(uri);
 
  }
 

	
 
  onRename() {
 
    this.renameTo = this.label;
 
    this.shadowRoot.querySelector("#renameDialog").open();
 
    this.shadowRoot.querySelector("#renameTo").setSelectionRange(0, -1);
 
    throw new Error("fixme");
 
    // this.shadowRoot.querySelector("#renameDialog").open();
 
    // this.shadowRoot.querySelector("#renameTo")!.setSelectionRange(0, -1);
 
  }
 

	
 
  onRenameKey(ev) {
 
    if (ev.key == "Enter") {
 
      this.shadowRoot.querySelector("[dialog-confirm]").click();
 
    }
 
    if (ev.key == "Escape") {
 
      this.shadowRoot.querySelector("[dialog-dismiss]").click();
 
    }
 
  onRenameKey(ev: KeyboardEvent) {
 
    throw new Error("fixme");
 
    // if (ev.key == "Enter") {
 
    //   this.shadowRoot.querySelector("[dialog-confirm]").click();
 
    // }
 
    // if (ev.key == "Escape") {
 
    //   this.shadowRoot.querySelector("[dialog-dismiss]").click();
 
    // }
 
  }
 

	
 
  onRenameClosed() {
 
    var dialog = this.shadowRoot.querySelector("#renameDialog");
 
    if (dialog.closingReason.confirmed) {
 
      var label = this.graph.Uri("rdfs:label");
 
      var ctxs = this.graph.contextsWithPattern(this.uri, label, null);
 
      if (ctxs.length != 1) {
 
        throw new Error(`${ctxs.length} label stmts for ${this.uri.label}`);
 
      }
 
      this.graph.patchObject(typeof this.uri === "string" ? this.graph.Uri(this.uri) : this.uri, label, this.graph.Literal(this.renameTo), ctxs[0]);
 
    }
 
    throw new Error("fixme");
 
    // var dialog = this.shadowRoot.querySelector("#renameDialog");
 
    // if (dialog.closingReason.confirmed) {
 
    //   var label = this.graph.Uri("rdfs:label");
 
    //   var ctxs = this.graph.contextsWithPattern(this.uri, label, null);
 
    //   if (ctxs.length != 1) {
 
    //     throw new Error(`${ctxs.length} label stmts for ${this.uri.label}`);
 
    //   }
 
    //   this.graph.patchObject(typeof this.uri === "string" ? this.graph.Uri(this.uri) : this.uri, label, this.graph.Literal(this.renameTo), ctxs[0]);
 
    // }
 
  }
 
}
0 comments (0 inline, 0 general)